ImGuiUtils (#4222)

This commit is contained in:
Pepe20129 2024-10-14 02:29:22 +02:00 committed by GitHub
parent 1ffa23b5a9
commit 914e838630
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 284 additions and 237 deletions

View File

@ -1,5 +1,6 @@
#include "debugSaveEditor.h"
#include "../../util.h"
#include "../../ImGuiUtils.h"
#include "../../OTRGlobals.h"
#include "../../UIWidgets.hpp"
@ -25,130 +26,6 @@ extern PlayState* gPlayState;
#include "textures/parameter_static/parameter_static.h"
}
typedef struct {
uint32_t id;
std::string name;
std::string nameFaded;
std::string texturePath;
} ItemMapEntry;
#define ITEM_MAP_ENTRY(id) \
{ \
id, { \
id, #id, #id "_Faded", static_cast<char*>(gItemIcons[id]) \
} \
}
// Maps items ids to info for use in ImGui
std::map<uint32_t, ItemMapEntry> itemMapping = {
ITEM_MAP_ENTRY(ITEM_STICK),
ITEM_MAP_ENTRY(ITEM_NUT),
ITEM_MAP_ENTRY(ITEM_BOMB),
ITEM_MAP_ENTRY(ITEM_BOW),
ITEM_MAP_ENTRY(ITEM_ARROW_FIRE),
ITEM_MAP_ENTRY(ITEM_DINS_FIRE),
ITEM_MAP_ENTRY(ITEM_SLINGSHOT),
ITEM_MAP_ENTRY(ITEM_OCARINA_FAIRY),
ITEM_MAP_ENTRY(ITEM_OCARINA_TIME),
ITEM_MAP_ENTRY(ITEM_BOMBCHU),
ITEM_MAP_ENTRY(ITEM_HOOKSHOT),
ITEM_MAP_ENTRY(ITEM_LONGSHOT),
ITEM_MAP_ENTRY(ITEM_ARROW_ICE),
ITEM_MAP_ENTRY(ITEM_FARORES_WIND),
ITEM_MAP_ENTRY(ITEM_BOOMERANG),
ITEM_MAP_ENTRY(ITEM_LENS),
ITEM_MAP_ENTRY(ITEM_BEAN),
ITEM_MAP_ENTRY(ITEM_HAMMER),
ITEM_MAP_ENTRY(ITEM_ARROW_LIGHT),
ITEM_MAP_ENTRY(ITEM_NAYRUS_LOVE),
ITEM_MAP_ENTR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_ENTRY(ITEM_WALLET_GIANT),
ITEM_MAP_ENTRY(ITEM_SEEDS),
ITEM_MAP_ENTRY(ITEM_FISHING_POLE),
ITEM_MAP_ENTRY(ITEM_KEY_BOSS),
ITEM_MAP_ENTRY(ITEM_COMPASS),
ITEM_MAP_ENTRY(ITEM_DUNGEON_MAP),
ITEM_MAP_ENTRY(ITEM_KEY_SMALL),
ITEM_MAP_ENTRY(ITEM_HEART_CONTAINER),
ITEM_MAP_ENTRY(ITEM_HEART_PIECE),
ITEM_MAP_ENTRY(ITEM_MAGIC_SMALL),
ITEM_MAP_ENTRY(ITEM_MAGIC_LARGE)
};
std::map<uint32_t, ItemMapEntry> gregMapping = {
{ITEM_RUPEE_GREEN, {ITEM_RUPEE_GREEN, "ITEM_RUPEE_GREEN", "ITEM_RUPEE_GREEN_Faded", gRupeeCounterIconTex}}
};
std::map<uint32_t, ItemMapEntry> triforcePieceMapping = {
{RG_TRIFORCE_PIECE, {RG_TRIFORCE_PIECE, "RG_TRIFORCE_PIECE", "RG_TRIFORCE_PIECE_Faded", gTriforcePieceTex}}
};
// Maps entries in the GS flag array to the area name it represents
std::vector<std::string> gsMapping = {
"Deku Tree",
@ -186,85 +63,6 @@ u8 gAllAmmoItems[] = {
ITEM_BOOMERANG, ITEM_LENS, ITEM_BEAN, ITEM_HAMMER,
};
typedef struct {
uint32_t id;
std::string name;
std::string nameFaded;
std::string texturePath;
} QuestMapEntry;
#define QUEST_MAP_ENTRY(id, tex) \
{ \
id, { \
id, #id, #id "_Faded", tex \
} \
}
// Maps quest items ids to info for use in ImGui
std::map<uint32_t, QuestMapEntry> questMapping = {
QUEST_MAP_ENTRY(QUEST_MEDALLION_FOREST, dgQuestIconMedallionForestTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_FIRE, dgQuestIconMedallionFireTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_WATER, dgQuestIconMedallionWaterTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_SPIRIT, dgQuestIconMedallionSpiritTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_SHADOW, dgQuestIconMedallionShadowTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_LIGHT, dgQuestIconMedallionLightTex),
QUEST_MAP_ENTRY(QUEST_KOKIRI_EMERALD, dgQuestIconKokiriEmeraldTex),
QUEST_MAP_ENTRY(QUEST_GORON_RUBY, dgQuestIconGoronRubyTex),
QUEST_MAP_ENTRY(QUEST_ZORA_SAPPHIRE, dgQuestIconZoraSapphireTex),
QUEST_MAP_ENTRY(QUEST_STONE_OF_AGONY, dgQuestIconStoneOfAgonyTex),
QUEST_MAP_ENTRY(QUEST_GERUDO_CARD, dgQuestIconGerudosCardTex),
QUEST_MAP_ENTRY(QUEST_SKULL_TOKEN, dgQuestIconGoldSkulltulaTex),
};
typedef struct {
uint32_t id;
std::string name;
std::string nameFaded;
ImVec4 color;
} SongMapEntry;
#define SONG_MAP_ENTRY(id, r, g, b) \
{ \
id, #id, #id "_Faded", ImVec4(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f) \
}
// Maps song ids to info for use in ImGui
std::array<SongMapEntry, 12> songMapping = { {
SONG_MAP_ENTRY(QUEST_SONG_LULLABY, 224, 107, 255),
SONG_MAP_ENTRY(QUEST_SONG_EPONA, 255, 195, 60),
SONG_MAP_ENTRY(QUEST_SONG_SARIA, 127, 255, 137),
SONG_MAP_ENTRY(QUEST_SONG_SUN, 255, 255, 60),
SONG_MAP_ENTRY(QUEST_SONG_TIME, 119, 236, 255),
SONG_MAP_ENTRY(QUEST_SONG_STORMS, 165, 165, 165),
SONG_MAP_ENTRY(QUEST_SONG_MINUET, 150, 255, 100),
SONG_MAP_ENTRY(QUEST_SONG_BOLERO, 255, 80, 40),
SONG_MAP_ENTRY(QUEST_SONG_SERENADE, 100, 150, 255),
SONG_MAP_ENTRY(QUEST_SONG_REQUIEM, 255, 160, 0),
SONG_MAP_ENTRY(QUEST_SONG_NOCTURNE, 255, 100, 255),
SONG_MAP_ENTRY(QUEST_SONG_PRELUDE, 255, 240, 100),
} };
#define VANILLA_SONG_MAP_ENTRY(id, r, g, b) \
{ \
id, #id "_Vanilla", #id "_Vanilla_Faded", ImVec4(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f) \
}
// Maps song ids to info for use in ImGui
std::array<SongMapEntry, 12> vanillaSongMapping = { {
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_LULLABY, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_EPONA, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_SARIA, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_SUN, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_TIME, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_STORMS, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_MINUET, 150, 255, 100),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_BOLERO, 255, 80, 40),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_SERENADE, 100, 150, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_REQUIEM, 255, 160, 0),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_NOCTURNE, 255, 100, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_PRELUDE, 255, 240, 100),
} };
// Encapsulates what is drawn by the passed-in function within a border
template<typename T>
void DrawGroupWithBorder(T&& drawFunc) {
@ -1812,37 +1610,4 @@ void SaveEditorWindow::DrawElement() {
}
}
void SaveEditorWindow::InitElement() {
// Load item icons into ImGui
for (const auto& entry : itemMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f));
}
for (const auto& entry : gregMapping) {
ImVec4 gregGreen = ImVec4(42.0f / 255.0f, 169.0f / 255.0f, 40.0f / 255.0f, 1.0f);
ImVec4 gregFadedGreen = gregGreen;
gregFadedGreen.w = 0.3f;
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, gregGreen);
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen);
}
for (const auto& entry : triforcePieceMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f));
}
for (const auto& entry : questMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f));
}
for (const auto& entry : songMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color);
ImVec4 fadedCol = entry.color;
fadedCol.w = 0.3f;
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol);
}
for (const auto& entry : vanillaSongMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color);
ImVec4 fadedCol = entry.color;
fadedCol.w = 0.3f;
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol);
}
}
void SaveEditorWindow::InitElement() {}

