diff options
Diffstat (limited to 'src/T2DLL/T2XEvent.cpp')
-rw-r--r-- | src/T2DLL/T2XEvent.cpp | 115 |
1 files changed, 99 insertions, 16 deletions
diff --git a/src/T2DLL/T2XEvent.cpp b/src/T2DLL/T2XEvent.cpp index ed84be7..a8624a8 100644 --- a/src/T2DLL/T2XEvent.cpp +++ b/src/T2DLL/T2XEvent.cpp @@ -1,55 +1,138 @@ +#include "T2DlgItem.h" +#include "T2WorldDef.h" +#include "T2WorldPlugin.h" #include "T2XEvent.h" -T2XEvent::T2XEvent(T2TowerEvent*, CResFile*, unsigned long, int) { +T2XEvent::T2XEvent(T2TowerEvent* inTowerEvent, CResFile* inResFile, DWORD inID, int inSubID) + : T2EventItem(inTowerEvent, inResFile, inSubID) +{ + mID = inID; + mRefCon = 0; + Init(inResFile); } -T2XEvent::T2XEvent(T2XEvent*, int) { +T2XEvent::T2XEvent(T2XEvent* inXEvent, int inSubID) + : T2EventItem(inXEvent, inSubID) +{ + mID = inXEvent->mID; + mRefCon = 0; } /*virtual*/ T2XEvent::~T2XEvent() { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + int res = thePlugin->XEventDestruct(this); + + int *item; + while (mDlgItemArray.FetchItemAt(1, &item)) { + mDlgItemArray.RemoveItemsAt(1, 1); + delete item; + } } -/*virtual*/ void T2XEvent::Init(CResFile*) { +/*virtual*/ void T2XEvent::Init(CResFile* inResFile) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + int res = thePlugin->XEventInit(this, inResFile); } -/*virtual*/ unsigned long T2XEvent::GetID() { +/*virtual*/ DWORD T2XEvent::GetID() { + return mID; } -/*virtual*/ int T2XEvent::Start(T2TowerDoc*) { +/*virtual*/ BOOL T2XEvent::Start(T2TowerDoc* inDoc) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + int res = thePlugin->XEventStart(this, inDoc); + return res != 0; } -/*virtual*/ int T2XEvent::Exec(T2TowerDoc*) { +/*virtual*/ int T2XEvent::Exec(T2TowerDoc* inDoc) { + int res = 3; + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + + int r = thePlugin->XEventExec(this, inDoc); + if (r == 2) { + int *array = new int[mDlgItemArray.GetCount() + 1]; + array[0] = mDlgItemArray.GetCount(); + + LArrayIterator iterator(mDlgItemArray); + int *item; + for (int i = 0; i < array[0]; i++) { + mDlgItemArray.FetchItemAt(i + 1, &item); + array[i + 1] = *item; + } + + delete[] array; + + res = IsExclusive() ? 1 : 0; + } else { + res = r; + } + + return res; } -/*virtual*/ void T2XEvent::StopEvent(T2TowerDoc*) { +/*virtual*/ void T2XEvent::StopEvent(T2TowerDoc* inDoc) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + int res = thePlugin->XEventStop(this, inDoc); } -/*virtual*/ int T2XEvent::IsBeginTime(unsigned int) { +/*virtual*/ BOOL T2XEvent::IsBeginTime(unsigned int inTime) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + return thePlugin->XEventIsBeginTime(this, GetTowerDoc(), inTime); } -/*virtual*/ int T2XEvent::IsBeginTime(T2TowerDoc*, unsigned int) { +/*virtual*/ BOOL T2XEvent::IsBeginTime(T2TowerDoc* inDoc, unsigned int inTime) { + return false; } -/*virtual*/ int T2XEvent::IsBeginDay(int) { +/*virtual*/ BOOL T2XEvent::IsBeginDay(int inDay) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + return thePlugin->XEventIsBeginDay(this, GetTowerDoc(), inDay); } -/*virtual*/ int T2XEvent::IsBeginDay(T2TowerDoc*, int) { +/*virtual*/ BOOL T2XEvent::IsBeginDay(T2TowerDoc* inDoc, int inDay) { + return false; } -/*virtual*/ void T2XEvent::Write(T2Archive&) { +/*virtual*/ void T2XEvent::Write(T2Archive& inArchive) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + thePlugin->XEventWrite(this, inArchive); } -/*virtual*/ void T2XEvent::Read(T2Archive&) { +/*virtual*/ void T2XEvent::Read(T2Archive& inArchive) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + thePlugin->XEventRead(this, inArchive); } unsigned int T2XEvent::GetRefCon() { + return mRefCon; } -void T2XEvent::SetRefCon(unsigned int) { +void T2XEvent::SetRefCon(unsigned int inRefCon) { + mRefCon = inRefCon; } -void T2XEvent::SetDialogItems(int, int, int* const, int, CString&) { +void T2XEvent::SetDialogItems(int inItem1, int inItem2, int* const inItemArray, int inItem4, CString& inText) { + mDlgItem1 = inItem1; + mDlgItem2 = inItem2; + + int *item; + + while (mDlgItemArray.FetchItemAt(1, &item)) { + mDlgItemArray.RemoveItemsAt(1, 1); + delete item; + } + + for (int i = 0; i < inItemArray[0]; i++) { + item = new int; + *item = inItemArray[i + 1]; + mDlgItemArray.Add(&item); + } + + mDlgItem4 = inItem4; + mDlgText = inText; } -/*virtual*/ unsigned int T2XEvent::DialogHook(T2EventDialog*, unsigned int, T2TowerDoc*) { +/*virtual*/ unsigned int T2XEvent::DialogHook(T2EventDialog* inDialog, unsigned int inResult, T2TowerDoc* inDoc) { + T2WorldPlugin *thePlugin = ((T2WorldPlugin *) GetWorldDef()->GetPlugin()); + return thePlugin->XEventDlgHook(this, inDoc, inDialog, inResult); } |