Added "add/edit link" dialog to the modify tab

This commit is contained in:
parax0
2016-03-01 11:18:07 -07:00
parent 2860c27d15
commit 984d9cf3f3
33 changed files with 1225 additions and 63 deletions

View File

@@ -115,7 +115,6 @@ HEADERS += \
Resource/Script/CScriptTemplate.h \
Resource/Script/EPropertyType.h \
Resource/Script/EVolumeShape.h \
Resource/Script/SConnection.h \
Resource/CAnimationParameters.h \
Resource/CAnimSet.h \
Resource/CCollisionMesh.h \
@@ -186,7 +185,8 @@ HEADERS += \
Resource/Cooker/CPoiToWorldCooker.h \
Resource/Factory/CSectionMgrIn.h \
Resource/Cooker/CScriptCooker.h \
ScriptExtra/CSplinePathExtra.h
ScriptExtra/CSplinePathExtra.h \
Resource/Script/SLink.h
# Source Files
SOURCES += \

View File

@@ -150,23 +150,39 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster)
}
// Write script states/messages
std::map<u32, TString> *pMaps[2] = { &pMaster->mStates, &pMaster->mMessages };
TString Types[2] = { "state", "message" };
for (u32 iScr = 0; iScr < 2; iScr++)
for (u32 iType = 0; iType < 2; iType++)
{
XMLElement *pElem = Master.NewElement(*(Types[iScr] + "s"));
TString Type = (iType == 0 ? "state" : "message");
XMLElement *pElem = Master.NewElement(*(Type + "s"));
pBase->LinkEndChild(pElem);
for (auto it = pMaps[iScr]->begin(); it != pMaps[iScr]->end(); it++)
{
TString ID;
if (it->first <= 0xFF) ID = TString::HexString(it->first, true, true, 2);
else ID = CFourCC(it->first).ToString();
u32 Num = (iType == 0 ? pMaster->NumStates() : pMaster->NumMessages());
XMLElement *pSubElem = Master.NewElement(*Types[iScr]);
pSubElem->SetAttribute("ID", *ID);
pSubElem->SetAttribute("name", *(it->second));
for (u32 iScr = 0; iScr < Num; iScr++)
{
u32 ID;
TString Name;
if (iType == 0)
{
SState State = pMaster->StateByIndex(iScr);
ID = State.ID;
Name = State.Name;
}
else
{
SMessage Message = pMaster->MessageByIndex(iScr);
ID = Message.ID;
Name = Message.Name;
}
TString StrID;
if (ID <= 0xFF) StrID = TString::HexString(ID, true, true, 2);
else StrID = CFourCC(ID).ToString();
XMLElement *pSubElem = Master.NewElement(*Type);
pSubElem->SetAttribute("ID", *StrID);
pSubElem->SetAttribute("name", *Name);
pElem->LinkEndChild(pSubElem);
}
}

View File

@@ -2,7 +2,7 @@
#define CAREALOADER_H
#include "CSectionMgrIn.h"
#include "Core/Resource/Script/SConnection.h"
#include "Core/Resource/Script/SLink.h"
#include "Core/Resource/CGameArea.h"
#include "Core/Resource/EGame.h"
#include "Core/Resource/CResCache.h"

View File

@@ -732,7 +732,7 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
StateID = CFourCC(StrID).ToLong();
TString StateName = pState->Attribute("name");
mpMaster->mStates[StateID] = StateName;
mpMaster->mStates[StateID] = SState(StateID, StateName);
pState = pState->NextSiblingElement("state");
}
}
@@ -753,7 +753,7 @@ void CTemplateLoader::LoadMasterTemplate(XMLDocument *pDoc, CMasterTemplate *pMa
MessageID = CFourCC(StrID).ToLong();
TString MessageName = pMessage->Attribute("name");
mpMaster->mMessages[MessageID] = MessageName;
mpMaster->mMessages[MessageID] = SMessage(MessageID, MessageName);
pMessage = pMessage->NextSiblingElement("message");
}
}

View File

