From c0c336500955a23e344651e5412c9d9d441ef4ee Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 28 Jun 2023 22:22:32 +0100 Subject: first pass of T2DLL --- src/T2DLL/T2XEvent.cpp | 115 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 99 insertions(+), 16 deletions(-) (limited to 'src/T2DLL/T2XEvent.cpp') 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); } -- cgit v1.2.3