mirror of https://github.com/OpenTTD/OpenTTD
Feature: Adds font tab to game options dialog.
This commit adds a new tab to the game options for font settings. The two options on the GUI tab related to fonts (prefer sprites/AA settings) have been moved to the new fonts tab. New on the font tab are sliders for the 4 font sizes and a buttons that when clicked launches a load dialog to select a new ttf font.pull/12611/head
parent
4c8c67b8b5
commit
f21efd9b0d
|
@ -2233,7 +2233,7 @@ DEF_CONSOLE_CMD(ConFont)
|
|||
FontCacheSubSetting *setting = GetFontCacheSubSetting(fs);
|
||||
/* Make sure all non sprite fonts are loaded. */
|
||||
if (!setting->font.empty() && !fc->HasParent()) {
|
||||
InitFontCache(fs == FS_MONO);
|
||||
InitFontCache();
|
||||
fc = FontCache::Get(fs);
|
||||
}
|
||||
IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs));
|
||||
|
|
|
@ -54,6 +54,7 @@ static const char * const _subdirs[] = {
|
|||
"game" PATHSEP "library" PATHSEP, ///< GAME_LIBRARY_DIR
|
||||
"screenshot" PATHSEP, ///< SCREENSHOT_DIR
|
||||
"social_integration" PATHSEP, ///< SOCIAL_INTEGRATION_DIR
|
||||
"baseset" PATHSEP, ///< FONT_DIR
|
||||
};
|
||||
// This should line up with the "Subdirectory" enum defined in fileio_type.h
|
||||
static_assert(lengthof(_subdirs) == NUM_SUBDIRS);
|
||||
|
|
|
@ -18,6 +18,7 @@ enum AbstractFileType {
|
|||
FT_SAVEGAME, ///< old or new savegame
|
||||
FT_SCENARIO, ///< old or new scenario
|
||||
FT_HEIGHTMAP, ///< heightmap file
|
||||
FT_FONT, ///< font file
|
||||
|
||||
FT_INVALID = 7, ///< Invalid or unknown file type.
|
||||
FT_NUMBITS = 3, ///< Number of bits required for storing a #AbstractFileType value.
|
||||
|
@ -34,6 +35,9 @@ enum DetailedFileType {
|
|||
DFT_HEIGHTMAP_BMP, ///< BMP file.
|
||||
DFT_HEIGHTMAP_PNG, ///< PNG file.
|
||||
|
||||
/* UI Resource files: */
|
||||
DFT_FONT_FILE, ///< A font file
|
||||
|
||||
/* fios 'files' */
|
||||
DFT_FIOS_DRIVE, ///< A drive (letter) entry.
|
||||
DFT_FIOS_PARENT, ///< A parent directory entry.
|
||||
|
@ -48,9 +52,13 @@ enum DetailedFileType {
|
|||
|
||||
/** Operation performed on the file. */
|
||||
enum SaveLoadOperation {
|
||||
SLO_CHECK, ///< Load file for checking and/or preview.
|
||||
SLO_LOAD, ///< File is being loaded.
|
||||
SLO_SAVE, ///< File is being saved.
|
||||
SLO_CHECK, ///< Load file for checking and/or preview.
|
||||
SLO_LOAD, ///< File is being loaded.
|
||||
SLO_SAVE, ///< File is being saved.
|
||||
SLO_LOAD_SMALL_FONT, ///< Load small font
|
||||
SLO_LOAD_MEDIUM_FONT, ///< Load medium font
|
||||
SLO_LOAD_LARGE_FONT, ///< Load large font
|
||||
SLO_LOAD_MONOSPACED_FONT, ///< Load monospaced font
|
||||
|
||||
SLO_INVALID, ///< Unknown file operation.
|
||||
};
|
||||
|
@ -79,6 +87,7 @@ enum FiosType {
|
|||
FIOS_TYPE_OLD_SCENARIO = MAKE_FIOS_TYPE(FT_SCENARIO, DFT_OLD_GAME_FILE),
|
||||
FIOS_TYPE_PNG = MAKE_FIOS_TYPE(FT_HEIGHTMAP, DFT_HEIGHTMAP_PNG),
|
||||
FIOS_TYPE_BMP = MAKE_FIOS_TYPE(FT_HEIGHTMAP, DFT_HEIGHTMAP_BMP),
|
||||
FIOS_TYPE_FONT = MAKE_FIOS_TYPE(FT_FONT, DFT_FONT_FILE),
|
||||
|
||||
FIOS_TYPE_INVALID = MAKE_FIOS_TYPE(FT_INVALID, DFT_INVALID),
|
||||
};
|
||||
|
@ -125,6 +134,7 @@ enum Subdirectory {
|
|||
GAME_LIBRARY_DIR, ///< Subdirectory for all GS libraries
|
||||
SCREENSHOT_DIR, ///< Subdirectory for all screenshots
|
||||
SOCIAL_INTEGRATION_DIR, ///< Subdirectory for all social integration plugins
|
||||
FONT_DIR, ///< Subdirectory for all of OpenTTD's fonts.
|
||||
NUM_SUBDIRS, ///< Number of subdirectories
|
||||
NO_DIRECTORY, ///< A path without any base directory
|
||||
};
|
||||
|
@ -146,6 +156,7 @@ enum Searchpath : unsigned {
|
|||
SP_AUTODOWNLOAD_DIR, ///< Search within the autodownload directory
|
||||
SP_AUTODOWNLOAD_PERSONAL_DIR, ///< Search within the autodownload directory located in the personal directory
|
||||
SP_AUTODOWNLOAD_PERSONAL_DIR_XDG, ///< Search within the autodownload directory located in the personal directory (XDG variant)
|
||||
SP_SYSTEM_FONT_PATH, ///< Search within the system font directory
|
||||
NUM_SEARCHPATHS
|
||||
};
|
||||
|
||||
|
|
42
src/fios.cpp
42
src/fios.cpp
|
@ -67,7 +67,7 @@ void FileList::BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperati
|
|||
{
|
||||
this->clear();
|
||||
|
||||
assert(fop == SLO_LOAD || fop == SLO_SAVE);
|
||||
assert(fop == SLO_LOAD || fop == SLO_SAVE || fop == SLO_LOAD_SMALL_FONT || fop == SLO_LOAD_MEDIUM_FONT || fop == SLO_LOAD_LARGE_FONT || fop == SLO_LOAD_MONOSPACED_FONT);
|
||||
switch (abstract_filetype) {
|
||||
case FT_NONE:
|
||||
break;
|
||||
|
@ -84,6 +84,10 @@ void FileList::BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperati
|
|||
FiosGetHeightmapList(fop, show_dirs, *this);
|
||||
break;
|
||||
|
||||
case FT_FONT:
|
||||
FiosGetFontList(fop, show_dirs, *this);
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
@ -180,6 +184,7 @@ bool FiosBrowseTo(const FiosItem *item)
|
|||
case FIOS_TYPE_OLD_SCENARIO:
|
||||
case FIOS_TYPE_PNG:
|
||||
case FIOS_TYPE_BMP:
|
||||
case FIOS_TYPE_FONT:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -445,6 +450,41 @@ void FiosGetSavegameList(SaveLoadOperation fop, bool show_dirs, FileList &file_l
|
|||
FiosGetFileList(fop, show_dirs, &FiosGetSavegameListCallback, NO_DIRECTORY, file_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for FiosGetFontList. It tells if a file is a font or not.
|
||||
* @param fop Should be one of the SLO_LOAD_*_FONT types.)
|
||||
* @param file Name of the file to check.
|
||||
* @param ext A pointer to the extension identifier inside file
|
||||
* @return a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a font, and the title of the file (if any).
|
||||
* @see FiosGetFontList
|
||||
*/
|
||||
std::tuple<FiosType, std::string> FiosGetFontListCallback([[maybe_unused]] SaveLoadOperation fop, const std::string &file, const std::string_view ext)
|
||||
{
|
||||
if(StrEqualsIgnoreCase(ext, ".ttf")) {
|
||||
return { FIOS_TYPE_FONT, GetFileTitle(file, FONT_DIR) };
|
||||
}
|
||||
|
||||
return { FIOS_TYPE_INVALID, {} };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of fonts.
|
||||
* @param fop inteneded file operation. Should be one of the SLO_LOAD_*_FONT types.
|
||||
* @param show_dirs Whether to show directories.
|
||||
* @param file_list Destination of the found files.
|
||||
* @see FiosGetFileList
|
||||
*/
|
||||
void FiosGetFontList(SaveLoadOperation fop, bool show_dirs, FileList &file_list)
|
||||
{
|
||||
static std::optional<std::string> fios_font_path;
|
||||
|
||||
if (!fios_font_path) fios_font_path = FioFindDirectory(FONT_DIR);
|
||||
|
||||
_fios_path = &(*fios_font_path);
|
||||
|
||||
FiosGetFileList(fop, show_dirs, &FiosGetFontListCallback, NO_DIRECTORY, file_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for FiosGetFileList. It tells if a file is a scenario or not.
|
||||
* @param fop Purpose of collecting the list.
|
||||
|
|
|
@ -107,6 +107,7 @@ void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fo
|
|||
void FiosGetSavegameList(SaveLoadOperation fop, bool show_dirs, FileList &file_list);
|
||||
void FiosGetScenarioList(SaveLoadOperation fop, bool show_dirs, FileList &file_list);
|
||||
void FiosGetHeightmapList(SaveLoadOperation fop, bool show_dirs, FileList &file_list);
|
||||
void FiosGetFontList(SaveLoadOperation fop, bool show_dirs, FileList &file_list);
|
||||
|
||||
bool FiosBrowseTo(const FiosItem *item);
|
||||
|
||||
|
@ -119,6 +120,7 @@ std::string FiosMakeSavegameName(const char *name);
|
|||
std::tuple<FiosType, std::string> FiosGetSavegameListCallback(SaveLoadOperation fop, const std::string &file, const std::string_view ext);
|
||||
std::tuple<FiosType, std::string> FiosGetScenarioListCallback(SaveLoadOperation fop, const std::string &file, const std::string_view ext);
|
||||
std::tuple<FiosType, std::string> FiosGetHeightmapListCallback(SaveLoadOperation fop, const std::string &file, const std::string_view ext);
|
||||
std::tuple<FiosType, std::string> FiosGetFontListCallback(SaveLoadOperation fop, const std::string &file, const std::string_view ext);
|
||||
|
||||
void ScanScenarios();
|
||||
const char *FindScenario(const ContentInfo *ci, bool md5sum);
|
||||
|
|
176
src/fios_gui.cpp
176
src/fios_gui.cpp
|
@ -5,7 +5,7 @@
|
|||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file fios_gui.cpp GUIs for loading/saving games, scenarios, heightmaps, ... */
|
||||
/** @file fios_gui.cpp GUIs for loading/saving games, scenarios, heightmaps, fonts, ... */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "saveload/saveload.h"
|
||||
|
@ -18,6 +18,7 @@
|
|||
#include "strings_func.h"
|
||||
#include "fileio_func.h"
|
||||
#include "fios.h"
|
||||
#include "fontcache.h"
|
||||
#include "window_func.h"
|
||||
#include "tilehighlight_func.h"
|
||||
#include "querystring_gui.h"
|
||||
|
@ -62,6 +63,22 @@ void LoadCheckData::Clear()
|
|||
ClearGRFConfigList(&this->grfconfig);
|
||||
}
|
||||
|
||||
static FontSize GetFontSizeFromOperation(SaveLoadOperation operation)
|
||||
{
|
||||
switch(operation) {
|
||||
case SLO_LOAD_SMALL_FONT:
|
||||
return FS_SMALL;
|
||||
case SLO_LOAD_MEDIUM_FONT:
|
||||
return FS_NORMAL;
|
||||
case SLO_LOAD_LARGE_FONT:
|
||||
return FS_LARGE;
|
||||
case SLO_LOAD_MONOSPACED_FONT:
|
||||
return FS_MONO;
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
/** Load game/scenario with optional content download */
|
||||
static constexpr NWidgetPart _nested_load_dialog_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
|
@ -227,12 +244,69 @@ static constexpr NWidgetPart _nested_save_dialog_widgets[] = {
|
|||
EndContainer(),
|
||||
};
|
||||
|
||||
/** Load font */
|
||||
static constexpr NWidgetPart _nested_load_font_dialog_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
|
||||
/* Current directory and free space */
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
/* Left side : filter box and available files */
|
||||
NWidget(NWID_VERTICAL),
|
||||
|
||||
/* Filter box with label */
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1),
|
||||
NWidget(NWID_HORIZONTAL), SetPadding(WidgetDimensions::unscaled.framerect.top, 0, WidgetDimensions::unscaled.framerect.bottom, 0), SetPIP(WidgetDimensions::unscaled.frametext.left, WidgetDimensions::unscaled.frametext.right, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL),
|
||||
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
/* Sort buttons */
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON),
|
||||
EndContainer(),
|
||||
|
||||
/* Files */
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND),
|
||||
NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetPadding(2, 2, 2, 2), SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_SAVE_OSK_TITLE), SetPadding(2, 2, 2, 2), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_SAVELOAD_OSKTITLE, STR_SAVELOAD_EDITBOX_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_USE_DEFAULT_FONT), SetDataTip(STR_SAVELOAD_USE_DEFAULT_FONT, STR_SAVELOAD_USE_DEFAULT_FONT_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_FONT_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1),
|
||||
EndContainer(),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
/** Text colours of #DetailedFileType fios entries in the window. */
|
||||
static const TextColour _fios_colours[] = {
|
||||
TC_LIGHT_BROWN, // DFT_OLD_GAME_FILE
|
||||
TC_ORANGE, // DFT_GAME_FILE
|
||||
TC_YELLOW, // DFT_HEIGHTMAP_BMP
|
||||
TC_ORANGE, // DFT_HEIGHTMAP_PNG
|
||||
TC_GOLD, // DFT_FONT_FILE
|
||||
TC_LIGHT_BLUE, // DFT_FIOS_DRIVE
|
||||
TC_DARK_GREEN, // DFT_FIOS_PARENT
|
||||
TC_DARK_GREEN, // DFT_FIOS_DIR
|
||||
|
@ -306,7 +380,7 @@ public:
|
|||
SaveLoadWindow(WindowDesc *desc, AbstractFileType abstract_filetype, SaveLoadOperation fop)
|
||||
: Window(desc), filename_editbox(64), abstract_filetype(abstract_filetype), fop(fop), filter_editbox(EDITBOX_MAX_SIZE)
|
||||
{
|
||||
assert(this->fop == SLO_SAVE || this->fop == SLO_LOAD);
|
||||
assert(this->fop == SLO_SAVE || this->fop == SLO_LOAD || this->fop == SLO_LOAD_SMALL_FONT || this->fop == SLO_LOAD_MEDIUM_FONT || this->fop == SLO_LOAD_LARGE_FONT || this->fop == SLO_LOAD_MONOSPACED_FONT);
|
||||
|
||||
/* For saving, construct an initial file name. */
|
||||
if (this->fop == SLO_SAVE) {
|
||||
|
@ -347,6 +421,25 @@ public:
|
|||
caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_HEIGHTMAP : STR_SAVELOAD_LOAD_HEIGHTMAP;
|
||||
break;
|
||||
|
||||
case FT_FONT:
|
||||
switch (this->fop) {
|
||||
case SLO_LOAD_SMALL_FONT:
|
||||
caption_string = STR_SAVELOAD_LOAD_SMALL_FONT_CAPTION;
|
||||
break;
|
||||
case SLO_LOAD_MEDIUM_FONT:
|
||||
caption_string = STR_SAVELOAD_LOAD_MEDIUM_FONT_CAPTION;
|
||||
break;
|
||||
case SLO_LOAD_LARGE_FONT:
|
||||
caption_string = STR_SAVELOAD_LOAD_LARGE_FONT_CAPTION;
|
||||
break;
|
||||
case SLO_LOAD_MONOSPACED_FONT:
|
||||
caption_string = STR_SAVELOAD_LOAD_MONOSPACED_FONT_CAPTION;
|
||||
break;
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
@ -385,6 +478,10 @@ public:
|
|||
o_dir.name = FioFindDirectory(HEIGHTMAP_DIR);
|
||||
break;
|
||||
|
||||
case FT_FONT:
|
||||
o_dir.name = FioFindDirectory(FONT_DIR);
|
||||
break;
|
||||
|
||||
default:
|
||||
o_dir.name = _personal_dir;
|
||||
}
|
||||
|
@ -620,16 +717,48 @@ public:
|
|||
case WID_SL_LOAD_BUTTON: {
|
||||
if (this->selected == nullptr || _load_check_data.HasErrors()) break;
|
||||
|
||||
_file_to_saveload.Set(*this->selected);
|
||||
switch(this->abstract_filetype) {
|
||||
|
||||
if (this->abstract_filetype == FT_HEIGHTMAP) {
|
||||
this->Close();
|
||||
ShowHeightmapLoad();
|
||||
} else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
|
||||
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
|
||||
ClearErrorMessages();
|
||||
this->Close();
|
||||
case FT_HEIGHTMAP:
|
||||
case FT_SAVEGAME:
|
||||
case FT_SCENARIO:
|
||||
_file_to_saveload.Set(*this->selected);
|
||||
|
||||
if (this->abstract_filetype == FT_HEIGHTMAP) {
|
||||
this->Close();
|
||||
ShowHeightmapLoad();
|
||||
} else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
|
||||
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
|
||||
ClearErrorMessages();
|
||||
this->Close();
|
||||
}
|
||||
break;
|
||||
|
||||
case FT_FONT: {
|
||||
// Font that we need to change is coded in the fop:
|
||||
FontSize font_size = GetFontSizeFromOperation(this->fop);
|
||||
FontCacheSubSetting *current_font_config = GetFontCacheSubSetting(font_size);
|
||||
|
||||
SetFont(font_size, this->selected->name, current_font_config->size);
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_SL_USE_DEFAULT_FONT: {
|
||||
// Font that we need to change is coded in the fop:
|
||||
FontSize font_size = GetFontSizeFromOperation(this->fop);
|
||||
FontCacheSubSetting *current_font_config = GetFontCacheSubSetting(font_size);
|
||||
|
||||
// Using empty string for the font name will trigger a load of the deafult font.
|
||||
SetFont(font_size, "", current_font_config->size);
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -863,6 +992,10 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
case FT_FONT: {
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
@ -907,6 +1040,13 @@ static WindowDesc _save_dialog_desc(
|
|||
std::begin(_nested_save_dialog_widgets), std::end(_nested_save_dialog_widgets)
|
||||
);
|
||||
|
||||
static WindowDesc _load_font_dialog_desc(
|
||||
WDP_CENTER, "load_font", 500, 294,
|
||||
WC_SAVELOAD, WC_NONE,
|
||||
0,
|
||||
std::begin(_nested_load_font_dialog_widgets), std::end(_nested_load_font_dialog_widgets)
|
||||
);
|
||||
|
||||
/**
|
||||
* Launch save/load dialog in the given mode.
|
||||
* @param abstract_filetype Kind of file to handle.
|
||||
|
@ -920,8 +1060,20 @@ void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fo
|
|||
if (fop == SLO_SAVE) {
|
||||
sld = &_save_dialog_desc;
|
||||
} else {
|
||||
/* Dialogue for loading a file. */
|
||||
sld = (abstract_filetype == FT_HEIGHTMAP) ? &_load_heightmap_dialog_desc : &_load_dialog_desc;
|
||||
/* Dialog for loading a file. Custom ones for loading heightmaps and fonts. Everything else uses the generic load dialog. */
|
||||
switch (abstract_filetype) {
|
||||
case FT_HEIGHTMAP:
|
||||
sld = &_load_heightmap_dialog_desc;
|
||||
break;
|
||||
|
||||
case FT_FONT:
|
||||
sld = &_load_font_dialog_desc;
|
||||
break;
|
||||
|
||||
default:
|
||||
sld = &_load_dialog_desc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
new SaveLoadWindow(sld, abstract_filetype, fop);
|
||||
|
|
|
@ -99,42 +99,16 @@ bool GetFontAAState()
|
|||
return _fcsettings.global_aa;
|
||||
}
|
||||
|
||||
void SetFont(FontSize fontsize, const std::string &font, uint size)
|
||||
void DebugPrintFontSettings(const std::string& desc)
|
||||
{
|
||||
FontCacheSubSetting *setting = GetFontCacheSubSetting(fontsize);
|
||||
bool changed = false;
|
||||
Debug(fontcache, 3, "{}", desc);
|
||||
|
||||
if (setting->font != font) {
|
||||
setting->font = font;
|
||||
changed = true;
|
||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
||||
FontCache* loadedFont = FontCache::Get(fs);
|
||||
FontCacheSubSetting* setting = GetFontCacheSubSetting(fs);
|
||||
|
||||
Debug(fontcache, 3, " {}: Actual Font={} Setting={}", FontSizeToName(fs), (loadedFont == NULL) ? "NULL" : loadedFont->GetFontName(), setting->font);
|
||||
}
|
||||
|
||||
if (setting->size != size) {
|
||||
setting->size = size;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!changed) return;
|
||||
|
||||
if (fontsize != FS_MONO) {
|
||||
/* Try to reload only the modified font. */
|
||||
FontCacheSettings backup = _fcsettings;
|
||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
||||
if (fs == fontsize) continue;
|
||||
FontCache *fc = FontCache::Get(fs);
|
||||
GetFontCacheSubSetting(fs)->font = fc->HasParent() ? fc->GetFontName() : "";
|
||||
}
|
||||
CheckForMissingGlyphs();
|
||||
_fcsettings = backup;
|
||||
} else {
|
||||
InitFontCache(true);
|
||||
}
|
||||
|
||||
LoadStringWidthTable();
|
||||
UpdateAllVirtCoords();
|
||||
ReInitAllWindows(true);
|
||||
|
||||
if (_save_config) SaveToConfig();
|
||||
}
|
||||
|
||||
#ifdef WITH_FREETYPE
|
||||
|
@ -149,7 +123,81 @@ extern void LoadCoreTextFont(FontSize fs);
|
|||
extern void LoadCoreTextFont(FontSize fs, const std::string &file_name, uint size);
|
||||
#endif
|
||||
|
||||
static void TryLoadDefaultTrueTypeFont([[maybe_unused]] FontSize fs)
|
||||
static void TryLoadDefaultTrueTypeFont([[maybe_unused]] FontSize fs, [[maybe_unused]] uint size);
|
||||
|
||||
[[maybe_unused]] static void LoadFontHelper([[maybe_unused]]FontSize fs)
|
||||
{
|
||||
#ifdef WITH_FREETYPE
|
||||
LoadFreeTypeFont(fs);
|
||||
#elif defined(_WIN32)
|
||||
LoadWin32Font(fs);
|
||||
#elif defined(WITH_COCOA)
|
||||
LoadCoreTextFont(fs);
|
||||
#endif
|
||||
}
|
||||
|
||||
[[maybe_unused]] static void LoadFontHelper([[maybe_unused]] FontSize fs, [[maybe_unused]] const std::string &file_name, [[maybe_unused]] uint size)
|
||||
{
|
||||
#ifdef WITH_FREETYPE
|
||||
LoadFreeTypeFont(fs, file_name, size);
|
||||
#elif defined(_WIN32)
|
||||
LoadWin32Font(fs, file_name, size);
|
||||
#elif defined(WITH_COCOA)
|
||||
LoadCoreTextFont(fs, file_name, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResizeFont(FontSize font_size, uint size)
|
||||
{
|
||||
FontCacheSubSetting *setting = GetFontCacheSubSetting(font_size);
|
||||
|
||||
if (setting->size == size) {
|
||||
return;
|
||||
}
|
||||
|
||||
setting->size = size;
|
||||
|
||||
// Default fonts are empty here. We will allow the user to resize the default font:
|
||||
if (setting->font.empty()){
|
||||
TryLoadDefaultTrueTypeFont(font_size, size);
|
||||
} else {
|
||||
LoadFontHelper(font_size);
|
||||
}
|
||||
|
||||
LoadStringWidthTable();
|
||||
UpdateAllVirtCoords();
|
||||
ReInitAllWindows(true);
|
||||
|
||||
if (_save_config) SaveToConfig();
|
||||
}
|
||||
|
||||
void SetFont(FontSize font_size, const std::string &font, uint size)
|
||||
{
|
||||
FontCacheSubSetting *setting = GetFontCacheSubSetting(font_size);
|
||||
bool changed = false;
|
||||
|
||||
if (setting->font != font) {
|
||||
setting->font = font;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (setting->size != size) {
|
||||
setting->size = size;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!changed) return;
|
||||
|
||||
CheckForMissingGlyphs();
|
||||
|
||||
LoadStringWidthTable();
|
||||
UpdateAllVirtCoords();
|
||||
ReInitAllWindows(true);
|
||||
|
||||
if (_save_config) SaveToConfig();
|
||||
}
|
||||
|
||||
static void TryLoadDefaultTrueTypeFont([[maybe_unused]] FontSize fs, [[maybe_unused]] uint size = 0)
|
||||
{
|
||||
#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
|
||||
std::string font_name{};
|
||||
|
@ -173,14 +221,11 @@ static void TryLoadDefaultTrueTypeFont([[maybe_unused]] FontSize fs)
|
|||
/* Find font file. */
|
||||
std::string full_font = FioFindFullPath(BASESET_DIR, font_name);
|
||||
if (!full_font.empty()) {
|
||||
int size = FontCache::GetDefaultFontHeight(fs);
|
||||
#ifdef WITH_FREETYPE
|
||||
LoadFreeTypeFont(fs, full_font, size);
|
||||
#elif defined(_WIN32)
|
||||
LoadWin32Font(fs, full_font, size);
|
||||
#elif defined(WITH_COCOA)
|
||||
LoadCoreTextFont(fs, full_font, size);
|
||||
#endif
|
||||
if (size == 0) {
|
||||
size = FontCache::GetDefaultFontHeight(fs);
|
||||
}
|
||||
|
||||
LoadFontHelper(fs, full_font, size);
|
||||
}
|
||||
#endif /* defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA) */
|
||||
}
|
||||
|
@ -189,28 +234,34 @@ static void TryLoadDefaultTrueTypeFont([[maybe_unused]] FontSize fs)
|
|||
* (Re)initialize the font cache related things, i.e. load the non-sprite fonts.
|
||||
* @param monospace Whether to initialise the monospace or regular fonts.
|
||||
*/
|
||||
void InitFontCache(bool monospace)
|
||||
void InitFontCache()
|
||||
{
|
||||
FontCache::InitializeFontCaches();
|
||||
|
||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
||||
if (monospace != (fs == FS_MONO)) continue;
|
||||
|
||||
FontCache *fc = FontCache::Get(fs);
|
||||
if (fc->HasParent()) delete fc;
|
||||
if (fc->HasParent()) {
|
||||
delete fc;
|
||||
}
|
||||
|
||||
if (!_fcsettings.prefer_sprite && GetFontCacheSubSetting(fs)->font.empty()) {
|
||||
TryLoadDefaultTrueTypeFont(fs);
|
||||
FontCacheSubSetting *setting = GetFontCacheSubSetting(fs);
|
||||
|
||||
if (_fcsettings.prefer_sprite){
|
||||
std::string backup = setting->font;
|
||||
setting->font = "";
|
||||
LoadFontHelper(fs);
|
||||
setting->font = backup;
|
||||
} else {
|
||||
#ifdef WITH_FREETYPE
|
||||
LoadFreeTypeFont(fs);
|
||||
#elif defined(_WIN32)
|
||||
LoadWin32Font(fs);
|
||||
#elif defined(WITH_COCOA)
|
||||
LoadCoreTextFont(fs);
|
||||
#endif
|
||||
if (setting->font.empty()) {
|
||||
TryLoadDefaultTrueTypeFont(fs, setting->size);
|
||||
} else {
|
||||
LoadFontHelper(fs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DebugPrintFontSettings("End of initFontCache()");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -239,10 +239,13 @@ inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs)
|
|||
}
|
||||
}
|
||||
|
||||
void InitFontCache(bool monospace);
|
||||
void DebugPrintFontSettings(const std::string& desc);
|
||||
|
||||
void InitFontCache();
|
||||
void UninitFontCache();
|
||||
|
||||
bool GetFontAAState();
|
||||
void SetFont(FontSize fontsize, const std::string &font, uint size);
|
||||
void ResizeFont(FontSize fontsize, uint size);
|
||||
|
||||
#endif /* FONTCACHE_H */
|
||||
|
|
|
@ -947,6 +947,8 @@ STR_GAME_OPTIONS_TAB_GENERAL :General
|
|||
STR_GAME_OPTIONS_TAB_GENERAL_TT :{BLACK}Choose general settings
|
||||
STR_GAME_OPTIONS_TAB_GRAPHICS :Graphics
|
||||
STR_GAME_OPTIONS_TAB_GRAPHICS_TT :{BLACK}Choose graphics settings
|
||||
STR_GAME_OPTIONS_TAB_FONTS :Fonts
|
||||
STR_GAME_OPTIONS_TAB_FONTS_TT :{BLACK}Choose font settings
|
||||
STR_GAME_OPTIONS_TAB_SOUND :Sound
|
||||
STR_GAME_OPTIONS_TAB_SOUND_TT :{BLACK}Choose sound and music settings
|
||||
STR_GAME_OPTIONS_TAB_SOCIAL :Social
|
||||
|
@ -1049,6 +1051,19 @@ STR_GAME_OPTIONS_GUI_SCALE_AUTO_TOOLTIP :{BLACK}Check th
|
|||
STR_GAME_OPTIONS_GUI_SCALE_BEVELS :{BLACK}Scale bevels
|
||||
STR_GAME_OPTIONS_GUI_SCALE_BEVELS_TOOLTIP :{BLACK}Check this box to scale bevels by interface size
|
||||
|
||||
STR_GAME_OPTIONS_SMALL_FONT_FRAME :{BLACK}Small font
|
||||
STR_GAME_OPTIONS_LOAD_SMALL_FONT_TOOLTIP :{BLACK}Choose small font. Used in map legends and on graphs.
|
||||
STR_GAME_OPTIONS_SMALL_FONT_SIZE_SLIDER_TOOLTIP :{BLACK}Drag to change the small size
|
||||
STR_GAME_OPTIONS_MEDIUM_FONT_FRAME :{BLACK}Medium font
|
||||
STR_GAME_OPTIONS_LOAD_MEDIUM_FONT_TOOLTIP :{BLACK}Choose medium font. Most text is displayed using this font.
|
||||
STR_GAME_OPTIONS_MEDIUM_FONT_SIZE_SLIDER_TOOLTIP :{BLACK}Drag to change the medium font size
|
||||
STR_GAME_OPTIONS_LARGE_FONT_FRAME :{BLACK}Large font
|
||||
STR_GAME_OPTIONS_LOAD_LARGE_FONT_TOOLTIP :{BLACK}Choose large font. Used to display News headlines.
|
||||
STR_GAME_OPTIONS_LARGE_FONT_SIZE_SLIDER_TOOLTIP :{BLACK}Drag to change the large font size
|
||||
STR_GAME_OPTIONS_MONOSPACED_FONT_FRAME :{BLACK}Monospaced font
|
||||
STR_GAME_OPTIONS_LOAD_MONOSPACED_FONT_TOOLTIP :{BLACK}Choose monospaced font. Used to display the Readme and other documents.
|
||||
STR_GAME_OPTIONS_MONOSPACED_FONT_SIZE_SLIDER_TOOLTIP :{BLACK}Drag to change the monospaced font size
|
||||
STR_GAME_OPTIONS_FONT_SIZE :{BLACK}Size:
|
||||
STR_GAME_OPTIONS_GUI_FONT_SPRITE :{BLACK}Use traditional sprite font
|
||||
STR_GAME_OPTIONS_GUI_FONT_SPRITE_TOOLTIP :{BLACK}Check this box if you prefer to use the traditional fixed-size sprite font
|
||||
STR_GAME_OPTIONS_GUI_FONT_AA :{BLACK}Anti-alias fonts
|
||||
|
@ -3257,6 +3272,10 @@ STR_SAVELOAD_SAVE_SCENARIO :{WHITE}Save Sce
|
|||
STR_SAVELOAD_LOAD_SCENARIO :{WHITE}Load Scenario
|
||||
STR_SAVELOAD_LOAD_HEIGHTMAP :{WHITE}Load Heightmap
|
||||
STR_SAVELOAD_SAVE_HEIGHTMAP :{WHITE}Save Heightmap
|
||||
STR_SAVELOAD_LOAD_SMALL_FONT_CAPTION :{WHITE}Load Small Font
|
||||
STR_SAVELOAD_LOAD_MEDIUM_FONT_CAPTION :{WHITE}Load Medium Font
|
||||
STR_SAVELOAD_LOAD_LARGE_FONT_CAPTION :{WHITE}Load Large Font
|
||||
STR_SAVELOAD_LOAD_MONOSPACED_FONT_CAPTION :{WHITE}Load Monospaced Font
|
||||
STR_SAVELOAD_HOME_BUTTON :{BLACK}Click here to jump to the current default save/load directory
|
||||
STR_SAVELOAD_BYTES_FREE :{BLACK}{BYTES} free
|
||||
STR_SAVELOAD_LIST_TOOLTIP :{BLACK}List of drives, directories and saved-game files
|
||||
|
@ -3268,6 +3287,9 @@ STR_SAVELOAD_SAVE_TOOLTIP :{BLACK}Save the
|
|||
STR_SAVELOAD_LOAD_BUTTON :{BLACK}Load
|
||||
STR_SAVELOAD_LOAD_TOOLTIP :{BLACK}Load the selected game
|
||||
STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP :{BLACK}Load the selected heightmap
|
||||
STR_SAVELOAD_LOAD_FONT_TOOLTIP :{BLACK}Load the selected font
|
||||
STR_SAVELOAD_USE_DEFAULT_FONT :{BLACK}Use Default Font
|
||||
STR_SAVELOAD_USE_DEFAULT_FONT_TOOLTIP :{BLACK}Use the default TTF font provided with OpenTTD.
|
||||
STR_SAVELOAD_DETAIL_CAPTION :{BLACK}Game Details
|
||||
STR_SAVELOAD_DETAIL_NOT_AVAILABLE :{BLACK}No information available
|
||||
STR_SAVELOAD_DETAIL_COMPANY_INDEX :{SILVER}{COMMA}: {WHITE}{STRING1}
|
||||
|
|
|
@ -699,7 +699,7 @@ int openttd_main(std::span<char * const> arguments)
|
|||
InitializeLanguagePacks();
|
||||
|
||||
/* Initialize the font cache */
|
||||
InitFontCache(false);
|
||||
InitFontCache();
|
||||
|
||||
/* This must be done early, since functions use the SetWindowDirty* calls */
|
||||
InitWindowSystem();
|
||||
|
|
|
@ -169,7 +169,7 @@ bool SetFallbackFont(FontCacheSettings *settings, const std::string &language_is
|
|||
if (best_font != nullptr) {
|
||||
ret = true;
|
||||
callback->SetFontNames(settings, best_font, &best_index);
|
||||
InitFontCache(callback->Monospace());
|
||||
InitFontCache();
|
||||
}
|
||||
|
||||
/* Clean up the list of filenames. */
|
||||
|
|
|
@ -174,7 +174,33 @@ static StringID VolumeMarkFunc(int, int mark, int value)
|
|||
return STR_GAME_OPTIONS_VOLUME_MARK;
|
||||
}
|
||||
|
||||
static constexpr NWidgetPart _nested_social_plugins_widgets[] = {
|
||||
static const int _min_small_font_size = 6;
|
||||
static const int _max_small_font_size = 20;
|
||||
|
||||
static const int _min_medium_font_size = 8;
|
||||
static const int _max_medium_font_size = 22;
|
||||
|
||||
static const int _min_large_font_size = 18;
|
||||
static const int _max_large_font_size = 32;
|
||||
|
||||
static const int _min_monospaced_font_size = 8;
|
||||
static const int _max_monospaced_font_size = 22;
|
||||
|
||||
static const int FONT_SLIDER_MARK_COUNT = 15; // Labeled at every even number. 8 Labeled marks and 7 unlabeled ones.
|
||||
|
||||
static StringID FontSizeMarkFunction([[maybe_unused]] int mark_count, int mark, int value)
|
||||
{
|
||||
// Skip the odd marks :
|
||||
if ((mark & 1) == 1) {
|
||||
return STR_NULL;
|
||||
}
|
||||
|
||||
SetDParam(0, value);
|
||||
|
||||
return STR_JUST_INT;
|
||||
}
|
||||
|
||||
static const NWidgetPart _nested_social_plugins_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_FRAME, COLOUR_GREY, WID_GO_SOCIAL_PLUGIN_TITLE), SetDataTip(STR_JUST_STRING2, STR_NULL),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
|
@ -356,6 +382,12 @@ struct GameOptionsWindow : Window {
|
|||
GameSettings *opt;
|
||||
bool reload;
|
||||
int gui_scale;
|
||||
|
||||
int small_font_size;
|
||||
int medium_font_size;
|
||||
int large_font_size;
|
||||
int monospaced_font_size;
|
||||
|
||||
static inline WidgetID active_tab = WID_GO_TAB_GENERAL;
|
||||
|
||||
GameOptionsWindow(WindowDesc *desc) : Window(desc)
|
||||
|
@ -364,6 +396,11 @@ struct GameOptionsWindow : Window {
|
|||
this->reload = false;
|
||||
this->gui_scale = _gui_scale;
|
||||
|
||||
this->small_font_size = std::clamp(static_cast<int>(_fcsettings.small.size), _min_small_font_size, _max_small_font_size);
|
||||
this->medium_font_size = std::clamp(static_cast<int>(_fcsettings.medium.size), _min_medium_font_size, _max_medium_font_size);
|
||||
this->large_font_size = std::clamp(static_cast<int>(_fcsettings.large.size), _min_large_font_size, _max_large_font_size);
|
||||
this->monospaced_font_size = std::clamp(static_cast<int>(_fcsettings.mono.size), _min_monospaced_font_size, _max_monospaced_font_size);
|
||||
|
||||
AddCustomRefreshRates();
|
||||
|
||||
this->InitNested(WN_GAME_OPTIONS_GAME_OPTIONS);
|
||||
|
@ -540,6 +577,22 @@ struct GameOptionsWindow : Window {
|
|||
plugin->SetStringParameters(widget);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_FONT_LOAD_SMALL_FONT:
|
||||
SetDParamStr(0, FontCache::Get(FS_SMALL)->GetFontName());
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LOAD_MEDIUM_FONT:
|
||||
SetDParamStr(0, FontCache::Get(FS_NORMAL)->GetFontName());
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LOAD_LARGE_FONT:
|
||||
SetDParamStr(0, FontCache::Get(FS_LARGE)->GetFontName());
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LOAD_MONOSPACED_FONT:
|
||||
SetDParamStr(0, FontCache::Get(FS_MONO)->GetFontName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,6 +623,22 @@ struct GameOptionsWindow : Window {
|
|||
DrawStringMultiLine(r, STR_GAME_OPTIONS_VIDEO_DRIVER_INFO);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_SMALL_FONT_SIZE_SLIDER:
|
||||
DrawSliderWidget(r, _min_small_font_size, _max_small_font_size, FONT_SLIDER_MARK_COUNT, this->small_font_size, FontSizeMarkFunction);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_MEDIUM_FONT_SIZE_SLIDER:
|
||||
DrawSliderWidget(r, _min_medium_font_size, _max_medium_font_size, FONT_SLIDER_MARK_COUNT, this->medium_font_size, FontSizeMarkFunction);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LARGE_FONT_SIZE_SLIDER:
|
||||
DrawSliderWidget(r, _min_large_font_size, _max_large_font_size, FONT_SLIDER_MARK_COUNT, this->large_font_size, FontSizeMarkFunction);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_MONOSPACED_FONT_SIZE_SLIDER:
|
||||
DrawSliderWidget(r, _min_monospaced_font_size, _max_monospaced_font_size, FONT_SLIDER_MARK_COUNT, this->monospaced_font_size, FontSizeMarkFunction);
|
||||
break;
|
||||
|
||||
case WID_GO_BASE_SFX_VOLUME:
|
||||
DrawSliderWidget(r, 0, INT8_MAX, VOLUME_NMARKS, _settings_client.music.effect_vol, VolumeMarkFunc);
|
||||
break;
|
||||
|
@ -577,12 +646,13 @@ struct GameOptionsWindow : Window {
|
|||
case WID_GO_BASE_MUSIC_VOLUME:
|
||||
DrawSliderWidget(r, 0, INT8_MAX, VOLUME_NMARKS, _settings_client.music.music_vol, VolumeMarkFunc);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SetTab(WidgetID widget)
|
||||
{
|
||||
this->SetWidgetsLoweredState(false, WID_GO_TAB_GENERAL, WID_GO_TAB_GRAPHICS, WID_GO_TAB_SOUND, WID_GO_TAB_SOCIAL);
|
||||
this->SetWidgetsLoweredState(false, WID_GO_TAB_GENERAL, WID_GO_TAB_GRAPHICS, WID_GO_TAB_FONTS, WID_GO_TAB_SOUND, WID_GO_TAB_SOCIAL);
|
||||
this->LowerWidget(widget);
|
||||
GameOptionsWindow::active_tab = widget;
|
||||
|
||||
|
@ -590,8 +660,9 @@ struct GameOptionsWindow : Window {
|
|||
switch (widget) {
|
||||
case WID_GO_TAB_GENERAL: pane = 0; break;
|
||||
case WID_GO_TAB_GRAPHICS: pane = 1; break;
|
||||
case WID_GO_TAB_SOUND: pane = 2; break;
|
||||
case WID_GO_TAB_SOCIAL: pane = 3; break;
|
||||
case WID_GO_TAB_FONTS: pane = 2; break;
|
||||
case WID_GO_TAB_SOUND: pane = 3; break;
|
||||
case WID_GO_TAB_SOCIAL: pane = 4; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
|
@ -685,6 +756,7 @@ struct GameOptionsWindow : Window {
|
|||
switch (widget) {
|
||||
case WID_GO_TAB_GENERAL:
|
||||
case WID_GO_TAB_GRAPHICS:
|
||||
case WID_GO_TAB_FONTS:
|
||||
case WID_GO_TAB_SOUND:
|
||||
case WID_GO_TAB_SOCIAL:
|
||||
this->SetTab(widget);
|
||||
|
@ -759,26 +831,33 @@ struct GameOptionsWindow : Window {
|
|||
}
|
||||
|
||||
#ifdef HAS_TRUETYPE_FONT
|
||||
case WID_GO_GUI_FONT_SPRITE:
|
||||
case WID_GO_FONT_SPRITE:
|
||||
_fcsettings.prefer_sprite = !_fcsettings.prefer_sprite;
|
||||
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_FONT_SPRITE, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_GUI_FONT_AA, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetLoweredState(WID_GO_FONT_SPRITE, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_AA, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_LOAD_SMALL_FONT, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_SMALL_FONT_SIZE_SLIDER, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_LOAD_MEDIUM_FONT, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_MEDIUM_FONT_SIZE_SLIDER, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_LOAD_LARGE_FONT, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_LARGE_FONT_SIZE_SLIDER, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_LOAD_MONOSPACED_FONT, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_MONOSPACED_FONT_SIZE_SLIDER, _fcsettings.prefer_sprite);
|
||||
this->SetDirty();
|
||||
|
||||
InitFontCache(false);
|
||||
InitFontCache(true);
|
||||
ClearFontCache();
|
||||
InitFontCache();
|
||||
CheckForMissingGlyphs();
|
||||
SetupWidgetDimensions();
|
||||
UpdateAllVirtCoords();
|
||||
ReInitAllWindows(true);
|
||||
break;
|
||||
|
||||
case WID_GO_GUI_FONT_AA:
|
||||
case WID_GO_FONT_AA:
|
||||
_fcsettings.global_aa = !_fcsettings.global_aa;
|
||||
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_FONT_AA, _fcsettings.global_aa);
|
||||
this->SetWidgetLoweredState(WID_GO_FONT_AA, _fcsettings.global_aa);
|
||||
MarkWholeScreenDirty();
|
||||
|
||||
ClearFontCache();
|
||||
|
@ -818,6 +897,50 @@ struct GameOptionsWindow : Window {
|
|||
break;
|
||||
}
|
||||
|
||||
case WID_GO_FONT_LOAD_SMALL_FONT:
|
||||
ShowSaveLoadDialog(FT_FONT, SLO_LOAD_SMALL_FONT);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LOAD_MEDIUM_FONT:
|
||||
ShowSaveLoadDialog(FT_FONT, SLO_LOAD_MEDIUM_FONT);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LOAD_LARGE_FONT:
|
||||
ShowSaveLoadDialog(FT_FONT, SLO_LOAD_LARGE_FONT);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LOAD_MONOSPACED_FONT:
|
||||
ShowSaveLoadDialog(FT_FONT, SLO_LOAD_MONOSPACED_FONT);
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_SMALL_FONT_SIZE_SLIDER:
|
||||
ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, _min_small_font_size, _max_small_font_size, FONT_SLIDER_MARK_COUNT, this->small_font_size);
|
||||
this->SetWidgetDirty(widget);
|
||||
|
||||
if (click_count > 0) this->mouse_capture_widget = widget;
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_MEDIUM_FONT_SIZE_SLIDER:
|
||||
ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, _min_medium_font_size, _max_medium_font_size, FONT_SLIDER_MARK_COUNT, this->medium_font_size);
|
||||
this->SetWidgetDirty(widget);
|
||||
|
||||
if (click_count > 0) this->mouse_capture_widget = widget;
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_LARGE_FONT_SIZE_SLIDER:
|
||||
ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, _min_large_font_size, _max_large_font_size, FONT_SLIDER_MARK_COUNT, this->large_font_size);
|
||||
this->SetWidgetDirty(widget);
|
||||
|
||||
if (click_count > 0) this->mouse_capture_widget = widget;
|
||||
break;
|
||||
|
||||
case WID_GO_FONT_MONOSPACED_FONT_SIZE_SLIDER:
|
||||
ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, _min_monospaced_font_size, _max_monospaced_font_size, FONT_SLIDER_MARK_COUNT, this->monospaced_font_size);
|
||||
this->SetWidgetDirty(widget);
|
||||
|
||||
if (click_count > 0) this->mouse_capture_widget = widget;
|
||||
break;
|
||||
|
||||
case WID_GO_BASE_SFX_VOLUME:
|
||||
case WID_GO_BASE_MUSIC_VOLUME: {
|
||||
uint8_t &vol = (widget == WID_GO_BASE_MUSIC_VOLUME) ? _settings_client.music.music_vol : _settings_client.music.effect_vol;
|
||||
|
@ -877,14 +1000,27 @@ struct GameOptionsWindow : Window {
|
|||
|
||||
void OnMouseLoop() override
|
||||
{
|
||||
if (_left_button_down || this->gui_scale == _gui_scale) return;
|
||||
if (_left_button_down) {
|
||||
return;
|
||||
}
|
||||
|
||||
_gui_scale_cfg = this->gui_scale;
|
||||
if (this->gui_scale != _gui_scale)
|
||||
{
|
||||
_gui_scale_cfg = this->gui_scale;
|
||||
|
||||
if (AdjustGUIZoom(false)) {
|
||||
ReInitAllWindows(true);
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false);
|
||||
this->SetDirty();
|
||||
if (AdjustGUIZoom(false)) {
|
||||
ReInitAllWindows(true);
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false);
|
||||
this->SetDirty();
|
||||
}
|
||||
} else if (static_cast<uint>(this->small_font_size) != _fcsettings.small.size) {
|
||||
ResizeFont(FS_SMALL, static_cast<uint>(this->small_font_size));
|
||||
} else if (static_cast<uint>(this->medium_font_size) != _fcsettings.medium.size) {
|
||||
ResizeFont(FS_NORMAL, static_cast<uint>(this->medium_font_size));
|
||||
} else if (static_cast<uint>(this->large_font_size) != _fcsettings.large.size) {
|
||||
ResizeFont(FS_LARGE, static_cast<uint>(this->large_font_size));
|
||||
} else if (static_cast<uint>(this->monospaced_font_size) != _fcsettings.mono.size) {
|
||||
ResizeFont(FS_MONO, static_cast<uint>(this->monospaced_font_size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -970,9 +1106,9 @@ struct GameOptionsWindow : Window {
|
|||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, _gui_scale_cfg == -1);
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_BEVEL_BUTTON, _settings_client.gui.scale_bevels);
|
||||
#ifdef HAS_TRUETYPE_FONT
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_FONT_SPRITE, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_FONT_AA, _fcsettings.global_aa);
|
||||
this->SetWidgetDisabledState(WID_GO_GUI_FONT_AA, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetLoweredState(WID_GO_FONT_SPRITE, _fcsettings.prefer_sprite);
|
||||
this->SetWidgetLoweredState(WID_GO_FONT_AA, _fcsettings.global_aa);
|
||||
this->SetWidgetDisabledState(WID_GO_FONT_AA, _fcsettings.prefer_sprite);
|
||||
#endif /* HAS_TRUETYPE_FONT */
|
||||
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_GRF_DROPDOWN, _game_mode != GM_MENU);
|
||||
|
@ -1000,6 +1136,7 @@ static constexpr NWidgetPart _nested_game_options_widgets[] = {
|
|||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPadding(WidgetDimensions::unscaled.sparse),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_GENERAL), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_GENERAL, STR_GAME_OPTIONS_TAB_GENERAL_TT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_GRAPHICS), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_GRAPHICS, STR_GAME_OPTIONS_TAB_GRAPHICS_TT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_FONTS), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_FONTS, STR_GAME_OPTIONS_TAB_FONTS_TT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_SOUND), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_SOUND, STR_GAME_OPTIONS_TAB_SOUND_TT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_SOCIAL), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_SOCIAL, STR_GAME_OPTIONS_TAB_SOCIAL_TT), SetFill(1, 0),
|
||||
EndContainer(),
|
||||
|
@ -1033,6 +1170,7 @@ static constexpr NWidgetPart _nested_game_options_widgets[] = {
|
|||
EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
/* End general tab */
|
||||
|
||||
/* Graphics tab */
|
||||
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
|
@ -1047,19 +1185,8 @@ static constexpr NWidgetPart _nested_game_options_widgets[] = {
|
|||
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_BEVELS, STR_NULL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_SCALE_BEVEL_BUTTON), SetAspect(WidgetDimensions::ASPECT_SETTINGS_BUTTON), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_BEVELS_TOOLTIP),
|
||||
EndContainer(),
|
||||
#ifdef HAS_TRUETYPE_FONT
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_FONT_SPRITE, STR_NULL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_FONT_SPRITE), SetAspect(WidgetDimensions::ASPECT_SETTINGS_BUTTON), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_FONT_SPRITE_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_FONT_AA, STR_NULL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_FONT_AA), SetAspect(WidgetDimensions::ASPECT_SETTINGS_BUTTON), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_FONT_AA_TOOLTIP),
|
||||
EndContainer(),
|
||||
#endif /* HAS_TRUETYPE_FONT */
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GRAPHICS, STR_NULL),
|
||||
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
|
@ -1108,6 +1235,66 @@ static constexpr NWidgetPart _nested_game_options_widgets[] = {
|
|||
EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
/* End graphics tab */
|
||||
|
||||
/* Fonts tab*/
|
||||
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
/* Global Font Options: */
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_FONT_SPRITE, STR_NULL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FONT_SPRITE), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_FONT_SPRITE_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_FONT_AA, STR_NULL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FONT_AA), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_FONT_AA_TOOLTIP),
|
||||
EndContainer(),
|
||||
|
||||
/* Small font: */
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_SMALL_FONT_FRAME, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_FONT_LOAD_SMALL_FONT), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_LOAD_SMALL_FONT_TOOLTIP), SetFill(1, 0), SetTextStyle(TC_BLACK, FS_SMALL), SetMinimalTextLines(1, 12, FS_SMALL), SetAlignment(SA_CENTER),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_TEXT_FONT_SIZE), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_FONT_SIZE, STR_NULL),
|
||||
NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_FONT_SMALL_FONT_SIZE_SLIDER), SetMinimalSize(67, 0), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_NORMAL), SetFill(1, 0), SetDataTip(0x0, STR_GAME_OPTIONS_SMALL_FONT_SIZE_SLIDER_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
/* Medium font: */
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_MEDIUM_FONT_FRAME, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_FONT_LOAD_MEDIUM_FONT), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_LOAD_MEDIUM_FONT_TOOLTIP), SetFill(1, 0), SetTextStyle(TC_BLACK, FS_NORMAL), SetMinimalTextLines(1, 12, FS_NORMAL), SetAlignment(SA_CENTER),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_TEXT_FONT_SIZE), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_FONT_SIZE, STR_NULL),
|
||||
NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_FONT_MEDIUM_FONT_SIZE_SLIDER), SetMinimalSize(67, 0), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_NORMAL), SetFill(1, 0), SetDataTip(0x0, STR_GAME_OPTIONS_MEDIUM_FONT_SIZE_SLIDER_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
/* Large font: */
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_LARGE_FONT_FRAME, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_FONT_LOAD_LARGE_FONT), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_LOAD_LARGE_FONT_TOOLTIP), SetFill(1, 0), SetTextStyle(TC_BLACK, FS_LARGE), SetMinimalTextLines(1, 12, FS_LARGE), SetAlignment(SA_CENTER),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_TEXT_FONT_SIZE), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_FONT_SIZE, STR_NULL),
|
||||
NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_FONT_LARGE_FONT_SIZE_SLIDER), SetMinimalSize(67, 0), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_NORMAL), SetFill(1, 0), SetDataTip(0x0, STR_GAME_OPTIONS_LARGE_FONT_SIZE_SLIDER_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
/* Monospaced font */
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_MONOSPACED_FONT_FRAME, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_FONT_LOAD_MONOSPACED_FONT), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_LOAD_MONOSPACED_FONT_TOOLTIP), SetFill(1, 0), SetTextStyle(TC_BLACK, FS_MONO), SetMinimalTextLines(1, 12, FS_MONO), SetAlignment(SA_CENTER),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_TEXT_FONT_SIZE), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_FONT_SIZE, STR_NULL),
|
||||
NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_FONT_MONOSPACED_FONT_SIZE_SLIDER), SetMinimalSize(67, 0), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_NORMAL), SetFill(1, 0), SetDataTip(0x0, STR_GAME_OPTIONS_MONOSPACED_FONT_SIZE_SLIDER_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
EndContainer(),
|
||||
/* End font tab */
|
||||
|
||||
/* Sound/Music tab */
|
||||
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
|
@ -1157,11 +1344,13 @@ static constexpr NWidgetPart _nested_game_options_widgets[] = {
|
|||
EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
/* End sound/music tab */
|
||||
|
||||
/* Social tab */
|
||||
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
|
||||
NWidgetFunction(MakeNWidgetSocialPlugins),
|
||||
EndContainer(),
|
||||
/* End social tab */
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
};
|
||||
|
|
|
@ -2157,7 +2157,7 @@ const char *GetCurrentLanguageIsoCode()
|
|||
*/
|
||||
bool MissingGlyphSearcher::FindMissingGlyphs()
|
||||
{
|
||||
InitFontCache(this->Monospace());
|
||||
InitFontCache();
|
||||
const Sprite *question_mark[FS_END];
|
||||
|
||||
for (FontSize size = this->Monospace() ? FS_MONO : FS_BEGIN; size < (this->Monospace() ? FS_END : FS_MONO); size++) {
|
||||
|
@ -2293,7 +2293,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
|
|||
/* Our fallback font does miss characters too, so keep the
|
||||
* user chosen font as that is more likely to be any good than
|
||||
* the wild guess we made */
|
||||
InitFontCache(searcher->Monospace());
|
||||
InitFontCache();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,7 @@ enum SaveLoadWidgets : WidgetID {
|
|||
WID_SL_DRIVES_DIRECTORIES_LIST, ///< Drives list.
|
||||
WID_SL_SCROLLBAR, ///< Scrollbar of the file list.
|
||||
WID_SL_CONTENT_DOWNLOAD, ///< Content download button, only available for play scenario/heightmap.
|
||||
WID_SL_USE_DEFAULT_FONT, ///< Click to use the default TTF OpenTTD provided font for a given font size.
|
||||
WID_SL_SAVE_OSK_TITLE, ///< Title textbox, only available for save operations.
|
||||
WID_SL_DELETE_SELECTION, ///< Delete button, only available for save operations.
|
||||
WID_SL_SAVE_GAME, ///< Save button, only available for save operations.
|
||||
|
|
|
@ -12,52 +12,63 @@
|
|||
|
||||
/** Widgets of the #GameOptionsWindow class. */
|
||||
enum GameOptionsWidgets : WidgetID {
|
||||
WID_GO_TAB_GENERAL, ///< General tab.
|
||||
WID_GO_TAB_GRAPHICS, ///< Graphics tab.
|
||||
WID_GO_TAB_SOUND, ///< Sound tab.
|
||||
WID_GO_TAB_SOCIAL, ///< Social tab.
|
||||
WID_GO_TAB_SELECTION, ///< Background of the tab selection.
|
||||
WID_GO_CURRENCY_DROPDOWN, ///< Currency dropdown.
|
||||
WID_GO_DISTANCE_DROPDOWN, ///< Measuring unit dropdown.
|
||||
WID_GO_AUTOSAVE_DROPDOWN, ///< Dropdown to say how often to autosave.
|
||||
WID_GO_LANG_DROPDOWN, ///< Language dropdown.
|
||||
WID_GO_RESOLUTION_DROPDOWN, ///< Dropdown for the resolution.
|
||||
WID_GO_FULLSCREEN_BUTTON, ///< Toggle fullscreen.
|
||||
WID_GO_GUI_SCALE, ///< GUI Scale slider.
|
||||
WID_GO_GUI_SCALE_AUTO, ///< Autodetect GUI scale button.
|
||||
WID_GO_GUI_SCALE_BEVEL_BUTTON, ///< Toggle for chunky bevels.
|
||||
WID_GO_GUI_FONT_SPRITE, ///< Toggle whether to prefer the sprite font over TTF fonts.
|
||||
WID_GO_GUI_FONT_AA, ///< Toggle whether to anti-alias fonts.
|
||||
WID_GO_BASE_GRF_DROPDOWN, ///< Use to select a base GRF.
|
||||
WID_GO_BASE_GRF_PARAMETERS, ///< Base GRF parameters.
|
||||
WID_GO_BASE_GRF_OPEN_URL, ///< Open base GRF URL.
|
||||
WID_GO_BASE_GRF_TEXTFILE, ///< Open base GRF readme, changelog (+1) or license (+2).
|
||||
WID_GO_TAB_GENERAL, ///< General tab.
|
||||
WID_GO_TAB_GRAPHICS, ///< Graphics tab.
|
||||
WID_GO_TAB_FONTS, ///< Fonts tab.
|
||||
WID_GO_TAB_SOUND, ///< Sound tab.
|
||||
WID_GO_TAB_SOCIAL, ///< Social tab.
|
||||
WID_GO_TAB_SELECTION, ///< Background of the tab selection.
|
||||
WID_GO_CURRENCY_DROPDOWN, ///< Currency dropdown.
|
||||
WID_GO_DISTANCE_DROPDOWN, ///< Measuring unit dropdown.
|
||||
WID_GO_AUTOSAVE_DROPDOWN, ///< Dropdown to say how often to autosave.
|
||||
WID_GO_LANG_DROPDOWN, ///< Language dropdown.
|
||||
WID_GO_RESOLUTION_DROPDOWN, ///< Dropdown for the resolution.
|
||||
WID_GO_FULLSCREEN_BUTTON, ///< Toggle fullscreen.
|
||||
WID_GO_GUI_SCALE, ///< GUI Scale slider.
|
||||
WID_GO_GUI_SCALE_AUTO, ///< Autodetect GUI scale button.
|
||||
WID_GO_GUI_SCALE_BEVEL_BUTTON, ///< Toggle for chunky bevels.
|
||||
WID_GO_FONT_SPRITE, ///< Toggle whether to prefer the sprite font over TTF fonts.
|
||||
WID_GO_FONT_AA, ///< Toggle whether to anti-alias fonts.
|
||||
WID_GO_TEXT_FONT, ///< Font label
|
||||
WID_GO_TEXT_FONT_SIZE, ///< Font size label.
|
||||
WID_GO_FONT_LOAD_MEDIUM_FONT, ///< Load medium font button.
|
||||
WID_GO_FONT_MEDIUM_FONT_SIZE_SLIDER, ///< Medium font size slider.
|
||||
WID_GO_FONT_LOAD_SMALL_FONT, ///< Load small font button.
|
||||
WID_GO_FONT_SMALL_FONT_SIZE_SLIDER, ///< Small font size slider.
|
||||
WID_GO_FONT_LOAD_LARGE_FONT, ///< Load large font button.
|
||||
WID_GO_FONT_LARGE_FONT_SIZE_SLIDER, ///< Large font size slider.
|
||||
WID_GO_FONT_LOAD_MONOSPACED_FONT, ///< Load monospaced font button.
|
||||
WID_GO_FONT_MONOSPACED_FONT_SIZE_SLIDER, ///< Monospaced font size slider.
|
||||
WID_GO_BASE_GRF_DROPDOWN, ///< Use to select a base GRF.
|
||||
WID_GO_BASE_GRF_PARAMETERS, ///< Base GRF parameters.
|
||||
WID_GO_BASE_GRF_OPEN_URL, ///< Open base GRF URL.
|
||||
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.
|
||||
WID_GO_TEXT_SFX_VOLUME, ///< Sound effects volume label.
|
||||
WID_GO_BASE_SFX_VOLUME, ///< Change sound effects volume.
|
||||
WID_GO_BASE_SFX_OPEN_URL, ///< Open base SFX URL.
|
||||
WID_GO_BASE_SFX_TEXTFILE, ///< Open base SFX readme, changelog (+1) or license (+2).
|
||||
WID_GO_BASE_SFX_DROPDOWN, ///< Use to select a base SFX.
|
||||
WID_GO_TEXT_SFX_VOLUME, ///< Sound effects volume label.
|
||||
WID_GO_BASE_SFX_VOLUME, ///< Change sound effects volume.
|
||||
WID_GO_BASE_SFX_OPEN_URL, ///< Open base SFX URL.
|
||||
WID_GO_BASE_SFX_TEXTFILE, ///< Open base SFX readme, changelog (+1) or license (+2).
|
||||
WID_GO_BASE_SFX_DESCRIPTION = WID_GO_BASE_SFX_TEXTFILE + TFT_CONTENT_END, ///< Description of selected base SFX.
|
||||
WID_GO_BASE_MUSIC_DROPDOWN, ///< Use to select a base music set.
|
||||
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_OPEN_URL, ///< Open base music URL.
|
||||
WID_GO_BASE_MUSIC_TEXTFILE, ///< Open base music readme, changelog (+1) or license (+2).
|
||||
WID_GO_BASE_MUSIC_DROPDOWN, ///< Use to select a base music set.
|
||||
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_OPEN_URL, ///< Open base music URL.
|
||||
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.
|
||||
WID_GO_VIDEO_VSYNC_BUTTON, ///< Toggle for video vsync.
|
||||
WID_GO_REFRESH_RATE_DROPDOWN, ///< Dropdown for all available refresh rates.
|
||||
WID_GO_VIDEO_DRIVER_INFO, ///< Label showing details about the current video driver.
|
||||
WID_GO_SURVEY_SEL, ///< Selection to hide survey if no JSON library is compiled in.
|
||||
WID_GO_SURVEY_PARTICIPATE_BUTTON, ///< Toggle for participating in the automated survey.
|
||||
WID_GO_SURVEY_LINK_BUTTON, ///< Button to open browser to go to the survey website.
|
||||
WID_GO_SURVEY_PREVIEW_BUTTON, ///< Button to open a preview window with the survey results
|
||||
WID_GO_SOCIAL_PLUGINS, ///< Main widget handling the social plugins.
|
||||
WID_GO_SOCIAL_PLUGIN_TITLE, ///< Title of the frame of the social plugin.
|
||||
WID_GO_SOCIAL_PLUGIN_PLATFORM, ///< Platform of the social plugin.
|
||||
WID_GO_SOCIAL_PLUGIN_STATE, ///< State of the social plugin.
|
||||
WID_GO_VIDEO_ACCEL_BUTTON, ///< Toggle for video acceleration.
|
||||
WID_GO_VIDEO_VSYNC_BUTTON, ///< Toggle for video vsync.
|
||||
WID_GO_REFRESH_RATE_DROPDOWN, ///< Dropdown for all available refresh rates.
|
||||
WID_GO_VIDEO_DRIVER_INFO, ///< Label showing details about the current video driver.
|
||||
WID_GO_SURVEY_SEL, ///< Selection to hide survey if no JSON library is compiled in.
|
||||
WID_GO_SURVEY_PARTICIPATE_BUTTON, ///< Toggle for participating in the automated survey.
|
||||
WID_GO_SURVEY_LINK_BUTTON, ///< Button to open browser to go to the survey website.
|
||||
WID_GO_SURVEY_PREVIEW_BUTTON, ///< Button to open a preview window with the survey results
|
||||
WID_GO_SOCIAL_PLUGINS, ///< Main widget handling the social plugins.
|
||||
WID_GO_SOCIAL_PLUGIN_TITLE, ///< Title of the frame of the social plugin.
|
||||
WID_GO_SOCIAL_PLUGIN_PLATFORM, ///< Platform of the social plugin.
|
||||
WID_GO_SOCIAL_PLUGIN_STATE, ///< State of the social plugin.
|
||||
};
|
||||
|
||||
/** Widgets of the #GameSettingsWindow class. */
|
||||
|
|
Loading…
Reference in New Issue