summaryrefslogtreecommitdiff
path: root/src/DbgEquipInfo.cpp
blob: b9c448719ecaa7fb414d67199e5ce5ca570ac976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "DbgEquipInfo.h"
#include "LArray.h"
#include "T2CrossEquipArray.h"
#include "T2EquipDef.h"
#include "T2FloorInfo.h"
#include "T2Mover.h"
#include "T2Tenant.h"
#include "T2TowerDoc.h"
#include "T2TowerMainView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

DbgEquipInfo::DbgEquipInfo(CWnd *pParentWnd)
    : CDialog(160, pParentWnd)
{
}

/*virtual*/ void DbgEquipInfo::DoDataExchange(CDataExchange *pDX) {
    CWnd::DoDataExchange(pDX);
    DDX_Control(pDX, 1014, mButton);
    DDX_Control(pDX, 1013, mList1);
    DDX_Control(pDX, 1011, mStatic1);
    DDX_Control(pDX, 1012, mStatic2);
    DDX_Control(pDX, 1010, mList2);
}

void DbgEquipInfo::SetEquip(T2Equip *inEquip) {
    mEquip = inEquip;
}

void DbgEquipInfo::SetDocument(T2TowerDoc *inDoc) {
    mDocument = inDoc;
}

void DbgEquipInfo::SetTowerMainView(T2TowerMainView *inView) {
    mTowerMainView = inView;
}

BEGIN_MESSAGE_MAP(DbgEquipInfo, CDialog)
    ON_NOTIFY(NM_CLICK, 1010, OnListClick)
END_MESSAGE_MAP()

/*virtual*/ BOOL DbgEquipInfo::OnInitDialog() {
    CDialog::OnInitDialog();

    CString str;

    mStatic1.SetWindowText(mEquip->GetEquipDef()->mStr48);
    str.Format("%d", mEquip->mEquipID);
    mStatic2.SetWindowText(str);

    RECT rect;
    mList2.GetClientRect(&rect);

    int width = rect.right;
    mList2.InsertColumn(0, "ID", LVCFMT_LEFT, width / 3);
    mList2.InsertColumn(1, "Type", LVCFMT_LEFT, (width * 2) / 3);

    LArrayIterator iterator(*mEquip->mCEArray);
    unsigned int id;
    int index = 0;

    while (iterator.Next(&id)) {
        if (id >= 1000) {
            str.Format("%d", id);
            mList2.InsertItem(index, str);

            T2Tenant *tenant = mDocument->mFloorInfo->GetTenant(id);
            if (tenant)
                mList2.SetItemText(index, 1, tenant->GetEquipDef()->mStr48);
            else
                mList2.SetItemText(index, 1, "UNKNOWN");
        } else if (id >= 1) {
            str.Format("%d", id);
            mList2.InsertItem(index, str);

            T2Mover *mover = mDocument->mFloorInfo->GetMover(id);
            if (mover)
                mList2.SetItemText(index, 1, mover->GetEquipDef()->mStr48);
            else
                mList2.SetItemText(index, 1, "UNKNOWN");
        }
        index++;
    }

    mEquip->GetEquipDef()->DebugInfo(mButton, mList1, mEquip);
    return true;
}

void DbgEquipInfo::OnListClick(NMHDR *inHdr, LRESULT *outResult) {
    int item = mList2.GetNextItem(-1, LVNI_SELECTED);
    if (item != -1)
        mTowerMainView->SendMessage(WM_COMMAND, MAKELONG(10000 + item, 0), 0);
    *outResult = 0;
}