Rev 3 | Rev 14 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 11 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | int frame_count; |
34 | int frame_count; |
35 | int array_index; |
35 | int array_index; |
36 | bool is_success; |
36 | bool is_success; |
37 | char *endptr; |
37 | char *endptr; |
38 | wchar_t app_pathname[MAX_PATH]; |
38 | wchar_t app_pathname[MAX_PATH]; |
39 | wchar_t |
39 | wchar_t font_pathname[MAX_PATH]; |
40 | struct _stat fileinfo; |
40 | struct _stat fileinfo; |
41 | HACCEL hAccelerators; |
41 | HACCEL hAccelerators; |
42 | ACCEL accelerators[] = |
42 | ACCEL accelerators[] = |
43 | { |
43 | { |
44 | {FVIRTKEY | FCONTROL, L'O', MENUID_GAME_LOAD}, |
44 | {FVIRTKEY | FCONTROL, L'O', MENUID_GAME_LOAD}, |
Line 118... | Line 118... | ||
118 | Config_Load (); |
118 | Config_Load (); |
119 | 119 | ||
120 | // read texts in the right language, if such a translation exists |
120 | // read texts in the right language, if such a translation exists |
121 | is_success = false; |
121 | is_success = false; |
122 | GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, os_language, WCHAR_SIZEOF (os_language)); |
122 | GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, os_language, WCHAR_SIZEOF (os_language)); |
123 | swprintf_s (language_file, WCHAR_SIZEOF (language_file), L"data/languages/%s.ini", os_language); |
- | |
124 | is_success = LocalizedTexts_Init ( |
123 | is_success = LocalizedTexts_Init (L"%s/data/languages/%s.ini", app_path, os_language); |
125 | 124 | ||
126 | // fallback to English if language not found |
125 | // fallback to English if language not found |
127 | if (!is_success) |
126 | if (!is_success) |
128 | is_success = LocalizedTexts_Init (L"data/languages/English.ini"); |
127 | is_success = LocalizedTexts_Init (L"%s/data/languages/English.ini", app_path); |
129 | 128 | ||
130 | // consistency check: don't go further if texts aren't available |
129 | // consistency check: don't go further if texts aren't available |
131 | if (!is_success) |
130 | if (!is_success) |
132 | return (-1); // bomb out on error |
131 | return (-1); // bomb out on error |
133 | 132 | ||
Line 227... | Line 226... | ||
227 | } |
226 | } |
228 | ShowWindow (hMainWnd, nCmdShow); |
227 | ShowWindow (hMainWnd, nCmdShow); |
229 | 228 | ||
230 | // display the splash screen |
229 | // display the splash screen |
231 | memset ((void *) &splash_bmp, 0, sizeof (splash_bmp)); |
230 | memset ((void *) &splash_bmp, 0, sizeof (splash_bmp)); |
232 | hSplashBmp = |
231 | hSplashBmp = W32LoadImage (L"%s/data/splash.bmp", app_path); // load the splash bitmap |
233 | GetObject (hSplashBmp, sizeof (splash_bmp), (void *) &splash_bmp); // get a structure containing its size (among others) |
232 | GetObject (hSplashBmp, sizeof (splash_bmp), (void *) &splash_bmp); // get a structure containing its size (among others) |
234 | hdcMem = CreateCompatibleDC (NULL); // create a device context compatible with the screen |
233 | hdcMem = CreateCompatibleDC (NULL); // create a device context compatible with the screen |
235 | hbmTmp = SelectBitmap (hdcMem, hSplashBmp); // select our bitmap to use in it |
234 | hbmTmp = SelectBitmap (hdcMem, hSplashBmp); // select our bitmap to use in it |
236 | hdc = BeginPaint (hMainWnd, &ps); // begin painting on the main window |
235 | hdc = BeginPaint (hMainWnd, &ps); // begin painting on the main window |
237 | GetClientRect (hMainWnd, &rect); |
236 | GetClientRect (hMainWnd, &rect); |
Line 246... | Line 245... | ||
246 | menu_info.cbSize = sizeof (MENUINFO); |
245 | menu_info.cbSize = sizeof (MENUINFO); |
247 | menu_info.fMask = MIM_STYLE; |
246 | menu_info.fMask = MIM_STYLE; |
248 | GetMenuInfo (GetMenu (hMainWnd), &menu_info); // get current style |
247 | GetMenuInfo (GetMenu (hMainWnd), &menu_info); // get current style |
249 | menu_info.dwStyle |= MNS_MODELESS; // add the "modeless" flag |
248 | menu_info.dwStyle |= MNS_MODELESS; // add the "modeless" flag |
250 | SetMenuInfo (GetMenu (hMainWnd), &menu_info); // and send it back |
249 | SetMenuInfo (GetMenu (hMainWnd), &menu_info); // and send it back |
251 | - | ||
252 | // temporarily add the files for the font we'll use to the system resources |
- | |
253 | AddFontResourceEx (L"data/fonts/papyrus.ttf", FR_PRIVATE, 0); |
- | |
254 | 250 | ||
255 | // load status icons, bitmaps and texts |
251 | // load status icons, bitmaps and texts |
256 | handlestatus[HANDLESTATUS_AVAILABLE].icon = |
252 | handlestatus[HANDLESTATUS_AVAILABLE].icon = W32LoadIcon (L"%s/data/icons/available.ico", app_path); |
257 | handlestatus[HANDLESTATUS_AVAILABLE].bitmap = |
253 | handlestatus[HANDLESTATUS_AVAILABLE].bitmap = W32LoadImage (L"%s/data/status/available.bmp", app_path); |
258 | handlestatus[HANDLESTATUS_AVAILABLE].text = LOCALIZE (L"Opponents_StatusAvailable"); |
254 | handlestatus[HANDLESTATUS_AVAILABLE].text = LOCALIZE (L"Opponents_StatusAvailable"); |
259 | handlestatus[HANDLESTATUS_INGAME].icon = |
255 | handlestatus[HANDLESTATUS_INGAME].icon = W32LoadIcon (L"%s/data/icons/ingame.ico", app_path); |
260 | handlestatus[HANDLESTATUS_INGAME].bitmap = |
256 | handlestatus[HANDLESTATUS_INGAME].bitmap = W32LoadImage (L"%s/data/status/ingame.bmp", app_path); |
261 | handlestatus[HANDLESTATUS_INGAME].text = LOCALIZE (L"Opponents_StatusInGame"); |
257 | handlestatus[HANDLESTATUS_INGAME].text = LOCALIZE (L"Opponents_StatusInGame"); |
262 | handlestatus[HANDLESTATUS_INSIMULATION].icon = |
258 | handlestatus[HANDLESTATUS_INSIMULATION].icon = W32LoadIcon (L"%s/data/icons/insimulation.ico", app_path); |
263 | handlestatus[HANDLESTATUS_INSIMULATION].bitmap = |
259 | handlestatus[HANDLESTATUS_INSIMULATION].bitmap = W32LoadImage (L"%s/data/status/insimulation.bmp", app_path); |
264 | handlestatus[HANDLESTATUS_INSIMULATION].text = LOCALIZE (L"Opponents_StatusInSimulation"); |
260 | handlestatus[HANDLESTATUS_INSIMULATION].text = LOCALIZE (L"Opponents_StatusInSimulation"); |
265 | handlestatus[HANDLESTATUS_INTOURNAMENT].icon = |
261 | handlestatus[HANDLESTATUS_INTOURNAMENT].icon = W32LoadIcon (L"%s/data/icons/intournament.ico", app_path); |
266 | handlestatus[HANDLESTATUS_INTOURNAMENT].bitmap = |
262 | handlestatus[HANDLESTATUS_INTOURNAMENT].bitmap = W32LoadImage (L"%s/data/status/intournament.bmp", app_path); |
267 | handlestatus[HANDLESTATUS_INTOURNAMENT].text = LOCALIZE (L"Opponents_StatusInTournament"); |
263 | handlestatus[HANDLESTATUS_INTOURNAMENT].text = LOCALIZE (L"Opponents_StatusInTournament"); |
268 | handlestatus[HANDLESTATUS_EXAMININGAGAME].icon = |
264 | handlestatus[HANDLESTATUS_EXAMININGAGAME].icon = W32LoadIcon (L"%s/data/icons/examiningagame.ico", app_path); |
269 | handlestatus[HANDLESTATUS_EXAMININGAGAME].bitmap = |
265 | handlestatus[HANDLESTATUS_EXAMININGAGAME].bitmap = W32LoadImage (L"%s/data/status/examiningagame.bmp", app_path); |
270 | handlestatus[HANDLESTATUS_EXAMININGAGAME].text = LOCALIZE (L"Opponents_StatusExaminingAGame"); |
266 | handlestatus[HANDLESTATUS_EXAMININGAGAME].text = LOCALIZE (L"Opponents_StatusExaminingAGame"); |
271 | handlestatus[HANDLESTATUS_NOTOPENFORAMATCH].icon = |
267 | handlestatus[HANDLESTATUS_NOTOPENFORAMATCH].icon = W32LoadIcon (L"%s/data/icons/notopenforamatch.ico", app_path); |
272 | handlestatus[HANDLESTATUS_NOTOPENFORAMATCH].bitmap = |
268 | handlestatus[HANDLESTATUS_NOTOPENFORAMATCH].bitmap = W32LoadImage (L"%s/data/status/notopenforamatch.bmp", app_path); |
273 | handlestatus[HANDLESTATUS_NOTOPENFORAMATCH].text = LOCALIZE (L"Opponents_StatusNotOpenForAMatch"); |
269 | handlestatus[HANDLESTATUS_NOTOPENFORAMATCH].text = LOCALIZE (L"Opponents_StatusNotOpenForAMatch"); |
274 | handlestatus[HANDLESTATUS_INACTIVEORBUSY].icon = |
270 | handlestatus[HANDLESTATUS_INACTIVEORBUSY].icon = W32LoadIcon (L"%s/data/icons/inactiveorbusy.ico", app_path); |
275 | handlestatus[HANDLESTATUS_INACTIVEORBUSY].bitmap = |
271 | handlestatus[HANDLESTATUS_INACTIVEORBUSY].bitmap = W32LoadImage (L"%s/data/status/inactiveorbusy.bmp", app_path); |
276 | handlestatus[HANDLESTATUS_INACTIVEORBUSY].text = LOCALIZE (L"Opponents_StatusInactiveOrBusy"); |
272 | handlestatus[HANDLESTATUS_INACTIVEORBUSY].text = LOCALIZE (L"Opponents_StatusInactiveOrBusy"); |
277 | handlestatus[HANDLESTATUS_OFFLINE].icon = |
273 | handlestatus[HANDLESTATUS_OFFLINE].icon = W32LoadIcon (L"%s/data/icons/offline.ico", app_path); |
278 | handlestatus[HANDLESTATUS_OFFLINE].bitmap = |
274 | handlestatus[HANDLESTATUS_OFFLINE].bitmap = W32LoadImage (L"%s/data/status/offline.bmp", app_path); |
279 | handlestatus[HANDLESTATUS_OFFLINE].text = LOCALIZE (L"Opponents_StatusOffline"); |
275 | handlestatus[HANDLESTATUS_OFFLINE].text = LOCALIZE (L"Opponents_StatusOffline"); |
280 | 276 | ||
281 | // load fonts |
277 | // load the system fonts |
282 | hFontChat = CreateFont (17, 0, 0, 0, FW_DONTCARE, false, false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, |
278 | hFontChat = CreateFont (17, 0, 0, 0, FW_DONTCARE, false, false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, |
283 | CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Comic Sans MS"); |
279 | CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Comic Sans MS"); |
284 | 280 | ||
285 | // initialize renderer |
281 | // initialize renderer |
286 | if (!Render_Init ()) |
282 | if (!Render_Init ()) |
287 | return (-1); // bomb out on error |
283 | return (-1); // bomb out on error |
288 | 284 | ||
289 | // load sprites |
285 | // load sprites |
290 | larrow_spriteindex = Render_LoadSprite (L"data/sprites/arrow-left.*"); |
286 | larrow_spriteindex = Render_LoadSprite (L"%s/data/sprites/arrow-left.*", app_path); |
291 | rarrow_spriteindex = Render_LoadSprite (L"data/sprites/arrow-right.*"); |
287 | rarrow_spriteindex = Render_LoadSprite (L"%s/data/sprites/arrow-right.*", app_path); |
292 | chatbutton_spriteindex = Render_LoadSprite (L"data/sprites/chat.*"); |
288 | chatbutton_spriteindex = Render_LoadSprite (L"%s/data/sprites/chat.*", app_path); |
293 | gamesbutton_spriteindex = Render_LoadSprite (L"data/sprites/games.*"); |
289 | gamesbutton_spriteindex = Render_LoadSprite (L"%s/data/sprites/games.*", app_path); |
294 | peoplebutton_spriteindex = Render_LoadSprite (L"data/sprites/people.*"); |
290 | peoplebutton_spriteindex = Render_LoadSprite (L"%s/data/sprites/people.*", app_path); |
295 | sepia_spriteindex = Render_LoadSprite (L"data/sprites/sepia.*"); |
291 | sepia_spriteindex = Render_LoadSprite (L"%s/data/sprites/sepia.*", app_path); |
296 | for (array_index = 0; array_index < 12; array_index++) |
292 | for (array_index = 0; array_index < 12; array_index++) |
297 | spinner_spriteindex[array_index] = Render_LoadSprite (L"data/sprites/spinner-%d.png", array_index * 30); // spinning wheel |
293 | spinner_spriteindex[array_index] = Render_LoadSprite (L"%s/data/sprites/spinner-%d.png", app_path, array_index * 30); // spinning wheel |
298 | 294 | ||
- | 295 | // add our custom fonts to the list of available fonts for the duration of the process |
|
- | 296 | swprintf_s (font_pathname, WCHAR_SIZEOF (font_pathname), L"%s/data/fonts/papyrus.ttf", app_path); |
|
- | 297 | AddFontResourceEx (font_pathname, FR_PRIVATE, 0); |
|
299 | // load fonts |
298 | // load rendered fonts |
300 | arrow_fontindex = Render_LoadFont (L"Papyrus", 20, false, false); |
299 | arrow_fontindex = Render_LoadFont (L"Papyrus", 20, false, false); |
301 | chat_fontindex = Render_LoadFont (L"Papyrus", 24, false, false); |
300 | chat_fontindex = Render_LoadFont (L"Papyrus", 24, false, false); |
302 | players_fontindex = Render_LoadFont (L"Papyrus", 32, false, true); |
301 | players_fontindex = Render_LoadFont (L"Papyrus", 32, false, true); |
303 | centermsg_fontindex = Render_LoadFont (L"Papyrus", 48, false, true); |
302 | centermsg_fontindex = Render_LoadFont (L"Papyrus", 48, false, true); |
304 | 303 |