mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Removing some unused ImGui font code
This commit is contained in:
parent
810b61f8f9
commit
f4596a7964
4 changed files with 100 additions and 171 deletions
|
|
@ -117,9 +117,6 @@ static void LoadFonts()
|
|||
fonts_.emplace(fontName.first, font);
|
||||
}
|
||||
|
||||
ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas();
|
||||
fontAtlas->AddFontDefault();
|
||||
|
||||
fontManager.InitializeFonts();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ public:
|
|||
fontCategoryModel_ {new QStandardItemModel(self)},
|
||||
settings_ {std::initializer_list<settings::SettingsInterfaceBase*> {
|
||||
&defaultRadarSite_,
|
||||
&fontSizes_,
|
||||
&gridWidth_,
|
||||
&gridHeight_,
|
||||
&mapProvider_,
|
||||
|
|
@ -169,16 +168,15 @@ public:
|
|||
|
||||
types::FontCategory selectedFontCategory_ {types::FontCategory::Unknown};
|
||||
|
||||
settings::SettingsInterface<std::string> defaultRadarSite_ {};
|
||||
settings::SettingsInterface<std::vector<std::int64_t>> fontSizes_ {};
|
||||
settings::SettingsInterface<std::int64_t> gridWidth_ {};
|
||||
settings::SettingsInterface<std::int64_t> gridHeight_ {};
|
||||
settings::SettingsInterface<std::string> mapProvider_ {};
|
||||
settings::SettingsInterface<std::string> mapboxApiKey_ {};
|
||||
settings::SettingsInterface<std::string> mapTilerApiKey_ {};
|
||||
settings::SettingsInterface<std::string> defaultAlertAction_ {};
|
||||
settings::SettingsInterface<bool> updateNotificationsEnabled_ {};
|
||||
settings::SettingsInterface<bool> debugEnabled_ {};
|
||||
settings::SettingsInterface<std::string> defaultRadarSite_ {};
|
||||
settings::SettingsInterface<std::int64_t> gridWidth_ {};
|
||||
settings::SettingsInterface<std::int64_t> gridHeight_ {};
|
||||
settings::SettingsInterface<std::string> mapProvider_ {};
|
||||
settings::SettingsInterface<std::string> mapboxApiKey_ {};
|
||||
settings::SettingsInterface<std::string> mapTilerApiKey_ {};
|
||||
settings::SettingsInterface<std::string> defaultAlertAction_ {};
|
||||
settings::SettingsInterface<bool> updateNotificationsEnabled_ {};
|
||||
settings::SettingsInterface<bool> debugEnabled_ {};
|
||||
|
||||
std::unordered_map<std::string, settings::SettingsInterface<std::string>>
|
||||
colorTables_ {};
|
||||
|
|
@ -424,10 +422,6 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
defaultRadarSite_.SetResetButton(self_->ui->resetRadarSiteButton);
|
||||
UpdateRadarDialogLocation(generalSettings.default_radar_site().GetValue());
|
||||
|
||||
fontSizes_.SetSettingsVariable(generalSettings.font_sizes());
|
||||
fontSizes_.SetEditWidget(self_->ui->fontSizesLineEdit);
|
||||
fontSizes_.SetResetButton(self_->ui->resetFontSizesButton);
|
||||
|
||||
gridWidth_.SetSettingsVariable(generalSettings.grid_width());
|
||||
gridWidth_.SetEditWidget(self_->ui->gridWidthSpinBox);
|
||||
gridWidth_.SetResetButton(self_->ui->resetGridWidthButton);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="general">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
|
|
@ -127,27 +127,7 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="5" column="2">
|
||||
<widget class="QComboBox" name="mapProviderComboBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Font Sizes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="radarSiteComboBox"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default Radar Site</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<item row="4" column="4">
|
||||
<widget class="QToolButton" name="resetMapProviderButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
|
|
@ -158,45 +138,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="fontSizesLineEdit"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Mapbox API Key</string>
|
||||
<string>Grid Width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>MapTiler API Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSpinBox" name="gridWidthSpinBox"/>
|
||||
</item>
|
||||
<item row="7" column="4">
|
||||
<widget class="QToolButton" name="resetMapTilerApiKeyButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="radarSiteSelectButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<item row="2" column="4">
|
||||
<widget class="QToolButton" name="resetGridHeightButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
|
|
@ -207,16 +156,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QLineEdit" name="mapTilerApiKeyLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QSpinBox" name="gridHeightSpinBox"/>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QToolButton" name="resetRadarSiteButton">
|
||||
<property name="text">
|
||||
|
|
@ -228,32 +167,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Grid Height</string>
|
||||
<string>MapTiler API Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QToolButton" name="resetFontSizesButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLineEdit" name="mapboxApiKeyLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="4">
|
||||
<item row="5" column="4">
|
||||
<widget class="QToolButton" name="resetMapboxApiKeyButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
|
|
@ -264,21 +185,97 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSpinBox" name="gridHeightSpinBox"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="gridWidthSpinBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Grid Width</string>
|
||||
<string>Grid Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default Radar Site</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QLineEdit" name="mapTilerApiKeyLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLineEdit" name="mapboxApiKeyLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="defaultAlertActionLabel">
|
||||
<property name="text">
|
||||
<string>Default Alert Action</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Mapbox API Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="4">
|
||||
<widget class="QToolButton" name="resetDefaultAlertActionButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QComboBox" name="mapProviderComboBox"/>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="radarSiteSelectButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Map Provider</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<item row="6" column="4">
|
||||
<widget class="QToolButton" name="resetMapTilerApiKeyButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QComboBox" name="defaultAlertActionComboBox"/>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QToolButton" name="resetGridWidthButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
|
|
@ -289,26 +286,8 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="defaultAlertActionLabel">
|
||||
<property name="text">
|
||||
<string>Default Alert Action</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QComboBox" name="defaultAlertActionComboBox"/>
|
||||
</item>
|
||||
<item row="8" column="4">
|
||||
<widget class="QToolButton" name="resetDefaultAlertActionButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="radarSiteComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
|||
|
|
@ -126,9 +126,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void CreateImGuiFont(QFile& fontFile,
|
||||
QByteArray& fontData,
|
||||
const std::vector<int64_t>& fontSizes);
|
||||
void ParseNames(FT_Face face);
|
||||
|
||||
const std::string resource_;
|
||||
|
|
@ -266,39 +263,6 @@ GLuint Font::GenerateTexture(gl::OpenGLFunctions& gl)
|
|||
return p->atlas_->id;
|
||||
}
|
||||
|
||||
void FontImpl::CreateImGuiFont(QFile& fontFile,
|
||||
QByteArray& fontData,
|
||||
const std::vector<int64_t>& fontSizes)
|
||||
{
|
||||
QFileInfo fileInfo(fontFile);
|
||||
ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas();
|
||||
ImFontConfig fontConfig {};
|
||||
|
||||
// Do not transfer ownership of font data to ImGui, makes const_cast safe
|
||||
fontConfig.FontDataOwnedByAtlas = false;
|
||||
|
||||
for (int64_t fontSize : fontSizes)
|
||||
{
|
||||
const float sizePixels = static_cast<float>(fontSize);
|
||||
|
||||
// Assign name to font
|
||||
strncpy(fontConfig.Name,
|
||||
fmt::format("{}:{}", fileInfo.fileName().toStdString(), fontSize)
|
||||
.c_str(),
|
||||
sizeof(fontConfig.Name) - 1);
|
||||
fontConfig.Name[sizeof(fontConfig.Name) - 1] = 0;
|
||||
|
||||
// Add font to atlas
|
||||
imGuiFonts_.emplace(
|
||||
fontSize,
|
||||
fontAtlas->AddFontFromMemoryTTF(
|
||||
const_cast<void*>(static_cast<const void*>(fontData.constData())),
|
||||
fontData.size(),
|
||||
sizePixels,
|
||||
&fontConfig));
|
||||
}
|
||||
}
|
||||
|
||||
ImFont* Font::ImGuiFont(std::size_t fontPixelSize)
|
||||
{
|
||||
auto it = p->imGuiFonts_.find(fontPixelSize);
|
||||
|
|
@ -334,11 +298,6 @@ std::shared_ptr<Font> Font::Create(const std::string& resource)
|
|||
font = std::make_shared<Font>(resource);
|
||||
QByteArray fontData = fontFile.readAll();
|
||||
|
||||
font->p->CreateImGuiFont(
|
||||
fontFile,
|
||||
fontData,
|
||||
settings::GeneralSettings::Instance().font_sizes().GetValue());
|
||||
|
||||
font->p->atlas_ = ftgl::texture_atlas_new(512, 512, 1);
|
||||
ftgl::texture_font_t* textureFont = ftgl::texture_font_new_from_memory(
|
||||
font->p->atlas_, BASE_POINT_SIZE, fontData.constData(), fontData.size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue