changeset 2639 | eeaefdabfdfd |
parent 2631 | 2ed0eb408229 |
child 2703 | a969970a5245 |
2638:0811adaec525 | 2639:eeaefdabfdfd |
---|---|
84 bool found = false; |
84 bool found = false; |
85 |
85 |
86 for (i = 0; i < NUM_CARGO; ++i) { |
86 for (i = 0; i < NUM_CARGO; ++i) { |
87 if (lid->ac[i] > 0) { |
87 if (lid->ac[i] > 0) { |
88 // Add a comma between each item. |
88 // Add a comma between each item. |
89 if (found) { *p++ = ','; *p++ = ' '; } |
89 if (found) { |
90 *p++ = ','; |
|
91 *p++ = ' '; |
|
92 } |
|
90 found = true; |
93 found = true; |
91 |
94 |
92 // If the accepted value is less than 8, show it in 1/8:ths |
95 // If the accepted value is less than 8, show it in 1/8:ths |
93 if (lid->ac[i] < 8) { |
96 if (lid->ac[i] < 8) { |
94 int32 argv[2]; |
97 int32 argv[2]; |
99 p = GetString(p, _cargoc.names_s[i]); |
102 p = GetString(p, _cargoc.names_s[i]); |
100 } |
103 } |
101 } |
104 } |
102 } |
105 } |
103 |
106 |
104 if (found) |
107 if (found) DrawStringMultiCenter(140, 76, BindCString(buf), 276); |
105 DrawStringMultiCenter(140, 76, BindCString(buf), 276); |
|
106 } |
108 } |
107 |
109 |
108 if (lid->td.build_date != 0) { |
110 if (lid->td.build_date != 0) { |
109 SetDParam(0,lid->td.build_date); |
111 SetDParam(0,lid->td.build_date); |
110 DrawStringCentered(140,71, STR_BUILD_DATE, 0); |
112 DrawStringCentered(140,71, STR_BUILD_DATE, 0); |
219 " Chris Sawyer - For an amazing game!" |
221 " Chris Sawyer - For an amazing game!" |
220 }; |
222 }; |
221 |
223 |
222 static void AboutWindowProc(Window *w, WindowEvent *e) |
224 static void AboutWindowProc(Window *w, WindowEvent *e) |
223 { |
225 { |
224 switch(e->event) { |
226 switch (e->event) { |
225 case WE_CREATE: /* Set up window counter and start position of scroller */ |
227 case WE_CREATE: /* Set up window counter and start position of scroller */ |
226 WP(w, scroller_d).counter = 0; |
228 WP(w, scroller_d).counter = 0; |
227 WP(w, scroller_d).height = w->height - 40; |
229 WP(w, scroller_d).height = w->height - 40; |
228 break; |
230 break; |
229 case WE_PAINT: { |
231 case WE_PAINT: { |
290 0x79E,0x7A5 | PALETTE_TO_GREEN,0x7AC | PALETTE_TO_RED,0x7B3,0x7BA,0x7C1 | PALETTE_TO_RED,0x7C8 | PALETTE_TO_PALE_GREEN,0x7CF | PALETTE_TO_YELLOW,0x7D6 | PALETTE_TO_RED |
292 0x79E,0x7A5 | PALETTE_TO_GREEN,0x7AC | PALETTE_TO_RED,0x7B3,0x7BA,0x7C1 | PALETTE_TO_RED,0x7C8 | PALETTE_TO_PALE_GREEN,0x7CF | PALETTE_TO_YELLOW,0x7D6 | PALETTE_TO_RED |
291 }; |
293 }; |
292 |
294 |
293 static void BuildTreesWndProc(Window *w, WindowEvent *e) |
295 static void BuildTreesWndProc(Window *w, WindowEvent *e) |
294 { |
296 { |
295 switch(e->event) { |
297 switch (e->event) { |
296 case WE_PAINT: { |
298 case WE_PAINT: { |
297 int x,y; |
299 int x,y; |
298 int i, count; |
300 int i, count; |
299 |
301 |
300 DrawWindowWidgets(w); |
302 DrawWindowWidgets(w); |
306 y = 54; |
308 y = 54; |
307 do { |
309 do { |
308 DrawSprite(_tree_sprites[i], x, y); |
310 DrawSprite(_tree_sprites[i], x, y); |
309 x += 35; |
311 x += 35; |
310 if (!(++i & 3)) { |
312 if (!(++i & 3)) { |
311 x -= 35*4; |
313 x -= 35 * 4; |
312 y += 47; |
314 y += 47; |
313 } |
315 } |
314 } while (--count); |
316 } while (--count); |
315 } break; |
317 } break; |
316 |
318 |
317 case WE_CLICK: { |
319 case WE_CLICK: { |
318 int wid; |
320 int wid = e->click.widget; |
319 |
321 |
320 switch(wid=e->click.widget) { |
322 switch (wid) { |
321 case 0: |
323 case 0: |
322 ResetObjectToPlace(); |
324 ResetObjectToPlace(); |
323 return; |
325 break; |
326 |
|
324 case 3: case 4: case 5: case 6: |
327 case 3: case 4: case 5: case 6: |
325 case 7: case 8: case 9: case 10: |
328 case 7: case 8: case 9: case 10: |
326 case 11:case 12: case 13: case 14: |
329 case 11:case 12: case 13: case 14: |
327 if ( (uint)(wid-3) >= (uint)WP(w,tree_d).count) |
330 if (wid - 3 >= WP(w,tree_d).count) break; |
328 return; |
|
329 |
331 |
330 if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, 1, NULL)) |
332 if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, 1, NULL)) |
331 _tree_to_plant = WP(w,tree_d).base + wid - 3; |
333 _tree_to_plant = WP(w,tree_d).base + wid - 3; |
332 break; |
334 break; |
333 |
335 |
460 { WIDGETS_END}, |
462 { WIDGETS_END}, |
461 }; |
463 }; |
462 |
464 |
463 static void ErrmsgWndProc(Window *w, WindowEvent *e) |
465 static void ErrmsgWndProc(Window *w, WindowEvent *e) |
464 { |
466 { |
465 switch(e->event) { |
467 switch (e->event) { |
466 case WE_PAINT: |
468 case WE_PAINT: |
467 COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
469 COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
468 DrawWindowWidgets(w); |
470 DrawWindowWidgets(w); |
469 COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
471 COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
470 if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) { |
472 if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) { |
496 238); |
498 238); |
497 } |
499 } |
498 break; |
500 break; |
499 |
501 |
500 case WE_MOUSELOOP: |
502 case WE_MOUSELOOP: |
501 if (_right_button_down) |
503 if (_right_button_down) DeleteWindow(w); |
502 DeleteWindow(w); |
504 break; |
503 break; |
505 |
504 case WE_4: |
506 case WE_4: |
505 if (!--_errmsg_duration) |
507 if (--_errmsg_duration == 0) DeleteWindow(w); |
506 DeleteWindow(w); |
508 break; |
507 break; |
509 |
508 case WE_DESTROY: { |
510 case WE_DESTROY: |
509 SetRedErrorSquare(0); |
511 SetRedErrorSquare(0); |
510 _switch_mode_errorstr = INVALID_STRING_ID; |
512 _switch_mode_errorstr = INVALID_STRING_ID; |
511 break; |
513 break; |
512 } |
|
513 |
514 |
514 case WE_KEYPRESS: |
515 case WE_KEYPRESS: |
515 if (e->keypress.keycode == WKC_SPACE) { |
516 if (e->keypress.keycode == WKC_SPACE) { |
516 // Don't continue. |
517 // Don't continue. |
517 e->keypress.cont = false; |
518 e->keypress.cont = false; |
617 }; |
618 }; |
618 |
619 |
619 |
620 |
620 static void TooltipsWndProc(Window *w, WindowEvent *e) |
621 static void TooltipsWndProc(Window *w, WindowEvent *e) |
621 { |
622 { |
622 |
623 switch (e->event) { |
623 switch(e->event) { |
624 case WE_PAINT: |
624 case WE_PAINT: { |
625 GfxFillRect(0, 0, w->width - 1, w->height - 1, 0); |
625 GfxFillRect(0, 0, w->width - 1, w->height - 1, 0); |
626 GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44); |
626 GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44); |
627 DrawStringMultiCenter((w->width >> 1), (w->height >> 1) - 5, WP(w,tooltips_d).string_id, 197); |
627 DrawStringMultiCenter((w->width>>1), (w->height>>1)-5, WP(w,tooltips_d).string_id, 197); |
628 break; |
628 break; |
629 |
629 } |
630 case WE_MOUSELOOP: |
630 case WE_MOUSELOOP: |
631 if (!_right_button_down) DeleteWindow(w); |
631 if (!_right_button_down) |
632 break; |
632 DeleteWindow(w); |
|
633 break; |
|
634 } |
633 } |
635 } |
634 } |
636 |
635 |
637 void GuiShowTooltips(StringID string_id) |
636 void GuiShowTooltips(StringID string_id) |
638 { |
637 { |
639 char buffer[512]; |
638 char buffer[512]; |
640 Window *w; |
639 Window *w; |
641 int right,bottom; |
640 int right,bottom; |
642 int x,y; |
641 int x,y; |
643 |
642 |
644 if (string_id == 0) |
643 if (string_id == 0) return; |
645 return; |
|
646 |
644 |
647 w = FindWindowById(WC_TOOLTIPS, 0); |
645 w = FindWindowById(WC_TOOLTIPS, 0); |
648 if (w != NULL) { |
646 if (w != NULL) { |
649 if (WP(w,tooltips_d).string_id == string_id) |
647 if (WP(w,tooltips_d).string_id == string_id) |
650 return; |
648 return; |
939 return false; |
937 return false; |
940 } |
938 } |
941 |
939 |
942 void HandleEditBox(Window *w, int wid) |
940 void HandleEditBox(Window *w, int wid) |
943 { |
941 { |
944 if (HandleCaret(&WP(w, querystr_d).text)) |
942 if (HandleCaret(&WP(w, querystr_d).text)) InvalidateWidget(w, wid); |
945 InvalidateWidget(w, wid); |
|
946 } |
943 } |
947 |
944 |
948 void DrawEditBox(Window *w, int wid) |
945 void DrawEditBox(Window *w, int wid) |
949 { |
946 { |
950 const Widget *wi = w->widget + wid; |
947 const Widget *wi = w->widget + wid; |
1010 } |
1007 } |
1011 HandleEditBox(w, 5); |
1008 HandleEditBox(w, 5); |
1012 } break; |
1009 } break; |
1013 |
1010 |
1014 case WE_KEYPRESS: { |
1011 case WE_KEYPRESS: { |
1015 switch(HandleEditBoxKey(w, 5, e)) { |
1012 switch (HandleEditBoxKey(w, 5, e)) { |
1016 case 1: // Return |
1013 case 1: // Return |
1017 goto press_ok; |
1014 goto press_ok; |
1018 case 2: // Escape |
1015 case 2: // Escape |
1019 DeleteWindow(w); |
1016 DeleteWindow(w); |
1020 break; |
1017 break; |
1238 |
1235 |
1239 switch (e->event) { |
1236 switch (e->event) { |
1240 case WE_CREATE: { /* Set up OPENTTD button */ |
1237 case WE_CREATE: { /* Set up OPENTTD button */ |
1241 o_dir.type = FIOS_TYPE_DIRECT; |
1238 o_dir.type = FIOS_TYPE_DIRECT; |
1242 switch (_saveload_mode) { |
1239 switch (_saveload_mode) { |
1243 case SLD_SAVE_GAME: case SLD_LOAD_GAME: |
1240 case SLD_SAVE_GAME: |
1241 case SLD_LOAD_GAME: |
|
1244 ttd_strlcpy(&o_dir.name[0], _path.save_dir, sizeof(o_dir.name)); |
1242 ttd_strlcpy(&o_dir.name[0], _path.save_dir, sizeof(o_dir.name)); |
1245 break; |
1243 break; |
1246 case SLD_SAVE_SCENARIO: case SLD_LOAD_SCENARIO: |
1244 |
1245 case SLD_SAVE_SCENARIO: |
|
1246 case SLD_LOAD_SCENARIO: |
|
1247 ttd_strlcpy(&o_dir.name[0], _path.scenario_dir, sizeof(o_dir.name)); |
1247 ttd_strlcpy(&o_dir.name[0], _path.scenario_dir, sizeof(o_dir.name)); |
1248 break; |
1248 break; |
1249 |
|
1249 default: |
1250 default: |
1250 ttd_strlcpy(&o_dir.name[0], _path.personal_dir, sizeof(o_dir.name)); |
1251 ttd_strlcpy(&o_dir.name[0], _path.personal_dir, sizeof(o_dir.name)); |
1251 } |
1252 } |
1252 break; |
1253 break; |
1253 } |
1254 } |
1306 case 6: { /* Click the listbox */ |
1307 case 6: { /* Click the listbox */ |
1307 int y = (e->click.pt.y - w->widget[6].top - 1) / 10; |
1308 int y = (e->click.pt.y - w->widget[6].top - 1) / 10; |
1308 char *name; |
1309 char *name; |
1309 const FiosItem *file; |
1310 const FiosItem *file; |
1310 |
1311 |
1311 if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) |
1312 if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return; |
1312 return; |
|
1313 |
1313 |
1314 file = _fios_list + y; |
1314 file = _fios_list + y; |
1315 |
1315 |
1316 if ((name = FiosBrowseTo(file)) != NULL) { |
1316 name = FiosBrowseTo(file); |
1317 if (name != NULL) { |
|
1317 if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) { |
1318 if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) { |
1318 _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD; |
1319 _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD; |
1319 |
1320 |
1320 SetFiosType(file->type); |
1321 SetFiosType(file->type); |
1321 ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
1322 ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name)); |
1472 WP(w,querystr_d).text.buf = _edit_str_buf; |
1473 WP(w,querystr_d).text.buf = _edit_str_buf; |
1473 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1474 UpdateTextBufferSize(&WP(w, querystr_d).text); |
1474 |
1475 |
1475 // pause is only used in single-player, non-editor mode, non-menu mode. It |
1476 // pause is only used in single-player, non-editor mode, non-menu mode. It |
1476 // will be unpaused in the WE_DESTROY event handler. |
1477 // will be unpaused in the WE_DESTROY event handler. |
1477 if(_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) |
1478 if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { |
1478 DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
1479 DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
1480 } |
|
1479 |
1481 |
1480 BuildFileList(); |
1482 BuildFileList(); |
1481 |
1483 |
1482 ResetObjectToPlace(); |
1484 ResetObjectToPlace(); |
1483 } |
1485 } |
1498 { WWT_SCROLLBAR, RESIZE_LRB, 7, 245, 256, 26, 307, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1500 { WWT_SCROLLBAR, RESIZE_LRB, 7, 245, 256, 26, 307, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1499 { WWT_RESIZEBOX, RESIZE_LRTB, 7, 245, 256, 308, 319, 0x0, STR_RESIZE_BUTTON}, |
1501 { WWT_RESIZEBOX, RESIZE_LRTB, 7, 245, 256, 308, 319, 0x0, STR_RESIZE_BUTTON}, |
1500 { WIDGETS_END}, |
1502 { WIDGETS_END}, |
1501 }; |
1503 }; |
1502 |
1504 |
1503 static void SelectScenarioWndProc(Window *w, WindowEvent *e) { |
1505 static void SelectScenarioWndProc(Window* w, WindowEvent* e) |
1506 { |
|
1504 const int list_start = 45; |
1507 const int list_start = 45; |
1505 switch(e->event) { |
1508 |
1509 switch (e->event) { |
|
1506 case WE_PAINT: |
1510 case WE_PAINT: |
1507 { |
1511 { |
1508 int y,pos; |
1512 int y,pos; |
1509 const FiosItem *item; |
1513 const FiosItem *item; |
1510 |
1514 |
1640 } |
1644 } |
1641 |
1645 |
1642 // p1 player to set to, p2 is -1 or +1 (down/up) |
1646 // p1 player to set to, p2 is -1 or +1 (down/up) |
1643 static int32 ClickChangePlayerCheat(int32 p1, int32 p2) |
1647 static int32 ClickChangePlayerCheat(int32 p1, int32 p2) |
1644 { |
1648 { |
1645 while(p1 >= 0 && p1 < MAX_PLAYERS) { |
1649 while (p1 >= 0 && p1 < MAX_PLAYERS) { |
1646 if (_players[p1].is_active) { |
1650 if (_players[p1].is_active) { |
1647 _local_player = p1; |
1651 _local_player = p1; |
1648 MarkWholeScreenDirty(); |
1652 MarkWholeScreenDirty(); |
1649 return _local_player; |
1653 return _local_player; |
1650 } |
1654 } |
1651 p1 += p2; |
1655 p1 += p2; |
1655 } |
1659 } |
1656 |
1660 |
1657 // p1 -1 or +1 (down/up) |
1661 // p1 -1 or +1 (down/up) |
1658 static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
1662 static int32 ClickChangeClimateCheat(int32 p1, int32 p2) |
1659 { |
1663 { |
1660 if(p1==-1) p1 = 3; |
1664 if (p1 == -1) p1 = 3; |
1661 if(p1==4) p1 = 0; |
1665 if (p1 == 4) p1 = 0; |
1662 _opt.landscape = p1; |
1666 _opt.landscape = p1; |
1663 GfxLoadSprites(); |
1667 GfxLoadSprites(); |
1664 MarkWholeScreenDirty(); |
1668 MarkWholeScreenDirty(); |
1665 return _opt.landscape; |
1669 return _opt.landscape; |
1666 } |
1670 } |
1671 static int32 ClickChangeDateCheat(int32 p1, int32 p2) |
1675 static int32 ClickChangeDateCheat(int32 p1, int32 p2) |
1672 { |
1676 { |
1673 YearMonthDay ymd; |
1677 YearMonthDay ymd; |
1674 ConvertDayToYMD(&ymd, _date); |
1678 ConvertDayToYMD(&ymd, _date); |
1675 |
1679 |
1676 if((ymd.year==0 && p2==-1) || (ymd.year==170 && p2==1)) return _cur_year; |
1680 if ((ymd.year == 0 && p2 == -1) || (ymd.year == 170 && p2 == 1)) return _cur_year; |
1677 |
1681 |
1678 SetDate(ConvertYMDToDay(_cur_year + p2, ymd.month, ymd.day)); |
1682 SetDate(ConvertYMDToDay(_cur_year + p2, ymd.month, ymd.day)); |
1679 EnginesMonthlyLoop(); |
1683 EnginesMonthlyLoop(); |
1680 SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
1684 SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); |
1681 return _cur_year; |
1685 return _cur_year; |
1759 |
1763 |
1760 extern void DrawPlayerIcon(int p, int x, int y); |
1764 extern void DrawPlayerIcon(int p, int x, int y); |
1761 |
1765 |
1762 static void CheatsWndProc(Window *w, WindowEvent *e) |
1766 static void CheatsWndProc(Window *w, WindowEvent *e) |
1763 { |
1767 { |
1764 switch(e->event) { |
1768 switch (e->event) { |
1765 case WE_PAINT: { |
1769 case WE_PAINT: { |
1766 int clk = WP(w,def_d).data_1; |
1770 int clk = WP(w,def_d).data_1; |
1767 const CheatEntry *ce = &_cheats_ui[0]; |
|
1768 int32 val; |
|
1769 int x, y; |
1771 int x, y; |
1770 int i; |
1772 int i; |
1771 |
1773 |
1772 DrawWindowWidgets(w); |
1774 DrawWindowWidgets(w); |
1773 |
1775 |
1774 DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, 350); |
1776 DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, 350); |
1775 |
1777 |
1776 x=0; |
1778 x = 0; |
1777 y=45; |
1779 y = 45; |
1778 |
1780 |
1779 for(i=0; i!=lengthof(_cheats_ui); i++,ce++) { |
1781 for (i = 0; i != lengthof(_cheats_ui); i++) { |
1782 const CheatEntry* ce = &_cheats_ui[i]; |
|
1783 |
|
1780 DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, x + 5, y + 2); |
1784 DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, x + 5, y + 2); |
1781 |
1785 |
1782 if (ce->type == CE_BOOL) { |
1786 if (ce->type == CE_BOOL) { |
1783 DrawFrameRect(x+20, y+1, x+30+9, y+9, (*(bool*)ce->variable) ? 6 : 4, (*(bool*)ce->variable) ? FR_LOWERED : 0); |
1787 DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, (*(bool*)ce->variable) ? 6 : 4, (*(bool*)ce->variable) ? FR_LOWERED : 0); |
1784 SetDParam(0, *(bool*)ce->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
1788 SetDParam(0, *(bool*)ce->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
1785 |
|
1786 } else if (ce->type == CE_CLICK) { |
1789 } else if (ce->type == CE_CLICK) { |
1787 DrawFrameRect(x+20, y+1, x+30+9, y+9, 0, (WP(w,def_d).data_1 == i*2+1) ? FR_LOWERED : 0); |
1790 DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, 0, (WP(w,def_d).data_1 == i * 2 + 1) ? FR_LOWERED : 0); |
1788 if (i == 0) |
1791 if (i == 0) { |
1789 SetDParam64(0, (int64) 10000000); |
1792 SetDParam64(0, 10000000); |
1790 else |
1793 } else { |
1791 SetDParam(0, false); |
1794 SetDParam(0, false); |
1792 |
1795 } |
1793 } else { |
1796 } else { |
1794 DrawFrameRect(x+20, y+1, x+20+9, y+9, 3, clk == i*2+1 ? FR_LOWERED : 0); |
1797 int32 val; |
1795 DrawFrameRect(x+30, y+1, x+30+9, y+9, 3, clk == i*2+2 ? FR_LOWERED : 0); |
1798 |
1796 DrawStringCentered(x+25, y+1, STR_6819, 0); |
1799 DrawFrameRect(x + 20, y + 1, x + 20 + 9, y + 9, 3, clk == i * 2 + 1 ? FR_LOWERED : 0); |
1797 DrawStringCentered(x+35, y+1, STR_681A, 0); |
1800 DrawFrameRect(x + 30, y + 1, x + 30 + 9, y + 9, 3, clk == i * 2 + 2 ? FR_LOWERED : 0); |
1801 DrawStringCentered(x + 25, y + 1, STR_6819, 0); |
|
1802 DrawStringCentered(x + 35, y + 1, STR_681A, 0); |
|
1798 |
1803 |
1799 val = ReadCE(ce); |
1804 val = ReadCE(ce); |
1800 |
1805 |
1801 // set correct string for switch climate cheat |
1806 // set correct string for switch climate cheat |
1802 if(ce->str==STR_CHEAT_SWITCH_CLIMATE) |
1807 if (ce->str == STR_CHEAT_SWITCH_CLIMATE) val += STR_TEMPERATE_LANDSCAPE; |
1803 val += STR_TEMPERATE_LANDSCAPE; |
|
1804 |
1808 |
1805 SetDParam(0, val); |
1809 SetDParam(0, val); |
1806 |
1810 |
1807 // display date for change date cheat |
1811 // display date for change date cheat |
1808 if(ce->str==STR_CHEAT_CHANGE_DATE) |
1812 if (ce->str == STR_CHEAT_CHANGE_DATE) SetDParam(0, _date); |
1809 SetDParam(0, _date); |
|
1810 |
1813 |
1811 // draw colored flag for change player cheat |
1814 // draw colored flag for change player cheat |
1812 if(ce->str==STR_CHEAT_CHANGE_PLAYER) |
1815 if (ce->str == STR_CHEAT_CHANGE_PLAYER) { |
1813 DrawPlayerIcon(_current_player, 156, y+2); |
1816 DrawPlayerIcon(_current_player, 156, y + 2); |
1814 |
1817 } |
1815 } |
1818 } |
1816 |
1819 |
1817 DrawString(50, y+1, ce->str, 0); |
1820 DrawString(50, y + 1, ce->str, 0); |
1818 |
1821 |
1819 y+=12; |
1822 y += 12; |
1820 } |
1823 } |
1821 break; |
1824 break; |
1822 } |
1825 } |
1826 |
|
1823 case WE_CLICK: { |
1827 case WE_CLICK: { |
1824 const CheatEntry *ce; |
1828 const CheatEntry *ce; |
1825 uint btn = (e->click.pt.y - 46) / 12; |
1829 uint btn = (e->click.pt.y - 46) / 12; |
1826 int32 val, oval; |
1830 int32 val, oval; |
1827 uint x = e->click.pt.x; |
1831 uint x = e->click.pt.x; |
1828 |
1832 |
1829 // not clicking a button? |
1833 // not clicking a button? |
1830 if(!IS_INT_INSIDE(x, 20, 40) || btn>=lengthof(_cheats_ui)) |
1834 if (!IS_INT_INSIDE(x, 20, 40) || btn >= lengthof(_cheats_ui)) break; |
1831 break; |
|
1832 |
1835 |
1833 ce = &_cheats_ui[btn]; |
1836 ce = &_cheats_ui[btn]; |
1834 oval = val = ReadCE(ce); |
1837 oval = val = ReadCE(ce); |
1835 |
1838 |
1836 *ce->been_used = true; |
1839 *ce->been_used = true; |
1837 |
1840 |
1838 switch(ce->type) { |
1841 switch (ce->type) { |
1839 case CE_BOOL: { |
1842 case CE_BOOL: { |
1840 val ^= 1; |
1843 val ^= 1; |
1841 if (ce->click_proc != NULL) |
1844 if (ce->click_proc != NULL) ce->click_proc(val, 0); |
1842 ce->click_proc(val, 0); |
|
1843 break; |
1845 break; |
1844 } |
1846 } |
1845 |
1847 |
1846 case CE_CLICK: { |
1848 case CE_CLICK: { |
1847 ce->click_proc(val, 0); |
1849 ce->click_proc(val, 0); |
1859 val -= ce->step; |
1861 val -= ce->step; |
1860 if (val < ce->min) val = ce->min; |
1862 if (val < ce->min) val = ce->min; |
1861 } |
1863 } |
1862 |
1864 |
1863 // take whatever the function returns |
1865 // take whatever the function returns |
1864 val = ce->click_proc(val, (x>=30) ? 1 : -1); |
1866 val = ce->click_proc(val, (x >= 30) ? 1 : -1); |
1865 |
1867 |
1866 if (val != oval) |
1868 if (val != oval) { |
1867 WP(w,def_d).data_1 = btn * 2 + 1 + ((x>=30) ? 1 : 0); |
1869 WP(w,def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0); |
1868 |
1870 } |
1869 break; |
1871 break; |
1870 } |
1872 } |
1871 } |
1873 } |
1872 |
1874 |
1873 if (val != oval) { |
1875 if (val != oval) { |
1884 WP(w,def_d).data_1 = 0; |
1886 WP(w,def_d).data_1 = 0; |
1885 SetWindowDirty(w); |
1887 SetWindowDirty(w); |
1886 break; |
1888 break; |
1887 } |
1889 } |
1888 } |
1890 } |
1891 |
|
1889 static const WindowDesc _cheats_desc = { |
1892 static const WindowDesc _cheats_desc = { |
1890 240, 22, 400, 160, |
1893 240, 22, 400, 160, |
1891 WC_CHEATS,0, |
1894 WC_CHEATS,0, |
1892 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1895 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1893 _cheat_widgets, |
1896 _cheat_widgets, |