Subversion Repositories Kolibri OS

Rev

Rev 1805 | Go to most recent revision | Details | Compare with Previous | 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
4481 hidnplayr 21
char mainWndTitle[] = "PHARAON's CRYPT\0";
1805 yogev_ezra 22
char mainWndCopyright[] = "(C) MMVI by Rabid Rabbit";
23
char mainWndMenuStart[] = "1. Ќ з вм ЁЈаг";
24
char mainWndMenuExit[] = "2. ‚л室";
25
char mainWndMenuLevel[] = "Ќ з «м­л© га®ўҐ­м - %U";
26
#else
4481 hidnplayr 27
char mainWndTitle[] = "PHARAON's CRYPT\0";
1805 yogev_ezra 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,
4481 hidnplayr 154
		0x14, 0x0,
1805 yogev_ezra 155
		0, WNDHEADCOLOUR,
4481 hidnplayr 156
		mainWndTitle
1805 yogev_ezra 157
		);
158
	// заголовок окна
4481 hidnplayr 159
	  kos_ChangeWindowCaption(mainWndTitle);
1805 yogev_ezra 160
	mainWndFace.Draw( 1, 21 );
161
	// первая строка
162
	kos_WriteTextToWindow(
163
		8, 32,
164
		0, 0x0,
165
		mainWndMenuStart, sizeof(mainWndMenuStart)-1
166
		);
167
	// вторая строка
168
	kos_WriteTextToWindow(
169
		8, 48,
170
		0, 0x0,
171
		mainWndMenuExit, sizeof(mainWndMenuExit)-1
172
		);
173
	// третья строка
174
	sprintf( line, mainWndMenuLevel, startGameLevel);
175
	kos_WriteTextToWindow(
176
		8, 64,
177
		0, 0x0,
178
		line, strlen( line )
179
		);
180
	// кнопки
181
	kos_DefineButton(
182
		mcx - 29, 64,
183
		12, 12,
184
		BT_SIZE_X_MINUS,
185
		0xCCCCCC
186
		);
187
	//
188
	kos_PutImage( bmPMButton + 12, 6, 2, mcx - 29 + 3, 69 );
189
	//
190
	kos_DefineButton(
191
		mcx - 16, 64,
192
		12, 12,
193
		BT_SIZE_X_PLUS,
194
		0xCCCCCC
195
		);
196
	//
197
	kos_PutImage( bmPMButton, 6, 6, mcx - 16 + 3, 67 );
198
	// копирайт
199
	kos_WriteTextToWindow(
200
		8, mcy - 16 + 21,
201
		0, 0x000066,
202
		mainWndCopyright, sizeof(mainWndCopyright)-1
203
		);
204
	//
205
	kos_WindowRedrawStatus( WRS_END );
206
}