Skip to content

Commit fd96a8a

Browse files
committed
rearrange layout + add Show addon menu button
1 parent 3c2ec03 commit fd96a8a

File tree

4 files changed

+91
-39
lines changed

4 files changed

+91
-39
lines changed

src/Gui.cpp

Lines changed: 78 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -63,54 +63,93 @@ void Gui::MainWindow::act()
6363

6464
ImGui::Begin("GW2 addon manager");
6565

66+
ImGui::Text("Active addons");
67+
ImGui::NewLine();
68+
69+
int idx = 0;
70+
char perAddonTag[256];
71+
6672
for (const auto& i : gAddon().main.GetAddonList())
6773
{
68-
ImGui::Text("%S", i.name);
74+
++idx;
75+
if ((i.status != GW2AL_OK) || !i.dsc)
76+
continue;
77+
78+
ImGui::Text("%S v%u.%u build %u", i.name, i.dsc->majorVer, i.dsc->minorVer, i.dsc->revision);
6979

70-
if (i.status == GW2AL_OK)
80+
sprintf_s(perAddonTag, "O##%S", i.name);
81+
82+
ImGui::SameLine();
83+
if (ImGui::Button(perAddonTag) && idx != activeIndex)
84+
activeIndex = idx;
85+
86+
if (idx == activeIndex)
7187
{
72-
ImGui::SameLine();
73-
if (!i.dsc)
74-
{
75-
ImGui::Text("E: [no description found]");
76-
continue;
77-
}
78-
79-
ImGui::Text("v%u.%u build %u", i.dsc->majorVer, i.dsc->minorVer, i.dsc->revision);
80-
//TODO: make it a hover popup
88+
ImGui::NewLine();
8189
ImGui::Text("%S", i.dsc->description);
82-
}
83-
else {
84-
ImGui::SameLine();
85-
switch (i.status)
90+
if (i.menuShowProc)
8691
{
87-
case GW2AL_BAD_DLL:
88-
ImGui::Text("E: [missing one of export functions]");
89-
break;
90-
case GW2AL_NOT_FOUND:
91-
ImGui::Text("E: [dll not found]");
92-
break;
93-
case GW2AL_DEP_NOT_LOADED:
94-
ImGui::Text("E: [dependency missing]");
95-
break;
96-
case GW2AL_DEP_OUTDATED:
97-
ImGui::Text("E: [dependency outdated]");
98-
break;
99-
default:
100-
ImGui::Text("E: [general failure]");
101-
break;
102-
}
92+
sprintf_s(perAddonTag, "Show addon menu##%S", i.name);
93+
if (ImGui::Button(perAddonTag))
94+
{
95+
i.menuShowProc();
96+
}
97+
}
98+
//TODO: make this work
99+
ImGui::SameLine();
100+
ImGui::Button("Update");
101+
ImGui::SameLine();
102+
ImGui::Button("Reload");
103+
ImGui::SameLine();
104+
ImGui::Button("Disable");
103105
}
106+
}
104107

105-
//TODO: make this work
106-
ImGui::Button("Update");
107-
ImGui::SameLine();
108-
ImGui::Button("Reload");
109-
ImGui::SameLine();
110-
ImGui::Button("Disable");
111-
ImGui::SameLine();
112-
ImGui::Button("Open config menu");
108+
ImGui::Separator();
109+
ImGui::Text("Inactive addons");
110+
ImGui::NewLine();
111+
112+
for (const auto& i : gAddon().main.GetAddonList())
113+
{
114+
if ((i.status == GW2AL_OK) && i.dsc)
115+
continue;
116+
117+
ImGui::Text("%S", i.name);
118+
119+
switch (i.status)
120+
{
121+
case GW2AL_BAD_DLL:
122+
ImGui::Text("E: [missing one of export functions]");
123+
break;
124+
case GW2AL_NOT_FOUND:
125+
ImGui::Text("E: [dll not found]");
126+
break;
127+
case GW2AL_DEP_NOT_LOADED:
128+
ImGui::Text("E: [dependency missing]");
129+
break;
130+
case GW2AL_DEP_OUTDATED:
131+
ImGui::Text("E: [dependency outdated]");
132+
break;
133+
case GW2AL_OK:
134+
ImGui::Text("E: [no description found]");
135+
break;
136+
default:
137+
ImGui::Text("E: [general failure]");
138+
break;
139+
}
140+
141+
ImGui::NewLine();
113142
}
143+
144+
ImGui::Separator();
145+
146+
//TODO: make this work
147+
ImGui::SameLine();
148+
ImGui::Button("Update all");
149+
ImGui::SameLine();
150+
ImGui::Button("Reload all");
151+
ImGui::SameLine();
152+
ImGui::Button("Disable all");
114153

115154
ImGui::End();
116155
}

src/Gui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Gui
1616
bool visible;
1717
void init();
1818
void act();
19+
int activeIndex = -1;
1920
} mainWindow;
2021

2122
public:

src/Main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void Main::updateAddonList()
3737
item.status = GW2AL_FAIL;
3838
item.hashedName = gAddon().api->hash_name(item.name);
3939
item.dsc = nullptr;
40+
item.showConfigPage = false;
41+
item.menuShowProc = nullptr;
4042

4143
/*
4244
constexpr size_t mbstrSz = 4096;
@@ -66,6 +68,11 @@ void Main::updateAddonStatuses()
6668
i.status = GW2AL_OK;
6769
else //otherwise try to load it again and store load error in status
6870
i.status = gAddon().api->load_addon(i.name);
71+
72+
wchar_t sMenuProc[2048];
73+
wsprintf(sMenuProc, L"%s_ExternalShowMenu", i.name);
74+
auto sMenuHa = gAddon().api->hash_name(sMenuProc);
75+
i.menuShowProc = (ExternalMenuShowProcType)gAddon().api->query_function(sMenuHa);
6976
}
7077
}
7178

src/Main.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#pragma once
22
#include "stdafx.h"
33

4+
typedef void(*ExternalMenuShowProcType)();
5+
46
class Main
57
{
68
public:
9+
710
struct AddonListEntry
811
{
912
wchar_t* name;
1013
gw2al_api_ret status;
1114
gw2al_hashed_name hashedName;
15+
ExternalMenuShowProcType menuShowProc;
16+
bool showConfigPage;
1217
const gw2al_addon_dsc* dsc;
1318
};
1419
const std::vector<AddonListEntry>& GetAddonList() { return addonList; }

0 commit comments

Comments
 (0)