Skip to content

Commit

Permalink
Merge pull request #154 from AnthonyFuller/select-fixes
Browse files Browse the repository at this point in the history
[DebugMod] Clean up menus, assets box fixes, some other mod fixes
  • Loading branch information
OrfeasZ authored Jan 12, 2025
2 parents 7c2e4e0 + 96f9da7 commit b698e06
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 86 deletions.
30 changes: 15 additions & 15 deletions Mods/DebugMod/Src/DebugMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,10 @@ void DebugMod::OnDrawMenu() {
m_DebugMenuActive = !m_DebugMenuActive;
}

if (ImGui::Button("POSITIONS MENU")) {
m_PositionsMenuActive = !m_PositionsMenuActive;
}

if (ImGui::Button("ENTITY MENU")) {
m_EntityMenuActive = !m_EntityMenuActive;
}
// Disabled due to it freezing the game.
//if (ImGui::Button("POSITIONS MENU")) {
// m_PositionsMenuActive = !m_PositionsMenuActive;
//}

if (ImGui::Button("PLAYER MENU")) {
m_PlayerMenuActive = !m_PlayerMenuActive;
Expand All @@ -107,10 +104,6 @@ void DebugMod::OnDrawMenu() {
if (ImGui::Button("NPCs MENU")) {
m_NPCsMenuActive = !m_NPCsMenuActive;
}

if (ImGui::Button("SCENE MENU")) {
m_SceneMenuActive = !m_SceneMenuActive;
}
}

void DebugMod::OnDrawUI(bool p_HasFocus) {
Expand All @@ -121,8 +114,7 @@ void DebugMod::OnDrawUI(bool p_HasFocus) {
DrawItemsBox(p_HasFocus);
DrawNPCsBox(p_HasFocus);
DrawPlayerBox(p_HasFocus);
DrawPositionBox(p_HasFocus);
DrawSceneBox(p_HasFocus);
//DrawPositionBox(p_HasFocus);

auto& s_ImgGuiIO = ImGui::GetIO();

Expand Down Expand Up @@ -589,9 +581,17 @@ void DebugMod::LoadRepositoryProps() {
if (s_Key == "Title") {
std::string s_Title = ConvertDynamicObjectValueTString(s_Entries->at(i).value);

m_RepositoryProps.insert(std::make_pair(s_Title, ZRepositoryID(s_Id.c_str())));
if (!s_Title.empty() && !m_RepositoryProps.contains(s_Id)) {
m_RepositoryProps.insert(std::make_pair(s_Id, s_Title));
}
}

break;
if (s_Key == "CommonName") {
std::string s_CommonName = ConvertDynamicObjectValueTString(s_Entries->at(i).value);

if (!s_CommonName.empty() && !m_RepositoryProps.contains(s_Id)) {
m_RepositoryProps.insert(std::make_pair(s_Id, s_CommonName));
}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions Mods/DebugMod/Src/DebugMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class DebugMod : public IPluginInterface {
void DrawItemsBox(bool p_HasFocus);
void DrawAssetsBox(bool p_HasFocus);
void DrawNPCsBox(bool p_HasFocus);
void DrawSceneBox(bool p_HasFocus);

static void EquipOutfit(
const TEntityRef<ZGlobalOutfitKit>& p_GlobalOutfitKit, uint8_t n_CurrentCharSetIndex,
Expand Down Expand Up @@ -104,12 +103,10 @@ class DebugMod : public IPluginInterface {
private:
bool m_DebugMenuActive = false;
bool m_PositionsMenuActive = false;
bool m_EntityMenuActive = false;
bool m_PlayerMenuActive = false;
bool m_ItemsMenuActive = false;
bool m_AssetsMenuActive = false;
bool m_NPCsMenuActive = false;
bool m_SceneMenuActive = false;
bool m_RenderNpcBoxes = false;
bool m_RenderNpcNames = false;
bool m_RenderNpcRepoIds = false;
Expand Down Expand Up @@ -148,7 +145,7 @@ class DebugMod : public IPluginInterface {
int m_Height = 0;
TResourcePtr<ZTemplateEntityFactory> m_RepositoryResource;
std::vector<char> m_TextureResourceData;
std::multimap<std::string, ZRepositoryID> m_RepositoryProps;
std::multimap<std::string, std::string> m_RepositoryProps; // RepoId -> Title/Common Name
const std::vector<std::string> m_CharSetCharacterTypes = {"Actor", "Nude", "HeroA"};

bool bActorSelectedByCamera = false;
Expand Down
8 changes: 5 additions & 3 deletions Mods/DebugMod/Src/UI/AssetsBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void DebugMod::DrawAssetsBox(bool p_HasFocus) {
ImGuiWindowFlags_ChildWindow
)) {
for (auto it = m_RepositoryProps.begin(); it != m_RepositoryProps.end(); ++it) {
const std::string s_PropTitle = it->first.c_str();
const std::string s_PropTitle = it->second.c_str();

if (s_PropTitle.empty()) {
continue;
Expand All @@ -63,12 +63,14 @@ void DebugMod::DrawAssetsBox(bool p_HasFocus) {
continue;
}

if (ImGui::Selectable(s_PropTitle.c_str())) {
std::string s_ButtonId = std::format("{}###{}", it->second, it->first);

if (ImGui::Selectable(s_ButtonId.c_str())) {
ImGui::ClearActiveID();
strcpy_s(s_PropTitle_SubString, s_PropTitle.c_str());

for (size_t i = 0; i < s_NumberOfPropsToSpawn_Repo; ++i) {
SpawnRepositoryProp(it->second, s_WorldInventoryButton == 1);
SpawnRepositoryProp(ZRepositoryID(it->first.c_str()), s_WorldInventoryButton == 1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Mods/DebugMod/Src/UI/ItemsBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void DebugMod::DrawItemsBox(bool p_HasFocus) {
for (size_t i = 0; i < s_Actions.size(); i++) {
const ZHM5Action* s_Action = s_Actions[i];
const ZHM5Item* s_Item = s_Action->m_Object.QueryInterface<ZHM5Item>();
std::string s_Title = std::format("{} {}", s_Item->m_pItemConfigDescriptor->m_sTitle.c_str(), i + 1);
std::string s_Title = std::format("{}###{}", s_Item->m_pItemConfigDescriptor->m_sTitle.c_str(), i + 1);

if (ImGui::Selectable(s_Title.c_str(), s_Selected == i)) {
s_Selected = i;
Expand Down
8 changes: 4 additions & 4 deletions Mods/DebugMod/Src/UI/NPCsBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "imgui_internal.h"

void DebugMod::DrawNPCsBox(const bool p_HasFocus) {
static std::string s_currentlySelectActor_Name;
static size_t s_SelectedID = -1;

if (!p_HasFocus || !m_NPCsMenuActive) {
Expand Down Expand Up @@ -51,14 +50,15 @@ void DebugMod::DrawNPCsBox(const bool p_HasFocus) {
continue;
}

std::string s_ButtonId = std::format("{}###{}", s_NPCName, i);

if (!s_CurrentlySelectedActor) {
s_SelectedID = -1;
}

if (ImGui::Selectable(s_NPCName.c_str(), s_SelectedID == i) || s_CurrentlySelectedActor == s_Actor) {
if (s_currentlySelectActor_Name != s_NPCName) // Stop it setting it all the time
if (ImGui::Selectable(s_ButtonId.c_str(), s_SelectedID == i) || s_CurrentlySelectedActor == s_Actor) {
if (s_SelectedID != i) // Stop it setting it all the time
{
s_currentlySelectActor_Name = s_NPCName;
s_CurrentlySelectedActor = s_Actor;
s_SelectedID = i;
m_SelectedEntity = s_CurrentlySelectedActor->m_rCharacter.m_ref;
Expand Down
59 changes: 0 additions & 59 deletions Mods/DebugMod/Src/UI/SceneBox.cpp

This file was deleted.

1 change: 1 addition & 0 deletions Mods/DiscordRichPresence/Src/DiscordRichPresence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void DiscordRichPresence::PopulateGameModes() {
{"campaign", "Mission"},
{"escalation", "Escalation"},
{"elusive", "Elusive Target"},
{"arcade", "Elusive Target Arcade"},
{"evergreen", "Freelancer"},
};

Expand Down

0 comments on commit b698e06

Please sign in to comment.