summaryrefslogtreecommitdiff
path: root/src/T2DLL/WalkerDlg.cpp
blob: fdd7e635a5fa2fd67547b1a49d230cd0a6858a6b (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
#include "CT2App.h"
#include "T2CtrlPalette.h"
#include "T2DlgItem.h"
#include "T2MainWindow.h"
#include "T2MWControl.h"
#include "T2TowerDoc.h"
#include "T2WorldDef.h"
#include "WalkerDlg.h"

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

WalkerDlg::WalkerDlg() {
    mDeleteOnClose = true;
}

/*virtual*/ WalkerDlg::~WalkerDlg() {
}

void WalkerDlg::Setup(T2TowerDoc *inDoc, HINSTANCE inInstance, CWnd *inParentWnd, const POINT &inPt, T2ImageObj *inImageObj) {
    mDocument = inDoc;

    T2DLGTEMPLATE tmpl;
    tmpl.resID = 7030;
    tmpl.pt = inPt;
    tmpl.moduleHandle = inInstance;

    Realize(inParentWnd, &tmpl, inDoc, inImageObj, inDoc->mWorldDef->GetPalette(), false, inParentWnd, 202, true);
    ShowWindow(SW_HIDE);
}

void WalkerDlg::Revert() {
    if (mFC != 1) {
        T2DlgItem *item = GetT2DlgItem(107 + mFC);
        item->SetValue(0);

        mFC = 1;

        item = GetT2DlgItem(107 + mFC);
        item->SetValue(1);
    }
}

void WalkerDlg::Save() {
    T2CtrlPalette *theCtrlPalette = ((CT2App *) AfxGetApp())->mMainWindow->mCtrlPalette;
    if (!theCtrlPalette)
        return;

    T2MWControl *theSlider = theCtrlPalette->mSliderControl;
    if (!theSlider)
        return;

    int value = 0;
    if (mFC != 0)
        value = 7 - mFC;
    theSlider->SetData(value);

    if (mFC == 0)
        mDocument->towerDoc_vf14C(-1);
    else
        mDocument->towerDoc_vf14C(mFC);
}

/*virtual*/ void WalkerDlg::OnT2Create() {
    mFC = mDocument->towerDoc_vf148();
    if (mFC == -1)
        mFC = 0;

    T2DlgItem *item = GetT2DlgItem(107 + mFC);
    item->SetValue(1);
}

/*virtual*/ int WalkerDlg::OnT2DialogCommand(UINT cmd, long data) {
    int result = 1;
    WORD w = LOWORD(cmd);

    if (w >= 107 && w <= 113) {
        T2DlgItem *item = GetT2DlgItem(107 + mFC);
        item->SetValue(0);

        mFC = w - 107;

        item = GetT2DlgItem(w);
        item->SetValue(1);
    } else {
        result = T2Dialog::OnT2DialogCommand(cmd, data);
    }

    return result;
}