1
0
forked from mirrors/0ad

This was SVN commit r9609.

This commit is contained in:
historic_bruno
2011-06-09 23:47:20 +00:00
parent 23f1072a2e
commit 0c803f99e8
8 changed files with 61 additions and 7 deletions
+1
View File
@@ -823,6 +823,7 @@ function setup_atlas_packages()
"ScenarioEditor/Sections/Environment",
"ScenarioEditor/Sections/Map",
"ScenarioEditor/Sections/Object",
"ScenarioEditor/Sections/Player",
"ScenarioEditor/Sections/Terrain",
"ScenarioEditor/Sections/Trigger",
"ScenarioEditor/Tools",
+9 -3
View File
@@ -848,6 +848,9 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
{
XMBElementList entities = parent.GetChildNodes();
CSimulation2& sim = *m_MapReader.pSimulation2;
CmpPtr<ICmpPlayerManager> cmpPlayerManager(sim.GetSimContext(), SYSTEM_ENTITY);
while (entity_idx < entities.Count)
{
// all new state at this scope and below doesn't need to be
@@ -903,12 +906,15 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
debug_warn(L"Invalid map XML data");
}
CSimulation2& sim = *m_MapReader.pSimulation2;
entity_id_t ent = sim.AddEntity(TemplateName, EntityUid);
if (ent == INVALID_ENTITY)
LOGERROR(L"Failed to load entity template '%ls'", TemplateName.c_str());
else
{
LOGERROR(L"Failed to load entity template '%ls'", TemplateName.c_str());
}
else if (cmpPlayerManager->GetPlayerByID(PlayerID) != INVALID_ENTITY)
{ // Don't add entities with invalid player IDs
// TODO: Is a warning OK or should it just silently fail?
CmpPtr<ICmpPosition> cmpPosition(sim, ent);
if (!cmpPosition.null())
{
+9 -1
View File
@@ -592,8 +592,16 @@ std::vector<std::string> CSimulation2::GetCivData()
std::string CSimulation2::GetPlayerDefaults()
{
VfsPath path = VfsPath(L"simulation/data/player_defaults.json");
return ReadJSON(L"simulation/data/player_defaults.json");
}
std::string CSimulation2::GetMapSizes()
{
return ReadJSON(L"simulation/data/map_sizes.json");
}
std::string CSimulation2::ReadJSON(VfsPath path)
{
std::string data;
if (!VfsFileExists(path))
+10
View File
@@ -226,9 +226,19 @@ public:
*/
std::string GetPlayerDefaults();
/**
* Get map sizes data
*
* @return string containing JSON format data
*/
std::string GetMapSizes();
private:
CSimulation2Impl* m;
// Helper for reading JSON files
std::string ReadJSON(VfsPath path);
NONCOPYABLE(CSimulation2);
};
@@ -64,6 +64,7 @@ public:
ScriptInterface& GetScriptInterface() const { return m_ScriptInterface; }
Observable<ObjectSettings>& GetObjectSettings() { return m_ObjectSettings; }
Observable<AtObj>& GetMapSettings() { return m_MapSettings; }
ToolManager& GetToolManager() { return m_ToolManager; }
@@ -77,6 +78,7 @@ private:
SectionLayout m_SectionLayout;
Observable<ObjectSettings> m_ObjectSettings;
Observable<AtObj> m_MapSettings;
void SetOpenFilename(const wxString& filename);
wxString m_OpenFilename;
@@ -31,6 +31,7 @@
#include "Sections/Cinematic/Cinematic.h"
#include "Sections/Map/Map.h"
#include "Sections/Object/Object.h"
#include "Sections/Player/Player.h"
#include "Sections/Terrain/Terrain.h"
#include "Sections/Trigger/Trigger.h"
@@ -288,6 +289,7 @@ void SectionLayout::Build(ScenarioEditor& scenarioEditor)
m_PageMappings.insert(std::make_pair(L###classname, (int)m_SidebarBook->GetPageCount()-1));
ADD_SIDEBAR(MapSidebar, _T("map.png"), _("Map"));
ADD_SIDEBAR(PlayerSidebar, _T("player.png"), _("Player"));
ADD_SIDEBAR(TerrainSidebar, _T("terrain.png"), _("Terrain"));
ADD_SIDEBAR(ObjectSidebar, _T("object.png"), _("Object"));
ADD_SIDEBAR(EnvironmentSidebar, _T("environment.png"), _("Environment"));
@@ -139,11 +139,31 @@ QUERYHANDLER(GetMapSettings)
msg->settings = g_Game->GetSimulation2()->GetMapSettingsString();
}
MESSAGEHANDLER(SetMapSettings)
QUERYHANDLER(GetMapSizes)
{
g_Game->GetSimulation2()->SetMapSettings(*msg->settings);
msg->sizes = g_Game->GetSimulation2()->GetMapSizes();
}
BEGIN_COMMAND(SetMapSettings)
{
void Do()
{
Redo();
}
void Undo()
{
// TODO
debug_warn(L"Can't undo SetMapSettings");
}
void Redo()
{
g_Game->GetSimulation2()->SetMapSettings(*msg->settings);
}
};
END_COMMAND(SetMapSettings)
QUERYHANDLER(GetRMSData)
{
msg->data = g_Game->GetSimulation2()->GetRMSData();
+6 -1
View File
@@ -152,7 +152,12 @@ QUERY(GetMapSettings,
((std::string, settings))
);
MESSAGE(SetMapSettings,
QUERY(GetMapSizes,
,
((std::string, sizes))
);
COMMAND(SetMapSettings, NOMERGE,
((std::string, settings))
);