196
soh/soh/ImGuiUtils.cpp Normal file
View File

@ -0,0 +1,196 @@
#include "ImGuiUtils.h"
#include <Context.h>
#include "assets/soh_assets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TUNIC_ZORA),
ITEM_MAP_ENTRY(ITEM_BOOTS_KOKIRI),
ITEM_MAP_ENTRY(ITEM_BOOTS_IRON),
ITEM_MAP_ENTRY(ITEM_BOOTS_HOVER),
ITEM_MAP_ENTRY(ITEM_BULLET_BAG_30),
ITEM_MAP_ENTRY(ITEM_BULLET_BAG_40),
ITEM_MAP_ENTRY(ITEM_BULLET_BAG_50),
ITEM_MAP_ENTRY(ITEM_QUIVER_30),
ITEM_MAP_ENTRY(ITEM_QUIVER_40),
ITEM_MAP_ENTRY(ITEM_QUIVER_50),
ITEM_MAP_ENTRY(ITEM_BOMB_BAG_20),
ITEM_MAP_ENTRY(ITEM_BOMB_BAG_30),
ITEM_MAP_ENTRY(ITEM_BOMB_BAG_40),
ITEM_MAP_ENTRY(ITEM_BRACELET),
ITEM_MAP_ENTRY(ITEM_GAUNTLETS_SILVER),
ITEM_MAP_ENTRY(ITEM_GAUNTLETS_GOLD),
ITEM_MAP_ENTRY(ITEM_SCALE_SILVER),
ITEM_MAP_ENTRY(ITEM_SCALE_GOLDEN),
ITEM_MAP_ENTRY(ITEM_SWORD_KNIFE),
ITEM_MAP_ENTRY(ITEM_WALLET_ADULT),
ITEM_MAP_ENTRY(ITEM_WALLET_GIANT),
ITEM_MAP_ENTRY(ITEM_SEEDS),
ITEM_MAP_ENTRY(ITEM_FISHING_POLE),
ITEM_MAP_ENTRY(ITEM_KEY_BOSS),
ITEM_MAP_ENTRY(ITEM_COMPASS),
ITEM_MAP_ENTRY(ITEM_DUNGEON_MAP),
ITEM_MAP_ENTRY(ITEM_KEY_SMALL),
ITEM_MAP_ENTRY(ITEM_HEART_CONTAINER),
ITEM_MAP_ENTRY(ITEM_HEART_PIECE),
ITEM_MAP_ENTRY(ITEM_MAGIC_SMALL),
ITEM_MAP_ENTRY(ITEM_MAGIC_LARGE)
};
std::map<uint32_t, ItemMapEntry> gregMapping = {
{ITEM_RUPEE_GREEN, {ITEM_RUPEE_GREEN, "ITEM_RUPEE_GREEN", "ITEM_RUPEE_GREEN_Faded", gRupeeCounterIconTex}}
};
std::map<uint32_t, ItemMapEntry> triforcePieceMapping = {
{RG_TRIFORCE_PIECE, {RG_TRIFORCE_PIECE, "RG_TRIFORCE_PIECE", "RG_TRIFORCE_PIECE_Faded", gTriforcePieceTex}}
};
std::map<uint32_t, QuestMapEntry> questMapping = {
QUEST_MAP_ENTRY(QUEST_MEDALLION_FOREST, dgQuestIconMedallionForestTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_FIRE, dgQuestIconMedallionFireTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_WATER, dgQuestIconMedallionWaterTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_SPIRIT, dgQuestIconMedallionSpiritTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_SHADOW, dgQuestIconMedallionShadowTex),
QUEST_MAP_ENTRY(QUEST_MEDALLION_LIGHT, dgQuestIconMedallionLightTex),
QUEST_MAP_ENTRY(QUEST_KOKIRI_EMERALD, dgQuestIconKokiriEmeraldTex),
QUEST_MAP_ENTRY(QUEST_GORON_RUBY, dgQuestIconGoronRubyTex),
QUEST_MAP_ENTRY(QUEST_ZORA_SAPPHIRE, dgQuestIconZoraSapphireTex),
QUEST_MAP_ENTRY(QUEST_STONE_OF_AGONY, dgQuestIconStoneOfAgonyTex),
QUEST_MAP_ENTRY(QUEST_GERUDO_CARD, dgQuestIconGerudosCardTex),
QUEST_MAP_ENTRY(QUEST_SKULL_TOKEN, dgQuestIconGoldSkulltulaTex),
};
std::array<SongMapEntry, 12> songMapping = { {
SONG_MAP_ENTRY(QUEST_SONG_LULLABY, 224, 107, 255),
SONG_MAP_ENTRY(QUEST_SONG_EPONA, 255, 195, 60),
SONG_MAP_ENTRY(QUEST_SONG_SARIA, 127, 255, 137),
SONG_MAP_ENTRY(QUEST_SONG_SUN, 255, 255, 60),
SONG_MAP_ENTRY(QUEST_SONG_TIME, 119, 236, 255),
SONG_MAP_ENTRY(QUEST_SONG_STORMS, 165, 165, 165),
SONG_MAP_ENTRY(QUEST_SONG_MINUET, 150, 255, 100),
SONG_MAP_ENTRY(QUEST_SONG_BOLERO, 255, 80, 40),
SONG_MAP_ENTRY(QUEST_SONG_SERENADE, 100, 150, 255),
SONG_MAP_ENTRY(QUEST_SONG_REQUIEM, 255, 160, 0),
SONG_MAP_ENTRY(QUEST_SONG_NOCTURNE, 255, 100, 255),
SONG_MAP_ENTRY(QUEST_SONG_PRELUDE, 255, 240, 100),
} };
std::array<SongMapEntry, 12> vanillaSongMapping = { {
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_LULLABY, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_EPONA, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_SARIA, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_SUN, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_TIME, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_STORMS, 255, 255, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_MINUET, 150, 255, 100),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_BOLERO, 255, 80, 40),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_SERENADE, 100, 150, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_REQUIEM, 255, 160, 0),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_NOCTURNE, 255, 100, 255),
VANILLA_SONG_MAP_ENTRY(QUEST_SONG_PRELUDE, 255, 240, 100),
} };
void RegisterImGuiItemIcons() {
for (const auto& entry : itemMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f));
}
for (const auto& entry : gregMapping) {
ImVec4 gregGreen = ImVec4(42.0f / 255.0f, 169.0f / 255.0f, 40.0f / 255.0f, 1.0f);
ImVec4 gregFadedGreen = gregGreen;
gregFadedGreen.w = 0.3f;
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, gregGreen);
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen);
}
for (const auto& entry : triforcePieceMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f));
}
for (const auto& entry : questMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.name, entry.second.texturePath, ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f));
}
for (const auto& entry : songMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color);
ImVec4 fadedCol = entry.color;
fadedCol.w = 0.3f;
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol);
}
for (const auto& entry : vanillaSongMapping) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.name, gSongNoteTex, entry.color);
ImVec4 fadedCol = entry.color;
fadedCol.w = 0.3f;
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(entry.nameFaded, gSongNoteTex, fadedCol);
}
}

