forked from 0ad/0ad
Renamed autobuilt ps.exe to pyrogenesis.exe, to match the new project layout.
Fixed Atlas project creation. Improved VS2005 linking speed. Added work-in-progress environment (water, sun) editing to Atlas. This was SVN commit r3935.
This commit is contained in:
parent
1036d9944d
commit
54c1508db6
@ -1 +1 @@
|
||||
ps -editor
|
||||
pyrogenesis.exe -editor
|
@ -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"
|
||||
"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"
|
@ -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
|
||||
|
Binary file not shown.
@ -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,
|
||||
})
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#include "../Common/Sidebar.h"
|
||||
|
||||
class EnvironmentSidebar : public Sidebar
|
||||
{
|
||||
public:
|
||||
EnvironmentSidebar(wxWindow* sidebarContainer, wxWindow* bottomBarContainer);
|
||||
|
||||
protected:
|
||||
virtual void OnFirstDisplay();
|
||||
};
|
@ -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<std::string, cmdHandler>("c"#t, &c##t ::Create)).second; \
|
||||
debug_assert(notAlreadyRegisted); \
|
||||
} } init; \
|
||||
};
|
||||
|
||||
cmdHandler c##t##__create() { \
|
||||
return &c##t ::Create; \
|
||||
}
|
||||
}
|
||||
|
@ -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<mCommandString*>(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())
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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<std::string, msgHandler> 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<prefix##t*>(msg)); \
|
||||
} \
|
||||
struct init { init() { \
|
||||
bool notAlreadyRegisted = GetMsgHandlers().insert(std::pair<std::string, msgHandler>(#t, &wrapper)).second; \
|
||||
debug_assert(notAlreadyRegisted); \
|
||||
} } init; \
|
||||
}; \
|
||||
void f##t##__wrapper(IMessage* msg) { \
|
||||
debug_assert(msg->GetType() == IMessage::expectedtype); \
|
||||
f##t (static_cast<prefix##t*>(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<std::string, msgHandler>("CommandString_"#t, &wrapper)).second; \
|
||||
debug_assert(notAlreadyRegisted); \
|
||||
} } init; \
|
||||
}; \
|
||||
void fCommandString_##t()
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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__
|
||||
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
51
source/tools/atlas/GameInterface/Register.cpp
Normal file
51
source/tools/atlas/GameInterface/Register.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "SharedTypes.h"
|
||||
#include "Shareable.h"
|
||||
|
||||
namespace AtlasMessage
|
||||
{
|
||||
|
||||
struct IMessage;
|
||||
|
||||
typedef void (*msgHandler)(IMessage*);
|
||||
typedef std::map<std::string, msgHandler> msgHandlers;
|
||||
extern msgHandlers& GetMsgHandlers();
|
||||
|
||||
struct Command;
|
||||
typedef Command* (*cmdHandler)(const void*);
|
||||
typedef std::map<std::string, cmdHandler> cmdHandlers;
|
||||
extern cmdHandlers& GetCmdHandlers();
|
||||
|
||||
#define MESSAGE(name, vals) \
|
||||
extern void f##name##__wrapper(AtlasMessage::IMessage*); \
|
||||
AtlasMessage::GetMsgHandlers().insert(std::pair<std::string, AtlasMessage::msgHandler>(#name, &f##name##__wrapper));
|
||||
|
||||
#define QUERY(name, in_vals, out_vals) \
|
||||
extern void f##name##__wrapper(AtlasMessage::IMessage*); \
|
||||
AtlasMessage::GetMsgHandlers().insert(std::pair<std::string, AtlasMessage::msgHandler>(#name, &f##name##__wrapper));
|
||||
|
||||
#define COMMAND(name, merge, vals) \
|
||||
extern cmdHandler c##name##__create(); \
|
||||
GetCmdHandlers().insert(std::pair<std::string, cmdHandler>("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"
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user