mirror of https://github.com/OpenTTD/OpenTTD
(svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
parent
485102814f
commit
4e41cf9e2b
1
gui.h
1
gui.h
|
@ -12,6 +12,7 @@ void PlaceProc_Sign(uint tile);
|
||||||
void ShowGameOptions();
|
void ShowGameOptions();
|
||||||
void ShowGameDifficulty();
|
void ShowGameDifficulty();
|
||||||
void ShowPatchesSelection();
|
void ShowPatchesSelection();
|
||||||
|
void ShowNewgrf();
|
||||||
|
|
||||||
/* graph_gui.c */
|
/* graph_gui.c */
|
||||||
void ShowOperatingProfitGraph();
|
void ShowOperatingProfitGraph();
|
||||||
|
|
|
@ -189,9 +189,9 @@ STR_00B7_VERSION :{BLACK}OpenTTD version {REV}
|
||||||
STR_00B8_ORIGINAL_DESIGN_PROGRAM :{BLACK}Original design by Chris Sawyer
|
STR_00B8_ORIGINAL_DESIGN_PROGRAM :{BLACK}Original design by Chris Sawyer
|
||||||
STR_00B9_ORIGINAL_GRAPHICS :{BLACK}Original graphics by Simon Foster
|
STR_00B9_ORIGINAL_GRAPHICS :{BLACK}Original graphics by Simon Foster
|
||||||
STR_SPECIAL_THANKS :{BLACK}Special thanks go out to:
|
STR_SPECIAL_THANKS :{BLACK}Special thanks go out to:
|
||||||
STR_SPECIAL_THANKS_SIGNALS :{BLACK}° Pre-Signals and Semaphores {COPYRIGHT} 2003 Michael Blunck
|
STR_SPECIAL_THANKS_SIGNALS :{BLACK} Pre-Signals and Semaphores {COPYRIGHT} 2003 Michael Blunck
|
||||||
STR_SPECIAL_THANKS_CANALS :{BLACK}° Foundations for Tracks on Slopes {COPYRIGHT} Marcin Grzegorczyk
|
STR_SPECIAL_THANKS_CANALS :{BLACK} Foundations for Tracks on Slopes {COPYRIGHT} Marcin Grzegorczyk
|
||||||
STR_SPECIAL_THANKS_FOUNDATIONS :{BLACK}° Canal/Lock graphics {COPYRIGHT} 2003-2004 George
|
STR_SPECIAL_THANKS_FOUNDATIONS :{BLACK} Canal/Lock graphics {COPYRIGHT} 2003-2004 George
|
||||||
STR_00BA_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT}2002-2004 The OpenTTD team
|
STR_00BA_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT}2002-2004 The OpenTTD team
|
||||||
|
|
||||||
STR_00C5 :{BLACK}{CROSS}
|
STR_00C5 :{BLACK}{CROSS}
|
||||||
|
@ -729,28 +729,30 @@ STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION :{BLACK}Vehicle design names selection
|
||||||
STR_02C2_SAVE_CUSTOMIZED_VEHICLE :{BLACK}Save customized vehicle design names to disk
|
STR_02C2_SAVE_CUSTOMIZED_VEHICLE :{BLACK}Save customized vehicle design names to disk
|
||||||
|
|
||||||
############ range for menu starts
|
############ range for menu starts
|
||||||
STR_02C3_GAME_OPTIONS :Game options
|
STR_02C3_GAME_OPTIONS :Game options
|
||||||
STR_02C4_GAME_OPTIONS :Game options
|
STR_02C4_GAME_OPTIONS :Game options
|
||||||
STR_02C5_DIFFICULTY_SETTINGS :Difficulty settings
|
STR_02C5_DIFFICULTY_SETTINGS :Difficulty settings
|
||||||
STR_02C6_DIFFICULTY_SETTINGS :Difficulty settings
|
STR_02C6_DIFFICULTY_SETTINGS :Difficulty settings
|
||||||
STR_02C7_CONFIG_PATCHES :Configure patches
|
STR_02C7_CONFIG_PATCHES :Configure patches
|
||||||
STR_02C8_CONFIG_PATCHES :Configure patches
|
STR_02C8_CONFIG_PATCHES :Configure patches
|
||||||
STR_GAMEOPTMENU_0A :
|
STR_NEWGRF_SETTINGS :Newgrf settings
|
||||||
STR_GAMEOPTMENU_0B :
|
STR_NEWGRF_SETTINGS2 :Newgrf settings
|
||||||
|
STR_GAMEOPTMENU_0A :
|
||||||
|
STR_GAMEOPTMENU_0B :
|
||||||
STR_02C9_TOWN_NAMES_DISPLAYED :{CHECKMARK}{SETX 12}Town names displayed
|
STR_02C9_TOWN_NAMES_DISPLAYED :{CHECKMARK}{SETX 12}Town names displayed
|
||||||
STR_02CA_TOWN_NAMES_DISPLAYED :{SETX 12}Town names displayed
|
STR_02CA_TOWN_NAMES_DISPLAYED :{SETX 12}Town names displayed
|
||||||
STR_02CB_STATION_NAMES_DISPLAYED :{CHECKMARK}{SETX 12}Station names displayed
|
STR_02CB_STATION_NAMES_DISPLAYED :{CHECKMARK}{SETX 12}Station names displayed
|
||||||
STR_02CC_STATION_NAMES_DISPLAYED :{SETX 12}Station names displayed
|
STR_02CC_STATION_NAMES_DISPLAYED :{SETX 12}Station names displayed
|
||||||
STR_02CD_SIGNS_DISPLAYED :{CHECKMARK}{SETX 12}Signs displayed
|
STR_02CD_SIGNS_DISPLAYED :{CHECKMARK}{SETX 12}Signs displayed
|
||||||
STR_02CE_SIGNS_DISPLAYED :{SETX 12}Signs displayed
|
STR_02CE_SIGNS_DISPLAYED :{SETX 12}Signs displayed
|
||||||
STR_WAYPOINTS_DISPLAYED :{CHECKMARK}{SETX 12}Waypoints displayed
|
STR_WAYPOINTS_DISPLAYED :{CHECKMARK}{SETX 12}Waypoints displayed
|
||||||
STR_WAYPOINTS_DISPLAYED2 :{SETX 12}Waypoints displayed
|
STR_WAYPOINTS_DISPLAYED2 :{SETX 12}Waypoints displayed
|
||||||
STR_02CF_FULL_ANIMATION :{CHECKMARK}{SETX 12}Full animation
|
STR_02CF_FULL_ANIMATION :{CHECKMARK}{SETX 12}Full animation
|
||||||
STR_02D0_FULL_ANIMATION :{SETX 12}Full animation
|
STR_02D0_FULL_ANIMATION :{SETX 12}Full animation
|
||||||
STR_02D1_FULL_DETAIL :{CHECKMARK}{SETX 12}Full detail
|
STR_02D1_FULL_DETAIL :{CHECKMARK}{SETX 12}Full detail
|
||||||
STR_02D2_FULL_DETAIL :{SETX 12}Full detail
|
STR_02D2_FULL_DETAIL :{SETX 12}Full detail
|
||||||
STR_02D3_TRANSPARENT_BUILDINGS :{CHECKMARK}{SETX 12}Transparent buildings
|
STR_02D3_TRANSPARENT_BUILDINGS :{CHECKMARK}{SETX 12}Transparent buildings
|
||||||
STR_02D4_TRANSPARENT_BUILDINGS :{SETX 12}Transparent buildings
|
STR_02D4_TRANSPARENT_BUILDINGS :{SETX 12}Transparent buildings
|
||||||
############ range ends here
|
############ range ends here
|
||||||
|
|
||||||
############ range for menu starts
|
############ range for menu starts
|
||||||
|
@ -883,7 +885,7 @@ STR_CURR_CZK :Czech Koruna (CZK)
|
||||||
STR_CURR_ISK :Icelandic Krona (ISK)
|
STR_CURR_ISK :Icelandic Krona (ISK)
|
||||||
STR_CURR_NOK :Norwegian Krone (NOK)
|
STR_CURR_NOK :Norwegian Krone (NOK)
|
||||||
STR_CURR_ROL :Romanian Leu (Lei)
|
STR_CURR_ROL :Romanian Leu (Lei)
|
||||||
STR_CURR_EUR :Euro (€)
|
STR_CURR_EUR :Euro ()
|
||||||
|
|
||||||
STR_OPTIONS_LANG :{BLACK}Language
|
STR_OPTIONS_LANG :{BLACK}Language
|
||||||
STR_OPTIONS_LANG_CBO :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
|
STR_OPTIONS_LANG_CBO :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
|
||||||
|
@ -2600,3 +2602,10 @@ STR_PERFORMANCE_DETAIL_MONEY_TIP :{BLACK}Amount of cash on hand
|
||||||
STR_PERFORMANCE_DETAIL_LOAN_TIP :{BLACK}Do you have a high loan?
|
STR_PERFORMANCE_DETAIL_LOAN_TIP :{BLACK}Do you have a high loan?
|
||||||
STR_PERFORMANCE_DETAIL_TOTAL_TIP :{BLACK}Total points out of possible points
|
STR_PERFORMANCE_DETAIL_TOTAL_TIP :{BLACK}Total points out of possible points
|
||||||
|
|
||||||
|
STR_NEWGRF_SETINGS_CAPTION :{WHITE}Newgrf settings
|
||||||
|
STR_NEWGRF_APPLY_CHANGES :{BLACK}Apply changes
|
||||||
|
STR_NEWGRF_SET_PARAMETERS :{BLACK}Set parameters
|
||||||
|
STR_NEWGRF_TIP :{BLACK}A list of all the Newgrf sets that you have installed. Click a set to change the settings.
|
||||||
|
STR_NEWGRF_NO_FILES_INSTALLED :{BLACK}There are currently no newgrf files installed! Please refer to the manual for instructions to install new graphics.
|
||||||
|
STR_NEWGRF_FILENAME :{BLACK}Filename:
|
||||||
|
STR_NEWGRF_GRF_ID :{BLACK}GRF ID:
|
32
main_gui.c
32
main_gui.c
|
@ -110,13 +110,15 @@ static void MenuClickSettings(int index)
|
||||||
case 0: ShowGameOptions(); return;
|
case 0: ShowGameOptions(); return;
|
||||||
case 1: ShowGameDifficulty(); return;
|
case 1: ShowGameDifficulty(); return;
|
||||||
case 2: ShowPatchesSelection(); return;
|
case 2: ShowPatchesSelection(); return;
|
||||||
case 4: _display_opt ^= DO_SHOW_TOWN_NAMES; MarkWholeScreenDirty(); return;
|
case 3: ShowNewgrf(); return;
|
||||||
case 5: _display_opt ^= DO_SHOW_STATION_NAMES; MarkWholeScreenDirty(); return;
|
|
||||||
case 6: _display_opt ^= DO_SHOW_SIGNS; MarkWholeScreenDirty(); return;
|
case 5: _display_opt ^= DO_SHOW_TOWN_NAMES; MarkWholeScreenDirty(); return;
|
||||||
case 7: _display_opt ^= DO_WAYPOINTS; MarkWholeScreenDirty(); return;
|
case 6: _display_opt ^= DO_SHOW_STATION_NAMES; MarkWholeScreenDirty(); return;
|
||||||
case 8: _display_opt ^= DO_FULL_ANIMATION; MarkWholeScreenDirty(); return;
|
case 7: _display_opt ^= DO_SHOW_SIGNS; MarkWholeScreenDirty(); return;
|
||||||
case 9: _display_opt ^= DO_FULL_DETAIL; MarkWholeScreenDirty(); return;
|
case 8: _display_opt ^= DO_WAYPOINTS; MarkWholeScreenDirty(); return;
|
||||||
case 10: _display_opt ^= DO_TRANS_BUILDINGS; MarkWholeScreenDirty(); return;
|
case 9: _display_opt ^= DO_FULL_ANIMATION; MarkWholeScreenDirty(); return;
|
||||||
|
case 10: _display_opt ^= DO_FULL_DETAIL; MarkWholeScreenDirty(); return;
|
||||||
|
case 11: _display_opt ^= DO_TRANS_BUILDINGS; MarkWholeScreenDirty(); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,16 +840,16 @@ static void ToolbarOptionsClick(Window *w)
|
||||||
{
|
{
|
||||||
uint16 x;
|
uint16 x;
|
||||||
|
|
||||||
w = PopupMainToolbMenu(w, 43, 2, STR_02C3_GAME_OPTIONS, 11);
|
w = PopupMainToolbMenu(w, 43, 2, STR_02C3_GAME_OPTIONS, 12);
|
||||||
|
|
||||||
x = (uint16)-1;
|
x = (uint16)-1;
|
||||||
if (_display_opt & DO_SHOW_TOWN_NAMES) x &= ~(1<<4);
|
if (_display_opt & DO_SHOW_TOWN_NAMES) x &= ~(1<<5);
|
||||||
if (_display_opt & DO_SHOW_STATION_NAMES) x &= ~(1<<5);
|
if (_display_opt & DO_SHOW_STATION_NAMES) x &= ~(1<<6);
|
||||||
if (_display_opt & DO_SHOW_SIGNS) x &= ~(1<<6);
|
if (_display_opt & DO_SHOW_SIGNS) x &= ~(1<<7);
|
||||||
if (_display_opt & DO_WAYPOINTS) x &= ~(1<<7);
|
if (_display_opt & DO_WAYPOINTS) x &= ~(1<<8);
|
||||||
if (_display_opt & DO_FULL_ANIMATION) x &= ~(1<<8);
|
if (_display_opt & DO_FULL_ANIMATION) x &= ~(1<<9);
|
||||||
if (_display_opt & DO_FULL_DETAIL) x &= ~(1<<9);
|
if (_display_opt & DO_FULL_DETAIL) x &= ~(1<<10);
|
||||||
if (!(_display_opt & DO_TRANS_BUILDINGS)) x &= ~(1<<10);
|
if (!(_display_opt & DO_TRANS_BUILDINGS)) x &= ~(1<<11);
|
||||||
WP(w,menu_d).checked_items = x;
|
WP(w,menu_d).checked_items = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
newgrf.c
1
newgrf.c
|
@ -26,6 +26,7 @@ extern int _replace_sprites_offset[16];
|
||||||
extern int _traininfo_vehicle_pitch;
|
extern int _traininfo_vehicle_pitch;
|
||||||
|
|
||||||
struct GRFFile *_cur_grffile, *_first_grffile;
|
struct GRFFile *_cur_grffile, *_first_grffile;
|
||||||
|
int _grffile_count;
|
||||||
static int _cur_spriteid;
|
static int _cur_spriteid;
|
||||||
static int _cur_stage;
|
static int _cur_stage;
|
||||||
extern int _custom_sprites_base;
|
extern int _custom_sprites_base;
|
||||||
|
|
140
settings_gui.c
140
settings_gui.c
|
@ -7,6 +7,7 @@
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
|
#include "newgrf.h"
|
||||||
|
|
||||||
static uint32 _difficulty_click_a;
|
static uint32 _difficulty_click_a;
|
||||||
static uint32 _difficulty_click_b;
|
static uint32 _difficulty_click_b;
|
||||||
|
@ -933,3 +934,142 @@ void ShowPatchesSelection()
|
||||||
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
||||||
AllocateWindowDesc(&_patches_selection_desc);
|
AllocateWindowDesc(&_patches_selection_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct GRFFile *_sel_grffile;
|
||||||
|
|
||||||
|
static void NewgrfWndProc(Window *w, WindowEvent *e)
|
||||||
|
{
|
||||||
|
uint i=0;
|
||||||
|
switch(e->event) {
|
||||||
|
case WE_PAINT: {
|
||||||
|
int x, y = 15;
|
||||||
|
struct GRFFile *c=_first_grffile;
|
||||||
|
|
||||||
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
|
if(_first_grffile==NULL) { // no grf sets installed
|
||||||
|
DrawStringMultiCenter(140, 240, STR_NEWGRF_NO_FILES_INSTALLED, 250);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw list of all grf files
|
||||||
|
while(c!=NULL) {
|
||||||
|
if(i>=w->vscroll.pos) { // draw files according to scrollbar position
|
||||||
|
if(_sel_grffile==c) GfxFillRect(2, y-1, 267, y + 12, 10); // show highlighted item with a different background
|
||||||
|
DrawSprite(SPRITE_PALETTE(0x2EB | 0x30b8000), 5, y+2);
|
||||||
|
DoDrawString(c->filename, 25, y+2, 0x10); // will be grf name later
|
||||||
|
y+=15;
|
||||||
|
}
|
||||||
|
|
||||||
|
c=c->next;
|
||||||
|
if(++i>=12+w->vscroll.pos) break; // stop after displaying 12 items
|
||||||
|
}
|
||||||
|
|
||||||
|
// DoDrawString(_sel_grffile->setname, 120, 200, 0x01); // draw grf name
|
||||||
|
|
||||||
|
if(_sel_grffile==NULL) { // no grf file selected yet
|
||||||
|
DrawStringMultiCenter(140, 240, STR_NEWGRF_TIP, 250);
|
||||||
|
} else {
|
||||||
|
// draw filename
|
||||||
|
x = DrawString(5, 210, STR_NEWGRF_FILENAME, 0);
|
||||||
|
DoDrawString(_sel_grffile->filename, x+2, 210, 0x01);
|
||||||
|
|
||||||
|
// draw grf id
|
||||||
|
x = DrawString(5, 220, STR_NEWGRF_GRF_ID, 0);
|
||||||
|
SET_DPARAM16(0, _sel_grffile->grfid);
|
||||||
|
DrawString(x+2, 220, STR_7024, 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case WE_CLICK:
|
||||||
|
switch(e->click.widget) {
|
||||||
|
case 2: { // select a grf file
|
||||||
|
int y;
|
||||||
|
|
||||||
|
y = e->click.pt.y - 16;
|
||||||
|
if (y < 0) return;
|
||||||
|
|
||||||
|
y = (y/15) + w->vscroll.pos; // calc selected item
|
||||||
|
if (y >= _grffile_count) return;
|
||||||
|
|
||||||
|
_sel_grffile = _first_grffile;
|
||||||
|
while(y) {
|
||||||
|
_sel_grffile = _sel_grffile->next;
|
||||||
|
y--;
|
||||||
|
}
|
||||||
|
SetWindowDirty(w);
|
||||||
|
} break;
|
||||||
|
case 9:
|
||||||
|
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
||||||
|
break;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
/* Parameter edit box not used yet
|
||||||
|
case WE_TIMEOUT:
|
||||||
|
WP(w,def_d).data_2 = 0;
|
||||||
|
SetWindowDirty(w);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WE_ON_EDIT_TEXT: {
|
||||||
|
if (*e->edittext.str) {
|
||||||
|
SetWindowDirty(w);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
case WE_DESTROY:
|
||||||
|
DeleteWindowById(WC_QUERY_STRING, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Widget _newgrf_widgets[] = {
|
||||||
|
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
|
{ WWT_CAPTION, 14, 11, 279, 0, 13, STR_NEWGRF_SETINGS_CAPTION,STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
|
{ WWT_MATRIX, 14, 0, 268, 14, 193, 0xC01, STR_NEWGRF_TIP},
|
||||||
|
{ WWT_PANEL, 14, 0, 279, 194, 332, 0x0, STR_NULL},
|
||||||
|
|
||||||
|
{ WWT_SCROLLBAR, 14, 269, 279, 14, 193, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
|
|
||||||
|
{ WWT_CLOSEBOX, 14, 147, 158, 300, 311, STR_0188, STR_NULL},
|
||||||
|
{ WWT_CLOSEBOX, 14, 159, 170, 300, 311, STR_0189, STR_NULL},
|
||||||
|
{ WWT_CLOSEBOX, 14, 175, 274, 300, 311, STR_NEWGRF_SET_PARAMETERS, STR_NULL},
|
||||||
|
|
||||||
|
{ WWT_CLOSEBOX, 3, 5, 138, 317, 328, STR_NEWGRF_APPLY_CHANGES, STR_NULL},
|
||||||
|
{ WWT_CLOSEBOX, 3, 142, 274, 317, 328, STR_012E_CANCEL, STR_NULL},
|
||||||
|
{ WIDGETS_END},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const WindowDesc _newgrf_desc = {
|
||||||
|
WDP_CENTER, WDP_CENTER, 280, 333,
|
||||||
|
WC_GAME_OPTIONS,0,
|
||||||
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
||||||
|
_newgrf_widgets,
|
||||||
|
NewgrfWndProc,
|
||||||
|
};
|
||||||
|
|
||||||
|
void ShowNewgrf()
|
||||||
|
{
|
||||||
|
Window *w;
|
||||||
|
DeleteWindowById(WC_GAME_OPTIONS, 0);
|
||||||
|
w = AllocateWindowDesc(&_newgrf_desc);
|
||||||
|
|
||||||
|
{ // little helper function to calculate _grffile_count
|
||||||
|
// should be REMOVED once _grffile_count is calculated at loading
|
||||||
|
_grffile_count=0;
|
||||||
|
struct GRFFile *c=_first_grffile;
|
||||||
|
while(c!=NULL) {
|
||||||
|
_grffile_count++;
|
||||||
|
c=c->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
w->vscroll.cap = 12;
|
||||||
|
w->vscroll.count = _grffile_count;
|
||||||
|
w->vscroll.pos = 0;
|
||||||
|
w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue