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