-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmenu.cpp
More file actions
168 lines (138 loc) · 2.97 KB
/
Copy pathmenu.cpp
File metadata and controls
168 lines (138 loc) · 2.97 KB
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
// Menu.cpp
//
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include "def.h"
#include "resource.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "button.h"
#include "menu.h"
#include "text.h"
#include "misc.h"
/////////////////////////////////////////////////////////////////////////////
#define MARGMENU 0
static short table_button_icon[] =
{
24, // go
40, // stop
32, // mange
30, // carry
31, // depose
22, // abat
27, // roc
28, // cultive
19, // build1 (cabane)
25, // build2 (couveuse)
35, // build3 (laboratoire)
61, // build4 (mine)
59, // build5 (usine)
101, // build6 (t�l�porteur)
20, // mur
26, // palis
42, // abat n
43, // roc n
23, // pont
33, // tour
34, // boit
39, // labo
54, // fleur
55, // fleur n
41, // dynamite
58, // bateau
60, // djeep
64, // drapeau
62, // extrait du fer
65, // fabrique jeep
63, // fabrique mine
83, // fabrique disciple
100, // repeat
107, // qarmure
106, // fabarmure
};
void GetText(int rank, char *pBuffer, int lgBuffer)
{
LoadString(TX_ACTION_GO+rank, pBuffer, lgBuffer);
}
void GetErr(int rank, char *pBuffer, int lgBuffer)
{
LoadString(TX_ERROR_MISC+rank, pBuffer, lgBuffer);
}
/////////////////////////////////////////////////////////////////////////////
CMenu::CMenu()
{
m_nbButtons = 0;
m_selRank = -1;
}
CMenu::~CMenu()
{
}
void CMenu::Delete()
{
m_nbButtons = 0;
m_selRank = -1;
}
BOOL CMenu::TreatEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
POINT pos;
if ( m_nbButtons == 0 ) return FALSE;
pos = ConvLongToPos(lParam);
switch( message )
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
if ( MouseDown(pos) ) return TRUE;
break;
case WM_MOUSEMOVE:
if ( MouseMove(pos) ) return TRUE;
break;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
if ( MouseUp(pos) ) return TRUE;
break;
}
return FALSE;
}
int CMenu::Detect(POINT pos)
{
int rank;
if ( pos.x < m_pos.x || pos.x > m_pos.x+m_dim.x ||
pos.y < m_pos.y || pos.y > m_pos.y+m_dim.y ) return -1;
rank = (pos.y-m_pos.y)/(DIMBUTTONY+MARGMENU);
rank += ((pos.x-m_pos.x)/(DIMBUTTONX+MARGMENU))*m_nbCel.y;
if ( rank >= m_nbButtons ) return -1;
return rank;
}
BOOL CMenu::MouseDown(POINT pos)
{
return FALSE;
}
BOOL CMenu::MouseMove(POINT pos)
{
m_mousePos = pos;
m_selRank = Detect(pos);
if ( pos.x < m_pos.x-(DIMBUTTONX+MARGMENU) ||
pos.x > m_pos.x+m_dim.x+(DIMBUTTONX+MARGMENU) ||
pos.y < m_pos.y-(DIMBUTTONY+MARGMENU) ||
pos.y > m_pos.y+m_dim.y+(DIMBUTTONY+MARGMENU) )
{
Delete(); // enl�ve le menu si souris trop loin !
}
return FALSE;
}
BOOL CMenu::MouseUp(POINT pos)
{
m_mousePos = pos;
m_selRank = Detect(pos);
return FALSE;
}
void CMenu::Message()
{
if ( m_selRank != -1 )
{
PostMessage(m_hWnd, WM_BUTTON0+m_selRank, 0, 0);
}
}