Subversion Repositories Kolibri OS

Rev

Rev 4481 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1805 yogev_ezra 1
#include "kosSyst.h"
2
#include "KosFile.h"
3
#include "gfxdef.h"
4
#include "mainWnd.h"
5
#include "lang.h"
6
 
7
 
8
//
9
RGB bmPMButton[] = {
10
	0xCCCCCC, 0xCCCCCC, 0x000000, 0x000000, 0xCCCCCC, 0xCCCCCC,
11
	0xCCCCCC, 0xCCCCCC, 0x000000, 0x000000, 0xCCCCCC, 0xCCCCCC,
12
	0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
13
	0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
14
	0xCCCCCC, 0xCCCCCC, 0x000000, 0x000000, 0xCCCCCC, 0xCCCCCC,
15
	0xCCCCCC, 0xCCCCCC, 0x000000, 0x000000, 0xCCCCCC, 0xCCCCCC,
16
};
17
 
18
 
19
//
20
#if LANG == RUS
21
char mainWndTitle[] = "PHARAON's CRYPT";
22
char mainWndCopyright[] = "(C) MMVI by Rabid Rabbit";
23
char mainWndMenuStart[] = "1. Ќ з вм ЁЈаг";
24
char mainWndMenuExit[] = "2. ‚л室";
25
char mainWndMenuLevel[] = "Ќ з «м­л© га®ўҐ­м - %U";
26
#else
27
char mainWndTitle[] = "PHARAON's CRYPT";
28
char mainWndCopyright[] = "(C) MMVI by Rabid Rabbit";
29
char mainWndMenuStart[] = "1. Start game";
30
char mainWndMenuExit[] = "2. Exit";
31
char mainWndMenuLevel[] = "Starting level - %U";
32
#endif
33
//
34
CKosBitmap mainWndFace;
35
//
36
Word mcx, mcy;
37
 
38
#define BT_SIZE_X_MINUS		4
39
#define BT_SIZE_X_PLUS		5
40
 
41
//
42
int MainWndLoop()
43
{
44
	Byte keyCode;
45
	Dword buttonID;
46
	int result;
47
	static bool firstTime = true;
48
 
49
	//
50
	startGameLevel = maxGameLevel;
51
	//
52
	if ( firstTime )
53
	{
54
		//
55
		mainWndFace.GetSize( mcx, mcy );
56
		//
57
		firstTime = false;
58
		//
59
		DrawMainWindow();
60
	}
61
	//
62
	kos_ChangeWindow( -1, -1, mcx + 1, mcy + 21 );
63
	//
64
	for ( result = MW_NONE; result == MW_NONE; )
65
	{
66
		switch( kos_WaitForEvent() )
67
		{
68
		case 1:
69
			DrawMainWindow();
70
			break;
71
 
72
		case 2:
73
			if ( kos_GetKey( keyCode ) )
74
			{
75
				//
76
				switch ( keyCode )
77
				{
78
				case '1':
79
					result = MW_START_GAME;
80
					break;
81
 
82
				case '2':
83
					result = MW_EXIT_APP;
84
					break;
85
 
86
				default:
87
					break;
88
				}
89
			}
90
			break;
91
 
92
		case 3:
93
			if ( kos_GetButtonID( buttonID ) )
94
			{
95
				//
96
				switch ( buttonID )
97
				{
98
				//
99
				case BT_SIZE_X_MINUS:
100
					if ( --startGameLevel < 1 )
101
						startGameLevel = 1;
102
					else
103
						DrawMainWindow();
104
					break;
105
 
106
				//
107
				case BT_SIZE_X_PLUS:
108
					if ( ++startGameLevel > maxGameLevel )
109
						startGameLevel = maxGameLevel;
110
					else
111
						DrawMainWindow();
112
					break;
113
 
114
				//
115
				default:
116
					break;
117
				}
118
			}
119
 
120
		default:
121
			break;
122
		}
123
	}
124
	// кнопки
125
	kos_DefineButton(
126
		0, 0,
127
		0, 0,
128
		BT_SIZE_X_MINUS + 0x80000000,
129
 
130
		);
131
	//
132
	kos_DefineButton(
133
		0, 0,
134
		0, 0,
135
		BT_SIZE_X_PLUS + 0x80000000,
136
 
137
		);
138
	//
139
	return result;
140
}
141
 
142
 
143
// полная отрисовка главного окна программы (1)
144
void DrawMainWindow()
145
{
146
	char line[64];
147
 
148
	//
149
	kos_WindowRedrawStatus( WRS_BEGIN );
150
	// окно
151
	kos_DefineAndDrawWindow(
152
		WNDLEFT, WNDTOP,
153
		mcx + 1, mcy + 21,
154
		0, 0x0,
155
		0, WNDHEADCOLOUR,
156
		WNDHEADCOLOUR
157
		);
158
	// заголовок окна
159
	kos_WriteTextToWindow(
160
		4, 7,
161
		0x10, WNDTITLECOLOUR,
162
		mainWndTitle, sizeof(mainWndTitle)-1
163
		);
164
	//
165
	mainWndFace.Draw( 1, 21 );
166
	// первая строка
167
	kos_WriteTextToWindow(
168
		8, 32,
169
		0, 0x0,
170
		mainWndMenuStart, sizeof(mainWndMenuStart)-1
171
		);
172
	// вторая строка
173
	kos_WriteTextToWindow(
174
		8, 48,
175
		0, 0x0,
176
		mainWndMenuExit, sizeof(mainWndMenuExit)-1
177
		);
178
	// третья строка
179
	sprintf( line, mainWndMenuLevel, startGameLevel);
180
	kos_WriteTextToWindow(
181
		8, 64,
182
		0, 0x0,
183
		line, strlen( line )
184
		);
185
	// кнопки
186
	kos_DefineButton(
187
		mcx - 29, 64,
188
		12, 12,
189
		BT_SIZE_X_MINUS,
190
		0xCCCCCC
191
		);
192
	//
193
	kos_PutImage( bmPMButton + 12, 6, 2, mcx - 29 + 3, 69 );
194
	//
195
	kos_DefineButton(
196
		mcx - 16, 64,
197
		12, 12,
198
		BT_SIZE_X_PLUS,
199
		0xCCCCCC
200
		);
201
	//
202
	kos_PutImage( bmPMButton, 6, 6, mcx - 16 + 3, 67 );
203
	// копирайт
204
	kos_WriteTextToWindow(
205
		8, mcy - 16 + 21,
206
		0, 0x000066,
207
		mainWndCopyright, sizeof(mainWndCopyright)-1
208
		);
209
	//
210
	kos_WindowRedrawStatus( WRS_END );
211
}