mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 02:19:41 +00:00
Feature: Add option to adjust font size separately from GUI size. (#7003)
Adds an option in the "Game Options" next to "Interface Size" called "Font Size". Available options are normal, double, and quad.
This commit is contained in:
parent
56a6d7aec8
commit
00d28a500d
@ -189,7 +189,7 @@ uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
|||||||
|
|
||||||
int SpriteFontCache::GetHeight() const
|
int SpriteFontCache::GetHeight() const
|
||||||
{
|
{
|
||||||
return ScaleGUITrad(this->height);
|
return this->height * (1 << (ZOOM_LVL_OUT_4X - _font_zoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpriteFontCache::GetDrawGlyphShadow()
|
bool SpriteFontCache::GetDrawGlyphShadow()
|
||||||
@ -293,6 +293,10 @@ void FreeTypeFontCache::SetFontSize(FontSize fs, FT_Face face, int pixels)
|
|||||||
pixels = Clamp(min(head->Lowest_Rec_PPEM, 20) + diff, scaled_height, MAX_FONT_SIZE);
|
pixels = Clamp(min(head->Lowest_Rec_PPEM, 20) + diff, scaled_height, MAX_FONT_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Apply user-specified font zoom. */
|
||||||
|
pixels *= (1 << (ZOOM_LVL_OUT_4X - _font_zoom));
|
||||||
|
|
||||||
this->used_size = pixels;
|
this->used_size = pixels;
|
||||||
|
|
||||||
FT_Error err = FT_Set_Pixel_Sizes(this->face, 0, pixels);
|
FT_Error err = FT_Set_Pixel_Sizes(this->face, 0, pixels);
|
||||||
@ -438,7 +442,7 @@ void FreeTypeFontCache::ClearFontCache()
|
|||||||
Layouter::ResetFontCache(this->fs);
|
Layouter::ResetFontCache(this->fs);
|
||||||
|
|
||||||
/* GUI scaling might have changed, determine font size anew if it was automatically selected. */
|
/* GUI scaling might have changed, determine font size anew if it was automatically selected. */
|
||||||
if (this->face != NULL && this->req_size == 0) this->SetFontSize(this->fs, this->face, this->req_size);
|
if (this->face != NULL) this->SetFontSize(this->fs, this->face, this->req_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key)
|
FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key)
|
||||||
|
@ -58,6 +58,7 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode,
|
|||||||
static ReusableBuffer<uint8> _cursor_backup;
|
static ReusableBuffer<uint8> _cursor_backup;
|
||||||
|
|
||||||
ZoomLevelByte _gui_zoom; ///< GUI Zoom level
|
ZoomLevelByte _gui_zoom; ///< GUI Zoom level
|
||||||
|
ZoomLevelByte _font_zoom; ///< Font Zoom level
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rect for repaint.
|
* The rect for repaint.
|
||||||
|
@ -995,6 +995,13 @@ STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL :Normal
|
|||||||
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM :Double size
|
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM :Double size
|
||||||
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM :Quad size
|
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM :Quad size
|
||||||
|
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM :{BLACK}Font size
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_TOOLTIP :{BLACK}Select the interface font size to use
|
||||||
|
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL :Normal
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM :Double size
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM :Quad size
|
||||||
|
|
||||||
STR_GAME_OPTIONS_BASE_GRF :{BLACK}Base graphics set
|
STR_GAME_OPTIONS_BASE_GRF :{BLACK}Base graphics set
|
||||||
STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Select the base graphics set to use
|
STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Select the base graphics set to use
|
||||||
STR_GAME_OPTIONS_BASE_GRF_STATUS :{RED}{NUM} missing/corrupted file{P "" s}
|
STR_GAME_OPTIONS_BASE_GRF_STATUS :{RED}{NUM} missing/corrupted file{P "" s}
|
||||||
|
@ -1029,6 +1029,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
|||||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_RESOLUTION_DROPDOWN, "WID_GO_RESOLUTION_DROPDOWN");
|
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_RESOLUTION_DROPDOWN, "WID_GO_RESOLUTION_DROPDOWN");
|
||||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_FULLSCREEN_BUTTON, "WID_GO_FULLSCREEN_BUTTON");
|
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_FULLSCREEN_BUTTON, "WID_GO_FULLSCREEN_BUTTON");
|
||||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_GUI_ZOOM_DROPDOWN, "WID_GO_GUI_ZOOM_DROPDOWN");
|
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_GUI_ZOOM_DROPDOWN, "WID_GO_GUI_ZOOM_DROPDOWN");
|
||||||
|
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_FONT_ZOOM_DROPDOWN, "WID_GO_FONT_ZOOM_DROPDOWN");
|
||||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_BASE_GRF_DROPDOWN, "WID_GO_BASE_GRF_DROPDOWN");
|
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_BASE_GRF_DROPDOWN, "WID_GO_BASE_GRF_DROPDOWN");
|
||||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_BASE_GRF_STATUS, "WID_GO_BASE_GRF_STATUS");
|
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_BASE_GRF_STATUS, "WID_GO_BASE_GRF_STATUS");
|
||||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_BASE_GRF_TEXTFILE, "WID_GO_BASE_GRF_TEXTFILE");
|
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GO_BASE_GRF_TEXTFILE, "WID_GO_BASE_GRF_TEXTFILE");
|
||||||
|
@ -2184,6 +2184,7 @@ public:
|
|||||||
WID_GO_BASE_MUSIC_STATUS = ::WID_GO_BASE_MUSIC_STATUS, ///< Info about corrupted files etc.
|
WID_GO_BASE_MUSIC_STATUS = ::WID_GO_BASE_MUSIC_STATUS, ///< Info about corrupted files etc.
|
||||||
WID_GO_BASE_MUSIC_TEXTFILE = ::WID_GO_BASE_MUSIC_TEXTFILE, ///< Open base music readme, changelog (+1) or license (+2).
|
WID_GO_BASE_MUSIC_TEXTFILE = ::WID_GO_BASE_MUSIC_TEXTFILE, ///< Open base music readme, changelog (+1) or license (+2).
|
||||||
WID_GO_BASE_MUSIC_DESCRIPTION = ::WID_GO_BASE_MUSIC_DESCRIPTION, ///< Description of selected base music set.
|
WID_GO_BASE_MUSIC_DESCRIPTION = ::WID_GO_BASE_MUSIC_DESCRIPTION, ///< Description of selected base music set.
|
||||||
|
WID_GO_FONT_ZOOM_DROPDOWN = ::WID_GO_FONT_ZOOM_DROPDOWN, ///< Dropdown for the font zoom level.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widgets of the #GameSettingsWindow class. */
|
/** Widgets of the #GameSettingsWindow class. */
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "textfile_gui.h"
|
#include "textfile_gui.h"
|
||||||
#include "stringfilter_type.h"
|
#include "stringfilter_type.h"
|
||||||
#include "querystring_gui.h"
|
#include "querystring_gui.h"
|
||||||
|
#include "fontcache.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -64,6 +65,13 @@ static const StringID _gui_zoom_dropdown[] = {
|
|||||||
INVALID_STRING_ID,
|
INVALID_STRING_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const StringID _font_zoom_dropdown[] = {
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL,
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM,
|
||||||
|
STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM,
|
||||||
|
INVALID_STRING_ID,
|
||||||
|
};
|
||||||
|
|
||||||
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; ///< Number of original town names.
|
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; ///< Number of original town names.
|
||||||
static StringID *_grf_names = NULL; ///< Pointer to town names defined by NewGRFs.
|
static StringID *_grf_names = NULL; ///< Pointer to town names defined by NewGRFs.
|
||||||
static int _nb_grf_names = 0; ///< Number of town names defined by NewGRFs.
|
static int _nb_grf_names = 0; ///< Number of town names defined by NewGRFs.
|
||||||
@ -302,6 +310,16 @@ struct GameOptionsWindow : Window {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WID_GO_FONT_ZOOM_DROPDOWN: {
|
||||||
|
list = new DropDownList();
|
||||||
|
*selected_index = ZOOM_LVL_OUT_4X - _font_zoom;
|
||||||
|
const StringID *items = _font_zoom_dropdown;
|
||||||
|
for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
|
||||||
|
*list->Append() = new DropDownListStringItem(*items, i, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WID_GO_BASE_GRF_DROPDOWN:
|
case WID_GO_BASE_GRF_DROPDOWN:
|
||||||
list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
|
list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
|
||||||
break;
|
break;
|
||||||
@ -331,6 +349,7 @@ struct GameOptionsWindow : Window {
|
|||||||
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
|
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
|
||||||
case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
|
case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
|
||||||
case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[ZOOM_LVL_OUT_4X - _gui_zoom]); break;
|
case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[ZOOM_LVL_OUT_4X - _gui_zoom]); break;
|
||||||
|
case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[ZOOM_LVL_OUT_4X - _font_zoom]); break;
|
||||||
case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->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_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
|
||||||
case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name); break;
|
case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name); break;
|
||||||
@ -541,6 +560,14 @@ struct GameOptionsWindow : Window {
|
|||||||
UpdateAllVirtCoords();
|
UpdateAllVirtCoords();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WID_GO_FONT_ZOOM_DROPDOWN:
|
||||||
|
GfxClearSpriteCache();
|
||||||
|
_font_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
|
||||||
|
ClearFontCache();
|
||||||
|
UpdateAllVirtCoords();
|
||||||
|
ReInitAllWindows();
|
||||||
|
break;
|
||||||
|
|
||||||
case WID_GO_BASE_GRF_DROPDOWN:
|
case WID_GO_BASE_GRF_DROPDOWN:
|
||||||
this->SetMediaSet<BaseGraphics>(index);
|
this->SetMediaSet<BaseGraphics>(index);
|
||||||
break;
|
break;
|
||||||
@ -616,6 +643,9 @@ static const NWidgetPart _nested_game_options_widgets[] = {
|
|||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_CURRENCY_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_CURRENCY_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
|
NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
|
||||||
|
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_FONT_ZOOM, STR_NULL),
|
||||||
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_FONT_ZOOM_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_TOOLTIP), SetFill(1, 0),
|
||||||
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
|
||||||
|
@ -462,13 +462,13 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||||||
return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator);
|
return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprite->type == ST_FONT && ZOOM_LVL_GUI != ZOOM_LVL_NORMAL) {
|
if (sprite->type == ST_FONT && ZOOM_LVL_FONT != ZOOM_LVL_NORMAL) {
|
||||||
/* Make ZOOM_LVL_GUI be ZOOM_LVL_NORMAL */
|
/* Make ZOOM_LVL_NORMAL be ZOOM_LVL_FONT */
|
||||||
sprite[ZOOM_LVL_NORMAL].width = sprite[ZOOM_LVL_GUI].width;
|
sprite[ZOOM_LVL_NORMAL].width = sprite[ZOOM_LVL_FONT].width;
|
||||||
sprite[ZOOM_LVL_NORMAL].height = sprite[ZOOM_LVL_GUI].height;
|
sprite[ZOOM_LVL_NORMAL].height = sprite[ZOOM_LVL_FONT].height;
|
||||||
sprite[ZOOM_LVL_NORMAL].x_offs = sprite[ZOOM_LVL_GUI].x_offs;
|
sprite[ZOOM_LVL_NORMAL].x_offs = sprite[ZOOM_LVL_FONT].x_offs;
|
||||||
sprite[ZOOM_LVL_NORMAL].y_offs = sprite[ZOOM_LVL_GUI].y_offs;
|
sprite[ZOOM_LVL_NORMAL].y_offs = sprite[ZOOM_LVL_FONT].y_offs;
|
||||||
sprite[ZOOM_LVL_NORMAL].data = sprite[ZOOM_LVL_GUI].data;
|
sprite[ZOOM_LVL_NORMAL].data = sprite[ZOOM_LVL_FONT].data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return BlitterFactory::GetCurrentBlitter()->Encode(sprite, allocator);
|
return BlitterFactory::GetCurrentBlitter()->Encode(sprite, allocator);
|
||||||
|
@ -308,5 +308,14 @@ min = ZOOM_LVL_MIN
|
|||||||
max = ZOOM_LVL_OUT_4X
|
max = ZOOM_LVL_OUT_4X
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
|
|
||||||
|
[SDTG_VAR]
|
||||||
|
name = ""font_zoom""
|
||||||
|
type = SLE_UINT8
|
||||||
|
var = _font_zoom
|
||||||
|
def = ZOOM_LVL_OUT_4X
|
||||||
|
min = ZOOM_LVL_MIN
|
||||||
|
max = ZOOM_LVL_OUT_4X
|
||||||
|
cat = SC_BASIC
|
||||||
|
|
||||||
[SDTG_END]
|
[SDTG_END]
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ enum GameOptionsWidgets {
|
|||||||
WID_GO_BASE_MUSIC_STATUS, ///< Info about corrupted files etc.
|
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_TEXTFILE, ///< Open base music readme, changelog (+1) or license (+2).
|
||||||
WID_GO_BASE_MUSIC_DESCRIPTION = WID_GO_BASE_MUSIC_TEXTFILE + TFT_END, ///< Description of selected base music set.
|
WID_GO_BASE_MUSIC_DESCRIPTION = WID_GO_BASE_MUSIC_TEXTFILE + TFT_END, ///< Description of selected base music set.
|
||||||
|
WID_GO_FONT_ZOOM_DROPDOWN, ///< Dropdown for the font zoom level.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widgets of the #GameSettingsWindow class. */
|
/** Widgets of the #GameSettingsWindow class. */
|
||||||
|
@ -53,6 +53,8 @@ DECLARE_POSTFIX_INCREMENT(ZoomLevel)
|
|||||||
typedef SimpleTinyEnumT<ZoomLevel, byte> ZoomLevelByte;
|
typedef SimpleTinyEnumT<ZoomLevel, byte> ZoomLevelByte;
|
||||||
|
|
||||||
extern ZoomLevelByte _gui_zoom;
|
extern ZoomLevelByte _gui_zoom;
|
||||||
|
extern ZoomLevelByte _font_zoom;
|
||||||
#define ZOOM_LVL_GUI (_gui_zoom)
|
#define ZOOM_LVL_GUI (_gui_zoom)
|
||||||
|
#define ZOOM_LVL_FONT (_font_zoom)
|
||||||
|
|
||||||
#endif /* ZOOM_TYPE_H */
|
#endif /* ZOOM_TYPE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user