branch | noai |
changeset 9574 | 698395509d12 |
parent 9545 | 179f651eb116 |
child 9599 | 949374e83b78 |
9573:fa56261c7142 | 9574:698395509d12 |
---|---|
1 /* $Id$ */ |
1 /* $Id$ */ |
2 |
|
3 /** @file settings_gui.cpp */ |
|
2 |
4 |
3 #include "stdafx.h" |
5 #include "stdafx.h" |
4 #include "openttd.h" |
6 #include "openttd.h" |
5 #include "currency.h" |
7 #include "currency.h" |
6 #include "functions.h" |
8 #include "functions.h" |
350 * Q: disasters |
352 * Q: disasters |
351 * R: area restructuring (0 = permissive, 2 = hostile) |
353 * R: area restructuring (0 = permissive, 2 = hostile) |
352 */ |
354 */ |
353 static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /* |
355 static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /* |
354 A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/ |
356 A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/ |
355 {2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, //easy |
357 {2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy |
356 {4, 1, 1, 2, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, //medium |
358 {4, 1, 1, 2, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium |
357 {7, 0, 2, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, //hard |
359 {7, 0, 2, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard |
358 }; |
360 }; |
359 |
361 |
360 void SetDifficultyLevel(int mode, GameOptions *gm_opt) |
362 void SetDifficultyLevel(int mode, GameOptions *gm_opt) |
361 { |
363 { |
362 int i; |
364 int i; |
391 enum { |
393 enum { |
392 GAMEDIFF_WND_TOP_OFFSET = 45, |
394 GAMEDIFF_WND_TOP_OFFSET = 45, |
393 GAMEDIFF_WND_ROWSIZE = 9 |
395 GAMEDIFF_WND_ROWSIZE = 9 |
394 }; |
396 }; |
395 |
397 |
396 // Temporary holding place of values in the difficulty window until 'Save' is clicked |
398 /* Temporary holding place of values in the difficulty window until 'Save' is clicked */ |
397 static GameOptions _opt_mod_temp; |
399 static GameOptions _opt_mod_temp; |
398 // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) |
400 // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) |
399 #define DIFF_INGAME_DISABLED_BUTTONS 0x383E |
401 #define DIFF_INGAME_DISABLED_BUTTONS 0x383E |
400 |
402 |
401 static void GameDifficultyWndProc(Window *w, WindowEvent *e) |
403 static void GameDifficultyWndProc(Window *w, WindowEvent *e) |
455 const GameSettingData *info; |
457 const GameSettingData *info; |
456 int x, y; |
458 int x, y; |
457 uint btn, dis; |
459 uint btn, dis; |
458 int16 val; |
460 int16 val; |
459 |
461 |
460 // Don't allow clients to make any changes |
462 /* Don't allow clients to make any changes */ |
461 if (_networking && !_network_server) |
463 if (_networking && !_network_server) |
462 return; |
464 return; |
463 |
465 |
464 x = e->we.click.pt.x - 5; |
466 x = e->we.click.pt.x - 5; |
465 if (!IS_INT_INSIDE(x, 0, 21)) // Button area |
467 if (!IS_INT_INSIDE(x, 0, 21)) // Button area |
467 |
469 |
468 y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET; |
470 y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET; |
469 if (y < 0) |
471 if (y < 0) |
470 return; |
472 return; |
471 |
473 |
472 // Get button from Y coord. |
474 /* Get button from Y coord. */ |
473 btn = y / (GAMEDIFF_WND_ROWSIZE + 2); |
475 btn = y / (GAMEDIFF_WND_ROWSIZE + 2); |
474 if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9) |
476 if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9) |
475 return; |
477 return; |
476 |
478 |
477 // Clicked disabled button? |
479 /* Clicked disabled button? */ |
478 dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0; |
480 dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0; |
479 |
481 |
480 if (HASBIT(dis, btn)) |
482 if (HASBIT(dis, btn)) |
481 return; |
483 return; |
482 |
484 |