diff --git a/binaries/system/Atlas.bat b/binaries/system/Atlas.bat index 42bf07ebe1..5da2d94a60 100644 --- a/binaries/system/Atlas.bat +++ b/binaries/system/Atlas.bat @@ -1 +1 @@ -ps -editor \ No newline at end of file +pyrogenesis.exe -editor \ No newline at end of file diff --git a/build/docs/builddoc.bat b/build/docs/builddoc.bat index e2c00dc9bc..1fddb3c61d 100644 --- a/build/docs/builddoc.bat +++ b/build/docs/builddoc.bat @@ -1 +1 @@ -"cppdoc_cmd.exe" -overwrite -autoview -autoquit -title="0 A.D." -company="Wildfire Games" -hier -insertbr -include-const -include-anonymous -document-preprocessor -comment-format="/**;*;*/;AFTER///;//;///" -classdir=projects -module="cppdoc-standard" -extensions="c,cpp,cxx,cc,h,hpp,hxx" -languages="c=cpp,cc=cpp,cpp=cpp,cs=csharp,cxx=cpp,h=cpp,hpp=cpp,hxx=cpp,java=java" -enable-author=true -enable-deprecations=true -enable-since=true -enable-version=true -file-links-for-globals=true -generate-deprecations-list=true -generate-hierarchy=true -header-background-dark="#ccccff" -header-background-light="#eeeeff" -include-private=true -include-protected=true -index-file-base=index -overview-html=overview.html -reduce-summary-font=true -selected-text-background=navy -selected-text-foreground=white -separate-index-pages=true -show-cppdoc-version=true -show-timestamp=true -summary-html=project.html -suppress-details=false -suppress-frames-links=false -table-background=white -wrap-long-lines=true "..\..\source\graphics" "..\..\source\maths" "..\..\source\ps" "..\..\source\renderer" "..\..\source\scripting" "..\..\source\sound" "..\..\docs\generated\index.html" \ No newline at end of file +"cppdoc_cmd.exe" -overwrite -autoview -autoquit -title="0 A.D." -company="Wildfire Games" -hier -include-const -include-anonymous -document-preprocessor -comment-format="/**;*;*/;AFTER///;//;///" -classdir=projects -module="cppdoc-standard" -extensions="c,cpp,cxx,cc,h,hpp,hxx" -languages="c=cpp,cc=cpp,cpp=cpp,cs=csharp,cxx=cpp,h=cpp,hpp=cpp,hxx=cpp,java=java" -enable-author=true -enable-deprecations=true -enable-since=true -enable-version=true -file-links-for-globals=true -generate-deprecations-list=true -generate-hierarchy=true -header-background-dark="#ccccff" -header-background-light="#eeeeff" -include-private=true -include-protected=true -index-file-base=index -overview-html=overview.html -reduce-summary-font=true -selected-text-background=navy -selected-text-foreground=white -separate-index-pages=true -show-cppdoc-version=true -show-timestamp=true -summary-html=project.html -suppress-details=false -suppress-frames-links=false -table-background=white -wrap-long-lines=true "..\..\source\graphics" "..\..\source\maths" "..\..\source\ps" "..\..\source\renderer" "..\..\source\scripting" "..\..\source\sound" "..\..\docs\generated\index.html" \ No newline at end of file diff --git a/build/premake/functions.lua b/build/premake/functions.lua index 9eaaa14e36..903ba604cf 100755 --- a/build/premake/functions.lua +++ b/build/premake/functions.lua @@ -1,10 +1,12 @@ function sourcesfromdirs(root, dirs) local res = {} for i,v in dirs do + local prefix + if v == "" then prefix = root..v else prefix = root..v.."/" end local files = matchfiles( - root..v.."/*.cpp", - root..v.."/*.h", - root..v.."/*.asm") + prefix.."*.cpp", + prefix.."*.h", + prefix.."*.asm") listconcat(res, files) end return res diff --git a/build/premake/premake.exe b/build/premake/premake.exe index e633158c04..5edf628f81 100755 Binary files a/build/premake/premake.exe and b/build/premake/premake.exe differ diff --git a/build/premake/premake.lua b/build/premake/premake.lua index d26bba88f0..cbd70d0f11 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -23,14 +23,14 @@ end -- They must each contain an "include" [on Windows: also "lib"] subdirectory. -- -- When adding new ones, make sure to also add them in the main_exe link step --- (it'd be nice to automate this, but lib names and debug suffixes differ wildly). +-- (it'd be nice to automate this, but lib names and debug suffixes differ wildly). libraries_dir = "../../../libraries/" source_root = "../../../source/" -- default for most projects - overridden by local in others -- Rationale: packages should not have any additional include paths except for -- those required by external libraries. Instead, we should always write the -- full relative path, e.g. #include "maths/Vector3d.h". This avoids confusion --- ("which file is meant?") and avoids enormous include path lists. +-- ("which file is meant?") and avoids enormous include path lists. -- packages: engine static libs, main exe, atlas, atlas frontends -- the engine libs are necessary because they are referenced by the separate @@ -119,18 +119,20 @@ function package_add_contents(source_root, rel_source_dirs, rel_include_dirs, ex table.insert(package.files, source_root .. v) end end - - package.includepaths = { - -- Put the project-specific PCH directory at the start of the - -- include path, so '#include "precompiled.h"' will look in - -- there first - source_root .. "pch/" .. package.name, - -- TODO: don't do this for the independent Atlas packages... - - -- next is source root dir, for absolute (nonrelative) includes - -- (e.g. "lib/precompiled.h") - source_root - } + + package.includepaths = {} + + -- Put the project-specific PCH directory at the start of the + -- include path, so '#include "precompiled.h"' will look in + -- there first + if not extra_params["no_default_pch"] then + table.insert(package.includepaths, source_root .. "pch/" .. package.name) + end + + -- next is source root dir, for absolute (nonrelative) includes + -- (e.g. "lib/precompiled.h") + table.insert(package.includepaths, source_root) + for i,v in rel_include_dirs do table.insert(package.includepaths, source_root .. v) end @@ -157,7 +159,7 @@ function setup_static_lib_package (package_name, rel_source_dirs, extern_libs, e create_package_with_cflags(package_name, "lib") package_add_contents(source_root, rel_source_dirs, {}, extern_libs, extra_params) - + if OS == "windows" then -- Precompiled Headers -- rationale: we need one PCH per static lib, since one global header would @@ -171,7 +173,7 @@ function setup_static_lib_package (package_name, rel_source_dirs, extern_libs, e -- * Visual Assist manages to use the project include path and can -- correctly open these files from the IDE. -- * precompiled.cpp (needed to "Create" the PCH) also goes in - -- the abovementioned dir. + -- the abovementioned dir. pch_dir = source_root.."pch/"..package_name.."/" package.pchheader = "precompiled.h" package.pchsource = "precompiled.cpp" @@ -296,8 +298,14 @@ end function setup_main_exe () create_package_with_cflags("pyrogenesis", "winexe") + table.insert(package.files, "../../../source/main.cpp") + -- For VS2005, tell the linker to use the libraries' .obj files instead of + -- the .lib, to allow incremental linking. + -- (Reduces re-link time from ~20 seconds to ~2 secs) + table.insert(package.buildflags, "use-library-dep-inputs") + package.links = { "engine", "graphics", @@ -412,8 +420,12 @@ end function setuppackage_atlas(package_name, target_type, rel_source_dirs, rel_include_dirs, extern_libs, flags) - local source_root = "../../../source/tools/atlas/" .. package_name + local source_root = "../../../source/tools/atlas/" .. package_name .. "/" create_package_with_cflags(package_name, target_type) + + -- Don't add the default 'sourceroot/pch/projectname' for finding PCH files + flags["no_default_pch"] = 1 + package_add_contents(source_root, rel_source_dirs, rel_include_dirs, extern_libs, flags) -- Platform Specifics @@ -481,77 +493,67 @@ end ---------------- Atlas packages ---------------- function setuppackages_atlas() - setuppackage_atlas("AtlasObject", "lib", { - -- src + setuppackage_atlas("AtlasObject", "lib", + { -- src "" - },{ - -- include - },{ - -- extern_libs + },{ -- include + },{ -- extern_libs "xerces" - },{ - -- flags + },{ -- flags }) - setuppackage_atlas("AtlasUI", "dll", { - -- src - "/ActorEditor", - "/ArchiveViewer", - "/ColourTester", - "/CustomControls/Buttons", - "/CustomControls/DraggableListCtrl", - "/CustomControls/EditableListCtrl", - "/CustomControls/FileHistory", - "/CustomControls/HighResTimer", - "/CustomControls/SnapSplitterWindow", - "/CustomControls/VirtualDirTreeCtrl", - "/CustomControls/Windows", - "/FileConverter", - "/General", - "/Misc", - "/ScenarioEditor", - "/ScenarioEditor/Sections/Common", - "/ScenarioEditor/Sections/Map", - "/ScenarioEditor/Sections/Object", - "/ScenarioEditor/Sections/Terrain", - "/ScenarioEditor/Tools", - "/ScenarioEditor/Tools/Common" - },{ - -- include - "/..", - "", - "/CustomControls" - },{ - -- extern_libs + setuppackage_atlas("AtlasUI", "dll", + { -- src + "ActorEditor", + "ArchiveViewer", + "ColourTester", + "CustomControls/Buttons", + "CustomControls/DraggableListCtrl", + "CustomControls/EditableListCtrl", + "CustomControls/FileHistory", + "CustomControls/HighResTimer", + "CustomControls/SnapSplitterWindow", + "CustomControls/VirtualDirTreeCtrl", + "CustomControls/Windows", + "FileConverter", + "General", + "Misc", + "ScenarioEditor", + "ScenarioEditor/Sections/Common", + "ScenarioEditor/Sections/Environment", + "ScenarioEditor/Sections/Map", + "ScenarioEditor/Sections/Object", + "ScenarioEditor/Sections/Terrain", + "ScenarioEditor/Tools", + "ScenarioEditor/Tools/Common" + },{ -- include + "..", + "CustomControls" + },{ -- extern_libs "boost", "devil", "xerces" - },{ - -- flags + },{ -- flags pch = 1, wx = 1, depends = { "AtlasObject", "DatafileIO" }, - extrasource = { "/Misc/atlas.rc" } + extrasource = { "Misc/atlas.rc" } }) - setuppackage_atlas("DatafileIO", "lib", { - -- src + setuppackage_atlas("DatafileIO", "lib", + { -- src "", - "/BAR", - "/DDT", - "/SCN", - "/Stream", - "/XMB" - },{ - -- include - "" - },{ - -- extern_libs + "BAR", + "DDT", + "SCN", + "Stream", + "XMB" + },{ -- include + },{ -- extern_libs "devil", "xerces", "zlib" - },{ - -- flags + },{ -- flags pch = 1, }) diff --git a/build/premake/src/Src/vs.c b/build/premake/src/Src/vs.c index ba7415fd7b..974326eace 100644 --- a/build/premake/src/Src/vs.c +++ b/build/premake/src/Src/vs.c @@ -525,6 +525,9 @@ int vs_write_cpp() if (prj_has_flag("no-import-lib")) tag_attr("IgnoreImportLibrary=\"%s\"", S_TRUE); + if (prj_has_flag("use-library-dep-inputs") && version >= VS2005) + tag_attr("UseLibraryDependencyInputs=\"%s\"", S_TRUE); + if (prj_get_numlinkoptions() > 0) { tag_attr_open("AdditionalOptions"); diff --git a/source/ps/GameSetup/Atlas.cpp b/source/ps/GameSetup/Atlas.cpp index 3cf521d9e8..2f2957ef30 100644 --- a/source/ps/GameSetup/Atlas.cpp +++ b/source/ps/GameSetup/Atlas.cpp @@ -36,7 +36,7 @@ static bool ATLAS_IsAvailable() // we need to go with the debug version in debug builds. // note: on Windows, the extension is replaced with .dll by dlopen. #ifndef NDEBUG - const char* so_name = "AtlasUI_d.so"; + const char* so_name = "AtlasUI_dbg.so"; #else const char* so_name = "AtlasUI.so"; #endif diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp index 91db64b834..2131b8e5f2 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp @@ -436,7 +436,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent) #ifndef UI_ONLY POST_MESSAGE(SetContext, (canvas->GetContext())); - POST_MESSAGE(CommandString, ("init")); + POST_MESSAGE(Init, ()); canvas->InitSize(); @@ -444,7 +444,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent) // a valid map loaded) POST_MESSAGE(GenerateMap, (9)); - POST_MESSAGE(CommandString, ("render_enable")); + POST_MESSAGE(RenderEnable, (true)); #endif // Set up a timer to make sure tool-updates happen frequently (in addition @@ -460,7 +460,7 @@ void ScenarioEditor::OnClose(wxCloseEvent&) SetCurrentTool(_T("")); #ifndef UI_ONLY - POST_MESSAGE(CommandString, ("shutdown")); + POST_MESSAGE(Shutdown, ()); #endif AtlasMessage::qExit().Post(); diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp index 70a099e43a..b5ab1d2cc1 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp @@ -7,6 +7,7 @@ #include "Sections/Map/Map.h" #include "Sections/Terrain/Terrain.h" #include "Sections/Object/Object.h" +#include "Sections/Environment/Environment.h" ////////////////////////////////////////////////////////////////////////// @@ -119,6 +120,7 @@ void SectionLayout::Build() ADD_SIDEBAR(MapSidebar, "Map"); ADD_SIDEBAR(TerrainSidebar, "Terrain"); ADD_SIDEBAR(ObjectSidebar, "Object"); + ADD_SIDEBAR(EnvironmentSidebar, "Env."); #undef ADD_SIDEBAR diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp new file mode 100644 index 0000000000..0d3732d568 --- /dev/null +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp @@ -0,0 +1,68 @@ +#include "stdafx.h" + +#include "Environment.h" + +#include "GameInterface/Messages.h" +#include "ScenarioEditor/Tools/Common/Tools.h" + +static AtlasMessage::sEnvironmentSettings g_EnvironmentSettings; + +class VariableSlider : public wxSlider +{ +public: + VariableSlider(wxWindow* parent, float& var, float min, float max) + : wxSlider(parent, -1, 0, 0, 1024), + m_Var(var), m_Min(min), m_Max(max) + { + } + + void OnScroll(wxScrollEvent& evt) + { + m_Var = m_Min + (m_Max - m_Min)*(evt.GetInt() / 1024.f); + POST_COMMAND(SetEnvironmentSettings, (g_EnvironmentSettings)); + } + +private: + float& m_Var; + float m_Min, m_Max; + + DECLARE_EVENT_TABLE(); +}; + +BEGIN_EVENT_TABLE(VariableSlider, wxSlider) + EVT_SCROLL(OnScroll) +END_EVENT_TABLE() + +class VariableSliderBox : public wxStaticBoxSizer +{ +public: + VariableSliderBox(wxWindow* parent, const wxString& label, float& var, float min, float max) + : wxStaticBoxSizer(wxVERTICAL, parent, label) + { + Add(new VariableSlider(parent, var, min, max)); + } +}; + +////////////////////////////////////////////////////////////////////////// + +EnvironmentSidebar::EnvironmentSidebar(wxWindow* sidebarContainer, wxWindow* bottomBarContainer) +: Sidebar(sidebarContainer, bottomBarContainer) +{ + wxStaticText* warning = new wxStaticText(this, -1, _("WARNING: None of these settings are saved with the map, so don't do anything serious with them.")); + warning->Wrap(180); + m_MainSizer->Add(warning, wxSizerFlags().Border()); + m_MainSizer->Add(new VariableSliderBox(this, _("Water height"), g_EnvironmentSettings.waterheight, 0, 1.2f)); + m_MainSizer->Add(new VariableSliderBox(this, _("Water shininess"), g_EnvironmentSettings.watershininess, 0, 500.f)); + m_MainSizer->Add(new VariableSliderBox(this, _("Water waviness"), g_EnvironmentSettings.waterwaviness, 0, 10.f)); + m_MainSizer->Add(new VariableSliderBox(this, _("Sun rotation"), g_EnvironmentSettings.sunrotation, 0, 2*M_PI)); + m_MainSizer->Add(new VariableSliderBox(this, _("Sun elevation"), g_EnvironmentSettings.sunelevation, -M_PI/2, M_PI/2)); +} + +void EnvironmentSidebar::OnFirstDisplay() +{ + AtlasMessage::qGetEnvironmentSettings qry; + qry.Post(); + g_EnvironmentSettings = qry.settings; + + // TODO: set defaults of controls +} diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.h b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.h new file mode 100644 index 0000000000..7930828f74 --- /dev/null +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.h @@ -0,0 +1,10 @@ +#include "../Common/Sidebar.h" + +class EnvironmentSidebar : public Sidebar +{ +public: + EnvironmentSidebar(wxWindow* sidebarContainer, wxWindow* bottomBarContainer); + +protected: + virtual void OnFirstDisplay(); +}; diff --git a/source/tools/atlas/GameInterface/CommandProc.h b/source/tools/atlas/GameInterface/CommandProc.h index 7622cd3927..0f254f0496 100644 --- a/source/tools/atlas/GameInterface/CommandProc.h +++ b/source/tools/atlas/GameInterface/CommandProc.h @@ -51,9 +51,9 @@ struct DataCommand : public Command // so commands can optionally override (De|C { void Destruct() {}; void Construct() {}; - // MergeWithSelf should be overridden by commands, and implemented + // MergeIntoPrevious should be overridden by commands, and implemented // to update 'prev' to include the effects of 'this' - void MergeWithSelf(void*) { debug_warn("MergeWithSelf unimplemented in some command"); } + void MergeIntoPrevious(void*) { debug_warn("MergeIntoPrevious unimplemented in some command"); } }; #define BEGIN_COMMAND(t) \ @@ -64,16 +64,12 @@ struct DataCommand : public Command // so commands can optionally override (De|C c##t(d##t* data) : msg(data) { Construct(); } \ ~c##t() { Destruct(); AtlasMessage::ShareableDelete(msg); /* msg was allocated by mDoCommand() */ } \ static Command* Create(const void* data) { return new c##t ((d##t*)data); } \ - virtual void Merge(Command* prev) { MergeWithSelf((c##t*)prev); } \ + virtual void Merge(Command* prev) { MergeIntoPrevious((c##t*)prev); } \ virtual const char* GetType() const { return #t; } #define END_COMMAND(t) \ }; \ - namespace register_command_##t { \ - struct init { init() { \ - bool notAlreadyRegisted = GetCmdHandlers().insert(std::pair("c"#t, &c##t ::Create)).second; \ - debug_assert(notAlreadyRegisted); \ - } } init; \ - }; - + cmdHandler c##t##__create() { \ + return &c##t ::Create; \ + } } diff --git a/source/tools/atlas/GameInterface/GameLoop.cpp b/source/tools/atlas/GameInterface/GameLoop.cpp index a9610cdf6a..fa26d68f8f 100644 --- a/source/tools/atlas/GameInterface/GameLoop.cpp +++ b/source/tools/atlas/GameInterface/GameLoop.cpp @@ -27,6 +27,7 @@ using namespace AtlasMessage; namespace AtlasMessage { extern void AtlasRenderSelection(); + extern void RegisterHandlers(); } void AtlasRender() @@ -85,6 +86,9 @@ bool BeginAtlas(int argc, char* argv[], void* dll) // Pass our message handler to Atlas Atlas_SetMessagePasser(&msgPasser); + // Register all the handlers for message which might be passed back + RegisterHandlers(); + // Create a new thread, and launch the Atlas window inside that thread pthread_t gameThread; pthread_create(&gameThread, NULL, LaunchWindow, NULL); @@ -132,20 +136,6 @@ bool BeginAtlas(int argc, char* argv[], void* dll) std::string name (msg->GetName()); - if (name == "CommandString") - { - // Allow some laziness: For commands that don't need any data other - // than their name, we just use CommandString (and then need to - // construct a reference to the appropriate handler for the - // given string) - name += "_"; - name += *static_cast(msg)->name; - // use 'static_cast' when casting messages, to make it clear - // that something slightly dangerous is happening - we have - // to just assume that GetName is correct, since we can't use - // proper RTTI. - } - msgHandlers::const_iterator it = GetMsgHandlers().find(name); if (it != GetMsgHandlers().end()) { diff --git a/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp index b965e144bc..cd2d493298 100644 --- a/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp @@ -137,7 +137,7 @@ BEGIN_COMMAND(AlterElevation) g_EntityManager.invalidateAll(); } - void MergeWithSelf(cAlterElevation* prev) + void MergeIntoPrevious(cAlterElevation* prev) { prev->m_TerrainDelta.OverlayWith(m_TerrainDelta); } @@ -199,7 +199,7 @@ BEGIN_COMMAND(FlattenElevation) g_EntityManager.invalidateAll(); } - void MergeWithSelf(cFlattenElevation* prev) + void MergeIntoPrevious(cFlattenElevation* prev) { prev->m_TerrainDelta.OverlayWith(m_TerrainDelta); } diff --git a/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp new file mode 100644 index 0000000000..e22c9f8fb5 --- /dev/null +++ b/source/tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp @@ -0,0 +1,73 @@ +#include "precompiled.h" + +#include "MessageHandler.h" + +#include "../CommandProc.h" + +#include "renderer/Renderer.h" +#include "renderer/WaterManager.h" +#include "ps/World.h" +#include "graphics/LightEnv.h" + +namespace AtlasMessage { + +sEnvironmentSettings GetSettings() +{ + sEnvironmentSettings s; + + WaterManager* wm = g_Renderer.GetWaterManager(); + s.waterheight = wm->m_WaterHeight / (65536.f * HEIGHT_SCALE); + s.watershininess = wm->m_Shininess; + s.waterwaviness = wm->m_Waviness; + + s.sunrotation = g_LightEnv.GetRotation(); + s.sunelevation = g_LightEnv.GetElevation(); + + return s; +} + +void SetSettings(const sEnvironmentSettings& s) +{ + WaterManager* wm = g_Renderer.GetWaterManager(); + wm->m_WaterHeight = s.waterheight * (65536.f * HEIGHT_SCALE); + wm->m_Shininess = s.watershininess; + wm->m_Waviness = s.waterwaviness; + + g_LightEnv.SetRotation(s.sunrotation); + g_LightEnv.SetElevation(s.sunelevation); +} + +BEGIN_COMMAND(SetEnvironmentSettings) + + sEnvironmentSettings m_OldSettings, m_NewSettings; + + void Do() + { + m_OldSettings = GetSettings(); + m_NewSettings = msg->settings; + Redo(); + } + + void Redo() + { + SetSettings(m_NewSettings); + } + + void Undo() + { + SetSettings(m_OldSettings); + } + + void MergeIntoPrevious(cSetEnvironmentSettings* prev) + { + prev->m_NewSettings = m_NewSettings; + } + +END_COMMAND(SetEnvironmentSettings) + +QUERYHANDLER(GetEnvironmentSettings) +{ + msg->settings = GetSettings(); +} + +} diff --git a/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp index 747da885ac..08c72d9865 100644 --- a/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp @@ -18,8 +18,10 @@ namespace AtlasMessage { -MESSAGEHANDLER_STR(init) +MESSAGEHANDLER(Init) { + UNUSED2(msg); + oglInit(); g_Quickstart = true; @@ -34,8 +36,10 @@ MESSAGEHANDLER_STR(init) } -MESSAGEHANDLER_STR(shutdown) +MESSAGEHANDLER(Shutdown) { + UNUSED2(msg); + // Empty the CommandProc, to get rid of its references to entities before // we kill the EntityManager GetCommandProc().Destroy(); @@ -53,15 +57,9 @@ QUERYHANDLER(Exit) } -MESSAGEHANDLER_STR(render_enable) +MESSAGEHANDLER(RenderEnable) { - g_GameLoop->rendering = true; -} - - -MESSAGEHANDLER_STR(render_disable) -{ - g_GameLoop->rendering = false; + g_GameLoop->rendering = msg->enabled; } ////////////////////////////////////////////////////////////////////////// diff --git a/source/tools/atlas/GameInterface/Handlers/MessageHandler.h b/source/tools/atlas/GameInterface/Handlers/MessageHandler.h index b239e9ff52..c43ae09110 100644 --- a/source/tools/atlas/GameInterface/Handlers/MessageHandler.h +++ b/source/tools/atlas/GameInterface/Handlers/MessageHandler.h @@ -6,45 +6,19 @@ namespace AtlasMessage { -// (Random note: Be careful not to give handler .cpp files the same name -// as any other file in the project, because it makes everything very confused) - -// TODO: measure how long this static initialisation stuff takes, and if it's -// non-negligible then make it do as little work as possible if Atlas is not run - typedef void (*msgHandler)(IMessage*); typedef std::map msgHandlers; extern msgHandlers& GetMsgHandlers(); #define THINGHANDLER(prefix, expectedtype, t) \ void f##t(prefix##t*); \ - namespace register_handler_##t { \ - void wrapper(IMessage* msg) { \ - debug_assert(msg->GetType() == IMessage::expectedtype); \ - f##t (static_cast(msg)); \ - } \ - struct init { init() { \ - bool notAlreadyRegisted = GetMsgHandlers().insert(std::pair(#t, &wrapper)).second; \ - debug_assert(notAlreadyRegisted); \ - } } init; \ - }; \ + void f##t##__wrapper(IMessage* msg) { \ + debug_assert(msg->GetType() == IMessage::expectedtype); \ + f##t (static_cast(msg)); \ + } \ void f##t(prefix##t* msg) #define MESSAGEHANDLER(t) THINGHANDLER(m, Message, t) #define QUERYHANDLER(t) THINGHANDLER(q, Query, t) -#define MESSAGEHANDLER_STR(t) \ - void fCommandString_##t(); \ - namespace register_handler_##t { \ - void wrapper(IMessage* msg) { \ - debug_assert(msg->GetType() == IMessage::Message); \ - fCommandString_##t (); \ - } \ - struct init { init() { \ - bool notAlreadyRegisted = GetMsgHandlers().insert(std::pair("CommandString_"#t, &wrapper)).second; \ - debug_assert(notAlreadyRegisted); \ - } } init; \ - }; \ - void fCommandString_##t() - } diff --git a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp index 8fe09a55a0..dccff3806d 100644 --- a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp @@ -519,7 +519,7 @@ BEGIN_COMMAND(MoveObject) SetPos(m_PosOld); } - void MergeWithSelf(cMoveObject* prev) + void MergeIntoPrevious(cMoveObject* prev) { // TODO: do something valid if prev unit != this unit debug_assert(prev->msg->id == msg->id); @@ -611,7 +611,7 @@ BEGIN_COMMAND(RotateObject) SetAngle(m_AngleOld, m_TransformOld); } - void MergeWithSelf(cRotateObject* prev) + void MergeIntoPrevious(cRotateObject* prev) { // TODO: do something valid if prev unit != this unit debug_assert(prev->msg->id == msg->id); diff --git a/source/tools/atlas/GameInterface/Handlers/TerrainHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/TerrainHandlers.cpp index 802f591be2..c474720c47 100644 --- a/source/tools/atlas/GameInterface/Handlers/TerrainHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/TerrainHandlers.cpp @@ -200,7 +200,7 @@ BEGIN_COMMAND(PaintTerrain) g_Game->GetWorld()->GetTerrain()->MakeDirty(RENDERDATA_UPDATE_INDICES); } - void MergeWithSelf(cPaintTerrain* prev) + void MergeIntoPrevious(cPaintTerrain* prev) { prev->m_TerrainDelta.OverlayWith(m_TerrainDelta); } diff --git a/source/tools/atlas/GameInterface/Messages.h b/source/tools/atlas/GameInterface/Messages.h index 6995151131..55e04ba298 100644 --- a/source/tools/atlas/GameInterface/Messages.h +++ b/source/tools/atlas/GameInterface/Messages.h @@ -1,15 +1,20 @@ #ifndef MESSAGES_H__ #define MESSAGES_H__ +#ifndef MESSAGES_SKIP_SETUP #include "MessagesSetup.h" +#endif // TODO: organisation, documentation, etc ////////////////////////////////////////////////////////////////////////// -MESSAGE(CommandString, - ((std::string, name)) - ); +MESSAGE(Init, ); + +MESSAGE(Shutdown, ); + +MESSAGE(RenderEnable, + ((bool, enabled))); ////////////////////////////////////////////////////////////////////////// @@ -163,6 +168,30 @@ MESSAGE(RotateAround, ((Position, pos)) ); +////////////////////////////////////////////////////////////////////////// + +struct sEnvironmentSettings +{ + float waterheight; // range 0..1 corresponds to min..max terrain height; out-of-bounds values allowed + float watershininess; + float waterwaviness; + + float sunrotation; // range 0..2pi + float sunelevation; // range -pi/2 .. +pi/2 + +}; +SHAREABLE_STRUCT(sEnvironmentSettings); + +QUERY(GetEnvironmentSettings, + // no inputs + , + ((sEnvironmentSettings, settings)) + ); + +COMMAND(SetEnvironmentSettings, MERGE, + ((sEnvironmentSettings, settings)) + ); + ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// @@ -186,7 +215,9 @@ COMMAND(PaintTerrain, MERGE, ////////////////////////////////////////////////////////////////////////// typedef int ObjectID; +FUNCTION( inline bool ObjectIDIsValid(ObjectID id) { return (id >= 0); } +); QUERY(PickObject, ((Position, pos)) @@ -230,6 +261,8 @@ COMMAND(SetObjectSettings, NOMERGE, ////////////////////////////////////////////////////////////////////////// +#ifndef MESSAGES_SKIP_SETUP #include "MessagesSetup.h" +#endif #endif // MESSAGES_H__ diff --git a/source/tools/atlas/GameInterface/MessagesSetup.h b/source/tools/atlas/GameInterface/MessagesSetup.h index b0cdc17648..7216d0cf72 100644 --- a/source/tools/atlas/GameInterface/MessagesSetup.h +++ b/source/tools/atlas/GameInterface/MessagesSetup.h @@ -112,13 +112,27 @@ const bool NOMERGE = false; } */ -#define MESSAGE(name, vals) \ +#define MESSAGE_WITH_INPUTS(name, vals) \ MESSAGESTRUCT(name) \ m##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, vals) ) \ : BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORINIT, ~, vals) {} \ BOOST_PP_SEQ_FOR_EACH_I(B_CONSTMEMBERS, ~, vals) \ }; +#define MESSAGE_WITHOUT_INPUTS(name, vals) \ + MESSAGESTRUCT(name) \ + m##name() {} \ + }; + +#define MESSAGE(name, vals) \ + BOOST_PP_IIF( \ + BOOST_PP_EQUAL(BOOST_PP_SEQ_SIZE((~)vals), 1), \ + MESSAGE_WITHOUT_INPUTS, \ + MESSAGE_WITH_INPUTS) \ + (name, vals) + + + #define COMMAND(name, merge, vals) \ COMMANDDATASTRUCT(name) \ d##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, vals) ) \ @@ -151,6 +165,7 @@ const bool NOMERGE = false; QUERY_WITH_INPUTS) \ (name, in_vals, out_vals) +#define FUNCTION(def) def ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// @@ -172,6 +187,7 @@ const bool NOMERGE = false; #undef QUERY_WITHOUT_INPUTS #undef QUERY_WITH_INPUTS #undef QUERY +#undef FUNCTION } diff --git a/source/tools/atlas/GameInterface/Register.cpp b/source/tools/atlas/GameInterface/Register.cpp new file mode 100644 index 0000000000..4a592cdb6e --- /dev/null +++ b/source/tools/atlas/GameInterface/Register.cpp @@ -0,0 +1,51 @@ +#include "precompiled.h" + +#include "SharedTypes.h" +#include "Shareable.h" + +namespace AtlasMessage +{ + +struct IMessage; + +typedef void (*msgHandler)(IMessage*); +typedef std::map msgHandlers; +extern msgHandlers& GetMsgHandlers(); + +struct Command; +typedef Command* (*cmdHandler)(const void*); +typedef std::map cmdHandlers; +extern cmdHandlers& GetCmdHandlers(); + +#define MESSAGE(name, vals) \ + extern void f##name##__wrapper(AtlasMessage::IMessage*); \ + AtlasMessage::GetMsgHandlers().insert(std::pair(#name, &f##name##__wrapper)); + +#define QUERY(name, in_vals, out_vals) \ + extern void f##name##__wrapper(AtlasMessage::IMessage*); \ + AtlasMessage::GetMsgHandlers().insert(std::pair(#name, &f##name##__wrapper)); + +#define COMMAND(name, merge, vals) \ + extern cmdHandler c##name##__create(); \ + GetCmdHandlers().insert(std::pair("c"#name, c##name##__create())); + +#define FUNCTION(def) + +#undef SHAREABLE_STRUCT +#define SHAREABLE_STRUCT(name) + + + +void RegisterHandlers() +{ + MESSAGE(DoCommand, ); + MESSAGE(UndoCommand, ); + MESSAGE(RedoCommand, ); + MESSAGE(MergeCommand, ); + + #define MESSAGES_SKIP_SETUP + #include "Messages.h" +} + +} +