mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13: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); |       fonts_.emplace(fontName.first, font); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas(); |  | ||||||
|    fontAtlas->AddFontDefault(); |  | ||||||
| 
 |  | ||||||
|    fontManager.InitializeFonts(); |    fontManager.InitializeFonts(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -93,7 +93,6 @@ public: | ||||||
|        fontCategoryModel_ {new QStandardItemModel(self)}, |        fontCategoryModel_ {new QStandardItemModel(self)}, | ||||||
|        settings_ {std::initializer_list<settings::SettingsInterfaceBase*> { |        settings_ {std::initializer_list<settings::SettingsInterfaceBase*> { | ||||||
|           &defaultRadarSite_, |           &defaultRadarSite_, | ||||||
|           &fontSizes_, |  | ||||||
|           &gridWidth_, |           &gridWidth_, | ||||||
|           &gridHeight_, |           &gridHeight_, | ||||||
|           &mapProvider_, |           &mapProvider_, | ||||||
|  | @ -170,7 +169,6 @@ public: | ||||||
|    types::FontCategory selectedFontCategory_ {types::FontCategory::Unknown}; |    types::FontCategory selectedFontCategory_ {types::FontCategory::Unknown}; | ||||||
| 
 | 
 | ||||||
|    settings::SettingsInterface<std::string>  defaultRadarSite_ {}; |    settings::SettingsInterface<std::string>  defaultRadarSite_ {}; | ||||||
|    settings::SettingsInterface<std::vector<std::int64_t>> fontSizes_ {}; |  | ||||||
|    settings::SettingsInterface<std::int64_t> gridWidth_ {}; |    settings::SettingsInterface<std::int64_t> gridWidth_ {}; | ||||||
|    settings::SettingsInterface<std::int64_t> gridHeight_ {}; |    settings::SettingsInterface<std::int64_t> gridHeight_ {}; | ||||||
|    settings::SettingsInterface<std::string>  mapProvider_ {}; |    settings::SettingsInterface<std::string>  mapProvider_ {}; | ||||||
|  | @ -424,10 +422,6 @@ void SettingsDialogImpl::SetupGeneralTab() | ||||||
|    defaultRadarSite_.SetResetButton(self_->ui->resetRadarSiteButton); |    defaultRadarSite_.SetResetButton(self_->ui->resetRadarSiteButton); | ||||||
|    UpdateRadarDialogLocation(generalSettings.default_radar_site().GetValue()); |    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_.SetSettingsVariable(generalSettings.grid_width()); | ||||||
|    gridWidth_.SetEditWidget(self_->ui->gridWidthSpinBox); |    gridWidth_.SetEditWidget(self_->ui->gridWidthSpinBox); | ||||||
|    gridWidth_.SetResetButton(self_->ui->resetGridWidthButton); |    gridWidth_.SetResetButton(self_->ui->resetGridWidthButton); | ||||||
|  |  | ||||||
|  | @ -102,7 +102,7 @@ | ||||||
|          </sizepolicy> |          </sizepolicy> | ||||||
|         </property> |         </property> | ||||||
|         <property name="currentIndex"> |         <property name="currentIndex"> | ||||||
|          <number>2</number> |          <number>0</number> | ||||||
|         </property> |         </property> | ||||||
|         <widget class="QWidget" name="general"> |         <widget class="QWidget" name="general"> | ||||||
|          <layout class="QVBoxLayout" name="verticalLayout_2"> |          <layout class="QVBoxLayout" name="verticalLayout_2"> | ||||||
|  | @ -127,27 +127,7 @@ | ||||||
|              <property name="bottomMargin"> |              <property name="bottomMargin"> | ||||||
|               <number>0</number> |               <number>0</number> | ||||||
|              </property> |              </property> | ||||||
|              <item row="5" column="2"> |              <item row="4" column="4"> | ||||||
|               <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"> |  | ||||||
|               <widget class="QToolButton" name="resetMapProviderButton"> |               <widget class="QToolButton" name="resetMapProviderButton"> | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|                 <string>...</string> |                 <string>...</string> | ||||||
|  | @ -158,45 +138,14 @@ | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </item> | ||||||
|              <item row="1" column="2"> |              <item row="1" column="0"> | ||||||
|               <widget class="QLineEdit" name="fontSizesLineEdit"/> |               <widget class="QLabel" name="label_2"> | ||||||
|              </item> |  | ||||||
|              <item row="6" column="0"> |  | ||||||
|               <widget class="QLabel" name="label_4"> |  | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|                 <string>Mapbox API Key</string> |                 <string>Grid Width</string> | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </item> | ||||||
|              <item row="7" column="0"> |              <item row="2" column="4"> | ||||||
|               <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"> |  | ||||||
|               <widget class="QToolButton" name="resetGridHeightButton"> |               <widget class="QToolButton" name="resetGridHeightButton"> | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|                 <string>...</string> |                 <string>...</string> | ||||||
|  | @ -207,16 +156,6 @@ | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </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"> |              <item row="0" column="4"> | ||||||
|               <widget class="QToolButton" name="resetRadarSiteButton"> |               <widget class="QToolButton" name="resetRadarSiteButton"> | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|  | @ -228,32 +167,14 @@ | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </item> | ||||||
|              <item row="3" column="0"> |              <item row="6" column="0"> | ||||||
|               <widget class="QLabel" name="label_3"> |               <widget class="QLabel" name="label_6"> | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|                 <string>Grid Height</string> |                 <string>MapTiler API Key</string> | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </item> | ||||||
|              <item row="1" column="4"> |              <item row="5" 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"> |  | ||||||
|               <widget class="QToolButton" name="resetMapboxApiKeyButton"> |               <widget class="QToolButton" name="resetMapboxApiKeyButton"> | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|                 <string>...</string> |                 <string>...</string> | ||||||
|  | @ -264,21 +185,97 @@ | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </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"> |              <item row="2" column="0"> | ||||||
|               <widget class="QLabel" name="label_2"> |               <widget class="QLabel" name="label_3"> | ||||||
|                <property name="text"> |                <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> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </item> | ||||||
|              <item row="5" column="0"> |              <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"> |               <widget class="QLabel" name="label_7"> | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|                 <string>Map Provider</string> |                 <string>Map Provider</string> | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </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"> |               <widget class="QToolButton" name="resetGridWidthButton"> | ||||||
|                <property name="text"> |                <property name="text"> | ||||||
|                 <string>...</string> |                 <string>...</string> | ||||||
|  | @ -289,26 +286,8 @@ | ||||||
|                </property> |                </property> | ||||||
|               </widget> |               </widget> | ||||||
|              </item> |              </item> | ||||||
|              <item row="8" column="0"> |              <item row="0" column="2"> | ||||||
|               <widget class="QLabel" name="defaultAlertActionLabel"> |               <widget class="QComboBox" name="radarSiteComboBox"/> | ||||||
|                <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> |              </item> | ||||||
|             </layout> |             </layout> | ||||||
|            </widget> |            </widget> | ||||||
|  |  | ||||||
|  | @ -126,9 +126,6 @@ public: | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    void CreateImGuiFont(QFile&                      fontFile, |  | ||||||
|                         QByteArray&                 fontData, |  | ||||||
|                         const std::vector<int64_t>& fontSizes); |  | ||||||
|    void ParseNames(FT_Face face); |    void ParseNames(FT_Face face); | ||||||
| 
 | 
 | ||||||
|    const std::string resource_; |    const std::string resource_; | ||||||
|  | @ -266,39 +263,6 @@ GLuint Font::GenerateTexture(gl::OpenGLFunctions& gl) | ||||||
|    return p->atlas_->id; |    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) | ImFont* Font::ImGuiFont(std::size_t fontPixelSize) | ||||||
| { | { | ||||||
|    auto it = p->imGuiFonts_.find(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); |    font                = std::make_shared<Font>(resource); | ||||||
|    QByteArray fontData = fontFile.readAll(); |    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); |    font->p->atlas_                   = ftgl::texture_atlas_new(512, 512, 1); | ||||||
|    ftgl::texture_font_t* textureFont = ftgl::texture_font_new_from_memory( |    ftgl::texture_font_t* textureFont = ftgl::texture_font_new_from_memory( | ||||||
|       font->p->atlas_, BASE_POINT_SIZE, fontData.constData(), fontData.size()); |       font->p->atlas_, BASE_POINT_SIZE, fontData.constData(), fontData.size()); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat