diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2EventItem.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2EventItem.cpp')
-rw-r--r-- | src/T2DLL/T2EventItem.cpp | 166 |
1 files changed, 150 insertions, 16 deletions
diff --git a/src/T2DLL/T2EventItem.cpp b/src/T2DLL/T2EventItem.cpp index 3a83cbb..302752f 100644 --- a/src/T2DLL/T2EventItem.cpp +++ b/src/T2DLL/T2EventItem.cpp @@ -1,79 +1,213 @@ +#include "CResFile.h" +#include "T2Archive.h" +#include "T2DlgItemAnimation.h" +#include "T2EventDialog.h" #include "T2EventItem.h" +#include "T2SoundPlayer.h" +#include "T2TowerDoc.h" +#include "T2TowerEvent.h" +#include "T2TowerMainView.h" +#include "T2WorldDef.h" -T2EventItem::T2EventItem(T2TowerEvent*, CResFile*, int) { +T2EventItem::T2EventItem(T2TowerEvent* inTowerEvent, CResFile* inResFile, int inSubID) { + mSubID = inSubID; + mTowerEvent = inTowerEvent; + mStatus = 0; + + *inResFile >> mLevelBit; + + int v; + *inResFile >> v; + mExclusive = (v != 0); + + *inResFile >> v; + mCycleDay = max(1, v); + + *inResFile >> mBeginTime; + *inResFile >> mEndTime; + + mOriginalDef = this; + _4 = 0; } -T2EventItem::T2EventItem(T2TowerEvent*, int, int, int, int, int, int) { +T2EventItem::T2EventItem(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit, BOOL inExclusive, int inCycleDay, int inBeginTime, int inEndTime) { + mSubID = inSubID; + mTowerEvent = inTowerEvent; + mLevelBit = inLevelBit; + mExclusive = inExclusive; + mCycleDay = inCycleDay; + mBeginTime = inBeginTime; + mEndTime = inEndTime; + + mStatus = 0; + mOriginalDef = NULL; + _4 = 0; } -T2EventItem::T2EventItem(T2EventItem*, int) { +T2EventItem::T2EventItem(T2EventItem* inItem, int inSubID) { + mSubID = inSubID; + + mTowerEvent = inItem->mTowerEvent; + mLevelBit = inItem->mLevelBit; + mExclusive = inItem->mExclusive; + mCycleDay = inItem->mCycleDay; + mBeginTime = inItem->mBeginTime; + mEndTime = inItem->mEndTime; + + mStatus = 0; + mOriginalDef = inItem; + _4 = 0; } /*virtual*/ T2EventItem::~T2EventItem() { } -/*virtual*/ void T2EventItem::Init(T2TowerDoc*) { +/*virtual*/ void T2EventItem::Init(T2TowerDoc* inDoc) { } -/*virtual*/ int T2EventItem::Start(T2TowerDoc*) { +/*virtual*/ BOOL T2EventItem::Start(T2TowerDoc* inDoc) { + return true; } -/*virtual*/ int T2EventItem::ReStart(T2TowerDoc*) { +/*virtual*/ int T2EventItem::ReStart(T2TowerDoc* inDoc) { + return 1; } -/*virtual*/ void T2EventItem::StopEvent(T2TowerDoc*) { +/*virtual*/ void T2EventItem::StopEvent(T2TowerDoc* inDoc) { } T2WorldDef* T2EventItem::GetWorldDef() { + return mTowerEvent->mWorldDef; } T2TowerDoc* T2EventItem::GetTowerDoc() const { + return mTowerEvent->mDocument; } T2TowerEvent* T2EventItem::GetTowerEvent() { + return mTowerEvent; } int T2EventItem::GetLevelBit() { + return mLevelBit; } -int T2EventItem::IsExclusive() { +BOOL T2EventItem::IsExclusive() { + return mExclusive; } int T2EventItem::GetCycleDay() { + return mCycleDay; } int T2EventItem::GetBeginTime() { + return mBeginTime; } -void T2EventItem::SetBeginTime(int) { +void T2EventItem::SetBeginTime(int inTime) { + mBeginTime = inTime; } int T2EventItem::GetEndTime() { + return mEndTime; } -/*virtual*/ int T2EventItem::IsBeginTime(unsigned int) { +/*virtual*/ BOOL T2EventItem::IsBeginTime(unsigned int inTime) { + return (mBeginTime == inTime); } -/*virtual*/ int T2EventItem::IsBeginDay(int) { +/*virtual*/ BOOL T2EventItem::IsBeginDay(int inDay) { + return (inDay % mCycleDay) == 0; } int T2EventItem::GetStatus() { + return mStatus; } -void T2EventItem::SetStatus(int) { +void T2EventItem::SetStatus(int inStatus) { + mStatus = inStatus; } T2EventItem* T2EventItem::GetOriginalDef() { + return mOriginalDef; } -/*virtual*/ unsigned int T2EventItem::DoDialog(T2TowerDoc*, int, int, int, const char*) { +/*virtual*/ unsigned int T2EventItem::DoDialog(T2TowerDoc* inDoc, int inDlgResID, int inAnimResID, int inAnimUnk, const char* inText) { + T2WorldDef *theWorldDef = GetWorldDef(); + inDoc->GetTowerMainView()->tmv_vf154(); + inDoc->towerDoc_vf290(true); + + unsigned int result = 0; + + while (result == 0) { + T2EventDialog *theDialog = T2EventDialog::Show(this, inDoc, theWorldDef->mModuleHandle, inDlgResID); + mEventDialog = theDialog; + SetupDialog(theDialog); + + CWnd *theLabel = theDialog->GetDlgItem(100); + if (theLabel) { + CString str = inText; + str = "l" + str; + theLabel->SetWindowText(str); + } + + T2DlgItemAnimation *animation = (T2DlgItemAnimation *) theDialog->GetDlgItem(101); + if (animation) + animation->SetAnimation(theWorldDef->mModuleHandle, inAnimResID, inAnimUnk); + + result = theDialog->DoModal(); + result = DialogHook(theDialog, result, inDoc); + } + + inDoc->towerDoc_vf290(false); + inDoc->GetTowerMainView()->tmv_vf150(); + return result; } -/*virtual*/ void T2EventItem::DoAlert(T2TowerDoc*, CString&, int) { +/*virtual*/ void T2EventItem::DoAlert(T2TowerDoc* inDoc, CString& inText, int inSoundID) { + T2WorldDef *theWorldDef = GetWorldDef(); + inDoc->GetTowerMainView()->tmv_vf154(); + inDoc->towerDoc_vf290(true); + + T2EventDialog *theDialog = T2EventDialog::Show(this, inDoc, theWorldDef->mModuleHandle, 8000); + + CWnd *theLabel = theDialog->GetDlgItem(100); + if (theLabel) { + theLabel->SetWindowText("l" + inText); + } + + T2DlgItemAnimation *animation = (T2DlgItemAnimation *) theDialog->GetDlgItem(101); + if (animation) + animation->SetAnimation(theWorldDef->mModuleHandle, 9000, 0); + + if (inSoundID) { + inDoc->mSoundPlayer->FadeOut(); + inDoc->mSoundPlayer->AddSound("EVENT:Voice", SoundPriority_1, inSoundID, theWorldDef->mModuleHandle); + inDoc->mSoundPlayer->Play("EVENT:Voice", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100); + } + + theDialog->DoModal(); + + if (inSoundID) { + inDoc->mSoundPlayer->Stop("EVENT:Voice"); + inDoc->mSoundPlayer->DeleteSound("EVENT:Voice"); + inDoc->mSoundPlayer->FadeIn(); + } + + inDoc->towerDoc_vf294(); + inDoc->GetTowerMainView()->tmv_vf150(); } -/*virtual*/ void T2EventItem::Write(T2Archive&) { +/*virtual*/ void T2EventItem::Write(T2Archive& inArchive) { + unsigned int len = 0; + inArchive << len; } -/*virtual*/ void T2EventItem::Read(T2Archive&) { +/*virtual*/ void T2EventItem::Read(T2Archive& inArchive) { + unsigned char tmp; + unsigned int len; + inArchive >> len; + + for (unsigned int i = 0; i < len; i++) + inArchive >> tmp; } |