|
@@ -101,27 +101,30 @@ static int GetCurRes()
|
|
|
}
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
/** Widgets of the game options menu */
|
|
|
enum GameOptionsWidgets {
|
|
|
GOW_BACKGROUND, ///< Background of the window
|
|
|
GOW_CURRENCY_DROPDOWN, ///< Currency dropdown
|
|
|
GOW_DISTANCE_DROPDOWN, ///< Measuring unit dropdown
|
|
|
GOW_ROADSIDE_DROPDOWN, ///< Dropdown to select the road side (to set the right side ;))
|
|
|
GOW_TOWNNAME_DROPDOWN, ///< Town name dropdown
|
|
|
GOW_AUTOSAVE_DROPDOWN, ///< Dropdown to say how often to autosave
|
|
|
GOW_LANG_DROPDOWN, ///< Language dropdown
|
|
|
GOW_RESOLUTION_DROPDOWN, ///< Dropdown for the resolution
|
|
|
GOW_FULLSCREEN_BUTTON, ///< Toggle fullscreen
|
|
|
GOW_SCREENSHOT_DROPDOWN, ///< Select the screenshot type... please use PNG!
|
|
|
GOW_BASE_GRF_DROPDOWN, ///< Use to select a base GRF
|
|
|
GOW_BASE_GRF_STATUS, ///< Info about missing files etc.
|
|
|
GOW_BASE_GRF_DESCRIPTION,///< Description of selected base GRF
|
|
|
GOW_BASE_SFX_DROPDOWN, ///< Use to select a base SFX
|
|
|
GOW_BASE_SFX_DESCRIPTION,///< Description of selected base SFX
|
|
|
GOW_BACKGROUND, ///< Background of the window
|
|
|
GOW_CURRENCY_DROPDOWN, ///< Currency dropdown
|
|
|
GOW_DISTANCE_DROPDOWN, ///< Measuring unit dropdown
|
|
|
GOW_ROADSIDE_DROPDOWN, ///< Dropdown to select the road side (to set the right side ;))
|
|
|
GOW_TOWNNAME_DROPDOWN, ///< Town name dropdown
|
|
|
GOW_AUTOSAVE_DROPDOWN, ///< Dropdown to say how often to autosave
|
|
|
GOW_LANG_DROPDOWN, ///< Language dropdown
|
|
|
GOW_RESOLUTION_DROPDOWN, ///< Dropdown for the resolution
|
|
|
GOW_FULLSCREEN_BUTTON, ///< Toggle fullscreen
|
|
|
GOW_SCREENSHOT_DROPDOWN, ///< Select the screenshot type... please use PNG!
|
|
|
GOW_BASE_GRF_DROPDOWN, ///< Use to select a base GRF
|
|
|
GOW_BASE_GRF_STATUS, ///< Info about missing files etc.
|
|
|
GOW_BASE_GRF_DESCRIPTION, ///< Description of selected base GRF
|
|
|
GOW_BASE_SFX_DROPDOWN, ///< Use to select a base SFX
|
|
|
GOW_BASE_SFX_DESCRIPTION, ///< Description of selected base SFX
|
|
|
GOW_BASE_MUSIC_DROPDOWN, ///< Use to select a base music set
|
|
|
GOW_BASE_MUSIC_STATUS, ///< Info about corrupted files etc.
|
|
|
GOW_BASE_MUSIC_DESCRIPTION, ///< Description of selected base music set
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Update/redraw the townnames dropdown
|
|
|
* @param w the window the dropdown belongs to
|
|
|
* @param sel the currently selected townname generator
|
|
@@ -191,12 +194,14 @@ struct GameOptionsWindow : Window {
|
|
|
case GOW_LANG_DROPDOWN: SetDParam(0, SPECSTR_LANGUAGE_START + _dynlang.curr); break;
|
|
|
case GOW_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
|
|
|
case GOW_SCREENSHOT_DROPDOWN: SetDParam(0, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); break;
|
|
|
case GOW_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name); break;
|
|
|
case GOW_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
|
|
|
case GOW_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name); break;
|
|
|
case GOW_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->name); break;
|
|
|
case GOW_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
@@ -211,12 +216,17 @@ struct GameOptionsWindow : Window {
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_SFX_DESCRIPTION:
|
|
|
SetDParamStr(0, BaseSounds::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
|
|
|
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_MUSIC_DESCRIPTION:
|
|
|
SetDParamStr(0, BaseMusic::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode()));
|
|
|
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
{
|
|
|
switch (widget) {
|
|
@@ -243,12 +253,31 @@ struct GameOptionsWindow : Window {
|
|
|
/* Find the biggest description for the default size. */
|
|
|
for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
|
|
|
SetDParamStr(0, BaseSounds::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
|
|
|
size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_MUSIC_DESCRIPTION:
|
|
|
/* Find the biggest description for the default size. */
|
|
|
for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
|
|
|
SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
|
|
|
size->height = max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_MUSIC_STATUS:
|
|
|
/* Find the biggest description for the default size. */
|
|
|
for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
|
|
|
uint invalid_files = BaseMusic::GetSet(i)->GetNumInvalid();
|
|
|
if (invalid_files == 0) continue;
|
|
|
|
|
|
SetDParam(0, invalid_files);
|
|
|
*size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_MUSIC_STATUS));
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
{
|
|
|
switch (widget) {
|
|
@@ -317,12 +346,16 @@ struct GameOptionsWindow : Window {
|
|
|
ShowSetMenu<BaseGraphics>(this, GOW_BASE_GRF_DROPDOWN);
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_SFX_DROPDOWN:
|
|
|
ShowSetMenu<BaseSounds>(this, GOW_BASE_SFX_DROPDOWN);
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_MUSIC_DROPDOWN:
|
|
|
ShowSetMenu<BaseMusic>(this, GOW_BASE_MUSIC_DROPDOWN);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Set the base media set.
|
|
|
* @param index the index of the media set
|
|
@@ -400,21 +433,28 @@ struct GameOptionsWindow : Window {
|
|
|
this->SetMediaSet<BaseGraphics>(index);
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_SFX_DROPDOWN:
|
|
|
this->SetMediaSet<BaseSounds>(index);
|
|
|
break;
|
|
|
|
|
|
case GOW_BASE_MUSIC_DROPDOWN:
|
|
|
this->SetMediaSet<BaseMusic>(index);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
{
|
|
|
this->SetWidgetLoweredState(GOW_FULLSCREEN_BUTTON, _fullscreen);
|
|
|
|
|
|
bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
|
|
|
this->GetWidget<NWidgetCore>(GOW_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
|
|
|
|
|
|
missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
|
|
|
this->GetWidget<NWidgetCore>(GOW_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
static const NWidgetPart _nested_game_options_widgets[] = {
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
|
@@ -456,13 +496,13 @@ static const NWidgetPart _nested_game_op
|
|
|
EndContainer(),
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
|
|
|
EndContainer(),
|
|
|
EndContainer(),
|
|
|
|
|
|
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPadding(0, 10, 0, 10),
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(00, 30, 0),
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
|
|
|
NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
|
|
|
EndContainer(),
|
|
|
NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_GRF_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 0, 0),
|
|
|
EndContainer(),
|
|
|
|
|
@@ -470,12 +510,20 @@ static const NWidgetPart _nested_game_op
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
|
|
EndContainer(),
|
|
|
NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_SFX_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 0, 0),
|
|
|
EndContainer(),
|
|
|
|
|
|
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL), SetPadding(0, 10, 0, 10),
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_BASE_MUSIC_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP),
|
|
|
NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_MUSIC_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
|
|
|
EndContainer(),
|
|
|
NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_MUSIC_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 0, 0),
|
|
|
EndContainer(),
|
|
|
EndContainer(),
|
|
|
};
|
|
|
|
|
|
static const WindowDesc _game_options_desc(
|
|
|
WDP_CENTER, 0, 0,
|
|
|
WC_GAME_OPTIONS, WC_NONE,
|