From 4c5667fbc66a99b6f120fa990b83c71e80770d32 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Thu, 9 May 2013 15:51:01 -0400 Subject: Fix tpt.message_box correctly to only accept true/false third arg. diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index cb6fd9a..3557c6f 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1739,7 +1739,7 @@ int luatpt_message_box(lua_State* l) { std::string title = std::string(luaL_optstring(l, 1, "Title")); std::string message = std::string(luaL_optstring(l, 2, "Message")); - int large = luaL_optint(l, 3, 0); + int large = lua_isboolean(l, 3)?lua_toboolean(l, 3):0; new InformationMessage(title, message, large); return 0; } -- cgit v0.9.2-21-gd62e From d1c8978a34906c1adb6bdc3fbae7f12c06aa8324 Mon Sep 17 00:00:00 2001 From: cracker64 Date: Thu, 9 May 2013 16:03:14 -0400 Subject: just one to_boolean works... any number is true. diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 3557c6f..9c73936 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1739,7 +1739,7 @@ int luatpt_message_box(lua_State* l) { std::string title = std::string(luaL_optstring(l, 1, "Title")); std::string message = std::string(luaL_optstring(l, 2, "Message")); - int large = lua_isboolean(l, 3)?lua_toboolean(l, 3):0; + int large = lua_toboolean(l, 3); new InformationMessage(title, message, large); return 0; } -- cgit v0.9.2-21-gd62e From e53f2bf0b5115917befc1f120a6731bca30e2024 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Thu, 9 May 2013 23:33:43 +0100 Subject: Forward resample argument correctly from VideoBuffer resize method diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp index bacb421..09da936 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -47,7 +47,7 @@ void VideoBuffer::Resize(float factor, bool resample) { int newWidth = ((float)Width)*factor; int newHeight = ((float)Height)*factor; - Resize(newWidth, newHeight); + Resize(newWidth, newHeight, resample); } void VideoBuffer::Resize(int width, int height, bool resample, bool fixedRatio) -- cgit v0.9.2-21-gd62e From 67e1213905edbd248ef4d434c3e5e53c151828a7 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 9 May 2013 18:52:13 -0400 Subject: fix tpt.message_box, fix compiling error diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 4d3c0c8..cb6fd9a 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1739,7 +1739,7 @@ int luatpt_message_box(lua_State* l) { std::string title = std::string(luaL_optstring(l, 1, "Title")); std::string message = std::string(luaL_optstring(l, 2, "Message")); - int large = luaL_optint(l, 1, 0); + int large = luaL_optint(l, 3, 0); new InformationMessage(title, message, large); return 0; } diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 55fac92..65fe189 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -130,13 +130,13 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { float rbx = gvx; float rby = gvy; bool rbLowGrav = false; - float tmp = fmaxf(fabsf(rbx), fabsf(rby)); + float tmp = fabsf(rbx) > fabsf(rby)?fabsf(rbx):fabsf(rby); if (tmp < 0.001f) { rbLowGrav = true; rbx = -parts[i].vx; rby = -parts[i].vy; - tmp = fmaxf(fabsf(rbx), fabsf(rby)); + tmp = fabsf(rbx) > fabsf(rby)?fabsf(rbx):fabsf(rby); } if (tmp < 0.001f) { -- cgit v0.9.2-21-gd62e From c2cdec9e621a2af25a256a484fdf68adc46ea96f Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sat, 11 May 2013 11:52:35 +0100 Subject: Togglable lua scripting diff --git a/SConscript b/SConscript index da4d53e..96ff876 100755 --- a/SConscript +++ b/SConscript @@ -44,6 +44,7 @@ AddOption('--sse2',dest="sse2",action='store_true',default=False,help="Enable SS 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.") @@ -90,15 +91,16 @@ if not GetOption("macosx"): env.Append(CPPPATH=[GetOption("sdl-dir")]) #Find correct lua include dir - 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")]) + 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")]) if not GetOption('nofft'): #Check for FFT lib @@ -121,7 +123,7 @@ if not GetOption("macosx"): raise SystemExit(1) #Check for Lua lib - if not GetOption("macosx"): + 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) @@ -135,9 +137,11 @@ else: env.Append(CPPPATH=['src/', 'data/', 'generated/']) env.Append(CCFLAGS=['-w', '-std=c++98', '-fkeep-inline-functions']) env.Append(LIBS=['pthread', 'm']) -env.Append(CPPDEFINES=["LUACONSOLE", "_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"]) +env.Append(CPPDEFINES=["_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"]) if not GetOption('nofft'): env.Append(CPPDEFINES=["GRAVFFT"]) +if not GetOption('nolua'): + env.Append(CPPDEFINED=["LUACONSOLE"]) if GetOption("ptw32-static"): env.Append(CPPDEFINES=['PTW32_STATIC_LIB']); @@ -267,7 +271,8 @@ sources+=Glob("src/gui/*/*.cpp") sources+=Glob("src/simulation/elements/*.cpp") sources+=Glob("src/simulation/tools/*.cpp") sources+=Glob("src/client/requestbroker/*.cpp") -sources+=Glob("src/socket/*.c") +if not GetOption('nolua'): + sources+=Glob("src/socket/*.c") #for source in sources: # print str(source) diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 9c73936..82ae6a0 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE #include #include #include @@ -1983,4 +1984,4 @@ int luatpt_screenshot(lua_State* l) Client::Ref().WriteFile(data, filename.str()); return 0; } - +#endif \ No newline at end of file diff --git a/src/cat/LuaBit.cpp b/src/cat/LuaBit.cpp index c55f45a..9807441 100644 --- a/src/cat/LuaBit.cpp +++ b/src/cat/LuaBit.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE /* ** Lua BitOp -- a bit operations library for Lua 5.1/5.2. ** http://bitop.luajit.org/ @@ -189,4 +190,4 @@ int luaopen_bit(lua_State *L) #endif return 1; } - +#endif \ No newline at end of file diff --git a/src/cat/LuaButton.cpp b/src/cat/LuaButton.cpp index 013adac..3f7ba26 100644 --- a/src/cat/LuaButton.cpp +++ b/src/cat/LuaButton.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -111,4 +112,5 @@ void LuaButton::triggerAction() LuaButton::~LuaButton() { -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/cat/LuaCheckbox.cpp b/src/cat/LuaCheckbox.cpp index bac5c4e..d844cf5 100644 --- a/src/cat/LuaCheckbox.cpp +++ b/src/cat/LuaCheckbox.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -109,4 +110,5 @@ void LuaCheckbox::triggerAction() LuaCheckbox::~LuaCheckbox() { -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/cat/LuaComponent.cpp b/src/cat/LuaComponent.cpp index 75e7a21..c32db6d 100644 --- a/src/cat/LuaComponent.cpp +++ b/src/cat/LuaComponent.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -79,4 +80,5 @@ LuaComponent::~LuaComponent() if(component->GetParentWindow()) component->GetParentWindow()->RemoveComponent(component); delete component; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/cat/LuaLabel.cpp b/src/cat/LuaLabel.cpp index b08e687..15a7720 100644 --- a/src/cat/LuaLabel.cpp +++ b/src/cat/LuaLabel.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -52,4 +53,5 @@ int LuaLabel::text(lua_State * l) LuaLabel::~LuaLabel() { -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/cat/LuaProgressBar.cpp b/src/cat/LuaProgressBar.cpp index 08c88ca..670d88a 100644 --- a/src/cat/LuaProgressBar.cpp +++ b/src/cat/LuaProgressBar.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -68,4 +69,5 @@ int LuaProgressBar::status(lua_State * l) LuaProgressBar::~LuaProgressBar() { -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 4b2e749..d299c2c 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE #include #include #include @@ -2201,3 +2202,4 @@ std::string LuaScriptInterface::FormatCommand(std::string command) LuaScriptInterface::~LuaScriptInterface() { delete legacy; } +#endif \ No newline at end of file diff --git a/src/cat/LuaSlider.cpp b/src/cat/LuaSlider.cpp index ce07ebb..e022ba0 100644 --- a/src/cat/LuaSlider.cpp +++ b/src/cat/LuaSlider.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -109,4 +110,5 @@ void LuaSlider::triggerOnValueChanged() LuaSlider::~LuaSlider() { -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/cat/LuaTextbox.cpp b/src/cat/LuaTextbox.cpp index 5721525..be4add9 100644 --- a/src/cat/LuaTextbox.cpp +++ b/src/cat/LuaTextbox.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -112,4 +113,5 @@ int LuaTextbox::text(lua_State * l) LuaTextbox::~LuaTextbox() { -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/cat/LuaWindow.cpp b/src/cat/LuaWindow.cpp index d765d68..80fc014 100644 --- a/src/cat/LuaWindow.cpp +++ b/src/cat/LuaWindow.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE extern "C" { #include "lua.h" @@ -590,4 +591,5 @@ LuaWindow::~LuaWindow() if(ui::Engine::Ref().GetWindow() == window) ui::Engine::Ref().CloseWindow(); delete window; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index a3ea66d..dfdd307 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -9,8 +9,10 @@ #include "simulation/Elements.h" #include "simulation/ElementGraphics.h" #include "simulation/Air.h" +#ifdef LUACONSOLE #include "cat/LuaScriptInterface.h" #include "cat/LuaScriptHelper.h" +#endif extern "C" { #include "hmap.h" @@ -1212,7 +1214,7 @@ void Renderer::render_parts() { if (elements[t].Graphics) { -#ifndef RENDERER +#if !defined(RENDERER) && defined(LUACONSOLE) if (lua_gr_func[t]) { luacon_graphicsReplacement(this, &(sim->parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb, i); diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index ed1a866..d7b808b 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -145,8 +145,12 @@ GameController::GameController(): gameView->AttachController(this); gameModel->AddObserver(gameView); - commandInterface = new LuaScriptInterface(this, gameModel);//new TPTScriptInterface(); +#ifdef LUACONSOLE + commandInterface = new LuaScriptInterface(this, gameModel); ((LuaScriptInterface*)commandInterface)->SetWindow(gameView); +#else + commandInterface = new TPTScriptInterface(this, gameModel); +#endif commandInterface->OnBrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().X); ActiveToolChanged(0, gameModel->GetActiveTool(0)); @@ -706,7 +710,9 @@ void GameController::Tick() { if(firstTick) { +#ifdef LUACONSOLE ((LuaScriptInterface*)commandInterface)->Init(); +#endif if(!Client::Ref().GetPrefBool("InstallCheck", false)) { Client::Ref().SetPref("InstallCheck", true); diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index c34d44a..f2cf26b 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -14,8 +14,11 @@ #include "gui/console/ConsoleController.h" #include "gui/localbrowser/LocalBrowserController.h" #include "gui/options/OptionsController.h" -//#include "cat/TPTScriptInterface.h" +#ifdef LUACONSOLE #include "cat/LuaScriptInterface.h" +#else +#include "cat/TPTScriptInterface.h" +#endif #include "client/ClientListener.h" #include "RenderPreset.h" #include "Menu.h" diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index c1f56f7..50239b1 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -24,8 +24,10 @@ #include "Snapshot.h" //#include "StorageClasses.h" +#ifdef LUACONSOLE #include "cat/LuaScriptInterface.h" #include "cat/LuaScriptHelper.h" +#endif int Simulation::Load(GameSave * save) { @@ -4196,7 +4198,11 @@ void Simulation::update_particles_i(int start, int inc) } //call the particle update function, if there is one +#if !defined(RENDERER) && defined(LUACONSOLE) if (elements[t].Update && lua_el_mode[t] != 2) +#else + if (elements[t].Update) +#endif { if ((*(elements[t].Update))(this, i, x, y, surround_space, nt, parts, pmap)) continue; @@ -4207,6 +4213,7 @@ void Simulation::update_particles_i(int start, int inc) y = (int)(parts[i].y+0.5f); } } +#if !defined(RENDERER) && defined(LUACONSOLE) if(lua_el_mode[t]) { if(luacon_elementReplacement(this, i, x, y, surround_space, nt, parts, pmap)) @@ -4215,6 +4222,7 @@ void Simulation::update_particles_i(int start, int inc) x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); } +#endif if(legacy_enable)//if heat sim is off Element::legacyUpdate(this, i,x,y,surround_space,nt, parts, pmap); diff --git a/src/socket/socket.lua.cpp b/src/socket/socket.lua.cpp index 80b32f7..0032e2c 100644 --- a/src/socket/socket.lua.cpp +++ b/src/socket/socket.lua.cpp @@ -1,3 +1,4 @@ +#ifdef LUACONSOLE // socket.lua from luasocket compiled into a cpp file extern "C" { #include "lua.h" @@ -10,3 +11,4 @@ void luaopen_socket(lua_State *l){ luaL_loadbuffer(l, socket_luac, socket_luac_sz, "@builtin socket.lua"); lua_call(l, 0, 0); } +#endif \ No newline at end of file -- cgit v0.9.2-21-gd62e From 4d9b9b17d7593333e271de07b68fbef64b310cfa Mon Sep 17 00:00:00 2001 From: mniip Date: Sat, 11 May 2013 15:08:32 +0400 Subject: D: diff --git a/src/Activity.h b/src/Activity.h index b91444d..285e6db 100644 --- a/src/Activity.h +++ b/src/Activity.h @@ -39,4 +39,4 @@ public: } } virtual ~WindowActivity() {} -}; \ No newline at end of file +}; diff --git a/src/Format.cpp b/src/Format.cpp index e4056c2..3bfb17b 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -433,4 +433,4 @@ unsigned long update_crc(unsigned long crc, unsigned char *buf, int len) unsigned long format::CalculateCRC(unsigned char * data, int len) { return update_crc(0xffffffffL, data, len) ^ 0xffffffffL; -} \ No newline at end of file +} diff --git a/src/Format.h b/src/Format.h index a791511..588cacf 100644 --- a/src/Format.h +++ b/src/Format.h @@ -35,4 +35,4 @@ namespace format std::vector VideoBufferToPTI(const VideoBuffer & vidBuf); VideoBuffer * PTIToVideoBuffer(std::vector & data); unsigned long CalculateCRC(unsigned char * data, int length); -} \ No newline at end of file +} diff --git a/src/cajun/reader.h b/src/cajun/reader.h index 553af35..4513297 100644 --- a/src/cajun/reader.h +++ b/src/cajun/reader.h @@ -145,4 +145,4 @@ private: } // End namespace -//#include "reader.inl" \ No newline at end of file +//#include "reader.inl" diff --git a/src/cajun/writer.h b/src/cajun/writer.h index f3d9596..2ac410a 100644 --- a/src/cajun/writer.h +++ b/src/cajun/writer.h @@ -75,4 +75,4 @@ private: } // End namespace -//#include "writer.inl" \ No newline at end of file +//#include "writer.inl" diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 82ae6a0..7eed062 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1984,4 +1984,4 @@ int luatpt_screenshot(lua_State* l) Client::Ref().WriteFile(data, filename.str()); return 0; } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaBit.cpp b/src/cat/LuaBit.cpp index 9807441..f1479d0 100644 --- a/src/cat/LuaBit.cpp +++ b/src/cat/LuaBit.cpp @@ -190,4 +190,4 @@ int luaopen_bit(lua_State *L) #endif return 1; } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaButton.cpp b/src/cat/LuaButton.cpp index 3f7ba26..1b55f89 100644 --- a/src/cat/LuaButton.cpp +++ b/src/cat/LuaButton.cpp @@ -113,4 +113,4 @@ void LuaButton::triggerAction() LuaButton::~LuaButton() { } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaButton.h b/src/cat/LuaButton.h index 012779d..69a77a4 100644 --- a/src/cat/LuaButton.h +++ b/src/cat/LuaButton.h @@ -30,4 +30,4 @@ public: LuaButton(lua_State * l); ~LuaButton(); -}; \ No newline at end of file +}; diff --git a/src/cat/LuaCheckbox.cpp b/src/cat/LuaCheckbox.cpp index d844cf5..55c39db 100644 --- a/src/cat/LuaCheckbox.cpp +++ b/src/cat/LuaCheckbox.cpp @@ -111,4 +111,4 @@ void LuaCheckbox::triggerAction() LuaCheckbox::~LuaCheckbox() { } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaCheckbox.h b/src/cat/LuaCheckbox.h index 479cab2..0f2e8ad 100644 --- a/src/cat/LuaCheckbox.h +++ b/src/cat/LuaCheckbox.h @@ -30,4 +30,4 @@ public: LuaCheckbox(lua_State * l); ~LuaCheckbox(); -}; \ No newline at end of file +}; diff --git a/src/cat/LuaComponent.cpp b/src/cat/LuaComponent.cpp index c32db6d..028dfb5 100644 --- a/src/cat/LuaComponent.cpp +++ b/src/cat/LuaComponent.cpp @@ -81,4 +81,4 @@ LuaComponent::~LuaComponent() component->GetParentWindow()->RemoveComponent(component); delete component; } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaComponent.h b/src/cat/LuaComponent.h index 9e11b12..8e40890 100644 --- a/src/cat/LuaComponent.h +++ b/src/cat/LuaComponent.h @@ -30,4 +30,4 @@ public: ui::Component * GetComponent() { return component; } LuaComponent(lua_State * l); ~LuaComponent(); -}; \ No newline at end of file +}; diff --git a/src/cat/LuaLabel.cpp b/src/cat/LuaLabel.cpp index 15a7720..4131918 100644 --- a/src/cat/LuaLabel.cpp +++ b/src/cat/LuaLabel.cpp @@ -54,4 +54,4 @@ int LuaLabel::text(lua_State * l) LuaLabel::~LuaLabel() { } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaLabel.h b/src/cat/LuaLabel.h index a80ea4f..2653d9c 100644 --- a/src/cat/LuaLabel.h +++ b/src/cat/LuaLabel.h @@ -26,4 +26,4 @@ public: LuaLabel(lua_State * l); ~LuaLabel(); -}; \ No newline at end of file +}; diff --git a/src/cat/LuaLuna.h b/src/cat/LuaLuna.h index 1d5d937..9fa4042 100644 --- a/src/cat/LuaLuna.h +++ b/src/cat/LuaLuna.h @@ -157,4 +157,4 @@ private: lua_pushfstring(L, "%s (%s)", T::className, buff); return 1; } -}; \ No newline at end of file +}; diff --git a/src/cat/LuaProgressBar.cpp b/src/cat/LuaProgressBar.cpp index 670d88a..787cfcf 100644 --- a/src/cat/LuaProgressBar.cpp +++ b/src/cat/LuaProgressBar.cpp @@ -70,4 +70,4 @@ int LuaProgressBar::status(lua_State * l) LuaProgressBar::~LuaProgressBar() { } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaProgressBar.h b/src/cat/LuaProgressBar.h index 9de56e7..a27ddee 100644 --- a/src/cat/LuaProgressBar.h +++ b/src/cat/LuaProgressBar.h @@ -27,4 +27,4 @@ public: LuaProgressBar(lua_State * l); ~LuaProgressBar(); -}; \ No newline at end of file +}; diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index d299c2c..09170a9 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -2202,4 +2202,4 @@ std::string LuaScriptInterface::FormatCommand(std::string command) LuaScriptInterface::~LuaScriptInterface() { delete legacy; } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaSlider.cpp b/src/cat/LuaSlider.cpp index e022ba0..f8505d2 100644 --- a/src/cat/LuaSlider.cpp +++ b/src/cat/LuaSlider.cpp @@ -111,4 +111,4 @@ void LuaSlider::triggerOnValueChanged() LuaSlider::~LuaSlider() { } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaSlider.h b/src/cat/LuaSlider.h index f9f327e..a1a97c4 100644 --- a/src/cat/LuaSlider.h +++ b/src/cat/LuaSlider.h @@ -30,4 +30,4 @@ public: LuaSlider(lua_State * l); ~LuaSlider(); -}; \ No newline at end of file +}; diff --git a/src/cat/LuaTextbox.cpp b/src/cat/LuaTextbox.cpp index be4add9..89191a6 100644 --- a/src/cat/LuaTextbox.cpp +++ b/src/cat/LuaTextbox.cpp @@ -114,4 +114,4 @@ int LuaTextbox::text(lua_State * l) LuaTextbox::~LuaTextbox() { } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaTextbox.h b/src/cat/LuaTextbox.h index 437875f..9a45f61 100644 --- a/src/cat/LuaTextbox.h +++ b/src/cat/LuaTextbox.h @@ -30,4 +30,4 @@ public: LuaTextbox(lua_State * l); ~LuaTextbox(); -}; \ No newline at end of file +}; diff --git a/src/cat/LuaWindow.cpp b/src/cat/LuaWindow.cpp index 80fc014..84e32e1 100644 --- a/src/cat/LuaWindow.cpp +++ b/src/cat/LuaWindow.cpp @@ -592,4 +592,4 @@ LuaWindow::~LuaWindow() ui::Engine::Ref().CloseWindow(); delete window; } -#endif \ No newline at end of file +#endif diff --git a/src/cat/LuaWindow.h b/src/cat/LuaWindow.h index f48c5f9..187b3dd 100644 --- a/src/cat/LuaWindow.h +++ b/src/cat/LuaWindow.h @@ -79,4 +79,4 @@ public: ui::Window * GetWindow() { return window; } LuaWindow(lua_State * l); ~LuaWindow(); -}; \ No newline at end of file +}; diff --git a/src/client/requestbroker/APIRequest.cpp b/src/client/requestbroker/APIRequest.cpp index d94171e..10b2a8b 100644 --- a/src/client/requestbroker/APIRequest.cpp +++ b/src/client/requestbroker/APIRequest.cpp @@ -134,4 +134,4 @@ void APIRequest::Cleanup() Parser->Cleanup(ResultObject); ResultObject = NULL; } -} \ No newline at end of file +} diff --git a/src/client/requestbroker/APIResultParser.h b/src/client/requestbroker/APIResultParser.h index 40c7512..aadfbfb 100644 --- a/src/client/requestbroker/APIResultParser.h +++ b/src/client/requestbroker/APIResultParser.h @@ -13,4 +13,4 @@ public: virtual ~APIResultParser() { } }; -#endif \ No newline at end of file +#endif diff --git a/src/client/requestbroker/ImageRequest.cpp b/src/client/requestbroker/ImageRequest.cpp index 778d8b6..9c8d42c 100644 --- a/src/client/requestbroker/ImageRequest.cpp +++ b/src/client/requestbroker/ImageRequest.cpp @@ -147,4 +147,4 @@ void ImageRequest::Cleanup() delete ((VideoBuffer*)ResultObject); ResultObject = NULL; } -} \ No newline at end of file +} diff --git a/src/client/requestbroker/ImageRequest.h b/src/client/requestbroker/ImageRequest.h index 9a2cf34..2fc0b62 100644 --- a/src/client/requestbroker/ImageRequest.h +++ b/src/client/requestbroker/ImageRequest.h @@ -11,4 +11,4 @@ public: virtual RequestBroker::ProcessResponse Process(RequestBroker & rb); virtual ~ImageRequest(); virtual void Cleanup(); -}; \ No newline at end of file +}; diff --git a/src/client/requestbroker/RequestBroker.cpp b/src/client/requestbroker/RequestBroker.cpp index cfa1294..17ee1cc 100644 --- a/src/client/requestbroker/RequestBroker.cpp +++ b/src/client/requestbroker/RequestBroker.cpp @@ -309,4 +309,4 @@ void RequestBroker::Request::Cleanup() (*iter)->Cleanup(); iter++; } -} \ No newline at end of file +} diff --git a/src/client/requestbroker/RequestBroker.h b/src/client/requestbroker/RequestBroker.h index 4c31e89..f6454a9 100644 --- a/src/client/requestbroker/RequestBroker.h +++ b/src/client/requestbroker/RequestBroker.h @@ -75,4 +75,4 @@ public: virtual ~Request(); virtual void Cleanup(); }; -}; \ No newline at end of file +}; diff --git a/src/client/requestbroker/ThumbRenderRequest.cpp b/src/client/requestbroker/ThumbRenderRequest.cpp index 3601401..1b38529 100644 --- a/src/client/requestbroker/ThumbRenderRequest.cpp +++ b/src/client/requestbroker/ThumbRenderRequest.cpp @@ -50,4 +50,4 @@ void ThumbRenderRequest::Cleanup() delete ((VideoBuffer*)ResultObject); ResultObject = NULL; } -} \ No newline at end of file +} diff --git a/src/debug/DebugInfo.h b/src/debug/DebugInfo.h index 49e46a4..4cdfedc 100644 --- a/src/debug/DebugInfo.h +++ b/src/debug/DebugInfo.h @@ -6,4 +6,4 @@ class DebugInfo { public: virtual void Draw(ui::Point position) {} -}; \ No newline at end of file +}; diff --git a/src/debug/ElementPopulation.cpp b/src/debug/ElementPopulation.cpp index 4caaf11..17e3c3d 100644 --- a/src/debug/ElementPopulation.cpp +++ b/src/debug/ElementPopulation.cpp @@ -81,4 +81,4 @@ void ElementPopulationDebug::Draw(ui::Point position) ElementPopulationDebug::~ElementPopulationDebug() { -} \ No newline at end of file +} diff --git a/src/debug/ElementPopulation.h b/src/debug/ElementPopulation.h index 845b91e..a1a2093 100644 --- a/src/debug/ElementPopulation.h +++ b/src/debug/ElementPopulation.h @@ -11,4 +11,4 @@ public: ElementPopulationDebug(Simulation * sim); virtual void Draw(ui::Point position); virtual ~ElementPopulationDebug(); -}; \ No newline at end of file +}; diff --git a/src/gui/dialogues/LegacyDialogues.h b/src/gui/dialogues/LegacyDialogues.h index 7f6097d..a604905 100644 --- a/src/gui/dialogues/LegacyDialogues.h +++ b/src/gui/dialogues/LegacyDialogues.h @@ -8,4 +8,4 @@ void ErrorUI(std::string title, std::string message) {} void InformationUI(std::string title, std::string message) {} -std::string MessagePromptUI(std::string title, std::string message, std::string text, std::string placeholder) {} \ No newline at end of file +std::string MessagePromptUI(std::string title, std::string message, std::string text, std::string placeholder) {} diff --git a/src/gui/filebrowser/FileBrowserActivity.cpp b/src/gui/filebrowser/FileBrowserActivity.cpp index 7612ae2..d27f1b1 100644 --- a/src/gui/filebrowser/FileBrowserActivity.cpp +++ b/src/gui/filebrowser/FileBrowserActivity.cpp @@ -333,4 +333,4 @@ FileBrowserActivity::~FileBrowserActivity() { if(callback) delete callback; -} \ No newline at end of file +} diff --git a/src/gui/filebrowser/FileBrowserActivity.h b/src/gui/filebrowser/FileBrowserActivity.h index d607d49..3696ba7 100644 --- a/src/gui/filebrowser/FileBrowserActivity.h +++ b/src/gui/filebrowser/FileBrowserActivity.h @@ -62,4 +62,4 @@ public: virtual void NotifyError(Task * task); virtual void NotifyProgress(Task * task); virtual void NotifyStatus(Task * task); -}; \ No newline at end of file +}; diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index 05726d3..aff535e 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -232,4 +232,4 @@ void PropertyWindow::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl void PropertyTool::Click(Simulation * sim, Brush * brush, ui::Point position) { new PropertyWindow(this, sim, position); -} \ No newline at end of file +} diff --git a/src/gui/game/RenderPreset.h b/src/gui/game/RenderPreset.h index 9cc9f4c..91689c7 100644 --- a/src/gui/game/RenderPreset.h +++ b/src/gui/game/RenderPreset.h @@ -16,4 +16,4 @@ public: ColourMode(colourMode) {} }; -#endif \ No newline at end of file +#endif diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp index def6e46..ed43da7 100644 --- a/src/gui/game/Tool.cpp +++ b/src/gui/game/Tool.cpp @@ -212,4 +212,4 @@ void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point posi void PlopTool::Click(Simulation * sim, Brush * brush, ui::Point position) { sim->create_part(-1, position.X, position.Y, toolID); -} \ No newline at end of file +} diff --git a/src/gui/interface/ContextMenu.cpp b/src/gui/interface/ContextMenu.cpp index 0d34e19..aa9eeb5 100644 --- a/src/gui/interface/ContextMenu.cpp +++ b/src/gui/interface/ContextMenu.cpp @@ -96,4 +96,4 @@ void ContextMenu::OnDraw() Graphics * g = ui::Engine::Ref().g; g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 100, 100, 100, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha); -} \ No newline at end of file +} diff --git a/src/gui/interface/ContextMenu.h b/src/gui/interface/ContextMenu.h index e5549d3..c7d8b5f 100644 --- a/src/gui/interface/ContextMenu.h +++ b/src/gui/interface/ContextMenu.h @@ -37,4 +37,4 @@ public: }; } -#endif \ No newline at end of file +#endif diff --git a/src/gui/interface/LuaProgressBar.h b/src/gui/interface/LuaProgressBar.h index dc2ef4e..98283cb 100644 --- a/src/gui/interface/LuaProgressBar.h +++ b/src/gui/interface/LuaProgressBar.h @@ -27,4 +27,4 @@ public: LuaProgressBar(lua_State * l); ~LuaProgressBar(); -}; \ No newline at end of file +}; diff --git a/src/gui/interface/ProgressBar.cpp b/src/gui/interface/ProgressBar.cpp index 95da72c..80eb9c6 100644 --- a/src/gui/interface/ProgressBar.cpp +++ b/src/gui/interface/ProgressBar.cpp @@ -78,4 +78,4 @@ void ProgressBar::Tick(float dt) intermediatePos += 1.0f*dt; if(intermediatePos>100.0f) intermediatePos = 0.0f; -} \ No newline at end of file +} diff --git a/src/gui/interface/ScrollPanel.cpp b/src/gui/interface/ScrollPanel.cpp index 74f6b62..11a4f71 100644 --- a/src/gui/interface/ScrollPanel.cpp +++ b/src/gui/interface/ScrollPanel.cpp @@ -170,4 +170,4 @@ void ScrollPanel::XTick(float dt) scrollBarWidth++; else if(!mouseInside && scrollBarWidth > 0 && !scrollbarSelected) scrollBarWidth--; -} \ No newline at end of file +} diff --git a/src/gui/interface/ScrollPanel.h b/src/gui/interface/ScrollPanel.h index c26c420..08b5069 100644 --- a/src/gui/interface/ScrollPanel.h +++ b/src/gui/interface/ScrollPanel.h @@ -29,4 +29,4 @@ namespace ui virtual void XOnMouseUp(int x, int y, unsigned int button); virtual void XOnMouseMoved(int localx, int localy, int dx, int dy); }; -} \ No newline at end of file +} diff --git a/src/gui/save/LocalSaveActivity.cpp b/src/gui/save/LocalSaveActivity.cpp index f494f09..084f2f2 100644 --- a/src/gui/save/LocalSaveActivity.cpp +++ b/src/gui/save/LocalSaveActivity.cpp @@ -142,4 +142,4 @@ LocalSaveActivity::~LocalSaveActivity() delete thumbnail; if(callback) delete callback; -} \ No newline at end of file +} diff --git a/src/gui/save/LocalSaveActivity.h b/src/gui/save/LocalSaveActivity.h index b58af5e..4668dd3 100644 --- a/src/gui/save/LocalSaveActivity.h +++ b/src/gui/save/LocalSaveActivity.h @@ -36,4 +36,4 @@ public: virtual void OnDraw(); virtual void OnResponseReady(void * imagePtr); virtual ~LocalSaveActivity(); -}; \ No newline at end of file +}; diff --git a/src/gui/save/ServerSaveActivity.h b/src/gui/save/ServerSaveActivity.h index 793579b..ceca173 100644 --- a/src/gui/save/ServerSaveActivity.h +++ b/src/gui/save/ServerSaveActivity.h @@ -49,4 +49,4 @@ protected: friend class CancelAction; friend class SaveAction; friend class RulesAction; -}; \ No newline at end of file +}; diff --git a/src/pim/Generator.cpp b/src/pim/Generator.cpp index a791211..3292c8a 100644 --- a/src/pim/Generator.cpp +++ b/src/pim/Generator.cpp @@ -515,4 +515,4 @@ namespace pim } } -} \ No newline at end of file +} diff --git a/src/pim/Generator.h b/src/pim/Generator.h index 2eb1029..4dd2cfe 100644 --- a/src/pim/Generator.h +++ b/src/pim/Generator.h @@ -175,4 +175,4 @@ namespace pim void Return(); }; } -} \ No newline at end of file +} diff --git a/src/pim/Machine.h b/src/pim/Machine.h index 3bf1131..0cbac4c 100644 --- a/src/pim/Machine.h +++ b/src/pim/Machine.h @@ -117,4 +117,4 @@ namespace pim return word; } }; -} \ No newline at end of file +} diff --git a/src/pim/Opcodes.h b/src/pim/Opcodes.h index 4e1a7ce..a701e97 100644 --- a/src/pim/Opcodes.h +++ b/src/pim/Opcodes.h @@ -9,4 +9,4 @@ namespace pim #undef OPDEF }; }; -} \ No newline at end of file +} diff --git a/src/pim/Parser.cpp b/src/pim/Parser.cpp index 4b164c8..0165141 100644 --- a/src/pim/Parser.cpp +++ b/src/pim/Parser.cpp @@ -650,4 +650,4 @@ namespace pim throw ParserExpectException(token, symbol); } } -} \ No newline at end of file +} diff --git a/src/pim/Parser.h b/src/pim/Parser.h index 9a4f736..19a2835 100644 --- a/src/pim/Parser.h +++ b/src/pim/Parser.h @@ -76,4 +76,4 @@ namespace pim std::vector Compile(); }; } -} \ No newline at end of file +} diff --git a/src/pim/Scanner.cpp b/src/pim/Scanner.cpp index e6d145a..4ceb942 100644 --- a/src/pim/Scanner.cpp +++ b/src/pim/Scanner.cpp @@ -196,4 +196,4 @@ namespace pim cChar = 0; } } -} \ No newline at end of file +} diff --git a/src/pim/Scanner.h b/src/pim/Scanner.h index 2e8143c..70e02ac 100644 --- a/src/pim/Scanner.h +++ b/src/pim/Scanner.h @@ -19,4 +19,4 @@ namespace pim Token NextToken(); }; } -} \ No newline at end of file +} diff --git a/src/pim/Token.cpp b/src/pim/Token.cpp index 453e92f..62931ac 100644 --- a/src/pim/Token.cpp +++ b/src/pim/Token.cpp @@ -48,4 +48,4 @@ namespace pim "INVALID SYMBOL" }; } -} \ No newline at end of file +} diff --git a/src/pim/Token.h b/src/pim/Token.h index 15cd48f..95d3f08 100644 --- a/src/pim/Token.h +++ b/src/pim/Token.h @@ -80,4 +80,4 @@ namespace pim } }; } -} \ No newline at end of file +} diff --git a/src/powdertoyjava/OpenGLCanvasMacOS.h b/src/powdertoyjava/OpenGLCanvasMacOS.h index cee495a..cca8765 100644 --- a/src/powdertoyjava/OpenGLCanvasMacOS.h +++ b/src/powdertoyjava/OpenGLCanvasMacOS.h @@ -32,4 +32,4 @@ extern "C" { #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/src/resampler/resampler.cpp b/src/resampler/resampler.cpp index ee3c0dc..9c20f25 100644 --- a/src/resampler/resampler.cpp +++ b/src/resampler/resampler.cpp @@ -1221,4 +1221,4 @@ char* Resampler::get_filter_name(int filter_num) return g_filters[filter_num].name; } -#endif \ No newline at end of file +#endif diff --git a/src/simulation/Sample.h b/src/simulation/Sample.h index 3605a5d..d37d0c8 100644 --- a/src/simulation/Sample.h +++ b/src/simulation/Sample.h @@ -26,4 +26,4 @@ public: SimulationSample() : PositionX(0), PositionY(0), ParticleID(0), particle(), AirPressure(0), AirVelocityX(0), AirVelocityY(0), WallType(0), Gravity(0), GravityVelocityX(0), GravityVelocityY(0), AirTemperature(0), NumParts(0) {} }; -#endif \ No newline at end of file +#endif diff --git a/src/simulation/Snapshot.h b/src/simulation/Snapshot.h index d87f4d9..2ef4d30 100644 --- a/src/simulation/Snapshot.h +++ b/src/simulation/Snapshot.h @@ -57,4 +57,4 @@ public: { } -}; \ No newline at end of file +}; diff --git a/src/simulation/StorageClasses.h b/src/simulation/StorageClasses.h index 45b9b00..7f60b39 100644 --- a/src/simulation/StorageClasses.h +++ b/src/simulation/StorageClasses.h @@ -51,4 +51,4 @@ typedef struct part_type part_type;*/ }; typedef struct part_transition part_transition;*/ -#endif \ No newline at end of file +#endif diff --git a/src/simulation/elements/116.cpp b/src/simulation/elements/116.cpp index e99f0cf..7e52557 100644 --- a/src/simulation/elements/116.cpp +++ b/src/simulation/elements/116.cpp @@ -46,4 +46,4 @@ Element_116::Element_116() } -Element_116::~Element_116() {} \ No newline at end of file +Element_116::~Element_116() {} diff --git a/src/simulation/elements/146.cpp b/src/simulation/elements/146.cpp index 173d435..df2b7bc 100644 --- a/src/simulation/elements/146.cpp +++ b/src/simulation/elements/146.cpp @@ -46,4 +46,4 @@ Element_146::Element_146() } -Element_146::~Element_146() {} \ No newline at end of file +Element_146::~Element_146() {} diff --git a/src/simulation/elements/BGLA.cpp b/src/simulation/elements/BGLA.cpp index 3c7e9ba..e514c90 100644 --- a/src/simulation/elements/BGLA.cpp +++ b/src/simulation/elements/BGLA.cpp @@ -46,4 +46,4 @@ Element_BGLA::Element_BGLA() } -Element_BGLA::~Element_BGLA() {} \ No newline at end of file +Element_BGLA::~Element_BGLA() {} diff --git a/src/simulation/elements/BHOL.cpp b/src/simulation/elements/BHOL.cpp index 8139e7d..7fc73ec 100644 --- a/src/simulation/elements/BHOL.cpp +++ b/src/simulation/elements/BHOL.cpp @@ -46,4 +46,4 @@ Element_BHOL::Element_BHOL() } -Element_BHOL::~Element_BHOL() {} \ No newline at end of file +Element_BHOL::~Element_BHOL() {} diff --git a/src/simulation/elements/BRAY.cpp b/src/simulation/elements/BRAY.cpp index 5030020..285c065 100644 --- a/src/simulation/elements/BRAY.cpp +++ b/src/simulation/elements/BRAY.cpp @@ -106,4 +106,4 @@ int Element_BRAY::graphics(GRAPHICS_FUNC_ARGS) } -Element_BRAY::~Element_BRAY() {} \ No newline at end of file +Element_BRAY::~Element_BRAY() {} diff --git a/src/simulation/elements/BRCK.cpp b/src/simulation/elements/BRCK.cpp index da96b87..a375207 100644 --- a/src/simulation/elements/BRCK.cpp +++ b/src/simulation/elements/BRCK.cpp @@ -62,4 +62,4 @@ int Element_BRCK::graphics(GRAPHICS_FUNC_ARGS) return 0; } -Element_BRCK::~Element_BRCK() {} \ No newline at end of file +Element_BRCK::~Element_BRCK() {} diff --git a/src/simulation/elements/BVBR.cpp b/src/simulation/elements/BVBR.cpp index 1a2cc41..4e86782 100644 --- a/src/simulation/elements/BVBR.cpp +++ b/src/simulation/elements/BVBR.cpp @@ -47,4 +47,4 @@ Element_BVBR::Element_BVBR() } -Element_BVBR::~Element_BVBR() {} \ No newline at end of file +Element_BVBR::~Element_BVBR() {} diff --git a/src/simulation/elements/CAUS.cpp b/src/simulation/elements/CAUS.cpp index 0118fad..520784e 100644 --- a/src/simulation/elements/CAUS.cpp +++ b/src/simulation/elements/CAUS.cpp @@ -83,4 +83,4 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS) } -Element_CAUS::~Element_CAUS() {} \ No newline at end of file +Element_CAUS::~Element_CAUS() {} diff --git a/src/simulation/elements/CFLM.cpp b/src/simulation/elements/CFLM.cpp index d19f9f0..53cb0a7 100644 --- a/src/simulation/elements/CFLM.cpp +++ b/src/simulation/elements/CFLM.cpp @@ -72,4 +72,4 @@ int Element_CFLM::graphics(GRAPHICS_FUNC_ARGS) } -Element_CFLM::~Element_CFLM() {} \ No newline at end of file +Element_CFLM::~Element_CFLM() {} diff --git a/src/simulation/elements/CNCT.cpp b/src/simulation/elements/CNCT.cpp index 4fa0808..5734791 100644 --- a/src/simulation/elements/CNCT.cpp +++ b/src/simulation/elements/CNCT.cpp @@ -46,4 +46,4 @@ Element_CNCT::Element_CNCT() } -Element_CNCT::~Element_CNCT() {} \ No newline at end of file +Element_CNCT::~Element_CNCT() {} diff --git a/src/simulation/elements/DESL.cpp b/src/simulation/elements/DESL.cpp index dc34dc8..53267f5 100644 --- a/src/simulation/elements/DESL.cpp +++ b/src/simulation/elements/DESL.cpp @@ -46,4 +46,4 @@ Element_DESL::Element_DESL() } -Element_DESL::~Element_DESL() {} \ No newline at end of file +Element_DESL::~Element_DESL() {} diff --git a/src/simulation/elements/DMND.cpp b/src/simulation/elements/DMND.cpp index 71321f6..9b86a84 100644 --- a/src/simulation/elements/DMND.cpp +++ b/src/simulation/elements/DMND.cpp @@ -46,4 +46,4 @@ Element_DMND::Element_DMND() } -Element_DMND::~Element_DMND() {} \ No newline at end of file +Element_DMND::~Element_DMND() {} diff --git a/src/simulation/elements/DRIC.cpp b/src/simulation/elements/DRIC.cpp index f1e37ec..8809fbb 100644 --- a/src/simulation/elements/DRIC.cpp +++ b/src/simulation/elements/DRIC.cpp @@ -46,4 +46,4 @@ Element_DRIC::Element_DRIC() } -Element_DRIC::~Element_DRIC() {} \ No newline at end of file +Element_DRIC::~Element_DRIC() {} diff --git a/src/simulation/elements/DUST.cpp b/src/simulation/elements/DUST.cpp index 7b4cf8c..5c80789 100644 --- a/src/simulation/elements/DUST.cpp +++ b/src/simulation/elements/DUST.cpp @@ -46,4 +46,4 @@ Element_DUST::Element_DUST() Graphics = NULL; } -Element_DUST::~Element_DUST() {} \ No newline at end of file +Element_DUST::~Element_DUST() {} diff --git a/src/simulation/elements/DYST.cpp b/src/simulation/elements/DYST.cpp index 14cfc27..6a04158 100644 --- a/src/simulation/elements/DYST.cpp +++ b/src/simulation/elements/DYST.cpp @@ -46,4 +46,4 @@ Element_DYST::Element_DYST() } -Element_DYST::~Element_DYST() {} \ No newline at end of file +Element_DYST::~Element_DYST() {} diff --git a/src/simulation/elements/ETRD.cpp b/src/simulation/elements/ETRD.cpp index 3447f07..72825ab 100644 --- a/src/simulation/elements/ETRD.cpp +++ b/src/simulation/elements/ETRD.cpp @@ -46,4 +46,4 @@ Element_ETRD::Element_ETRD() } -Element_ETRD::~Element_ETRD() {} \ No newline at end of file +Element_ETRD::~Element_ETRD() {} diff --git a/src/simulation/elements/FRME.cpp b/src/simulation/elements/FRME.cpp index c1d3a79..1382265 100644 --- a/src/simulation/elements/FRME.cpp +++ b/src/simulation/elements/FRME.cpp @@ -57,4 +57,4 @@ int Element_FRME::graphics(GRAPHICS_FUNC_ARGS) return 0; } -Element_FRME::~Element_FRME() {} \ No newline at end of file +Element_FRME::~Element_FRME() {} diff --git a/src/simulation/elements/GLAS.cpp b/src/simulation/elements/GLAS.cpp index 347e809..109cad0 100644 --- a/src/simulation/elements/GLAS.cpp +++ b/src/simulation/elements/GLAS.cpp @@ -59,4 +59,4 @@ int Element_GLAS::update(UPDATE_FUNC_ARGS) } -Element_GLAS::~Element_GLAS() {} \ No newline at end of file +Element_GLAS::~Element_GLAS() {} diff --git a/src/simulation/elements/GOO.cpp b/src/simulation/elements/GOO.cpp index f23360d..6592eed 100644 --- a/src/simulation/elements/GOO.cpp +++ b/src/simulation/elements/GOO.cpp @@ -61,4 +61,4 @@ int Element_GOO::update(UPDATE_FUNC_ARGS) } -Element_GOO::~Element_GOO() {} \ No newline at end of file +Element_GOO::~Element_GOO() {} diff --git a/src/simulation/elements/GUNP.cpp b/src/simulation/elements/GUNP.cpp index 7dc78db..dc8e0b9 100644 --- a/src/simulation/elements/GUNP.cpp +++ b/src/simulation/elements/GUNP.cpp @@ -46,4 +46,4 @@ Element_GUNP::Element_GUNP() } -Element_GUNP::~Element_GUNP() {} \ No newline at end of file +Element_GUNP::~Element_GUNP() {} diff --git a/src/simulation/elements/INSL.cpp b/src/simulation/elements/INSL.cpp index 4be5020..7fe5dff 100644 --- a/src/simulation/elements/INSL.cpp +++ b/src/simulation/elements/INSL.cpp @@ -46,4 +46,4 @@ Element_INSL::Element_INSL() } -Element_INSL::~Element_INSL() {} \ No newline at end of file +Element_INSL::~Element_INSL() {} diff --git a/src/simulation/elements/INST.cpp b/src/simulation/elements/INST.cpp index dcf1c11..8340011 100644 --- a/src/simulation/elements/INST.cpp +++ b/src/simulation/elements/INST.cpp @@ -46,4 +46,4 @@ Element_INST::Element_INST() } -Element_INST::~Element_INST() {} \ No newline at end of file +Element_INST::~Element_INST() {} diff --git a/src/simulation/elements/INWR.cpp b/src/simulation/elements/INWR.cpp index 3e438be..0356304 100644 --- a/src/simulation/elements/INWR.cpp +++ b/src/simulation/elements/INWR.cpp @@ -46,4 +46,4 @@ Element_INWR::Element_INWR() } -Element_INWR::~Element_INWR() {} \ No newline at end of file +Element_INWR::~Element_INWR() {} diff --git a/src/simulation/elements/LIFE.cpp b/src/simulation/elements/LIFE.cpp index 9c5bdf8..d442310 100644 --- a/src/simulation/elements/LIFE.cpp +++ b/src/simulation/elements/LIFE.cpp @@ -128,4 +128,4 @@ int Element_LIFE::graphics(GRAPHICS_FUNC_ARGS) } -Element_LIFE::~Element_LIFE() {} \ No newline at end of file +Element_LIFE::~Element_LIFE() {} diff --git a/src/simulation/elements/LNTG.cpp b/src/simulation/elements/LNTG.cpp index da3199f..8b6e29a 100644 --- a/src/simulation/elements/LNTG.cpp +++ b/src/simulation/elements/LNTG.cpp @@ -46,4 +46,4 @@ Element_LNTG::Element_LNTG() } -Element_LNTG::~Element_LNTG() {} \ No newline at end of file +Element_LNTG::~Element_LNTG() {} diff --git a/src/simulation/elements/LO2.cpp b/src/simulation/elements/LO2.cpp index 41a5053..abf08a4 100644 --- a/src/simulation/elements/LO2.cpp +++ b/src/simulation/elements/LO2.cpp @@ -46,4 +46,4 @@ Element_LO2::Element_LO2() } -Element_LO2::~Element_LO2() {} \ No newline at end of file +Element_LO2::~Element_LO2() {} diff --git a/src/simulation/elements/LOLZ.cpp b/src/simulation/elements/LOLZ.cpp index 301e99a..9017211 100644 --- a/src/simulation/elements/LOLZ.cpp +++ b/src/simulation/elements/LOLZ.cpp @@ -61,4 +61,4 @@ int Element_LOLZ::RuleTable[9][9] = //#TPT-Directive ElementHeader Element_LOLZ static int lolz[XRES/9][YRES/9]; int Element_LOLZ::lolz[XRES/9][YRES/9]; -Element_LOLZ::~Element_LOLZ() {} \ No newline at end of file +Element_LOLZ::~Element_LOLZ() {} diff --git a/src/simulation/elements/LOVE.cpp b/src/simulation/elements/LOVE.cpp index f3b476a..f346635 100644 --- a/src/simulation/elements/LOVE.cpp +++ b/src/simulation/elements/LOVE.cpp @@ -61,4 +61,4 @@ int Element_LOVE::RuleTable[9][9] = //#TPT-Directive ElementHeader Element_LOVE static int love[XRES/9][YRES/9]; int Element_LOVE::love[XRES/9][YRES/9]; -Element_LOVE::~Element_LOVE() {} \ No newline at end of file +Element_LOVE::~Element_LOVE() {} diff --git a/src/simulation/elements/LRBD.cpp b/src/simulation/elements/LRBD.cpp index faf57cd..1b40fd3 100644 --- a/src/simulation/elements/LRBD.cpp +++ b/src/simulation/elements/LRBD.cpp @@ -46,4 +46,4 @@ Element_LRBD::Element_LRBD() } -Element_LRBD::~Element_LRBD() {} \ No newline at end of file +Element_LRBD::~Element_LRBD() {} diff --git a/src/simulation/elements/METL.cpp b/src/simulation/elements/METL.cpp index a194793..d504e57 100644 --- a/src/simulation/elements/METL.cpp +++ b/src/simulation/elements/METL.cpp @@ -46,4 +46,4 @@ Element_METL::Element_METL() } -Element_METL::~Element_METL() {} \ No newline at end of file +Element_METL::~Element_METL() {} diff --git a/src/simulation/elements/MORT.cpp b/src/simulation/elements/MORT.cpp index 768fddc..e5ef6ea 100644 --- a/src/simulation/elements/MORT.cpp +++ b/src/simulation/elements/MORT.cpp @@ -54,4 +54,4 @@ int Element_MORT::update(UPDATE_FUNC_ARGS) } -Element_MORT::~Element_MORT() {} \ No newline at end of file +Element_MORT::~Element_MORT() {} diff --git a/src/simulation/elements/MWAX.cpp b/src/simulation/elements/MWAX.cpp index cb0cfbd..0a75013 100644 --- a/src/simulation/elements/MWAX.cpp +++ b/src/simulation/elements/MWAX.cpp @@ -46,4 +46,4 @@ Element_MWAX::Element_MWAX() } -Element_MWAX::~Element_MWAX() {} \ No newline at end of file +Element_MWAX::~Element_MWAX() {} diff --git a/src/simulation/elements/NICE.cpp b/src/simulation/elements/NICE.cpp index 0c121c6..aa4ed44 100644 --- a/src/simulation/elements/NICE.cpp +++ b/src/simulation/elements/NICE.cpp @@ -46,4 +46,4 @@ Element_NICE::Element_NICE() } -Element_NICE::~Element_NICE() {} \ No newline at end of file +Element_NICE::~Element_NICE() {} diff --git a/src/simulation/elements/NITR.cpp b/src/simulation/elements/NITR.cpp index d4bce87..c61d2d1 100644 --- a/src/simulation/elements/NITR.cpp +++ b/src/simulation/elements/NITR.cpp @@ -46,4 +46,4 @@ Element_NITR::Element_NITR() } -Element_NITR::~Element_NITR() {} \ No newline at end of file +Element_NITR::~Element_NITR() {} diff --git a/src/simulation/elements/NONE.cpp b/src/simulation/elements/NONE.cpp index 5dd02af..b2bcd12 100644 --- a/src/simulation/elements/NONE.cpp +++ b/src/simulation/elements/NONE.cpp @@ -63,4 +63,4 @@ VideoBuffer * Element_NONE::iconGen(int wallID, int width, int height) } -Element_NONE::~Element_NONE() {} \ No newline at end of file +Element_NONE::~Element_NONE() {} diff --git a/src/simulation/elements/NSCN.cpp b/src/simulation/elements/NSCN.cpp index 1e71f10..36d0a06 100644 --- a/src/simulation/elements/NSCN.cpp +++ b/src/simulation/elements/NSCN.cpp @@ -46,4 +46,4 @@ Element_NSCN::Element_NSCN() } -Element_NSCN::~Element_NSCN() {} \ No newline at end of file +Element_NSCN::~Element_NSCN() {} diff --git a/src/simulation/elements/NTCT.cpp b/src/simulation/elements/NTCT.cpp index 24a190b..7aa2969 100644 --- a/src/simulation/elements/NTCT.cpp +++ b/src/simulation/elements/NTCT.cpp @@ -55,4 +55,4 @@ int Element_NTCT::update(UPDATE_FUNC_ARGS) } -Element_NTCT::~Element_NTCT() {} \ No newline at end of file +Element_NTCT::~Element_NTCT() {} diff --git a/src/simulation/elements/NWHL.cpp b/src/simulation/elements/NWHL.cpp index b1c10e5..ed39c56 100644 --- a/src/simulation/elements/NWHL.cpp +++ b/src/simulation/elements/NWHL.cpp @@ -54,4 +54,4 @@ int Element_NWHL::update(UPDATE_FUNC_ARGS) } -Element_NWHL::~Element_NWHL() {} \ No newline at end of file +Element_NWHL::~Element_NWHL() {} diff --git a/src/simulation/elements/PLEX.cpp b/src/simulation/elements/PLEX.cpp index a4bd63e..2b8c867 100644 --- a/src/simulation/elements/PLEX.cpp +++ b/src/simulation/elements/PLEX.cpp @@ -46,4 +46,4 @@ Element_PLEX::Element_PLEX() } -Element_PLEX::~Element_PLEX() {} \ No newline at end of file +Element_PLEX::~Element_PLEX() {} diff --git a/src/simulation/elements/PLSM.cpp b/src/simulation/elements/PLSM.cpp index 6d39a6b..a9e5728 100644 --- a/src/simulation/elements/PLSM.cpp +++ b/src/simulation/elements/PLSM.cpp @@ -67,4 +67,4 @@ int Element_PLSM::graphics(GRAPHICS_FUNC_ARGS) } -Element_PLSM::~Element_PLSM() {} \ No newline at end of file +Element_PLSM::~Element_PLSM() {} diff --git a/src/simulation/elements/PSCN.cpp b/src/simulation/elements/PSCN.cpp index 5456eaf..8e0a3d4 100644 --- a/src/simulation/elements/PSCN.cpp +++ b/src/simulation/elements/PSCN.cpp @@ -46,4 +46,4 @@ Element_PSCN::Element_PSCN() } -Element_PSCN::~Element_PSCN() {} \ No newline at end of file +Element_PSCN::~Element_PSCN() {} diff --git a/src/simulation/elements/PSTE.cpp b/src/simulation/elements/PSTE.cpp index add4370..0857bff 100644 --- a/src/simulation/elements/PSTE.cpp +++ b/src/simulation/elements/PSTE.cpp @@ -46,4 +46,4 @@ Element_PSTE::Element_PSTE() } -Element_PSTE::~Element_PSTE() {} \ No newline at end of file +Element_PSTE::~Element_PSTE() {} diff --git a/src/simulation/elements/PSTS.cpp b/src/simulation/elements/PSTS.cpp index 06a8c1e..e309ed1 100644 --- a/src/simulation/elements/PSTS.cpp +++ b/src/simulation/elements/PSTS.cpp @@ -46,4 +46,4 @@ Element_PSTS::Element_PSTS() } -Element_PSTS::~Element_PSTS() {} \ No newline at end of file +Element_PSTS::~Element_PSTS() {} diff --git a/src/simulation/elements/PTCT.cpp b/src/simulation/elements/PTCT.cpp index be3c231..e78c453 100644 --- a/src/simulation/elements/PTCT.cpp +++ b/src/simulation/elements/PTCT.cpp @@ -55,4 +55,4 @@ int Element_PTCT::update(UPDATE_FUNC_ARGS) } -Element_PTCT::~Element_PTCT() {} \ No newline at end of file +Element_PTCT::~Element_PTCT() {} diff --git a/src/simulation/elements/RBDM.cpp b/src/simulation/elements/RBDM.cpp index 9e08bc3..b1aed85 100644 --- a/src/simulation/elements/RBDM.cpp +++ b/src/simulation/elements/RBDM.cpp @@ -46,4 +46,4 @@ Element_RBDM::Element_RBDM() } -Element_RBDM::~Element_RBDM() {} \ No newline at end of file +Element_RBDM::~Element_RBDM() {} diff --git a/src/simulation/elements/SALT.cpp b/src/simulation/elements/SALT.cpp index 4e21f1b..6772c2b 100644 --- a/src/simulation/elements/SALT.cpp +++ b/src/simulation/elements/SALT.cpp @@ -46,4 +46,4 @@ Element_SALT::Element_SALT() } -Element_SALT::~Element_SALT() {} \ No newline at end of file +Element_SALT::~Element_SALT() {} diff --git a/src/simulation/elements/SAND.cpp b/src/simulation/elements/SAND.cpp index dade4f1..3a99e0e 100644 --- a/src/simulation/elements/SAND.cpp +++ b/src/simulation/elements/SAND.cpp @@ -46,4 +46,4 @@ Element_SAND::Element_SAND() } -Element_SAND::~Element_SAND() {} \ No newline at end of file +Element_SAND::~Element_SAND() {} diff --git a/src/simulation/elements/SMKE.cpp b/src/simulation/elements/SMKE.cpp index b4572d0..4a993a3 100644 --- a/src/simulation/elements/SMKE.cpp +++ b/src/simulation/elements/SMKE.cpp @@ -65,4 +65,4 @@ int Element_SMKE::graphics(GRAPHICS_FUNC_ARGS) return 1; } -Element_SMKE::~Element_SMKE() {} \ No newline at end of file +Element_SMKE::~Element_SMKE() {} diff --git a/src/simulation/elements/SPAWN.cpp b/src/simulation/elements/SPAWN.cpp index 517c712..db12b2f 100644 --- a/src/simulation/elements/SPAWN.cpp +++ b/src/simulation/elements/SPAWN.cpp @@ -57,4 +57,4 @@ int Element_SPAWN::update(UPDATE_FUNC_ARGS) -Element_SPAWN::~Element_SPAWN() {} \ No newline at end of file +Element_SPAWN::~Element_SPAWN() {} diff --git a/src/simulation/elements/SPAWN2.cpp b/src/simulation/elements/SPAWN2.cpp index 4ce0ceb..96a50da 100644 --- a/src/simulation/elements/SPAWN2.cpp +++ b/src/simulation/elements/SPAWN2.cpp @@ -57,4 +57,4 @@ int Element_SPAWN2::update(UPDATE_FUNC_ARGS) -Element_SPAWN2::~Element_SPAWN2() {} \ No newline at end of file +Element_SPAWN2::~Element_SPAWN2() {} diff --git a/src/simulation/elements/STKM2.cpp b/src/simulation/elements/STKM2.cpp index 943cac9..ee94adb 100644 --- a/src/simulation/elements/STKM2.cpp +++ b/src/simulation/elements/STKM2.cpp @@ -53,4 +53,4 @@ int Element_STKM2::update(UPDATE_FUNC_ARGS) return 0; } -Element_STKM2::~Element_STKM2() {} \ No newline at end of file +Element_STKM2::~Element_STKM2() {} diff --git a/src/simulation/elements/STNE.cpp b/src/simulation/elements/STNE.cpp index c2197c5..c0354db 100644 --- a/src/simulation/elements/STNE.cpp +++ b/src/simulation/elements/STNE.cpp @@ -46,4 +46,4 @@ Element_STNE::Element_STNE() } -Element_STNE::~Element_STNE() {} \ No newline at end of file +Element_STNE::~Element_STNE() {} diff --git a/src/simulation/elements/SWCH.cpp b/src/simulation/elements/SWCH.cpp index 824929d..893ce9e 100644 --- a/src/simulation/elements/SWCH.cpp +++ b/src/simulation/elements/SWCH.cpp @@ -110,4 +110,4 @@ int Element_SWCH::graphics(GRAPHICS_FUNC_ARGS) } -Element_SWCH::~Element_SWCH() {} \ No newline at end of file +Element_SWCH::~Element_SWCH() {} diff --git a/src/simulation/elements/TESC.cpp b/src/simulation/elements/TESC.cpp index 0ad7e00..6d66682 100644 --- a/src/simulation/elements/TESC.cpp +++ b/src/simulation/elements/TESC.cpp @@ -46,4 +46,4 @@ Element_TESC::Element_TESC() } -Element_TESC::~Element_TESC() {} \ No newline at end of file +Element_TESC::~Element_TESC() {} diff --git a/src/simulation/elements/URAN.cpp b/src/simulation/elements/URAN.cpp index 3ced8fe..61d5add 100644 --- a/src/simulation/elements/URAN.cpp +++ b/src/simulation/elements/URAN.cpp @@ -58,4 +58,4 @@ int Element_URAN::update(UPDATE_FUNC_ARGS) } -Element_URAN::~Element_URAN() {} \ No newline at end of file +Element_URAN::~Element_URAN() {} diff --git a/src/simulation/elements/VOID.cpp b/src/simulation/elements/VOID.cpp index a21413a..ee95179 100644 --- a/src/simulation/elements/VOID.cpp +++ b/src/simulation/elements/VOID.cpp @@ -46,4 +46,4 @@ Element_VOID::Element_VOID() } -Element_VOID::~Element_VOID() {} \ No newline at end of file +Element_VOID::~Element_VOID() {} diff --git a/src/simulation/elements/WAX.cpp b/src/simulation/elements/WAX.cpp index 2203b61..1873222 100644 --- a/src/simulation/elements/WAX.cpp +++ b/src/simulation/elements/WAX.cpp @@ -46,4 +46,4 @@ Element_WAX::Element_WAX() } -Element_WAX::~Element_WAX() {} \ No newline at end of file +Element_WAX::~Element_WAX() {} diff --git a/src/simulation/elements/WHOL.cpp b/src/simulation/elements/WHOL.cpp index aba4e19..41a34bb 100644 --- a/src/simulation/elements/WHOL.cpp +++ b/src/simulation/elements/WHOL.cpp @@ -46,4 +46,4 @@ Element_WHOL::Element_WHOL() } -Element_WHOL::~Element_WHOL() {} \ No newline at end of file +Element_WHOL::~Element_WHOL() {} diff --git a/src/simulation/elements/WIFI.cpp b/src/simulation/elements/WIFI.cpp index a20e6de..81d4e60 100644 --- a/src/simulation/elements/WIFI.cpp +++ b/src/simulation/elements/WIFI.cpp @@ -98,4 +98,4 @@ int Element_WIFI::graphics(GRAPHICS_FUNC_ARGS) } -Element_WIFI::~Element_WIFI() {} \ No newline at end of file +Element_WIFI::~Element_WIFI() {} diff --git a/src/simulation/elements/WOOD.cpp b/src/simulation/elements/WOOD.cpp index 589aa2f..4676790 100644 --- a/src/simulation/elements/WOOD.cpp +++ b/src/simulation/elements/WOOD.cpp @@ -72,4 +72,4 @@ int Element_WOOD::graphics(GRAPHICS_FUNC_ARGS) return 0; } -Element_WOOD::~Element_WOOD() {} \ No newline at end of file +Element_WOOD::~Element_WOOD() {} diff --git a/src/simulation/tools/AirTool.cpp b/src/simulation/tools/AirTool.cpp index 9fd7f79..23120a0 100644 --- a/src/simulation/tools/AirTool.cpp +++ b/src/simulation/tools/AirTool.cpp @@ -19,4 +19,4 @@ int Tool_Air::Perform(Simulation * sim, Particle * cpart, int x, int y, float st return 1; } -Tool_Air::~Tool_Air() {} \ No newline at end of file +Tool_Air::~Tool_Air() {} diff --git a/src/simulation/tools/Cool.cpp b/src/simulation/tools/Cool.cpp index b1b57b1..4c5788d 100644 --- a/src/simulation/tools/Cool.cpp +++ b/src/simulation/tools/Cool.cpp @@ -20,4 +20,4 @@ int Tool_Cool::Perform(Simulation * sim, Particle * cpart, int x, int y, float s return 1; } -Tool_Cool::~Tool_Cool() {} \ No newline at end of file +Tool_Cool::~Tool_Cool() {} diff --git a/src/simulation/tools/GravTool.cpp b/src/simulation/tools/GravTool.cpp index 630ba12..3ff30bd 100644 --- a/src/simulation/tools/GravTool.cpp +++ b/src/simulation/tools/GravTool.cpp @@ -15,4 +15,4 @@ int Tool_Grav::Perform(Simulation * sim, Particle * cpart, int x, int y, float s return 1; } -Tool_Grav::~Tool_Grav() {} \ No newline at end of file +Tool_Grav::~Tool_Grav() {} diff --git a/src/simulation/tools/Heat.cpp b/src/simulation/tools/Heat.cpp index f28274c..1be3e6e 100644 --- a/src/simulation/tools/Heat.cpp +++ b/src/simulation/tools/Heat.cpp @@ -20,4 +20,4 @@ int Tool_Heat::Perform(Simulation * sim, Particle * cpart, int x, int y, float s return 1; } -Tool_Heat::~Tool_Heat() {} \ No newline at end of file +Tool_Heat::~Tool_Heat() {} diff --git a/src/simulation/tools/NGrv.cpp b/src/simulation/tools/NGrv.cpp index 525d697..5e339e6 100644 --- a/src/simulation/tools/NGrv.cpp +++ b/src/simulation/tools/NGrv.cpp @@ -15,4 +15,4 @@ int Tool_NGrv::Perform(Simulation * sim, Particle * cpart, int x, int y, float s return 1; } -Tool_NGrv::~Tool_NGrv() {} \ No newline at end of file +Tool_NGrv::~Tool_NGrv() {} diff --git a/src/simulation/tools/SimTool.cpp b/src/simulation/tools/SimTool.cpp index d7015fa..4b3ddeb 100644 --- a/src/simulation/tools/SimTool.cpp +++ b/src/simulation/tools/SimTool.cpp @@ -7,4 +7,4 @@ Name(""), Colour(PIXPACK(0xFFFFFF)), Description("NULL Tool, does NOTHING") { -} \ No newline at end of file +} diff --git a/src/simulation/tools/SimTool.h b/src/simulation/tools/SimTool.h index c32ba5b..c5a5cb1 100644 --- a/src/simulation/tools/SimTool.h +++ b/src/simulation/tools/SimTool.h @@ -20,4 +20,4 @@ public: virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) { return 0; } }; -#endif \ No newline at end of file +#endif diff --git a/src/socket/socket.lua.cpp b/src/socket/socket.lua.cpp index 0032e2c..4952cce 100644 --- a/src/socket/socket.lua.cpp +++ b/src/socket/socket.lua.cpp @@ -11,4 +11,4 @@ void luaopen_socket(lua_State *l){ luaL_loadbuffer(l, socket_luac, socket_luac_sz, "@builtin socket.lua"); lua_call(l, 0, 0); } -#endif \ No newline at end of file +#endif diff --git a/src/tests/PowderInteractionMachine.cpp b/src/tests/PowderInteractionMachine.cpp index c2b37a2..329cfd7 100644 --- a/src/tests/PowderInteractionMachine.cpp +++ b/src/tests/PowderInteractionMachine.cpp @@ -18,4 +18,4 @@ int main(int argc, char * argv[]) parser->Compile(); } -#endif \ No newline at end of file +#endif diff --git a/src/tests/VirtualMachineTest.cpp b/src/tests/VirtualMachineTest.cpp index ee92999..1f8a52d 100644 --- a/src/tests/VirtualMachineTest.cpp +++ b/src/tests/VirtualMachineTest.cpp @@ -13,4 +13,4 @@ int main(int argc, char * argv[]) std::cout << "Return value: " << vm->Pop() << std::endl; } } -#endif \ No newline at end of file +#endif diff --git a/src/virtualmachine/Exceptions.h b/src/virtualmachine/Exceptions.h index 9628d10..3a25e87 100644 --- a/src/virtualmachine/Exceptions.h +++ b/src/virtualmachine/Exceptions.h @@ -97,4 +97,4 @@ namespace vm } ~InvalidProgramException() throw() {}; }; -} \ No newline at end of file +} diff --git a/src/virtualmachine/JustInTime.cpp b/src/virtualmachine/JustInTime.cpp index 9929d81..9f6fe57 100644 --- a/src/virtualmachine/JustInTime.cpp +++ b/src/virtualmachine/JustInTime.cpp @@ -1141,4 +1141,4 @@ namespace vm #undef OP } -#endif \ No newline at end of file +#endif diff --git a/src/virtualmachine/VirtualMachine.cpp b/src/virtualmachine/VirtualMachine.cpp index 929723a..a657f3c 100644 --- a/src/virtualmachine/VirtualMachine.cpp +++ b/src/virtualmachine/VirtualMachine.cpp @@ -402,4 +402,4 @@ namespace vm return 1; } -} \ No newline at end of file +} -- cgit v0.9.2-21-gd62e From 9d89d4b79b26584490e55cfb992fc58d3e11ea2b Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 11 May 2013 21:43:52 -0400 Subject: fix tooltips and dt diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index fcfa95c..925ff2c 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -171,6 +171,8 @@ GameView::GameView(): infoTip(""), infoTipPresence(0), buttonTipShow(0), + isToolTipFadingIn(false), + isButtonTipFadingIn(false), toolTipPosition(-1, -1), shiftBehaviour(false), ctrlBehaviour(false), @@ -1154,8 +1156,7 @@ void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::str if (selectMode == PlaceSave || selectMode == SelectNone) { buttonTip = toolTip; - if (buttonTipShow < 120) - buttonTipShow += 3; + isButtonTipFadingIn = true; } } else if(sender->Position.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16) @@ -1164,15 +1165,13 @@ void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::str toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), sender->Position.Y+3); if(toolTipPosition.Y+10 > Size.Y-MENUSIZE) toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); - if (toolTipPresence < 120) - toolTipPresence += 3; + isToolTipFadingIn = true; } else { this->toolTip = toolTip; toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10); - if (toolTipPresence < 160) - toolTipPresence += 3; + isToolTipFadingIn = true; } } @@ -1526,15 +1525,33 @@ void GameView::OnTick(float dt) if(infoTipPresence<0) infoTipPresence = 0; } - if (selectMode != PlaceSave && selectMode != SelectNone && buttonTipShow < 120) - buttonTipShow += 2; + if (isButtonTipFadingIn || (selectMode != PlaceSave && selectMode != SelectNone)) + { + isButtonTipFadingIn = false; + if(buttonTipShow < 120) + { + buttonTipShow += int(dt*2)>0?int(dt*2):1; + if(buttonTipShow>120) + buttonTipShow = 120; + } + } else if(buttonTipShow>0) { buttonTipShow -= int(dt)>0?int(dt):1; if(buttonTipShow<0) buttonTipShow = 0; } - if(toolTipPresence>0) + if (isToolTipFadingIn) + { + isToolTipFadingIn = false; + if(toolTipPresence < 120) + { + toolTipPresence += int(dt*2)>0?int(dt*2):1; + if(toolTipPresence>120) + toolTipPresence = 120; + } + } + else if(toolTipPresence>0) { toolTipPresence -= int(dt)>0?int(dt):1; if(toolTipPresence<0) diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 093d80b..8d5c57b 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -51,18 +51,20 @@ private: bool showDebug; bool wallBrush; int introText; - int buttonTipShow; - std::string buttonTip; std::string introTextMessage; int toolIndex; int currentSaveType; Menu * lastMenu; - int infoTipPresence; + int toolTipPresence; std::string toolTip; + bool isToolTipFadingIn; ui::Point toolTipPosition; + int infoTipPresence; std::string infoTip; - int toolTipPresence; + int buttonTipShow; + std::string buttonTip; + bool isButtonTipFadingIn; queue pointQueue; GameController * c; diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 6911c25..29fd5aa 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -247,7 +247,7 @@ void Engine::SetFps(float fps) { this->fps = fps; if(FpsLimit > 2.0f) - this->dt = FpsLimit/fps; + this->dt = 60/fps; else this->dt = 1.0f; } diff --git a/src/gui/render/RenderView.cpp b/src/gui/render/RenderView.cpp index 3b3a91a..8c09ceb 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -80,6 +80,7 @@ RenderView::RenderView(): ui::Window(ui::Point(0, 0), ui::Point(XRES, YRES+MENUSIZE)), toolTip(""), toolTipPresence(0), + isToolTipFadingIn(false), ren(NULL) { ui::Button * presetButton; @@ -373,6 +374,16 @@ void RenderView::OnDraw() void RenderView::OnTick(float dt) { + if (isToolTipFadingIn) + { + isToolTipFadingIn = false; + if(toolTipPresence < 120) + { + toolTipPresence += int(dt*2)>0?int(dt*2):1; + if(toolTipPresence > 120) + toolTipPresence = 0; + } + } if(toolTipPresence>0) { toolTipPresence -= int(dt)>0?int(dt):1; @@ -394,8 +405,7 @@ void RenderView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bo void RenderView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip) { this->toolTip = toolTip; - if (toolTipPresence < 120) - toolTipPresence += 3; + this->isToolTipFadingIn = true; } RenderView::~RenderView() { diff --git a/src/gui/render/RenderView.h b/src/gui/render/RenderView.h index 8a65eb1..4cf8cf0 100644 --- a/src/gui/render/RenderView.h +++ b/src/gui/render/RenderView.h @@ -20,6 +20,7 @@ class RenderView: public ui::Window { std::vector colourModes; std::string toolTip; int toolTipPresence; + bool isToolTipFadingIn; int line1, line2, line3, line4; public: class RenderModeAction; -- cgit v0.9.2-21-gd62e From 135bf443478dac8f4141dcbbb8fb1aced7731be1 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 11 May 2013 22:29:24 -0400 Subject: fix bug where you could set invalid types with PROP diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index aff535e..6c9bf26 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -139,6 +139,11 @@ void PropertyWindow::SetProperty() buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit); buffer >> tempInt; } + if (property->GetOption().first == "type" && (tempInt < 0 || tempInt >= PT_NUM)) + { + new ErrorMessage("Could not set property", "Invalid Particle Type"); + return; + } } else { @@ -193,6 +198,7 @@ void PropertyWindow::SetProperty() break; default: new ErrorMessage("Could not set property", "Invalid property"); + return; } sim->flood_prop( position.X, -- cgit v0.9.2-21-gd62e From a5ae843553bd83feda78bb107314ff3eb9b23c95 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 11 May 2013 22:42:58 -0400 Subject: also check .Enabled in PROP diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index 6c9bf26..90e70b3 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -139,7 +139,7 @@ void PropertyWindow::SetProperty() buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit); buffer >> tempInt; } - if (property->GetOption().first == "type" && (tempInt < 0 || tempInt >= PT_NUM)) + if (property->GetOption().first == "type" && (tempInt < 0 || tempInt >= PT_NUM || !sim->elements[tempInt].Enabled)) { new ErrorMessage("Could not set property", "Invalid Particle Type"); return; -- cgit v0.9.2-21-gd62e From 196c4e9c66c8e2c9abd58dfbe3c41478f0e70b2b Mon Sep 17 00:00:00 2001 From: cracker64 Date: Mon, 13 May 2013 15:26:20 -0300 Subject: Typo where LUACONSOLE was never enabled diff --git a/SConscript b/SConscript index 96ff876..1a5576f 100755 --- a/SConscript +++ b/SConscript @@ -141,7 +141,7 @@ env.Append(CPPDEFINES=["_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"]) if not GetOption('nofft'): env.Append(CPPDEFINES=["GRAVFFT"]) if not GetOption('nolua'): - env.Append(CPPDEFINED=["LUACONSOLE"]) + env.Append(CPPDEFINES=["LUACONSOLE"]) if GetOption("ptw32-static"): env.Append(CPPDEFINES=['PTW32_STATIC_LIB']); -- cgit v0.9.2-21-gd62e From e5cbcecdb9b796c41a4a6e582d4805f0fbc7351e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 13 May 2013 19:07:59 -0400 Subject: fix circle brush shape at some sizes diff --git a/src/gui/game/EllipseBrush.h b/src/gui/game/EllipseBrush.h index ad28766..a71b107 100644 --- a/src/gui/game/EllipseBrush.h +++ b/src/gui/game/EllipseBrush.h @@ -29,10 +29,10 @@ public: } else { - int yTop = ry, yBottom, i, j; + int yTop = ry+1, yBottom, i, j; for (i = 0; i <= rx; i++) { - while (pow(i-rx,2.0f)*pow(ry,2.0f) + pow(yTop-ry,2.0f)*pow(rx,2.0f) <= pow(rx,2.0f)*pow(ry,2.0f)) + while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) yTop++; yBottom = 2*ry - yTop; for (int j = 0; j <= ry*2; j++) -- cgit v0.9.2-21-gd62e From 7856f727a5b7d88904752267d4a1decd66ecbf4e Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 13 May 2013 21:10:45 -0400 Subject: rename TUGN to TUNG (more popular spelling). Broken BRMT smelts back into TUGN diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index d7b808b..fab4a5d 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -740,7 +740,7 @@ void GameController::ResetAir() sim->air->Clear(); for (int i = 0; i < NPART; i++) { - if (sim->parts[i].type == PT_QRTZ || sim->parts[i].type == PT_GLAS || sim->parts[i].type == PT_TUGN) + if (sim->parts[i].type == PT_QRTZ || sim->parts[i].type == PT_GLAS || sim->parts[i].type == PT_TUNG) { sim->parts[i].pavg[0] = sim->parts[i].pavg[1] = 0; } diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 50239b1..719bfdd 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2917,7 +2917,7 @@ int Simulation::create_part(int p, int x, int y, int tv) parts[i].dcolour = 0; parts[i].flags = 0; - if (t == PT_GLAS || t == PT_QRTZ || t == PT_TUGN) + if (t == PT_GLAS || t == PT_QRTZ || t == PT_TUNG) { parts[i].pavg[1] = pv[y/CELL][x/CELL]; } @@ -3793,7 +3793,7 @@ void Simulation::update_particles_i(int start, int inc) if (elements[t].Diffusion)//the random diffusion that gasses have { #ifdef REALISTIC - //The magic number controlls diffusion speed + //The magic number controls diffusion speed parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f); parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f); #else @@ -3836,13 +3836,11 @@ void Simulation::update_particles_i(int start, int inc) h_count = 0; #ifdef REALISTIC if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)) - { - float c_Cm = 0.0f; #else if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)>(rand()%250)) +#endif { float c_Cm = 0.0f; -#endif if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT)) { #ifdef REALISTIC @@ -3926,11 +3924,12 @@ void Simulation::update_particles_i(int start, int inc) if ((t==PT_ICEI || t==PT_SNOW) && (parts[i].ctype==0 || parts[i].ctype>=PT_NUM || parts[i].ctype==PT_ICEI || parts[i].ctype==PT_SNOW)) parts[i].ctype = PT_WATR; - if (ctemph>elements[t].HighTemperature&&elements[t].HighTemperatureTransition>-1) { + if (ctemph>elements[t].HighTemperature && elements[t].HighTemperatureTransition>-1) + { // particle type change due to high temperature #ifdef REALISTIC float dbt = ctempl - pt; - if (elements[t].HighTemperatureTransition!=PT_NUM) + if (elements[t].HighTemperatureTransition != PT_NUM) { if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm)) { @@ -3943,14 +3942,18 @@ void Simulation::update_particles_i(int start, int inc) s = 0; } } - #else - if (elements[t].HighTemperatureTransition!=PT_NUM) +#else + if (elements[t].HighTemperatureTransition != PT_NUM) t = elements[t].HighTemperatureTransition; #endif - else if (t==PT_ICEI || t==PT_SNOW) { - if (parts[i].ctype-1) { + else if (t == PT_BRMT) + { + if (parts[i].ctype == PT_TUNG && ctemph <= 3695.0) + s = 0; + else + { + t = PT_LAVA; + parts[i].type = PT_TUNG; + } + } + else + s = 0; + } + else if (ctempl -1) + { // particle type change due to low temperature #ifdef REALISTIC float dbt = ctempl - pt; - if (elements[t].LowTemperatureTransition!=PT_NUM) + if (elements[t].LowTemperatureTransition != PT_NUM) { if (platent[elements[t].LowTemperatureTransition] >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm)) { @@ -4012,44 +4032,62 @@ void Simulation::update_particles_i(int start, int inc) } } #else - if (elements[t].LowTemperatureTransition!=PT_NUM) - t = elements[t].LowTemperatureTransition; + if (elements[t].LowTemperatureTransition != PT_NUM) + t = elements[t].LowTemperatureTransition; #endif - else if (t==PT_WTRV) { - if (pt<273.0f) t = PT_RIME; - else t = PT_DSTW; + else if (t == PT_WTRV) + { + if (pt < 273.0f) + t = PT_RIME; + else + t = PT_DSTW; } - else if (t==PT_LAVA) { - if (parts[i].ctype>0 && parts[i].ctype=elements[PT_BMTL].HighTemperature) s = 0; - else if ((parts[i].ctype==PT_VIBR || parts[i].ctype==PT_BVBR) && pt>=273.15f) s = 0; - else if (parts[i].ctype==PT_TUGN) { - if (pt>3695.0) s = 0; + else if (t == PT_LAVA) + { + if (parts[i].ctype>0 && parts[i].ctype=elements[PT_BMTL].HighTemperature) + s = 0; + else if ((parts[i].ctype==PT_VIBR || parts[i].ctype==PT_BVBR) && pt>=273.15f) + s = 0; + else if (parts[i].ctype==PT_TUNG) + { + if (pt>3695.0) + s = 0; } - else if (elements[parts[i].ctype].HighTemperatureTransition==PT_LAVA) { - if (pt>=elements[parts[i].ctype].HighTemperature) s = 0; + else if (elements[parts[i].ctype].HighTemperatureTransition == PT_LAVA) + { + if (pt >= elements[parts[i].ctype].HighTemperature) + s = 0; } - else if (pt>=973.0f) s = 0; // freezing point for lava with any other (not listed in ptransitions as turning into lava) ctype - if (s) { + else if (pt>=973.0f) + s = 0; // freezing point for lava with any other (not listed in ptransitions as turning into lava) ctype + if (s) + { t = parts[i].ctype; parts[i].ctype = PT_NONE; - if (t==PT_THRM) { + if (t == PT_THRM) + { parts[i].tmp = 0; t = PT_BMTL; } - if (t==PT_PLUT) + if (t == PT_PLUT) { parts[i].tmp = 0; t = PT_LAVA; } } } - else if (pt<973.0f) t = PT_STNE; - else s = 0; + else if (pt<973.0f) + t = PT_STNE; + else + s = 0; } - else s = 0; + else + s = 0; } - else s = 0; + else + s = 0; #ifdef REALISTIC pt = restrict_flt(pt, MIN_TEMP, MAX_TEMP); for (j=0; j<8; j++) @@ -4057,30 +4095,37 @@ void Simulation::update_particles_i(int start, int inc) parts[surround_hconduct[j]].temp = pt; } #endif - if (s) { // particle type change occurred - if (t==PT_ICEI||t==PT_LAVA||t==PT_SNOW) + if (s) // particle type change occurred + { + if (t==PT_ICEI || t==PT_LAVA || t==PT_SNOW) parts[i].ctype = parts[i].type; - if (!(t==PT_ICEI&&parts[i].ctype==PT_FRZW)) parts[i].life = 0; - if (elements[t].State==ST_GAS&&elements[parts[i].type].State!=ST_GAS) + if (!(t==PT_ICEI && parts[i].ctype==PT_FRZW)) + parts[i].life = 0; + if (elements[t].State==ST_GAS && elements[parts[i].type].State!=ST_GAS) pv[y/CELL][x/CELL] += 0.50f; + part_change_type(i,x,y,t); - if (t==PT_FIRE||t==PT_PLSM||t==PT_CFLM) + + if (t==PT_FIRE || t==PT_PLSM || t==PT_CFLM) parts[i].life = rand()%50+120; - if (t==PT_LAVA) { - if (parts[i].ctype==PT_BRMT) parts[i].ctype = PT_BMTL; - else if (parts[i].ctype==PT_SAND) parts[i].ctype = PT_GLAS; - else if (parts[i].ctype==PT_BGLA) parts[i].ctype = PT_GLAS; - else if (parts[i].ctype==PT_PQRT) parts[i].ctype = PT_QRTZ; + if (t == PT_LAVA) + { + if (parts[i].ctype == PT_BRMT) parts[i].ctype = PT_BMTL; + else if (parts[i].ctype == PT_SAND) parts[i].ctype = PT_GLAS; + else if (parts[i].ctype == PT_BGLA) parts[i].ctype = PT_GLAS; + else if (parts[i].ctype == PT_PQRT) parts[i].ctype = PT_QRTZ; parts[i].life = rand()%120+240; } - if (t==PT_NONE) { + if (t == PT_NONE) + { kill_part(i); goto killed; } } pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); - if (t==PT_LAVA) { + if (t == PT_LAVA) + { parts[i].life = restrict_flt((parts[i].temp-700)/7, 0.0f, 400.0f); if (parts[i].ctype==PT_THRM&&parts[i].tmp>0) { @@ -4093,11 +4138,7 @@ void Simulation::update_particles_i(int start, int inc) parts[i].temp = MAX_TEMP; } } -#ifdef REALISTIC //needed to fix update_particles_i parsing } -#else - } -#endif else parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); } diff --git a/src/simulation/elements/BRMT.cpp b/src/simulation/elements/BRMT.cpp index cf4f99d..c2556ea 100644 --- a/src/simulation/elements/BRMT.cpp +++ b/src/simulation/elements/BRMT.cpp @@ -40,7 +40,7 @@ Element_BRMT::Element_BRMT() LowTemperature = ITL; LowTemperatureTransition = NT; HighTemperature = 1273.0f; - HighTemperatureTransition = PT_LAVA; + HighTemperatureTransition = ST; Update = &Element_BRMT::update; diff --git a/src/simulation/elements/DMG.cpp b/src/simulation/elements/DMG.cpp index 4f1daaf..4612d77 100644 --- a/src/simulation/elements/DMG.cpp +++ b/src/simulation/elements/DMG.cpp @@ -92,7 +92,7 @@ int Element_DMG::update(UPDATE_FUNC_ARGS) sim->part_change_type(rr>>8, x+nxi, y+nxj, PT_BCOL); else if(t == PT_QRTZ) sim->part_change_type(rr>>8, x+nxi, y+nxj, PT_PQRT); - else if(t == PT_TUGN) + else if(t == PT_TUNG) sim->part_change_type(rr>>8, x+nxi, y+nxj, PT_BRMT); } } diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index 15fd0e4..a8b40f7 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -158,7 +158,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) } } break; - case PT_TUGN: + case PT_TUNG: if(parts[i].temp < 3595.0){ parts[i].temp += (rand()%20)-4; } diff --git a/src/simulation/elements/TUGN.cpp b/src/simulation/elements/TUGN.cpp deleted file mode 100644 index 4fb8032..0000000 --- a/src/simulation/elements/TUGN.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "simulation/Elements.h" -#include "simulation/Air.h" -//#TPT-Directive ElementClass Element_TUGN PT_TUGN 171 -Element_TUGN::Element_TUGN() -{ - Identifier = "DEFAULT_PT_TUGN"; - Name = "TUGN"; - Colour = PIXPACK(0x505050); - MenuVisible = 1; - MenuSection = SC_ELEC; - Enabled = 1; - - Advection = 0.0f; - AirDrag = 0.00f * CFDS; - AirLoss = 0.90f; - Loss = 0.00f; - Collision = 0.0f; - Gravity = 0.0f; - Diffusion = 0.00f; - HotAir = 0.000f * CFDS; - Falldown = 0; - - Flammable = 0; - Explosive = 0; - Meltable = 1; - Hardness = 1; - - Weight = 100; - - Temperature = R_TEMP+0.0f +273.15f; - HeatConduct = 251; - Description = "Brittle metal with a very high melting point."; - - State = ST_SOLID; - Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; - - LowPressure = IPL; - LowPressureTransition = NT; - HighPressure = IPH; - HighPressureTransition = NT; - LowTemperature = ITL; - LowTemperatureTransition = NT; - HighTemperature = ITH; - HighTemperatureTransition = NT; - /*HighTemperature = 3895.0f; - HighTemperatureTransition = PT_LAVA;*/ - - Update = &Element_TUGN::update; - Graphics = &Element_TUGN::graphics; - -} - -#define MELTING_POINT 3695.0 - -//#TPT-Directive ElementHeader Element_TUGN static int update(UPDATE_FUNC_ARGS) -int Element_TUGN::update(UPDATE_FUNC_ARGS) -{ - bool splode = false; - if(parts[i].temp > 2400.0) - { - int r, rx, ry, rt; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (BOUNDS_CHECK && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if((r&0xFF) == PT_O2) - { - splode = true; - } - } - } - if((parts[i].temp > MELTING_POINT && !(rand()%20)) || splode) - { - if(!(rand()%50)) - { - sim->pv[y/CELL][x/CELL] += 50.0f; - } - else if(!(rand()%100)) - { - sim->part_change_type(i, x, y, PT_FIRE); - parts[i].life = rand()%500; - return 1; - } - else - { - sim->part_change_type(i, x, y, PT_LAVA); - parts[i].ctype = PT_TUGN; - return 1; - } - if(splode) - { - parts[i].temp = MELTING_POINT + (rand()%600) + 200; - } - parts[i].vx += (rand()%100)-50; - parts[i].vy += (rand()%100)-50; - return 1; - } - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; - if (parts[i].pavg[1]-parts[i].pavg[0] > 0.50f || parts[i].pavg[1]-parts[i].pavg[0] < -0.50f) - { - sim->part_change_type(i,x,y,PT_BRMT); - } - return 0; -} - - -//#TPT-Directive ElementHeader Element_TUGN static int graphics(GRAPHICS_FUNC_ARGS) -int Element_TUGN::graphics(GRAPHICS_FUNC_ARGS) -{ - double startTemp = (MELTING_POINT - 1500.0); - double tempOver = (((cpart->temp - startTemp)/1500.0)*M_PI) - (M_PI/2.0); - if(tempOver > -(M_PI/2.0)) - { - if(tempOver > (M_PI/2.0)) - tempOver = (M_PI/2.0); - double gradv = sin(tempOver) + 1.0; - *firer = (int)(gradv * 258.0); - *fireg = (int)(gradv * 156.0); - *fireb = (int)(gradv * 112.0); - *firea = 30; - - *colr += *firer; - *colg += *fireg; - *colb += *fireb; - *pixel_mode |= FIRE_ADD; - } - return 0; -} - -Element_TUGN::~Element_TUGN() {} diff --git a/src/simulation/elements/TUNG.cpp b/src/simulation/elements/TUNG.cpp new file mode 100644 index 0000000..1666346 --- /dev/null +++ b/src/simulation/elements/TUNG.cpp @@ -0,0 +1,133 @@ +#include "simulation/Elements.h" +#include "simulation/Air.h" +//#TPT-Directive ElementClass Element_TUNG PT_TUNG 171 +Element_TUNG::Element_TUNG() +{ + Identifier = "DEFAULT_PT_TUNG"; + Name = "TUNG"; + Colour = PIXPACK(0x505050); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Tungsten. Brittle metal with a very high melting point."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + /*HighTemperature = 3895.0f; + HighTemperatureTransition = PT_LAVA;*/ + + Update = &Element_TUNG::update; + Graphics = &Element_TUNG::graphics; + +} + +#define MELTING_POINT 3695.0 + +//#TPT-Directive ElementHeader Element_TUNG static int update(UPDATE_FUNC_ARGS) +int Element_TUNG::update(UPDATE_FUNC_ARGS) +{ + bool splode = false; + if(parts[i].temp > 2400.0) + { + int r, rx, ry, rt; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (BOUNDS_CHECK && (rx || ry)) + { + r = pmap[y+ry][x+rx]; + if((r&0xFF) == PT_O2) + { + splode = true; + } + } + } + if((parts[i].temp > MELTING_POINT && !(rand()%20)) || splode) + { + if(!(rand()%50)) + { + sim->pv[y/CELL][x/CELL] += 50.0f; + } + else if(!(rand()%100)) + { + sim->part_change_type(i, x, y, PT_FIRE); + parts[i].life = rand()%500; + return 1; + } + else + { + sim->part_change_type(i, x, y, PT_LAVA); + parts[i].ctype = PT_TUNG; + return 1; + } + if(splode) + { + parts[i].temp = MELTING_POINT + (rand()%600) + 200; + } + parts[i].vx += (rand()%100)-50; + parts[i].vy += (rand()%100)-50; + return 1; + } + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; + if (parts[i].pavg[1]-parts[i].pavg[0] > 0.50f || parts[i].pavg[1]-parts[i].pavg[0] < -0.50f) + { + sim->part_change_type(i,x,y,PT_BRMT); + parts[i].ctype = PT_TUNG; + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_TUNG static int graphics(GRAPHICS_FUNC_ARGS) +int Element_TUNG::graphics(GRAPHICS_FUNC_ARGS) +{ + double startTemp = (MELTING_POINT - 1500.0); + double tempOver = (((cpart->temp - startTemp)/1500.0)*M_PI) - (M_PI/2.0); + if(tempOver > -(M_PI/2.0)) + { + if(tempOver > (M_PI/2.0)) + tempOver = (M_PI/2.0); + double gradv = sin(tempOver) + 1.0; + *firer = (int)(gradv * 258.0); + *fireg = (int)(gradv * 156.0); + *fireb = (int)(gradv * 112.0); + *firea = 30; + + *colr += *firer; + *colg += *fireg; + *colb += *fireb; + *pixel_mode |= FIRE_ADD; + } + return 0; +} + +Element_TUNG::~Element_TUNG() {} -- cgit v0.9.2-21-gd62e From 18ddb7a1558d474f6f216307c89bfde5e24f924d Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 13 May 2013 22:08:55 -0400 Subject: some more description changes diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp index 16d619d..5a5ea33 100644 --- a/src/simulation/elements/ANAR.cpp +++ b/src/simulation/elements/ANAR.cpp @@ -28,7 +28,7 @@ Element_ANAR::Element_ANAR() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 70; - Description = "Very light dust. Behaves opposite gravity"; + Description = "Anti-air. Very light dust, which behaves opposite gravity."; State = ST_SOLID; Properties = TYPE_PART; diff --git a/src/simulation/elements/BCOL.cpp b/src/simulation/elements/BCOL.cpp index d6e1612..9c90ff3 100644 --- a/src/simulation/elements/BCOL.cpp +++ b/src/simulation/elements/BCOL.cpp @@ -28,7 +28,7 @@ Element_BCOL::Element_BCOL() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 150; - Description = "Broken Coal. Heavy particles. See COAL"; + Description = "Broken Coal. Heavy particles, burns slowly."; State = ST_SOLID; Properties = TYPE_PART; diff --git a/src/simulation/elements/BMTL.cpp b/src/simulation/elements/BMTL.cpp index 65a76b7..1d91e82 100644 --- a/src/simulation/elements/BMTL.cpp +++ b/src/simulation/elements/BMTL.cpp @@ -28,7 +28,7 @@ Element_BMTL::Element_BMTL() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 251; - Description = "Breakable metal."; + Description = "Breakable metal. Common conductive building material, can melt and break under pressure."; State = ST_SOLID; Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; diff --git a/src/simulation/elements/BREC.cpp b/src/simulation/elements/BREC.cpp index 1c09c64..b7a5857 100644 --- a/src/simulation/elements/BREC.cpp +++ b/src/simulation/elements/BREC.cpp @@ -28,7 +28,7 @@ Element_BREC::Element_BREC() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 211; - Description = "Broken electronics"; + Description = "Broken electronics. Formed from EMP blasts, and when constantly sparked while under pressure, turns to EXOT."; State = ST_SOLID; Properties = TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; diff --git a/src/simulation/elements/BRMT.cpp b/src/simulation/elements/BRMT.cpp index c2556ea..4bc5910 100644 --- a/src/simulation/elements/BRMT.cpp +++ b/src/simulation/elements/BRMT.cpp @@ -28,7 +28,7 @@ Element_BRMT::Element_BRMT() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 211; - Description = "Broken metal."; + Description = "Broken metal. Created when iron rusts or when when metals break from pressure."; State = ST_SOLID; Properties = TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp index 20e3f92..2933dcf 100644 --- a/src/simulation/elements/CRAY.cpp +++ b/src/simulation/elements/CRAY.cpp @@ -28,7 +28,7 @@ Element_CRAY::Element_CRAY() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 0; - Description = "Particle Ray Emitter. Creates a beam of particles set by its ctype, range is set by tmp."; + Description = "Particle Ray Emitter. Creates a beam of particles set by its ctype, with a range set by tmp."; State = ST_SOLID; Properties = TYPE_SOLID|PROP_LIFE_DEC; diff --git a/src/simulation/elements/DMG.cpp b/src/simulation/elements/DMG.cpp index 4612d77..e805370 100644 --- a/src/simulation/elements/DMG.cpp +++ b/src/simulation/elements/DMG.cpp @@ -28,7 +28,7 @@ Element_DMG::Element_DMG() Temperature = R_TEMP-2.0f +273.15f; HeatConduct = 29; - Description = "Generates damaging pressure and breaks elements it hits."; + Description = "Generates damaging pressure and breaks any elements it hits."; State = ST_NONE; Properties = TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC|PROP_SPARKSETTLE; diff --git a/src/simulation/elements/FRAY.cpp b/src/simulation/elements/FRAY.cpp index c529b87..8eed23c 100644 --- a/src/simulation/elements/FRAY.cpp +++ b/src/simulation/elements/FRAY.cpp @@ -28,7 +28,7 @@ Element_FRAY::Element_FRAY() Temperature = 20.0f+0.0f +273.15f; HeatConduct = 0; - Description = "Force Emitter. Pushes or pulls objects based on its temp value, use like ARAY."; + Description = "Force Emitter. Pushes or pulls objects based on its temp value. Use like ARAY."; State = ST_SOLID; Properties = TYPE_SOLID|PROP_LIFE_DEC; diff --git a/src/simulation/elements/GUNP.cpp b/src/simulation/elements/GUNP.cpp index dc8e0b9..625feeb 100644 --- a/src/simulation/elements/GUNP.cpp +++ b/src/simulation/elements/GUNP.cpp @@ -28,7 +28,7 @@ Element_GUNP::Element_GUNP() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 97; - Description = "Gunpowder. Light dust, explosive."; + Description = "Gunpowder. Light dust, explodes on contact with fire or spark."; State = ST_SOLID; Properties = TYPE_PART; diff --git a/src/simulation/elements/H2.cpp b/src/simulation/elements/H2.cpp index f652d59..b9d8cd9 100644 --- a/src/simulation/elements/H2.cpp +++ b/src/simulation/elements/H2.cpp @@ -28,7 +28,7 @@ Element_H2::Element_H2() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 251; - Description = "Hydrogen. Combusts with OXYG to make WATR. Undergoes fusion at high temperature and pressure"; + Description = "Hydrogen. Combusts with OXYG to make WATR. Undergoes fusion at high temperature and pressure."; State = ST_GAS; Properties = TYPE_GAS; diff --git a/src/simulation/elements/INVIS.cpp b/src/simulation/elements/INVIS.cpp index 5e7f87d..e73c9bf 100644 --- a/src/simulation/elements/INVIS.cpp +++ b/src/simulation/elements/INVIS.cpp @@ -6,7 +6,7 @@ Element_INVIS::Element_INVIS() Name = "INVS"; Colour = PIXPACK(0x00CCCC); MenuVisible = 1; - MenuSection = SC_SOLIDS; + MenuSection = SC_SENSOR; Enabled = 1; Advection = 0.0f; diff --git a/src/simulation/elements/ISOZ.cpp b/src/simulation/elements/ISOZ.cpp index d3d6e6e..9f01495 100644 --- a/src/simulation/elements/ISOZ.cpp +++ b/src/simulation/elements/ISOZ.cpp @@ -28,7 +28,7 @@ Element_ISOZ::Element_ISOZ() Temperature = R_TEMP-2.0f +273.15f; HeatConduct = 29; - Description = "Radioactive liquid. Decays into photons when touching PHOT or under negative pressure."; + Description = "Isotope-Z. Radioactive liquid, decays into photons when touching PHOT or under negative pressure."; State = ST_LIQUID; Properties = TYPE_LIQUID|PROP_NEUTPENETRATE; diff --git a/src/simulation/elements/NICE.cpp b/src/simulation/elements/NICE.cpp index aa4ed44..bd87de9 100644 --- a/src/simulation/elements/NICE.cpp +++ b/src/simulation/elements/NICE.cpp @@ -28,7 +28,7 @@ Element_NICE::Element_NICE() Temperature = 35.0f; HeatConduct = 46; - Description = "Nitrogen Ice."; + Description = "Nitrogen Ice. Very cold, will melt into LN2 when heated only slightly."; State = ST_SOLID; Properties = TYPE_SOLID; diff --git a/src/simulation/elements/PQRT.cpp b/src/simulation/elements/PQRT.cpp index e70377c..665f5a4 100644 --- a/src/simulation/elements/PQRT.cpp +++ b/src/simulation/elements/PQRT.cpp @@ -28,7 +28,7 @@ Element_PQRT::Element_PQRT() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 3; - Description = "Broken quartz."; + Description = "Powdered quartz, broken form of QRTZ."; State = ST_SOLID; Properties = TYPE_PART| PROP_HOT_GLOW; diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp index ce91087..2d629a6 100644 --- a/src/simulation/elements/PRTI.cpp +++ b/src/simulation/elements/PRTI.cpp @@ -28,7 +28,7 @@ Element_PRTI::Element_PRTI() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 0; - Description = "Portal IN. Things go in here, now with temperature dependent channels (same as WIFI)"; + Description = "Portal IN. Particles go in here. Also has temperature dependent channels (same as WIFI)"; State = ST_SOLID; Properties = TYPE_SOLID; diff --git a/src/simulation/elements/PRTO.cpp b/src/simulation/elements/PRTO.cpp index af3e7f8..218ce78 100644 --- a/src/simulation/elements/PRTO.cpp +++ b/src/simulation/elements/PRTO.cpp @@ -28,7 +28,7 @@ Element_PRTO::Element_PRTO() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 0; - Description = "Portal OUT. Things come out here, now with temperature dependent channels (same as WIFI)"; + Description = "Portal OUT. Particles come out here. Also has temperature dependent channels (same as WIFI)"; State = ST_SOLID; Properties = TYPE_SOLID; diff --git a/src/simulation/elements/PSNS.cpp b/src/simulation/elements/PSNS.cpp index 033150d..1ab8de3 100644 --- a/src/simulation/elements/PSNS.cpp +++ b/src/simulation/elements/PSNS.cpp @@ -28,7 +28,7 @@ Element_PSNS::Element_PSNS() Temperature = 277.15f; HeatConduct = 0; - Description = "Pressure sensor, creates spark when the pressure is greater than its temperature."; + Description = "Pressure sensor, creates a spark when the pressure is greater than its temperature."; State = ST_SOLID; Properties = TYPE_SOLID; diff --git a/src/simulation/elements/REPL.cpp b/src/simulation/elements/REPL.cpp index d0e2aaf..e0823ec 100644 --- a/src/simulation/elements/REPL.cpp +++ b/src/simulation/elements/REPL.cpp @@ -28,7 +28,7 @@ Element_REPL::Element_REPL() Temperature = 20.0f+0.0f +273.15f; HeatConduct = 0; - Description = "Repels or attracts particles based on its temp value."; + Description = "Repels or attracts particles based on its temperature."; State = ST_NONE; Properties = TYPE_SOLID; diff --git a/src/simulation/elements/STOR.cpp b/src/simulation/elements/STOR.cpp index 92dd80f..a09096f 100644 --- a/src/simulation/elements/STOR.cpp +++ b/src/simulation/elements/STOR.cpp @@ -28,7 +28,7 @@ Element_STOR::Element_STOR() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 0; - Description = "Stores a single particle, releases when charged with PSCN, also passes to PIPE."; + Description = "Captures and stores a single particle. releases when charged with PSCN, also passes to PIPE."; State = ST_NONE; Properties = TYPE_SOLID; diff --git a/src/simulation/elements/TESC.cpp b/src/simulation/elements/TESC.cpp index 6d66682..00ae151 100644 --- a/src/simulation/elements/TESC.cpp +++ b/src/simulation/elements/TESC.cpp @@ -28,7 +28,7 @@ Element_TESC::Element_TESC() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 251; - Description = "Tesla coil!"; + Description = "Tesla coil! Creates lightning when sparked."; State = ST_SOLID; Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; diff --git a/src/simulation/elements/THDR.cpp b/src/simulation/elements/THDR.cpp index 3c9f0c9..507db2d 100644 --- a/src/simulation/elements/THDR.cpp +++ b/src/simulation/elements/THDR.cpp @@ -28,7 +28,7 @@ Element_THDR::Element_THDR() Temperature = 9000.0f +273.15f; HeatConduct = 1; - Description = "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals."; + Description = "Lightning! Very hot, inflicts damage upon most materials, and transfers current to metals."; State = ST_NONE; Properties = TYPE_PART; diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp index 8ad0b4d..62378c6 100644 --- a/src/simulation/elements/TRON.cpp +++ b/src/simulation/elements/TRON.cpp @@ -28,7 +28,7 @@ Element_TRON::Element_TRON() Temperature = 0.0f; HeatConduct = 40; - Description = "Smart particles, Travels in straight lines and avoids obstacles. Grows with time."; + Description = "Smart particles, Travels in straight lines and avoids obstacles. Grows with time."; State = ST_NONE; Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL; diff --git a/src/simulation/elements/TTAN.cpp b/src/simulation/elements/TTAN.cpp index 919c2b1..3f997f7 100644 --- a/src/simulation/elements/TTAN.cpp +++ b/src/simulation/elements/TTAN.cpp @@ -29,7 +29,7 @@ Element_TTAN::Element_TTAN() Temperature = R_TEMP+0.0f +273.15f; HeatConduct = 251; - Description = "Titanium, Higher melting temperature than other metals, blocks all air pressure"; + Description = "Titanium. Higher melting temperature than most other metals, blocks all air pressure."; State = ST_SOLID; Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW|PROP_LIFE_DEC; diff --git a/src/simulation/elements/WTRV.cpp b/src/simulation/elements/WTRV.cpp index 11ff088..b49ef67 100644 --- a/src/simulation/elements/WTRV.cpp +++ b/src/simulation/elements/WTRV.cpp @@ -28,7 +28,7 @@ Element_WTRV::Element_WTRV() Temperature = R_TEMP+100.0f+273.15f; HeatConduct = 48; - Description = "Steam, heats up air, produced from hot water."; + Description = "Steam. Produced from hot water."; State = ST_GAS; Properties = TYPE_GAS; -- cgit v0.9.2-21-gd62e From 431f5a0083dca3da5c881e507908690ebb5a052a Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 14 May 2013 14:40:18 -0400 Subject: lua simulation api functions for creating particles, walls, boxes, and walls diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 09170a9..485f167 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -447,6 +447,15 @@ void LuaScriptInterface::initSimulationAPI() {"velocityX", simulation_velocityX}, {"velocityY", simulation_velocityY}, {"gravMap", simulation_gravMap}, + {"createParts", simulation_createParts}, + {"createLine", simulation_createLine}, + {"createBox", simulation_createBox}, + {"floodParts", simulation_floodParts}, + {"createWalls", simulation_createWalls}, + {"createWallLine", simulation_createWallLine}, + {"createWallBox", simulation_createWallBox}, + {"floodWalls", simulation_floodWalls}, + {"clearSim", simulation_clearSim}, {NULL, NULL} }; luaL_register(l, "simulation", simulationAPIMethods); @@ -914,6 +923,178 @@ int LuaScriptInterface::simulation_gravMap(lua_State* l) return 0; } +int LuaScriptInterface::simulation_createParts(lua_State * l) +{ + int x = luaL_optint(l,1,-1); + int y = luaL_optint(l,2,-1); + int rx = luaL_optint(l,3,5); + int ry = luaL_optint(l,4,5); + int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); + int brush = luaL_optint(l,6,CIRCLE_BRUSH); + //int flags = luaL_optint(l,7,get_brush_flags()); + if (x < 0 || x > XRES || y < 0 || y > YRES) + return luaL_error(l, "Coordinates out of range (%d,%d)", x, y); + if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) + return luaL_error(l, "Unrecognised element number '%d'", c); + + vector brushList = luacon_model->GetBrushList(); + if (brush < 0 || brush > brushList.size()) + return luaL_error(l, "Invalid brush id '%d'", brush); + ui::Point tempRadius = brushList[brush]->GetRadius(); + brushList[brush]->SetRadius(ui::Point(rx, ry)); + + int ret = luacon_sim->CreateParts(x, y, c, brushList[brush]); + lua_pushinteger(l, ret); + brushList[brush]->SetRadius(tempRadius); + return 1; +} + +int LuaScriptInterface::simulation_createLine(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int rx = luaL_optint(l,5,5); + int ry = luaL_optint(l,6,5); + int c = luaL_optint(l,7,luacon_model->GetActiveTool(0)->GetToolID()); + int brush = luaL_optint(l,8,CIRCLE_BRUSH); + //int flags = luaL_optint(l,9,get_brush_flags()); + if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) + return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); + if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) + return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); + if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) + return luaL_error(l, "Unrecognised element number '%d'", c); + + vector brushList = luacon_model->GetBrushList(); + if (brush < 0 || brush > brushList.size()) + return luaL_error(l, "Invalid brush id '%d'", brush); + ui::Point tempRadius = brushList[brush]->GetRadius(); + brushList[brush]->SetRadius(ui::Point(rx, ry)); + + luacon_sim->CreateLine(x1, y1, x2, y2, c, brushList[brush]); + return 0; +} + +int LuaScriptInterface::simulation_createBox(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); + //int flags = luaL_optint(l,6,get_brush_flags()); + if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) + return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); + if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) + return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); + if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) + return luaL_error(l, "Unrecognised element number '%d'", c); + + luacon_sim->CreateBox(x1, y1, x2, y2, c, 0); + return 0; +} + +int LuaScriptInterface::simulation_floodParts(lua_State * l) +{ + int x = luaL_optint(l,1,-1); + int y = luaL_optint(l,2,-1); + int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID()); + int cm = luaL_optint(l,4,-1); + int bm = luaL_optint(l,5,-1); + //int flags = luaL_optint(l,6,0); + if (x < 0 || x > XRES || y < 0 || y > YRES) + return luaL_error(l, "coordinates out of range (%d,%d)", x, y); + if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) + return luaL_error(l, "Unrecognised element number '%d'", c); + int ret = luacon_sim->FloodParts(x, y, c, cm, bm, 0); + lua_pushinteger(l, ret); + return 1; +} + +int LuaScriptInterface::simulation_createWalls(lua_State * l) +{ + int x = luaL_optint(l,1,-1); + int y = luaL_optint(l,2,-1); + int rx = luaL_optint(l,3,5); + int ry = luaL_optint(l,4,5); + int c = luaL_optint(l,5,-1); + //int flags = luaL_optint(l,6,get_brush_flags()); + if (x < 0 || x > XRES || y < 0 || y > YRES) + return luaL_error(l, "Coordinates out of range (%d,%d)", x, y); + if (c < 0 || c >= UI_WALLCOUNT) + return luaL_error(l, "Unrecognised wall id '%d'", c); + + int ret = luacon_sim->CreateWalls(x, y, rx, ry, c, 0); + lua_pushinteger(l, ret); + return 1; +} + +int LuaScriptInterface::simulation_createWallLine(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int rx = luaL_optint(l,5,5); + int ry = luaL_optint(l,6,5); + int c = luaL_optint(l,7,-1); + //int flags = luaL_optint(l,8,get_brush_flags()); + if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) + return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); + if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) + return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); + if (c < 0 || c >= UI_WALLCOUNT) + return luaL_error(l, "Unrecognised wall id '%d'", c); + + luacon_sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, 0); + return 0; +} + +int LuaScriptInterface::simulation_createWallBox(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); + //int flags = luaL_optint(l,6,get_brush_flags()); + if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) + return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); + if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) + return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); + if (c < 0 || c >= UI_WALLCOUNT) + return luaL_error(l, "Unrecognised wall id '%d'", c); + + luacon_sim->CreateWallBox(x1, y1, x2, y2, c, 0); + return 0; +} + +int LuaScriptInterface::simulation_floodWalls(lua_State * l) +{ + int x = luaL_optint(l,1,-1); + int y = luaL_optint(l,2,-1); + int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID()); + int cm = luaL_optint(l,4,-1); + int bm = luaL_optint(l,5,-1); + //int flags = luaL_optint(l,6,0); + if (x < 0 || x > XRES || y < 0 || y > YRES) + return luaL_error(l, "coordinates out of range (%d,%d)", x, y); + if (c < 0 || c >= UI_WALLCOUNT) + return luaL_error(l, "Unrecognised wall id '%d'", c); + int ret = luacon_sim->FloodWalls(x, y, c, cm, bm, 0); + lua_pushinteger(l, ret); + return 1; +} + +int LuaScriptInterface::simulation_clearSim(lua_State * l) +{ + luacon_sim->clear_sim(); + return 0; +} + + //// Begin Renderer API void LuaScriptInterface::initRendererAPI() diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index 0b9f6f3..fc3f41a 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -64,6 +64,15 @@ class LuaScriptInterface: public CommandInterface static int simulation_velocityY(lua_State * l); static int simulation_gravMap(lua_State * l); static int simulation_ambientHeat(lua_State * l); + static int simulation_createParts(lua_State * l); + static int simulation_createLine(lua_State * l); + static int simulation_createBox(lua_State * l); + static int simulation_floodParts(lua_State * l); + static int simulation_createWalls(lua_State * l); + static int simulation_createWallLine(lua_State * l); + static int simulation_createWallBox(lua_State * l); + static int simulation_floodWalls(lua_State * l); + static int simulation_clearSim(lua_State * l); //Renderer void initRendererAPI(); diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index fab4a5d..09e1a1c 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1306,7 +1306,7 @@ void GameController::Vote(int direction) void GameController::ChangeBrush() { - gameModel->SetBrush(gameModel->GetBrushID()+1); + gameModel->SetBrushID(gameModel->GetBrushID()+1); BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y); } diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 1494d6d..18276d0 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -292,7 +292,7 @@ void GameModel::BuildMenus() //Build menu for GOL types for(int i = 0; i < NGOL; i++) { - Tool * tempTool = new GolTool(i, sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name)); + Tool * tempTool = new GolTool(PT_LIFE|(i<<8), sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name)); menuList[SC_LIFE]->AddTool(tempTool); } @@ -424,12 +424,17 @@ Brush * GameModel::GetBrush() return brushList[currentBrush]; } +vector GameModel::GetBrushList() +{ + return brushList; +} + int GameModel::GetBrushID() { return currentBrush; } -void GameModel::SetBrush(int i) +void GameModel::SetBrushID(int i) { currentBrush = i%brushList.size(); notifyBrushChanged(); @@ -511,6 +516,7 @@ Menu * GameModel::GetActiveMenu() return activeMenu; } +//Get an element tool from an element ID Tool * GameModel::GetElementTool(int elementID) { #ifdef DEBUG diff --git a/src/gui/game/GameModel.h b/src/gui/game/GameModel.h index 0ade162..f8ccfb5 100644 --- a/src/gui/game/GameModel.h +++ b/src/gui/game/GameModel.h @@ -105,8 +105,6 @@ public: GameModel(); ~GameModel(); - Tool * GetToolFromIdentifier(std::string identifier); - void SetEdgeMode(int edgeMode); int GetEdgeMode(); @@ -136,26 +134,29 @@ public: void UpdateQuickOptions(); + Tool * GetActiveTool(int selection); + void SetActiveTool(int selection, Tool * tool); void SetToolStrength(float value); float GetToolStrength(); - Tool * GetLastTool(); void SetLastTool(Tool * newTool); + Tool * GetToolFromIdentifier(std::string identifier); + Tool * GetElementTool(int elementID); + vector GetToolList(); + vector GetUnlistedTools(); + + Brush * GetBrush(); + vector GetBrushList(); + int GetBrushID(); + void SetBrushID(int i); void SetVote(int direction); SaveInfo * GetSave(); SaveFile * GetSaveFile(); - Brush * GetBrush(); void SetSave(SaveInfo * newSave); void SetSaveFile(SaveFile * newSave); void AddObserver(GameView * observer); - //Get an element tool from an element ID - Tool * GetElementTool(int elementID); - - Tool * GetActiveTool(int selection); - void SetActiveTool(int selection, Tool * tool); - bool GetPaused(); void SetPaused(bool pauseState); bool GetDecoration(); @@ -166,16 +167,12 @@ public: void ShowGravityGrid(bool showGrid); void ClearSimulation(); vector GetMenuList(); - vector GetUnlistedTools(); - vector GetToolList(); vector GetQuickOptions(); void SetActiveMenu(Menu * menu); Menu * GetActiveMenu(); void FrameStep(int frames); User GetUser(); void SetUser(User user); - void SetBrush(int i); - int GetBrushID(); Simulation * GetSimulation(); Renderer * GetRenderer(); void SetZoomEnabled(bool enabled); diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp index ed43da7..e33b0ce 100644 --- a/src/gui/game/Tool.cpp +++ b/src/gui/game/Tool.cpp @@ -117,16 +117,16 @@ GolTool::GolTool(int id, string name, string description, int r, int g, int b, s } GolTool::~GolTool() {} void GolTool::Draw(Simulation * sim, Brush * brush, ui::Point position){ - sim->CreateParts(position.X, position.Y, PT_LIFE|(toolID<<8), brush); + sim->CreateParts(position.X, position.Y, toolID, brush); } void GolTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) { - sim->CreateLine(position1.X, position1.Y, position2.X, position2.Y, PT_LIFE|(toolID<<8), brush); + sim->CreateLine(position1.X, position1.Y, position2.X, position2.Y, toolID, brush); } void GolTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { - sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, PT_LIFE|(toolID<<8), 0); + sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID, 0); } void GolTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { - sim->FloodParts(position.X, position.Y, PT_LIFE|(toolID<<8), -1, -1, 0); + sim->FloodParts(position.X, position.Y, toolID, -1, -1, 0); } -- cgit v0.9.2-21-gd62e From 2e409f966cbae3665ac2d6f9a9a0311f3894e3b6 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 14 May 2013 16:39:20 -0400 Subject: gfx.draw/fillcircle diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 485f167..15f2def 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1876,6 +1876,8 @@ void LuaScriptInterface::initGraphicsAPI() {"drawLine", graphics_drawLine}, {"drawRect", graphics_drawRect}, {"fillRect", graphics_fillRect}, + {"drawCircle", graphics_drawCircle}, + {"fillCircle", graphics_fillCircle}, {NULL, NULL} }; luaL_register(l, "graphics", graphicsAPIMethods); @@ -1953,6 +1955,54 @@ int LuaScriptInterface::graphics_drawLine(lua_State * l) int LuaScriptInterface::graphics_drawRect(lua_State * l) { + int x, y, rx, ry, r, g, b, a; + x = lua_tointeger(l, 1); + y = lua_tointeger(l, 2); + rx = lua_tointeger(l, 3); + ry = lua_tointeger(l, 4); + r = luaL_optint(l, 5, 255); + g = luaL_optint(l, 6, 255); + b = luaL_optint(l, 7, 255); + a = luaL_optint(l, 8, 255); + + if (r<0) r = 0; + if (r>255) r = 255; + if (g<0) g = 0; + if (g>255) g = 255; + if (b<0) b = 0; + if (b>255) b = 255; + if (a<0) a = 0; + if (a>255) a = 255; + luacon_g->drawrect(x, y, rx, ry, r, g, b, a); + return 0; +} + +int LuaScriptInterface::graphics_fillRect(lua_State * l) +{ + int x, y, rx, ry, r, g, b, a; + x = lua_tointeger(l, 1); + y = lua_tointeger(l, 2); + rx = lua_tointeger(l, 3); + ry = lua_tointeger(l, 4); + r = luaL_optint(l, 5, 255); + g = luaL_optint(l, 6, 255); + b = luaL_optint(l, 7, 255); + a = luaL_optint(l, 8, 255); + + if (r<0) r = 0; + if (r>255) r = 255; + if (g<0) g = 0; + if (g>255) g = 255; + if (b<0) b = 0; + if (b>255) b = 255; + if (a<0) a = 0; + if (a>255) a = 255; + luacon_g->fillrect(x, y, rx, ry, r, g, b, a); + return 0; +} + +int LuaScriptInterface::graphics_drawCircle(lua_State * l) +{ int x, y, w, h, r, g, b, a; x = lua_tointeger(l, 1); y = lua_tointeger(l, 2); @@ -1971,11 +2021,11 @@ int LuaScriptInterface::graphics_drawRect(lua_State * l) if (b>255) b = 255; if (a<0) a = 0; if (a>255) a = 255; - luacon_g->drawrect(x, y, w, h, r, g, b, a); + luacon_g->drawcircle(x, y, w, h, r, g, b, a); return 0; } -int LuaScriptInterface::graphics_fillRect(lua_State * l) +int LuaScriptInterface::graphics_fillCircle(lua_State * l) { int x, y, w, h, r, g, b, a; x = lua_tointeger(l, 1); @@ -1995,7 +2045,7 @@ int LuaScriptInterface::graphics_fillRect(lua_State * l) if (b>255) b = 255; if (a<0) a = 0; if (a>255) a = 255; - luacon_g->fillrect(x, y, w, h, r, g, b, a); + luacon_g->fillcircle(x, y, w, h, r, g, b, a); return 0; } diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index fc3f41a..9b54688 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -109,6 +109,8 @@ class LuaScriptInterface: public CommandInterface static int graphics_drawLine(lua_State * l); static int graphics_drawRect(lua_State * l); static int graphics_fillRect(lua_State * l); + static int graphics_drawCircle(lua_State * l); + static int graphics_fillCircle(lua_State * l); void initFileSystemAPI(); static int fileSystem_list(lua_State * l); diff --git a/src/graphics/Graphics.h b/src/graphics/Graphics.h index 3a87bb6..2cbdd87 100644 --- a/src/graphics/Graphics.h +++ b/src/graphics/Graphics.h @@ -239,6 +239,8 @@ public: void draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a); void drawrect(int x, int y, int width, int height, int r, int g, int b, int a); void fillrect(int x, int y, int width, int height, int r, int g, int b, int a); + void drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); + void fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); void clearrect(int x, int y, int width, int height); void gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2); diff --git a/src/graphics/OpenGLDrawMethods.inl b/src/graphics/OpenGLDrawMethods.inl index bfc338a..2bba731 100644 --- a/src/graphics/OpenGLDrawMethods.inl +++ b/src/graphics/OpenGLDrawMethods.inl @@ -314,6 +314,47 @@ void PIXELMETHODS_CLASS::fillrect(int x, int y, int width, int height, int r, in glEnd(); } +void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) +{ + int yTop = ry, yBottom, i, j; + for (i = 0; i <= rx; i++) { + yBottom = yTop; + while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) + yTop++; + if (yBottom != yTop) + yTop--; + for (int j = yBottom; j <= yTop; j++) + { + blendpixel(x+i, y+j, r, g, b, a); + if (i != rx) + blendpixel(x+2*rx-i, y+j, r, g, b, a); + if (j != ry) + { + blendpixel(x+i, y+2*ry-j, r, g, b, a); + if (i != rx) + blendpixel(x+2*rx-i, y+2*ry-j, r, g, b, a); + } + } + } +} + +void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) +{ + int yTop = ry+1, yBottom, i, j; + for (i = 0; i <= rx; i++) + { + while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) + yTop++; + yBottom = 2*ry - yTop; + for (int j = yBottom+1; j < yTop; j++) + { + blendpixel(x+i, y+j, r, g, b, a); + if (i != rx) + blendpixel(x+2*rx-i, y+j, r, g, b, a); + } + } +} + void PIXELMETHODS_CLASS::gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2) { glBegin(GL_QUADS); diff --git a/src/graphics/RasterDrawMethods.inl b/src/graphics/RasterDrawMethods.inl index b4de875..c53c0a8 100644 --- a/src/graphics/RasterDrawMethods.inl +++ b/src/graphics/RasterDrawMethods.inl @@ -356,6 +356,47 @@ void PIXELMETHODS_CLASS::fillrect(int x, int y, int w, int h, int r, int g, int blendpixel(x+i, y+j, r, g, b, a); } +void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) +{ + int yTop = ry, yBottom, i, j; + for (i = 0; i <= rx; i++) { + yBottom = yTop; + while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) + yTop++; + if (yBottom != yTop) + yTop--; + for (int j = yBottom; j <= yTop; j++) + { + blendpixel(x+i, y+j, r, g, b, a); + if (i != rx) + blendpixel(x+2*rx-i, y+j, r, g, b, a); + if (j != ry) + { + blendpixel(x+i, y+2*ry-j, r, g, b, a); + if (i != rx) + blendpixel(x+2*rx-i, y+2*ry-j, r, g, b, a); + } + } + } +} + +void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) +{ + int yTop = ry+1, yBottom, i, j; + for (i = 0; i <= rx; i++) + { + while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) + yTop++; + yBottom = 2*ry - yTop; + for (int j = yBottom+1; j < yTop; j++) + { + blendpixel(x+i, y+j, r, g, b, a); + if (i != rx) + blendpixel(x+2*rx-i, y+j, r, g, b, a); + } + } +} + void PIXELMETHODS_CLASS::gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2) { diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h index 9251006..8a7120f 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -126,6 +126,8 @@ public: void draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a); void drawrect(int x, int y, int width, int height, int r, int g, int b, int a); void fillrect(int x, int y, int width, int height, int r, int g, int b, int a); + void drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); + void fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a); void clearrect(int x, int y, int width, int height); void gradientrect(int x, int y, int width, int height, int r, int g, int b, int a, int r2, int g2, int b2, int a2); -- cgit v0.9.2-21-gd62e From ab3675d6eea1ce6eeeac713ed44f5cb591ff820f Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 14 May 2013 18:11:04 -0400 Subject: minor lua api fixes diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 7eed062..7be9db7 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1838,6 +1838,8 @@ int luatpt_heat(lua_State* l) int luatpt_cmode_set(lua_State* l) { int cmode = luaL_optint(l, 1, 0)+1; + if (cmode == 11) + cmode = 0; if (cmode >= 0 && cmode <= 10) luacon_controller->LoadRenderPreset(cmode); else diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 15f2def..17928ef 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1017,9 +1017,9 @@ int LuaScriptInterface::simulation_createWalls(lua_State * l) { int x = luaL_optint(l,1,-1); int y = luaL_optint(l,2,-1); - int rx = luaL_optint(l,3,5); - int ry = luaL_optint(l,4,5); - int c = luaL_optint(l,5,-1); + int rx = luaL_optint(l,3,0); + int ry = luaL_optint(l,4,0); + int c = luaL_optint(l,5,8); //int flags = luaL_optint(l,6,get_brush_flags()); if (x < 0 || x > XRES || y < 0 || y > YRES) return luaL_error(l, "Coordinates out of range (%d,%d)", x, y); @@ -1037,9 +1037,9 @@ int LuaScriptInterface::simulation_createWallLine(lua_State * l) int y1 = luaL_optint(l,2,-1); int x2 = luaL_optint(l,3,-1); int y2 = luaL_optint(l,4,-1); - int rx = luaL_optint(l,5,5); - int ry = luaL_optint(l,6,5); - int c = luaL_optint(l,7,-1); + int rx = luaL_optint(l,5,0); + int ry = luaL_optint(l,6,0); + int c = luaL_optint(l,7,8); //int flags = luaL_optint(l,8,get_brush_flags()); if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); @@ -1058,7 +1058,7 @@ int LuaScriptInterface::simulation_createWallBox(lua_State * l) int y1 = luaL_optint(l,2,-1); int x2 = luaL_optint(l,3,-1); int y2 = luaL_optint(l,4,-1); - int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); + int c = luaL_optint(l,5,8); //int flags = luaL_optint(l,6,get_brush_flags()); if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); @@ -1075,7 +1075,7 @@ int LuaScriptInterface::simulation_floodWalls(lua_State * l) { int x = luaL_optint(l,1,-1); int y = luaL_optint(l,2,-1); - int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID()); + int c = luaL_optint(l,3,8); int cm = luaL_optint(l,4,-1); int bm = luaL_optint(l,5,-1); //int flags = luaL_optint(l,6,0); -- cgit v0.9.2-21-gd62e From 94d21a1679749df49342903545192254a27f8ffc Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 14 May 2013 23:50:26 -0400 Subject: when called with no arguments, some tpt. functions will act as get functions (unfinished) Also, redo some menu stuff to use int's instead of Menu *s, and fix bug with toggleable buttons being toggled without triggering their actions diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 7be9db7..e2dba35 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -692,14 +692,11 @@ char *luacon_geterror(){ lua_pop(luacon_ci->l, 1); return err; } -/*void luacon_close(){ - lua_close(l); -}*/ //TPT Interface methods int luatpt_test(lua_State* l) { - int testint = 0; + int testint = 0; testint = luaL_optint(l, 1, 0); printf("Test successful, got %d\n", testint); return 0; @@ -863,7 +860,7 @@ int luatpt_error(lua_State* l) } int luatpt_drawtext(lua_State* l) { - char *string; + char *string; int textx, texty, textred, textgreen, textblue, textalpha; textx = luaL_optint(l, 1, 0); texty = luaL_optint(l, 2, 0); @@ -916,7 +913,12 @@ int luatpt_create(lua_State* l) int luatpt_setpause(lua_State* l) { int pausestate; - pausestate = luaL_optint(l, 1, 0); + pausestate = luaL_optint(l, 1, -1); + if (pausestate == -1) + { + lua_pushnumber(l, luacon_model->GetPaused()); + return 1; + } luacon_model->SetPaused(pausestate==0?0:1); return 0; } @@ -924,21 +926,27 @@ int luatpt_setpause(lua_State* l) int luatpt_togglepause(lua_State* l) { luacon_model->SetPaused(!luacon_model->GetPaused()); - //sys_pause=!sys_pause; - return 0; + lua_pushnumber(l, luacon_model->GetPaused()); + return 1; } int luatpt_togglewater(lua_State* l) { luacon_sim->water_equal_test=!luacon_sim->water_equal_test; - return 0; + lua_pushnumber(l, luacon_sim->water_equal_test); + return 1; } int luatpt_setconsole(lua_State* l) { int consolestate; - consolestate = luaL_optint(l, 1, 0); - if (consolestate) + consolestate = luaL_optint(l, 1, -1); + if (consolestate == -1) + { + lua_pushnumber(l, luacon_ci->Window != ui::Engine::Ref().GetWindow()); + return 1; + } + else if (consolestate) luacon_controller->ShowConsole(); else luacon_controller->HideConsole(); @@ -1542,11 +1550,13 @@ int luatpt_get_name(lua_State* l) int luatpt_set_shortcuts(lua_State* l) { - int shortcut = luaL_optint(l, 1, 0); - if (shortcut) - shortcuts = true; - else - shortcuts = false; + int shortcut = luaL_optint(l, 1, -1); + if (shortcut == -1) + { + lua_pushnumber(l, shortcuts); + return 1; + } + shortcuts = shortcut?true:false; return 0; } @@ -1746,84 +1756,107 @@ int luatpt_message_box(lua_State* l) } int luatpt_get_numOfParts(lua_State* l) { - lua_pushinteger(l, luacon_sim->parts_lastActiveIndex); - return 1; + lua_pushinteger(l, luacon_sim->parts_lastActiveIndex); + return 1; } int luatpt_start_getPartIndex(lua_State* l) { - getPartIndex_curIdx = -1; - return 1; + getPartIndex_curIdx = -1; + return 1; } int luatpt_next_getPartIndex(lua_State* l) { - while(1) - { - getPartIndex_curIdx++; - if(getPartIndex_curIdx >= NPART) - { - getPartIndex_curIdx = 0; - lua_pushboolean(l, 0); - return 1; - } - if(luacon_sim->parts[getPartIndex_curIdx].type) - break; + while(1) + { + getPartIndex_curIdx++; + if(getPartIndex_curIdx >= NPART) + { + getPartIndex_curIdx = 0; + lua_pushboolean(l, 0); + return 1; + } + if(luacon_sim->parts[getPartIndex_curIdx].type) + break; - } + } - lua_pushboolean(l, 1); - return 1; + lua_pushboolean(l, 1); + return 1; } int luatpt_getPartIndex(lua_State* l) { - if(getPartIndex_curIdx < 0) - { - lua_pushinteger(l, 0); - return 1; - } - lua_pushinteger(l, getPartIndex_curIdx); - return 1; + if(getPartIndex_curIdx < 0) + { + lua_pushinteger(l, 0); + return 1; + } + lua_pushinteger(l, getPartIndex_curIdx); + return 1; } int luatpt_hud(lua_State* l) { - int hudstate = luaL_optint(l, 1, 0); - if (hudstate) + int hudstate = luaL_optint(l, 1, -1); + if (hudstate == -1) + { + lua_pushinteger(l, luacon_controller->GetHudEnable()); + return 1; + } + else if (hudstate) luacon_controller->SetHudEnable(1); else luacon_controller->SetHudEnable(0); - return 0; + return 0; } int luatpt_gravity(lua_State* l) { - int gravstate; - gravstate = luaL_optint(l, 1, 0); - if(gravstate) - luacon_sim->grav->start_grav_async(); - else - luacon_sim->grav->stop_grav_async(); - return 0; + int gravstate; + gravstate = luaL_optint(l, 1, -1); + if (gravstate == -1) + { + lua_pushinteger(l, luacon_sim->grav->ngrav_enable); + return 1; + } + else if(gravstate) + luacon_sim->grav->start_grav_async(); + else + luacon_sim->grav->stop_grav_async(); + luacon_model->UpdateQuickOptions(); + return 0; } int luatpt_airheat(lua_State* l) { - int aheatstate; - aheatstate = luaL_optint(l, 1, 0); - luacon_sim->aheat_enable = (aheatstate==0?0:1); - return 0; + int aheatstate; + aheatstate = luaL_optint(l, 1, -1); + if (aheatstate == -1) + { + lua_pushinteger(l, luacon_sim->aheat_enable); + return 1; + } + luacon_sim->aheat_enable = (aheatstate==0?0:1); + luacon_model->UpdateQuickOptions(); + return 0; } int luatpt_active_menu(lua_State* l) { - int menuid; - menuid = luaL_optint(l, 1, -1); - if (menuid < SC_TOTAL && menuid >= 0) - luacon_model->SetActiveMenu(luacon_model->GetMenuList()[menuid]); - else - return luaL_error(l, "Invalid menu"); - return 0; + int menuid; + menuid = luaL_optint(l, 1, -1); + if (menuid == -1) + { + lua_pushinteger(l, luacon_model->GetActiveMenu()); + return 1; + } + if (menuid >= 0 && menuid < SC_TOTAL) + luacon_controller->SetActiveMenu(menuid); + else + return luaL_error(l, "Invalid menu"); + return 0; } int luatpt_decorations_enable(lua_State* l) { int decostate; decostate = luaL_optint(l, 1, 0); luacon_model->SetDecoration(decostate==0?false:true); + luacon_model->UpdateQuickOptions(); return 0; } @@ -1940,7 +1973,7 @@ int luatpt_getscript(lua_State* l) luacommand = new char[strlen(filename)+20]; sprintf(luacommand,"dofile(\"%s\")",filename); luaL_dostring (l, luacommand); - } + } fin: if(filedata) free(filedata); diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 17928ef..da03be5 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -2431,6 +2431,7 @@ std::string LuaScriptInterface::FormatCommand(std::string command) } LuaScriptInterface::~LuaScriptInterface() { + lua_close(l); delete legacy; } #endif diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 09e1a1c..ad48f66 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -924,6 +924,11 @@ void GameController::SetHudEnable(bool hudState) gameView->SetHudEnable(hudState); } +bool GameController::GetHudEnable() +{ + return gameView->GetHudEnable(); +} + void GameController::SetActiveColourPreset(int preset) { gameModel->SetActiveColourPreset(preset); @@ -935,18 +940,15 @@ void GameController::SetColour(ui::Colour colour) gameModel->SetPresetColour(colour); } -void GameController::SetActiveMenu(Menu * menu) +void GameController::SetActiveMenu(int menuID) { - gameModel->SetActiveMenu(menu); + gameModel->SetActiveMenu(menuID); vector menuList = gameModel->GetMenuList(); bool set = false; - for(int i = 0; i < menuList.size(); i++) + if(menuID == SC_DECO) { - if(menuList[i]==menu && i == SC_DECO) - { - gameModel->SetColourSelectorVisibility(true); - set = true; - } + gameModel->SetColourSelectorVisibility(true); + set = true; } if(!set) gameModel->SetColourSelectorVisibility(false); diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index f2cf26b..59fd4c8 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -100,7 +100,8 @@ public: void SetDecoration(); void ShowGravityGrid(); void SetHudEnable(bool hudState); - void SetActiveMenu(Menu * menu); + bool GetHudEnable(); + void SetActiveMenu(int menuID); std::vector GetMenuList(); void SetActiveTool(int toolSelection, Tool * tool); void ActiveToolChanged(int toolSelection, Tool *tool); diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 18276d0..960f45a 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -31,7 +31,7 @@ GameModel::GameModel(): colour(255, 0, 0, 255), toolStrength(1.0f), activeColourPreset(-1), - activeMenu(NULL), + activeMenu(-1), edgeMode(0) { sim = new Simulation(); @@ -221,9 +221,9 @@ void GameModel::BuildQuickOptionMenu(GameController * controller) void GameModel::BuildMenus() { - char lastMenu = 0; - if(activeMenu) - lastMenu = activeMenu->GetIcon(); + int lastMenu = -1; + if(activeMenu != -1) + lastMenu = activeMenu; std::string activeToolIdentifiers[3]; if(regularToolset[0]) @@ -346,19 +346,15 @@ void GameModel::BuildMenus() lastTool = activeTools[0]; //Set default menu - activeMenu = menuList[SC_POWDERS]; + activeMenu = SC_POWDERS; - if(lastMenu) + if(lastMenu != -1) //What is this? ... { - for(std::vector::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter) - { - if((*iter)->GetIcon() == lastMenu) - activeMenu = *iter; - } + activeMenu = lastMenu; } - if(activeMenu) - toolList = activeMenu->GetToolList(); + if(activeMenu != -1) + toolList = menuList[activeMenu]->GetToolList(); else toolList = std::vector(); @@ -471,32 +467,26 @@ float GameModel::GetToolStrength() return toolStrength; } -void GameModel::SetActiveMenu(Menu * menu) +void GameModel::SetActiveMenu(int menuID) { - for(int i = 0; i < menuList.size(); i++) + activeMenu = menuID; + toolList = menuList[menuID]->GetToolList(); + notifyToolListChanged(); + + if(menuID == SC_DECO) { - if(menuList[i]==menu) + if(activeTools != decoToolset) { - activeMenu = menu; - toolList = menu->GetToolList(); - notifyToolListChanged(); - - if(menu == menuList[SC_DECO]) - { - if(activeTools != decoToolset) - { - activeTools = decoToolset; - notifyActiveToolsChanged(); - } - } - else - { - if(activeTools != regularToolset) - { - activeTools = regularToolset; - notifyActiveToolsChanged(); - } - } + activeTools = decoToolset; + notifyActiveToolsChanged(); + } + } + else + { + if(activeTools != regularToolset) + { + activeTools = regularToolset; + notifyActiveToolsChanged(); } } } @@ -511,7 +501,7 @@ vector GameModel::GetToolList() return toolList; } -Menu * GameModel::GetActiveMenu() +int GameModel::GetActiveMenu() { return activeMenu; } diff --git a/src/gui/game/GameModel.h b/src/gui/game/GameModel.h index f8ccfb5..dd54d91 100644 --- a/src/gui/game/GameModel.h +++ b/src/gui/game/GameModel.h @@ -53,7 +53,7 @@ private: vector menuList; vector quickOptions; - Menu * activeMenu; + int activeMenu; int currentBrush; vector brushList; SaveInfo * currentSave; @@ -168,8 +168,8 @@ public: void ClearSimulation(); vector GetMenuList(); vector GetQuickOptions(); - void SetActiveMenu(Menu * menu); - Menu * GetActiveMenu(); + void SetActiveMenu(int menuID); + int GetActiveMenu(); void FrameStep(int frames); User GetUser(); void SetUser(User user); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 925ff2c..f054793 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -189,7 +189,7 @@ GameView::GameView(): toolTipPresence(0), currentSaveType(0), lastLogEntry(0.0f), - lastMenu(NULL) + lastMenu(-1) { int currentX = 1; @@ -403,7 +403,6 @@ GameView::GameView(): }; pauseButton = new ui::Button(ui::Point(Size.X-16, Size.Y-16), ui::Point(15, 15), "", "Pause/Resume the simulation"); //Pause pauseButton->SetIcon(IconPause); - pauseButton->SetTogglable(true); pauseButton->SetActionCallback(new PauseAction(this)); AddComponent(pauseButton); @@ -459,13 +458,13 @@ class GameView::MenuAction: public ui::ButtonAction { GameView * v; public: - Menu * menu; + int menuID; bool needsClick; - MenuAction(GameView * _v, Menu * menu_) + MenuAction(GameView * _v, int menuID_) { v = _v; - menu = menu_; - if (v->c->GetMenuList()[SC_DECO] == menu) + menuID = menuID_; + if (menuID == SC_DECO) needsClick = true; else needsClick = false; @@ -473,12 +472,12 @@ public: void MouseEnterCallback(ui::Button * sender) { if(!needsClick && !ui::Engine::Ref().GetMouseButton()) - v->c->SetActiveMenu(menu); + v->c->SetActiveMenu(menuID); } void ActionCallback(ui::Button * sender) { if (needsClick) - v->c->SetActiveMenu(menu); + v->c->SetActiveMenu(menuID); else MouseEnterCallback(sender); } @@ -566,15 +565,14 @@ void GameView::NotifyMenuListChanged(GameModel * sender) } toolButtons.clear(); vector menuList = sender->GetMenuList(); - for(vector::reverse_iterator iter = menuList.rbegin(), end = menuList.rend(); iter != end; ++iter) + for (int i = menuList.size()-1; i >= 0; i--) { std::string tempString = ""; - Menu * item = *iter; - tempString += item->GetIcon(); - ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString, item->GetDescription()); + tempString += menuList[i]->GetIcon(); + ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString, menuList[i]->GetDescription()); tempButton->Appearance.Margin = ui::Border(0, 2, 3, 2); tempButton->SetTogglable(true); - tempButton->SetActionCallback(new MenuAction(this, item)); + tempButton->SetActionCallback(new MenuAction(this, i)); currentY-=16; AddComponent(tempButton); menuButtons.push_back(tempButton); @@ -591,6 +589,11 @@ void GameView::SetHudEnable(bool hudState) showHud = hudState; } +bool GameView::GetHudEnable() +{ + return showHud; +} + ui::Point GameView::GetMousePosition() { return mousePosition; @@ -643,7 +646,7 @@ void GameView::NotifyToolListChanged(GameModel * sender) int totalColour; for(int i = 0; i < menuButtons.size(); i++) { - if(((MenuAction*)menuButtons[i]->GetActionCallback())->menu==sender->GetActiveMenu()) + if(((MenuAction*)menuButtons[i]->GetActionCallback())->menuID==sender->GetActiveMenu()) { menuButtons[i]->SetToggleState(true); } @@ -698,7 +701,7 @@ void GameView::NotifyToolListChanged(GameModel * sender) AddComponent(tempButton); toolButtons.push_back(tempButton); } - if (sender->GetActiveMenu() != sender->GetMenuList()[SC_DECO]) + if (sender->GetActiveMenu() != SC_DECO) lastMenu = sender->GetActiveMenu(); } @@ -1364,7 +1367,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { c->SetDecoration(true); c->SetPaused(true); - c->SetActiveMenu(c->GetMenuList()[SC_DECO]); + c->SetActiveMenu(SC_DECO); } break; case 'y': diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 8d5c57b..328b67c 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -54,7 +54,7 @@ private: std::string introTextMessage; int toolIndex; int currentSaveType; - Menu * lastMenu; + int lastMenu; int toolTipPresence; std::string toolTip; @@ -130,6 +130,7 @@ public: ui::Point GetMousePosition(); void SetSample(SimulationSample sample); void SetHudEnable(bool hudState); + bool GetHudEnable(); bool CtrlBehaviour(){ return ctrlBehaviour; } bool ShiftBehaviour(){ return shiftBehaviour; } void ExitPrompt(); diff --git a/src/gui/interface/Button.cpp b/src/gui/interface/Button.cpp index 37ef22d..71ec499 100644 --- a/src/gui/interface/Button.cpp +++ b/src/gui/interface/Button.cpp @@ -153,6 +153,10 @@ void Button::OnMouseUnclick(int x, int y, unsigned int button) { if(isButtonDown) { + if(isTogglable) + { + toggle = !toggle; + } isButtonDown = false; DoAction(); } @@ -173,10 +177,6 @@ void Button::OnMouseClick(int x, int y, unsigned int button) return; if(button == 1) { - if(isTogglable) - { - toggle = !toggle; - } isButtonDown = true; } else if(button == 3) -- cgit v0.9.2-21-gd62e From dfc33aaeeaa066ff0107b4ed68ec7756fbc5acb3 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 15 May 2013 13:51:45 -0400 Subject: finish return values for the legacy api, add sim.saveStamp and sim.loadStamp diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index e2dba35..b9afd7e 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -1854,7 +1854,12 @@ int luatpt_active_menu(lua_State* l) int luatpt_decorations_enable(lua_State* l) { int decostate; - decostate = luaL_optint(l, 1, 0); + decostate = luaL_optint(l, 1, -1); + if (decostate == -1) + { + lua_pushinteger(l, luacon_model->GetDecoration()); + return 1; + } luacon_model->SetDecoration(decostate==0?false:true); luacon_model->UpdateQuickOptions(); return 0; @@ -1863,14 +1868,19 @@ int luatpt_decorations_enable(lua_State* l) int luatpt_heat(lua_State* l) { int heatstate; - heatstate = luaL_optint(l, 1, 0); + heatstate = luaL_optint(l, 1, -1); + if (heatstate == -1) + { + lua_pushinteger(l, luacon_sim->legacy_enable); + return 1; + } luacon_sim->legacy_enable = (heatstate==1?0:1); return 0; } int luatpt_cmode_set(lua_State* l) { - int cmode = luaL_optint(l, 1, 0)+1; + int cmode = luaL_optint(l, 1, 3)+1; if (cmode == 11) cmode = 0; if (cmode >= 0 && cmode <= 10) @@ -1893,8 +1903,13 @@ int luatpt_setdebug(lua_State* l) } int luatpt_setfpscap(lua_State* l) { - int fpscap = luaL_optint(l, 1, 0); - if (fpscap < 2) + int fpscap = luaL_optint(l, 1, -1); + if (fpscap == -1) + { + lua_pushinteger(l, ui::Engine::Ref().FpsLimit); + return 1; + } + else if (fpscap < 2) return luaL_error(l, "fps cap too small"); ui::Engine::Ref().FpsLimit = fpscap; return 0; diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index da03be5..1a600ef 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -456,6 +456,8 @@ void LuaScriptInterface::initSimulationAPI() {"createWallBox", simulation_createWallBox}, {"floodWalls", simulation_floodWalls}, {"clearSim", simulation_clearSim}, + {"saveStamp", simulation_saveStamp}, + {"loadStamp", simulation_loadStamp}, {NULL, NULL} }; luaL_register(l, "simulation", simulationAPIMethods); @@ -1094,6 +1096,47 @@ int LuaScriptInterface::simulation_clearSim(lua_State * l) return 0; } +int LuaScriptInterface::simulation_saveStamp(lua_State * l) +{ + int x = luaL_optint(l,1,0); + int y = luaL_optint(l,2,0); + int w = luaL_optint(l,3,XRES); + int h = luaL_optint(l,4,YRES); + std::string name = luacon_controller->StampRegion(ui::Point(x, y), ui::Point(x+w, y+h)); + lua_pushstring(l, name.c_str()); + return 1; +} + +int LuaScriptInterface::simulation_loadStamp(lua_State * l) +{ + int stamp_size, i = -1, j, x, y, ret; + SaveFile * tempfile; + x = luaL_optint(l,2,0); + y = luaL_optint(l,3,0); + if (lua_isnumber(l, 1)) //Load from stamp ID + { + i = luaL_optint(l, 1, 0); + int stampCount = Client::Ref().GetStampsCount(); + if (i < 0 || i >= stampCount) + return luaL_error(l, "Invalid stamp ID: %d", i); + tempfile = Client::Ref().GetStamp(Client::Ref().GetStamps(0, stampCount)[i]); + } + else //Load from 10 char name, or full filename + { + char * filename = (char*)luaL_optstring(l, 1, ""); + tempfile = Client::Ref().GetStamp(filename); + } + if (tempfile) + { + luacon_sim->Load(x, y, tempfile->GetGameSave()); + //luacon_sim->sys_pause = (tempfile->GetGameSave()->paused | luacon_model->GetPaused())?1:0; + lua_pushinteger(l, 1); + } + else + lua_pushnil(l); + return 1; +} + //// Begin Renderer API diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index 9b54688..c002f41 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -73,6 +73,8 @@ class LuaScriptInterface: public CommandInterface static int simulation_createWallBox(lua_State * l); static int simulation_floodWalls(lua_State * l); static int simulation_clearSim(lua_State * l); + static int simulation_saveStamp(lua_State * l); + static int simulation_loadStamp(lua_State * l); //Renderer void initRendererAPI(); diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 1a2f296..367aa70 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -949,6 +949,8 @@ void Client::MoveStampToFront(std::string stampID) SaveFile * Client::GetStamp(std::string stampID) { std::string stampFile = std::string(STAMPS_DIR PATH_SEP + stampID + ".stm"); + if (!FileExists(stampFile)) + stampFile = stampID; if(FileExists(stampFile)) { SaveFile * file = new SaveFile(stampID); diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index ad48f66..267133b 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -509,17 +509,20 @@ void GameController::ToolClick(int toolSelection, ui::Point point) activeTool->Click(sim, cBrush, point); } -void GameController::StampRegion(ui::Point point1, ui::Point point2) +std::string GameController::StampRegion(ui::Point point1, ui::Point point2) { GameSave * newSave; newSave = gameModel->GetSimulation()->Save(point1.X, point1.Y, point2.X, point2.Y); if(newSave) { newSave->paused = gameModel->GetPaused(); - gameModel->AddStamp(newSave); + return gameModel->AddStamp(newSave); } else + { new ErrorMessage("Could not create stamp", "Error generating save file"); + return ""; + } } void GameController::CopyRegion(ui::Point point1, ui::Point point2) diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index 59fd4c8..b67df41 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -90,7 +90,7 @@ public: void DrawRect(int toolSelection, ui::Point point1, ui::Point point2); void DrawLine(int toolSelection, ui::Point point1, ui::Point point2); void DrawFill(int toolSelection, ui::Point point); - void StampRegion(ui::Point point1, ui::Point point2); + std::string StampRegion(ui::Point point1, ui::Point point2); void CopyRegion(ui::Point point1, ui::Point point2); void CutRegion(ui::Point point1, ui::Point point2); void Update(); diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 960f45a..aecd0eb 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -348,10 +348,8 @@ void GameModel::BuildMenus() //Set default menu activeMenu = SC_POWDERS; - if(lastMenu != -1) //What is this? ... - { + if(lastMenu != -1) activeMenu = lastMenu; - } if(activeMenu != -1) toolList = menuList[activeMenu]->GetToolList(); @@ -882,12 +880,12 @@ void GameModel::SetPlaceSave(GameSave * save) notifyPlaceSaveChanged(); } -void GameModel::AddStamp(GameSave * save) +std::string GameModel::AddStamp(GameSave * save) { if(stamp) delete stamp; stamp = save; - Client::Ref().AddStamp(save); + return Client::Ref().AddStamp(save); } void GameModel::SetClipboard(GameSave * save) diff --git a/src/gui/game/GameModel.h b/src/gui/game/GameModel.h index dd54d91..92df87f 100644 --- a/src/gui/game/GameModel.h +++ b/src/gui/game/GameModel.h @@ -186,7 +186,7 @@ public: void SetZoomWindowPosition(ui::Point position); ui::Point GetZoomWindowPosition(); void SetStamp(GameSave * newStamp); - void AddStamp(GameSave * save); + std::string AddStamp(GameSave * save); void SetClipboard(GameSave * save); void SetPlaceSave(GameSave * save); void Log(string message); -- cgit v0.9.2-21-gd62e From 624f038cc94f1e07ec16eb9d643663981478794d Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 15 May 2013 15:14:48 -0400 Subject: fix downvote button not being reset when you clear a save diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index f054793..e03dc78 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -931,7 +931,7 @@ void GameView::NotifySaveChanged(GameModel * sender) upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); upVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100), downVoteButton->Enabled = false; - upVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); + downVoteButton->Appearance.BackgroundDisabled = (ui::Colour(0, 0, 0)); downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100), tagSimulationButton->Enabled = false; tagSimulationButton->SetText("[no tags set]"); -- cgit v0.9.2-21-gd62e From 3d530e4f7382e6a9d50cb2ade8be2f2508bd5760 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 15 May 2013 20:36:45 -0400 Subject: fix pause button. I'm not sure why I removed that ... diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index e03dc78..12414c7 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -403,6 +403,7 @@ GameView::GameView(): }; pauseButton = new ui::Button(ui::Point(Size.X-16, Size.Y-16), ui::Point(15, 15), "", "Pause/Resume the simulation"); //Pause pauseButton->SetIcon(IconPause); + pauseButton->SetTogglable(true); pauseButton->SetActionCallback(new PauseAction(this)); AddComponent(pauseButton); -- cgit v0.9.2-21-gd62e From 5ad819efbd4dd745d315d6a238fd0aa11af7be31 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 15 May 2013 21:10:22 -0400 Subject: remove checks on location / element in the simulation drawing functions. fix drawing circles with an rx of 0. Probably fix compiling error diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 1a600ef..3d93071 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -934,10 +934,10 @@ int LuaScriptInterface::simulation_createParts(lua_State * l) int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); int brush = luaL_optint(l,6,CIRCLE_BRUSH); //int flags = luaL_optint(l,7,get_brush_flags()); - if (x < 0 || x > XRES || y < 0 || y > YRES) + /*if (x < 0 || x > XRES || y < 0 || y > YRES) return luaL_error(l, "Coordinates out of range (%d,%d)", x, y); if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) - return luaL_error(l, "Unrecognised element number '%d'", c); + return luaL_error(l, "Unrecognised element number '%d'", c);*/ vector brushList = luacon_model->GetBrushList(); if (brush < 0 || brush > brushList.size()) @@ -962,12 +962,12 @@ int LuaScriptInterface::simulation_createLine(lua_State * l) int c = luaL_optint(l,7,luacon_model->GetActiveTool(0)->GetToolID()); int brush = luaL_optint(l,8,CIRCLE_BRUSH); //int flags = luaL_optint(l,9,get_brush_flags()); - if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) + /* (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) - return luaL_error(l, "Unrecognised element number '%d'", c); + return luaL_error(l, "Unrecognised element number '%d'", c);*/ vector brushList = luacon_model->GetBrushList(); if (brush < 0 || brush > brushList.size()) @@ -987,12 +987,12 @@ int LuaScriptInterface::simulation_createBox(lua_State * l) int y2 = luaL_optint(l,4,-1); int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); //int flags = luaL_optint(l,6,get_brush_flags()); - if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) + /*if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) - return luaL_error(l, "Unrecognised element number '%d'", c); + return luaL_error(l, "Unrecognised element number '%d'", c);*/ luacon_sim->CreateBox(x1, y1, x2, y2, c, 0); return 0; @@ -1006,10 +1006,10 @@ int LuaScriptInterface::simulation_floodParts(lua_State * l) int cm = luaL_optint(l,4,-1); int bm = luaL_optint(l,5,-1); //int flags = luaL_optint(l,6,0); - if (x < 0 || x > XRES || y < 0 || y > YRES) + /*if (x < 0 || x > XRES || y < 0 || y > YRES) return luaL_error(l, "coordinates out of range (%d,%d)", x, y); - if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) - return luaL_error(l, "Unrecognised element number '%d'", c); + if ((c >= 0 && c < PT_NUM && !luacon_sim->elements[c].Enabled) || c < 0) + return luaL_error(l, "Unrecognised element number '%d'", c);*/ int ret = luacon_sim->FloodParts(x, y, c, cm, bm, 0); lua_pushinteger(l, ret); return 1; @@ -1949,24 +1949,22 @@ int LuaScriptInterface::graphics_textSize(lua_State * l) int LuaScriptInterface::graphics_drawText(lua_State * l) { - char * text; - int x, y, r, g, b, a; - x = lua_tointeger(l, 1); - y = lua_tointeger(l, 2); - text = (char*)lua_tostring(l, 3); - r = luaL_optint(l, 4, 255); - g = luaL_optint(l, 5, 255); - b = luaL_optint(l, 6, 255); - a = luaL_optint(l, 7, 255); + int x = lua_tointeger(l, 1); + int y = lua_tointeger(l, 2); + char * text = (char*)lua_tostring(l, 3); + int r = luaL_optint(l, 4, 255); + int g = luaL_optint(l, 5, 255); + int b = luaL_optint(l, 6, 255); + int a = luaL_optint(l, 7, 255); if (r<0) r = 0; - if (r>255) r = 255; + else if (r>255) r = 255; if (g<0) g = 0; - if (g>255) g = 255; + else if (g>255) g = 255; if (b<0) b = 0; - if (b>255) b = 255; + else if (b>255) b = 255; if (a<0) a = 0; - if (a>255) a = 255; + else if (a>255) a = 255; luacon_g->drawtext(x, y, text, r, g, b, a); return 0; @@ -1974,121 +1972,121 @@ int LuaScriptInterface::graphics_drawText(lua_State * l) int LuaScriptInterface::graphics_drawLine(lua_State * l) { - int x1, y1, x2, y2, r, g, b, a; - x1 = lua_tointeger(l, 1); - y1 = lua_tointeger(l, 2); - x2 = lua_tointeger(l, 3); - y2 = lua_tointeger(l, 4); - r = luaL_optint(l, 5, 255); - g = luaL_optint(l, 6, 255); - b = luaL_optint(l, 7, 255); - a = luaL_optint(l, 8, 255); + int x1 = lua_tointeger(l, 1); + int y1 = lua_tointeger(l, 2); + int x2 = lua_tointeger(l, 3); + int y2 = lua_tointeger(l, 4); + int r = luaL_optint(l, 5, 255); + int g = luaL_optint(l, 6, 255); + int b = luaL_optint(l, 7, 255); + int a = luaL_optint(l, 8, 255); if (r<0) r = 0; - if (r>255) r = 255; + else if (r>255) r = 255; if (g<0) g = 0; - if (g>255) g = 255; + else if (g>255) g = 255; if (b<0) b = 0; - if (b>255) b = 255; + else if (b>255) b = 255; if (a<0) a = 0; - if (a>255) a = 255; + else if (a>255) a = 255; + luacon_g->draw_line(x1, y1, x2, y2, r, g, b, a); return 0; } int LuaScriptInterface::graphics_drawRect(lua_State * l) { - int x, y, rx, ry, r, g, b, a; - x = lua_tointeger(l, 1); - y = lua_tointeger(l, 2); - rx = lua_tointeger(l, 3); - ry = lua_tointeger(l, 4); - r = luaL_optint(l, 5, 255); - g = luaL_optint(l, 6, 255); - b = luaL_optint(l, 7, 255); - a = luaL_optint(l, 8, 255); + int x = lua_tointeger(l, 1); + int y = lua_tointeger(l, 2); + int width = lua_tointeger(l, 3); + int height = lua_tointeger(l, 4); + int r = luaL_optint(l, 5, 255); + int g = luaL_optint(l, 6, 255); + int b = luaL_optint(l, 7, 255); + int a = luaL_optint(l, 8, 255); if (r<0) r = 0; - if (r>255) r = 255; + else if (r>255) r = 255; if (g<0) g = 0; - if (g>255) g = 255; + else if (g>255) g = 255; if (b<0) b = 0; - if (b>255) b = 255; + else if (b>255) b = 255; if (a<0) a = 0; - if (a>255) a = 255; - luacon_g->drawrect(x, y, rx, ry, r, g, b, a); + else if (a>255) a = 255; + + luacon_g->drawrect(x, y, width, height, r, g, b, a); return 0; } int LuaScriptInterface::graphics_fillRect(lua_State * l) { - int x, y, rx, ry, r, g, b, a; - x = lua_tointeger(l, 1); - y = lua_tointeger(l, 2); - rx = lua_tointeger(l, 3); - ry = lua_tointeger(l, 4); - r = luaL_optint(l, 5, 255); - g = luaL_optint(l, 6, 255); - b = luaL_optint(l, 7, 255); - a = luaL_optint(l, 8, 255); + int x = lua_tointeger(l, 1); + int y = lua_tointeger(l, 2); + int width = lua_tointeger(l, 3); + int height = lua_tointeger(l, 4); + int r = luaL_optint(l, 5, 255); + int g = luaL_optint(l, 6, 255); + int b = luaL_optint(l, 7, 255); + int a = luaL_optint(l, 8, 255); if (r<0) r = 0; - if (r>255) r = 255; + else if (r>255) r = 255; if (g<0) g = 0; - if (g>255) g = 255; + else if (g>255) g = 255; if (b<0) b = 0; - if (b>255) b = 255; + else if (b>255) b = 255; if (a<0) a = 0; - if (a>255) a = 255; - luacon_g->fillrect(x, y, rx, ry, r, g, b, a); + else if (a>255) a = 255; + + luacon_g->fillrect(x, y, width, height, r, g, b, a); return 0; } int LuaScriptInterface::graphics_drawCircle(lua_State * l) { - int x, y, w, h, r, g, b, a; - x = lua_tointeger(l, 1); - y = lua_tointeger(l, 2); - w = lua_tointeger(l, 3); - h = lua_tointeger(l, 4); - r = luaL_optint(l, 5, 255); - g = luaL_optint(l, 6, 255); - b = luaL_optint(l, 7, 255); - a = luaL_optint(l, 8, 255); + int x = lua_tointeger(l, 1); + int y = lua_tointeger(l, 2); + int rx = lua_tointeger(l, 3); + int ry = lua_tointeger(l, 4); + int r = luaL_optint(l, 5, 255); + int g = luaL_optint(l, 6, 255); + int b = luaL_optint(l, 7, 255); + int a = luaL_optint(l, 8, 255); if (r<0) r = 0; - if (r>255) r = 255; + else if (r>255) r = 255; if (g<0) g = 0; - if (g>255) g = 255; + else if (g>255) g = 255; if (b<0) b = 0; - if (b>255) b = 255; + else if (b>255) b = 255; if (a<0) a = 0; - if (a>255) a = 255; - luacon_g->drawcircle(x, y, w, h, r, g, b, a); + else if (a>255) a = 255; + + luacon_g->drawcircle(x, y, abs(rx), abs(ry), r, g, b, a); return 0; } int LuaScriptInterface::graphics_fillCircle(lua_State * l) { - int x, y, w, h, r, g, b, a; - x = lua_tointeger(l, 1); - y = lua_tointeger(l, 2); - w = lua_tointeger(l, 3); - h = lua_tointeger(l, 4); - r = luaL_optint(l, 5, 255); - g = luaL_optint(l, 6, 255); - b = luaL_optint(l, 7, 255); - a = luaL_optint(l, 8, 255); + int x = lua_tointeger(l, 1); + int y = lua_tointeger(l, 2); + int rx = lua_tointeger(l, 3); + int ry = lua_tointeger(l, 4); + int r = luaL_optint(l, 5, 255); + int g = luaL_optint(l, 6, 255); + int b = luaL_optint(l, 7, 255); + int a = luaL_optint(l, 8, 255); if (r<0) r = 0; - if (r>255) r = 255; + else if (r>255) r = 255; if (g<0) g = 0; - if (g>255) g = 255; + else if (g>255) g = 255; if (b<0) b = 0; - if (b>255) b = 255; + else if (b>255) b = 255; if (a<0) a = 0; - if (a>255) a = 255; - luacon_g->fillcircle(x, y, w, h, r, g, b, a); + else if (a>255) a = 255; + + luacon_g->fillcircle(x, y, abs(rx), abs(ry), r, g, b, a); return 0; } diff --git a/src/graphics/OpenGLDrawMethods.inl b/src/graphics/OpenGLDrawMethods.inl index 2bba731..52d09da 100644 --- a/src/graphics/OpenGLDrawMethods.inl +++ b/src/graphics/OpenGLDrawMethods.inl @@ -1,4 +1,5 @@ -#include "../data/font.h" +#include "../data/font.h" +#include int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a) { @@ -317,6 +318,12 @@ void PIXELMETHODS_CLASS::fillrect(int x, int y, int width, int height, int r, in void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) { int yTop = ry, yBottom, i, j; + if (!rx) + { + for (j = -ry; j <= ry; j++) + blendpixel(x, y+j, r, g, b, a); + return; + } for (i = 0; i <= rx; i++) { yBottom = yTop; while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) @@ -325,14 +332,14 @@ void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, yTop--; for (int j = yBottom; j <= yTop; j++) { - blendpixel(x+i, y+j, r, g, b, a); + blendpixel(x+i-rx, y+j-ry, r, g, b, a); if (i != rx) - blendpixel(x+2*rx-i, y+j, r, g, b, a); + blendpixel(x-i+rx, y+j-ry, r, g, b, a); if (j != ry) { - blendpixel(x+i, y+2*ry-j, r, g, b, a); + blendpixel(x+i-rx, y-j+ry, r, g, b, a); if (i != rx) - blendpixel(x+2*rx-i, y+2*ry-j, r, g, b, a); + blendpixel(x-i+rx, y-j+ry, r, g, b, a); } } } @@ -341,6 +348,12 @@ void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) { int yTop = ry+1, yBottom, i, j; + if (!rx) + { + for (j = -ry; j <= ry; j++) + blendpixel(x, y+j, r, g, b, a); + return; + } for (i = 0; i <= rx; i++) { while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) @@ -348,9 +361,9 @@ void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, yBottom = 2*ry - yTop; for (int j = yBottom+1; j < yTop; j++) { - blendpixel(x+i, y+j, r, g, b, a); + blendpixel(x+i-rx, y+j-ry, r, g, b, a); if (i != rx) - blendpixel(x+2*rx-i, y+j, r, g, b, a); + blendpixel(x-i+rx, y+j-ry, r, g, b, a); } } } diff --git a/src/graphics/RasterDrawMethods.inl b/src/graphics/RasterDrawMethods.inl index c53c0a8..5ac22cb 100644 --- a/src/graphics/RasterDrawMethods.inl +++ b/src/graphics/RasterDrawMethods.inl @@ -1,4 +1,5 @@ #include "font.h" +#include int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a) { @@ -359,6 +360,12 @@ void PIXELMETHODS_CLASS::fillrect(int x, int y, int w, int h, int r, int g, int void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) { int yTop = ry, yBottom, i, j; + if (!rx) + { + for (j = -ry; j <= ry; j++) + blendpixel(x, y+j, r, g, b, a); + return; + } for (i = 0; i <= rx; i++) { yBottom = yTop; while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) @@ -367,14 +374,14 @@ void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, yTop--; for (int j = yBottom; j <= yTop; j++) { - blendpixel(x+i, y+j, r, g, b, a); + blendpixel(x+i-rx, y+j-ry, r, g, b, a); if (i != rx) - blendpixel(x+2*rx-i, y+j, r, g, b, a); + blendpixel(x-i+rx, y+j-ry, r, g, b, a); if (j != ry) { - blendpixel(x+i, y+2*ry-j, r, g, b, a); + blendpixel(x+i-rx, y-j+ry, r, g, b, a); if (i != rx) - blendpixel(x+2*rx-i, y+2*ry-j, r, g, b, a); + blendpixel(x-i+rx, y-j+ry, r, g, b, a); } } } @@ -383,6 +390,12 @@ void PIXELMETHODS_CLASS::drawcircle(int x, int y, int rx, int ry, int r, int g, void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, int b, int a) { int yTop = ry+1, yBottom, i, j; + if (!rx) + { + for (j = -ry; j <= ry; j++) + blendpixel(x, y+j, r, g, b, a); + return; + } for (i = 0; i <= rx; i++) { while (pow(i-rx,2.0)*pow(ry,2.0) + pow(yTop-ry,2.0)*pow(rx,2.0) <= pow(rx,2.0)*pow(ry,2.0)) @@ -390,9 +403,9 @@ void PIXELMETHODS_CLASS::fillcircle(int x, int y, int rx, int ry, int r, int g, yBottom = 2*ry - yTop; for (int j = yBottom+1; j < yTop; j++) { - blendpixel(x+i, y+j, r, g, b, a); + blendpixel(x+i-rx, y+j-ry, r, g, b, a); if (i != rx) - blendpixel(x+2*rx-i, y+j, r, g, b, a); + blendpixel(x-i+rx, y+j-ry, r, g, b, a); } } } -- cgit v0.9.2-21-gd62e From 81876a93a30ad71018009a60aed9ede0b43533ab Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 00:20:07 -0400 Subject: redo some brush drawing stuff to remove useless checks, and to allow for replace mode in the future diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 3d93071..f9991a0 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -976,6 +976,7 @@ int LuaScriptInterface::simulation_createLine(lua_State * l) brushList[brush]->SetRadius(ui::Point(rx, ry)); luacon_sim->CreateLine(x1, y1, x2, y2, c, brushList[brush]); + brushList[brush]->SetRadius(tempRadius); return 0; } diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 719bfdd..946b356 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -375,8 +375,6 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h) void Simulation::CreateBox(int x1, int y1, int x2, int y2, int c, int flags) { int i, j; - if (c==SPC_PROP) - return; if (x1>x2) { i = x2; @@ -677,8 +675,6 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags) int coord_stack_size = 0; int created_something = 0; - if (c==SPC_PROP) - return 0; if (cm==-1) { if (c==0) @@ -886,19 +882,6 @@ int Simulation::flood_water(int x, int y, int i, int originaly, int check) return 1; } -//wrapper around create_part to create TESC with correct tmp value -int Simulation::create_part_add_props(int p, int x, int y, int tv, int rx, int ry) -{ - p=create_part(p, x, y, tv); - if (tv==PT_TESC) - { - parts[p].tmp=rx*4+ry*4+7; - if (parts[p].tmp>300) - parts[p].tmp=300; - } - return p; -} - void Simulation::SetEdgeMode(int newEdgeMode) { edgeMode = newEdgeMode; @@ -1050,15 +1033,9 @@ void Simulation::ApplyDecorationPoint(int positionX, int positionY, int colR, in if(cBrush) { - int radiusX, radiusY, sizeX, sizeY; - - radiusX = cBrush->GetRadius().X; - radiusY = cBrush->GetRadius().Y; - - sizeX = cBrush->GetSize().X; - sizeY = cBrush->GetSize().Y; - + int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y; unsigned char *bitmap = cBrush->GetBitmap(); + for(int y = 0; y < sizeY; y++) { for(int x = 0; x < sizeX; x++) @@ -1095,7 +1072,8 @@ void Simulation::ApplyDecorationBox(int x1, int y1, int x2, int y2, int colR, in void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode, Brush * cBrush) { - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy, rx, ry; + bool reverseXY = abs(y2-y1) > abs(x2-x1); + int x, y, dx, dy, sy, rx, ry; float e, de; if(cBrush) @@ -1104,7 +1082,7 @@ void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, i ry = cBrush->GetRadius().Y; } - if (cp) + if (reverseXY) { y = x1; x1 = y1; @@ -1133,7 +1111,7 @@ void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int colR, i sy = (y1GetRadius().X; - radiusY = cBrush->GetRadius().Y; - - sizeX = cBrush->GetSize().X; - sizeY = cBrush->GetSize().Y; + int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y; unsigned char *bitmap = cBrush->GetBitmap(); for(int y = 0; y < sizeY; y++) for(int x = 0; x < sizeX; x++) @@ -1190,11 +1162,10 @@ int Simulation::ToolBrush(int positionX, int positionY, int tool, Brush * cBrush void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength) { - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy, rx, ry; + bool reverseXY = abs(y2-y1) > abs(x2-x1); + int x, y, dx, dy, sy, rx = cBrush->GetRadius().X, ry = cBrush->GetRadius().Y; float e, de; - rx = cBrush->GetRadius().X; - ry = cBrush->GetRadius().Y; - if (cp) + if (reverseXY) { y = x1; x1 = y1; @@ -1223,7 +1194,7 @@ void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBru sy = (y1= 0.5f) { y += sy; - if ((!(rx+ry)) && ((y1=y2))) + if (!(rx+ry) && ((y1=y2))) { - if (cp) + if (reverseXY) ToolBrush(y, x, tool, cBrush, strength); else ToolBrush(x, y, tool, cBrush, strength); @@ -1266,39 +1237,25 @@ int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush) { if(cBrush) { - int radiusX, radiusY, sizeX, sizeY; - - radiusX = cBrush->GetRadius().X; - radiusY = cBrush->GetRadius().Y; - - sizeX = cBrush->GetSize().X; - sizeY = cBrush->GetSize().Y; - + int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y, fn; unsigned char *bitmap = cBrush->GetBitmap(); - if(c == PT_NONE) - { - for(int y = 0; y < sizeY; y++) - { - for(int x = 0; x < sizeX; x++) - { - if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES)) - { - delete_part(positionX+(x-radiusX), positionY+(y-radiusY), 0); - } - } - } - } - else + if (c == 0)// && !(flags&BRUSH_REPLACEMODE)) // delete + fn = 0; + //else if ((flags&BRUSH_SPECIFIC_DELETE) && !(flags&BRUSH_REPLACEMODE)) // specific delete + // fn = 1; + //else if (flags&BRUSH_REPLACEMODE) // replace + // fn = 2; + else // normal draw + fn = 3; + + for(int y = 0; y < sizeY; y++) { - for(int y = 0; y < sizeY; y++) + for(int x = 0; x < sizeX; x++) { - for(int x = 0; x < sizeX; x++) + if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES)) { - if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES)) - { - create_part(-2, positionX+(x-radiusX), positionY+(y-radiusY), c); - } + CreatePartFlags(positionX+(x-radiusX), positionY+(y-radiusY), c, fn, 0); } } } @@ -1308,77 +1265,47 @@ int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush) int Simulation::CreateParts(int x, int y, int rx, int ry, int c, int flags) { - int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p; - int wall = c - 100; - if (c==SPC_WIND || c==PT_FIGH) - return 0; - - if (c==PT_LIGH) + int i, j, f = 0, fn; + + if (c == 0)// && !(flags&BRUSH_REPLACEMODE)) // delete + fn = 0; + //else if ((flags&BRUSH_SPECIFIC_DELETE) && !(flags&BRUSH_REPLACEMODE)) // specific delete + // fn = 1; + //else if (flags&BRUSH_REPLACEMODE) // replace + // fn = 2; + else // normal draw + fn = 3; + + for (j=-ry; j<=ry; j++) + for (i=-rx; i<=rx; i++) + if (CreatePartFlags(x+i, y+j, c, fn, flags)) + f = 1; + return !f; +} + +int Simulation::CreatePartFlags(int x, int y, int c, int fn, int flags) +{ + if (fn == 0) //delete + delete_part(x, y, 0); + else if (fn == 1) //specific delete + delete_part(x, y, flags); + else if (fn == 2) //replace mode { - if (lighting_recreate>0 && rx+ry>0) + if (x<0 || y<0 || x>=XRES || y>=YRES) return 0; - p=create_part(-2, x, y, c); - if (p!=-1) - { - parts[p].life=rx+ry; - if (parts[p].life>55) - parts[p].life=55; - parts[p].temp=parts[p].life*150; // temperature of the lighting shows the power of the lighting - lighting_recreate+=parts[p].life/2+1; - return 1; - } - else return 0; - } - - //eraser - if (c == 0) - { - if (rx==0&&ry==0) + //if ((pmap[y][x]&0xFF)!=SLALT&&SLALT!=0) + // return 0; + if ((pmap[y][x])) { delete_part(x, y, 0); + if (c!=0) + create_part(-2, x, y, c); } - else - { - for (j=-ry; j<=ry; j++) - for (i=-rx; i<=rx; i++) - delete_part(x+i, y+j, 0); - } - return 1; - } - - if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV) - { - if (rx==0&&ry==0) - { - create_part(-2, x, y, c); - } - else - { - for (j=-ry; j<=ry; j++) - for (i=-rx; i<=rx; i++) - { - if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES) - continue; - create_part(-2, x+i, y+j, c); - } - } - return 1; - } - - //else, no special modes, draw element like normal. - if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later. - { - if (create_part_add_props(-2, x, y, c, rx, ry)==-1) - f = 1; } - else - { - for (j=-ry; j<=ry; j++) - for (i=-rx; i<=rx; i++) - if (create_part_add_props(-2, x+i, y+j, c, rx, ry)==-1) - f = 1; - } - return !f; + else if (fn == 3) //normal draw + if (create_part(-2, x, y, c) == -1) + return 1; + return 0; } int Simulation::CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush) @@ -1443,13 +1370,10 @@ int Simulation::CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brus void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush) { - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy, rx, ry; - rx = cBrush->GetRadius().X; - ry = cBrush->GetRadius().Y; + int x, y, dx, dy, sy, rx = cBrush->GetRadius().X, ry = cBrush->GetRadius().Y; + bool reverseXY = abs(y2-y1) > abs(x2-x1); float e, de; - if (c==SPC_PROP) - return; - if (cp) + if (reverseXY) { y = x1; x1 = y1; @@ -1478,7 +1402,7 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrus sy = (y1= 0.5f) { y += sy; - if ((c==WL_EHOLE+100 || c==WL_ALLOWGAS+100 || c==WL_ALLOWENERGY+100 || c==WL_ALLOWALLELEC+100 || c==WL_ALLOWSOLID+100 || c==WL_ALLOWAIR+100 || c==WL_WALL+100 || c==WL_DESTROYALL+100 || c==WL_ALLOWLIQUID+100 || c==WL_FAN+100 || c==WL_STREAM+100 || c==WL_DETECT+100 || c==WL_EWALL+100 || c==WL_WALLELEC+100 || !(rx+ry)) - && ((y1=y2))) + if (!(rx+ry) && ((y1=y2))) { - if (cp) + if (reverseXY) CreateParts(y, x, c, cBrush); else CreateParts(x, y, c, cBrush); @@ -1499,13 +1422,13 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrus } } -void Simulation::CreateLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags) +//Now simply creates a 0 pixel radius line without all the complicated flags / other checks +void Simulation::CreateLine(int x1, int y1, int x2, int y2, int c) { - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; + bool reverseXY = abs(y2-y1) > abs(x2-x1); + int x, y, dx, dy, sy; float e, de; - if (c==SPC_PROP) - return; - if (cp) + if (reverseXY) { y = x1; x1 = y1; @@ -1534,21 +1457,20 @@ void Simulation::CreateLine(int x1, int y1, int x2, int y2, int rx, int ry, int sy = (y1= 0.5f) { y += sy; - if ((c==WL_EHOLE+100 || c==WL_ALLOWGAS+100 || c==WL_ALLOWENERGY+100 || c==WL_ALLOWALLELEC+100 || c==WL_ALLOWSOLID+100 || c==WL_ALLOWAIR+100 || c==WL_WALL+100 || c==WL_DESTROYALL+100 || c==WL_ALLOWLIQUID+100 || c==WL_FAN+100 || c==WL_STREAM+100 || c==WL_DETECT+100 || c==WL_EWALL+100 || c==WL_WALLELEC+100 || !(rx+ry)) - && ((y1=y2))) + if ((y1=y2)) { - if (cp) - CreateParts(y, x, rx, ry, c, flags); + if (reverseXY) + create_part(-2, y, x, c); else - CreateParts(x, y, rx, ry, c, flags); + create_part(-2, x, y, c); } e -= 1.0f; } @@ -1953,7 +1875,7 @@ void Simulation::create_arc(int sx, int sy, int dx, int dy, int midpoints, int v xmid[i+1] += (rand()%variance)-voffset; ymid[i+1] += (rand()%variance)-voffset; } - CreateLine(xmid[i], ymid[i], xmid[i+1], ymid[i+1], 0, 0, type, flags); + CreateLine(xmid[i], ymid[i], xmid[i+1], ymid[i+1], type); } free(xmid); free(ymid); @@ -2713,9 +2635,6 @@ int Simulation::create_part(int p, int x, int y, int tv) return -1; if (t>=0 && tnearest_part(i, PT_ETRD, -1); if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL) { - sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0); + sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), PT_PLSM); sim->part_change_type(i,x,y,ct); ct = parts[i].ctype = PT_NONE; parts[i].life = 20; diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 65fe189..93d5158 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -421,7 +421,11 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { { int np = -1; if (playerp->elem == SPC_AIR) - sim->CreateParts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0); + { + for(int j = -4; j < 5; j++) + for (int k = -4; k < 5; k++) + sim->create_part(-2, rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01)+j, ry+k, SPC_AIR); + } else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate np = -1; else -- cgit v0.9.2-21-gd62e From ebe145b39ff1bc28912ed9e4ac058aeab0214388 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 00:55:44 -0400 Subject: soap lines show in nothing mode, some small changes to arguments for sim api drawing functions diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index f9991a0..c409b1a 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -933,11 +933,7 @@ int LuaScriptInterface::simulation_createParts(lua_State * l) int ry = luaL_optint(l,4,5); int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); int brush = luaL_optint(l,6,CIRCLE_BRUSH); - //int flags = luaL_optint(l,7,get_brush_flags()); - /*if (x < 0 || x > XRES || y < 0 || y > YRES) - return luaL_error(l, "Coordinates out of range (%d,%d)", x, y); - if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) - return luaL_error(l, "Unrecognised element number '%d'", c);*/ + int flags = luaL_optint(l,7,0); vector brushList = luacon_model->GetBrushList(); if (brush < 0 || brush > brushList.size()) @@ -961,13 +957,7 @@ int LuaScriptInterface::simulation_createLine(lua_State * l) int ry = luaL_optint(l,6,5); int c = luaL_optint(l,7,luacon_model->GetActiveTool(0)->GetToolID()); int brush = luaL_optint(l,8,CIRCLE_BRUSH); - //int flags = luaL_optint(l,9,get_brush_flags()); - /* (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) - return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); - if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) - return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); - if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) - return luaL_error(l, "Unrecognised element number '%d'", c);*/ + int flags = luaL_optint(l,9,0); vector brushList = luacon_model->GetBrushList(); if (brush < 0 || brush > brushList.size()) @@ -987,13 +977,7 @@ int LuaScriptInterface::simulation_createBox(lua_State * l) int x2 = luaL_optint(l,3,-1); int y2 = luaL_optint(l,4,-1); int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); - //int flags = luaL_optint(l,6,get_brush_flags()); - /*if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) - return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); - if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) - return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); - if (c < 0 || c >= PT_NUM || !luacon_sim->elements[c].Enabled) - return luaL_error(l, "Unrecognised element number '%d'", c);*/ + int flags = luaL_optint(l,6,0); luacon_sim->CreateBox(x1, y1, x2, y2, c, 0); return 0; @@ -1006,11 +990,7 @@ int LuaScriptInterface::simulation_floodParts(lua_State * l) int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID()); int cm = luaL_optint(l,4,-1); int bm = luaL_optint(l,5,-1); - //int flags = luaL_optint(l,6,0); - /*if (x < 0 || x > XRES || y < 0 || y > YRES) - return luaL_error(l, "coordinates out of range (%d,%d)", x, y); - if ((c >= 0 && c < PT_NUM && !luacon_sim->elements[c].Enabled) || c < 0) - return luaL_error(l, "Unrecognised element number '%d'", c);*/ + int flags = luaL_optint(l,6,0); int ret = luacon_sim->FloodParts(x, y, c, cm, bm, 0); lua_pushinteger(l, ret); return 1; @@ -1023,9 +1003,7 @@ int LuaScriptInterface::simulation_createWalls(lua_State * l) int rx = luaL_optint(l,3,0); int ry = luaL_optint(l,4,0); int c = luaL_optint(l,5,8); - //int flags = luaL_optint(l,6,get_brush_flags()); - if (x < 0 || x > XRES || y < 0 || y > YRES) - return luaL_error(l, "Coordinates out of range (%d,%d)", x, y); + int flags = luaL_optint(l,6,0); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); @@ -1043,11 +1021,7 @@ int LuaScriptInterface::simulation_createWallLine(lua_State * l) int rx = luaL_optint(l,5,0); int ry = luaL_optint(l,6,0); int c = luaL_optint(l,7,8); - //int flags = luaL_optint(l,8,get_brush_flags()); - if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) - return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); - if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) - return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); + int flags = luaL_optint(l,8,0); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); @@ -1062,11 +1036,7 @@ int LuaScriptInterface::simulation_createWallBox(lua_State * l) int x2 = luaL_optint(l,3,-1); int y2 = luaL_optint(l,4,-1); int c = luaL_optint(l,5,8); - //int flags = luaL_optint(l,6,get_brush_flags()); - if (x1 < 0 || x1 > XRES || y1 < 0 || y1 > YRES) - return luaL_error(l, "Starting coordinates out of range (%d,%d)", x1, y1); - if (x2 < 0 || x2 > XRES || y2 < 0 || y2 > YRES) - return luaL_error(l, "Ending Coordinates out of range (%d,%d)", x2, y2); + int flags = luaL_optint(l,6,0); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); @@ -1081,9 +1051,7 @@ int LuaScriptInterface::simulation_floodWalls(lua_State * l) int c = luaL_optint(l,3,8); int cm = luaL_optint(l,4,-1); int bm = luaL_optint(l,5,-1); - //int flags = luaL_optint(l,6,0); - if (x < 0 || x > XRES || y < 0 || y > YRES) - return luaL_error(l, "coordinates out of range (%d,%d)", x, y); + int flags = luaL_optint(l,6,0); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); int ret = luacon_sim->FloodWalls(x, y, c, cm, bm, 0); diff --git a/src/simulation/ElementGraphics.h b/src/simulation/ElementGraphics.h index 0f3723c..d1c8167 100644 --- a/src/simulation/ElementGraphics.h +++ b/src/simulation/ElementGraphics.h @@ -33,7 +33,7 @@ #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 -#define RENDER_BASC OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND +#define RENDER_BASC OPTIONS | PSPEC_STICKMAN | PMODE_FLAT | PMODE_ADD | PMODE_BLEND | EFFECT_LINES #define RENDER_NONE OPTIONS | PSPEC_STICKMAN | PMODE_FLAT #define COLOUR_HEAT 0x00000001 diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 5ce0d1e..5387f85 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -139,7 +139,6 @@ public: int flood_water(int x, int y, int i, int originaly, int check); TPT_NO_INLINE void detach(int i); TPT_NO_INLINE void part_change_type(int i, int x, int y, int t); - TPT_NO_INLINE int create_part_add_props(int p, int x, int y, int tv, int rx, int ry); //int InCurrentBrush(int i, int j, int rx, int ry); //int get_brush_flags(); TPT_NO_INLINE int create_part(int p, int x, int y, int t); @@ -170,8 +169,9 @@ public: int CreateParts(int positionX, int positionY, int c, Brush * cBrush); //Old particle creation, will create a crappy square, do not use int CreateParts(int x, int y, int rx, int ry, int c, int flags); + int CreatePartFlags(int x, int y, int c, int fn, int flags); void CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush); - void CreateLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags); + void CreateLine(int x1, int y1, int x2, int y2, int c); void CreateWallBox(int x1, int y1, int x2, int y2, int c, int flags); int FloodWalls(int x, int y, int c, int cm, int bm, int flags); diff --git a/src/simulation/elements/BIZR.cpp b/src/simulation/elements/BIZR.cpp index 8b61543..0352c26 100644 --- a/src/simulation/elements/BIZR.cpp +++ b/src/simulation/elements/BIZR.cpp @@ -117,6 +117,7 @@ int Element_BIZR::graphics(GRAPHICS_FUNC_ARGS) *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); *pixel_mode |= FIRE_ADD; } + *pixel_mode |= PMODE_BLUR; return 0; } diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index 472dbd7..79434e9 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -246,7 +246,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) int Element_SOAP::graphics(GRAPHICS_FUNC_ARGS) { - *pixel_mode |= EFFECT_LINES; + *pixel_mode |= EFFECT_LINES|PMODE_BLUR; return 1; } -- cgit v0.9.2-21-gd62e From 242f4bcdf63a29075f03308552ac2d02e93b0d92 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 01:00:48 -0400 Subject: more minor fixes diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index c409b1a..e066d6e 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -979,7 +979,7 @@ int LuaScriptInterface::simulation_createBox(lua_State * l) int c = luaL_optint(l,5,luacon_model->GetActiveTool(0)->GetToolID()); int flags = luaL_optint(l,6,0); - luacon_sim->CreateBox(x1, y1, x2, y2, c, 0); + luacon_sim->CreateBox(x1, y1, x2, y2, c, flags); return 0; } @@ -991,7 +991,7 @@ int LuaScriptInterface::simulation_floodParts(lua_State * l) int cm = luaL_optint(l,4,-1); int bm = luaL_optint(l,5,-1); int flags = luaL_optint(l,6,0); - int ret = luacon_sim->FloodParts(x, y, c, cm, bm, 0); + int ret = luacon_sim->FloodParts(x, y, c, cm, bm, flags); lua_pushinteger(l, ret); return 1; } @@ -1007,7 +1007,7 @@ int LuaScriptInterface::simulation_createWalls(lua_State * l) if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - int ret = luacon_sim->CreateWalls(x, y, rx, ry, c, 0); + int ret = luacon_sim->CreateWalls(x, y, rx, ry, c, flags); lua_pushinteger(l, ret); return 1; } @@ -1025,7 +1025,7 @@ int LuaScriptInterface::simulation_createWallLine(lua_State * l) if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - luacon_sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, 0); + luacon_sim->CreateWallLine(x1, y1, x2, y2, rx, ry, c, flags); return 0; } @@ -1040,7 +1040,7 @@ int LuaScriptInterface::simulation_createWallBox(lua_State * l) if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - luacon_sim->CreateWallBox(x1, y1, x2, y2, c, 0); + luacon_sim->CreateWallBox(x1, y1, x2, y2, c, flags); return 0; } @@ -1054,7 +1054,7 @@ int LuaScriptInterface::simulation_floodWalls(lua_State * l) int flags = luaL_optint(l,6,0); if (c < 0 || c >= UI_WALLCOUNT) return luaL_error(l, "Unrecognised wall id '%d'", c); - int ret = luacon_sim->FloodWalls(x, y, c, cm, bm, 0); + int ret = luacon_sim->FloodWalls(x, y, c, cm, bm, flags); lua_pushinteger(l, ret); return 1; } @@ -1069,8 +1069,8 @@ int LuaScriptInterface::simulation_saveStamp(lua_State * l) { int x = luaL_optint(l,1,0); int y = luaL_optint(l,2,0); - int w = luaL_optint(l,3,XRES); - int h = luaL_optint(l,4,YRES); + int w = luaL_optint(l,3,XRES-1); + int h = luaL_optint(l,4,YRES-1); std::string name = luacon_controller->StampRegion(ui::Point(x, y), ui::Point(x+w, y+h)); lua_pushstring(l, name.c_str()); return 1; @@ -1097,9 +1097,13 @@ int LuaScriptInterface::simulation_loadStamp(lua_State * l) } if (tempfile) { - luacon_sim->Load(x, y, tempfile->GetGameSave()); - //luacon_sim->sys_pause = (tempfile->GetGameSave()->paused | luacon_model->GetPaused())?1:0; - lua_pushinteger(l, 1); + if (luacon_sim->Load(x, y, tempfile->GetGameSave())) + { + //luacon_sim->sys_pause = (tempfile->GetGameSave()->paused | luacon_model->GetPaused())?1:0; + lua_pushinteger(l, 1); + } + else + lua_pushnil(l); } else lua_pushnil(l); -- cgit v0.9.2-21-gd62e From 751da54183acb5f7dae94e815aec1e0daf7bbd36 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 15:09:17 -0400 Subject: make making VIBR from molten TTAN+EXOT a little easier (molten VIBR slowly kills EXOT) diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp index 2746695..df075e0 100644 --- a/src/simulation/elements/EXOT.cpp +++ b/src/simulation/elements/EXOT.cpp @@ -70,11 +70,22 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) { } else if (rt == PT_LAVA) { - if ((parts[r>>8].ctype == PT_TTAN || parts[r>>8].ctype == PT_GOLD) && !(rand()%10)) + if (parts[r>>8].ctype == PT_TTAN || parts[r>>8].ctype == PT_GOLD) { - parts[r>>8].ctype = PT_VIBR; - sim->kill_part(i); - return 1; + if (!(rand()%10)) + { + parts[r>>8].ctype = PT_VIBR; + sim->kill_part(i); + return 1; + } + } + else if (parts[r>>8].ctype == PT_VIBR) + { + if (1>rand()%1000) + { + sim->kill_part(i); + return 1; + } } } if ((parts[i].tmp>245) && (parts[i].life>1000)) -- cgit v0.9.2-21-gd62e From 6f8e2c03456552bdd54355606b8b8389f884c06d Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 17:01:33 -0400 Subject: remove unneeded / duplicate constants, fix SPC_AIR/other tools so it won't conflict with lua elements (the 11th one won't work right now) diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index 06441c8..265ff27 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -947,6 +947,11 @@ void GameSave::readOPS(char * data, int dataLength) case PT_PSTN: if (savedVersion < 87 && particles[newIndex].ctype) particles[newIndex].life = 1; + case PT_STKM: + case PT_STKM2: + case PT_FIGH: + if (savedVersion < 88 && particles[newIndex].ctype == OLD_SPC_AIR) + particles[newIndex].ctype = SPC_AIR; } newIndex++; } @@ -1566,6 +1571,9 @@ void GameSave::readPSv(char * data, int dataLength) particles[i-1].ctype = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2])); } } + if (ver < 88) //fix air blowing stickmen + if ((particles[i-1].type == PT_STKM || particles[i-1].type == PT_STKM2 || particles[i-1].type == PT_FIGH) && particles[i-1].ctype == OLD_SPC_AIR) + particles[i-1].ctype == SPC_AIR; } } diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h index cb13216..67e2c4b 100644 --- a/src/simulation/Elements.h +++ b/src/simulation/Elements.h @@ -48,41 +48,6 @@ #define BOUNDS_CHECK true -#define SPC_AIR 236 -#define SPC_HEAT 237 -#define SPC_COOL 238 -#define SPC_VACUUM 239 -#define SPC_WIND 241 -#define SPC_PGRV 243 -#define SPC_NGRV 244 -#define SPC_PROP 246 - - -#define NGT_GOL 0 -#define NGT_HLIF 1 -#define NGT_ASIM 2 -#define NGT_2x2 3 -#define NGT_DANI 4 -#define NGT_AMOE 5 -#define NGT_MOVE 6 -#define NGT_PGOL 7 -#define NGT_DMOE 8 -#define NGT_34 9 -#define NGT_LLIF 10 -#define NGT_STAN 11 -#define NGT_SEED 12 -#define NGT_MAZE 13 -#define NGT_COAG 14 -#define NGT_WALL 15 -#define NGT_GNAR 16 -#define NGT_REPL 17 -#define NGT_MYST 18 -#define NGT_LOTE 19 -#define NGT_FRG2 20 -#define NGT_STAR 21 -#define NGT_FROG 22 -#define NGT_BRAN 23 - #define OLD_PT_WIND 147 //#define PT_NUM 161 diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 946b356..cf8f149 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2631,43 +2631,12 @@ int Simulation::create_part(int p, int x, int y, int tv) int t = tv & 0xFF; int v = (tv >> 8) & 0xFFFFFF; - if (x<0 || y<0 || x>=XRES || y>=YRES || ((t<=0 || t>=PT_NUM)&&t!=SPC_HEAT&&t!=SPC_COOL&&t!=SPC_AIR&&t!=SPC_VACUUM&&t!=SPC_PGRV&&t!=SPC_NGRV)) + if (x<0 || y<0 || x>=XRES || y>=YRES) return -1; - if (t>=0 && t=0 && t>8].temp>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP); - } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 50.0f, MIN_TEMP, MAX_TEMP); - } else { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP); - } - } - if (t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP) - { - if ((pmap[y][x]&0xFF)==PT_PUMP || (pmap[y][x]&0xFF)==PT_GPMP) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP); - } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 50.0f, MIN_TEMP, MAX_TEMP); - } else { - parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP); - } - } - return pmap[y][x]>>8; - } - else - { - return -1; - } - }*/ - if (t==SPC_AIR) + if (tv == SPC_AIR) { pv[y/CELL][x/CELL] += 0.03f; if (y+CELLparts_lastActiveIndex) parts_lastActiveIndex = i; + parts[i].x = (float)x; + parts[i].y = (float)y; + parts[i].type = t; + parts[i].vx = 0; + parts[i].vy = 0; + parts[i].life = 0; + parts[i].ctype = 0; + parts[i].temp = elements[t].Temperature; + parts[i].tmp = 0; + parts[i].tmp2 = 0; parts[i].dcolour = 0; parts[i].flags = 0; if (t == PT_GLAS || t == PT_QRTZ || t == PT_TUNG) { + parts[i].pavg[0] = 0.0f; parts[i].pavg[1] = pv[y/CELL][x/CELL]; } else @@ -2845,19 +2800,7 @@ int Simulation::create_part(int p, int x, int y, int tv) parts[i].pavg[0] = 0.0f; parts[i].pavg[1] = 0.0f; } - if (t!=PT_STKM&&t!=PT_STKM2&&t!=PT_FIGH)//set everything to default values first, except for stickman. - { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = t; - parts[i].vx = 0; - parts[i].vy = 0; - parts[i].life = 0; - parts[i].ctype = 0; - parts[i].temp = elements[t].Temperature; - parts[i].tmp = 0; - parts[i].tmp2 = 0; - } + switch (t) { case PT_SOAP: @@ -2964,14 +2907,7 @@ int Simulation::create_part(int p, int x, int y, int tv) case PT_STKM: if (player.spwn==0) { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = PT_STKM; - parts[i].vx = 0; - parts[i].vy = 0; parts[i].life = 100; - parts[i].ctype = 0; - parts[i].temp = elements[t].Temperature; Element_STKM::STKM_init_legs(this, &player, i); player.spwn = 1; player.elem = PT_DUST; @@ -2986,14 +2922,7 @@ int Simulation::create_part(int p, int x, int y, int tv) case PT_STKM2: if (player2.spwn==0) { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = PT_STKM2; - parts[i].vx = 0; - parts[i].vy = 0; parts[i].life = 100; - parts[i].ctype = 0; - parts[i].temp = elements[t].Temperature; Element_STKM::STKM_init_legs(this, &player2, i); player2.spwn = 1; player2.elem = PT_DUST; diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index 770d732..219db51 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -19,8 +19,6 @@ #define SC_CRACKER2 16 #define SC_TOTAL 15 -#define UI_WALLSTART 222 -#define UI_ACTUALSTART 122 #define UI_WALLCOUNT 16 #define O_WL_WALLELEC 122 @@ -61,14 +59,8 @@ #define WL_ALLOWENERGY 15 #define WL_FLOODHELPER 255 -#define SPC_AIR 236 -#define SPC_HEAT 237 -#define SPC_COOL 238 -#define SPC_VACUUM 239 -#define SPC_WIND 241 -#define SPC_PGRV 243 -#define SPC_NGRV 244 -#define SPC_PROP 246 +#define OLD_SPC_AIR 236 +#define SPC_AIR 256 #define DECO_DRAW 0 #define DECO_ADD 1 diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 93d5158..7767266 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -90,7 +90,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { parts[i].temp += 1; //Death - if (parts[i].life<1 || (sim->pv[y/CELL][x/CELL]>=4.5f && playerp->elem != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... + if (parts[i].life<1 || (sim->pv[y/CELL][x/CELL]>=4.5f && playerp->elem != SPC_AIR) ) //If his HP is less than 0 or there is very big wind... { for (r=-2; r<=1; r++) { diff --git a/src/simulation/tools/Cool.cpp b/src/simulation/tools/Cool.cpp index 4c5788d..07c24f9 100644 --- a/src/simulation/tools/Cool.cpp +++ b/src/simulation/tools/Cool.cpp @@ -12,7 +12,10 @@ int Tool_Cool::Perform(Simulation * sim, Particle * cpart, int x, int y, float s { if(!cpart) return 0; - cpart->temp -= strength; + if (cpart->type == PT_PUMP || cpart->type == PT_GPMP) + cpart->temp -= .1f*strength; + else + cpart->temp -= strength; if(cpart->temp > MAX_TEMP) cpart->temp = MAX_TEMP; if(cpart->temp < 0) diff --git a/src/simulation/tools/Heat.cpp b/src/simulation/tools/Heat.cpp index 1be3e6e..2d6510c 100644 --- a/src/simulation/tools/Heat.cpp +++ b/src/simulation/tools/Heat.cpp @@ -12,7 +12,10 @@ int Tool_Heat::Perform(Simulation * sim, Particle * cpart, int x, int y, float s { if(!cpart) return 0; - cpart->temp += strength; + if (cpart->type == PT_PUMP || cpart->type == PT_GPMP) + cpart->temp += .1f*strength; + else + cpart->temp += strength; if(cpart->temp > MAX_TEMP) cpart->temp = MAX_TEMP; if(cpart->temp < 0) -- cgit v0.9.2-21-gd62e From 027649e85894b688d271d9b736d5ca204304de29 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 19:33:30 -0400 Subject: lua simulation api functions for drawing with tools / deco diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index e066d6e..f9239f9 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -455,6 +455,12 @@ void LuaScriptInterface::initSimulationAPI() {"createWallLine", simulation_createWallLine}, {"createWallBox", simulation_createWallBox}, {"floodWalls", simulation_floodWalls}, + {"toolBrush", simulation_toolBrush}, + {"toolLine", simulation_toolLine}, + {"toolBox", simulation_toolBox}, + {"decoBrush", simulation_decoBrush}, + {"decoLine", simulation_decoLine}, + {"decoBox", simulation_decoBox}, {"clearSim", simulation_clearSim}, {"saveStamp", simulation_saveStamp}, {"loadStamp", simulation_loadStamp}, @@ -476,6 +482,20 @@ void LuaScriptInterface::initSimulationAPI() lua_pushinteger(l, MAX_TEMP); lua_setfield(l, simulationAPI, "MAX_TEMP"); lua_pushinteger(l, MIN_TEMP); lua_setfield(l, simulationAPI, "MIN_TEMP"); + lua_pushinteger(l, 0); lua_setfield(l, simulationAPI, "TOOL_HEAT"); + lua_pushinteger(l, 1); lua_setfield(l, simulationAPI, "TOOL_COOL"); + lua_pushinteger(l, 2); lua_setfield(l, simulationAPI, "TOOL_VAC"); + lua_pushinteger(l, 3); lua_setfield(l, simulationAPI, "TOOL_AIR"); + lua_pushinteger(l, 4); lua_setfield(l, simulationAPI, "TOOL_PGRV"); + lua_pushinteger(l, 5); lua_setfield(l, simulationAPI, "TOOL_NGRV"); + lua_pushinteger(l, DECO_DRAW); lua_setfield(l, simulationAPI, "DECO_DRAW"); + lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR"); + lua_pushinteger(l, DECO_ADD); lua_setfield(l, simulationAPI, "DECO_ADD"); + lua_pushinteger(l, DECO_SUBTRACT); lua_setfield(l, simulationAPI, "DECO_SUBTRACT"); + lua_pushinteger(l, DECO_MULTIPLY); lua_setfield(l, simulationAPI, "DECO_MULTIPLY"); + lua_pushinteger(l, DECO_DIVIDE); lua_setfield(l, simulationAPI, "DECO_DIVIDE"); + lua_pushinteger(l, DECO_SMUDGE); lua_setfield(l, simulationAPI, "DECO_SMUDGE"); + //Declare FIELD_BLAH constants std::vector particlePropertiesV = Particle::GetProperties(); particlePropertiesCount = 0; @@ -936,14 +956,14 @@ int LuaScriptInterface::simulation_createParts(lua_State * l) int flags = luaL_optint(l,7,0); vector brushList = luacon_model->GetBrushList(); - if (brush < 0 || brush > brushList.size()) + if (brush < 0 || brush >= brushList.size()) return luaL_error(l, "Invalid brush id '%d'", brush); ui::Point tempRadius = brushList[brush]->GetRadius(); brushList[brush]->SetRadius(ui::Point(rx, ry)); int ret = luacon_sim->CreateParts(x, y, c, brushList[brush]); - lua_pushinteger(l, ret); brushList[brush]->SetRadius(tempRadius); + lua_pushinteger(l, ret); return 1; } @@ -960,7 +980,7 @@ int LuaScriptInterface::simulation_createLine(lua_State * l) int flags = luaL_optint(l,9,0); vector brushList = luacon_model->GetBrushList(); - if (brush < 0 || brush > brushList.size()) + if (brush < 0 || brush >= brushList.size()) return luaL_error(l, "Invalid brush id '%d'", brush); ui::Point tempRadius = brushList[brush]->GetRadius(); brushList[brush]->SetRadius(ui::Point(rx, ry)); @@ -1059,6 +1079,144 @@ int LuaScriptInterface::simulation_floodWalls(lua_State * l) return 1; } +int LuaScriptInterface::simulation_toolBrush(lua_State * l) +{ + int x = luaL_optint(l,1,-1); + int y = luaL_optint(l,2,-1); + int rx = luaL_optint(l,3,5); + int ry = luaL_optint(l,4,5); + int tool = luaL_optint(l,5,0); + int brush = luaL_optint(l,6,CIRCLE_BRUSH); + float strength = luaL_optnumber(l,7,1.0f); + if (tool < 0 || tool >= luacon_sim->tools.size()) + return luaL_error(l, "Invalid tool id '%d'", tool); + + vector brushList = luacon_model->GetBrushList(); + if (brush < 0 || brush >= brushList.size()) + return luaL_error(l, "Invalid brush id '%d'", brush); + ui::Point tempRadius = brushList[brush]->GetRadius(); + brushList[brush]->SetRadius(ui::Point(rx, ry)); + + int ret = luacon_sim->ToolBrush(x, y, tool, brushList[brush], strength); + brushList[brush]->SetRadius(tempRadius); + lua_pushinteger(l, ret); + return 1; +} + +int LuaScriptInterface::simulation_toolLine(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int rx = luaL_optint(l,5,5); + int ry = luaL_optint(l,6,5); + int tool = luaL_optint(l,7,0); + int brush = luaL_optint(l,8,CIRCLE_BRUSH); + float strength = luaL_optnumber(l,9,1.0f); + if (tool < 0 || tool >= luacon_sim->tools.size()) + return luaL_error(l, "Invalid tool id '%d'", tool); + + vector brushList = luacon_model->GetBrushList(); + if (brush < 0 || brush >= brushList.size()) + return luaL_error(l, "Invalid brush id '%d'", brush); + ui::Point tempRadius = brushList[brush]->GetRadius(); + brushList[brush]->SetRadius(ui::Point(rx, ry)); + + luacon_sim->ToolLine(x1, y1, x2, y2, tool, brushList[brush], strength); + brushList[brush]->SetRadius(tempRadius); + return 0; +} + +int LuaScriptInterface::simulation_toolBox(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int tool = luaL_optint(l,5,0); + float strength = luaL_optnumber(l,6,1.0f); + if (tool < 0 || tool >= luacon_sim->tools.size()) + return luaL_error(l, "Invalid tool id '%d'", tool); + + luacon_sim->ToolBox(x1, y1, x2, y2, tool, strength); + return 0; +} + +int LuaScriptInterface::simulation_decoBrush(lua_State * l) +{ + int x = luaL_optint(l,1,-1); + int y = luaL_optint(l,2,-1); + int rx = luaL_optint(l,3,5); + int ry = luaL_optint(l,4,5); + int r = luaL_optint(l,5,255); + int g = luaL_optint(l,6,255); + int b = luaL_optint(l,7,255); + int a = luaL_optint(l,8,255); + int tool = luaL_optint(l,9,DECO_DRAW); + int brush = luaL_optint(l,10,CIRCLE_BRUSH); + if (tool < 0 || tool >= luacon_sim->tools.size()) + return luaL_error(l, "Invalid tool id '%d'", tool); + + vector brushList = luacon_model->GetBrushList(); + if (brush < 0 || brush >= brushList.size()) + return luaL_error(l, "Invalid brush id '%d'", brush); + ui::Point tempRadius = brushList[brush]->GetRadius(); + brushList[brush]->SetRadius(ui::Point(rx, ry)); + + luacon_sim->ApplyDecorationPoint(x, y, r, g, b, a, tool, brushList[brush]); + brushList[brush]->SetRadius(tempRadius); + return 0; +} + +int LuaScriptInterface::simulation_decoLine(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int rx = luaL_optint(l,5,5); + int ry = luaL_optint(l,6,5); + int r = luaL_optint(l,7,255); + int g = luaL_optint(l,8,255); + int b = luaL_optint(l,9,255); + int a = luaL_optint(l,10,255); + int tool = luaL_optint(l,11,DECO_DRAW); + int brush = luaL_optint(l,12,CIRCLE_BRUSH); + if (tool < 0 || tool >= luacon_sim->tools.size()) + return luaL_error(l, "Invalid tool id '%d'", tool); + + vector brushList = luacon_model->GetBrushList(); + if (brush < 0 || brush >= brushList.size()) + return luaL_error(l, "Invalid brush id '%d'", brush); + ui::Point tempRadius = brushList[brush]->GetRadius(); + brushList[brush]->SetRadius(ui::Point(rx, ry)); + + luacon_sim->ApplyDecorationLine(x1, y1, x2, y2, r, g, b, a, tool, brushList[brush]); + brushList[brush]->SetRadius(tempRadius); + return 0; +} + +int LuaScriptInterface::simulation_decoBox(lua_State * l) +{ + int x1 = luaL_optint(l,1,-1); + int y1 = luaL_optint(l,2,-1); + int x2 = luaL_optint(l,3,-1); + int y2 = luaL_optint(l,4,-1); + int rx = luaL_optint(l,5,5); + int ry = luaL_optint(l,6,5); + int r = luaL_optint(l,7,255); + int g = luaL_optint(l,8,255); + int b = luaL_optint(l,9,255); + int a = luaL_optint(l,10,255); + int tool = luaL_optint(l,11,0); + if (tool < 0 || tool >= luacon_sim->tools.size()) + return luaL_error(l, "Invalid tool id '%d'", tool); + + luacon_sim->ApplyDecorationBox(x1, y1, x2, y2, r, g, b, a, tool); + return 0; +} + int LuaScriptInterface::simulation_clearSim(lua_State * l) { luacon_sim->clear_sim(); diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index c002f41..953d695 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -72,6 +72,12 @@ class LuaScriptInterface: public CommandInterface static int simulation_createWallLine(lua_State * l); static int simulation_createWallBox(lua_State * l); static int simulation_floodWalls(lua_State * l); + static int simulation_toolBrush(lua_State * l); + static int simulation_toolLine(lua_State * l); + static int simulation_toolBox(lua_State * l); + static int simulation_decoBrush(lua_State * l); + static int simulation_decoLine(lua_State * l); + static int simulation_decoBox(lua_State * l); static int simulation_clearSim(lua_State * l); static int simulation_saveStamp(lua_State * l); static int simulation_loadStamp(lua_State * l); diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index aecd0eb..b57a7cb 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -292,7 +292,7 @@ void GameModel::BuildMenus() //Build menu for GOL types for(int i = 0; i < NGOL; i++) { - Tool * tempTool = new GolTool(PT_LIFE|(i<<8), sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name)); + Tool * tempTool = new ElementTool(PT_LIFE|(i<<8), sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name)); menuList[SC_LIFE]->AddTool(tempTool); } diff --git a/src/gui/game/Tool.cpp b/src/gui/game/Tool.cpp index e33b0ce..df99e57 100644 --- a/src/gui/game/Tool.cpp +++ b/src/gui/game/Tool.cpp @@ -45,7 +45,7 @@ void Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Po sim->ToolLine(position1.X, position1.Y, position2.X, position2.Y, toolID, brush, strength); } void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { - sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, brush, strength); + sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, strength); } void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}; @@ -110,26 +110,6 @@ void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { sim->FloodWalls(position.X, position.Y, toolID, -1, -1, 0); } - -GolTool::GolTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)): - Tool(id, name, description, r, g, b, identifier, textureGen) -{ -} -GolTool::~GolTool() {} -void GolTool::Draw(Simulation * sim, Brush * brush, ui::Point position){ - sim->CreateParts(position.X, position.Y, toolID, brush); -} -void GolTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) { - sim->CreateLine(position1.X, position1.Y, position2.X, position2.Y, toolID, brush); -} -void GolTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { - sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID, 0); -} -void GolTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) { - sim->FloodParts(position.X, position.Y, toolID, -1, -1, 0); -} - - WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)): Tool(id, name, description, r, g, b, identifier, textureGen) { diff --git a/src/gui/game/Tool.h b/src/gui/game/Tool.h index ea38fbc..df4e5cc 100644 --- a/src/gui/game/Tool.h +++ b/src/gui/game/Tool.h @@ -158,17 +158,6 @@ public: virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position); }; -class GolTool: public Tool -{ -public: - GolTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL); - virtual ~GolTool(); - virtual void Draw(Simulation * sim, Brush * brush, ui::Point position); - virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false); - virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2); - virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position); -}; - class WindTool: public Tool { public: diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index cf8f149..4289016 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1213,7 +1213,7 @@ void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBru } } } -void Simulation::ToolBox(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength) +void Simulation::ToolBox(int x1, int y1, int x2, int y2, int tool, float strength) { int i, j; if (x1>x2) diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 5387f85..1b27bc7 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -160,7 +160,7 @@ public: int Tool(int x, int y, int tool, float strength = 1.0f); int ToolBrush(int x, int y, int tool, Brush * cBrush, float strength = 1.0f); void ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength = 1.0f); - void ToolBox(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength = 1.0f); + void ToolBox(int x1, int y1, int x2, int y2, int tool, float strength = 1.0f); void CreateBox(int x1, int y1, int x2, int y2, int c, int flags); int FloodINST(int x, int y, int fullc, int cm); -- cgit v0.9.2-21-gd62e From fd97e923f3f8409346723a9924761c9e21bb79d3 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 19:36:41 -0400 Subject: remove check in deco tools (that shouldn't be there) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index f9239f9..f257636 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1155,8 +1155,6 @@ int LuaScriptInterface::simulation_decoBrush(lua_State * l) int a = luaL_optint(l,8,255); int tool = luaL_optint(l,9,DECO_DRAW); int brush = luaL_optint(l,10,CIRCLE_BRUSH); - if (tool < 0 || tool >= luacon_sim->tools.size()) - return luaL_error(l, "Invalid tool id '%d'", tool); vector brushList = luacon_model->GetBrushList(); if (brush < 0 || brush >= brushList.size()) @@ -1183,8 +1181,6 @@ int LuaScriptInterface::simulation_decoLine(lua_State * l) int a = luaL_optint(l,10,255); int tool = luaL_optint(l,11,DECO_DRAW); int brush = luaL_optint(l,12,CIRCLE_BRUSH); - if (tool < 0 || tool >= luacon_sim->tools.size()) - return luaL_error(l, "Invalid tool id '%d'", tool); vector brushList = luacon_model->GetBrushList(); if (brush < 0 || brush >= brushList.size()) @@ -1210,8 +1206,6 @@ int LuaScriptInterface::simulation_decoBox(lua_State * l) int b = luaL_optint(l,9,255); int a = luaL_optint(l,10,255); int tool = luaL_optint(l,11,0); - if (tool < 0 || tool >= luacon_sim->tools.size()) - return luaL_error(l, "Invalid tool id '%d'", tool); luacon_sim->ApplyDecorationBox(x1, y1, x2, y2, r, g, b, a, tool); return 0; -- cgit v0.9.2-21-gd62e From 7b6ded50dca6df5dfe2b22eb47de966e02878284 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 20:04:39 -0400 Subject: rename GRAV back to PGRV, fix formatting in generator, remove useless file diff --git a/generator.py b/generator.py index 952b6fa..30a4c23 100644 --- a/generator.py +++ b/generator.py @@ -92,13 +92,13 @@ public: virtual ~{0}(); {2} }}; - """.format(className, elementBase, string.join(classMembers, "\n\t")) +""".format(className, elementBase, string.join(classMembers, "\n\t")) elementHeader += """ std::vector GetElements(); #endif - """ +""" elementContent = """#include "ElementClasses.h" @@ -122,7 +122,7 @@ std::vector GetElements() elementContent += """return elements; } - """; +"""; outputPath, outputFile = os.path.split(outputH) if not os.path.exists(outputPath): @@ -140,11 +140,13 @@ def generateTools(toolFiles, outputCpp, outputH): toolClasses = {} toolHeader = """#ifndef TOOLCLASSES_H - #define TOOLCLASSES_H - #include - #include "simulation/Tools.h" - #include "simulation/tools/SimTool.h" - """ +#define TOOLCLASSES_H + +#include + +#include "simulation/tools/SimTool.h" + +""" directives = [] @@ -176,34 +178,36 @@ def generateTools(toolFiles, outputCpp, outputH): toolClasses[d[1]].append(string.join(d[2:], " ")+";") for className, classMembers in toolClasses.items(): - toolHeader += """class {0}: public SimTool - {{ - public: - {0}(); - virtual ~{0}(); - virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength); - {1} - }}; - """.format(className, string.join(classMembers, "\n")) + toolHeader += """ +class {0}: public SimTool +{{ +public: + {0}(); + virtual ~{0}(); + virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength); +}}; +""".format(className, string.join(classMembers, "\n")) - toolHeader += """std::vector GetTools(); - #endif - """ + toolHeader += """ +std::vector GetTools(); + +#endif +""" toolContent = """#include "ToolClasses.h" - std::vector GetTools() - { - std::vector tools; - """; +std::vector GetTools() +{ + std::vector tools; +"""; toolIDs = sorted(classDirectives, key=lambda directive: directive[3]) for d in toolIDs: toolContent += """ tools.push_back(new %s()); - """ % (d[1]) +""" % (d[1]) toolContent += """ return tools; - } - """; +} +"""; outputPath, outputFile = os.path.split(outputH) if not os.path.exists(outputPath): diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index f257636..8cb01ee 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -15,6 +15,7 @@ #include "gui/dialogues/TextPrompt.h" #include "gui/dialogues/ConfirmPrompt.h" #include "simulation/Simulation.h" +#include "ToolClasses.h" #include "gui/game/GameModel.h" #include "gui/game/Tool.h" #include "LuaScriptHelper.h" @@ -482,12 +483,12 @@ void LuaScriptInterface::initSimulationAPI() lua_pushinteger(l, MAX_TEMP); lua_setfield(l, simulationAPI, "MAX_TEMP"); lua_pushinteger(l, MIN_TEMP); lua_setfield(l, simulationAPI, "MIN_TEMP"); - lua_pushinteger(l, 0); lua_setfield(l, simulationAPI, "TOOL_HEAT"); - lua_pushinteger(l, 1); lua_setfield(l, simulationAPI, "TOOL_COOL"); - lua_pushinteger(l, 2); lua_setfield(l, simulationAPI, "TOOL_VAC"); - lua_pushinteger(l, 3); lua_setfield(l, simulationAPI, "TOOL_AIR"); - lua_pushinteger(l, 4); lua_setfield(l, simulationAPI, "TOOL_PGRV"); - lua_pushinteger(l, 5); lua_setfield(l, simulationAPI, "TOOL_NGRV"); + lua_pushinteger(l, TOOL_HEAT); lua_setfield(l, simulationAPI, "TOOL_HEAT"); + lua_pushinteger(l, TOOL_COOL); lua_setfield(l, simulationAPI, "TOOL_COOL"); + lua_pushinteger(l, TOOL_VAC); lua_setfield(l, simulationAPI, "TOOL_VAC"); + lua_pushinteger(l, TOOL_AIR); lua_setfield(l, simulationAPI, "TOOL_AIR"); + lua_pushinteger(l, TOOL_PGRV); lua_setfield(l, simulationAPI, "TOOL_PGRV"); + lua_pushinteger(l, TOOL_NGRV); lua_setfield(l, simulationAPI, "TOOL_NGRV"); lua_pushinteger(l, DECO_DRAW); lua_setfield(l, simulationAPI, "DECO_DRAW"); lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR"); lua_pushinteger(l, DECO_ADD); lua_setfield(l, simulationAPI, "DECO_ADD"); diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index b57a7cb..5925079 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -3,7 +3,7 @@ #include "GameView.h" #include "simulation/Simulation.h" #include "simulation/Air.h" -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "graphics/Renderer.h" #include "gui/interface/Point.h" #include "Brush.h" diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 4289016..4c1a543 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -17,7 +17,7 @@ //#include "graphics/Renderer.h" //#include "graphics/Graphics.h" #include "Misc.h" -#include "Tools.h" +#include "ToolClasses.h" #include "gui/game/Brush.h" #include "client/GameSave.h" #include "Sample.h" diff --git a/src/simulation/Tools.h b/src/simulation/Tools.h deleted file mode 100644 index 525701e..0000000 --- a/src/simulation/Tools.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef TOOLS_H_ -#define TOOLS_H_ - -#include "ToolClasses.h" - - -#endif diff --git a/src/simulation/tools/AirTool.cpp b/src/simulation/tools/AirTool.cpp index 23120a0..4e7ebde 100644 --- a/src/simulation/tools/AirTool.cpp +++ b/src/simulation/tools/AirTool.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "simulation/Air.h" //#TPT-Directive ToolClass Tool_Air TOOL_AIR 3 Tool_Air::Tool_Air() diff --git a/src/simulation/tools/Cool.cpp b/src/simulation/tools/Cool.cpp index 07c24f9..bc49634 100644 --- a/src/simulation/tools/Cool.cpp +++ b/src/simulation/tools/Cool.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" //#TPT-Directive ToolClass Tool_Cool TOOL_COOL 1 Tool_Cool::Tool_Cool() { diff --git a/src/simulation/tools/GravTool.cpp b/src/simulation/tools/GravTool.cpp deleted file mode 100644 index 3ff30bd..0000000 --- a/src/simulation/tools/GravTool.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "simulation/Tools.h" -#include "simulation/Simulation.h" -//#TPT-Directive ToolClass Tool_Grav TOOL_GRAV 4 -Tool_Grav::Tool_Grav() -{ - Identifier = "DEFAULT_TOOL_GRAV"; - Name = "GRAV"; - Colour = PIXPACK(0xCCCCFF); - Description = "Creates a short-lasting gravity well"; -} - -int Tool_Grav::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) -{ - sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] += 0.03f*strength; - return 1; -} - -Tool_Grav::~Tool_Grav() {} diff --git a/src/simulation/tools/Heat.cpp b/src/simulation/tools/Heat.cpp index 2d6510c..903efe3 100644 --- a/src/simulation/tools/Heat.cpp +++ b/src/simulation/tools/Heat.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" //#TPT-Directive ToolClass Tool_Heat TOOL_HEAT 0 Tool_Heat::Tool_Heat() { diff --git a/src/simulation/tools/NGrv.cpp b/src/simulation/tools/NGrv.cpp index 5e339e6..65530c5 100644 --- a/src/simulation/tools/NGrv.cpp +++ b/src/simulation/tools/NGrv.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "simulation/Simulation.h" //#TPT-Directive ToolClass Tool_NGrv TOOL_NGRV 5 Tool_NGrv::Tool_NGrv() diff --git a/src/simulation/tools/PGrv.cpp b/src/simulation/tools/PGrv.cpp new file mode 100644 index 0000000..cfa381c --- /dev/null +++ b/src/simulation/tools/PGrv.cpp @@ -0,0 +1,18 @@ +#include "ToolClasses.h" +#include "simulation/Simulation.h" +//#TPT-Directive ToolClass Tool_PGrv TOOL_PGRV 4 +Tool_PGrv::Tool_PGrv() +{ + Identifier = "DEFAULT_TOOL_PGRV"; + Name = "PGRV"; + Colour = PIXPACK(0xCCCCFF); + Description = "Creates a short-lasting gravity well"; +} + +int Tool_PGrv::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] += 0.03f*strength; + return 1; +} + +Tool_PGrv::~Tool_PGrv() {} diff --git a/src/simulation/tools/SimTool.cpp b/src/simulation/tools/SimTool.cpp index 4b3ddeb..0fdec2b 100644 --- a/src/simulation/tools/SimTool.cpp +++ b/src/simulation/tools/SimTool.cpp @@ -1,5 +1,5 @@ #include "simulation/Element.h" -#include "simulation/Tools.h" +#include "ToolClasses.h" SimTool::SimTool(): Identifier("DEFAULT_TOOL_INVALID"), diff --git a/src/simulation/tools/Vac.cpp b/src/simulation/tools/Vac.cpp index aa319e2..fbf7e85 100644 --- a/src/simulation/tools/Vac.cpp +++ b/src/simulation/tools/Vac.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "simulation/Air.h" //#TPT-Directive ToolClass Tool_Vac TOOL_VAC 2 Tool_Vac::Tool_Vac() @@ -6,7 +6,7 @@ Tool_Vac::Tool_Vac() Identifier = "DEFAULT_TOOL_VAC"; Name = "VAC"; Colour = PIXPACK(0x303030); - Description = "Removes air pressure"; + Description = "Reduces air pressure"; } int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) -- cgit v0.9.2-21-gd62e From 9cd84eccde7baff9a3a4627dd03ade3f8b72d479 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 21:59:40 -0400 Subject: fix tpt.selectedl sometimes being incorrect diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 267133b..e98086a 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -947,14 +947,15 @@ void GameController::SetActiveMenu(int menuID) { gameModel->SetActiveMenu(menuID); vector menuList = gameModel->GetMenuList(); - bool set = false; if(menuID == SC_DECO) - { gameModel->SetColourSelectorVisibility(true); - set = true; - } - if(!set) + else + { gameModel->SetColourSelectorVisibility(false); + ActiveToolChanged(0, gameModel->GetActiveTool(0)); + ActiveToolChanged(1, gameModel->GetActiveTool(1)); + ActiveToolChanged(2, gameModel->GetActiveTool(2)); + } } std::vector GameController::GetMenuList() -- cgit v0.9.2-21-gd62e From 77bf649fb4482c86ac1fd9b3233f062b53226007 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 16 May 2013 23:12:33 -0400 Subject: new lua sim api functions to get/set deco color, load a save, and adjust coordinates to the screen / zoom window diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 8cb01ee..bce6012 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -462,9 +462,13 @@ void LuaScriptInterface::initSimulationAPI() {"decoBrush", simulation_decoBrush}, {"decoLine", simulation_decoLine}, {"decoBox", simulation_decoBox}, + {"decoColor", simulation_decoColor}, + {"decoColour", simulation_decoColor}, {"clearSim", simulation_clearSim}, {"saveStamp", simulation_saveStamp}, {"loadStamp", simulation_loadStamp}, + {"loadSave", simulation_loadSave}, + {"adjustCoords", simulation_adjustCoords}, {NULL, NULL} }; luaL_register(l, "simulation", simulationAPIMethods); @@ -1212,6 +1216,38 @@ int LuaScriptInterface::simulation_decoBox(lua_State * l) return 0; } +int LuaScriptInterface::simulation_decoColor(lua_State * l) +{ + int acount = lua_gettop(l); + unsigned int color; + if (acount == 0) + { + ui::Colour tempColor = luacon_model->GetColourSelectorColour(); + unsigned int color = (tempColor.Alpha << 24) | PIXRGB(tempColor.Red, tempColor.Green, tempColor.Blue); + lua_pushnumber(l, color); + return 1; + } + else if (acount == 1) + color = (unsigned int)luaL_optnumber(l, 1, 0xFFFF0000); + else + { + int r, g, b, a; + r = luaL_optint(l, 1, 255); + g = luaL_optint(l, 2, 255); + b = luaL_optint(l, 3, 255); + a = luaL_optint(l, 4, 255); + + if (r < 0) r = 0; if (r > 255) r = 255; + if (g < 0) g = 0; if (g > 255) g = 255; + if (b < 0) b = 0; if (b > 255) b = 255; + if (a < 0) a = 0; if (a > 255) a = 255; + + color = (a << 24) + PIXRGB(r, g, b); + } + luacon_model->SetColourSelectorColour(ui::Colour(PIXR(color), PIXG(color), PIXB(color), color >> 24)); + return 0; +} + int LuaScriptInterface::simulation_clearSim(lua_State * l) { luacon_sim->clear_sim(); @@ -1263,6 +1299,24 @@ int LuaScriptInterface::simulation_loadStamp(lua_State * l) return 1; } +int LuaScriptInterface::simulation_loadSave(lua_State * l) +{ + int saveID = luaL_optint(l,1,0); + int history = luaL_optint(l,2,0); //Exact second a previous save was saved + luacon_controller->OpenSavePreview(saveID, history); + return 0; +} + +int LuaScriptInterface::simulation_adjustCoords(lua_State * l) +{ + int x = luaL_optint(l,1,0); + int y = luaL_optint(l,2,0); + ui::Point Coords = luacon_controller->PointTranslate(ui::Point(x, y)); + lua_pushinteger(l, Coords.X); + lua_pushinteger(l, Coords.Y); + return 2; +} + //// Begin Renderer API diff --git a/src/cat/LuaScriptInterface.h b/src/cat/LuaScriptInterface.h index 953d695..0c868d3 100644 --- a/src/cat/LuaScriptInterface.h +++ b/src/cat/LuaScriptInterface.h @@ -78,9 +78,12 @@ class LuaScriptInterface: public CommandInterface static int simulation_decoBrush(lua_State * l); static int simulation_decoLine(lua_State * l); static int simulation_decoBox(lua_State * l); + static int simulation_decoColor(lua_State * l); static int simulation_clearSim(lua_State * l); static int simulation_saveStamp(lua_State * l); static int simulation_loadStamp(lua_State * l); + static int simulation_loadSave(lua_State * l); + static int simulation_adjustCoords(lua_State * l); //Renderer void initRendererAPI(); diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index e98086a..d8ff3c6 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1048,7 +1048,7 @@ void GameController::LoadSave(SaveInfo * save) void GameController::OpenSavePreview(int saveID, int saveDate) { - activePreview = new PreviewController(saveID, new SaveOpenCallback(this)); + activePreview = new PreviewController(saveID, saveDate, new SaveOpenCallback(this)); ui::Engine::Ref().ShowWindow(activePreview->GetView()); } -- cgit v0.9.2-21-gd62e