Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
7d70c1f8d7
108
README
108
README
@ -1,15 +1,15 @@
|
||||
The Powder Toy - May 2013
|
||||
The Powder Toy - June 2014
|
||||
|
||||
Get the latest version here: http://powdertoy.co.uk/Download.html
|
||||
Get the latest version here: http://powdertoy.co.uk/Download.html
|
||||
|
||||
To use online features such as saving, you need to register at: http://powdertoy.co.uk/Register.html
|
||||
|
||||
|
||||
Have you ever wanted to blow something up? Or maybe you always dreamt of operating an atomic power plant? Do you have a will to develop your own CPU? The Powder Toy lets you to do all of these, and even more!
|
||||
|
||||
The Powder Toy is a free physics sandbox game, which simulates air pressure and velocity, heat, gravity and a countless number of interactions between different substances! The game provides you with various building materials, liquids, gases and electronic components which can be used to construct complex machines, guns, bombs, realistic terrains and almost anything else. You can then mine them and watch cool explosions, add intricate wirings, play with little stickmen or operate your machine. You can browse and play thousands of different saves made by the community or upload your own <EFBFBD> we welcome your creations!
|
||||
The Powder Toy is a free physics sandbox game, which simulates air pressure and velocity, heat, gravity and a countless number of interactions between different substances! The game provides you with various building materials, liquids, gases and electronic components which can be used to construct complex machines, guns, bombs, realistic terrains and almost anything else. You can then mine them and watch cool explosions, add intricate wirings, play with little stickmen or operate your machine. You can browse and play thousands of different saves made by the community or upload your own - we welcome your creations!
|
||||
|
||||
There is a Lua API <EFBFBD> you can automate your work or even make plugins for the game. The Powder Toy is free and the source code is distributed under the GNU General Public License, so you can modify the game yourself or help with development. Tpt is compiled using scons.
|
||||
There is a Lua API - you can automate your work or even make plugins for the game. The Powder Toy is free and the source code is distributed under the GNU General Public License, so you can modify the game yourself or help with development. TPT is compiled using scons.
|
||||
|
||||
|
||||
Thanks:
|
||||
@ -42,48 +42,51 @@ Controls:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
|
||||
TAB Switch between circle/square/triangle brush
|
||||
Space Pause
|
||||
Q Quit
|
||||
Esc Quit
|
||||
Z Zoom
|
||||
S Save stamp (+ Ctrl when STK2 is out)
|
||||
L Load last saved stamp
|
||||
K Stamp library
|
||||
1-9 Set view mode
|
||||
P Save screenshot to .png
|
||||
F Pause and go to next frame
|
||||
G Increase grid size
|
||||
Shift + G Decrease grid size
|
||||
H Show/Hide HUD
|
||||
Ctrl + H Show intro text
|
||||
F1 Show intro text
|
||||
D Debug mode (+ Ctrl when STK2 is out)
|
||||
I Invert Pressure and Velocity map
|
||||
W Toggle gravity modes (+ Ctrl when STK2 is out)
|
||||
Y Toggle air modes
|
||||
Ctrl + B Toggle decorations on/off
|
||||
U Toggle ambient heat on/off
|
||||
Ctrl + I Install powder toy, for loading saves/stamps by double clicking
|
||||
~ Console
|
||||
= Reset pressure and velocity map
|
||||
Ctrl + = Reset Electricity
|
||||
[ Decrease brush size
|
||||
] Increase brush size
|
||||
Alt + [ Decrease brush size by 1
|
||||
Alt + ] Increase brush size by 1
|
||||
TAB Switch between circle/square/triangle brush
|
||||
Space Pause
|
||||
Q Quit
|
||||
Esc Quit
|
||||
Z Zoom
|
||||
S Save stamp (+ Ctrl when STK2 is out)
|
||||
L Load last saved stamp
|
||||
K Stamp library
|
||||
1-9 Set view mode
|
||||
P / F2 Save screenshot to .png
|
||||
E Bring up element search
|
||||
F Pause and go to next frame
|
||||
G Increase grid size
|
||||
Shift + G Decrease grid size
|
||||
H Show/Hide HUD
|
||||
Ctrl + H / F1 Show intro text
|
||||
D / F3 Debug mode (+ Ctrl when STK2 is out)
|
||||
I Invert Pressure and Velocity map
|
||||
W Toggle gravity modes (+ Ctrl when STK2 is out)
|
||||
Y Toggle air modes
|
||||
B Enter decoration editor menu
|
||||
Ctrl + B Toggle decorations on/off
|
||||
N Toggle Newtonian Gravity on/off
|
||||
U Toggle ambient heat on/off
|
||||
Ctrl + I Install powder toy, for loading saves/stamps by double clicking
|
||||
~ Console
|
||||
= Reset pressure and velocity map
|
||||
Ctrl + = Reset Electricity
|
||||
[ Decrease brush size
|
||||
] Increase brush size
|
||||
Alt + [ Decrease brush size by 1
|
||||
Alt + ] Increase brush size by 1
|
||||
|
||||
Ctrl + C/V/X Copy/Paste/Cut
|
||||
Ctrl + Z Undo
|
||||
Ctrl + Cursor drag Rectangle
|
||||
Shift + Cursor drag Line
|
||||
Middle click Sample element
|
||||
Alt + Left click Sample element
|
||||
Mouse scroll Change brush size
|
||||
Ctrl + Mouse scroll Change vertical brush size
|
||||
Shift + Mouse scroll Change horizontal brush size
|
||||
Shift + Ctrl + R Horizontal mirror for selected area
|
||||
Ctrl + R Rotate selected area counterclockwise
|
||||
Ctrl + C/V/X Copy/Paste/Cut
|
||||
Ctrl + Z Undo
|
||||
Ctrl + Cursor drag Rectangle
|
||||
Shift + Cursor drag Line
|
||||
Middle click Sample element
|
||||
Alt + Left click Sample element
|
||||
Mouse scroll Change brush size
|
||||
Ctrl + Mouse scroll Change vertical brush size
|
||||
Shift + Mouse scroll Change horizontal brush size
|
||||
Shift + R Horizontal mirror for selected area when pasting stamps
|
||||
Ctrl + Shift + R Vertical mirror for selected area when pasting stamps
|
||||
R Rotate selected area counterclockwise when pasting stamps
|
||||
|
||||
Only the left Ctrl, Shift, and Alt buttons are enabled to work, not the ones on the right
|
||||
|
||||
@ -91,11 +94,10 @@ Only the left Ctrl, Shift, and Alt buttons are enabled to work, not the ones on
|
||||
Command Line:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
scale:1 Normal window resolution
|
||||
scale:2 Doubled window resolution
|
||||
kiosk Fullscreen mode
|
||||
proxy:server[:port] Proxy server to use [Example: proxy:wwwcache.lancs.ac.uk:8080]
|
||||
open <file> Opens the file as a stamp or game save
|
||||
ddir <directory> Directory used for saving stamps and preferences
|
||||
ptsave:<save id>#<name(Optional)> (ex. ptsave:2198#Destroyable_city_5_wth_metro~dima-gord)
|
||||
|
||||
scale:1 Normal window resolution
|
||||
scale:2 Doubled window resolution
|
||||
kiosk Fullscreen mode
|
||||
proxy:server[:port] Proxy server to use [Example: proxy:wwwcache.lancs.ac.uk:8080]
|
||||
open <file> Opens the file as a stamp or game save
|
||||
ddir <directory> Directory used for saving stamps and preferences
|
||||
ptsave:<save id>#[name] [Example: ptsave:2198#Destroyable_city_5_wth_metro~dima-gord]
|
||||
|
1071
SConscript
Executable file → Normal file
1071
SConscript
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
20
SConstruct
20
SConstruct
@ -1,2 +1,22 @@
|
||||
#run generator.py
|
||||
if not GetOption('clean'):
|
||||
execfile("generator.py")
|
||||
|
||||
AddOption('--builddir',dest="builddir",default="build",help="Directory to build to.")
|
||||
SConscript('SConscript', variant_dir=GetOption('builddir'), duplicate=0)
|
||||
if GetOption('clean'):
|
||||
import os, shutil
|
||||
try:
|
||||
shutil.rmtree(".sconf_temp/")
|
||||
except:
|
||||
print "couldn't remove .sconf_temp/"
|
||||
|
||||
try:
|
||||
shutil.rmtree("generated/")
|
||||
except:
|
||||
print "couldn't remove generated/"
|
||||
|
||||
try:
|
||||
os.remove(".sconsign.dblite")
|
||||
except:
|
||||
print "couldn't remove .sconsign.dblite"
|
||||
|
@ -1,701 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.10: http://docutils.sourceforge.net/" />
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Authors: Ian Bicking, Michael Foord
|
||||
:Contact: fuzzyman@voidspace.org.uk
|
||||
:Date: 2005/08/26
|
||||
:Version: 0.1.0
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Stylesheet for Docutils.
|
||||
Based on ``blue_box.css`` by Ian Bicking
|
||||
and ``html4css1.css`` revision 1.46.
|
||||
*/
|
||||
|
||||
@import url(file:///usr/local/lib/python2.7/dist-packages/docutils/writers/html4css1/html4css1.css);
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
em, i {
|
||||
/* Typically serif fonts have much nicer italics */
|
||||
font-family: Times New Roman, Times, serif;
|
||||
}
|
||||
|
||||
a.target {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.target {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
a.toc-backref:hover {
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
background-color: #cccccc;
|
||||
}
|
||||
|
||||
div.attention, div.caution, div.danger, div.error, div.hint,
|
||||
div.important, div.note, div.tip, div.warning {
|
||||
background-color: #cccccc;
|
||||
padding: 3px;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
text-align: center;
|
||||
background-color: #999999;
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title {
|
||||
color: #cc0000;
|
||||
font-family: sans-serif;
|
||||
text-align: center;
|
||||
background-color: #999999;
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
border: thin solid black;
|
||||
/* This makes the borders rounded on Mozilla, which pleases me */
|
||||
-moz-border-radius: 8px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
background-color: #444499;
|
||||
color: #ffffff;
|
||||
border: medium solid black;
|
||||
}
|
||||
|
||||
h1 a.toc-backref, h2 a.toc-backref {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #666666;
|
||||
color: #ffffff;
|
||||
border: medium solid black;
|
||||
}
|
||||
|
||||
h3, h4, h5, h6 {
|
||||
background-color: #cccccc;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref,
|
||||
h6 a.toc-backref {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
text-align: center;
|
||||
background-color: #444499;
|
||||
color: #eeeeee;
|
||||
border: thick solid black;
|
||||
-moz-border-radius: 20px;
|
||||
}
|
||||
|
||||
table.footnote {
|
||||
padding-left: 0.5ex;
|
||||
}
|
||||
|
||||
table.citation {
|
||||
padding-left: 0.5ex
|
||||
}
|
||||
|
||||
pre.literal-block, pre.doctest-block {
|
||||
border: thin black solid;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.image img { border-style : solid;
|
||||
border-width : 2px;
|
||||
}
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
code, tt {
|
||||
color: #000066;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document">
|
||||
|
||||
|
||||
<div class="section" id="scons-script">
|
||||
<h1><a class="toc-backref" href="#id1">SCons script</a></h1>
|
||||
<p>the purpose of this script is to run a build of tpt from start to finish, including dependency checks.</p>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first">Table of Contents</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#scons-script" id="id1">SCons script</a></li>
|
||||
<li><a class="reference internal" href="#requirements" id="id2">requirements</a><ul>
|
||||
<li><a class="reference internal" href="#stdlib" id="id3">stdlib</a></li>
|
||||
<li><a class="reference internal" href="#rd-party" id="id4">3rd party</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#long-commandlines" id="id5">long commandlines</a></li>
|
||||
<li><a class="reference internal" href="#commandline-options" id="id6">commandline options</a></li>
|
||||
<li><a class="reference internal" href="#main-program" id="id7">main program</a><ul>
|
||||
<li><a class="reference internal" href="#platform-selection" id="id8">platform selection</a><ul>
|
||||
<li><a class="reference internal" href="#generic-platform-settings" id="id9">generic platform settings</a></li>
|
||||
<li><a class="reference internal" href="#windows-specific-platform-settings" id="id10">windows specific platform settings</a></li>
|
||||
<li><a class="reference internal" href="#macosx-specific-platform-settings" id="id11">macosx specific platform settings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#enviroment-setup" id="id12">enviroment setup</a><ul>
|
||||
<li><a class="reference internal" href="#generic-enviroment-settings" id="id13">generic enviroment settings</a></li>
|
||||
<li><a class="reference internal" href="#rpi-specific-enviroment-settings" id="id14">rpi specific enviroment settings</a></li>
|
||||
<li><a class="reference internal" href="#windows-specific-enviroment-settings" id="id15">windows specific enviroment settings</a></li>
|
||||
<li><a class="reference internal" href="#linux-specific-enviroment-settings" id="id16">linux specific enviroment settings</a></li>
|
||||
<li><a class="reference internal" href="#macosx-specific-enviroment-settings" id="id17">macosx specific enviroment settings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#defines" id="id18">defines</a></li>
|
||||
<li><a class="reference internal" href="#compiling" id="id19">compiling</a><ul>
|
||||
<li><a class="reference internal" href="#sources" id="id20">sources</a><ul>
|
||||
<li><a class="reference internal" href="#windows-specific-sources" id="id21">windows specific sources</a></li>
|
||||
<li><a class="reference internal" href="#macosx-specific-sources" id="id22">macosx specific sources</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#apply-long-commandlines-fix" id="id23">apply long commandlines fix</a></li>
|
||||
<li><a class="reference internal" href="#find-proper-executable-name" id="id24">find proper executable name</a></li>
|
||||
<li><a class="reference internal" href="#detect-python-executable-name" id="id25">detect python executable name</a></li>
|
||||
<li><a class="reference internal" href="#run-generator-commands" id="id26">run generator commands</a></li>
|
||||
<li><a class="reference internal" href="#final-settings" id="id27">final settings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="requirements">
|
||||
<h1><a class="toc-backref" href="#id2">requirements</a></h1>
|
||||
<div class="section" id="stdlib">
|
||||
<h2><a class="toc-backref" href="#id3">stdlib</a></h2>
|
||||
<pre class="literal-block">
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import time
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="rd-party">
|
||||
<h2><a class="toc-backref" href="#id4">3rd party</a></h2>
|
||||
<p>nothing besides scons.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="long-commandlines">
|
||||
<h1><a class="toc-backref" href="#id5">long commandlines</a></h1>
|
||||
<!-- : Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32 -->
|
||||
<p>because of an implementation detail commandlines are limited to 10000 characters on windows using mingw. the following fix was copied from
|
||||
<a class="reference external" href="http://scons.org/wiki/LongCmdLinesOnWin32">http://scons.org/wiki/LongCmdLinesOnWin32</a> and circumvents this issue.</p>
|
||||
<pre class="literal-block">
|
||||
class ourSpawn:
|
||||
def ourspawn(self, sh, escape, cmd, args, env):
|
||||
newargs = ' '.join(args[1:])
|
||||
cmdline = cmd + " " + newargs
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
|
||||
data, err = proc.communicate()
|
||||
rv = proc.wait()
|
||||
if rv:
|
||||
print "====="
|
||||
print err
|
||||
print "====="
|
||||
return rv
|
||||
|
||||
def SetupSpawn( env ):
|
||||
if sys.platform == 'win32':
|
||||
buf = ourSpawn()
|
||||
buf.ourenv = env
|
||||
env['SPAWN'] = buf.ourspawn
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="commandline-options">
|
||||
<h1><a class="toc-backref" href="#id6">commandline options</a></h1>
|
||||
<p>the following defines all optional commandlines</p>
|
||||
<pre class="literal-block">
|
||||
AddOption('--opengl',dest="opengl",action='store_true',default=False,help="Build with OpenGL interface support.")
|
||||
AddOption('--opengl-renderer',dest="opengl-renderer",action='store_true',default=False,help="Build with OpenGL renderer support. (requires --opengl)")
|
||||
AddOption('--renderer',dest="renderer",action='store_true',default=False,help="Save renderer")
|
||||
AddOption('--macosx',dest="macosx",action='store_true',default=False,help="Mac OS X platform target")
|
||||
AddOption('--rpi',dest="rpi",action='store_true',default=False,help="Raspbain platform target")
|
||||
AddOption('--64bit',dest="_64bit",action='store_true',default=False,help="64-bit platform target")
|
||||
AddOption('--static',dest="static",action="store_true",default=False,help="Static linking, reduces external library dependancies but increased file size")
|
||||
AddOption('--pthreadw32-static',dest="ptw32-static",action="store_true",default=False,help="Use PTW32_STATIC_LIB for pthreadw32 headers")
|
||||
AddOption('--python-ver',dest="pythonver",default=False,help="Python version to use for generator.py")
|
||||
AddOption('--release',dest="release",action='store_true',default=False,help="Enable optimisations (Will slow down compiling)")
|
||||
AddOption('--lua-dir',dest="lua-dir",default=False,help="Directory for lua includes")
|
||||
AddOption('--sdl-dir',dest="sdl-dir",default=False,help="Directory for SDL includes")
|
||||
AddOption('--tool',dest="toolprefix",default=False,help="Prefix")
|
||||
AddOption('--sse',dest="sse",action='store_true',default=False,help="Enable SSE optimisations")
|
||||
AddOption('--sse2',dest="sse2",action='store_true',default=False,help="Enable SSE2 optimisations")
|
||||
AddOption('--sse3',dest="sse3",action='store_true',default=False,help="Enable SSE3 optimisations")
|
||||
AddOption('--x86',dest="x86",action='store_true',default=True,help="Target Intel x86 platform")
|
||||
AddOption('--nofft',dest="nofft", action='store_true',default=False,help="Do not use fftw3f for gravity.")
|
||||
AddOption('--nolua',dest="nolua", action='store_true',default=False,help="Disable all lua scripting features.")
|
||||
|
||||
AddOption('--debugging', dest="debug", action="store_true", default=False, help="Enable debug options")
|
||||
AddOption('--beta',dest="beta",action='store_true',default=False,help="Beta build.")
|
||||
AddOption('--save-version',dest="save-version",default=False,help="Save version.")
|
||||
AddOption('--minor-version',dest="minor-version",default=False,help="Minor version.")
|
||||
AddOption('--build-number',dest="build-number",default=False,help="Build number.")
|
||||
AddOption('--snapshot',dest="snapshot",action='store_true',default=False,help="Snapshot build.")
|
||||
AddOption('--snapshot-id',dest="snapshot-id",default=False,help="Snapshot build ID.")
|
||||
AddOption('--stable',dest="stable",default=True,help="Non snapshot build")
|
||||
AddOption('--aao', dest="everythingAtOnce", action='store_true', default=False, help="Compile the whole game without generating intermediate objects (very slow), enable this when using compilers like clang or mscc that don't support -fkeep-inline-functions")
|
||||
</pre>
|
||||
<p>using either of these commandline options is compulsory</p>
|
||||
<pre class="literal-block">
|
||||
AddOption('--win',dest="win",action='store_true',default=False,help="Windows platform target.")
|
||||
AddOption('--lin',dest="lin",action='store_true',default=False,help="Linux platform target")
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="main-program">
|
||||
<h1><a class="toc-backref" href="#id7">main program</a></h1>
|
||||
<p>the gist of the compiling rules are defined here</p>
|
||||
<div class="section" id="platform-selection">
|
||||
<h2><a class="toc-backref" href="#id8">platform selection</a></h2>
|
||||
<div class="section" id="generic-platform-settings">
|
||||
<h3><a class="toc-backref" href="#id9">generic platform settings</a></h3>
|
||||
<p>check if a platform is specified.
|
||||
.. : TODO: make it suggest commandline options if it isn't</p>
|
||||
<pre class="literal-block">
|
||||
if((not GetOption('lin')) and (not GetOption('win')) and (not GetOption('rpi')) and (not GetOption('macosx'))):
|
||||
print "You must specify a platform to target"
|
||||
raise SystemExit(1)
|
||||
</pre>
|
||||
<p>check if a tool prefix is set, and if it is select the propper tools for building.
|
||||
.. : TODO someone explain wtf this actually does</p>
|
||||
<pre class="literal-block">
|
||||
if GetOption("toolprefix"):
|
||||
env['CC'] = GetOption("toolprefix")+env['CC']
|
||||
env['CXX'] = GetOption("toolprefix")+env['CXX']
|
||||
if GetOption('win'):
|
||||
env['RC'] = GetOption("toolprefix")+env['RC']
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="windows-specific-platform-settings">
|
||||
<h3><a class="toc-backref" href="#id10">windows specific platform settings</a></h3>
|
||||
<p>if the platform is windows switch to a mingw toolset, use the default otherwise</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('win')):
|
||||
env = Environment(tools = ['mingw'], ENV = os.environ)
|
||||
else:
|
||||
env = Environment(tools = ['default'], ENV = os.environ)
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="macosx-specific-platform-settings">
|
||||
<h3><a class="toc-backref" href="#id11">macosx specific platform settings</a></h3>
|
||||
<p>if we're not on MACOSX check for headers etc</p>
|
||||
<pre class="literal-block">
|
||||
if not GetOption("macosx"):
|
||||
conf = Configure(env)
|
||||
</pre>
|
||||
<p>if sdl-dir is set check if we can find the sdl header there, if we can't just pass the header path to the compiler.</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption("sdl-dir")):
|
||||
if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'):
|
||||
print "sdl headers not found or not installed"
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
env.Append(CPPPATH=[GetOption("sdl-dir")])
|
||||
else:
|
||||
</pre>
|
||||
<p>otherwise try to parse the pkg config for sdl and grab the correct flags from there.</p>
|
||||
<pre class="literal-block">
|
||||
try:
|
||||
env.ParseConfig('sdl-config --cflags')
|
||||
env.ParseConfig('sdl-config --libs')
|
||||
except:
|
||||
if not conf.CheckLib("SDL"):
|
||||
print "libSDL not found or not installed"
|
||||
raise SystemExit(1)
|
||||
</pre>
|
||||
<p>if lua is enabled try to parse the lua pgk-config, if that fails try the lua-dir option
|
||||
.. : TODO: make this look the same as the SDL check, maybe make a function for it. keep it DRY.</p>
|
||||
<pre class="literal-block">
|
||||
if not GetOption("nolua"):
|
||||
try:
|
||||
env.ParseConfig('pkg-config --cflags lua5.1')
|
||||
except:
|
||||
if(GetOption("lua-dir")):
|
||||
if not conf.CheckCHeader(GetOption("lua-dir") + '/lua.h'):
|
||||
print "lua5.1 headers not found or not installed"
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
env.Append(CPPPATH=[GetOption("lua-dir")])
|
||||
</pre>
|
||||
<p>if fft is enabled try to parse its config, fail otherwise.</p>
|
||||
<pre class="literal-block">
|
||||
if not GetOption('nofft'):
|
||||
# Check for FFT lib
|
||||
if not conf.CheckLib('fftw3f') and not conf.CheckLib('fftw3f-3'):
|
||||
print "libfftw3f not found or not installed"
|
||||
raise SystemExit(1)
|
||||
</pre>
|
||||
<p>try to autodetect some libraries, fail otherwise</p>
|
||||
<pre class="literal-block">
|
||||
#Check for Bzip lib
|
||||
if not conf.CheckLib('bz2'):
|
||||
print "libbz2 not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
#Check for zlib
|
||||
if not conf.CheckLib('z'):
|
||||
print "libz not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
if not conf.CheckCHeader("bzlib.h"):
|
||||
print "bzip2 headers not found"
|
||||
raise SystemExit(1)
|
||||
</pre>
|
||||
<!-- : TODO: checking if it's macosx again? seems like bitrot. -->
|
||||
<pre class="literal-block">
|
||||
#Check for Lua lib
|
||||
if not GetOption("macosx") and not GetOption("nolua"):
|
||||
if not conf.CheckLib('lua5.1') and not conf.CheckLib('lua-5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua'):
|
||||
print "liblua not found or not installed"
|
||||
raise SystemExit(1)
|
||||
</pre>
|
||||
<p>finish the configuration</p>
|
||||
<pre class="literal-block">
|
||||
env = conf.Finish();
|
||||
else:
|
||||
</pre>
|
||||
<p>if we ARE on macosx add the libraries to LIBS
|
||||
.. : seems like we're terrible at mac support? what gives?</p>
|
||||
<pre class="literal-block">
|
||||
env.Append(LIBS=['z', 'bz2'])
|
||||
if not GetOption('nofft'):
|
||||
env.Append(LIBS=['fftw3f'])
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="enviroment-setup">
|
||||
<h2><a class="toc-backref" href="#id12">enviroment setup</a></h2>
|
||||
<p>add the correct compiler flags.</p>
|
||||
<div class="section" id="generic-enviroment-settings">
|
||||
<h3><a class="toc-backref" href="#id13">generic enviroment settings</a></h3>
|
||||
<p>make sure the compiler can find the source data and generated files. enable warnings, set C++ flavor, and keep inline functions</p>
|
||||
<pre class="literal-block">
|
||||
env.Append(CPPPATH=['src/', 'data/', 'generated/'])
|
||||
env.Append(CCFLAGS=['-w', '-std=c++98', '-fkeep-inline-functions'])
|
||||
env.Append(LIBS=['pthread', 'm'])
|
||||
env.Append(CPPDEFINES=["_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"])
|
||||
</pre>
|
||||
<p>check all enabled libs, and add a define if they are enabled.</p>
|
||||
<pre class="literal-block">
|
||||
if not GetOption('nofft'):
|
||||
env.Append(CPPDEFINES=["GRAVFFT"])
|
||||
if not GetOption('nolua'):
|
||||
env.Append(CPPDEFINES=["LUACONSOLE"])
|
||||
</pre>
|
||||
<p>check if we need to use PTW32_STATIC_LIB for pthreadw32 headers
|
||||
.. : TODO: explain this so it actually means something :P</p>
|
||||
<pre class="literal-block">
|
||||
if GetOption("ptw32-static"):
|
||||
env.Append(CPPDEFINES=['PTW32_STATIC_LIB']);
|
||||
</pre>
|
||||
<p>check if we need to do static linking.</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('static')):
|
||||
env.Append(LINKFLAGS=['-static-libgcc'])
|
||||
</pre>
|
||||
<p>check if we need to compile the save renderer. add a define accordingly. compile the game by default.</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('renderer')):
|
||||
env.Append(CPPDEFINES=['RENDERER'])
|
||||
else:
|
||||
env.Append(CPPDEFINES=["USE_SDL"])
|
||||
</pre>
|
||||
<p>apply optimisations if it's a release build</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('release')):
|
||||
if GetOption('macosx'):
|
||||
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer'])
|
||||
else:
|
||||
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer', '-funsafe-loop-optimizations', '-Wunsafe-loop-optimizations'])
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="rpi-specific-enviroment-settings">
|
||||
<h3><a class="toc-backref" href="#id14">rpi specific enviroment settings</a></h3>
|
||||
<p>check if we're compiling for rpi, if we are include rpi specific libraries and defines.</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('rpi')):
|
||||
if(GetOption('opengl')):
|
||||
env.ParseConfig('pkg-config --libs glew gl glu')
|
||||
openGLLibs = ['GL']
|
||||
env.Append(LIBS=['X11', 'rt'])
|
||||
env.Append(CPPDEFINES=["LIN"])
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="windows-specific-enviroment-settings">
|
||||
<h3><a class="toc-backref" href="#id15">windows specific enviroment settings</a></h3>
|
||||
<p>check if we're compiling for windows, if we are include windows specific libraries and defines.</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('win')):
|
||||
openGLLibs = ['opengl32', 'glew32']
|
||||
env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'regex'])
|
||||
env.Append(CCFLAGS=['-std=gnu++98'])
|
||||
env.Append(LIBS=['winmm', 'gdi32'])
|
||||
env.Append(CPPDEFINES=["WIN"])
|
||||
env.Append(LINKFLAGS=['-mwindows'])
|
||||
if(GetOption('_64bit')):
|
||||
env.Append(CPPDEFINES=['__CRT__NO_INLINE'])
|
||||
env.Append(LINKFLAGS=['-Wl,--stack=16777216'])
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="linux-specific-enviroment-settings">
|
||||
<h3><a class="toc-backref" href="#id16">linux specific enviroment settings</a></h3>
|
||||
<p>check if we're compiling for linux, if we are include linux specific libraries and defines.</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('lin')):
|
||||
if(GetOption('opengl')):
|
||||
env.ParseConfig('pkg-config --libs glew gl glu')
|
||||
openGLLibs = ['GL']
|
||||
env.Append(LIBS=['X11', 'rt'])
|
||||
env.Append(CPPDEFINES=["LIN"])
|
||||
if GetOption('_64bit'):
|
||||
env.Append(LINKFLAGS=['-m64'])
|
||||
env.Append(CCFLAGS=['-m64'])
|
||||
else:
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="macosx-specific-enviroment-settings">
|
||||
<h3><a class="toc-backref" href="#id17">macosx specific enviroment settings</a></h3>
|
||||
<p>check if we're compiling for macosx, if we are include macosx specific libraries and defines.</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('macosx')):
|
||||
env.Append(CPPDEFINES=["MACOSX"])
|
||||
env.Append(CCFLAGS=['-I/Library/Frameworks/SDL.framework/Headers'])
|
||||
env.Append(CCFLAGS=['-I/Library/Frameworks/Lua.framework/Headers'])
|
||||
if not GetOption('nofft'):
|
||||
env.Append(LINKFLAGS=['-lfftw3f'])
|
||||
env.Append(LINKFLAGS=['-framework'])
|
||||
env.Append(LINKFLAGS=['SDL'])
|
||||
env.Append(LINKFLAGS=['-framework'])
|
||||
env.Append(LINKFLAGS=['Lua'])
|
||||
env.Append(LINKFLAGS=['-framework']);
|
||||
env.Append(LINKFLAGS=['Cocoa'])
|
||||
#env.Append(LINKFLAGS=['-framework SDL'])
|
||||
#env.Append(LINKFLAGS=['-framework Lua'])
|
||||
#env.Append(LINKFLAGS=['-framework Cocoa'])
|
||||
if GetOption('_64bit'):
|
||||
env.Append(LINKFLAGS=['-m64'])
|
||||
env.Append(CCFLAGS=['-m64'])
|
||||
else:
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="defines">
|
||||
<h2><a class="toc-backref" href="#id18">defines</a></h2>
|
||||
<p>A lot of commandline flags translate directly into defines. those flags follow:</p>
|
||||
<pre class="literal-block">
|
||||
if GetOption('_64bit'):
|
||||
env.Append(CPPDEFINES=["_64BIT"])
|
||||
|
||||
if(GetOption('beta')):
|
||||
env.Append(CPPDEFINES='BETA')
|
||||
|
||||
if(not GetOption('snapshot') and not GetOption('beta') and not GetOption('release') and not GetOption('stable')):
|
||||
env.Append(CPPDEFINES='SNAPSHOT_ID=0')
|
||||
env.Append(CPPDEFINES='SNAPSHOT')
|
||||
elif(GetOption('snapshot') or GetOption('snapshot-id')):
|
||||
if(GetOption('snapshot-id')):
|
||||
env.Append(CPPDEFINES=['SNAPSHOT_ID=' + GetOption('snapshot-id')])
|
||||
else:
|
||||
env.Append(CPPDEFINES=['SNAPSHOT_ID=' + str(int(time.time()))])
|
||||
env.Append(CPPDEFINES='SNAPSHOT')
|
||||
elif(GetOption('stable')):
|
||||
env.Append(CPPDEFINES='STABLE')
|
||||
|
||||
if(GetOption('save-version')):
|
||||
env.Append(CPPDEFINES=['SAVE_VERSION=' + GetOption('save-version')])
|
||||
|
||||
if(GetOption('minor-version')):
|
||||
env.Append(CPPDEFINES=['MINOR_VERSION=' + GetOption('minor-version')])
|
||||
|
||||
if(GetOption('build-number')):
|
||||
env.Append(CPPDEFINES=['BUILD_NUM=' + GetOption('build-number')])
|
||||
|
||||
if(GetOption('x86')):
|
||||
env.Append(CPPDEFINES='X86')
|
||||
|
||||
if(GetOption('debug')):
|
||||
env.Append(CPPDEFINES='DEBUG')
|
||||
env.Append(CCFLAGS='-g')
|
||||
|
||||
if(GetOption('sse')):
|
||||
env.Append(CCFLAGS='-msse')
|
||||
env.Append(CPPDEFINES='X86_SSE')
|
||||
|
||||
if(GetOption('sse2')):
|
||||
env.Append(CCFLAGS='-msse2')
|
||||
env.Append(CPPDEFINES='X86_SSE2')
|
||||
|
||||
if(GetOption('sse3')):
|
||||
env.Append(CCFLAGS='-msse3')
|
||||
env.Append(CPPDEFINES='X86_SSE3')
|
||||
|
||||
if(GetOption('opengl')):
|
||||
env.Append(CPPDEFINES=["OGLI", "PIX32OGL"])
|
||||
env.Append(LIBS=openGLLibs)
|
||||
|
||||
if(GetOption('opengl') and GetOption('opengl-renderer')):
|
||||
env.Append(CPPDEFINES=["OGLR"])
|
||||
elif(GetOption('opengl-renderer')):
|
||||
print "opengl-renderer requires opengl"
|
||||
raise SystemExit(1)
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="compiling">
|
||||
<h2><a class="toc-backref" href="#id19">compiling</a></h2>
|
||||
<div class="section" id="sources">
|
||||
<h3><a class="toc-backref" href="#id20">sources</a></h3>
|
||||
<p>find all source files</p>
|
||||
<pre class="literal-block">
|
||||
# generic sources
|
||||
# ---------------
|
||||
sources=Glob("src/*.cpp")
|
||||
|
||||
sources+=Glob("src/*/*.cpp")
|
||||
sources+=Glob("src/gui/*/*.cpp")
|
||||
sources+=Glob("src/simulation/elements/*.cpp")
|
||||
sources+=Glob("src/simulation/tools/*.cpp")
|
||||
sources+=Glob("src/client/requestbroker/*.cpp")
|
||||
if not GetOption('nolua'):
|
||||
sources+=Glob("src/socket/*.c")
|
||||
</pre>
|
||||
<div class="section" id="windows-specific-sources">
|
||||
<h4><a class="toc-backref" href="#id21">windows specific sources</a></h4>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('win')):
|
||||
sources += env.RES('resources/powder-res.rc')
|
||||
sources = filter(lambda source: not 'src\\simulation\\Gravity.cpp' in str(source), sources)
|
||||
sources = filter(lambda source: not 'src/simulation/Gravity.cpp' in str(source), sources)
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="macosx-specific-sources">
|
||||
<h4><a class="toc-backref" href="#id22">macosx specific sources</a></h4>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('macosx')):
|
||||
sources +=["SDLMain.m"]
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="apply-long-commandlines-fix">
|
||||
<h2>apply <a class="reference internal" href="#long-commandlines">long commandlines</a> fix</h2>
|
||||
<p>apply the commandline fix</p>
|
||||
<pre class="literal-block">
|
||||
SetupSpawn(env)
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="find-proper-executable-name">
|
||||
<h2><a class="toc-backref" href="#id24">find proper executable name</a></h2>
|
||||
<p>use some settings to detect what name to use for the executable</p>
|
||||
<pre class="literal-block">
|
||||
programName = "powder"
|
||||
|
||||
if(GetOption('renderer')):
|
||||
programName = "render"
|
||||
|
||||
if(GetOption('win')):
|
||||
if(GetOption('renderer')):
|
||||
programName = "Render"
|
||||
else:
|
||||
programName = "Powder"
|
||||
|
||||
if(GetOption('_64bit')):
|
||||
programName += "64"
|
||||
|
||||
if(not (GetOption('sse2') or GetOption('sse3'))):
|
||||
programName += "-legacy"
|
||||
|
||||
if(GetOption('macosx')):
|
||||
programName += "-x"
|
||||
|
||||
if(GetOption('win')):
|
||||
programName += ".exe"
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="detect-python-executable-name">
|
||||
<h2><a class="toc-backref" href="#id25">detect python executable name</a></h2>
|
||||
<p>detect the executable name for python so we can run some generator scripts</p>
|
||||
<pre class="literal-block">
|
||||
if(GetOption('pythonver')):
|
||||
pythonVer = GetOption('pythonver')
|
||||
elif(GetOption('lin')):
|
||||
pythonVer = "python2"
|
||||
else:
|
||||
pythonVer = "python"
|
||||
</pre>
|
||||
<!-- if(GetOption('win')): # this seems like dead code, when you uncomment this add some documentation please
|
||||
envCopy = env.Clone()
|
||||
envCopy.Append(CCFLAGS=['-mincoming-stack-boundary=2'])
|
||||
sources+=envCopy.Object('src/simulation/Gravity.cpp') -->
|
||||
</div>
|
||||
<div class="section" id="run-generator-commands">
|
||||
<h2><a class="toc-backref" href="#id26">run generator commands</a></h2>
|
||||
<pre class="literal-block">
|
||||
env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), pythonVer + " generator.py elements $TARGETS $SOURCES")
|
||||
sources+=Glob("generated/ElementClasses.cpp")
|
||||
|
||||
env.Command(['generated/ToolClasses.cpp', 'generated/ToolClasses.h'], Glob('src/simulation/tools/*.cpp'), pythonVer + " generator.py tools $TARGETS $SOURCES")
|
||||
sources+=Glob("generated/ToolClasses.cpp")
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="final-settings">
|
||||
<h2><a class="toc-backref" href="#id27">final settings</a></h2>
|
||||
<p>make a MD5 checksum decide wether or not a file changed. we had some problems with using the modification date for this purpose.</p>
|
||||
<pre class="literal-block">
|
||||
env.Decider('MD5')
|
||||
</pre>
|
||||
<p>set a default target</p>
|
||||
<pre class="literal-block">
|
||||
t=env.Program(target=programName, source=sources)
|
||||
Default(t)
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,217 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.10: http://docutils.sourceforge.net/" />
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Authors: Ian Bicking, Michael Foord
|
||||
:Contact: fuzzyman@voidspace.org.uk
|
||||
:Date: 2005/08/26
|
||||
:Version: 0.1.0
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Stylesheet for Docutils.
|
||||
Based on ``blue_box.css`` by Ian Bicking
|
||||
and ``html4css1.css`` revision 1.46.
|
||||
*/
|
||||
|
||||
@import url(file:///usr/local/lib/python2.7/dist-packages/docutils/writers/html4css1/html4css1.css);
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
em, i {
|
||||
/* Typically serif fonts have much nicer italics */
|
||||
font-family: Times New Roman, Times, serif;
|
||||
}
|
||||
|
||||
a.target {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.target {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
a.toc-backref:hover {
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
background-color: #cccccc;
|
||||
}
|
||||
|
||||
div.attention, div.caution, div.danger, div.error, div.hint,
|
||||
div.important, div.note, div.tip, div.warning {
|
||||
background-color: #cccccc;
|
||||
padding: 3px;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
text-align: center;
|
||||
background-color: #999999;
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title {
|
||||
color: #cc0000;
|
||||
font-family: sans-serif;
|
||||
text-align: center;
|
||||
background-color: #999999;
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
border: thin solid black;
|
||||
/* This makes the borders rounded on Mozilla, which pleases me */
|
||||
-moz-border-radius: 8px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
background-color: #444499;
|
||||
color: #ffffff;
|
||||
border: medium solid black;
|
||||
}
|
||||
|
||||
h1 a.toc-backref, h2 a.toc-backref {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #666666;
|
||||
color: #ffffff;
|
||||
border: medium solid black;
|
||||
}
|
||||
|
||||
h3, h4, h5, h6 {
|
||||
background-color: #cccccc;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref,
|
||||
h6 a.toc-backref {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
text-align: center;
|
||||
background-color: #444499;
|
||||
color: #eeeeee;
|
||||
border: thick solid black;
|
||||
-moz-border-radius: 20px;
|
||||
}
|
||||
|
||||
table.footnote {
|
||||
padding-left: 0.5ex;
|
||||
}
|
||||
|
||||
table.citation {
|
||||
padding-left: 0.5ex
|
||||
}
|
||||
|
||||
pre.literal-block, pre.doctest-block {
|
||||
border: thin black solid;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.image img { border-style : solid;
|
||||
border-width : 2px;
|
||||
}
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
code, tt {
|
||||
color: #000066;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document">
|
||||
|
||||
|
||||
<!-- #!/bin/bash -->
|
||||
<div class="section" id="documentation-generator">
|
||||
<h1>Documentation generator</h1>
|
||||
<p>the purpose of this script is to generate html documentation from the source code of specified files.</p>
|
||||
</div>
|
||||
<div class="section" id="requirements">
|
||||
<h1>requirements</h1>
|
||||
<p>this script requires pylit to be installed and the rst2html command to be available</p>
|
||||
</div>
|
||||
<div class="section" id="pre-generation">
|
||||
<h1>pre generation</h1>
|
||||
<p>make sure the script terminates on errors</p>
|
||||
<pre class="literal-block">
|
||||
set -e
|
||||
</pre>
|
||||
<p>skip pregeneration if we get any commandline parameters</p>
|
||||
<pre class="literal-block">
|
||||
if [ $# == 0 ]
|
||||
then
|
||||
</pre>
|
||||
<p>list of files to generate documentation for. the format is always:</p>
|
||||
<pre class="literal-block">
|
||||
"$0 filename language"
|
||||
</pre>
|
||||
<p>the following languages are available:
|
||||
- c
|
||||
- c++
|
||||
- css
|
||||
- python
|
||||
- shell
|
||||
- slang
|
||||
- latex</p>
|
||||
<pre class="literal-block">
|
||||
$0 SConscript python
|
||||
$0 gendocs.sh shell
|
||||
</pre>
|
||||
<p>exit program after running all the generation steps</p>
|
||||
<pre class="literal-block">
|
||||
exit
|
||||
fi
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="generation">
|
||||
<h1>generation</h1>
|
||||
<p>inform the user of which file we're processing</p>
|
||||
<pre class="literal-block">
|
||||
echo "--- generating docs for $1"
|
||||
</pre>
|
||||
<p>run pylit to convert source code to restructured text</p>
|
||||
<pre class="literal-block">
|
||||
pylit $1 --language $2 $1.txt
|
||||
</pre>
|
||||
<p>run rst2html to convert restructured text to html</p>
|
||||
<pre class="literal-block">
|
||||
rst2html.py $1.txt --stylesheet docs/style.css > docs/$1.html
|
||||
</pre>
|
||||
<p>clean up the restructured text file</p>
|
||||
<pre class="literal-block">
|
||||
rm $1.txt
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
137
docs/style.css
137
docs/style.css
@ -1,137 +0,0 @@
|
||||
/*
|
||||
:Authors: Ian Bicking, Michael Foord
|
||||
:Contact: fuzzyman@voidspace.org.uk
|
||||
:Date: 2005/08/26
|
||||
:Version: 0.1.0
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Stylesheet for Docutils.
|
||||
Based on ``blue_box.css`` by Ian Bicking
|
||||
and ``html4css1.css`` revision 1.46.
|
||||
*/
|
||||
|
||||
@import url(file:///usr/local/lib/python2.7/dist-packages/docutils/writers/html4css1/html4css1.css);
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
em, i {
|
||||
/* Typically serif fonts have much nicer italics */
|
||||
font-family: Times New Roman, Times, serif;
|
||||
}
|
||||
|
||||
a.target {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.target {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
a.toc-backref:hover {
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
background-color: #cccccc;
|
||||
}
|
||||
|
||||
div.attention, div.caution, div.danger, div.error, div.hint,
|
||||
div.important, div.note, div.tip, div.warning {
|
||||
background-color: #cccccc;
|
||||
padding: 3px;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
text-align: center;
|
||||
background-color: #999999;
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title {
|
||||
color: #cc0000;
|
||||
font-family: sans-serif;
|
||||
text-align: center;
|
||||
background-color: #999999;
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
border: thin solid black;
|
||||
/* This makes the borders rounded on Mozilla, which pleases me */
|
||||
-moz-border-radius: 8px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
background-color: #444499;
|
||||
color: #ffffff;
|
||||
border: medium solid black;
|
||||
}
|
||||
|
||||
h1 a.toc-backref, h2 a.toc-backref {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #666666;
|
||||
color: #ffffff;
|
||||
border: medium solid black;
|
||||
}
|
||||
|
||||
h3, h4, h5, h6 {
|
||||
background-color: #cccccc;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref,
|
||||
h6 a.toc-backref {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
text-align: center;
|
||||
background-color: #444499;
|
||||
color: #eeeeee;
|
||||
border: thick solid black;
|
||||
-moz-border-radius: 20px;
|
||||
}
|
||||
|
||||
table.footnote {
|
||||
padding-left: 0.5ex;
|
||||
}
|
||||
|
||||
table.citation {
|
||||
padding-left: 0.5ex
|
||||
}
|
||||
|
||||
pre.literal-block, pre.doctest-block {
|
||||
border: thin black solid;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.image img { border-style : solid;
|
||||
border-width : 2px;
|
||||
}
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
code, tt {
|
||||
color: #000066;
|
||||
}
|
63
gendocs.sh
63
gendocs.sh
@ -1,63 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Documentation generator
|
||||
# =======================
|
||||
|
||||
# the purpose of this script is to generate html documentation from the source code of specified files.
|
||||
|
||||
# requirements
|
||||
# ============
|
||||
|
||||
# this script requires pylit to be installed and the rst2html command to be available
|
||||
|
||||
# pre generation
|
||||
# ==============
|
||||
|
||||
# make sure the script terminates on errors
|
||||
|
||||
set -e
|
||||
|
||||
# skip pregeneration if we get any commandline parameters
|
||||
|
||||
if [ $# == 0 ]
|
||||
then
|
||||
|
||||
# list of files to generate documentation for. the format is always::
|
||||
|
||||
# "$0 filename language"
|
||||
|
||||
# the following languages are available:
|
||||
# - c
|
||||
# - c++
|
||||
# - css
|
||||
# - python
|
||||
# - shell
|
||||
# - slang
|
||||
# - latex
|
||||
|
||||
$0 SConscript python
|
||||
$0 gendocs.sh shell
|
||||
|
||||
# exit program after running all the generation steps
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
# generation
|
||||
# ==========
|
||||
|
||||
# inform the user of which file we're processing
|
||||
|
||||
echo "--- generating docs for $1"
|
||||
|
||||
# run pylit to convert source code to restructured text
|
||||
|
||||
pylit $1 --language $2 $1.txt
|
||||
|
||||
# run rst2html to convert restructured text to html
|
||||
|
||||
rst2html.py $1.txt --stylesheet docs/style.css > docs/$1.html
|
||||
|
||||
# clean up the restructured text file
|
||||
|
||||
rm $1.txt
|
10
generator.py
10
generator.py
@ -223,11 +223,5 @@ std::vector<SimTool*> GetTools()
|
||||
f.write(toolContent)
|
||||
f.close()
|
||||
|
||||
if(len(sys.argv) > 3):
|
||||
if(sys.argv[1] == "elements"):
|
||||
generateElements(sys.argv[4:], sys.argv[2], sys.argv[3])
|
||||
elif(sys.argv[1] == "tools"):
|
||||
generateTools(sys.argv[4:], sys.argv[2], sys.argv[3])
|
||||
else:
|
||||
generateElements(os.listdir("src/simulation/elements"), "generated/ElementClasses.cpp", "generated/ElementClasses.h")
|
||||
generateTools(os.listdir("src/simulation/simtools"), "generated/ToolClasses.cpp", "generated/ToolClasses.h")
|
||||
generateElements(os.listdir("src/simulation/elements"), "generated/ElementClasses.cpp", "generated/ElementClasses.h")
|
||||
generateTools(os.listdir("src/simulation/simtools"), "generated/ToolClasses.cpp", "generated/ToolClasses.h")
|
||||
|
20
src/Config.h
20
src/Config.h
@ -12,7 +12,7 @@
|
||||
|
||||
//VersionInfoStart
|
||||
#ifndef SAVE_VERSION
|
||||
#define SAVE_VERSION 89
|
||||
#define SAVE_VERSION 90
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_VERSION
|
||||
@ -20,26 +20,17 @@
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_NUM
|
||||
#define BUILD_NUM 283
|
||||
#define BUILD_NUM 322
|
||||
#endif
|
||||
|
||||
#ifndef SNAPSHOT_ID
|
||||
#define SNAPSHOT_ID 0
|
||||
#endif
|
||||
|
||||
#ifndef STABLE
|
||||
#ifndef BETA
|
||||
#define BETA
|
||||
#define SNAPSHOT
|
||||
#endif
|
||||
#endif
|
||||
//VersionInfoEnd
|
||||
|
||||
//#define IGNORE_UPDATES //uncomment this for mods, to not get any update notifications
|
||||
|
||||
#if defined(DEBUG) || defined(RENDERER) || defined(X86_SSE2)
|
||||
#define HIGH_QUALITY_RESAMPLE //High quality image resampling, slower but much higher quality than my terribad linear interpolation
|
||||
#endif
|
||||
|
||||
#if defined(SNAPSHOT)
|
||||
#define IDENT_RELTYPE "S"
|
||||
@ -130,6 +121,7 @@
|
||||
#define CELL 4
|
||||
#define ISTP (CELL/2)
|
||||
#define CFDS (4.0f/CELL)
|
||||
#define SIM_MAXVELOCITY 1e4f
|
||||
|
||||
//Air constants
|
||||
#define AIR_TSTEPP 0.3f
|
||||
@ -181,6 +173,12 @@
|
||||
#define TPT_INLINE inline
|
||||
#endif
|
||||
|
||||
#if defined(WIN) && defined(__GNUC__)
|
||||
#define TH_ENTRY_POINT __attribute__((force_align_arg_pointer))
|
||||
#else
|
||||
#define TH_ENTRY_POINT
|
||||
#endif
|
||||
|
||||
#define SDEUT
|
||||
//#define REALHEAT
|
||||
|
||||
|
@ -3,10 +3,13 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#ifdef SDL_INC
|
||||
#include "SDL/SDL.h"
|
||||
#else
|
||||
#include "SDL.h"
|
||||
#endif
|
||||
#ifdef WIN
|
||||
#define _WIN32_WINNT 0x0501 //Necessary for some macros and functions, tells windows.h to include functions only available in Windows XP or later
|
||||
#include "SDL_syswm.h"
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
@ -49,9 +52,13 @@ extern "C" {
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if defined(USE_SDL) && defined(LIN)
|
||||
#if defined(WIN) || defined(LIN)
|
||||
#ifdef SDL_INC
|
||||
#include <SDL/SDL_syswm.h>
|
||||
#else
|
||||
#include <SDL_syswm.h>
|
||||
#endif
|
||||
#endif
|
||||
#if defined(USE_SDL) && defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
|
||||
SDL_SysWMinfo sdl_wminfo;
|
||||
Atom XA_CLIPBOARD, XA_TARGETS, XA_UTF8_STRING;
|
||||
@ -93,7 +100,7 @@ void ClipboardPush(std::string text)
|
||||
XFlush(sdl_wminfo.info.x11.display);
|
||||
sdl_wminfo.info.x11.unlock_func();
|
||||
#else
|
||||
printf("Not implemented: put text on clipboard \"%s\"\n", text);
|
||||
printf("Not implemented: put text on clipboard \"%s\"\n", text.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,11 @@
|
||||
Feel free to customize this file to suit your needs
|
||||
*/
|
||||
|
||||
#ifdef SDL_INC
|
||||
#include "SDL/SDL.h"
|
||||
#else
|
||||
#include "SDL.h"
|
||||
#endif
|
||||
#include "SDLMain.h"
|
||||
#include <sys/param.h> /* for MAXPATHLEN */
|
||||
#include <unistd.h>
|
||||
@ -81,18 +85,20 @@ static NSString *getApplicationName(void)
|
||||
/* The main class of the application, the application's delegate */
|
||||
@implementation SDLMain
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
/* Set the working directory to Application Support */
|
||||
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||
{
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
if([paths count] < 1) return;
|
||||
|
||||
if ([paths count] < 1)
|
||||
return;
|
||||
|
||||
NSString *appSupportPath = [paths objectAtIndex:0];
|
||||
BOOL isDir = NO;
|
||||
NSError *error = nil;
|
||||
NSString *appPath = [appSupportPath stringByAppendingPathComponent:@"The Powder Toy"];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:appPath isDirectory:&isDir] && isDir == NO) {
|
||||
if(![[NSFileManager defaultManager] createDirectoryAtPath:appPath withIntermediateDirectories:YES attributes:nil error:&error])
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:appPath isDirectory:&isDir] && isDir == NO)
|
||||
{
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:appPath withIntermediateDirectories:YES attributes:nil error:&error])
|
||||
{
|
||||
NSLog(@"Could not set up working dir. Error: %@", error);
|
||||
return;
|
||||
@ -297,9 +303,15 @@ static void CustomApplicationMain (int argc, char **argv)
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||
{
|
||||
int status;
|
||||
SInt32 versionMajor = 0, versionMinor = 0;
|
||||
Gestalt(gestaltSystemVersionMajor, &versionMajor);
|
||||
Gestalt(gestaltSystemVersionMinor, &versionMinor);
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
[self setupWorkingDirectory:gFinderLaunch];
|
||||
/* using gFinderLaunch doesn't work in Mavericks and above, so always change it */
|
||||
if (versionMajor > 10 || versionMinor >= 9)
|
||||
[self setupWorkingDirectory:TRUE];
|
||||
else
|
||||
[self setupWorkingDirectory:gFinderLaunch];
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||
@ -355,7 +367,8 @@ static void CustomApplicationMain (int argc, char **argv)
|
||||
|
||||
@end
|
||||
|
||||
char * readUserPreferences() {
|
||||
char * readUserPreferences()
|
||||
{
|
||||
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
NSString *prefDataNSString = [prefs stringForKey:@"powder.pref"];
|
||||
@ -367,12 +380,12 @@ char * readUserPreferences() {
|
||||
SDL_strlcpy(prefDataCopy, prefData, [prefDataNSString length]+1);
|
||||
|
||||
[prefDataNSString release];
|
||||
[prefs release];
|
||||
|
||||
return prefDataCopy;
|
||||
}
|
||||
|
||||
void writeUserPreferences(const char * prefData) {
|
||||
void writeUserPreferences(const char * prefData)
|
||||
{
|
||||
NSString *prefDataNSString = [NSString stringWithUTF8String:prefData];
|
||||
|
||||
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
||||
@ -380,10 +393,10 @@ void writeUserPreferences(const char * prefData) {
|
||||
[prefs synchronize];
|
||||
|
||||
[prefDataNSString release];
|
||||
[prefs release];
|
||||
}
|
||||
|
||||
char * readClipboard() {
|
||||
char * readClipboard()
|
||||
{
|
||||
NSPasteboard *clipboard = [NSPasteboard generalPasteboard];
|
||||
|
||||
NSArray *classes = [[NSArray alloc] initWithObjects:[NSString class], nil];
|
||||
@ -403,7 +416,8 @@ char * readClipboard() {
|
||||
return clipboardDataCopy;
|
||||
}
|
||||
|
||||
void writeClipboard(const char * clipboardData) {
|
||||
void writeClipboard(const char * clipboardData)
|
||||
{
|
||||
NSPasteboard *clipboard = [NSPasteboard generalPasteboard];
|
||||
|
||||
NSString *newString = [NSString stringWithUTF8String: clipboardData];
|
@ -1003,6 +1003,11 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
particles[newIndex].ctype = 0;
|
||||
}
|
||||
break;
|
||||
case PT_PHOT:
|
||||
if (savedVersion < 90)
|
||||
{
|
||||
particles[newIndex].flags |= FLAG_PHOTDECO;
|
||||
}
|
||||
}
|
||||
//note: PSv was used in version 77.0 and every version before, add something in PSv too if the element is that old
|
||||
newIndex++;
|
||||
@ -1550,6 +1555,10 @@ void GameSave::readPSv(char * data, int dataLength)
|
||||
// no more particle properties to load, so we can change type here without messing up loading
|
||||
if (i && i<=NPART)
|
||||
{
|
||||
if (ver<90 && particles[i-1].type == PT_PHOT)
|
||||
{
|
||||
particles[i-1].flags |= FLAG_PHOTDECO;
|
||||
}
|
||||
if (ver<79 && particles[i-1].type == PT_SPNG)
|
||||
{
|
||||
if (fabs(particles[i-1].vx)>0.0f || fabs(particles[i-1].vy)>0.0f)
|
||||
|
@ -141,7 +141,7 @@ void RequestBroker::RetrieveImage(std::string imageUrl, int width, int height, R
|
||||
assureRunning();
|
||||
}
|
||||
|
||||
void * RequestBroker::thumbnailQueueProcessHelper(void * ref)
|
||||
TH_ENTRY_POINT void * RequestBroker::thumbnailQueueProcessHelper(void * ref)
|
||||
{
|
||||
((RequestBroker*)ref)->thumbnailQueueProcessTH();
|
||||
return NULL;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <pthread.h>
|
||||
#undef GetUserName //God dammit microsoft!
|
||||
|
||||
#include "Config.h"
|
||||
#include "Singleton.h"
|
||||
|
||||
class GameSave;
|
||||
@ -39,7 +40,7 @@ private:
|
||||
std::vector<Request*> requestQueue;
|
||||
std::vector<Request*> activeRequests;
|
||||
|
||||
static void * thumbnailQueueProcessHelper(void * ref);
|
||||
TH_ENTRY_POINT static void * thumbnailQueueProcessHelper(void * ref);
|
||||
void thumbnailQueueProcessTH();
|
||||
void assureRunning();
|
||||
|
||||
|
@ -870,9 +870,15 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve
|
||||
break;
|
||||
case IconVoteUp:
|
||||
if(invert)
|
||||
drawchar(x, y+1, 0xCB, 0, 100, 0, alpha);
|
||||
{
|
||||
drawchar(x-11, y+1, 0xCB, 0, 100, 0, alpha);
|
||||
drawtext(x+2, y+1, "Vote", 0, 100, 0, alpha);
|
||||
}
|
||||
else
|
||||
drawchar(x, y+1, 0xCB, 0, 187, 18, alpha);
|
||||
{
|
||||
drawchar(x-11, y+1, 0xCB, 0, 187, 18, alpha);
|
||||
drawtext(x+2, y+1, "Vote", 0, 187, 18, alpha);
|
||||
}
|
||||
break;
|
||||
case IconVoteDown:
|
||||
if(invert)
|
||||
|
@ -418,8 +418,30 @@ void PIXELMETHODS_CLASS::gradientrect(int x, int y, int width, int height, int r
|
||||
void PIXELMETHODS_CLASS::clearrect(int x, int y, int w, int h)
|
||||
{
|
||||
int i;
|
||||
for (i=1; i<h; i++)
|
||||
memset(vid+(x+1+(VIDXRES)*(y+i)), 0, PIXELSIZE*(w-1));
|
||||
|
||||
// TODO: change calls to clearrect to use sensible meanings of x, y, w, h then remove these 4 lines
|
||||
x += 1;
|
||||
y += 1;
|
||||
w -= 1;
|
||||
h -= 1;
|
||||
|
||||
if (x+w > VIDXRES) w = VIDXRES-x;
|
||||
if (y+h > VIDYRES) h = VIDYRES-y;
|
||||
if (x<0)
|
||||
{
|
||||
w += x;
|
||||
x = 0;
|
||||
}
|
||||
if (y<0)
|
||||
{
|
||||
h += y;
|
||||
y = 0;
|
||||
}
|
||||
if (w<0 || h<0)
|
||||
return;
|
||||
|
||||
for (i=0; i<h; i++)
|
||||
memset(vid+(x+(VIDXRES)*(y+i)), 0, PIXELSIZE*w);
|
||||
}
|
||||
|
||||
void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int a)
|
||||
|
@ -1155,9 +1155,9 @@ void Renderer::render_parts()
|
||||
for (ny=0; ny<YRES; ny++)
|
||||
for (nx=0; nx<XRES; nx++)
|
||||
{
|
||||
if (ny%(4*gridSize)==0)
|
||||
if (ny%(4*gridSize) == 0)
|
||||
blendpixel(nx, ny, 100, 100, 100, 80);
|
||||
if (nx%(4*gridSize)==0)
|
||||
if (nx%(4*gridSize) == 0 && ny%(4*gridSize) != 0)
|
||||
blendpixel(nx, ny, 100, 100, 100, 80);
|
||||
}
|
||||
}
|
||||
@ -1365,7 +1365,7 @@ void Renderer::render_parts()
|
||||
{
|
||||
if (t==PT_SOAP)
|
||||
{
|
||||
if ((parts[i].ctype&7) == 7)
|
||||
if ((parts[i].ctype&7) == 7 && parts[i].tmp >= 0 && parts[i].tmp < NPART && parts[i].tmp2 >= 0 && parts[i].tmp2 < NPART)
|
||||
draw_line(nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), colr, colg, colb, cola);
|
||||
}
|
||||
}
|
||||
@ -1956,6 +1956,23 @@ void Renderer::render_parts()
|
||||
fire_r[ny/CELL][nx/CELL] = firer;
|
||||
fire_g[ny/CELL][nx/CELL] = fireg;
|
||||
fire_b[ny/CELL][nx/CELL] = fireb;
|
||||
#endif
|
||||
}
|
||||
if(firea && (pixel_mode & FIRE_SPARK))
|
||||
{
|
||||
#ifdef OGLR
|
||||
smokeV[csmokeV++] = nx;
|
||||
smokeV[csmokeV++] = ny;
|
||||
smokeC[csmokeC++] = ((float)firer)/255.0f;
|
||||
smokeC[csmokeC++] = ((float)fireg)/255.0f;
|
||||
smokeC[csmokeC++] = ((float)fireb)/255.0f;
|
||||
smokeC[csmokeC++] = ((float)firea)/255.0f;
|
||||
csmoke++;
|
||||
#else
|
||||
firea /= 4;
|
||||
fire_r[ny/CELL][nx/CELL] = (firea*firer + (255-firea)*fire_r[ny/CELL][nx/CELL]) >> 8;
|
||||
fire_g[ny/CELL][nx/CELL] = (firea*fireg + (255-firea)*fire_g[ny/CELL][nx/CELL]) >> 8;
|
||||
fire_b[ny/CELL][nx/CELL] = (firea*fireb + (255-firea)*fire_b[ny/CELL][nx/CELL]) >> 8;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -2441,6 +2458,7 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
|
||||
SetColourMode(COLOUR_DEFAULT);
|
||||
AddRenderMode(RENDER_BASC);
|
||||
AddRenderMode(RENDER_FIRE);
|
||||
AddRenderMode(RENDER_SPRK);
|
||||
|
||||
//Render mode presets. Possibly load from config in future?
|
||||
renderModePresets = new RenderPreset[11];
|
||||
@ -2467,11 +2485,13 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
|
||||
|
||||
renderModePresets[4].Name = "Fire Display";
|
||||
renderModePresets[4].RenderModes.push_back(RENDER_FIRE);
|
||||
renderModePresets[4].RenderModes.push_back(RENDER_SPRK);
|
||||
renderModePresets[4].RenderModes.push_back(RENDER_EFFE);
|
||||
renderModePresets[4].RenderModes.push_back(RENDER_BASC);
|
||||
|
||||
renderModePresets[5].Name = "Blob Display";
|
||||
renderModePresets[5].RenderModes.push_back(RENDER_FIRE);
|
||||
renderModePresets[5].RenderModes.push_back(RENDER_SPRK);
|
||||
renderModePresets[5].RenderModes.push_back(RENDER_EFFE);
|
||||
renderModePresets[5].RenderModes.push_back(RENDER_BLOB);
|
||||
|
||||
@ -2482,6 +2502,7 @@ Renderer::Renderer(Graphics * g, Simulation * sim):
|
||||
|
||||
renderModePresets[7].Name = "Fancy Display";
|
||||
renderModePresets[7].RenderModes.push_back(RENDER_FIRE);
|
||||
renderModePresets[7].RenderModes.push_back(RENDER_SPRK);
|
||||
renderModePresets[7].RenderModes.push_back(RENDER_GLOW);
|
||||
renderModePresets[7].RenderModes.push_back(RENDER_BLUR);
|
||||
renderModePresets[7].RenderModes.push_back(RENDER_EFFE);
|
||||
|
@ -25,7 +25,8 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
|
||||
WindowActivity(ui::Point(-1, -1), ui::Point(236, 302)),
|
||||
gameController(gameController),
|
||||
tools(tools),
|
||||
firstResult(NULL)
|
||||
firstResult(NULL),
|
||||
exit(false)
|
||||
{
|
||||
ui::Label * title = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), "Element Search");
|
||||
title->SetTextColour(style::Colour::InformationTitle);
|
||||
@ -56,7 +57,7 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
|
||||
CloseAction(ElementSearchActivity * a) : a(a) { }
|
||||
void ActionCallback(ui::Button * sender_)
|
||||
{
|
||||
a->Exit();
|
||||
a->exit = true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -167,7 +168,7 @@ void ElementSearchActivity::searchTools(std::string query)
|
||||
void ElementSearchActivity::SetActiveTool(int selectionState, Tool * tool)
|
||||
{
|
||||
gameController->SetActiveTool(selectionState, tool);
|
||||
Exit();
|
||||
exit = true;
|
||||
}
|
||||
|
||||
void ElementSearchActivity::OnDraw()
|
||||
@ -179,17 +180,23 @@ void ElementSearchActivity::OnDraw()
|
||||
g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180);
|
||||
}
|
||||
|
||||
void ElementSearchActivity::OnTick(float dt)
|
||||
{
|
||||
if (exit)
|
||||
Exit();
|
||||
}
|
||||
|
||||
void ElementSearchActivity::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||
{
|
||||
if(key == KEY_ENTER || key == KEY_RETURN)
|
||||
{
|
||||
if(firstResult)
|
||||
gameController->SetActiveTool(0, firstResult);
|
||||
Exit();
|
||||
exit = true;
|
||||
}
|
||||
if(key == KEY_ESCAPE)
|
||||
{
|
||||
Exit();
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,13 @@ class ElementSearchActivity: public WindowActivity {
|
||||
void searchTools(std::string query);
|
||||
public:
|
||||
class ToolAction;
|
||||
bool exit;
|
||||
Tool * GetFirstResult() { return firstResult; }
|
||||
ElementSearchActivity(GameController * gameController, std::vector<Tool*> tools);
|
||||
void SetActiveTool(int selectionState, Tool * tool);
|
||||
virtual ~ElementSearchActivity();
|
||||
virtual void OnDraw();
|
||||
virtual void OnTick(float dt);
|
||||
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||
};
|
||||
|
||||
|
@ -134,6 +134,7 @@ FileBrowserActivity::FileBrowserActivity(std::string directory, FileSelectedCall
|
||||
textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
textField->SetActionCallback(new SearchAction(this));
|
||||
AddComponent(textField);
|
||||
FocusComponent(textField);
|
||||
|
||||
itemList = new ui::ScrollPanel(ui::Point(4, 45), ui::Point(Size.X-8, Size.Y-53));
|
||||
AddComponent(itemList);
|
||||
|
@ -126,6 +126,7 @@ GameController::GameController():
|
||||
options(NULL),
|
||||
activePreview(NULL),
|
||||
localBrowser(NULL),
|
||||
foundSign(NULL),
|
||||
HasDone(false),
|
||||
firstTick(true)
|
||||
{
|
||||
@ -350,6 +351,12 @@ void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis
|
||||
BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y);
|
||||
}
|
||||
|
||||
void GameController::SetBrushSize(ui::Point newSize)
|
||||
{
|
||||
gameModel->GetBrush()->SetRadius(newSize);
|
||||
BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y);
|
||||
}
|
||||
|
||||
void GameController::AdjustZoomSize(int direction, bool logarithmic)
|
||||
{
|
||||
int newSize;
|
||||
@ -554,34 +561,36 @@ bool GameController::BrushChanged(int brushType, int rx, int ry)
|
||||
bool GameController::MouseDown(int x, int y, unsigned button)
|
||||
{
|
||||
bool ret = commandInterface->OnMouseDown(x, y, button);
|
||||
ui::Point point = PointTranslate(ui::Point(x, y));
|
||||
x = point.X;
|
||||
y = point.Y;
|
||||
if(ret && y<YRES && x<XRES)
|
||||
if (gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
|
||||
if (ret && y<YRES && x<XRES && !gameView->GetPlacingSave() && !gameView->GetPlacingZoom())
|
||||
{
|
||||
ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y));
|
||||
x = point.X;
|
||||
y = point.Y;
|
||||
if (gameModel->GetActiveTool(0) && gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
|
||||
{
|
||||
sign * foundSign = GetSignAt(x, y);
|
||||
foundSign = GetSignAt(x, y);
|
||||
if(foundSign && splitsign(foundSign->text.c_str()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GameController::MouseUp(int x, int y, unsigned button)
|
||||
{
|
||||
bool ret = commandInterface->OnMouseUp(x, y, button);
|
||||
ui::Point point = PointTranslate(ui::Point(x, y));
|
||||
x = point.X;
|
||||
y = point.Y;
|
||||
if(ret && y<YRES && x<XRES)
|
||||
if (ret && foundSign && y<YRES && x<XRES && !gameView->GetPlacingSave())
|
||||
{
|
||||
if (gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
|
||||
ui::Point point = gameModel->AdjustZoomCoords(ui::Point(x, y));
|
||||
x = point.X;
|
||||
y = point.Y;
|
||||
if (gameModel->GetActiveTool(0) && gameModel->GetActiveTool(0)->GetIdentifier() != "DEFAULT_UI_SIGN" || button != BUTTON_LEFT) //If it's not a sign tool or you are right/middle clicking
|
||||
{
|
||||
sign * foundSign = GetSignAt(x, y);
|
||||
if(foundSign) {
|
||||
const char* str=foundSign->text.c_str();
|
||||
const char* str = foundSign->text.c_str();
|
||||
char type;
|
||||
int pos=splitsign(str, &type);
|
||||
int pos = splitsign(str, &type);
|
||||
if (pos)
|
||||
{
|
||||
ret = false;
|
||||
@ -609,6 +618,7 @@ bool GameController::MouseUp(int x, int y, unsigned button)
|
||||
}
|
||||
}
|
||||
}
|
||||
foundSign = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -720,7 +730,7 @@ void GameController::Tick()
|
||||
#ifdef LUACONSOLE
|
||||
((LuaScriptInterface*)commandInterface)->Init();
|
||||
#endif
|
||||
#ifndef MACOSX
|
||||
#if !defined(MACOSX) && !defined(NO_INSTALL_CHECK)
|
||||
if(!Client::Ref().GetPrefBool("InstallCheck", false))
|
||||
{
|
||||
Client::Ref().SetPref("InstallCheck", true);
|
||||
@ -1401,8 +1411,7 @@ std::string GameController::ElementResolve(int type, int ctype)
|
||||
else if (type >= 0 && type < PT_NUM && gameModel->GetSimulation()->elements)
|
||||
return std::string(gameModel->GetSimulation()->elements[type].Name);
|
||||
}
|
||||
else
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
bool GameController::IsValidElement(int type)
|
||||
|
@ -32,6 +32,8 @@ private:
|
||||
//Simulation * sim;
|
||||
bool firstTick;
|
||||
int screenshotIndex;
|
||||
sign * foundSign;
|
||||
|
||||
PreviewController * activePreview;
|
||||
GameView * gameView;
|
||||
GameModel * gameModel;
|
||||
@ -79,6 +81,7 @@ public:
|
||||
void SetZoomEnabled(bool zoomEnable);
|
||||
void SetZoomPosition(ui::Point position);
|
||||
void AdjustBrushSize(int direction, bool logarithmic = false, bool xAxis = false, bool yAxis = false);
|
||||
void SetBrushSize(ui::Point newSize);
|
||||
void AdjustZoomSize(int direction, bool logarithmic = false);
|
||||
void ToolClick(int toolSelection, ui::Point point);
|
||||
void DrawPoints(int toolSelection, queue<ui::Point> & pointQueue);
|
||||
|
@ -379,15 +379,21 @@ void GameModel::BuildMenus()
|
||||
|
||||
Tool * GameModel::GetToolFromIdentifier(std::string identifier)
|
||||
{
|
||||
for(std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter)
|
||||
for (std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter)
|
||||
{
|
||||
std::vector<Tool*> menuTools = (*iter)->GetToolList();
|
||||
for(std::vector<Tool*>::iterator titer = menuTools.begin(), tend = menuTools.end(); titer != tend; ++titer)
|
||||
for (std::vector<Tool*>::iterator titer = menuTools.begin(), tend = menuTools.end(); titer != tend; ++titer)
|
||||
{
|
||||
if(identifier == (*titer)->GetIdentifier())
|
||||
if (identifier == (*titer)->GetIdentifier())
|
||||
return *titer;
|
||||
}
|
||||
}
|
||||
for (std::vector<Tool*>::iterator iter = extraElementTools.begin(), end = extraElementTools.end(); iter != end; ++iter)
|
||||
{
|
||||
if (identifier == (*iter)->GetIdentifier())
|
||||
return *iter;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -957,6 +963,7 @@ void GameModel::Log(string message)
|
||||
if(consoleLog.size()>100)
|
||||
consoleLog.pop_back();
|
||||
notifyLogChanged(message);
|
||||
std::cout << message << std::endl;
|
||||
}
|
||||
|
||||
deque<string> GameModel::GetLog()
|
||||
|
@ -175,6 +175,7 @@ GameView::GameView():
|
||||
isToolTipFadingIn(false),
|
||||
isButtonTipFadingIn(false),
|
||||
toolTipPosition(-1, -1),
|
||||
saveSimulationButtonEnabled(false),
|
||||
shiftBehaviour(false),
|
||||
ctrlBehaviour(false),
|
||||
altBehaviour(false),
|
||||
@ -283,11 +284,11 @@ GameView::GameView():
|
||||
v->c->Vote(1);
|
||||
}
|
||||
};
|
||||
upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Like this save");
|
||||
upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(39, 15), "", "Like this save");
|
||||
upVoteButton->SetIcon(IconVoteUp);
|
||||
upVoteButton->Appearance.Margin.Top+=2;
|
||||
upVoteButton->Appearance.Margin.Left+=2;
|
||||
currentX+=14;
|
||||
currentX+=38;
|
||||
upVoteButton->SetActionCallback(new UpVoteAction(this));
|
||||
AddComponent(upVoteButton);
|
||||
|
||||
@ -319,7 +320,7 @@ GameView::GameView():
|
||||
v->c->OpenTags();
|
||||
}
|
||||
};
|
||||
tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(251, 15), "[no tags set]", "Add simulation tags");
|
||||
tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(227, 15), "[no tags set]", "Add simulation tags");
|
||||
tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
tagSimulationButton->SetIcon(IconTag);
|
||||
currentX+=252;
|
||||
@ -618,6 +619,16 @@ ui::Point GameView::GetMousePosition()
|
||||
return currentMouse;
|
||||
}
|
||||
|
||||
bool GameView::GetPlacingSave()
|
||||
{
|
||||
return selectMode != SelectNone;
|
||||
}
|
||||
|
||||
bool GameView::GetPlacingZoom()
|
||||
{
|
||||
return zoomEnabled && !zoomCursorFixed;
|
||||
}
|
||||
|
||||
void GameView::NotifyActiveToolsChanged(GameModel * sender)
|
||||
{
|
||||
for(int i = 0; i < toolButtons.size(); i++)
|
||||
@ -2250,7 +2261,10 @@ void GameView::OnDraw()
|
||||
|
||||
if(toolTipPresence && toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length())
|
||||
{
|
||||
g->drawtext(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
||||
if (toolTipPosition.Y == Size.Y-MENUSIZE-10)
|
||||
g->drawtext_outline(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
||||
else
|
||||
g->drawtext(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
|
||||
}
|
||||
|
||||
if(buttonTipShow > 0)
|
||||
|
@ -136,6 +136,8 @@ public:
|
||||
bool GetHudEnable();
|
||||
void SetDebugHUD(bool mode);
|
||||
bool GetDebugHUD();
|
||||
bool GetPlacingSave();
|
||||
bool GetPlacingZoom();
|
||||
bool CtrlBehaviour(){ return ctrlBehaviour; }
|
||||
bool ShiftBehaviour(){ return shiftBehaviour; }
|
||||
bool AltBehaviour(){ return altBehaviour; }
|
||||
|
@ -1,6 +1,10 @@
|
||||
|
||||
#if defined(USE_SDL)
|
||||
#ifdef SDL_INC
|
||||
#include "SDL/SDL.h"
|
||||
#else
|
||||
#include "SDL.h"
|
||||
#endif
|
||||
#define KEY_UNKNOWN SDLK_UNKNOWN
|
||||
#define KEY_UP SDLK_UP
|
||||
#define KEY_NUM_UP SDLK_KP8
|
||||
@ -49,7 +53,11 @@
|
||||
#define KEY_MOD_MODE KMOD_MODE
|
||||
#define KEY_MOD_RESERVED KMOD_RESERVED
|
||||
|
||||
#ifdef MACOSX
|
||||
#define KEY_MOD_CONTROL (KEY_MOD_RCONTROL | KEY_MOD_LCONTROL | KEY_MOD_LMETA | KEY_MOD_RMETA)
|
||||
#else
|
||||
#define KEY_MOD_CONTROL (KEY_MOD_RCONTROL | KEY_MOD_LCONTROL)
|
||||
#endif
|
||||
#define KEY_MOD_ALT (KEY_MOD_RALT | KEY_MOD_LALT)
|
||||
#define KEY_MOD_SHIFT (KEY_MOD_RSHIFT | KEY_MOD_LSHIFT)
|
||||
|
||||
|
@ -346,8 +346,8 @@ void Label::updateSelection()
|
||||
|
||||
void Label::SetDisplayText(std::string newText)
|
||||
{
|
||||
displayText = newText;
|
||||
tDisplayText = displayText;
|
||||
ClearSelection();
|
||||
displayText = tDisplayText = newText;
|
||||
}
|
||||
|
||||
void Label::Draw(const Point& screenPos)
|
||||
|
@ -180,19 +180,16 @@ void SaveButton::Draw(const Point& screenPos)
|
||||
g->fillrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 100, 170, 255, 100);
|
||||
}
|
||||
|
||||
scaleFactor = (Size.Y-25)/((float)YRES);
|
||||
thumbBoxSize = ui::Point(((float)XRES)*scaleFactor, ((float)YRES)*scaleFactor);
|
||||
if(thumbnail)
|
||||
{
|
||||
thumbBoxSize = ui::Point(thumbnail->Width, thumbnail->Height);
|
||||
//thumbBoxSize = ui::Point(thumbnail->Width, thumbnail->Height);
|
||||
if(save && save->id)
|
||||
g->draw_image(thumbnail, screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 255);
|
||||
else
|
||||
g->draw_image(thumbnail, screenPos.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
scaleFactor = (Size.Y-25)/((float)YRES);
|
||||
thumbBoxSize = ui::Point(((float)XRES)*scaleFactor, ((float)YRES)*scaleFactor);
|
||||
}
|
||||
if(save)
|
||||
{
|
||||
if(save->id)
|
||||
|
@ -1,11 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#ifdef WIN
|
||||
#include <direct.h>
|
||||
#define getcwd _getcwd
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "OptionsView.h"
|
||||
#include "gui/Style.h"
|
||||
#include "gui/interface/Button.h"
|
||||
#include "gui/interface/Label.h"
|
||||
#include "gui/interface/DropDown.h"
|
||||
#include "gui/dialogues/ErrorMessage.h"
|
||||
|
||||
OptionsView::OptionsView():
|
||||
ui::Window(ui::Point(-1, -1), ui::Point(300, 310)){
|
||||
ui::Window(ui::Point(-1, -1), ui::Point(300, 330)){
|
||||
|
||||
ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options");
|
||||
tempLabel->SetTextColour(style::Colour::InformationTitle);
|
||||
@ -150,7 +159,14 @@ OptionsView::OptionsView():
|
||||
OptionsView * v;
|
||||
public:
|
||||
FullscreenAction(OptionsView * v_){ v = v_; }
|
||||
virtual void ActionCallback(ui::Checkbox * sender){ v->c->SetFullscreen(sender->GetChecked()); }
|
||||
virtual void ActionCallback(ui::Checkbox * sender)
|
||||
{
|
||||
#ifdef MACOSX
|
||||
ErrorMessage::Blocking("Error", "fullscreen doesn't work on OS X");
|
||||
#else
|
||||
v->c->SetFullscreen(sender->GetChecked());
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
fullscreen = new ui::Checkbox(ui::Point(8, 230), ui::Point(Size.X-6, 16), "Fullscreen", "");
|
||||
@ -191,6 +207,35 @@ OptionsView::OptionsView():
|
||||
AddComponent(tempLabel);
|
||||
AddComponent(showAvatars);
|
||||
|
||||
class DataFolderAction: public ui::ButtonAction
|
||||
{
|
||||
public:
|
||||
DataFolderAction() { }
|
||||
void ActionCallback(ui::Button * sender)
|
||||
{
|
||||
//one of these should always be defined
|
||||
#ifdef WIN
|
||||
const char* openCommand = "start ";
|
||||
#elif MACOSX
|
||||
const char* openCommand = "open ";
|
||||
//#elif LIN
|
||||
#else
|
||||
const char* openCommand = "xdg-open ";
|
||||
#endif
|
||||
char* workingDirectory = new char[FILENAME_MAX+strlen(openCommand)];
|
||||
sprintf(workingDirectory, "%s\"%s\"", openCommand, getcwd(NULL, 0));
|
||||
system(workingDirectory);
|
||||
delete workingDirectory;
|
||||
}
|
||||
};
|
||||
ui::Button * dataFolderButton = new ui::Button(ui::Point(8, Size.Y-38), ui::Point(90, 16), "Open Data Folder");
|
||||
dataFolderButton->SetActionCallback(new DataFolderAction());
|
||||
AddComponent(dataFolderButton);
|
||||
|
||||
tempLabel = new ui::Label(ui::Point(dataFolderButton->Position.X+dataFolderButton->Size.X+3, dataFolderButton->Position.Y), ui::Point(Size.X-28, 16), "\bg- Open the data and preferences folder");
|
||||
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
AddComponent(tempLabel);
|
||||
|
||||
class CloseAction: public ui::ButtonAction
|
||||
{
|
||||
public:
|
||||
|
@ -186,6 +186,14 @@ RenderView::RenderView():
|
||||
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BASC));
|
||||
AddComponent(tCheckbox);
|
||||
|
||||
checkboxOffset += cSpace;
|
||||
|
||||
tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Spark", "Glow effect on sparks");
|
||||
renderModes.push_back(tCheckbox);
|
||||
tCheckbox->SetIcon(IconEffect);
|
||||
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_SPRK));
|
||||
AddComponent(tCheckbox);
|
||||
|
||||
checkboxOffset += sSpace;
|
||||
line1 = checkboxOffset-5;
|
||||
|
||||
@ -231,9 +239,9 @@ RenderView::RenderView():
|
||||
AddComponent(tCheckbox);
|
||||
|
||||
#ifdef OGLR
|
||||
tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "I don't know what this does..."); //I would remove the whole checkbox, but then there's a large empty space
|
||||
tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Some type of OpenGL effect ... maybe"); //I would remove the whole checkbox, but then there's a large empty space
|
||||
#else
|
||||
tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Does nothing");
|
||||
tCheckbox = new ui::Checkbox(ui::Point(checkboxOffset, YRES+4), ui::Point(30, 16), "Effect", "Enables moving solids, stickmen guns, and premium(tm) graphics");
|
||||
#endif
|
||||
displayModes.push_back(tCheckbox);
|
||||
tCheckbox->SetIcon(IconEffect);
|
||||
@ -379,9 +387,9 @@ void RenderView::OnTick(float dt)
|
||||
isToolTipFadingIn = false;
|
||||
if(toolTipPresence < 120)
|
||||
{
|
||||
toolTipPresence += int(dt*2)>0?int(dt*2):1;
|
||||
toolTipPresence += int(dt*2)>1?int(dt*2):2;
|
||||
if(toolTipPresence > 120)
|
||||
toolTipPresence = 0;
|
||||
toolTipPresence = 120;
|
||||
}
|
||||
}
|
||||
if(toolTipPresence>0)
|
||||
|
@ -114,6 +114,7 @@ ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUp
|
||||
nameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
nameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
AddComponent(nameField);
|
||||
FocusComponent(nameField);
|
||||
|
||||
descriptionField = new ui::Textbox(ui::Point(8, 65), ui::Point((Size.X/2)-16, Size.Y-(65+16+4)), save.GetDescription(), "[save description]");
|
||||
descriptionField->SetMultiline(true);
|
||||
|
@ -80,6 +80,7 @@ void SearchController::Update()
|
||||
|
||||
void SearchController::Exit()
|
||||
{
|
||||
InstantOpen(false);
|
||||
if(ui::Engine::Ref().GetWindow() == searchView)
|
||||
{
|
||||
ui::Engine::Ref().CloseWindow();
|
||||
|
@ -29,7 +29,7 @@ bool SearchModel::GetShowTags()
|
||||
return showTags;
|
||||
}
|
||||
|
||||
void * SearchModel::updateSaveListTHelper(void * obj)
|
||||
TH_ENTRY_POINT void * SearchModel::updateSaveListTHelper(void * obj)
|
||||
{
|
||||
return ((SearchModel *)obj)->updateSaveListT();
|
||||
}
|
||||
@ -47,7 +47,7 @@ void * SearchModel::updateSaveListT()
|
||||
return saveList;
|
||||
}
|
||||
|
||||
void * SearchModel::updateTagListTHelper(void * obj)
|
||||
TH_ENTRY_POINT void * SearchModel::updateTagListTHelper(void * obj)
|
||||
{
|
||||
return ((SearchModel *)obj)->updateTagListT();
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ private:
|
||||
bool updateSaveListWorking;
|
||||
volatile bool updateSaveListFinished;
|
||||
pthread_t updateSaveListThread;
|
||||
static void * updateSaveListTHelper(void * obj);
|
||||
TH_ENTRY_POINT static void * updateSaveListTHelper(void * obj);
|
||||
void * updateSaveListT();
|
||||
|
||||
bool updateTagListWorking;
|
||||
volatile bool updateTagListFinished;
|
||||
pthread_t updateTagListThread;
|
||||
static void * updateTagListTHelper(void * obj);
|
||||
TH_ENTRY_POINT static void * updateTagListTHelper(void * obj);
|
||||
void * updateTagListT();
|
||||
public:
|
||||
SearchModel();
|
||||
|
@ -39,6 +39,7 @@ SearchView::SearchView():
|
||||
searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
searchField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
searchField->SetActionCallback(new SearchAction(this));
|
||||
FocusComponent(searchField);
|
||||
|
||||
|
||||
class SortAction : public ui::ButtonAction
|
||||
|
@ -588,26 +588,14 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel)
|
||||
return mpcontinue;
|
||||
}
|
||||
|
||||
int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::string selectalt, std::string selectreplace, int bsx, int bsy)
|
||||
int luacon_step(int mx, int my)
|
||||
{
|
||||
int i, j, callret;
|
||||
lua_State* l=luacon_ci->l;
|
||||
lua_pushinteger(l, bsy);
|
||||
lua_pushinteger(l, bsx);
|
||||
lua_pushstring(l, selectreplace.c_str());
|
||||
lua_pushstring(l, selectalt.c_str());
|
||||
lua_pushstring(l, selectr.c_str());
|
||||
lua_pushstring(l, selectl.c_str());
|
||||
lua_pushinteger(l, my);
|
||||
lua_pushinteger(l, mx);
|
||||
lua_setfield(l, tptProperties, "mousex");
|
||||
lua_setfield(l, tptProperties, "mousey");
|
||||
lua_setfield(l, tptProperties, "selectedl");
|
||||
lua_setfield(l, tptProperties, "selectedr");
|
||||
lua_setfield(l, tptProperties, "selecteda");
|
||||
lua_setfield(l, tptProperties, "selectedreplace");
|
||||
lua_setfield(l, tptProperties, "brushx");
|
||||
lua_setfield(l, tptProperties, "brushy");
|
||||
lua_pushstring(l, "stepfunctions");
|
||||
lua_rawget(l, LUA_REGISTRYINDEX);
|
||||
if(!lua_istable(l, -1))
|
||||
@ -1226,15 +1214,16 @@ int luatpt_set_property(lua_State* l)
|
||||
int luatpt_set_wallmap(lua_State* l)
|
||||
{
|
||||
int nx, ny, acount;
|
||||
int x1, y1, width, height;
|
||||
float value;
|
||||
int x1, y1, width, height, wallType;
|
||||
acount = lua_gettop(l);
|
||||
|
||||
x1 = abs(luaL_optint(l, 1, 0));
|
||||
y1 = abs(luaL_optint(l, 2, 0));
|
||||
width = abs(luaL_optint(l, 3, XRES/CELL));
|
||||
height = abs(luaL_optint(l, 4, YRES/CELL));
|
||||
value = (float)luaL_optint(l, acount, 0);
|
||||
wallType = luaL_optint(l, acount, 0);
|
||||
if (wallType < 0 || wallType >= UI_WALLCOUNT)
|
||||
return luaL_error(l, "Unrecognised wall number %d", wallType);
|
||||
|
||||
if (acount == 5) //Draw rect
|
||||
{
|
||||
@ -1249,7 +1238,7 @@ int luatpt_set_wallmap(lua_State* l)
|
||||
for (nx = x1; nx<x1+width; nx++)
|
||||
for (ny = y1; ny<y1+height; ny++)
|
||||
{
|
||||
luacon_sim->bmap[ny][nx] = value;
|
||||
luacon_sim->bmap[ny][nx] = wallType;
|
||||
}
|
||||
}
|
||||
else //Set point
|
||||
@ -1258,20 +1247,15 @@ int luatpt_set_wallmap(lua_State* l)
|
||||
x1 = (XRES/CELL);
|
||||
if(y1 > (YRES/CELL))
|
||||
y1 = (YRES/CELL);
|
||||
luacon_sim->bmap[y1][x1] = value;
|
||||
luacon_sim->bmap[y1][x1] = wallType;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luatpt_get_wallmap(lua_State* l)
|
||||
{
|
||||
int nx, ny, acount;
|
||||
int x1, y1, width, height;
|
||||
float value;
|
||||
acount = lua_gettop(l);
|
||||
|
||||
x1 = abs(luaL_optint(l, 1, 0));
|
||||
y1 = abs(luaL_optint(l, 2, 0));
|
||||
int x1 = abs(luaL_optint(l, 1, 0));
|
||||
int y1 = abs(luaL_optint(l, 2, 0));
|
||||
|
||||
if(x1 > (XRES/CELL) || y1 > (YRES/CELL))
|
||||
return luaL_error(l, "Out of range");
|
||||
@ -1765,7 +1749,7 @@ int luatpt_next_getPartIndex(lua_State* l)
|
||||
getPartIndex_curIdx++;
|
||||
if (getPartIndex_curIdx >= NPART)
|
||||
{
|
||||
getPartIndex_curIdx = 0;
|
||||
getPartIndex_curIdx = -1;
|
||||
lua_pushboolean(l, 0);
|
||||
return 1;
|
||||
}
|
||||
@ -1782,7 +1766,7 @@ int luatpt_getPartIndex(lua_State* l)
|
||||
{
|
||||
if(getPartIndex_curIdx < 0)
|
||||
{
|
||||
lua_pushinteger(l, 0);
|
||||
lua_pushinteger(l, -1);
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger(l, getPartIndex_curIdx);
|
||||
|
@ -29,12 +29,7 @@
|
||||
|
||||
#define LUA_BITOP_VERSION "1.0.2"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
#include "LuaCompat.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */
|
||||
@ -183,11 +178,11 @@ int luaopen_bit(lua_State *L)
|
||||
msg = "arithmetic right-shift broken";
|
||||
luaL_error(L, "bit library self-test failed (%s)", msg);
|
||||
}
|
||||
#if LUA_VERSION_NUM < 502
|
||||
//#if LUA_VERSION_NUM < 502
|
||||
luaL_register(L, "bit", bit_funcs);
|
||||
#else
|
||||
luaL_newlib(L, bit_funcs);
|
||||
#endif
|
||||
//#else
|
||||
// luaL_newlib(L, bit_funcs);
|
||||
//#endif
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaButton.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
#include "LuaComponent.h"
|
||||
|
||||
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaCheckbox.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
#include "LuaComponent.h"
|
||||
|
||||
|
11
src/lua/LuaCompat.c
Normal file
11
src/lua/LuaCompat.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "LuaCompat.h"
|
||||
|
||||
#if LUA_VERSION_NUM >= 502
|
||||
//implement missing luaL_typerror function
|
||||
int luaL_typerror (lua_State *L, int narg, const char *tname)
|
||||
{
|
||||
const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg));
|
||||
return luaL_argerror(L, narg, msg);
|
||||
}
|
||||
|
||||
#endif
|
30
src/lua/LuaCompat.h
Normal file
30
src/lua/LuaCompat.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef LUAINC_H
|
||||
#define LUAINC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef LUA_INC
|
||||
#include "lua5.1/lua.h"
|
||||
#include "lua5.1/lauxlib.h"
|
||||
#include "lua5.1/lualib.h"
|
||||
#else
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
#endif
|
||||
|
||||
#if LUA_VERSION_NUM >= 502
|
||||
#define luaL_getn(L,i) lua_rawlen(L, (i))
|
||||
#define LUA_GLOBALSINDEX LUA_RIDX_GLOBALS
|
||||
|
||||
LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaComponent.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
|
||||
namespace ui
|
||||
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaScriptInterface.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
#include "LuaComponent.h"
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
#pragma once
|
||||
//http://lua-users.org/wiki/SimplerCppBinding
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
}
|
||||
#include "LuaCompat.h"
|
||||
|
||||
template <typename T> class Luna
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaProgressBar.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
#include "LuaComponent.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@ extern int tptElements; //Table for TPT element names
|
||||
extern int tptParts, tptPartsMeta, tptElementTransitions, tptPartsCData, tptPartMeta, tptPart, cIndex;
|
||||
|
||||
void luacon_hook(lua_State *L, lua_Debug *ar);
|
||||
int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, std::string selectedreplace, int bsx, int bsy);
|
||||
int luacon_step(int mx, int my);
|
||||
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
|
||||
int luacon_keyevent(int key, int modifier, int event);
|
||||
int luacon_eval(const char *command);
|
||||
|
@ -73,6 +73,18 @@ int atPanic(lua_State *l)
|
||||
throw std::runtime_error("Unprotected lua panic: " + std::string(lua_tostring(l, -1)));
|
||||
}
|
||||
|
||||
int TptIndexClosure(lua_State *l)
|
||||
{
|
||||
LuaScriptInterface *lsi = (LuaScriptInterface *)lua_touserdata(l, lua_upvalueindex(1));
|
||||
return lsi->tpt_index(l);
|
||||
}
|
||||
|
||||
int TptNewindexClosure(lua_State *l)
|
||||
{
|
||||
LuaScriptInterface *lsi = (LuaScriptInterface *)lua_touserdata(l, lua_upvalueindex(1));
|
||||
return lsi->tpt_newIndex(l);
|
||||
}
|
||||
|
||||
LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
CommandInterface(c, m),
|
||||
currentCommand(false),
|
||||
@ -127,7 +139,7 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
int i = 0, j;
|
||||
char tmpname[12];
|
||||
int currentElementMeta, currentElement;
|
||||
const static struct luaL_reg tptluaapi [] = {
|
||||
const static struct luaL_Reg tptluaapi [] = {
|
||||
{"test", &luatpt_test},
|
||||
{"drawtext", &luatpt_drawtext},
|
||||
{"create", &luatpt_create},
|
||||
@ -214,14 +226,6 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
lua_setfield(l, tptProperties, "mousex");
|
||||
lua_pushinteger(l, 0);
|
||||
lua_setfield(l, tptProperties, "mousey");
|
||||
lua_pushstring(l, "DEFAULT_PT_DUST");
|
||||
lua_setfield(l, tptProperties, "selectedl");
|
||||
lua_pushstring(l, "DEFAULT_PT_NONE");
|
||||
lua_setfield(l, tptProperties, "selectedr");
|
||||
lua_pushstring(l, "DEFAULT_PT_NONE");
|
||||
lua_setfield(l, tptProperties, "selecteda");
|
||||
lua_pushstring(l, "DEFAULT_PT_NONE");
|
||||
lua_setfield(l, tptProperties, "selectedreplace");
|
||||
|
||||
lua_newtable(l);
|
||||
tptPropertiesVersion = lua_gettop(l);
|
||||
@ -332,6 +336,16 @@ tpt.partsdata = nil");
|
||||
lua_gr_func[i] = 0;
|
||||
}
|
||||
|
||||
//make tpt.* a metatable
|
||||
lua_newtable(l);
|
||||
lua_pushlightuserdata(l, this);
|
||||
lua_pushcclosure(l, TptIndexClosure, 1);
|
||||
lua_setfield(l, -2, "__index");
|
||||
lua_pushlightuserdata(l, this);
|
||||
lua_pushcclosure(l, TptNewindexClosure, 1);
|
||||
lua_setfield(l, -2, "__newindex");
|
||||
lua_setmetatable(l, -2);
|
||||
|
||||
}
|
||||
|
||||
void LuaScriptInterface::Init()
|
||||
@ -351,11 +365,84 @@ void LuaScriptInterface::SetWindow(ui::Window * window)
|
||||
Window = window;
|
||||
}
|
||||
|
||||
int LuaScriptInterface::tpt_index(lua_State *l)
|
||||
{
|
||||
std::string key = luaL_checkstring(l, 2);
|
||||
if (!key.compare("selectedl"))
|
||||
return lua_pushstring(l, luacon_selectedl.c_str()), 1;
|
||||
if (!key.compare("selectedr"))
|
||||
return lua_pushstring(l, luacon_selectedr.c_str()), 1;
|
||||
if (!key.compare("selecteda"))
|
||||
return lua_pushstring(l, luacon_selectedalt.c_str()), 1;
|
||||
if (!key.compare("selectedreplace"))
|
||||
return lua_pushstring(l, luacon_selectedreplace.c_str()), 1;
|
||||
if (!key.compare("brushx"))
|
||||
return lua_pushnumber(l, luacon_brushx), 1;
|
||||
if (!key.compare("brushy"))
|
||||
return lua_pushnumber(l, luacon_brushy), 1;
|
||||
if (!key.compare("brushID"))
|
||||
return lua_pushnumber(l, m->GetBrushID()), 1;
|
||||
|
||||
//if not a special key, return the value in the table
|
||||
return lua_rawget(l, 1), 1;
|
||||
}
|
||||
|
||||
int LuaScriptInterface::tpt_newIndex(lua_State *l)
|
||||
{
|
||||
std::string key = luaL_checkstring(l, 2);
|
||||
if (!key.compare("selectedl"))
|
||||
{
|
||||
Tool *t = m->GetToolFromIdentifier(luaL_checkstring(l, 3));
|
||||
if (t)
|
||||
c->SetActiveTool(0, t);
|
||||
else
|
||||
luaL_error(l, "Invalid tool identifier: %s", lua_tostring(l, 3));
|
||||
}
|
||||
else if (!key.compare("selectedr"))
|
||||
{
|
||||
Tool *t = m->GetToolFromIdentifier(luaL_checkstring(l, 3));
|
||||
if (t)
|
||||
c->SetActiveTool(1, t);
|
||||
else
|
||||
luaL_error(l, "Invalid tool identifier: %s", lua_tostring(l, 3));
|
||||
}
|
||||
else if (!key.compare("selecteda"))
|
||||
{
|
||||
Tool *t = m->GetToolFromIdentifier(luaL_checkstring(l, 3));
|
||||
if (t)
|
||||
c->SetActiveTool(2, t);
|
||||
else
|
||||
luaL_error(l, "Invalid tool identifier: %s", lua_tostring(l, 3));
|
||||
}
|
||||
else if (!key.compare("selectedreplace"))
|
||||
{
|
||||
Tool *t = m->GetToolFromIdentifier(luaL_checkstring(l, 3));
|
||||
if( t)
|
||||
c->SetActiveTool(3, t);
|
||||
else
|
||||
luaL_error(l, "Invalid tool identifier: %s", lua_tostring(l, 3));
|
||||
}
|
||||
else if (!key.compare("brushx"))
|
||||
c->SetBrushSize(ui::Point(luaL_checkinteger(l, 3), luacon_brushy));
|
||||
else if (!key.compare("brushy"))
|
||||
c->SetBrushSize(ui::Point(luacon_brushx, luaL_checkinteger(l, 3)));
|
||||
else if (!key.compare("brushID"))
|
||||
{
|
||||
m->SetBrushID(luaL_checkinteger(l, 3));
|
||||
c->BrushChanged(m->GetBrushID(), luacon_brushx, luacon_brushy);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if not a special key, set a value in the table
|
||||
return lua_rawset(l, 1), 1;
|
||||
}
|
||||
}
|
||||
|
||||
//// Begin Interface API
|
||||
|
||||
void LuaScriptInterface::initInterfaceAPI()
|
||||
{
|
||||
struct luaL_reg interfaceAPIMethods [] = {
|
||||
struct luaL_Reg interfaceAPIMethods [] = {
|
||||
{"showWindow", interface_showWindow},
|
||||
{"closeWindow", interface_closeWindow},
|
||||
{"addComponent", interface_addComponent},
|
||||
@ -448,7 +535,7 @@ int LuaScriptInterface::particlePropertiesCount;
|
||||
void LuaScriptInterface::initSimulationAPI()
|
||||
{
|
||||
//Methods
|
||||
struct luaL_reg simulationAPIMethods [] = {
|
||||
struct luaL_Reg simulationAPIMethods [] = {
|
||||
{"partNeighbours", simulation_partNeighbours},
|
||||
{"partNeighbors", simulation_partNeighbours},
|
||||
{"partChangeType", simulation_partChangeType},
|
||||
@ -1678,7 +1765,7 @@ int LuaScriptInterface::simulation_neighbours(lua_State * l)
|
||||
void LuaScriptInterface::initRendererAPI()
|
||||
{
|
||||
//Methods
|
||||
struct luaL_reg rendererAPIMethods [] = {
|
||||
struct luaL_Reg rendererAPIMethods [] = {
|
||||
{"renderModes", renderer_renderModes},
|
||||
{"displayModes", renderer_displayModes},
|
||||
{"colourMode", renderer_colourMode},
|
||||
@ -1870,7 +1957,7 @@ int LuaScriptInterface::renderer_debugHUD(lua_State * l)
|
||||
void LuaScriptInterface::initElementsAPI()
|
||||
{
|
||||
//Methods
|
||||
struct luaL_reg elementsAPIMethods [] = {
|
||||
struct luaL_Reg elementsAPIMethods [] = {
|
||||
{"allocate", elements_allocate},
|
||||
{"element", elements_element},
|
||||
{"property", elements_property},
|
||||
@ -1910,6 +1997,7 @@ void LuaScriptInterface::initElementsAPI()
|
||||
SETCONST(l, FLAG_STAGNANT);
|
||||
SETCONST(l, FLAG_SKIPMOVE);
|
||||
SETCONST(l, FLAG_MOVABLE);
|
||||
SETCONST(l, FLAG_PHOTDECO);
|
||||
SETCONST(l, ST_NONE);
|
||||
SETCONST(l, ST_SOLID);
|
||||
SETCONST(l, ST_LIQUID);
|
||||
@ -1999,7 +2087,7 @@ int LuaScriptInterface::elements_loadDefault(lua_State * l)
|
||||
luacon_model->BuildMenus();
|
||||
luacon_sim->init_can_move();
|
||||
std::fill(luacon_ren->graphicscache, luacon_ren->graphicscache+PT_NUM, gcache_item());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaScriptInterface::elements_allocate(lua_State * l)
|
||||
@ -2296,6 +2384,7 @@ int LuaScriptInterface::elements_property(lua_State * l)
|
||||
}
|
||||
else
|
||||
return luaL_error(l, "Invalid element property");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2385,7 +2474,7 @@ int LuaScriptInterface::elements_free(lua_State * l)
|
||||
void LuaScriptInterface::initGraphicsAPI()
|
||||
{
|
||||
//Methods
|
||||
struct luaL_reg graphicsAPIMethods [] = {
|
||||
struct luaL_Reg graphicsAPIMethods [] = {
|
||||
{"textSize", graphics_textSize},
|
||||
{"drawText", graphics_drawText},
|
||||
{"drawLine", graphics_drawLine},
|
||||
@ -2393,6 +2482,8 @@ void LuaScriptInterface::initGraphicsAPI()
|
||||
{"fillRect", graphics_fillRect},
|
||||
{"drawCircle", graphics_drawCircle},
|
||||
{"fillCircle", graphics_fillCircle},
|
||||
{"getColors", graphics_getColors},
|
||||
{"getHexColor", graphics_getHexColor},
|
||||
{NULL, NULL}
|
||||
};
|
||||
luaL_register(l, "graphics", graphicsAPIMethods);
|
||||
@ -2559,10 +2650,40 @@ int LuaScriptInterface::graphics_fillCircle(lua_State * l)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LuaScriptInterface::graphics_getColors(lua_State * l)
|
||||
{
|
||||
unsigned int color = lua_tointeger(l, 1);
|
||||
|
||||
int a = color >> 24;
|
||||
int r = (color >> 16)&0xFF;
|
||||
int g = (color >> 8)&0xFF;
|
||||
int b = color&0xFF;
|
||||
|
||||
lua_pushinteger(l, r);
|
||||
lua_pushinteger(l, g);
|
||||
lua_pushinteger(l, b);
|
||||
lua_pushinteger(l, a);
|
||||
return 4;
|
||||
}
|
||||
|
||||
int LuaScriptInterface::graphics_getHexColor(lua_State * l)
|
||||
{
|
||||
int r = lua_tointeger(l, 1);
|
||||
int g = lua_tointeger(l, 2);
|
||||
int b = lua_tointeger(l, 3);
|
||||
int a = 0;
|
||||
if (lua_gettop(l) >= 4)
|
||||
a = lua_tointeger(l, 4);
|
||||
unsigned int color = (a<<24) + (r<<16) + (g<<8) + b;
|
||||
|
||||
lua_pushinteger(l, color);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void LuaScriptInterface::initFileSystemAPI()
|
||||
{
|
||||
//Methods
|
||||
struct luaL_reg fileSystemAPIMethods [] = {
|
||||
struct luaL_Reg fileSystemAPIMethods [] = {
|
||||
{"list", fileSystem_list},
|
||||
{"exists", fileSystem_exists},
|
||||
{"isFile", fileSystem_isFile},
|
||||
@ -2801,14 +2922,19 @@ bool LuaScriptInterface::OnBrushChanged(int brushType, int rx, int ry)
|
||||
|
||||
bool LuaScriptInterface::OnActiveToolChanged(int toolSelection, Tool * tool)
|
||||
{
|
||||
std::string identifier;
|
||||
if (tool)
|
||||
identifier = tool->GetIdentifier();
|
||||
else
|
||||
identifier = "";
|
||||
if (toolSelection == 0)
|
||||
luacon_selectedl = tool->GetIdentifier();
|
||||
luacon_selectedl = identifier;
|
||||
else if (toolSelection == 1)
|
||||
luacon_selectedr = tool->GetIdentifier();
|
||||
luacon_selectedr = identifier;
|
||||
else if (toolSelection == 2)
|
||||
luacon_selectedalt = tool->GetIdentifier();
|
||||
luacon_selectedalt = identifier;
|
||||
else if (toolSelection == 3)
|
||||
luacon_selectedreplace = tool->GetIdentifier();
|
||||
luacon_selectedreplace = identifier;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2867,7 +2993,7 @@ void LuaScriptInterface::OnTick()
|
||||
ui::Engine::Ref().LastTick(gettime());
|
||||
if(luacon_mousedown)
|
||||
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0);
|
||||
luacon_step(luacon_mousex, luacon_mousey, luacon_selectedl, luacon_selectedr, luacon_selectedalt, luacon_selectedreplace, luacon_brushx, luacon_brushy);
|
||||
luacon_step(luacon_mousex, luacon_mousey);
|
||||
}
|
||||
|
||||
int LuaScriptInterface::Command(std::string command)
|
||||
@ -2934,6 +3060,223 @@ int LuaScriptInterface::Command(std::string command)
|
||||
}
|
||||
}
|
||||
|
||||
int strlcmp(const char* a, const char* b, int len)
|
||||
{
|
||||
while(len)
|
||||
{
|
||||
if(!*b)
|
||||
return 1;
|
||||
if(*a>*b)
|
||||
return -1;
|
||||
if(*a<*b)
|
||||
return 1;
|
||||
a++;
|
||||
b++;
|
||||
len--;
|
||||
}
|
||||
if(!*b)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string highlight(std::string command)
|
||||
{
|
||||
#define CMP(X) (!strlcmp(wstart, X, len))
|
||||
std::stringstream result;
|
||||
int pos = 0;
|
||||
int len = command.length();
|
||||
const char *raw = command.c_str();
|
||||
char c;
|
||||
while(c = raw[pos])
|
||||
{
|
||||
if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_')
|
||||
{
|
||||
int len = 0;
|
||||
char w;
|
||||
const char* wstart = raw+pos;
|
||||
while((w = wstart[len]) && ((w >= 'A' && w <= 'Z') || (w >= 'a' && w <= 'z') || (w >= '0' && w <= '9') || w == '_'))
|
||||
len++;
|
||||
if(CMP("and") || CMP("break") || CMP("do") || CMP("else") || CMP("elseif") || CMP("end") || CMP("for") || CMP("function") || CMP("if") || CMP("in") || CMP("local") || CMP("not") || CMP("or") || CMP("repeat") || CMP("return") || CMP("then") || CMP("until") || CMP("while"))
|
||||
{
|
||||
result << "\x0F\xB5\x89\x01";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
}
|
||||
else if(CMP("false") || CMP("nil") || CMP("true"))
|
||||
{
|
||||
result << "\x0F\xCB\x4B\x16";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
}
|
||||
else
|
||||
{
|
||||
result << "\x0F\x2A\xA1\x98";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
}
|
||||
pos += len;
|
||||
}
|
||||
else if((c >= '0' && c <= '9') || (c == '.' && raw[pos + 1] >= '0' && raw[pos + 1] <= '9'))
|
||||
{
|
||||
if(c == '0' && raw[pos + 1] == 'x')
|
||||
{
|
||||
int len = 2;
|
||||
char w;
|
||||
const char *wstart = raw + pos;
|
||||
while((w = wstart[len]) && ((w >= '0' && w <= '9') || (w >= 'A' && w <= 'F') || (w >= 'a' && w <= 'f')))
|
||||
len++;
|
||||
result << "\x0F\xD3\x36\x82";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
pos += len;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len = 0;
|
||||
char w;
|
||||
const char *wstart = raw+pos;
|
||||
bool seendot = false;
|
||||
while((w = wstart[len]) && ((w >= '0' && w <= '9') || w == '.'))
|
||||
{
|
||||
if(w == '.')
|
||||
if(seendot)
|
||||
break;
|
||||
else
|
||||
seendot = true;
|
||||
len++;
|
||||
}
|
||||
if(w == 'e')
|
||||
{
|
||||
len++;
|
||||
w = wstart[len];
|
||||
if(w == '+' || w == '-')
|
||||
len++;
|
||||
while((w = wstart[len]) && (w >= '0' && w <= '9'))
|
||||
len++;
|
||||
}
|
||||
result << "\x0F\xD3\x36\x82";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
pos += len;
|
||||
}
|
||||
}
|
||||
else if(c == '\'' || c == '"' || (c == '[' && (raw[pos + 1] == '[' || raw[pos + 1] == '=')))
|
||||
{
|
||||
if(c == '[')
|
||||
{
|
||||
int len = 1, eqs=0;
|
||||
char w;
|
||||
const char *wstart = raw + pos;
|
||||
while((w = wstart[len]) && (w == '='))
|
||||
{
|
||||
eqs++;
|
||||
len++;
|
||||
}
|
||||
while((w = wstart[len]))
|
||||
{
|
||||
if(w == ']')
|
||||
{
|
||||
int nlen = 1;
|
||||
const char *cstart = wstart + len;
|
||||
while((w = cstart[nlen]) && (w == '='))
|
||||
nlen++;
|
||||
if(w == ']' && nlen == eqs+1)
|
||||
{
|
||||
len += nlen+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
len++;
|
||||
}
|
||||
result << "\x0F\xDC\x32\x2F";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
pos += len;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len = 1;
|
||||
char w;
|
||||
const char *wstart = raw+pos;
|
||||
while((w = wstart[len]) && (w != c))
|
||||
{
|
||||
if(w == '\\' && wstart[len + 1])
|
||||
len++;
|
||||
len++;
|
||||
}
|
||||
if(w == c)
|
||||
len++;
|
||||
result << "\x0F\xDC\x32\x2F";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
pos += len;
|
||||
}
|
||||
}
|
||||
else if(c == '-' && raw[pos + 1] == '-')
|
||||
{
|
||||
if(raw[pos + 2] == '[')
|
||||
{
|
||||
int len = 3, eqs = 0;
|
||||
char w;
|
||||
const char *wstart = raw + pos;
|
||||
while((w = wstart[len]) && (w == '='))
|
||||
{
|
||||
eqs++;
|
||||
len++;
|
||||
}
|
||||
while((w = wstart[len]))
|
||||
{
|
||||
if(w == ']')
|
||||
{
|
||||
int nlen = 1;
|
||||
const char *cstart = wstart + len;
|
||||
while((w = cstart[nlen]) && (w == '='))
|
||||
nlen++;
|
||||
if(w == ']' && nlen == eqs + 1)
|
||||
{
|
||||
len += nlen+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
len++;
|
||||
}
|
||||
result << "\x0F\x85\x99\x01";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
pos += len;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len = 2;
|
||||
char w;
|
||||
const char *wstart = raw + pos;
|
||||
while((w = wstart[len]) && (w != '\n'))
|
||||
len++;
|
||||
result << "\x0F\x85\x99\x01";
|
||||
result.write(wstart, len);
|
||||
result << "\bw";
|
||||
pos += len;
|
||||
}
|
||||
}
|
||||
else if(c == '{' || c == '}')
|
||||
{
|
||||
result << "\x0F\xCB\x4B\x16" << c;
|
||||
pos++;
|
||||
}
|
||||
else if(c == '.' && raw[pos + 1] == '.' && raw[pos + 2] == '.')
|
||||
{
|
||||
result << "\x0F\x2A\xA1\x98...";
|
||||
pos += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
result << c;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
std::string LuaScriptInterface::FormatCommand(std::string command)
|
||||
{
|
||||
if(command != "" && command[0] == '!')
|
||||
@ -2941,7 +3284,7 @@ std::string LuaScriptInterface::FormatCommand(std::string command)
|
||||
return "!"+legacy->FormatCommand(command.substr(1));
|
||||
}
|
||||
else
|
||||
return command;
|
||||
return highlight(command);
|
||||
}
|
||||
|
||||
LuaScriptInterface::~LuaScriptInterface() {
|
||||
|
@ -1,12 +1,7 @@
|
||||
#ifndef LUASCRIPTINTERFACE_H_
|
||||
#define LUASCRIPTINTERFACE_H_
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
#include "LuaCompat.h"
|
||||
|
||||
#include "CommandInterface.h"
|
||||
#include "simulation/Simulation.h"
|
||||
@ -136,6 +131,8 @@ class LuaScriptInterface: public CommandInterface
|
||||
static int graphics_fillRect(lua_State * l);
|
||||
static int graphics_drawCircle(lua_State * l);
|
||||
static int graphics_fillCircle(lua_State * l);
|
||||
static int graphics_getColors(lua_State * l);
|
||||
static int graphics_getHexColor(lua_State * l);
|
||||
|
||||
void initFileSystemAPI();
|
||||
static int fileSystem_list(lua_State * l);
|
||||
@ -149,6 +146,9 @@ class LuaScriptInterface: public CommandInterface
|
||||
static int fileSystem_copy(lua_State * l);
|
||||
|
||||
public:
|
||||
int tpt_index(lua_State *l);
|
||||
int tpt_newIndex(lua_State *l);
|
||||
|
||||
ui::Window * Window;
|
||||
lua_State *l;
|
||||
LuaScriptInterface(GameController * c, GameModel * m);
|
||||
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaSlider.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
#include "LuaComponent.h"
|
||||
|
||||
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaScriptInterface.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
#include "LuaComponent.h"
|
||||
|
||||
|
@ -1,10 +1,4 @@
|
||||
#ifdef LUACONSOLE
|
||||
extern "C"
|
||||
{
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
#include "LuaScriptInterface.h"
|
||||
|
@ -1,11 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
#include "LuaLuna.h"
|
||||
|
||||
#include "gui/interface/Platform.h"
|
||||
|
@ -26,10 +26,22 @@ AnyType::AnyType(const AnyType & v):
|
||||
|
||||
AnyType::operator NumberType()
|
||||
{
|
||||
if(type != TypeNumber)
|
||||
throw InvalidConversionException(type, TypeNumber);
|
||||
else
|
||||
if (type == TypeNumber)
|
||||
return NumberType(value.num);
|
||||
else if (type == TypeFloat)
|
||||
return NumberType(value.numf);
|
||||
else
|
||||
throw InvalidConversionException(type, TypeNumber);
|
||||
}
|
||||
|
||||
AnyType::operator FloatType()
|
||||
{
|
||||
if (type == TypeNumber)
|
||||
return FloatType(value.num);
|
||||
else if (type == TypeFloat)
|
||||
return FloatType(value.numf);
|
||||
else
|
||||
throw InvalidConversionException(type, TypeFloat);
|
||||
}
|
||||
|
||||
AnyType::operator StringType()
|
||||
@ -96,6 +108,18 @@ int NumberType::Value()
|
||||
return value.num;
|
||||
}
|
||||
|
||||
//Float Type
|
||||
|
||||
FloatType::FloatType(float number): AnyType(TypeFloat, ValueValue())
|
||||
{
|
||||
value.numf = number;
|
||||
}
|
||||
|
||||
float FloatType::Value()
|
||||
{
|
||||
return value.numf;
|
||||
}
|
||||
|
||||
//String type
|
||||
|
||||
StringType::StringType(std::string string): AnyType(TypeString, ValueValue())
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <typeinfo>
|
||||
#include "gui/interface/Point.h"
|
||||
|
||||
enum ValueType { TypeNumber, TypePoint, TypeString, TypeNull, TypeFunction };
|
||||
typedef union { int num; std::string* str; ui::Point* pt; } ValueValue;
|
||||
enum ValueType { TypeNumber, TypeFloat, TypePoint, TypeString, TypeNull, TypeFunction };
|
||||
typedef union { int num; float numf; std::string* str; ui::Point* pt; } ValueValue;
|
||||
|
||||
class GeneralException
|
||||
{
|
||||
@ -23,6 +23,7 @@ public:
|
||||
|
||||
|
||||
class NumberType;
|
||||
class FloatType;
|
||||
class StringType;
|
||||
class PointType;
|
||||
|
||||
@ -35,6 +36,7 @@ public:
|
||||
AnyType(ValueType type_, ValueValue value_);
|
||||
AnyType(const AnyType & v);
|
||||
operator NumberType();
|
||||
operator FloatType();
|
||||
operator StringType();
|
||||
operator PointType();
|
||||
ValueType GetType();
|
||||
@ -44,6 +46,8 @@ public:
|
||||
{
|
||||
case TypeNumber:
|
||||
return "Number";
|
||||
case TypeFloat:
|
||||
return "Float";
|
||||
case TypePoint:
|
||||
return "Point";
|
||||
case TypeString:
|
||||
@ -62,6 +66,8 @@ public:
|
||||
{
|
||||
case TypeNumber:
|
||||
return "Number";
|
||||
case TypeFloat:
|
||||
return "Float";
|
||||
case TypePoint:
|
||||
return "Point";
|
||||
case TypeString:
|
||||
@ -95,6 +101,13 @@ public:
|
||||
int Value();
|
||||
};
|
||||
|
||||
class FloatType: public AnyType
|
||||
{
|
||||
public:
|
||||
FloatType(float number);
|
||||
float Value();
|
||||
};
|
||||
|
||||
class StringType: public AnyType
|
||||
{
|
||||
public:
|
||||
|
@ -84,11 +84,13 @@ ValueType TPTScriptInterface::testType(std::string word)
|
||||
parseNumber:
|
||||
for(i = 0; i < word.length(); i++)
|
||||
{
|
||||
if(!(rawWord[i] >= '0' && rawWord[i] <= '9') && rawWord[i] != '.' && !(rawWord[i] == '-' && !i))
|
||||
if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i))
|
||||
{
|
||||
if(rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
|
||||
if (rawWord[i] == '.' && rawWord[i+1])
|
||||
goto parseFloat;
|
||||
else if (rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
|
||||
goto parsePoint;
|
||||
else if((rawWord[i] == '#' || rawWord[i] == 'x') &&
|
||||
else if ((rawWord[i] == '#' || (i && rawWord[i-1] == '0' && rawWord[i] == 'x')) &&
|
||||
((rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
|
||||
|| (rawWord[i+1] >= 'a' && rawWord[i+1] <= 'f')
|
||||
|| (rawWord[i+1] >= 'A' && rawWord[i+1] <= 'F')))
|
||||
@ -97,17 +99,23 @@ ValueType TPTScriptInterface::testType(std::string word)
|
||||
goto parseString;
|
||||
}
|
||||
}
|
||||
return TypeNumber;
|
||||
parseFloat:
|
||||
for (i++; i < word.length(); i++)
|
||||
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||
{
|
||||
goto parseString;
|
||||
}
|
||||
return TypeFloat;
|
||||
parseNumberHex:
|
||||
i++;
|
||||
for(; i < word.length(); i++)
|
||||
for (i++; i < word.length(); i++)
|
||||
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||
{
|
||||
goto parseString;
|
||||
}
|
||||
return TypeNumber;
|
||||
parsePoint:
|
||||
i++;
|
||||
for(; i < word.length(); i++)
|
||||
for (i++; i < word.length(); i++)
|
||||
if(!(rawWord[i] >= '0' && rawWord[i] <= '9'))
|
||||
{
|
||||
goto parseString;
|
||||
@ -117,22 +125,22 @@ ValueType TPTScriptInterface::testType(std::string word)
|
||||
return TypeString;
|
||||
}
|
||||
|
||||
int TPTScriptInterface::parseNumber(char * stringData)
|
||||
float TPTScriptInterface::parseNumber(char * stringData)
|
||||
{
|
||||
char cc;
|
||||
int base = 10;
|
||||
int currentNumber = 0;
|
||||
if(stringData[0] == '#')
|
||||
if (stringData[0] == '#')
|
||||
{
|
||||
stringData++;
|
||||
base = 16;
|
||||
}
|
||||
else if(stringData[0] == '0' && stringData[1] == 'x')
|
||||
else if (stringData[0] == '0' && stringData[1] == 'x')
|
||||
{
|
||||
stringData+=2;
|
||||
base = 16;
|
||||
}
|
||||
if(base == 16)
|
||||
if (base == 16)
|
||||
{
|
||||
while(cc = *(stringData++))
|
||||
{
|
||||
@ -149,7 +157,7 @@ int TPTScriptInterface::parseNumber(char * stringData)
|
||||
}
|
||||
else
|
||||
{
|
||||
return atof(stringData);
|
||||
return atoi(stringData);
|
||||
}
|
||||
return currentNumber;
|
||||
}
|
||||
@ -181,6 +189,8 @@ AnyType TPTScriptInterface::eval(std::deque<std::string> * words)
|
||||
break;
|
||||
case TypeNumber:
|
||||
return NumberType(parseNumber(rawWord));
|
||||
case TypeFloat:
|
||||
return FloatType(atof(rawWord));
|
||||
case TypePoint:
|
||||
{
|
||||
int pointX, pointY;
|
||||
@ -190,6 +200,7 @@ AnyType TPTScriptInterface::eval(std::deque<std::string> * words)
|
||||
case TypeString:
|
||||
return StringType(word);
|
||||
}
|
||||
return StringType(word);
|
||||
}
|
||||
|
||||
std::string TPTScriptInterface::FormatCommand(std::string command)
|
||||
@ -257,9 +268,14 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
|
||||
//Selector
|
||||
int newValue;
|
||||
if(value.GetType() == TypeNumber)
|
||||
float newValuef;
|
||||
if (value.GetType() == TypeNumber)
|
||||
{
|
||||
newValue = ((NumberType)value).Value();
|
||||
newValue = newValuef = ((NumberType)value).Value();
|
||||
}
|
||||
else if (value.GetType() == TypeFloat)
|
||||
{
|
||||
newValue = newValuef = ((FloatType)value).Value();
|
||||
}
|
||||
else if(value.GetType() == TypeString)
|
||||
{
|
||||
@ -267,9 +283,11 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
{
|
||||
std::string newString = ((StringType)value).Value();
|
||||
if (newString.at(newString.length()-1) == 'C')
|
||||
newValue = atoi(newString.substr(0, newString.length()-1).c_str())+273;
|
||||
newValuef = atof(newString.substr(0, newString.length()-1).c_str())+273.15;
|
||||
else if (newString.at(newString.length()-1) == 'F')
|
||||
newValue = (int)((atoi(newString.substr(0, newString.length()-1).c_str())-32.0f)*5/9+273.15f);
|
||||
newValuef = (atof(newString.substr(0, newString.length()-1).c_str())-32.0f)*5/9+273.15f;
|
||||
else
|
||||
throw GeneralException("Invalid value for assignment");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -285,7 +303,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
}
|
||||
else
|
||||
throw GeneralException("Invalid value for assignment");
|
||||
if (property.Value() == "type" && (newValue < 0 || newValue >= PT_NUM))
|
||||
if (property.Value() == "type" && (newValue < 0 || newValue >= PT_NUM || !sim->elements[newValue].Enabled))
|
||||
throw GeneralException("Invalid element");
|
||||
|
||||
if(selector.GetType() == TypePoint || selector.GetType() == TypeNumber)
|
||||
@ -309,7 +327,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
*((int*)(partsBlock+(partIndex*sizeof(Particle))+propertyOffset)) = newValue;
|
||||
break;
|
||||
case FormatFloat:
|
||||
*((float*)(partsBlock+(partIndex*sizeof(Particle))+propertyOffset)) = newValue;
|
||||
*((float*)(partsBlock+(partIndex*sizeof(Particle))+propertyOffset)) = newValuef;
|
||||
break;
|
||||
}
|
||||
returnValue = 1;
|
||||
@ -334,7 +352,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
if(sim->parts[j].type)
|
||||
{
|
||||
returnValue++;
|
||||
*((float*)(partsBlock+(j*sizeof(Particle))+propertyOffset)) = newValue;
|
||||
*((float*)(partsBlock+(j*sizeof(Particle))+propertyOffset)) = newValuef;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -371,7 +389,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
if(sim->parts[j].type == type)
|
||||
{
|
||||
returnValue++;
|
||||
*((float*)(partsBlock+(j*sizeof(Particle))+propertyOffset)) = newValue;
|
||||
*((float*)(partsBlock+(j*sizeof(Particle))+propertyOffset)) = newValuef;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
class TPTScriptInterface: public CommandInterface {
|
||||
protected:
|
||||
AnyType eval(std::deque<std::string> * words);
|
||||
int parseNumber(char * stringData);
|
||||
float parseNumber(char * stringData);
|
||||
AnyType tptS_set(std::deque<std::string> * words);
|
||||
AnyType tptS_create(std::deque<std::string> * words);
|
||||
AnyType tptS_delete(std::deque<std::string> * words);
|
||||
|
@ -24,7 +24,7 @@ int auxiliar_open(lua_State *L) {
|
||||
* Creates a new class with given methods
|
||||
* Methods whose names start with __ are passed directly to the metatable.
|
||||
\*-------------------------------------------------------------------------*/
|
||||
void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func) {
|
||||
void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) {
|
||||
luaL_newmetatable(L, classname); /* mt */
|
||||
/* create __index table to place methods */
|
||||
lua_pushstring(L, "__index"); /* mt,"__index" */
|
@ -31,11 +31,10 @@
|
||||
* RCS ID: $Id: auxiliar.h,v 1.9 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
int auxiliar_open(lua_State *L);
|
||||
void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func);
|
||||
void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func);
|
||||
void auxiliar_add2group(lua_State *L, const char *classname, const char *group);
|
||||
void auxiliar_setclass(lua_State *L, const char *classname, int objidx);
|
||||
void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx);
|
@ -4,9 +4,6 @@
|
||||
*
|
||||
* RCS ID: $Id: buffer.c,v 1.28 2007/06/11 23:44:54 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "buffer.h"
|
||||
|
||||
/*=========================================================================*\
|
||||
@ -225,7 +222,7 @@ static int recvline(p_buffer buf, luaL_Buffer *b) {
|
||||
pos = 0;
|
||||
while (pos < count && data[pos] != '\n') {
|
||||
/* we ignore all \r's */
|
||||
if (data[pos] != '\r') luaL_putchar(b, data[pos]);
|
||||
if (data[pos] != '\r') luaL_addchar(b, data[pos]);
|
||||
pos++;
|
||||
}
|
||||
if (pos < count) { /* found '\n' */
|
@ -17,7 +17,7 @@
|
||||
*
|
||||
* RCS ID: $Id: buffer.h,v 1.12 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
#include "io.h"
|
||||
#include "timeout.h"
|
@ -6,9 +6,6 @@
|
||||
\*=========================================================================*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "except.h"
|
||||
|
||||
/*=========================================================================*\
|
||||
@ -21,7 +18,7 @@ static int finalize(lua_State *L);
|
||||
static int do_nothing(lua_State *L);
|
||||
|
||||
/* except functions */
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{"newtry", global_newtry},
|
||||
{"protect", global_protect},
|
||||
{NULL, NULL}
|
@ -28,7 +28,7 @@
|
||||
* RCS ID: $Id: except.h,v 1.2 2005/09/29 06:11:41 diego Exp $
|
||||
\*=========================================================================*/
|
||||
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
int except_open(lua_State *L);
|
||||
|
@ -7,9 +7,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "inet.h"
|
||||
|
||||
/*=========================================================================*\
|
||||
@ -21,7 +18,7 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp);
|
||||
static int inet_global_gethostname(lua_State *L);
|
||||
|
||||
/* DNS functions */
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{ "toip", inet_global_toip },
|
||||
{ "tohostname", inet_global_tohostname },
|
||||
{ "gethostname", inet_global_gethostname},
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* RCS ID: $Id: inet.h,v 1.16 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
#include "socket.h"
|
||||
#include "timeout.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
* RCS ID: $Id: io.h,v 1.11 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include <stdio.h>
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
#include "timeout.h"
|
||||
|
@ -14,16 +14,6 @@
|
||||
* RCS ID: $Id: luasocket.c,v 1.53 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
|
||||
/*=========================================================================*\
|
||||
* Standard include files
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501)
|
||||
#include "compat-5.1.h"
|
||||
#endif
|
||||
|
||||
/*=========================================================================*\
|
||||
* LuaSocket includes
|
||||
\*=========================================================================*/
|
||||
@ -47,7 +37,7 @@ static int base_open(lua_State *L);
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* Modules and functions
|
||||
\*-------------------------------------------------------------------------*/
|
||||
static const luaL_reg mod[] = {
|
||||
static const luaL_Reg mod[] = {
|
||||
{"auxiliar", auxiliar_open},
|
||||
{"except", except_open},
|
||||
{"timeout", timeout_open},
|
||||
@ -59,7 +49,7 @@ static const luaL_reg mod[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{"skip", global_skip},
|
||||
{"__unload", global_unload},
|
||||
{NULL, NULL}
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
* RCS ID: $Id: luasocket.h,v 1.25 2007/06/11 23:44:54 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* Current socket library version
|
@ -6,8 +6,6 @@
|
||||
\*=========================================================================*/
|
||||
#include <string.h>
|
||||
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "auxiliar.h"
|
||||
#include "options.h"
|
||||
#include "inet.h"
|
@ -10,7 +10,7 @@
|
||||
* RCS ID: $Id: options.h,v 1.4 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
#include "socket.h"
|
||||
|
||||
/* option registry */
|
@ -6,9 +6,6 @@
|
||||
\*=========================================================================*/
|
||||
#include <string.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "socket.h"
|
||||
#include "timeout.h"
|
||||
#include "select.h"
|
||||
@ -27,7 +24,7 @@ static void make_assoc(lua_State *L, int tab);
|
||||
static int global_select(lua_State *L);
|
||||
|
||||
/* functions in library namespace */
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{"select", global_select},
|
||||
{NULL, NULL}
|
||||
};
|
@ -1,10 +1,6 @@
|
||||
#ifdef LUACONSOLE
|
||||
// socket.lua from luasocket compiled into a cpp file
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
#include "../LuaCompat.h"
|
||||
void luaopen_socket(lua_State *l){
|
||||
int socket_luac_sz=4061;
|
||||
const char* socket_luac="-----------------------------------------------------------------------------\012-- LuaSocket helper module\012-- Author: Diego Nehab\012-- RCS ID: $Id: socket.lua,v 1.22 2005/11/22 08:33:29 diego Exp $\012-----------------------------------------------------------------------------\012\012-----------------------------------------------------------------------------\012-- Declare module and import dependencies\012-----------------------------------------------------------------------------\012local base = _G\012local string = require(\042string\042)\012local math = require(\042math\042)\012local socket = require(\042socket.core\042)\012module(\042socket\042)\012\012-----------------------------------------------------------------------------\012-- Exported auxiliar functions\012-----------------------------------------------------------------------------\012function connect(address, port, laddress, lport)\012 local sock, err = socket.tcp()\012 if not sock then return nil, err end\012 if laddress then\012 local res, err = sock:bind(laddress, lport, -1)\012 if not res then return nil, err end\012 end\012 local res, err = sock:connect(address, port)\012 if not res then return nil, err end\012 return sock\012end\012\012function bind(host, port, backlog)\012 local sock, err = socket.tcp()\012 if not sock then return nil, err end\012 sock:setoption(\042reuseaddr\042, true)\012 local res, err = sock:bind(host, port)\012 if not res then return nil, err end\012 res, err = sock:listen(backlog)\012 if not res then return nil, err end\012 return sock\012end\012\012try = newtry()\012\012function choose(table)\012 return function(name, opt1, opt2)\012 if base.type(name) ~= \042string\042 then\012 name, opt1, opt2 = \042default\042, name, opt1\012 end\012 local f = table[name or \042nil\042]\012 if not f then base.error(\042unknown key (\042.. base.tostring(name) ..\042)\042, 3)\012 else return f(opt1, opt2) end\012 end\012end\012\012-----------------------------------------------------------------------------\012-- Socket sources and sinks, conforming to LTN12\012-----------------------------------------------------------------------------\012-- create namespaces inside LuaSocket namespace\012sourcet = {}\012sinkt = {}\012\012BLOCKSIZE = 2048\012\012sinkt[\042close-when-done\042] = function(sock)\012 return base.setmetatable({\012 getfd = function() return sock:getfd() end,\012 dirty = function() return sock:dirty() end\012 }, {\012 __call = function(self, chunk, err)\012 if not chunk then\012 sock:close()\012 return 1\012 else return sock:send(chunk) end\012 end\012 })\012end\012\012sinkt[\042keep-open\042] = function(sock)\012 return base.setmetatable({\012 getfd = function() return sock:getfd() end,\012 dirty = function() return sock:dirty() end\012 }, {\012 __call = function(self, chunk, err)\012 if chunk then return sock:send(chunk)\012 else return 1 end\012 end\012 })\012end\012\012sinkt[\042default\042] = sinkt[\042keep-open\042]\012\012sink = choose(sinkt)\012\012sourcet[\042by-length\042] = function(sock, length)\012 return base.setmetatable({\012 getfd = function() return sock:getfd() end,\012 dirty = function() return sock:dirty() end\012 }, {\012 __call = function()\012 if length <= 0 then return nil end\012 local size = math.min(socket.BLOCKSIZE, length)\012 local chunk, err = sock:receive(size)\012 if err then return nil, err end\012 length = length - string.len(chunk)\012 return chunk\012 end\012 })\012end\012\012sourcet[\042until-closed\042] = function(sock)\012 local done\012 return base.setmetatable({\012 getfd = function() return sock:getfd() end,\012 dirty = function() return sock:dirty() end\012 }, {\012 __call = function()\012 if done then return nil end\012 local chunk, err, partial = sock:receive(socket.BLOCKSIZE)\012 if not err then return chunk\012 elseif err == \042closed\042 then\012 sock:close()\012 done = 1\012 return partial\012 else return nil, err end\012 end\012 })\012end\012\012\012sourcet[\042default\042] = sourcet[\042until-closed\042]\012\012source = choose(sourcet)\012\012";
|
@ -1,2 +1,2 @@
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
void luaopen_socket(lua_State *l);
|
@ -6,9 +6,6 @@
|
||||
\*=========================================================================*/
|
||||
#include <string.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "auxiliar.h"
|
||||
#include "socket.h"
|
||||
#include "inet.h"
|
||||
@ -38,7 +35,7 @@ static int meth_setfd(lua_State *L);
|
||||
static int meth_dirty(lua_State *L);
|
||||
|
||||
/* tcp object methods */
|
||||
static luaL_reg tcp[] = {
|
||||
static luaL_Reg tcp[] = {
|
||||
{"__gc", meth_close},
|
||||
{"__tostring", auxiliar_tostring},
|
||||
{"accept", meth_accept},
|
||||
@ -73,7 +70,7 @@ static t_opt opt[] = {
|
||||
};
|
||||
|
||||
/* functions in library namespace */
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{"tcp", global_create},
|
||||
{NULL, NULL}
|
||||
};
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* RCS ID: $Id: tcp.h,v 1.7 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "timeout.h"
|
@ -6,9 +6,6 @@
|
||||
\*=========================================================================*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "auxiliar.h"
|
||||
#include "timeout.h"
|
||||
|
||||
@ -33,7 +30,7 @@
|
||||
static int timeout_lua_gettime(lua_State *L);
|
||||
static int timeout_lua_sleep(lua_State *L);
|
||||
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{ "gettime", timeout_lua_gettime },
|
||||
{ "sleep", timeout_lua_sleep },
|
||||
{ NULL, NULL }
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* RCS ID: $Id: timeout.h,v 1.14 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
/* timeout control structure */
|
||||
typedef struct t_timeout_ {
|
@ -6,9 +6,6 @@
|
||||
\*=========================================================================*/
|
||||
#include <string.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "auxiliar.h"
|
||||
#include "socket.h"
|
||||
#include "inet.h"
|
||||
@ -43,7 +40,7 @@ static int meth_setfd(lua_State *L);
|
||||
static int meth_dirty(lua_State *L);
|
||||
|
||||
/* udp object methods */
|
||||
static luaL_reg udp[] = {
|
||||
static luaL_Reg udp[] = {
|
||||
{"__gc", meth_close},
|
||||
{"__tostring", auxiliar_tostring},
|
||||
{"close", meth_close},
|
||||
@ -76,7 +73,7 @@ static t_opt opt[] = {
|
||||
};
|
||||
|
||||
/* functions in library namespace */
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{"udp", global_create},
|
||||
{NULL, NULL}
|
||||
};
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* RCS ID: $Id: udp.h,v 1.10 2005/10/07 04:40:59 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
#include "timeout.h"
|
||||
#include "socket.h"
|
@ -7,9 +7,6 @@
|
||||
\*=========================================================================*/
|
||||
#include <string.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "auxiliar.h"
|
||||
#include "socket.h"
|
||||
#include "options.h"
|
||||
@ -40,7 +37,7 @@ static const char *unix_tryconnect(p_unix un, const char *path);
|
||||
static const char *unix_trybind(p_unix un, const char *path);
|
||||
|
||||
/* unix object methods */
|
||||
static luaL_reg un[] = {
|
||||
static luaL_Reg un[] = {
|
||||
{"__gc", meth_close},
|
||||
{"__tostring", auxiliar_tostring},
|
||||
{"accept", meth_accept},
|
||||
@ -72,7 +69,7 @@ static t_opt opt[] = {
|
||||
};
|
||||
|
||||
/* our socket creation function */
|
||||
static luaL_reg func[] = {
|
||||
static luaL_Reg func[] = {
|
||||
{"unix", global_create},
|
||||
{NULL, NULL}
|
||||
};
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
* RCS ID: $Id: unix.h,v 1.9 2006/03/13 07:16:39 diego Exp $
|
||||
\*=========================================================================*/
|
||||
#include "lua.h"
|
||||
#include "../LuaCompat.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "timeout.h"
|
74
src/simulation/CoordStack.h
Normal file
74
src/simulation/CoordStack.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Simulation_CoordStack_h
|
||||
#define Simulation_CoordStack_h
|
||||
|
||||
#include "Config.h" // for XRES and YRES
|
||||
#include <exception>
|
||||
|
||||
class CoordStackOverflowException: public std::exception
|
||||
{
|
||||
public:
|
||||
CoordStackOverflowException() { }
|
||||
virtual const char* what() const throw()
|
||||
{
|
||||
return "Maximum number of entries in the coordinate stack was exceeded";
|
||||
}
|
||||
~CoordStackOverflowException() throw() {};
|
||||
};
|
||||
|
||||
class CoordStack
|
||||
{
|
||||
private:
|
||||
unsigned short (*stack)[2];
|
||||
int stack_size;
|
||||
const static int stack_limit = XRES*YRES;
|
||||
public:
|
||||
CoordStack() :
|
||||
stack(NULL),
|
||||
stack_size(0)
|
||||
{
|
||||
stack = (unsigned short(*)[2])(malloc(sizeof(unsigned short)*2*stack_limit));
|
||||
}
|
||||
~CoordStack()
|
||||
{
|
||||
if (stack) free(stack);
|
||||
}
|
||||
void push(int x, int y)
|
||||
{
|
||||
if (stack_size>=stack_limit)
|
||||
throw CoordStackOverflowException();
|
||||
stack[stack_size][0] = x;
|
||||
stack[stack_size][1] = y;
|
||||
stack_size++;
|
||||
}
|
||||
void pop(int& x, int& y)
|
||||
{
|
||||
stack_size--;
|
||||
x = stack[stack_size][0];
|
||||
y = stack[stack_size][1];
|
||||
}
|
||||
int getSize() const
|
||||
{
|
||||
return stack_size;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
stack_size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
@ -21,6 +21,7 @@
|
||||
#define FIREMODE 0x00FF0000
|
||||
#define FIRE_ADD 0x00010000
|
||||
#define FIRE_BLEND 0x00020000
|
||||
#define FIRE_SPARK 0x00040000
|
||||
|
||||
#define EFFECT 0xFF000000
|
||||
#define EFFECT_GRAVIN 0x01000000
|
||||
@ -29,7 +30,8 @@
|
||||
#define EFFECT_DBGLINES 0x08000000
|
||||
|
||||
#define RENDER_EFFE OPTIONS | PSPEC_STICKMAN | EFFECT | PMODE_SPARK | PMODE_FLARE | PMODE_LFLARE
|
||||
#define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_ADD | PMODE_BLEND | FIREMODE
|
||||
#define RENDER_FIRE OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_ADD | PMODE_BLEND | FIRE_ADD | FIRE_BLEND
|
||||
#define RENDER_SPRK OPTIONS | PSPEC_STICKMAN | PMODE_ADD | PMODE_BLEND | FIRE_SPARK
|
||||
#define RENDER_GLOW OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_GLOW | PMODE_ADD | PMODE_BLEND
|
||||
#define RENDER_BLUR OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_BLUR | PMODE_ADD | PMODE_BLEND
|
||||
#define RENDER_BLOB OPTIONS | PSPEC_STICKMAN | /*PMODE_FLAT |*/ PMODE_BLOB | PMODE_ADD | PMODE_BLEND
|
||||
|
@ -35,7 +35,9 @@
|
||||
#define FLAG_STAGNANT 0x1
|
||||
#define FLAG_SKIPMOVE 0x2 // skip movement for one frame, only implemented for PHOT
|
||||
#define FLAG_WATEREQUAL 0x4 //if a liquid was already checked during equalization
|
||||
#define FLAG_MOVABLE 0x8 // if can move
|
||||
#define FLAG_MOVABLE 0x8 // compatibility with old saves (moving SPNG), only applies to SPNG
|
||||
#define FLAG_PHOTDECO 0x8 // compatibility with old saves (decorated photons), only applies to PHOT. Having the same value as FLAG_MOVABLE is fine because they apply to different elements, and this saves space for future flags,
|
||||
|
||||
|
||||
#define ST_NONE 0
|
||||
#define ST_SOLID 1
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user