mirror of https://github.com/OpenTTD/OpenTTD
Change: Move baseset missing/corrupted files label to list item. (#11455)
This allows any baseset error to be displayed in the drop down list so it is more easily visible, and avoids wasted space in the layout.pull/11456/head
parent
1071acb483
commit
bd2ddb07ca
|
@ -121,6 +121,21 @@ struct BaseSet {
|
|||
return this->description.at(std::string{});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string to use when listing this set in the settings window.
|
||||
* If there are no invalid files, then this is just the set name,
|
||||
* otherwise a string is formatted including the number of invalid files.
|
||||
* @return the string to display.
|
||||
*/
|
||||
std::string GetListLabel() const
|
||||
{
|
||||
if (this->GetNumInvalid() == 0) return this->name;
|
||||
|
||||
SetDParamStr(0, this->name);
|
||||
SetDParam(1, this->GetNumInvalid());
|
||||
return GetString(STR_BASESET_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate and check the MD5 hash of the supplied file.
|
||||
* @param file The file get the hash of.
|
||||
|
|
|
@ -1080,7 +1080,6 @@ STR_GAME_OPTIONS_REFRESH_RATE_WARNING :{WHITE}Refresh
|
|||
|
||||
STR_GAME_OPTIONS_BASE_GRF :{BLACK}Base graphics set
|
||||
STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Select the base graphics set to use (cannot be changed in-game, only from the main menu)
|
||||
STR_GAME_OPTIONS_BASE_GRF_STATUS :{RED}{NUM} missing/corrupted file{P "" s}
|
||||
STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP :{BLACK}Additional information about the base graphics set
|
||||
|
||||
STR_GAME_OPTIONS_BASE_SFX :{BLACK}Base sounds set
|
||||
|
@ -1089,9 +1088,10 @@ STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP :{BLACK}Addition
|
|||
|
||||
STR_GAME_OPTIONS_BASE_MUSIC :{BLACK}Base music set
|
||||
STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP :{BLACK}Select the base music set to use
|
||||
STR_GAME_OPTIONS_BASE_MUSIC_STATUS :{RED}{NUM} corrupted file{P "" s}
|
||||
STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP :{BLACK}Additional information about the base music set
|
||||
|
||||
STR_BASESET_STATUS :{RAW_STRING} {RED}({NUM} missing/corrupted file{P "" s})
|
||||
|
||||
STR_ERROR_RESOLUTION_LIST_FAILED :{WHITE}Failed to retrieve a list of supported resolutions
|
||||
STR_ERROR_FULLSCREEN_FAILED :{WHITE}Fullscreen mode failed
|
||||
|
||||
|
|
|
@ -327,11 +327,9 @@ struct GameOptionsWindow : Window {
|
|||
break;
|
||||
}
|
||||
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
|
||||
case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name); break;
|
||||
case WID_GO_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
|
||||
case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name); break;
|
||||
case WID_GO_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->name); break;
|
||||
case WID_GO_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
|
||||
case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->GetListLabel()); break;
|
||||
case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->GetListLabel()); break;
|
||||
case WID_GO_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->GetListLabel()); break;
|
||||
case WID_GO_REFRESH_RATE_DROPDOWN: SetDParam(0, _settings_client.gui.refresh_rate); break;
|
||||
case WID_GO_RESOLUTION_DROPDOWN: {
|
||||
auto current_resolution = GetCurrentResolutionIndex();
|
||||
|
@ -436,28 +434,6 @@ struct GameOptionsWindow : Window {
|
|||
void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GO_BASE_GRF_STATUS:
|
||||
/* Find the biggest description for the default size. */
|
||||
for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
|
||||
uint invalid_files = BaseGraphics::GetSet(i)->GetNumInvalid();
|
||||
if (invalid_files == 0) continue;
|
||||
|
||||
SetDParam(0, invalid_files);
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_GRF_STATUS));
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_GO_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;
|
||||
|
||||
case WID_GO_TEXT_SFX_VOLUME:
|
||||
case WID_GO_TEXT_MUSIC_VOLUME: {
|
||||
Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME));
|
||||
|
@ -751,9 +727,6 @@ struct GameOptionsWindow : Window {
|
|||
this->SetWidgetDisabledState(WID_GO_BASE_GRF_DROPDOWN, _game_mode != GM_MENU);
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_SFX_DROPDOWN, _game_mode != GM_MENU);
|
||||
|
||||
bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
|
||||
this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
|
||||
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_GRF_PARAMETERS, BaseGraphics::GetUsedSet() == nullptr || !BaseGraphics::GetUsedSet()->IsConfigurable());
|
||||
|
||||
for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
|
||||
|
@ -761,9 +734,6 @@ struct GameOptionsWindow : Window {
|
|||
this->SetWidgetDisabledState(WID_GO_BASE_SFX_TEXTFILE + tft, BaseSounds::GetUsedSet() == nullptr || !BaseSounds::GetUsedSet()->GetTextfile(tft).has_value());
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_MUSIC_TEXTFILE + tft, BaseMusic::GetUsedSet() == nullptr || !BaseMusic::GetUsedSet()->GetTextfile(tft).has_value());
|
||||
}
|
||||
|
||||
missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
|
||||
this->GetWidget<NWidgetCore>(WID_GO_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -865,8 +835,7 @@ static const NWidgetPart _nested_game_options_widgets[] = {
|
|||
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_STATUS), SetMinimalSize(100, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP), SetFill(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_PARAMETERS), SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
|
||||
EndContainer(),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_DESCRIPTION), SetMinimalSize(200, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
|
||||
|
@ -894,10 +863,7 @@ static const NWidgetPart _nested_game_options_widgets[] = {
|
|||
EndContainer(),
|
||||
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(100, 12), SetFill(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP), SetFill(1, 0),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_SFX_DESCRIPTION), SetMinimalSize(200, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_NULL, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
|
||||
|
@ -907,10 +873,7 @@ static const NWidgetPart _nested_game_options_widgets[] = {
|
|||
EndContainer(),
|
||||
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_STATUS), SetMinimalSize(100, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP), SetFill(1, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_MUSIC_DESCRIPTION), SetMinimalSize(200, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_NULL, STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
|
||||
NWidget(NWID_VERTICAL), SetPIP(0, 0, 0),
|
||||
|
|
|
@ -29,7 +29,7 @@ DropDownList BuildSetDropDownList(int *selected_index)
|
|||
*selected_index = T::GetIndexOfUsedSet();
|
||||
DropDownList list;
|
||||
for (int i = 0; i < n; i++) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(T::GetSet(i)->name, i, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(T::GetSet(i)->GetListLabel(), i, false));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ enum GameOptionsWidgets {
|
|||
WID_GO_GUI_SCALE_BEVEL_BUTTON, ///< Toggle for chunky bevels.
|
||||
WID_GO_BASE_GRF_DROPDOWN, ///< Use to select a base GRF.
|
||||
WID_GO_BASE_GRF_PARAMETERS, ///< Base GRF parameters.
|
||||
WID_GO_BASE_GRF_STATUS, ///< Info about missing files etc.
|
||||
WID_GO_BASE_GRF_TEXTFILE, ///< Open base GRF readme, changelog (+1) or license (+2).
|
||||
WID_GO_BASE_GRF_DESCRIPTION = WID_GO_BASE_GRF_TEXTFILE + TFT_CONTENT_END, ///< Description of selected base GRF.
|
||||
WID_GO_BASE_SFX_DROPDOWN, ///< Use to select a base SFX.
|
||||
|
@ -39,7 +38,6 @@ enum GameOptionsWidgets {
|
|||
WID_GO_TEXT_MUSIC_VOLUME, ///< Music volume label.
|
||||
WID_GO_BASE_MUSIC_VOLUME, ///< Change music volume.
|
||||
WID_GO_BASE_MUSIC_JUKEBOX, ///< Open the jukebox.
|
||||
WID_GO_BASE_MUSIC_STATUS, ///< Info about corrupted files etc.
|
||||
WID_GO_BASE_MUSIC_TEXTFILE, ///< Open base music readme, changelog (+1) or license (+2).
|
||||
WID_GO_BASE_MUSIC_DESCRIPTION = WID_GO_BASE_MUSIC_TEXTFILE + TFT_CONTENT_END, ///< Description of selected base music set.
|
||||
WID_GO_VIDEO_ACCEL_BUTTON, ///< Toggle for video acceleration.
|
||||
|
|
Loading…
Reference in New Issue