summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2EquipDef.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2EquipDef.cpp187
1 files changed, 187 insertions, 0 deletions
diff --git a/src/T2DLL/T2EquipDef.cpp b/src/T2DLL/T2EquipDef.cpp
new file mode 100644
index 0000000..bb694d6
--- /dev/null
+++ b/src/T2DLL/T2EquipDef.cpp
@@ -0,0 +1,187 @@
+#include "CResFile.h"
+#include "T2Archive.h"
+#include "T2BitImage.h"
+#include "T2Equip.h"
+#include "T2EquipDef.h"
+#include "T2EquipPlugin.h"
+#include "T2ImageObj.h"
+#include "T2InfoDialog.h"
+#include "T2People.h"
+#include "T2PeopleLinkIterator.h"
+#include "T2TowerDoc.h"
+#include "T2WorldDef.h"
+#include "UT2Coordinate.h"
+
+T2EquipDef::T2EquipDef(DWORD type, T2PluginSpecifier& specifier, CResFile* resFile, T2WorldDef* worldDef, T2EquipPlugin* plugin)
+ : T2ToolDef(type, specifier, resFile, worldDef, plugin)
+{
+ unsigned long tmp;
+
+ *resFile >> mCapacity;
+ *resFile >> mStress;
+ *resFile >> tmp;
+
+ for (int j = 0; j < mValiationCount; j++) {
+ *resFile >> m154;
+ *resFile >> tmp;
+ *resFile >> tmp;
+ }
+
+ *resFile >> mOutSpan;
+ *resFile >> mInSpan;
+ *resFile >> mNumOfInMoney;
+
+ for (int i = 0; i < mNumOfInMoney; i++) {
+ if (i < 4) {
+ *resFile >> mInMoney[i];
+ } else {
+ int moneyTmp;
+ *resFile >> moneyTmp;
+ }
+ }
+
+ m124 = NULL;
+ m128 = NULL;
+ m130 = NULL;
+ m140 = 0;
+
+ if (mNumOfInMoney > 4)
+ mNumOfInMoney = 4;
+
+ try {
+ int outViewKind = worldDef->GetOutViewKind() + 1001;
+ m124 = new T2BitImage(mModuleHandle, outViewKind, 1);
+ mImageObj->AddObject(mModuleHandle, outViewKind, m124);
+ } catch (int e) {
+ }
+
+ try {
+ m128 = new T2BitImage(mModuleHandle, 1010, 1);
+ mImageObj->AddObject(mModuleHandle, 1010, m128);
+ } catch (int e) {
+ }
+
+ try {
+ m130 = new T2BitImage(mModuleHandle, 1100, 1);
+ mImageObj->AddObject(mModuleHandle, 1100, m130);
+ } catch (int e) {
+ }
+
+ mWordDefArray = MakeWordDefArray();
+}
+
+/*virtual*/ T2EquipDef::~T2EquipDef() {
+ if (m124)
+ delete m124;
+ if (m128)
+ delete m128;
+ if (m130)
+ delete m130;
+
+ if (mWordDefArray)
+ delete mWordDefArray;
+}
+
+/*virtual*/ int T2EquipDef::InitObject(T2Object* object) {
+ object->SetUsed(true);
+ ((T2Equip *) object)->mEquipType = GetEquipType();
+ ((T2Equip *) object)->mCapacity = mCapacity;
+ ((T2Equip *) object)->mAttribute = mAttribute;
+ ((T2Equip *) object)->SetEquipDef(this);
+ return true;
+}
+
+/*virtual*/ int T2EquipDef::ClickProc(T2TowerDoc*, RECT*, unsigned int&) {
+ return 1;
+}
+
+/*virtual*/ int T2EquipDef::GetDestructPartProc(int, POINT, POINT, T2Equip*) {
+ return -1;
+}
+
+/*virtual*/ AREACHECKCODE T2EquipDef::AreaCheck(T2TowerDoc*, RECT&, unsigned int, int) {
+ return AreaCheckCode_0;
+}
+
+/*virtual*/ PARTCODE T2EquipDef::GetPartFromPoint(T2TowerDoc* towerDoc, T2Equip* equip, POINT pt, int*) {
+ UT2Coordinate::QDToUnit(pt, towerDoc->mZoomLevel);
+ if (PtInRect(&equip->mArea, pt))
+ return PartCode_2;
+ else
+ return PartCode_0;
+}
+
+/*virtual*/ void T2EquipDef::BuildFinish(T2TowerDoc* towerDoc, T2Equip* equip) {
+ towerDoc->towerDoc_vf170()->CalcOptionObj(towerDoc, equip);
+}
+
+/*virtual*/ unsigned long T2EquipDef::OptionProc(T2TowerDoc*, T2Equip*, void*) {
+ return 0;
+}
+
+/*virtual*/ void T2EquipDef::DebugInfo(CWnd&, CListCtrl&, T2Equip*) {
+}
+
+/*virtual*/ int T2EquipDef::FingerToolProc(T2TowerDoc*, T2Equip*, const POINT&, MOUSEEVENT) {
+ return 0;
+}
+
+/*virtual*/ T2InfoDialog* T2EquipDef::ShowInfoDialog(T2TowerDoc* towerDoc, T2Equip* equip) {
+ CRect rect;
+ AfxGetMainWnd()->GetWindowRect(rect);
+
+ T2DLGTEMPLATE tmpl;
+ tmpl.pt = rect.CenterPoint();
+ tmpl.moduleHandle = mModuleHandle;
+ tmpl.resID = GetInfoDialogID(towerDoc, equip);
+
+ T2InfoDialog *dialog = ConstructInfoDialog(equip);
+ dialog->Realize(this, &tmpl, towerDoc, mImageObj, NULL, true, NULL, 0, 1);
+ return dialog;
+}
+
+/*virtual*/ int T2EquipDef::GetInfoDialogID(T2TowerDoc*, const T2Equip*) const {
+ return 1000;
+}
+
+/*virtual*/ T2InfoDialog* T2EquipDef::ConstructInfoDialog(T2Equip* equip) {
+ return new T2InfoDialog(equip);
+}
+
+/*virtual*/ void T2EquipDef::DrawPeople(T2TowerDoc* towerDoc, T2Equip* equip) {
+ //T2People *people = (T2People *) equip;
+ //T2PeopleLinkIterator iter(people);
+ //T2People *i;
+ //while (iter.Next(&i))
+ // i->Draw(towerDoc, people);
+ // TODO: which subclass is this...?
+}
+
+int T2EquipDef::GetInMoney(int i) {
+ int cost = 0;
+ if (i < mNumOfInMoney)
+ cost = mInMoney[i];
+ return cost;
+}
+
+/*virtual*/ void T2EquipDef::LoadExtraData(T2Archive& archive, T2TowerDoc*, T2HaveOutViewObject*) {
+ int len;
+ archive >> len;
+
+ for (int i = 0; i < len; i++) {
+ unsigned char b;
+ archive >> b;
+ }
+}
+
+/*virtual*/ void T2EquipDef::SaveExtraData(T2Archive& archive, T2HaveOutViewObject*) {
+ int len = 0;
+ archive << len;
+}
+
+T2WordDefArray* T2EquipDef::MakeWordDefArray() {
+ return 0; // TODO
+}
+
+void T2EquipDef::GetWords(T2People*, CString&) const {
+}