diff --git a/GWToolboxdll/Modules/ChatCommands.cpp b/GWToolboxdll/Modules/ChatCommands.cpp index c08333d88..a6859d4aa 100644 --- a/GWToolboxdll/Modules/ChatCommands.cpp +++ b/GWToolboxdll/Modules/ChatCommands.cpp @@ -1682,7 +1682,7 @@ void CHAT_CMD_FUNC(ChatCommands::CmdTB) } else if (arg1 == L"close" || arg1 == L"quit" || arg1 == L"exit") { // e.g. /tb close - GWToolbox::Instance().SignalTerminate(); + GWToolbox::SignalTerminate(); } else { // e.g. /tb travel diff --git a/plugins/clock/clock.cpp b/plugins/clock/clock.cpp deleted file mode 100644 index 1861978b4..000000000 --- a/plugins/clock/clock.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "Clock.h" - -#include -#include - -#include - -#include "GWCA/GWCA.h" - -namespace { - char time_buf[100] = {0}; - - errno_t GetTime(char* out, const size_t len) - { - time_t timestamp; - if (time(×tamp) != timestamp) { - return -1; - } - if (ctime_s(out, len, ×tamp) != 0) { - return -1; - } - out[strlen(out) - 1] = 0; // Remove newline char - return 0; - } - - using SendChat_pt = void(__cdecl *)(wchar_t* message, uint32_t agent_id); - SendChat_pt SendChat_Func = nullptr; - SendChat_pt SendChat_Ret = nullptr; - - void __cdecl OnSendChat(wchar_t* message, uint32_t agent_id) - { - GW::Hook::EnterHook(); - if (message && wcsncmp(L"/clock", message, 6) == 0) { - wchar_t sendchat_buf[100]; - GetTime(time_buf, _countof(time_buf)); - swprintf(sendchat_buf, _countof(sendchat_buf), L"#%S", time_buf); - message = sendchat_buf; - agent_id = 0; - } - SendChat_Ret(message, agent_id); - GW::Hook::LeaveHook(); - } -} - -DLLAPI ToolboxPlugin* ToolboxPluginInstance() -{ - static Clock instance; - return &instance; -} - -void Clock::Draw(IDirect3DDevice9*) -{ - constexpr auto flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar; - if (ImGui::Begin(Name(), can_close && show_closebutton ? GetVisiblePtr() : nullptr, GetWinFlags(flags))) { - GetTime(time_buf, _countof(time_buf)); - ImGui::TextUnformatted(time_buf); - } - ImGui::End(); -} - -void Clock::Initialize(ImGuiContext* ctx, const ImGuiAllocFns fns, const HMODULE toolbox_dll) -{ - ToolboxUIPlugin::Initialize(ctx, fns, toolbox_dll); - - GW::HookBase::Initialize(); - GW::Scanner::Initialize(); - // Copied from GWCA's ChatMgr module - SendChat_Func = (SendChat_pt)GW::Scanner::Find("\x8D\x85\xE0\xFE\xFF\xFF\x50\x68\x1C\x01", "xxxxxxxxx", -0x3E); - - if (SendChat_Func) { - GW::HookBase::CreateHook((void**)&SendChat_Func, OnSendChat, (void**)&SendChat_Ret); - GW::HookBase::EnableHooks(SendChat_Func); - } -} - -void Clock::SignalTerminate() -{ - ToolboxUIPlugin::SignalTerminate(); - if (SendChat_Func) { - GW::HookBase::RemoveHook(SendChat_Func); - } - GW::HookBase::Deinitialize(); -} diff --git a/plugins/clock/clock.h b/plugins/clock/clock.h deleted file mode 100644 index 39c4a8a3e..000000000 --- a/plugins/clock/clock.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include - -class Clock : public ToolboxUIPlugin { -public: - Clock() - { - show_closebutton = false; - show_title = false; - can_collapse = false; - can_close = false; - is_resizable = true; - is_movable = true; - lock_size = true; - lock_move = true; - } - - const char* Name() const override { return "Clock"; } - - void Draw(IDirect3DDevice9*) override; - void Initialize(ImGuiContext*, ImGuiAllocFns, HMODULE) override; - void SignalTerminate() override; -};