From a237642cfd2ac5b1becbc225c162606f9e888b46 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Fri, 30 Jun 2023 03:30:05 -0700 Subject: [PATCH] Add tab icons #109 --- include/imgui/toggle/imgui_toggle_presets.cpp | 14 ++-- resource/common/locale/English.toml | 2 + src/cheatmenu.cpp | 3 + src/custom/customskins_sa.cpp | 2 +- src/pages/game.cpp | 12 +-- src/pages/menu.cpp | 22 ++--- src/pages/ped.cpp | 14 ++-- src/pages/player.cpp | 82 +++++++++---------- src/pages/scene.cpp | 10 +-- src/pages/teleport.cpp | 4 +- src/pages/vehicle.cpp | 6 +- src/pages/visual.cpp | 13 +-- src/pages/weapon.cpp | 6 +- src/pch.h | 1 + src/utils/d3dhook.cpp | 3 +- src/utils/fontmgr.cpp | 7 +- src/utils/widget.cpp | 58 +++++++------ 17 files changed, 135 insertions(+), 124 deletions(-) diff --git a/include/imgui/toggle/imgui_toggle_presets.cpp b/include/imgui/toggle/imgui_toggle_presets.cpp index 396b7ed..1d7055c 100644 --- a/include/imgui/toggle/imgui_toggle_presets.cpp +++ b/include/imgui/toggle/imgui_toggle_presets.cpp @@ -118,11 +118,14 @@ ImGuiToggleConfig ImGuiTogglePresets::MaterialStyle(float size_scale /*= 1.0f*/) const ImVec2 material_size(37 * size_scale, 16 * size_scale); const float material_inset = -2.5f * size_scale; - static ImGuiTogglePalette material_palette_on; - material_palette_on.Frame = {0.9411f, 0.1961f, 0.2588f, 1.00f}; - material_palette_on.FrameHover = {0.8411f, 0.1961f, 0.2588f, 1.00f}; - material_palette_on.Knob = White; - material_palette_on.KnobHover = White; + static ImGuiTogglePalette material_palette_on, material_palette_off; + material_palette_on.Frame = {0.9411f, 0.1961f, 0.2588f, 1.00f}; // red + material_palette_on.FrameHover = {0.8411f, 0.1961f, 0.2588f, 1.00f}; // red + material_palette_on.Knob = {1.0f, 1.0f, 1.0f, 1.0f}; + material_palette_on.KnobHover = {1.0f, 1.0f, 1.0f, 1.0f}; + + material_palette_off.Frame = {0.1294f, 0.1333f, 0.1764f, 1.0f}; + material_palette_off.FrameHover = {0.1176f, 0.1176f, 0.1569f, 1.0f}; // setup config ImGuiToggleConfig config; @@ -131,6 +134,7 @@ ImGuiToggleConfig ImGuiTogglePresets::MaterialStyle(float size_scale /*= 1.0f*/) config.On.KnobInset = config.Off.KnobInset = material_inset; config.On.KnobOffset = config.Off.KnobOffset = ImVec2(-material_inset, 0); config.On.Palette = &material_palette_on; + config.Off.Palette = &material_palette_off; return config; } diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index 11337cb..07be4c7 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -714,6 +714,7 @@ LightIntensity = "High light min intensity" LightShadowStrength = "Light shadow strength" LockWeather = "Lock weather" Minute = "Minute" +Miscellaneous = "Miscellaneous" MoneyColor = "Money color" MoneyFontOutline = "Money font outline" MoneyFontStyle = "Money font style" @@ -845,6 +846,7 @@ ScenePage = "Scene" SetValue = "Set value" SpawnTab = "Spawn" TeleportPage = "Teleport" +ToggleTab = "Toggle" VehiclePage = "Vehicle" VisualPage = "Visual" WeaponPage = "Weapon" diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index 6a6050e..2ab0d77 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -265,6 +265,9 @@ void CheatMenuMgr::ApplyStyle() style->Colors[ImGuiCol_Button] = ImColor(33, 34, 45, 255); style->Colors[ImGuiCol_ButtonActive] = ImColor(240, 50, 66, 255); style->Colors[ImGuiCol_ButtonHovered] = ImColor(30, 30, 40, 255); + style->Colors[ImGuiCol_ScrollbarGrab] = ImColor(33, 34, 45, 255); + style->Colors[ImGuiCol_ScrollbarGrabActive] = ImColor(240, 50, 66, 255); + style->Colors[ImGuiCol_ScrollbarGrabHovered] = ImColor(30, 30, 40, 255); style->Colors[ImGuiCol_FrameBg] = ImColor(33, 34, 45, 255); style->Colors[ImGuiCol_FrameBgActive] = ImColor(240, 50, 66, 255); style->Colors[ImGuiCol_FrameBgHovered] = ImColor(30, 30, 40, 255); diff --git a/src/custom/customskins_sa.cpp b/src/custom/customskins_sa.cpp index f2baa08..5fe0962 100644 --- a/src/custom/customskins_sa.cpp +++ b/src/custom/customskins_sa.cpp @@ -51,7 +51,7 @@ void CustomSkinsMgr::Draw() { if (m_bInit) { - Widget::Filter(TEXT("Window.Search"), m_Filter, std::format("{}{}", TEXT("Player.TotalSkins"), m_List.size()).c_str()); + Widget::Filter(TEXT_ICON(ICON_FA_MAGNIFYING_GLASS, "Window.Search"), m_Filter, std::format("{}{}", TEXT("Player.TotalSkins"), m_List.size()).c_str()); Widget::Tooltip(TEXT("Player.CustomSkinsDirTip")); ImGui::Spacing(); ImGui::TextWrapped(TEXT("Player.CustomSkinsTip")); diff --git a/src/pages/game.cpp b/src/pages/game.cpp index 32162f3..27a6651 100644 --- a/src/pages/game.cpp +++ b/src/pages/game.cpp @@ -190,7 +190,7 @@ void GamePage::Draw() if (ImGui::BeginTabBar("Game", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { - if (ImGui::BeginTabItem(TEXT("Window.CheckboxTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TOGGLE_ON, "Window.ToggleTab"))) { ImGui::BeginChild("##Checkbox"); ImGui::Spacing(); @@ -372,7 +372,7 @@ void GamePage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.MenusTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_BARS, "Window.MenusTab"))) { ImGui::Spacing(); ImGui::BeginChild("##Menus"); @@ -605,7 +605,7 @@ void GamePage::Draw() ImGui::EndTabItem(); } #ifdef GTASA - if (ImGui::BeginTabItem(TEXT("Game.Freecam"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_CAMERA, "Game.Freecam"))) { ImGui::Spacing(); bool state = Freecam.GetState(); @@ -736,7 +736,7 @@ void GamePage::Draw() ImGui::EndTabItem(); } #endif - if (ImGui::BeginTabItem(TEXT("Game.Missions"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_LIST_OL, "Game.Missions"))) { ImGui::Spacing(); @@ -767,7 +767,7 @@ void GamePage::Draw() ImGui::EndTabItem(); } #ifdef GTASA - if (ImGui::BeginTabItem(TEXT("Game.Stats"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_BARS_STAGGERED, "Game.Stats"))) { ImGui::Spacing(); @@ -800,7 +800,7 @@ void GamePage::Draw() Widget::DataList(m_StatData, nullptr, nullptr, true); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Game.RandomCheats"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_MASKS_THEATER, "Game.RandomCheats"))) { ImGui::Spacing(); ImGui::Columns(2, NULL, false); diff --git a/src/pages/menu.cpp b/src/pages/menu.cpp index 1dbabb5..d99b4df 100644 --- a/src/pages/menu.cpp +++ b/src/pages/menu.cpp @@ -30,7 +30,7 @@ void MenuPage::Draw() { if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { - if (ImGui::BeginTabItem(TEXT("Menu.Config"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_GEAR, "Menu.Config"))) { static int selected = Locale::GetCurrentLocaleIndex(); static std::vector& vec = Locale::GetLocaleList(); @@ -61,15 +61,15 @@ void MenuPage::Draw() } ImGui::Spacing(); - if (ImGui::Button(TEXT("Menu.ResetSize"), ImVec2(Widget::CalcSize(2)))) + if (ImGui::Button(TEXT("Menu.ResetSize"), ImVec2(Widget::CalcSize(1)))) { CheatMenu.ResetParams(); } - ImGui::SameLine(); - if (ImGui::Button(TEXT("Menu.ReloadFonts"), ImVec2(Widget::CalcSize(2)))) - { - FontMgr::SetFontReloadRequired(true); - } + // ImGui::SameLine(); + // if (ImGui::Button(TEXT("Menu.ReloadFonts"), ImVec2(Widget::CalcSize(2)))) + // { + // FontMgr::SetFontReloadRequired(true); + // } ImGui::Spacing(); @@ -120,7 +120,7 @@ void MenuPage::Draw() ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Menu.Overlay"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_WINDOW_RESTORE, "Menu.Overlay"))) { ImGui::Spacing(); ImGui::Spacing(); @@ -207,7 +207,7 @@ void MenuPage::Draw() ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Menu.Hotkeys"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_KEYBOARD, "Menu.Hotkeys"))) { ImGui::Spacing(); ImGui::Text(TEXT("Menu.Usage")); @@ -243,7 +243,7 @@ void MenuPage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Menu.Commands"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TERMINAL, "Menu.Commands"))) { if (ImGui::BeginChild("CommandsChild")) { @@ -297,7 +297,7 @@ void MenuPage::Draw() } ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Menu.About"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_INFO, "Menu.About"))) { ImGui::Spacing(); diff --git a/src/pages/ped.cpp b/src/pages/ped.cpp index 086c5f1..8dfaedd 100644 --- a/src/pages/ped.cpp +++ b/src/pages/ped.cpp @@ -26,7 +26,7 @@ static const char* pedTypeList = "Civ Male\0Civ Female\0Cop\0Leones\0Triads\0Dia PedPage &pedPage = PedPage::Get(); PedPage::PedPage() - : IPage(ePageID::Ped, ICON_FA_PEOPLE_ROBBERY, true) + : IPage(ePageID::Ped, ICON_FA_PEOPLE_GROUP, true) { /* Taken from gta chaos mod by Lordmau5 & _AG @@ -254,7 +254,7 @@ void PedPage::Draw() { if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { - if (ImGui::BeginTabItem(TEXT("Window.CheckboxTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TOGGLE_ON, "Window.ToggleTab"))) { ImGui::BeginChild("CheckboxesChild"); ImGui::Spacing(); @@ -302,7 +302,7 @@ void PedPage::Draw() ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.MenusTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_BARS, "Window.MenusTab"))) { ImGui::Spacing(); ImGui::BeginChild("MenusChild"); @@ -343,13 +343,13 @@ void PedPage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.SpawnTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PEOPLE_GROUP, "Window.SpawnTab"))) { if (ImGui::BeginTabBar("SpawnPedBar")) { ImGui::Spacing(); - if (ImGui::BeginTabItem(TEXT("Window.Search"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_MAGNIFYING_GLASS, "Window.Search"))) { ImGui::Spacing(); #ifdef GTASA @@ -439,7 +439,7 @@ void PedPage::Draw() ImGui::EndTabItem(); } #ifdef GTASA - if (ImGui::BeginTabItem(TEXT("Ped.GangWars"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PERSON_RIFLE, "Ped.GangWars"))) { ImGui::Spacing(); if (ImGui::Button(TEXT("Ped.StartWar"), ImVec2(Widget::CalcSize(2)))) @@ -496,7 +496,7 @@ void PedPage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Ped.GangModelEditor"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PEOPLE_ARROWS, "Ped.GangModelEditor"))) { ImGui::Spacing(); if (ImGui::Button(TEXT("Ped.ResetModels"), Widget::CalcSize(1))) diff --git a/src/pages/player.cpp b/src/pages/player.cpp index d7bb929..c8cd983 100644 --- a/src/pages/player.cpp +++ b/src/pages/player.cpp @@ -231,7 +231,7 @@ void PlayerPage::SetCloth(std::string& name) void PlayerPage::RemoveClothesTab() { - if (ImGui::BeginTabItem(TEXT("Player.RemoveClothesTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TRASH_CAN, "Player.RemoveClothesTab"))) { ImGui::TextWrapped(TEXT("Player.ClothesTip")); ImGui::Spacing(); @@ -360,7 +360,7 @@ void PlayerPage::Draw() if (ImGui::BeginTabBar("Player", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { - if (ImGui::BeginTabItem(TEXT("Window.CheckboxTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TOGGLE_ON, "Window.ToggleTab"))) { ImGui::BeginChild("CheckboxesChild"); ImGui::Spacing(); @@ -650,7 +650,7 @@ void PlayerPage::Draw() ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.MenusTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_BARS, "Window.MenusTab"))) { ImGui::BeginChild("PlayerMenus"); @@ -799,58 +799,52 @@ void PlayerPage::Draw() } #ifdef GTASA - if (ImGui::BeginTabItem(TEXT("Player.AppearanceTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_SHIRT, "Player.ClothesTab"))) { - if (ImGui::BeginTabBar("AppearanceTabBar")) + if (pPlayer->m_nModelIndex == 0) { - if (ImGui::BeginTabItem(TEXT("Player.ClothesTab"))) + Widget::ImageList(m_ClothData, fArgWrapper(playerPage.SetCloth), + [](std::string& str) { - if (pPlayer->m_nModelIndex == 0) - { - Widget::ImageList(m_ClothData, fArgWrapper(playerPage.SetCloth), - [](std::string& str) - { - std::stringstream ss(str); - std::string temp; + std::stringstream ss(str); + std::string temp; - getline(ss, temp, '$'); - getline(ss, temp, '$'); + getline(ss, temp, '$'); + getline(ss, temp, '$'); - return temp; - }, nullptr, nullptr, nullptr, fArgNoneWrapper(playerPage.RemoveClothesTab)); - } - else - { - ImGui::TextWrapped(TEXT("Player.NeedCJSkin")); - ImGui::Spacing(); + return temp; + }, nullptr, nullptr, nullptr, fArgNoneWrapper(playerPage.RemoveClothesTab)); + } + else + { + ImGui::TextWrapped(TEXT("Player.NeedCJSkin")); + ImGui::Spacing(); - if (ImGui::Button(TEXT("Player.ChangeToCJ"), ImVec2(Widget::CalcSize(1)))) - { - pPlayer->SetModelIndex(0); - Util::ClearCharTasksCarCheck(pPlayer); - } - } - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem(TEXT("Player.PedSkinsTab"))) + if (ImGui::Button(TEXT("Player.ChangeToCJ"), ImVec2(Widget::CalcSize(1)))) { - Widget::ImageList(pedPage.m_PedData, fArgWrapper(playerPage.SetModel), - [](std::string& str) - { - return pedPage.m_PedData.m_pData->Get(str.c_str(), "Unknown"); - }); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem(TEXT("Player.CustomSkinsTab"))) - { - ImGui::Spacing(); - CustomSkins.Draw(); - ImGui::EndTabItem(); + pPlayer->SetModelIndex(0); + Util::ClearCharTasksCarCheck(pPlayer); } - ImGui::EndTabBar(); } ImGui::EndTabItem(); } + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PERSON_MILITARY_TO_PERSON, "Player.PedSkinsTab"))) + { + Widget::ImageList(pedPage.m_PedData, fArgWrapper(playerPage.SetModel), + [](std::string& str) + { + return pedPage.m_PedData.m_pData->Get(str.c_str(), "Unknown"); + }); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_FOLDER_OPEN, "Player.CustomSkinsTab"))) + { + ImGui::BeginChild("AAA"); + ImGui::Spacing(); + CustomSkins.Draw(); + ImGui::EndChild(); + ImGui::EndTabItem(); + } #else if (ImGui::BeginTabItem(TEXT("Player.SkinsTab"))) { diff --git a/src/pages/scene.cpp b/src/pages/scene.cpp index d23ed81..fdb043d 100644 --- a/src/pages/scene.cpp +++ b/src/pages/scene.cpp @@ -20,7 +20,7 @@ void ScenePage::Draw() CPlayerPed* pPlayer = FindPlayerPed(); int hPlayer = CPools::GetPedRef(pPlayer); - if (ImGui::BeginTabItem(TEXT("Scene.AnimationTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PEOPLE_PULLING, "Scene.AnimationTab"))) { ImGui::Spacing(); if (ImGui::Button(TEXT("Scene.StopAnimation"), Widget::CalcSize())) @@ -58,7 +58,7 @@ void ScenePage::Draw() ImGui::EndTabItem(); } #ifdef GTASA - if (ImGui::BeginTabItem(TEXT("Scene.Tasks"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_LIST_CHECK, "Scene.Tasks"))) { ImGui::Spacing(); Widget::Toggle(TEXT("Menu.ShowPedTasks"), &Overlay::m_bPedTasks); @@ -103,7 +103,7 @@ void ScenePage::Draw() } ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Scene.CutsceneTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_FILM, "Scene.CutsceneTab"))) { ImGui::Spacing(); if (ImGui::Button(TEXT("Scene.StopCutscene"), Widget::CalcSize())) @@ -120,7 +120,7 @@ void ScenePage::Draw() } ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Scene.ParticleTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_SPRAY_CAN, "Scene.ParticleTab"))) { ImGui::Spacing(); if (ImGui::Button(TEXT("Scene.RemoveAll"), Widget::CalcSize(2))) @@ -147,7 +147,7 @@ void ScenePage::Draw() } ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Scene.Styles"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PERSON_RUNNING, "Scene.Styles"))) { ImGui::Spacing(); diff --git a/src/pages/teleport.cpp b/src/pages/teleport.cpp index 0629d02..8b05269 100644 --- a/src/pages/teleport.cpp +++ b/src/pages/teleport.cpp @@ -279,7 +279,7 @@ void TeleportPage::Draw() if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { ImGui::Spacing(); - if (ImGui::BeginTabItem(TEXT("Window.TeleportPage"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_MAP_LOCATION_DOT, "Window.TeleportPage"))) { ImGui::Spacing(); if (ImGui::BeginChild("Teleport Child")) @@ -386,7 +386,7 @@ void TeleportPage::Draw() ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.LocationsTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_MAGNIFYING_GLASS_LOCATION, "Window.LocationsTab"))) { #ifdef GTASA FetchRadarSpriteData(); diff --git a/src/pages/vehicle.cpp b/src/pages/vehicle.cpp index 21980c4..e30320b 100644 --- a/src/pages/vehicle.cpp +++ b/src/pages/vehicle.cpp @@ -522,7 +522,7 @@ void VehiclePage::Draw() ImGui::Spacing(); - if (ImGui::BeginTabItem(TEXT("Window.CheckboxTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TOGGLE_ON, "Window.ToggleTab"))) { ImGui::BeginChild("CheckboxesChild"); ImGui::Spacing(); @@ -802,7 +802,7 @@ void VehiclePage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.MenusTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_BARS, "Window.MenusTab"))) { ImGui::Spacing(); ImGui::BeginChild("MenusChild"); @@ -1003,7 +1003,7 @@ void VehiclePage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.SpawnTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TRUCK_PICKUP, "Window.SpawnTab"))) { ImGui::Spacing(); diff --git a/src/pages/visual.cpp b/src/pages/visual.cpp index b29e097..8784b3a 100644 --- a/src/pages/visual.cpp +++ b/src/pages/visual.cpp @@ -605,7 +605,7 @@ void VisualPage::Draw() { if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { - if (ImGui::BeginTabItem(TEXT("Window.CheckboxTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TOGGLE_ON, "Window.ToggleTab"))) { ImGui::BeginChild("VisualCHild"); ImGui::Spacing(); @@ -859,7 +859,7 @@ void VisualPage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.MenusTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_BARS, "Window.MenusTab"))) { static bool initPatches = false; if (!initPatches) @@ -948,9 +948,10 @@ void VisualPage::Draw() } #ifdef GTASA - if (m_nTimecycHour == 8 ? ImGui::BeginTabItem(TEXT("Visual.TimecycTab")) : ImGui::BeginTabItem(TEXT("Visual.Timecyc24hTab"))) + if (m_nTimecycHour == 8 ? ImGui::BeginTabItem(TEXT_ICON(ICON_FA_CALENDAR_DAY, "Visual.TimecycTab")) + : ImGui::BeginTabItem(TEXT_ICON(ICON_FA_CALENDAR_DAY, "Visual.Timecyc24hTab"))) #else - if (ImGui::BeginTabItem(TEXT("Visual.TimecycTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_CALENDAR_DAY, "Visual.TimecycTab"))) #endif { ImGui::Spacing(); @@ -970,7 +971,7 @@ void VisualPage::Draw() ImGui::Spacing(); if (ImGui::BeginTabBar("Timecyc subtab", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { - if (ImGui::BeginTabItem(TEXT("Visual.ColorsTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PALETTE , "Visual.ColorsTab"))) { ImGui::BeginChild("TimecycColors"); ImGui::Spacing(); @@ -1015,7 +1016,7 @@ void VisualPage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("Misc")) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_CARET_DOWN, "Visual.Miscellaneous"))) { ImGui::BeginChild("TimecycMisc"); ImGui::Spacing(); diff --git a/src/pages/weapon.cpp b/src/pages/weapon.cpp index 0290acd..b903853 100644 --- a/src/pages/weapon.cpp +++ b/src/pages/weapon.cpp @@ -293,7 +293,7 @@ void WeaponPage::Draw() if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { - if (ImGui::BeginTabItem(TEXT("Window.CheckboxTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_TOGGLE_ON, "Window.ToggleTab"))) { ImGui::BeginChild("CheckboxesChild"); ImGui::Spacing(); @@ -372,7 +372,7 @@ void WeaponPage::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem(TEXT("Window.SpawnTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_GUN, "Window.SpawnTab"))) { ImGui::Spacing(); if (ImGui::InputInt(TEXT("Weapon.Ammo"), &m_nAmmoCount)) @@ -396,7 +396,7 @@ void WeaponPage::Draw() ImGui::EndTabItem(); } #ifdef GTASA - if (ImGui::BeginTabItem(TEXT("Weapon.GangWeaponEditor"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PERSON_RIFLE, "Weapon.GangWeaponEditor"))) { ImGui::Spacing(); float width = ImGui::GetWindowContentRegionMax().x - ImGui::GetWindowContentRegionMin().x; diff --git a/src/pch.h b/src/pch.h index ceb12c3..cefe4e5 100644 --- a/src/pch.h +++ b/src/pch.h @@ -66,6 +66,7 @@ #define TEXT(x) Locale::GetText(x).c_str() #define TEXT_S(x) Locale::GetText(x) +#define TEXT_ICON(x, y) std::format("{} {}", x, Locale::GetText(y)).c_str() using namespace plugin; diff --git a/src/utils/d3dhook.cpp b/src/utils/d3dhook.cpp index cdcdc2b..3836248 100644 --- a/src/utils/d3dhook.cpp +++ b/src/utils/d3dhook.cpp @@ -139,8 +139,7 @@ void D3dHook::ProcessFrame(void* ptr) ImGui_ImplWin32_EnableDpiAwareness(); // Loading fonts - io.FontDefault = FontMgr::LoadFont("text", FontMgr::eFontMode::Text, MENU_DATA_PATH("fonts/text.ttf"), 1.3f); - FontMgr::LoadFont("merge", FontMgr::eFontMode::Merge, MENU_DATA_PATH("fonts/icon.ttf"), 1.0f); + io.FontDefault = FontMgr::LoadFont("text", FontMgr::eFontMode::Merge, MENU_DATA_PATH("fonts/text.ttf"), 1.3f); FontMgr::LoadFont("title", FontMgr::eFontMode::Text, MENU_DATA_PATH("fonts/title.ttf"), 2.5f); FontMgr::LoadFont("icon", FontMgr::eFontMode::Icon, MENU_DATA_PATH("fonts/icon.ttf"), 1.5f); io.Fonts->Build(); diff --git a/src/utils/fontmgr.cpp b/src/utils/fontmgr.cpp index 2e5a570..00495ad 100644 --- a/src/utils/fontmgr.cpp +++ b/src/utils/fontmgr.cpp @@ -59,7 +59,7 @@ ImFont* FontMgr::LoadFont(const char* fontID, eFontMode mode, const char* path, ImFontConfig config; config.MergeMode = false; config.GlyphMinAdvanceX = fontSize; // Use if you want to make the icon monospaced - + for (FontInfo info : m_vecFonts) { if (!strcmp(info.m_ID.c_str(), fontID)) @@ -70,7 +70,7 @@ ImFont* FontMgr::LoadFont(const char* fontID, eFontMode mode, const char* path, } } - if (mode == eFontMode::Text || mode == eFontMode::Merge) + if (mode == eFontMode::Text) { data.m_pFont = io.Fonts->AddFontFromFileTTF(path, fontSize, NULL, GetGlyphRanges()); } @@ -81,8 +81,9 @@ ImFont* FontMgr::LoadFont(const char* fontID, eFontMode mode, const char* path, if (mode == eFontMode::Merge) { + data.m_pFont = io.Fonts->AddFontFromFileTTF(path, fontSize, NULL, GetGlyphRanges()); config.MergeMode = true; - io.Fonts->AddFontFromFileTTF(path, fontSize, &config, GetIconGlyphRanges()); + io.Fonts->AddFontFromFileTTF(MENU_DATA_PATH("fonts/icon.ttf"), fontSize, &config, GetIconGlyphRanges()); } if (new_font) diff --git a/src/utils/widget.cpp b/src/utils/widget.cpp index 1c3a4e0..85cec7c 100644 --- a/src/utils/widget.cpp +++ b/src/utils/widget.cpp @@ -93,7 +93,7 @@ void DrawClippedList(ResourceStore& data, fArg3_t clickFunc, bool favourites, bo ImGui::SameLine(); } - if (Widget::Filter("##Filter", data.m_Filter, TEXT("Window.Search"))) + if (Widget::Filter("##Filter", data.m_Filter, TEXT_ICON(ICON_FA_MAGNIFYING_GLASS, "Window.Search"))) { data.UpdateSearchList(favourites); } @@ -137,39 +137,44 @@ void DrawClippedList(ResourceStore& data, fArg3_t clickFunc, bool favourites, bo if (contextMenu.show) { + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8)); if (ImGui::BeginPopupContextWindow()) { ImGui::Text(contextMenu.key.c_str()); ImGui::Separator(); - if (!favourites && ImGui::MenuItem(TEXT("Menu.Favourites"))) + if (!favourites && ImGui::MenuItem(TEXT_ICON(ICON_FA_STAR,"Menu.Favourites"))) { data.m_pData->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val); data.m_pData->Save(); } - if (!favourites && ImGui::MenuItem(TEXT("Menu.Remove"))) + if (ImGui::MenuItem(TEXT_ICON(ICON_FA_TRASH_CAN,"Menu.Remove"))) { - if (contextMenu.root == "Custom" || data.m_bAllowRemoveAll) + if (favourites) { - data.m_pData->RemoveKey(contextMenu.root.c_str(), contextMenu.key.c_str()); - data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str()); - data.m_pData->Save(); - data.UpdateSearchList(); - Util::SetMessage(TEXT("Window.RemoveEntry")); + if (ImGui::MenuItem(TEXT_ICON(ICON_FA_XMARK,"Menu.FavouritesRemove"))) + { + data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str()); + data.m_pData->Save(); + data.UpdateSearchList(true); + } } else { - Util::SetMessage(TEXT("Window.CustomRemoveOnly")); + if (contextMenu.root == "Custom" || data.m_bAllowRemoveAll) + { + data.m_pData->RemoveKey(contextMenu.root.c_str(), contextMenu.key.c_str()); + data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str()); + data.m_pData->Save(); + data.UpdateSearchList(); + Util::SetMessage(TEXT("Window.RemoveEntry")); + } + else + { + Util::SetMessage(TEXT("Window.CustomRemoveOnly")); + } } } - - if (favourites &&ImGui::MenuItem(TEXT("Menu.FavouritesRemove"))) - { - data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str()); - data.m_pData->Save(); - data.UpdateSearchList(true); - } - if (contextOptionsFunc) { contextOptionsFunc(); @@ -181,6 +186,7 @@ void DrawClippedList(ResourceStore& data, fArg3_t clickFunc, bool favourites, bo } ImGui::EndPopup(); } + ImGui::PopStyleVar(); } ImGui::EndChild(); } @@ -195,7 +201,7 @@ void Widget::DataList(ResourceStore& data, fArg3_t clickFunc, fArgNone_t addFunc // Drawing the list here if (ImGui::BeginTabBar("MYTABS")) { - if (ImGui::BeginTabItem(TEXT("Window.Search"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_MAGNIFYING_GLASS, "Window.Search"))) { ImGui::Spacing(); DrawClippedList(data, clickFunc, false, isEditItem, contextOptionsFunc); @@ -205,7 +211,7 @@ void Widget::DataList(ResourceStore& data, fArg3_t clickFunc, fArgNone_t addFunc { data.UpdateSearchList(); } - if (ImGui::BeginTabItem(TEXT("Window.FavouritesTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_STAR, "Window.FavouritesTab"))) { ImGui::Spacing(); DrawClippedList(data, clickFunc, true, isEditItem, contextOptionsFunc); @@ -217,7 +223,7 @@ void Widget::DataList(ResourceStore& data, fArg3_t clickFunc, fArgNone_t addFunc } if (addFunc) { - if (ImGui::BeginTabItem(TEXT("Window.AddNew"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PLUS, "Window.AddNew"))) { ImGui::Spacing(); ImGui::BeginChild("AddNew2"); @@ -300,7 +306,7 @@ void DrawClippedImages(ResourceStore& data, ImVec2 imgSz, size_t imagesInRow, bo } ImGui::SameLine(); } - if (Widget::Filter("##Filter", data.m_Filter, TEXT("Window.Search"))) + if (Widget::Filter("##Filter", data.m_Filter, TEXT_ICON(ICON_FA_MAGNIFYING_GLASS, "Window.Search"))) { data.UpdateSearchList(favourites, getNameFunc, verifyFunc); } @@ -445,7 +451,7 @@ void Widget::ImageList(ResourceStore &store, fArg1_t clickFunc, fRtnArg1_t getNa // Draw images here if (ImGui::BeginTabBar("MYTABS")) { - if (ImGui::BeginTabItem(TEXT("Window.Search"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_MAGNIFYING_GLASS, "Window.Search"))) { ImGui::Spacing(); DrawClippedImages(store, m_ImageSize, imagesInRow, showImages, false, clickFunc, getNameFunc, verifyFunc, contextOptionsFunc); @@ -455,7 +461,7 @@ void Widget::ImageList(ResourceStore &store, fArg1_t clickFunc, fRtnArg1_t getNa { store.UpdateSearchList(false, getNameFunc, verifyFunc); } - if (ImGui::BeginTabItem(TEXT("Window.FavouritesTab"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_STAR, "Window.FavouritesTab"))) { ImGui::Spacing(); DrawClippedImages(store, m_ImageSize, imagesInRow, showImages, true, clickFunc, getNameFunc, verifyFunc, contextOptionsFunc); @@ -467,7 +473,7 @@ void Widget::ImageList(ResourceStore &store, fArg1_t clickFunc, fRtnArg1_t getNa } if (addFunc) { - if (ImGui::BeginTabItem(TEXT("Window.AddNew"))) + if (ImGui::BeginTabItem(TEXT_ICON(ICON_FA_PLUS, "Window.AddNew"))) { ImGui::Spacing(); ImGui::TextWrapped(TEXT("Window.AddNewTip")); @@ -477,7 +483,7 @@ void Widget::ImageList(ResourceStore &store, fArg1_t clickFunc, fRtnArg1_t getNa addFunc(); ImGui::Dummy(ImVec2(0.0f, 10.0f)); - if (ImGui::CollapsingHeader(TEXT("Window.AddNewCustomImg"))) + if (ImGui::CollapsingHeader(TEXT("Window.GBe"))) { ImGui::Spacing(); ImGui::TextWrapped(std::vformat(TEXT("Window.AddNewTip2"), std::make_format_args(store.m_FileName)).c_str());