Skip to content

Commit

Permalink
Added warning prompt then trying to reroll to a character that is cur…
Browse files Browse the repository at this point in the history
…rently in an outpost that doesn't support toolbox
  • Loading branch information
3vcloud committed May 19, 2024
1 parent 6c73e04 commit 922c0bb
Show file tree
Hide file tree
Showing 6 changed files with 403 additions and 384 deletions.
10 changes: 5 additions & 5 deletions GWToolboxdll/GWToolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,6 @@ namespace {
return inifile;
}

bool ShouldDisableToolbox() {
const auto m = GW::Map::GetMapInfo();
return m && (m->GetIsPvP() || m->GetIsGuildHall());
}

bool CanRenderToolbox() {
return !gwtoolbox_disabled
&& GW::UI::GetIsUIDrawn()
Expand Down Expand Up @@ -356,6 +351,11 @@ void UpdateEnabledWidgetVectors(ToolboxModule* m, bool added)
}
}

bool GWToolbox::ShouldDisableToolbox(GW::Constants::MapID map_id) {
const auto m = GW::Map::GetMapInfo(map_id);
return m && (m->GetIsPvP() || m->GetIsGuildHall());
}

bool GWToolbox::IsInitialized() { return gwtoolbox_state == GWToolboxState::Initialised; }

bool GWToolbox::ToggleModule(ToolboxWidget& m, const bool enable)
Expand Down
7 changes: 7 additions & 0 deletions GWToolboxdll/GWToolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ class ToolboxWidget;
class ToolboxWindow;
class ToolboxModule;

namespace GW {
namespace Constants {
enum class MapID : uint32_t;
}
}

class GWToolbox {
public:
static GWToolbox& Instance()
{
static GWToolbox instance;
return instance;
}
static bool ShouldDisableToolbox(GW::Constants::MapID = (GW::Constants::MapID)0);

static HMODULE GetDLLModule();
static void Draw(IDirect3DDevice9* device);
Expand Down
31 changes: 31 additions & 0 deletions GWToolboxdll/ImGuiAddons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,37 @@ namespace ImGui {
SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), flags, ImVec2(0.5f, 0.5f));
}

bool ConfirmDialog(const char* message, bool* result) {
bool res = false;
ImGui::OpenPopup("##confirm_popup");
if (ImGui::BeginPopupModal("##confirm_popup", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextUnformatted(message);
static bool was_enter_down = true, was_escape_down = true;
if (!ImGui::IsKeyDown(ImGuiKey_Enter)) {
was_enter_down = false;
}
if (!ImGui::IsKeyDown(ImGuiKey_Escape)) {
was_escape_down = false;
}

if (ImGui::Button("Yes", ImVec2(120, 0)) || (!was_enter_down && ImGui::IsKeyPressed(ImGuiKey_Enter, false))) {
was_enter_down = true;
*result = true;
res = true;
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("No", ImVec2(120, 0)) || (!was_escape_down && ImGui::IsKeyPressed(ImGuiKey_Escape, false))) {
was_escape_down = true;
*result = false;
res = true;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
return res;
}

bool SmallConfirmButton(const char* label, bool* confirm_bool, const char* confirm_content)
{
static char id_buf[128];
Expand Down
3 changes: 3 additions & 0 deletions GWToolboxdll/ImGuiAddons.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace ImGui {
IMGUI_API bool MyCombo(const char* label, const char* preview_text, int* current_item,
bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count);

// Show a popup on-screen with a message and yes/no buttons. Returns true if an option has been chosen, with *result as true/false for yes/no
IMGUI_API bool ConfirmDialog(const char* message, bool* result);

IMGUI_API bool SmallConfirmButton(const char* label, bool* confirm_bool, const char* confirm_content = "Are you sure you want to continue?");

IMGUI_API bool ConfirmButton(const char* label, bool* confirm_bool, const char* confirm_content = "Are you sure you want to continue?");
Expand Down
Loading

0 comments on commit 922c0bb

Please sign in to comment.