@@ -57,43 +57,43 @@ CScriptTemplate* CMasterTemplate::TemplateByIndex(u32 Index)
return (std::next(it, Index))->second;
}
TString CMasterTemplate::StateByID(u32 StateID)
SState CMasterTemplate::StateByID(u32 StateID)
{
auto it = mStates.find(StateID);
if (it != mStates.end())
return it->second;
else
return "Invalid";
return SState(-1, "Invalid");
}
TString CMasterTemplate::StateByID(const CFourCC& State)
SState CMasterTemplate::StateByID(const CFourCC& State)
{
return StateByID(State.ToLong());
}
TString CMasterTemplate::StateByIndex(u32 Index)
SState CMasterTemplate::StateByIndex(u32 Index)
{
auto it = mStates.begin();
return (std::next(it, Index))->second;
}
TString CMasterTemplate::MessageByID(u32 MessageID)
SMessage CMasterTemplate::MessageByID(u32 MessageID)
{
auto it = mMessages.find(MessageID);
if (it != mMessages.end())
return it->second;
else
return "Invalid";
return SMessage(-1, "Invalid");
}
TString CMasterTemplate::MessageByID(const CFourCC& MessageID)
SMessage CMasterTemplate::MessageByID(const CFourCC& MessageID)
{
return MessageByID(MessageID.ToLong());
}
TString CMasterTemplate::MessageByIndex(u32 Index)
SMessage CMasterTemplate::MessageByIndex(u32 Index)
{
auto it = mMessages.begin();
return (std::next(it, Index))->second;

View File

@@ -2,6 +2,7 @@
#define CMASTERTEMPLATE_H
#include "CScriptTemplate.h"
#include "SLink.h"
#include "Core/Resource/EGame.h"
#include <Common/types.h>
#include <map>
@@ -21,8 +22,8 @@ class CMasterTemplate
std::map<TString, CStructTemplate*> mStructTemplates;
std::map<u32, CScriptTemplate*> mTemplates;
std::map<u32, TString> mStates;
std::map<u32, TString> mMessages;
std::map<u32, SState> mStates;
std::map<u32, SMessage> mMessages;
struct SPropIDInfo
{
@@ -46,12 +47,12 @@ public:
CScriptTemplate* TemplateByID(u32 ObjectID);
CScriptTemplate* TemplateByID(const CFourCC& ObjectID);
CScriptTemplate* TemplateByIndex(u32 Index);
TString StateByID(u32 StateID);
TString StateByID(const CFourCC& StateID);
TString StateByIndex(u32 Index);
TString MessageByID(u32 MessageID);
TString MessageByID(const CFourCC& MessageID);
TString MessageByIndex(u32 Index);
SState StateByID(u32 StateID);
SState StateByID(const CFourCC& StateID);
SState StateByIndex(u32 Index);
SMessage MessageByID(u32 MessageID);
SMessage MessageByID(const CFourCC& MessageID);
SMessage MessageByIndex(u32 Index);
TString GetDirectory() const;
CStructTemplate* GetStructAtSource(const TString& rkSource);
bool IsLoadedSuccessfully();

View File

@@ -1,7 +1,7 @@
#ifndef CSCRIPTOBJECT_H
#define CSCRIPTOBJECT_H
#include "SConnection.h"
#include "SLink.h"
#include "IProperty.h"
#include "IPropertyTemplate.h"
#include "CScriptTemplate.h"

View File

@@ -1,13 +0,0 @@
#ifndef SCONNECTION_H
#define SCONNECTION_H
#include <Common/types.h>
struct SLink
{
u32 State;
u32 Message;
u32 ObjectID; // not a pointer because it can refer to objects outside the current area
};
#endif // SCONNECTION_H

View File

@@ -0,0 +1,32 @@
#ifndef SLINK_H
#define SLINK_H
#include <Common/TString.h>
#include <Common/types.h>
struct SState
{
u32 ID;
TString Name;
SState() {}
SState(u32 _ID, const TString& rkName) : ID(_ID), Name(rkName) {}
};
struct SMessage
{
u32 ID;
TString Name;
SMessage() {}
SMessage(u32 _ID, const TString& rkName) : ID(_ID), Name(rkName) {}
};
struct SLink
{
u32 State;
u32 Message;
u32 ObjectID; // not a pointer because it can refer to objects outside the current area
};
#endif // SLINK_H