summaryrefslogtreecommitdiff
path: root/src/T2TowerMainView.h
blob: 0bccd8f2b6702239e6eaf8674f5e0bc69a8674b5 (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
#pragma once
#include "common.h"
#include "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 {
    DECLARE_MESSAGE_MAP()
    DECLARE_DYNCREATE(T2TowerMainView)

public:
    T2TowerMainView();
    virtual ~T2TowerMainView();
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext &dc) const;
    virtual BOOL PreTranslateMessage(MSG *pMsg);
    virtual void OnInitialUpdate() {}

	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:
    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);

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

    afx_msg int OnCreate(LPCREATESTRUCT lpcs);
    afx_msg void OnDestroy();
    void AdjustWorldBounds();
    void ClearUpdateRect();
    void x42AC1B();
    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);

    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);
    afx_msg void OnCommand10000to10010(UINT nCmd);

    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    void HandleLButtonDown(CPoint inPt);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    void HandleLButtonUp(CPoint inPt);

    afx_msg void OnUpdateDebugGrid(CCmdUI *pCmdUI);
    afx_msg void OnDebugGrid();

    void x42E366(int inType);

    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    void HandleRButtonDown(CPoint inPt);
    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
    void HandleRButtonUp(CPoint inPt);

    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);
};