From f2c0303875b40aa5ccfa8b319f6f1e11b0fe54b0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 25 Aug 2024 13:57:05 +1000 Subject: [PATCH] Misc: Use lightgun controller icon --- dep/imgui/include/imconfig.h | 4 ++-- scripts/generate_update_fa_glyph_ranges.py | 6 +++--- src/core/achievements.cpp | 2 -- src/core/achievements.h | 2 +- src/core/fullscreen_ui.cpp | 2 -- src/core/guncon.cpp | 2 +- src/core/imgui_overlays.cpp | 2 -- src/core/justifier.cpp | 2 +- src/util/imgui_animated.h | 6 +----- src/util/imgui_fullscreen.cpp | 2 -- src/util/imgui_manager.cpp | 19 +++++++++++-------- src/util/imgui_manager.h | 5 ++++- 12 files changed, 24 insertions(+), 30 deletions(-) diff --git a/dep/imgui/include/imconfig.h b/dep/imgui/include/imconfig.h index a387582f7..fb8690c0c 100644 --- a/dep/imgui/include/imconfig.h +++ b/dep/imgui/include/imconfig.h @@ -63,7 +63,7 @@ //#define IMGUI_USE_BGRA_PACKED_COLOR //---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) -//#define IMGUI_USE_WCHAR32 +#define IMGUI_USE_WCHAR32 //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. @@ -105,7 +105,7 @@ operator MyVec4() const { return MyVec4(x,y,z,w); } */ //---- ...Or use Dear ImGui's own very basic math operators. -//#define IMGUI_DEFINE_MATH_OPERATORS +#define IMGUI_DEFINE_MATH_OPERATORS //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). diff --git a/scripts/generate_update_fa_glyph_ranges.py b/scripts/generate_update_fa_glyph_ranges.py index fafc5c230..eee303454 100755 --- a/scripts/generate_update_fa_glyph_ranges.py +++ b/scripts/generate_update_fa_glyph_ranges.py @@ -55,11 +55,11 @@ def get_pairs(tokens): for token in tokens: u8_bytes = u8_encodings[token] u8 = str(u8_bytes, "utf-8") - u16 = u8.encode("utf-16le") - if len(u16) > 2: + u32 = u8.encode("utf-32le") + if len(u32) > 4: raise ValueError("{} {} too long".format(u8_bytes, token)) - codepoint = int.from_bytes(u16, byteorder="little", signed=False) + codepoint = int.from_bytes(u32, byteorder="little", signed=False) codepoints.append(codepoint) codepoints.sort() codepoints.append(0) # null terminator diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index ff4b7dd55..a5edd568b 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -3,8 +3,6 @@ // TODO: Don't poll when booting the game, e.g. Crash Warped freaks out. -#define IMGUI_DEFINE_MATH_OPERATORS - #include "achievements.h" #include "achievements_private.h" #include "bios.h" diff --git a/src/core/achievements.h b/src/core/achievements.h index ef8f0ef3d..d756077ac 100644 --- a/src/core/achievements.h +++ b/src/core/achievements.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index b6af1755a..4fb27ea98 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#define IMGUI_DEFINE_MATH_OPERATORS - #include "fullscreen_ui.h" #include "achievements.h" #include "bios.h" diff --git a/src/core/guncon.cpp b/src/core/guncon.cpp index 89d23e41c..a794fd214 100644 --- a/src/core/guncon.cpp +++ b/src/core/guncon.cpp @@ -304,7 +304,7 @@ static const SettingInfo s_settings[] = { "%.0f%%", nullptr, 100.0f}}; const Controller::ControllerInfo GunCon::INFO = { - ControllerType::GunCon, "GunCon", TRANSLATE_NOOP("ControllerType", "GunCon"), nullptr, + ControllerType::GunCon, "GunCon", TRANSLATE_NOOP("ControllerType", "GunCon"), ICON_PF_LIGHT_GUN, s_binding_info, s_settings, Controller::VibrationCapabilities::NoVibration}; void GunCon::LoadSettings(SettingsInterface& si, const char* section, bool initial) diff --git a/src/core/imgui_overlays.cpp b/src/core/imgui_overlays.cpp index f4a743fe7..5fa0c3488 100644 --- a/src/core/imgui_overlays.cpp +++ b/src/core/imgui_overlays.cpp @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#define IMGUI_DEFINE_MATH_OPERATORS - #include "imgui_overlays.h" #include "cdrom.h" #include "controller.h" diff --git a/src/core/justifier.cpp b/src/core/justifier.cpp index b13873e24..0e435e31d 100644 --- a/src/core/justifier.cpp +++ b/src/core/justifier.cpp @@ -391,7 +391,7 @@ static const SettingInfo s_settings[] = { const Controller::ControllerInfo Justifier::INFO = {ControllerType::Justifier, "Justifier", TRANSLATE_NOOP("ControllerType", "Justifier"), - nullptr, + ICON_PF_LIGHT_GUN, s_binding_info, s_settings, Controller::VibrationCapabilities::NoVibration}; diff --git a/src/util/imgui_animated.h b/src/util/imgui_animated.h index 9f354ae41..eeec51fbf 100644 --- a/src/util/imgui_animated.h +++ b/src/util/imgui_animated.h @@ -1,12 +1,8 @@ -// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif - #include "common/easing.h" #include "imgui.h" diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index aa4beb5f4..2d04b425d 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) -#define IMGUI_DEFINE_MATH_OPERATORS - #include "imgui_fullscreen.h" #include "gpu_device.h" #include "image.h" diff --git a/src/util/imgui_manager.cpp b/src/util/imgui_manager.cpp index 1cca1a50d..294c83206 100644 --- a/src/util/imgui_manager.cpp +++ b/src/util/imgui_manager.cpp @@ -1,5 +1,5 @@ // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin -// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) +// SPDX-License-Identifier: (GPL-3.0 OR PolyForm-Strict-1.0.0) #include "imgui_manager.h" #include "gpu_device.h" @@ -26,6 +26,7 @@ #include #include #include +#include #include Log_SetChannel(ImGuiManager); @@ -57,6 +58,8 @@ struct OSDMessage } // namespace +static_assert(std::is_same_v); + static void UpdateScale(); static void SetStyle(); static void SetKeyMap(); @@ -76,7 +79,7 @@ static float s_global_prescale = 1.0f; // before window scale static float s_global_scale = 1.0f; static std::string s_font_path; -static std::vector s_font_range; +static std::vector s_font_range; static ImFont* s_standard_font; static ImFont* s_fixed_font; @@ -111,7 +114,7 @@ static bool s_scale_changed = false; static std::array s_software_cursors = {}; } // namespace ImGuiManager -void ImGuiManager::SetFontPathAndRange(std::string path, std::vector range) +void ImGuiManager::SetFontPathAndRange(std::string path, std::vector range) { if (s_font_path == path && s_font_range == range) return; @@ -552,11 +555,11 @@ bool ImGuiManager::AddIconFonts(float size) 0xf7a0, 0xf7a0, 0xf7c2, 0xf7c2, 0xf807, 0xf807, 0xf815, 0xf815, 0xf818, 0xf818, 0xf84c, 0xf84c, 0xf8cc, 0xf8cc, 0x0, 0x0}; static constexpr ImWchar range_pf[] = { - 0x2196, 0x2199, 0x219e, 0x21a1, 0x21b0, 0x21b3, 0x21ba, 0x21c3, 0x21c7, 0x21ca, 0x21d0, 0x21d4, 0x21dc, - 0x21dd, 0x21e0, 0x21e3, 0x21ed, 0x21ee, 0x21f3, 0x21f3, 0x21f7, 0x21f8, 0x21fa, 0x21fb, 0x227a, 0x227f, - 0x2284, 0x2284, 0x235e, 0x235e, 0x2360, 0x2361, 0x2364, 0x2366, 0x23b2, 0x23b4, 0x23ce, 0x23ce, 0x23f4, - 0x23f7, 0x2427, 0x243a, 0x243c, 0x243e, 0x2460, 0x246b, 0x24f5, 0x24fd, 0x24ff, 0x24ff, 0x2717, 0x2717, - 0x278a, 0x278e, 0x27fc, 0x27fc, 0xe001, 0xe001, 0xff21, 0xff3a, 0x0, 0x0}; + 0x2196, 0x2199, 0x219e, 0x21a1, 0x21b0, 0x21b3, 0x21ba, 0x21c3, 0x21c7, 0x21ca, 0x21d0, 0x21d4, 0x21dc, + 0x21dd, 0x21e0, 0x21e3, 0x21ed, 0x21ee, 0x21f7, 0x21f8, 0x21fa, 0x21fb, 0x227a, 0x227f, 0x2284, 0x2284, + 0x235e, 0x235e, 0x2360, 0x2361, 0x2364, 0x2366, 0x23b2, 0x23b4, 0x23ce, 0x23ce, 0x23f4, 0x23f7, 0x2427, + 0x243a, 0x243c, 0x243e, 0x2460, 0x246b, 0x24f5, 0x24fd, 0x24ff, 0x24ff, 0x2717, 0x2717, 0x278a, 0x278e, + 0x27fc, 0x27fc, 0xe001, 0xe001, 0xff21, 0xff3a, 0x1f52b, 0x1f52b, 0x0, 0x0}; { ImFontConfig cfg; diff --git a/src/util/imgui_manager.h b/src/util/imgui_manager.h index 71dc1ea85..4ffa36663 100644 --- a/src/util/imgui_manager.h +++ b/src/util/imgui_manager.h @@ -15,8 +15,11 @@ union InputBindingKey; enum class GenericInputBinding : u8; namespace ImGuiManager { + +using WCharType = u32; + /// Sets the path to the font to use. Empty string means to use the default. -void SetFontPathAndRange(std::string path, std::vector range); +void SetFontPathAndRange(std::string path, std::vector range); /// Changes the global scale. void SetGlobalScale(float global_scale);