summaryrefslogtreecommitdiff
path: root/src/T2TowerMainView.h
blob: a91e867b87e8b6b00d6d0f1f54fdb5bbb66af24f (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#pragma once
#include "common.h"
#include "T2DLL/LAttachable.h"

enum {
    kTool0_Null = 0,
    kTool1_Tenant,
    kTool2_Mover,
    kTool3_OutObj,
    kTool4_Finger,
    kTool5_Hand
};

enum {
    kAnotherToolVar0 = 0,
    kAnotherToolVar1,
    kAnotherToolVar2,
    kAnotherToolVar3
};

enum {
    kScroll1 = 1,
    kScroll2,
    kScroll3,
    kScrollOptionMask = 0xFF,
    kScrollOpt2 = 0x100,
    kScrollOpt2Mask = 0xFF00,
    kScrollOpt3 = 0x10000,
    kScrollOpt3Mask = 0xFF0000,
};

class T2TowerMainView : public CView, public LAttachable {
protected:
    T2TowerMainView();
    DECLARE_DYNCREATE(T2TowerMainView)

public:
    virtual ~T2TowerMainView();
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext &dc) const;

    //{{AFX_VIRTUAL(T2TowerMainView)
    public:
    virtual BOOL PreTranslateMessage(MSG *pMsg);
    virtual void OnInitialUpdate() {}
    protected:
    virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
    virtual void OnDraw(CDC *pDC);
    virtual void OnUpdate(CView *pSender, LPARAM lHint, CObject *pHint);
    virtual void OnActivateView(BOOL bActivate, CView *pActivateView, CView *pDeactiveView);
    //}}AFX_VIRTUAL

public:
	virtual void tmv_vf110();
	virtual void DrawDebugGrid();
	virtual void CopySimulationImage(const RECT &inRect);
    void x42B484(CDC *pDC, const RECT &inRect);
	virtual void tmv_vf11C();
	virtual void tmv_vf120(); // DrawSimulation?
	virtual void Invalidate(BOOL inFlag);
	virtual void InvalUnitRect(const RECT &inRect, BOOL inFlag = false);
	virtual T2TowerDoc *GetTowerDoc();
	virtual void SetScrollV(int inV);
	virtual void SetScrollH(int inH);
	virtual void tmv_vf138(const POINT &inPt, unsigned int inCode);
	virtual void tmv_vf13C(int inX, int inY, unsigned int inCode);
	virtual void GetVisibleUnitRect(RECT &outRect) const;
    void HandToolClick(CPoint inPt);
    void HandToolDrag(CPoint inPt);
    void HandToolRelease(CPoint inPt);
	virtual void tmv_vf144();
	virtual void DoZoomIn(POINT inPt);
	virtual void DoZoomOut();
	virtual void UnhideToolSprite();
	virtual void HideToolSprite();
	virtual void CenterOnRectAndZoom(const RECT &inRect);
	virtual void CenterOnRect(const RECT *inRect);

	virtual BOOL tmv_vf160(POINT &outPt);

	T2TowerDoc *mDocument;

	// Represents the full world area in unit coordinates
	RECT mWorldBounds;

	// A buffer storing the entire tower
	T2BitImage *mImage;

	// Where the view is currently scrolled to
	POINT mScrollOffset;

	RECT m6C;
	POINT m7C;

	// An extra offset that will centre the image within the viewport, if the
	// viewport is larger than the world area
    POINT mImageOrigin;

	// The unit coordinates that are currently visible
	RECT mVisibleArea;

	RECT mUpdateRect1;
	RECT mUpdateRect2;
	RECT mSpriteUpdateRect;

	// The last point handled when clicking or dragging with the Hand tool
	CPoint mHandToolLastPos;

	// Which mouse buttons we consider to be held down
	UINT mPressedButtons;

	// Tracks how many times the tool-specific sprite has been hidden
	int mHideToolSpriteCount;

	BOOL mDC;
	POINT _E0;
	int mAnotherToolVar;
	int _EC;
	int mDebugMode;
	int mActiveTool;
	BOOL mIsDebugGrid;
	T2ToolDef *mActiveToolDef;
	int mToolSpriteIndex;
	CString mToolSpriteName;
	POINT _108;
	BOOL mSkipOffscreenDraw;
	unsigned int mDbgEquipID;
	T2Equip *mDbgEquip;
    POINT mNextScrollOffset;

	// Where the player initially clicked, in window coordinates
	CPoint mInitialClickPos;

protected:

    BOOL CreateToolSprite(BOOL inSkipShowing = false);
    BOOL DeleteToolSprite();

    void AdjustWorldBounds();
    void ClearUpdateRect();
    void x42AC1B();

    void DrawDebugBkgndInfo(CDC *pDC);
    void DrawDebugFloorInfoTenant(CDC *pDC, const RECT &inRect);
    void DrawDebugFloorInfoMover(CDC *pDC, const RECT &inRect);
    void DrawDebugFloorInfoRequest(CDC *pDC, const RECT &inRect);
    void DrawDebugEquip(CDC *pDC, const RECT &inRect);
    void x42CA08(const POINT &inPt);

    void HandleLButtonDown(CPoint inPt);
    void HandleLButtonUp(CPoint inPt);

    void x42E366(int inType);

    void HandleRButtonDown(CPoint inPt);
    void HandleRButtonUp(CPoint inPt);

    //{{AFX_MSG(T2TowerMainView)
    afx_msg int OnCreate(LPCREATESTRUCT lpcs);
    afx_msg void OnDestroy();
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnDebugNormalDisplay();
    afx_msg void OnUpdateDebugNormalDisplay(CCmdUI *pCmdUI);
    afx_msg void OnDebugBkgndInfo();
    afx_msg void OnUpdateDebugBkgndInfo(CCmdUI *pCmdUI);
    afx_msg void OnDebugFloorInfoTenant();
    afx_msg void OnUpdateDebugFloorInfoTenant(CCmdUI *pCmdUI);
    afx_msg void OnDebugFloorInfoMover();
    afx_msg void OnUpdateDebugFloorInfoMover(CCmdUI *pCmdUI);
    afx_msg void OnDebugFloorInfoRequest();
    afx_msg void OnUpdateDebugFloorInfoRequest(CCmdUI *pCmdUI);
    afx_msg void OnCommand10000to10010(UINT nCmd);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnUpdateDebugGrid(CCmdUI *pCmdUI);
    afx_msg void OnDebugGrid();
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnUpdateDebugDisplaySpeedMeasuring(CCmdUI *pCmdUI);
    afx_msg void OnDebugDisplaySpeedMeasuring();
    afx_msg void OnUpdateDebugOffscreenSpeedMeasuring(CCmdUI *pCmdUI);
    afx_msg void OnDebugOffscreenSpeedMeasuring();
    afx_msg void OnTimer(UINT nIDEvent);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};