summaryrefslogtreecommitdiff
path: root/src/T2DLL/WalkerDlg.cpp
blob: 4c2c842e83459436eec6c7dbf0b593364cce98d3 (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 "T2.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 = T2_APP->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->SetWalkRate(-1);
    else
        mDocument->SetWalkRate(mFC);
}

/*virtual*/ void WalkerDlg::OnT2Create() {
    mFC = mDocument->GetWalkRate();
    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;
}