Set svn:eol-style=native
This was SVN commit r6909.
This commit is contained in:
parent
bc78e877be
commit
43ba574b85
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,87 +1,87 @@
|
||||
/* Desc: interface for creation and editing of triggers. Interprets
|
||||
XML specifications then uses this to construct layout.
|
||||
*/
|
||||
|
||||
#include "../Common/Sidebar.h"
|
||||
#include "GameInterface/Messages.h"
|
||||
|
||||
class TriggerItemData;
|
||||
class TriggerTreeCtrl;
|
||||
class TriggerBottomBar;
|
||||
class TriggerPage;
|
||||
class wxTreeItemId;
|
||||
class wxTreeItemData;
|
||||
class wxTreeEvent;
|
||||
class wxListEvent;
|
||||
class wxNotebook;
|
||||
class wxNotebookEvent;
|
||||
class wxTreeEvent;
|
||||
class wxListEvent;
|
||||
|
||||
class TriggerSidebar : public Sidebar
|
||||
{
|
||||
public:
|
||||
enum { ID_CondList, ID_EffectList };
|
||||
|
||||
TriggerSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer);
|
||||
|
||||
void onTreeDrag(wxTreeEvent& evt);
|
||||
void onTreeNameChange(wxTreeEvent& evt);
|
||||
//void onTreeDelete(wxTreeEvent& evt);
|
||||
void onTreeSelChange(wxTreeEvent& evt);
|
||||
void onTreeCollapse(wxTreeEvent& evt);
|
||||
void onListSelect(wxListEvent& evt);
|
||||
void onEffectSelect(wxListEvent& evt);
|
||||
void onCondSelect(wxListEvent& evt);
|
||||
void onPageChange(wxNotebookEvent& evt);
|
||||
|
||||
bool IsGroupSelected();
|
||||
TriggerItemData* ToDerived(wxTreeItemData* data);
|
||||
TriggerItemData* GetSelectedItemData();
|
||||
|
||||
//Finds condition number (index+1) of m_SelectedCond [needed because of logic blocks]
|
||||
int GetConditionCount(int limit);
|
||||
int GetLogicBlockCount(int limit);
|
||||
void UpdateLists();
|
||||
void UpdateEngineData();
|
||||
|
||||
//AtlasMessage::sTriggerList m_TriggerList;
|
||||
|
||||
TriggerBottomBar* m_TriggerBottom;
|
||||
TriggerTreeCtrl* m_TriggerTree;
|
||||
TriggerPage* m_ConditionPage, *m_EffectPage;
|
||||
wxNotebook* m_Notebook;
|
||||
|
||||
size_t m_TriggerCount, m_GroupCount;
|
||||
long m_SelectedCond, m_SelectedEffect, m_SelectedCondIndex, m_SelectedEffectIndex;
|
||||
wxString m_LogicBlockString, m_LogicBlockEndString;
|
||||
|
||||
protected:
|
||||
virtual void OnFirstDisplay();
|
||||
|
||||
private:
|
||||
struct copyIfRootChild
|
||||
{
|
||||
copyIfRootChild(std::vector<AtlasMessage::sTriggerGroup>& groupList) : m_groupList(groupList) {}
|
||||
void operator() ( const AtlasMessage::sTriggerGroup& group )
|
||||
{
|
||||
if ( *group.parentName == std::wstring(L"Triggers") )
|
||||
m_groupList.push_back(group);
|
||||
}
|
||||
private:
|
||||
std::vector<AtlasMessage::sTriggerGroup>& m_groupList;
|
||||
};
|
||||
|
||||
void AddGroupTree(const AtlasMessage::sTriggerGroup& group, wxTreeItemId parent);
|
||||
|
||||
void CreateGroup(std::vector<AtlasMessage::sTriggerGroup>& groupList,
|
||||
AtlasMessage::sTriggerGroup& parent, wxTreeItemId index);
|
||||
|
||||
AtlasMessage::sTrigger CreateTrigger(TriggerItemData* data);
|
||||
|
||||
std::vector<AtlasMessage::sTriggerGroup> m_TriggerGroups;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
|
||||
/* Desc: interface for creation and editing of triggers. Interprets
|
||||
XML specifications then uses this to construct layout.
|
||||
*/
|
||||
|
||||
#include "../Common/Sidebar.h"
|
||||
#include "GameInterface/Messages.h"
|
||||
|
||||
class TriggerItemData;
|
||||
class TriggerTreeCtrl;
|
||||
class TriggerBottomBar;
|
||||
class TriggerPage;
|
||||
class wxTreeItemId;
|
||||
class wxTreeItemData;
|
||||
class wxTreeEvent;
|
||||
class wxListEvent;
|
||||
class wxNotebook;
|
||||
class wxNotebookEvent;
|
||||
class wxTreeEvent;
|
||||
class wxListEvent;
|
||||
|
||||
class TriggerSidebar : public Sidebar
|
||||
{
|
||||
public:
|
||||
enum { ID_CondList, ID_EffectList };
|
||||
|
||||
TriggerSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer);
|
||||
|
||||
void onTreeDrag(wxTreeEvent& evt);
|
||||
void onTreeNameChange(wxTreeEvent& evt);
|
||||
//void onTreeDelete(wxTreeEvent& evt);
|
||||
void onTreeSelChange(wxTreeEvent& evt);
|
||||
void onTreeCollapse(wxTreeEvent& evt);
|
||||
void onListSelect(wxListEvent& evt);
|
||||
void onEffectSelect(wxListEvent& evt);
|
||||
void onCondSelect(wxListEvent& evt);
|
||||
void onPageChange(wxNotebookEvent& evt);
|
||||
|
||||
bool IsGroupSelected();
|
||||
TriggerItemData* ToDerived(wxTreeItemData* data);
|
||||
TriggerItemData* GetSelectedItemData();
|
||||
|
||||
//Finds condition number (index+1) of m_SelectedCond [needed because of logic blocks]
|
||||
int GetConditionCount(int limit);
|
||||
int GetLogicBlockCount(int limit);
|
||||
void UpdateLists();
|
||||
void UpdateEngineData();
|
||||
|
||||
//AtlasMessage::sTriggerList m_TriggerList;
|
||||
|
||||
TriggerBottomBar* m_TriggerBottom;
|
||||
TriggerTreeCtrl* m_TriggerTree;
|
||||
TriggerPage* m_ConditionPage, *m_EffectPage;
|
||||
wxNotebook* m_Notebook;
|
||||
|
||||
size_t m_TriggerCount, m_GroupCount;
|
||||
long m_SelectedCond, m_SelectedEffect, m_SelectedCondIndex, m_SelectedEffectIndex;
|
||||
wxString m_LogicBlockString, m_LogicBlockEndString;
|
||||
|
||||
protected:
|
||||
virtual void OnFirstDisplay();
|
||||
|
||||
private:
|
||||
struct copyIfRootChild
|
||||
{
|
||||
copyIfRootChild(std::vector<AtlasMessage::sTriggerGroup>& groupList) : m_groupList(groupList) {}
|
||||
void operator() ( const AtlasMessage::sTriggerGroup& group )
|
||||
{
|
||||
if ( *group.parentName == std::wstring(L"Triggers") )
|
||||
m_groupList.push_back(group);
|
||||
}
|
||||
private:
|
||||
std::vector<AtlasMessage::sTriggerGroup>& m_groupList;
|
||||
};
|
||||
|
||||
void AddGroupTree(const AtlasMessage::sTriggerGroup& group, wxTreeItemId parent);
|
||||
|
||||
void CreateGroup(std::vector<AtlasMessage::sTriggerGroup>& groupList,
|
||||
AtlasMessage::sTriggerGroup& parent, wxTreeItemId index);
|
||||
|
||||
AtlasMessage::sTrigger CreateTrigger(TriggerItemData* data);
|
||||
|
||||
std::vector<AtlasMessage::sTriggerGroup> m_TriggerGroups;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,179 +1,179 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "MessageHandler.h"
|
||||
#include "../CommandProc.h"
|
||||
#include "graphics/Camera.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "ps/Game.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "maths/MathUtil.h"
|
||||
#include "maths/Quaternion.h"
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
|
||||
#define LOG_CATEGORY "Cinema"
|
||||
|
||||
namespace AtlasMessage {
|
||||
|
||||
|
||||
sCinemaPath ConstructCinemaPath(const CCinemaPath* source)
|
||||
{
|
||||
sCinemaPath path;
|
||||
const CCinemaData* data = source->GetData();
|
||||
path.mode = data->m_Mode;
|
||||
path.style = data->m_Style;
|
||||
path.growth = data->m_Growth;
|
||||
path.timescale = data->m_Timescale;
|
||||
path.change = data->m_Switch;
|
||||
|
||||
return path;
|
||||
}
|
||||
CCinemaData ConstructCinemaData(const sCinemaPath& path)
|
||||
{
|
||||
CCinemaData data;
|
||||
data.m_Growth = data.m_GrowthCount = path.growth;
|
||||
data.m_Switch = path.change;
|
||||
data.m_Mode = path.mode;
|
||||
data.m_Style = path.style;
|
||||
|
||||
return data;
|
||||
}
|
||||
sCinemaSplineNode ConstructCinemaNode(const SplineData& data)
|
||||
{
|
||||
sCinemaSplineNode node;
|
||||
node.px = data.Position.X;
|
||||
node.py = data.Position.Y;
|
||||
node.pz = data.Position.Z;
|
||||
|
||||
node.rx = data.Rotation.X;
|
||||
node.ry = data.Rotation.Y;
|
||||
node.rz = data.Rotation.Z;
|
||||
node.t = data.Distance;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
std::vector<sCinemaPath> GetCurrentPaths()
|
||||
{
|
||||
const std::map<CStrW, CCinemaPath>& paths = g_Game->GetView()->GetCinema()->GetAllPaths();
|
||||
std::vector<sCinemaPath> atlasPaths;
|
||||
|
||||
for ( std::map<CStrW, CCinemaPath>::const_iterator it=paths.begin(); it!=paths.end(); it++ )
|
||||
{
|
||||
sCinemaPath path = ConstructCinemaPath(&it->second);
|
||||
path.name = it->first;
|
||||
|
||||
const std::vector<SplineData>& nodes = it->second.GetAllNodes();
|
||||
std::vector<sCinemaSplineNode> atlasNodes;
|
||||
|
||||
for ( size_t i=0; i<nodes.size(); ++i )
|
||||
atlasNodes.push_back( ConstructCinemaNode(nodes[i]) );
|
||||
|
||||
if ( !atlasNodes.empty() )
|
||||
{
|
||||
float back = atlasNodes.back().t;
|
||||
if ( atlasNodes.size() > 2 )
|
||||
{
|
||||
for ( size_t i=atlasNodes.size()-2; i>0; --i )
|
||||
atlasNodes[i].t = atlasNodes[i-1].t;
|
||||
}
|
||||
atlasNodes.back().t = atlasNodes.front().t;
|
||||
atlasNodes.front().t = back;
|
||||
}
|
||||
path.nodes = atlasNodes;
|
||||
atlasPaths.push_back(path);
|
||||
}
|
||||
return atlasPaths;
|
||||
}
|
||||
|
||||
void SetCurrentPaths(const std::vector<sCinemaPath>& atlasPaths)
|
||||
{
|
||||
std::map<CStrW, CCinemaPath> paths;
|
||||
|
||||
for ( std::vector<sCinemaPath>::const_iterator it=atlasPaths.begin(); it!=atlasPaths.end(); it++ )
|
||||
{
|
||||
CStrW pathName(*it->name);
|
||||
paths[pathName] = CCinemaPath();
|
||||
paths[pathName].SetTimescale(it->timescale);
|
||||
|
||||
const sCinemaPath& atlasPath = *it;
|
||||
const std::vector<sCinemaSplineNode> nodes = *atlasPath.nodes;
|
||||
TNSpline spline;
|
||||
CCinemaData data = ConstructCinemaData(atlasPath);
|
||||
|
||||
for ( size_t j=0; j<nodes.size(); ++j )
|
||||
{
|
||||
spline.AddNode( CVector3D(nodes[j].px, nodes[j].py, nodes[j].pz),
|
||||
CVector3D(nodes[j].rx, nodes[j].ry, nodes[j].rz), nodes[j].t );
|
||||
}
|
||||
paths[pathName] = CCinemaPath(data, spline);
|
||||
}
|
||||
|
||||
g_Game->GetView()->GetCinema()->SetAllPaths(paths);
|
||||
}
|
||||
QUERYHANDLER(GetCameraInfo)
|
||||
{
|
||||
sCameraInfo info;
|
||||
CMatrix3D* cam = &g_Game->GetView()->GetCamera()->m_Orientation;
|
||||
|
||||
CQuaternion quatRot = cam->GetRotation();
|
||||
quatRot.Normalize();
|
||||
CVector3D rotation = quatRot.ToEulerAngles();
|
||||
rotation.X = RADTODEG(rotation.X);
|
||||
rotation.Y = RADTODEG(rotation.Y);
|
||||
rotation.Z = RADTODEG(rotation.Z);
|
||||
CVector3D translation = cam->GetTranslation();
|
||||
|
||||
info.pX = translation.X;
|
||||
info.pY = translation.Y;
|
||||
info.pZ = translation.Z;
|
||||
info.rX = rotation.X;
|
||||
info.rY = rotation.Y;
|
||||
info.rZ = rotation.Z;
|
||||
msg->info = info;
|
||||
}
|
||||
|
||||
MESSAGEHANDLER(CinemaEvent)
|
||||
{
|
||||
CCinemaManager* manager = g_Game->GetView()->GetCinema();
|
||||
|
||||
if ( msg->mode == eCinemaEventMode::SMOOTH )
|
||||
manager->OverridePath(*msg->path);
|
||||
else if ( msg->mode == eCinemaEventMode::IMMEDIATE_PATH )
|
||||
manager->MoveToPointAt(msg->t);
|
||||
else if ( msg->mode == eCinemaEventMode::RESET )
|
||||
g_Game->GetView()->ResetCamera();
|
||||
else if ( msg->mode == eCinemaEventMode::SELECT )
|
||||
manager->SetCurrentPath(*msg->path, msg->drawCurrent, msg->lines);
|
||||
else
|
||||
debug_assert(false);
|
||||
}
|
||||
|
||||
BEGIN_COMMAND(SetCinemaPaths)
|
||||
{
|
||||
std::vector<sCinemaPath> m_oldPaths, m_newPaths;
|
||||
void Do()
|
||||
{
|
||||
m_oldPaths = GetCurrentPaths();
|
||||
m_newPaths = *msg->paths;
|
||||
Redo();
|
||||
}
|
||||
void Redo()
|
||||
{
|
||||
SetCurrentPaths(m_newPaths);
|
||||
}
|
||||
void Undo()
|
||||
{
|
||||
SetCurrentPaths(m_oldPaths);
|
||||
}
|
||||
};
|
||||
END_COMMAND(SetCinemaPaths)
|
||||
|
||||
QUERYHANDLER(GetCinemaPaths)
|
||||
{
|
||||
msg->paths = GetCurrentPaths();
|
||||
}
|
||||
|
||||
}
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "MessageHandler.h"
|
||||
#include "../CommandProc.h"
|
||||
#include "graphics/Camera.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "ps/Game.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "maths/MathUtil.h"
|
||||
#include "maths/Quaternion.h"
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
|
||||
#define LOG_CATEGORY "Cinema"
|
||||
|
||||
namespace AtlasMessage {
|
||||
|
||||
|
||||
sCinemaPath ConstructCinemaPath(const CCinemaPath* source)
|
||||
{
|
||||
sCinemaPath path;
|
||||
const CCinemaData* data = source->GetData();
|
||||
path.mode = data->m_Mode;
|
||||
path.style = data->m_Style;
|
||||
path.growth = data->m_Growth;
|
||||
path.timescale = data->m_Timescale;
|
||||
path.change = data->m_Switch;
|
||||
|
||||
return path;
|
||||
}
|
||||
CCinemaData ConstructCinemaData(const sCinemaPath& path)
|
||||
{
|
||||
CCinemaData data;
|
||||
data.m_Growth = data.m_GrowthCount = path.growth;
|
||||
data.m_Switch = path.change;
|
||||
data.m_Mode = path.mode;
|
||||
data.m_Style = path.style;
|
||||
|
||||
return data;
|
||||
}
|
||||
sCinemaSplineNode ConstructCinemaNode(const SplineData& data)
|
||||
{
|
||||
sCinemaSplineNode node;
|
||||
node.px = data.Position.X;
|
||||
node.py = data.Position.Y;
|
||||
node.pz = data.Position.Z;
|
||||
|
||||
node.rx = data.Rotation.X;
|
||||
node.ry = data.Rotation.Y;
|
||||
node.rz = data.Rotation.Z;
|
||||
node.t = data.Distance;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
std::vector<sCinemaPath> GetCurrentPaths()
|
||||
{
|
||||
const std::map<CStrW, CCinemaPath>& paths = g_Game->GetView()->GetCinema()->GetAllPaths();
|
||||
std::vector<sCinemaPath> atlasPaths;
|
||||
|
||||
for ( std::map<CStrW, CCinemaPath>::const_iterator it=paths.begin(); it!=paths.end(); it++ )
|
||||
{
|
||||
sCinemaPath path = ConstructCinemaPath(&it->second);
|
||||
path.name = it->first;
|
||||
|
||||
const std::vector<SplineData>& nodes = it->second.GetAllNodes();
|
||||
std::vector<sCinemaSplineNode> atlasNodes;
|
||||
|
||||
for ( size_t i=0; i<nodes.size(); ++i )
|
||||
atlasNodes.push_back( ConstructCinemaNode(nodes[i]) );
|
||||
|
||||
if ( !atlasNodes.empty() )
|
||||
{
|
||||
float back = atlasNodes.back().t;
|
||||
if ( atlasNodes.size() > 2 )
|
||||
{
|
||||
for ( size_t i=atlasNodes.size()-2; i>0; --i )
|
||||
atlasNodes[i].t = atlasNodes[i-1].t;
|
||||
}
|
||||
atlasNodes.back().t = atlasNodes.front().t;
|
||||
atlasNodes.front().t = back;
|
||||
}
|
||||
path.nodes = atlasNodes;
|
||||
atlasPaths.push_back(path);
|
||||
}
|
||||
return atlasPaths;
|
||||
}
|
||||
|
||||
void SetCurrentPaths(const std::vector<sCinemaPath>& atlasPaths)
|
||||
{
|
||||
std::map<CStrW, CCinemaPath> paths;
|
||||
|
||||
for ( std::vector<sCinemaPath>::const_iterator it=atlasPaths.begin(); it!=atlasPaths.end(); it++ )
|
||||
{
|
||||
CStrW pathName(*it->name);
|
||||
paths[pathName] = CCinemaPath();
|
||||
paths[pathName].SetTimescale(it->timescale);
|
||||
|
||||
const sCinemaPath& atlasPath = *it;
|
||||
const std::vector<sCinemaSplineNode> nodes = *atlasPath.nodes;
|
||||
TNSpline spline;
|
||||
CCinemaData data = ConstructCinemaData(atlasPath);
|
||||
|
||||
for ( size_t j=0; j<nodes.size(); ++j )
|
||||
{
|
||||
spline.AddNode( CVector3D(nodes[j].px, nodes[j].py, nodes[j].pz),
|
||||
CVector3D(nodes[j].rx, nodes[j].ry, nodes[j].rz), nodes[j].t );
|
||||
}
|
||||
paths[pathName] = CCinemaPath(data, spline);
|
||||
}
|
||||
|
||||
g_Game->GetView()->GetCinema()->SetAllPaths(paths);
|
||||
}
|
||||
QUERYHANDLER(GetCameraInfo)
|
||||
{
|
||||
sCameraInfo info;
|
||||
CMatrix3D* cam = &g_Game->GetView()->GetCamera()->m_Orientation;
|
||||
|
||||
CQuaternion quatRot = cam->GetRotation();
|
||||
quatRot.Normalize();
|
||||
CVector3D rotation = quatRot.ToEulerAngles();
|
||||
rotation.X = RADTODEG(rotation.X);
|
||||
rotation.Y = RADTODEG(rotation.Y);
|
||||
rotation.Z = RADTODEG(rotation.Z);
|
||||
CVector3D translation = cam->GetTranslation();
|
||||
|
||||
info.pX = translation.X;
|
||||
info.pY = translation.Y;
|
||||
info.pZ = translation.Z;
|
||||
info.rX = rotation.X;
|
||||
info.rY = rotation.Y;
|
||||
info.rZ = rotation.Z;
|
||||
msg->info = info;
|
||||
}
|
||||
|
||||
MESSAGEHANDLER(CinemaEvent)
|
||||
{
|
||||
CCinemaManager* manager = g_Game->GetView()->GetCinema();
|
||||
|
||||
if ( msg->mode == eCinemaEventMode::SMOOTH )
|
||||
manager->OverridePath(*msg->path);
|
||||
else if ( msg->mode == eCinemaEventMode::IMMEDIATE_PATH )
|
||||
manager->MoveToPointAt(msg->t);
|
||||
else if ( msg->mode == eCinemaEventMode::RESET )
|
||||
g_Game->GetView()->ResetCamera();
|
||||
else if ( msg->mode == eCinemaEventMode::SELECT )
|
||||
manager->SetCurrentPath(*msg->path, msg->drawCurrent, msg->lines);
|
||||
else
|
||||
debug_assert(false);
|
||||
}
|
||||
|
||||
BEGIN_COMMAND(SetCinemaPaths)
|
||||
{
|
||||
std::vector<sCinemaPath> m_oldPaths, m_newPaths;
|
||||
void Do()
|
||||
{
|
||||
m_oldPaths = GetCurrentPaths();
|
||||
m_newPaths = *msg->paths;
|
||||
Redo();
|
||||
}
|
||||
void Redo()
|
||||
{
|
||||
SetCurrentPaths(m_newPaths);
|
||||
}
|
||||
void Undo()
|
||||
{
|
||||
SetCurrentPaths(m_oldPaths);
|
||||
}
|
||||
};
|
||||
END_COMMAND(SetCinemaPaths)
|
||||
|
||||
QUERYHANDLER(GetCinemaPaths)
|
||||
{
|
||||
msg->paths = GetCurrentPaths();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,346 +1,346 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "MessageHandler.h"
|
||||
#include "../CommandProc.h"
|
||||
#include "../Shareable.h"
|
||||
|
||||
#include "simulation/TriggerManager.h"
|
||||
#include "ps/Game.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
|
||||
namespace AtlasMessage {
|
||||
|
||||
sTriggerSpec TriggerSpecToAtlas(const CTriggerSpec& spec)
|
||||
{
|
||||
sTriggerSpec atlasSpec;
|
||||
std::vector< sTriggerParameter > atlasParameters;
|
||||
const std::set<TriggerParameter>& parameters = spec.GetParameters();
|
||||
|
||||
for ( std::set<TriggerParameter>::const_iterator it=parameters.begin(); it!=parameters.end(); ++it )
|
||||
{
|
||||
sTriggerParameter atlasParam;
|
||||
atlasParam.column = it->column;
|
||||
atlasParam.inputType = it->inputType;
|
||||
atlasParam.name = it->name;
|
||||
atlasParam.parameterOrder = it->parameterOrder;
|
||||
atlasParam.row = it->row;
|
||||
|
||||
atlasParam.windowType = it->windowType;
|
||||
atlasParam.xPos = it->xPos;
|
||||
atlasParam.yPos = it->yPos;
|
||||
atlasParam.xSize = it->xSize;
|
||||
atlasParam.ySize = it->ySize;
|
||||
atlasParameters.push_back(atlasParam);
|
||||
}
|
||||
atlasSpec.functionName = spec.functionName;
|
||||
atlasSpec.displayName = spec.displayName;
|
||||
atlasSpec.parameters = atlasParameters;
|
||||
return atlasSpec;
|
||||
}
|
||||
|
||||
sTrigger TriggerToAtlas(const MapTrigger& trigger)
|
||||
{
|
||||
sTrigger atlasTrigger;
|
||||
atlasTrigger.active = trigger.active;
|
||||
atlasTrigger.timeValue = trigger.timeValue;
|
||||
atlasTrigger.maxRuns = trigger.maxRunCount;
|
||||
atlasTrigger.group = trigger.groupName;
|
||||
atlasTrigger.name = trigger.name;
|
||||
|
||||
std::vector<bool> atlasNots;
|
||||
std::vector<int> atlasBlocks, atlasBlockEnds;
|
||||
|
||||
for ( std::set<MapTriggerLogicBlock>::const_iterator it = trigger.logicBlocks.begin();
|
||||
it != trigger.logicBlocks.end(); ++it )
|
||||
{
|
||||
atlasBlocks.push_back( (int)it->index );
|
||||
atlasNots.push_back( it->negated );
|
||||
}
|
||||
for ( std::set<size_t>::const_iterator it = trigger.logicBlockEnds.begin();
|
||||
it != trigger.logicBlockEnds.end(); ++it )
|
||||
{
|
||||
atlasBlockEnds.push_back( (int)*it );
|
||||
}
|
||||
atlasTrigger.logicNots = atlasNots;
|
||||
atlasTrigger.logicBlocks = atlasBlocks;
|
||||
atlasTrigger.logicBlockEnds = atlasBlockEnds;
|
||||
|
||||
std::vector<sTriggerCondition> atlasConditions;
|
||||
std::vector<sTriggerEffect> atlasEffects;
|
||||
|
||||
for ( std::list<MapTriggerCondition>::const_iterator it = trigger.conditions.begin();
|
||||
it != trigger.conditions.end(); ++it )
|
||||
{
|
||||
sTriggerCondition atlasCondition;
|
||||
atlasCondition.linkLogic = it->linkLogic;
|
||||
atlasCondition.name = it->name;
|
||||
atlasCondition.functionName = it->functionName;
|
||||
atlasCondition.displayName = it->displayName;
|
||||
atlasCondition.negated = it->negated;
|
||||
std::vector<std::wstring> parameters;
|
||||
|
||||
for ( std::list<CStrW>::const_iterator it2=it->parameters.begin();
|
||||
it2 != it->parameters.end(); ++it2 )
|
||||
{
|
||||
parameters.push_back( std::wstring(it2->c_str()) );
|
||||
}
|
||||
|
||||
atlasCondition.parameters = parameters;
|
||||
atlasConditions.push_back(atlasCondition);
|
||||
}
|
||||
|
||||
for ( std::list<MapTriggerEffect>::const_iterator it = trigger.effects.begin();
|
||||
it != trigger.effects.end(); ++it )
|
||||
{
|
||||
sTriggerEffect atlasEffect;
|
||||
std::vector<std::wstring> parameters;
|
||||
atlasEffect.name = it->name;
|
||||
atlasEffect.functionName = it->functionName;
|
||||
atlasEffect.displayName = it->displayName;
|
||||
|
||||
for ( std::list<CStrW>::const_iterator it2 = it->parameters.begin();
|
||||
it2 != it->parameters.end(); ++it2 )
|
||||
{
|
||||
parameters.push_back( std::wstring(it2->c_str()) );
|
||||
}
|
||||
atlasEffect.parameters = parameters;
|
||||
atlasEffects.push_back( atlasEffect );
|
||||
}
|
||||
|
||||
atlasTrigger.conditions = atlasConditions;
|
||||
atlasTrigger.effects = atlasEffects;
|
||||
return atlasTrigger;
|
||||
}
|
||||
|
||||
sTriggerGroup GroupToAtlas(const MapTriggerGroup& group)
|
||||
{
|
||||
sTriggerGroup atlasGroup;
|
||||
atlasGroup.parentName = group.parentName;
|
||||
atlasGroup.name = group.name;
|
||||
|
||||
std::vector<sTrigger> atlasTriggers;
|
||||
std::vector<std::wstring> atlasChildren;
|
||||
for ( std::list<MapTrigger>::const_iterator it = group.triggers.begin();
|
||||
it != group.triggers.end(); ++it )
|
||||
{
|
||||
atlasTriggers.push_back( TriggerToAtlas(*it) );
|
||||
}
|
||||
for ( std::list<CStrW>::const_iterator it = group.childGroups.begin();
|
||||
it != group.childGroups.end(); ++it )
|
||||
{
|
||||
atlasChildren.push_back( std::wstring(it->c_str()) );
|
||||
}
|
||||
|
||||
atlasGroup.triggers = atlasTriggers;
|
||||
atlasGroup.children = atlasChildren;
|
||||
return atlasGroup;
|
||||
}
|
||||
|
||||
MapTrigger AtlasToTrigger(const sTrigger& trigger)
|
||||
{
|
||||
MapTrigger engineTrigger;
|
||||
|
||||
engineTrigger.active = trigger.active;
|
||||
engineTrigger.groupName = *trigger.group;
|
||||
|
||||
std::vector<int> blockEnds = *trigger.logicBlockEnds, blocks = *trigger.logicBlocks;
|
||||
std::copy( blockEnds.begin(), blockEnds.end(), inserter(engineTrigger.logicBlockEnds, engineTrigger.logicBlockEnds.begin()) );
|
||||
std::copy( blocks.begin(), blocks.end(), inserter(engineTrigger.logicBlocks, engineTrigger.logicBlocks.begin()) );
|
||||
|
||||
engineTrigger.maxRunCount = trigger.maxRuns;
|
||||
engineTrigger.name = *trigger.name;
|
||||
engineTrigger.timeValue = trigger.timeValue;
|
||||
|
||||
std::vector<sTriggerCondition> conditions = *trigger.conditions;
|
||||
std::vector<sTriggerEffect> effects = *trigger.effects;
|
||||
|
||||
for ( std::vector<sTriggerCondition>::const_iterator it = conditions.begin(); it != conditions.end(); ++it )
|
||||
{
|
||||
engineTrigger.conditions.push_back( MapTriggerCondition() );
|
||||
MapTriggerCondition* cond = &engineTrigger.conditions.back();
|
||||
|
||||
cond->functionName = *it->functionName;
|
||||
cond->displayName = *it->displayName;
|
||||
cond->linkLogic = it->linkLogic;
|
||||
cond->name = *it->name;
|
||||
cond->negated = it->negated;
|
||||
|
||||
std::vector<std::wstring> parameters = *it->parameters;
|
||||
for ( std::vector<std::wstring>::const_iterator it2 = parameters.begin(); it2 != parameters.end(); ++it2 )
|
||||
{
|
||||
cond->parameters.push_back( CStrW(*it2) );
|
||||
}
|
||||
}
|
||||
|
||||
for ( std::vector<sTriggerEffect>::const_iterator it = effects.begin(); it != effects.end(); ++it )
|
||||
{
|
||||
engineTrigger.effects.push_back( MapTriggerEffect() );
|
||||
MapTriggerEffect* effect = &engineTrigger.effects.back();
|
||||
|
||||
effect->functionName = *it->functionName;
|
||||
effect->displayName = *it->displayName;
|
||||
effect->name = *it->name;
|
||||
std::vector<std::wstring> parameters = *it->parameters;
|
||||
|
||||
for ( std::vector<std::wstring>::const_iterator it2 = parameters.begin(); it2 != parameters.end(); ++it2 )
|
||||
{
|
||||
effect->parameters.push_back( CStrW(*it2) );
|
||||
}
|
||||
}
|
||||
|
||||
return engineTrigger;
|
||||
}
|
||||
|
||||
|
||||
MapTriggerGroup AtlasToGroup(const sTriggerGroup& group)
|
||||
{
|
||||
MapTriggerGroup engineGroup;
|
||||
engineGroup.parentName = *group.parentName;
|
||||
engineGroup.name = *group.name;
|
||||
|
||||
std::list<MapTrigger> engineTriggers;
|
||||
std::vector<std::wstring> atlasChildren = *group.children;
|
||||
std::vector<sTrigger> atlasTriggers = *group.triggers;
|
||||
|
||||
for ( std::vector<sTrigger>::const_iterator it = atlasTriggers.begin();
|
||||
it != atlasTriggers.end(); ++it )
|
||||
{
|
||||
engineTriggers.push_back( AtlasToTrigger(*it) );
|
||||
}
|
||||
for ( std::vector<std::wstring>::const_iterator it = atlasChildren.begin(); it != atlasChildren.end(); ++it )
|
||||
engineGroup.childGroups.push_back(*it);
|
||||
|
||||
engineGroup.triggers = engineTriggers;
|
||||
return engineGroup;
|
||||
}
|
||||
|
||||
std::vector<sTriggerGroup> GetCurrentTriggers()
|
||||
{
|
||||
const std::list<MapTriggerGroup>& groups = g_TriggerManager.GetAllTriggerGroups();
|
||||
std::vector<sTriggerGroup> atlasGroups;
|
||||
|
||||
for ( std::list<MapTriggerGroup>::const_iterator it = groups.begin(); it != groups.end(); ++it )
|
||||
atlasGroups.push_back( GroupToAtlas(*it) );
|
||||
return atlasGroups;
|
||||
}
|
||||
|
||||
void SetCurrentTriggers(const std::vector<sTriggerGroup>& groups)
|
||||
{
|
||||
std::list<MapTriggerGroup> engineGroups;
|
||||
for ( std::vector<sTriggerGroup>::const_iterator it = groups.begin(); it != groups.end(); ++it )
|
||||
engineGroups.push_back( AtlasToGroup(*it) );
|
||||
g_TriggerManager.SetAllGroups(engineGroups);
|
||||
}
|
||||
|
||||
QUERYHANDLER(GetTriggerData)
|
||||
{
|
||||
const std::list<CTriggerCondition>& conditions = g_TriggerManager.GetAllConditions();
|
||||
const std::list<CTriggerEffect>& effects = g_TriggerManager.GetAllEffects();
|
||||
std::vector<sTriggerSpec> atlasConditions;
|
||||
std::vector<sTriggerSpec> atlasEffects;
|
||||
|
||||
for ( std::list<CTriggerCondition>::const_iterator it=conditions.begin(); it!=conditions.end(); ++it )
|
||||
atlasConditions.push_back( TriggerSpecToAtlas(*it) );
|
||||
for ( std::list<CTriggerEffect>::const_iterator it=effects.begin(); it!=effects.end(); ++it )
|
||||
atlasEffects.push_back( TriggerSpecToAtlas(*it) );
|
||||
|
||||
msg->conditions = atlasConditions;
|
||||
msg->effects = atlasEffects;
|
||||
msg->groups = GetCurrentTriggers();
|
||||
}
|
||||
|
||||
QUERYHANDLER(GetTriggerChoices)
|
||||
{
|
||||
CStrW selectedName(*msg->name);
|
||||
std::vector<std::wstring> choices = g_TriggerManager.GetTriggerChoices(selectedName);
|
||||
std::vector<std::wstring> translations = g_TriggerManager.GetTriggerTranslations(selectedName);
|
||||
|
||||
if ( choices.empty() )
|
||||
return;
|
||||
|
||||
//If a special list (i.e. uses engine data)
|
||||
if ( choices.size() == 1 )
|
||||
{
|
||||
|
||||
if ( choices[0] == std::wstring(L"ATLAS_CINEMA_LIST") )
|
||||
{
|
||||
choices.clear();
|
||||
const std::map<CStrW, CCinemaPath>& paths = g_Game->GetView()->GetCinema()->GetAllPaths();
|
||||
for ( std::map<CStrW, CCinemaPath>::const_iterator it = paths.begin(); it != paths.end(); ++it )
|
||||
{
|
||||
choices.push_back(it->first);
|
||||
translations.push_back( L"\"" + it->first + L"\"" ); //Strings need quotes in JS
|
||||
}
|
||||
}
|
||||
else if ( choices[0] == std::wstring(L"ATLAS_TRIGGER_LIST") )
|
||||
{
|
||||
choices.clear();
|
||||
const std::list<MapTriggerGroup>& groups = g_TriggerManager.GetAllTriggerGroups();
|
||||
for ( std::list<MapTriggerGroup>::const_iterator it = groups.begin();
|
||||
it != groups.end(); ++it )
|
||||
{
|
||||
for ( std::list<MapTrigger>::const_iterator it2 = it->triggers.begin();
|
||||
it2 != it->triggers.end(); ++it2 )
|
||||
{
|
||||
choices.push_back(it2->name);
|
||||
translations.push_back( L"\"" + it2->name + L"\"" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( choices[0] == std::wstring(L"ATLAS_TRIG_GROUP_LIST") )
|
||||
{
|
||||
choices.clear();
|
||||
const std::list<MapTriggerGroup>& groups = g_TriggerManager.GetAllTriggerGroups();
|
||||
for ( std::list<MapTriggerGroup>::const_iterator it = groups.begin();
|
||||
it != groups.end(); ++it )
|
||||
{
|
||||
choices.push_back(it->name);
|
||||
translations.push_back( L"\"" + it->name + L"\"" );
|
||||
}
|
||||
}
|
||||
else
|
||||
debug_warn("Invalid special choice list for trigger specification parameter");
|
||||
}
|
||||
msg->choices = choices;
|
||||
msg->translations = translations;
|
||||
}
|
||||
|
||||
QUERYHANDLER(GetWorldPosition)
|
||||
{
|
||||
Position pos;
|
||||
pos.type1.x = msg->x;
|
||||
pos.type1.y = msg->y;
|
||||
CVector3D worldPos = pos.GetWorldSpace();
|
||||
Position ret(worldPos.X, worldPos.Y, worldPos.Z);
|
||||
msg->position = ret;
|
||||
}
|
||||
BEGIN_COMMAND(SetAllTriggers)
|
||||
{
|
||||
std::vector<sTriggerGroup> m_oldGroups, m_newGroups;
|
||||
|
||||
void Do()
|
||||
{
|
||||
m_oldGroups = GetCurrentTriggers();
|
||||
m_newGroups = *msg->groups;
|
||||
Redo();
|
||||
}
|
||||
void Redo()
|
||||
{
|
||||
SetCurrentTriggers(m_newGroups);
|
||||
}
|
||||
void Undo()
|
||||
{
|
||||
SetCurrentTriggers(m_oldGroups);
|
||||
}
|
||||
};
|
||||
END_COMMAND(SetAllTriggers)
|
||||
|
||||
|
||||
MESSAGEHANDLER(TriggerToggleSelector)
|
||||
{
|
||||
//TODO: Draw stuff
|
||||
UNUSED2(msg);
|
||||
}
|
||||
|
||||
}
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "MessageHandler.h"
|
||||
#include "../CommandProc.h"
|
||||
#include "../Shareable.h"
|
||||
|
||||
#include "simulation/TriggerManager.h"
|
||||
#include "ps/Game.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
|
||||
namespace AtlasMessage {
|
||||
|
||||
sTriggerSpec TriggerSpecToAtlas(const CTriggerSpec& spec)
|
||||
{
|
||||
sTriggerSpec atlasSpec;
|
||||
std::vector< sTriggerParameter > atlasParameters;
|
||||
const std::set<TriggerParameter>& parameters = spec.GetParameters();
|
||||
|
||||
for ( std::set<TriggerParameter>::const_iterator it=parameters.begin(); it!=parameters.end(); ++it )
|
||||
{
|
||||
sTriggerParameter atlasParam;
|
||||
atlasParam.column = it->column;
|
||||
atlasParam.inputType = it->inputType;
|
||||
atlasParam.name = it->name;
|
||||
atlasParam.parameterOrder = it->parameterOrder;
|
||||
atlasParam.row = it->row;
|
||||
|
||||
atlasParam.windowType = it->windowType;
|
||||
atlasParam.xPos = it->xPos;
|
||||
atlasParam.yPos = it->yPos;
|
||||
atlasParam.xSize = it->xSize;
|
||||
atlasParam.ySize = it->ySize;
|
||||
atlasParameters.push_back(atlasParam);
|
||||
}
|
||||
atlasSpec.functionName = spec.functionName;
|
||||
atlasSpec.displayName = spec.displayName;
|
||||
atlasSpec.parameters = atlasParameters;
|
||||
return atlasSpec;
|
||||
}
|
||||
|
||||
sTrigger TriggerToAtlas(const MapTrigger& trigger)
|
||||
{
|
||||
sTrigger atlasTrigger;
|
||||
atlasTrigger.active = trigger.active;
|
||||
atlasTrigger.timeValue = trigger.timeValue;
|
||||
atlasTrigger.maxRuns = trigger.maxRunCount;
|
||||
atlasTrigger.group = trigger.groupName;
|
||||
atlasTrigger.name = trigger.name;
|
||||
|
||||
std::vector<bool> atlasNots;
|
||||
std::vector<int> atlasBlocks, atlasBlockEnds;
|
||||
|
||||
for ( std::set<MapTriggerLogicBlock>::const_iterator it = trigger.logicBlocks.begin();
|
||||
it != trigger.logicBlocks.end(); ++it )
|
||||
{
|
||||
atlasBlocks.push_back( (int)it->index );
|
||||
atlasNots.push_back( it->negated );
|
||||
}
|
||||
for ( std::set<size_t>::const_iterator it = trigger.logicBlockEnds.begin();
|
||||
it != trigger.logicBlockEnds.end(); ++it )
|
||||
{
|
||||
atlasBlockEnds.push_back( (int)*it );
|
||||
}
|
||||
atlasTrigger.logicNots = atlasNots;
|
||||
atlasTrigger.logicBlocks = atlasBlocks;
|
||||
atlasTrigger.logicBlockEnds = atlasBlockEnds;
|
||||
|
||||
std::vector<sTriggerCondition> atlasConditions;
|
||||
std::vector<sTriggerEffect> atlasEffects;
|
||||
|
||||
for ( std::list<MapTriggerCondition>::const_iterator it = trigger.conditions.begin();
|
||||
it != trigger.conditions.end(); ++it )
|
||||
{
|
||||
sTriggerCondition atlasCondition;
|
||||
atlasCondition.linkLogic = it->linkLogic;
|
||||
atlasCondition.name = it->name;
|
||||
atlasCondition.functionName = it->functionName;
|
||||
atlasCondition.displayName = it->displayName;
|
||||
atlasCondition.negated = it->negated;
|
||||
std::vector<std::wstring> parameters;
|
||||
|
||||
for ( std::list<CStrW>::const_iterator it2=it->parameters.begin();
|
||||
it2 != it->parameters.end(); ++it2 )
|
||||
{
|
||||
parameters.push_back( std::wstring(it2->c_str()) );
|
||||
}
|
||||
|
||||
atlasCondition.parameters = parameters;
|
||||
atlasConditions.push_back(atlasCondition);
|
||||
}
|
||||
|
||||
for ( std::list<MapTriggerEffect>::const_iterator it = trigger.effects.begin();
|
||||
it != trigger.effects.end(); ++it )
|
||||
{
|
||||
sTriggerEffect atlasEffect;
|
||||
std::vector<std::wstring> parameters;
|
||||
atlasEffect.name = it->name;
|
||||
atlasEffect.functionName = it->functionName;
|
||||
atlasEffect.displayName = it->displayName;
|
||||
|
||||
for ( std::list<CStrW>::const_iterator it2 = it->parameters.begin();
|
||||
it2 != it->parameters.end(); ++it2 )
|
||||
{
|
||||
parameters.push_back( std::wstring(it2->c_str()) );
|
||||
}
|
||||
atlasEffect.parameters = parameters;
|
||||
atlasEffects.push_back( atlasEffect );
|
||||
}
|
||||
|
||||
atlasTrigger.conditions = atlasConditions;
|
||||
atlasTrigger.effects = atlasEffects;
|
||||
return atlasTrigger;
|
||||
}
|
||||
|
||||
sTriggerGroup GroupToAtlas(const MapTriggerGroup& group)
|
||||
{
|
||||
sTriggerGroup atlasGroup;
|
||||
atlasGroup.parentName = group.parentName;
|
||||
atlasGroup.name = group.name;
|
||||
|
||||
std::vector<sTrigger> atlasTriggers;
|
||||
std::vector<std::wstring> atlasChildren;
|
||||
for ( std::list<MapTrigger>::const_iterator it = group.triggers.begin();
|
||||
it != group.triggers.end(); ++it )
|
||||
{
|
||||
atlasTriggers.push_back( TriggerToAtlas(*it) );
|
||||
}
|
||||
for ( std::list<CStrW>::const_iterator it = group.childGroups.begin();
|
||||
it != group.childGroups.end(); ++it )
|
||||
{
|
||||
atlasChildren.push_back( std::wstring(it->c_str()) );
|
||||
}
|
||||
|
||||
atlasGroup.triggers = atlasTriggers;
|
||||
atlasGroup.children = atlasChildren;
|
||||
return atlasGroup;
|
||||
}
|
||||
|
||||
MapTrigger AtlasToTrigger(const sTrigger& trigger)
|
||||
{
|
||||
MapTrigger engineTrigger;
|
||||
|
||||
engineTrigger.active = trigger.active;
|
||||
engineTrigger.groupName = *trigger.group;
|
||||
|
||||
std::vector<int> blockEnds = *trigger.logicBlockEnds, blocks = *trigger.logicBlocks;
|
||||
std::copy( blockEnds.begin(), blockEnds.end(), inserter(engineTrigger.logicBlockEnds, engineTrigger.logicBlockEnds.begin()) );
|
||||
std::copy( blocks.begin(), blocks.end(), inserter(engineTrigger.logicBlocks, engineTrigger.logicBlocks.begin()) );
|
||||
|
||||
engineTrigger.maxRunCount = trigger.maxRuns;
|
||||
engineTrigger.name = *trigger.name;
|
||||
engineTrigger.timeValue = trigger.timeValue;
|
||||
|
||||
std::vector<sTriggerCondition> conditions = *trigger.conditions;
|
||||
std::vector<sTriggerEffect> effects = *trigger.effects;
|
||||
|
||||
for ( std::vector<sTriggerCondition>::const_iterator it = conditions.begin(); it != conditions.end(); ++it )
|
||||
{
|
||||
engineTrigger.conditions.push_back( MapTriggerCondition() );
|
||||
MapTriggerCondition* cond = &engineTrigger.conditions.back();
|
||||
|
||||
cond->functionName = *it->functionName;
|
||||
cond->displayName = *it->displayName;
|
||||
cond->linkLogic = it->linkLogic;
|
||||
cond->name = *it->name;
|
||||
cond->negated = it->negated;
|
||||
|
||||
std::vector<std::wstring> parameters = *it->parameters;
|
||||
for ( std::vector<std::wstring>::const_iterator it2 = parameters.begin(); it2 != parameters.end(); ++it2 )
|
||||
{
|
||||
cond->parameters.push_back( CStrW(*it2) );
|
||||
}
|
||||
}
|
||||
|
||||
for ( std::vector<sTriggerEffect>::const_iterator it = effects.begin(); it != effects.end(); ++it )
|
||||
{
|
||||
engineTrigger.effects.push_back( MapTriggerEffect() );
|
||||
MapTriggerEffect* effect = &engineTrigger.effects.back();
|
||||
|
||||
effect->functionName = *it->functionName;
|
||||
effect->displayName = *it->displayName;
|
||||
effect->name = *it->name;
|
||||
std::vector<std::wstring> parameters = *it->parameters;
|
||||
|
||||
for ( std::vector<std::wstring>::const_iterator it2 = parameters.begin(); it2 != parameters.end(); ++it2 )
|
||||
{
|
||||
effect->parameters.push_back( CStrW(*it2) );
|
||||
}
|
||||
}
|
||||
|
||||
return engineTrigger;
|
||||
}
|
||||
|
||||
|
||||
MapTriggerGroup AtlasToGroup(const sTriggerGroup& group)
|
||||
{
|
||||
MapTriggerGroup engineGroup;
|
||||
engineGroup.parentName = *group.parentName;
|
||||
engineGroup.name = *group.name;
|
||||
|
||||
std::list<MapTrigger> engineTriggers;
|
||||
std::vector<std::wstring> atlasChildren = *group.children;
|
||||
std::vector<sTrigger> atlasTriggers = *group.triggers;
|
||||
|
||||
for ( std::vector<sTrigger>::const_iterator it = atlasTriggers.begin();
|
||||
it != atlasTriggers.end(); ++it )
|
||||
{
|
||||
engineTriggers.push_back( AtlasToTrigger(*it) );
|
||||
}
|
||||
for ( std::vector<std::wstring>::const_iterator it = atlasChildren.begin(); it != atlasChildren.end(); ++it )
|
||||
engineGroup.childGroups.push_back(*it);
|
||||
|
||||
engineGroup.triggers = engineTriggers;
|
||||
return engineGroup;
|
||||
}
|
||||
|
||||
std::vector<sTriggerGroup> GetCurrentTriggers()
|
||||
{
|
||||
const std::list<MapTriggerGroup>& groups = g_TriggerManager.GetAllTriggerGroups();
|
||||
std::vector<sTriggerGroup> atlasGroups;
|
||||
|
||||
for ( std::list<MapTriggerGroup>::const_iterator it = groups.begin(); it != groups.end(); ++it )
|
||||
atlasGroups.push_back( GroupToAtlas(*it) );
|
||||
return atlasGroups;
|
||||
}
|
||||
|
||||
void SetCurrentTriggers(const std::vector<sTriggerGroup>& groups)
|
||||
{
|
||||
std::list<MapTriggerGroup> engineGroups;
|
||||
for ( std::vector<sTriggerGroup>::const_iterator it = groups.begin(); it != groups.end(); ++it )
|
||||
engineGroups.push_back( AtlasToGroup(*it) );
|
||||
g_TriggerManager.SetAllGroups(engineGroups);
|
||||
}
|
||||
|
||||
QUERYHANDLER(GetTriggerData)
|
||||
{
|
||||
const std::list<CTriggerCondition>& conditions = g_TriggerManager.GetAllConditions();
|
||||
const std::list<CTriggerEffect>& effects = g_TriggerManager.GetAllEffects();
|
||||
std::vector<sTriggerSpec> atlasConditions;
|
||||
std::vector<sTriggerSpec> atlasEffects;
|
||||
|
||||
for ( std::list<CTriggerCondition>::const_iterator it=conditions.begin(); it!=conditions.end(); ++it )
|
||||
atlasConditions.push_back( TriggerSpecToAtlas(*it) );
|
||||
for ( std::list<CTriggerEffect>::const_iterator it=effects.begin(); it!=effects.end(); ++it )
|
||||
atlasEffects.push_back( TriggerSpecToAtlas(*it) );
|
||||
|
||||
msg->conditions = atlasConditions;
|
||||
msg->effects = atlasEffects;
|
||||
msg->groups = GetCurrentTriggers();
|
||||
}
|
||||
|
||||
QUERYHANDLER(GetTriggerChoices)
|
||||
{
|
||||
CStrW selectedName(*msg->name);
|
||||
std::vector<std::wstring> choices = g_TriggerManager.GetTriggerChoices(selectedName);
|
||||
std::vector<std::wstring> translations = g_TriggerManager.GetTriggerTranslations(selectedName);
|
||||
|
||||
if ( choices.empty() )
|
||||
return;
|
||||
|
||||
//If a special list (i.e. uses engine data)
|
||||
if ( choices.size() == 1 )
|
||||
{
|
||||
|
||||
if ( choices[0] == std::wstring(L"ATLAS_CINEMA_LIST") )
|
||||
{
|
||||
choices.clear();
|
||||
const std::map<CStrW, CCinemaPath>& paths = g_Game->GetView()->GetCinema()->GetAllPaths();
|
||||
for ( std::map<CStrW, CCinemaPath>::const_iterator it = paths.begin(); it != paths.end(); ++it )
|
||||
{
|
||||
choices.push_back(it->first);
|
||||
translations.push_back( L"\"" + it->first + L"\"" ); //Strings need quotes in JS
|
||||
}
|
||||
}
|
||||
else if ( choices[0] == std::wstring(L"ATLAS_TRIGGER_LIST") )
|
||||
{
|
||||
choices.clear();
|
||||
const std::list<MapTriggerGroup>& groups = g_TriggerManager.GetAllTriggerGroups();
|
||||
for ( std::list<MapTriggerGroup>::const_iterator it = groups.begin();
|
||||
it != groups.end(); ++it )
|
||||
{
|
||||
for ( std::list<MapTrigger>::const_iterator it2 = it->triggers.begin();
|
||||
it2 != it->triggers.end(); ++it2 )
|
||||
{
|
||||
choices.push_back(it2->name);
|
||||
translations.push_back( L"\"" + it2->name + L"\"" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( choices[0] == std::wstring(L"ATLAS_TRIG_GROUP_LIST") )
|
||||
{
|
||||
choices.clear();
|
||||
const std::list<MapTriggerGroup>& groups = g_TriggerManager.GetAllTriggerGroups();
|
||||
for ( std::list<MapTriggerGroup>::const_iterator it = groups.begin();
|
||||
it != groups.end(); ++it )
|
||||
{
|
||||
choices.push_back(it->name);
|
||||
translations.push_back( L"\"" + it->name + L"\"" );
|
||||
}
|
||||
}
|
||||
else
|
||||
debug_warn("Invalid special choice list for trigger specification parameter");
|
||||
}
|
||||
msg->choices = choices;
|
||||
msg->translations = translations;
|
||||
}
|
||||
|
||||
QUERYHANDLER(GetWorldPosition)
|
||||
{
|
||||
Position pos;
|
||||
pos.type1.x = msg->x;
|
||||
pos.type1.y = msg->y;
|
||||
CVector3D worldPos = pos.GetWorldSpace();
|
||||
Position ret(worldPos.X, worldPos.Y, worldPos.Z);
|
||||
msg->position = ret;
|
||||
}
|
||||
BEGIN_COMMAND(SetAllTriggers)
|
||||
{
|
||||
std::vector<sTriggerGroup> m_oldGroups, m_newGroups;
|
||||
|
||||
void Do()
|
||||
{
|
||||
m_oldGroups = GetCurrentTriggers();
|
||||
m_newGroups = *msg->groups;
|
||||
Redo();
|
||||
}
|
||||
void Redo()
|
||||
{
|
||||
SetCurrentTriggers(m_newGroups);
|
||||
}
|
||||
void Undo()
|
||||
{
|
||||
SetCurrentTriggers(m_oldGroups);
|
||||
}
|
||||
};
|
||||
END_COMMAND(SetAllTriggers)
|
||||
|
||||
|
||||
MESSAGEHANDLER(TriggerToggleSelector)
|
||||
{
|
||||
//TODO: Draw stuff
|
||||
UNUSED2(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user