83
soh/soh/ImGuiUtils.h Normal file
View File

@ -0,0 +1,83 @@
#ifndef IM_GUI_UTILS_H
#define IM_GUI_UTILS_H
#pragma once
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
#include <imgui.h>
#include <array>
#include <map>
#include <string>
#include "Enhancements/randomizer/randomizerTypes.h"
#include "variables.h" //only for gItemIcons
extern "C" {
#include "textures/icon_item_static/icon_item_static.h"
#include "textures/icon_item_24_static/icon_item_24_static.h"
#include "textures/parameter_static/parameter_static.h"
}
void RegisterImGuiItemIcons();
typedef struct {
uint32_t id;
std::string name;
std::string nameFaded;
std::string texturePath;
} ItemMapEntry;
#define ITEM_MAP_ENTRY(id) \
{ \
id, { \
id, #id, #id "_Faded", static_cast<char*>(gItemIcons[id]) \
} \
}
// Maps items ids to info for use in ImGui
extern std::map<uint32_t, ItemMapEntry> itemMapping;
extern std::map<uint32_t, ItemMapEntry> gregMapping;
typedef struct {
uint32_t id;
std::string name;
std::string nameFaded;
std::string texturePath;
} QuestMapEntry;
#define QUEST_MAP_ENTRY(id, tex) \
{ \
id, { \
id, #id, #id "_Faded", tex \
} \
}
// Maps quest items ids to info for use in ImGui
extern std::map<uint32_t, QuestMapEntry> questMapping;
typedef struct {
uint32_t id;
std::string name;
std::string nameFaded;
ImVec4 color;
} SongMapEntry;
#define SONG_MAP_ENTRY(id, r, g, b) \
{ \
id, #id, #id "_Faded", ImVec4(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f) \
}
// Maps song ids to info for use in ImGui
extern std::array<SongMapEntry, 12> songMapping;
#define VANILLA_SONG_MAP_ENTRY(id, r, g, b) \
{ \
id, #id "_Vanilla", #id "_Vanilla_Faded", ImVec4(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f) \
}
// Maps song ids to info for use in ImGui
extern std::array<SongMapEntry, 12> vanillaSongMapping;
#endif //IM_GUI_UTILS_H

View File

@ -46,6 +46,7 @@
#include "Fonts.h"
#include <utils/StringHelper.h>
#include "Enhancements/custom-message/CustomMessageManager.h"
#include "ImGuiUtils.h"
#include "Enhancements/presets.h"
#include "util.h"
#include <boost_custom/container_hash/hash_32.hpp>
@ -1182,6 +1183,8 @@ extern "C" void InitOTR() {
// #endregion
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnFileDropped>(SoH_ProcessDroppedFiles);
RegisterImGuiItemIcons();
time_t now = time(NULL);
tm *tm_now = localtime(&now);
if (tm_now->tm_mon == 11 && tm_now->tm_mday >= 24 && tm_now->tm_mday <= 25) {