Skip to content

Commit 4060ae3

Browse files
henderkesclaude
andcommitted
Texmod: keep it a module; give modules a per-frame Draw hook
A plain module only gets Update() (game thread, outside the ImGui frame), so it can't paint an overlay - which is why Texmod had been promoted to a widget. Add a no-op ToolboxModule::Draw(IDirect3DDevice9*) called once per render frame for non-UI modules, so TexmodModule can stay a module and still draw its recording overlay. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b09c736 commit 4060ae3

5 files changed

Lines changed: 19 additions & 15 deletions

File tree

GWToolboxdll/GWToolbox.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,12 @@ void GWToolbox::Draw(IDirect3DDevice9* device)
11281128
}
11291129
}
11301130

1131+
// Non-UI modules have no window of their own but may still paint an overlay
1132+
// this frame (e.g. Texmod's recording banner).
1133+
for (size_t i = 0; i < other_modules_enabled.size(); i++) {
1134+
other_modules_enabled[i]->Draw(device);
1135+
}
1136+
11311137
#ifdef _DEBUG
11321138
// Feel free to uncomment to play with ImGui's features
11331139
//ImGui::ShowDemoWindow();

GWToolboxdll/Modules/TexmodModule.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -946,13 +946,7 @@ void TexmodModule::Terminate()
946946
{
947947
TeardownTextureCapture();
948948
ShutdownGMod(); // synchronously unloads every pack from gMod
949-
ToolboxWidget::Terminate();
950-
}
951-
952-
void TexmodModule::RegisterSettingsContent()
953-
{
954-
// Plain-module settings: skip ToolboxUIElement's visibility/size/position UI.
955-
ToolboxModule::RegisterSettingsContent();
949+
ToolboxModule::Terminate();
956950
}
957951

958952
void TexmodModule::DrawSettingsInternal()

GWToolboxdll/Modules/TexmodModule.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <ToolboxWidget.h>
3+
#include <ToolboxModule.h>
44

55
// ---------------------------------------------------------------------------
66
// TexmodModule
@@ -10,10 +10,10 @@
1010
// priority: when two packs replace the same texture, the one higher in the list
1111
// wins, so reordering re-adds packs in the desired order.
1212
//
13-
// A widget (not a plain module) only so it gets a per-frame Draw() for the texture-
14-
// recording overlay; its settings are still registered like a plain module.
13+
// Draw() (a plain-module render hook) is used only to paint the texture-recording
14+
// overlay; the module has no window of its own.
1515
// ---------------------------------------------------------------------------
16-
class TexmodModule final : public ToolboxWidget {
16+
class TexmodModule final : public ToolboxModule {
1717
public:
1818
static TexmodModule& Instance()
1919
{
@@ -35,9 +35,6 @@ class TexmodModule final : public ToolboxWidget {
3535
void LoadSettings(ToolboxIni* ini) override;
3636
void SaveSettings(ToolboxIni* ini) override;
3737

38-
// Register settings like a plain module (no widget visibility/position controls).
39-
void RegisterSettingsContent() override;
40-
4138
private:
4239
TexmodModule() = default;
4340
};

GWToolboxdll/ToolboxModule.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using SectionDrawCallback = std::function<void(const std::string& section, bool is_showing)>;
88
class ToolboxModule;
99
class ToolboxIni;
10+
struct IDirect3DDevice9;
1011

1112
struct SectionDrawCallbackInfo {
1213
float weighting{};
@@ -72,6 +73,12 @@ class ToolboxModule {
7273
// Update. Will always be called once every frame. Delta in seconds
7374
virtual void Update(float) { }
7475

76+
// Called once per render frame, inside the ImGui frame, for every enabled module.
77+
// UI elements override this to draw their window; a plain module can use it to
78+
// paint an overlay (e.g. on the background draw list), which it otherwise can't
79+
// do from Update() (that runs on the game thread, outside the ImGui frame).
80+
virtual void Draw(IDirect3DDevice9*) { }
81+
7582
// This is provided (and called), but use ImGui::GetIO() during update/render if possible.
7683
virtual bool WndProc(UINT, WPARAM, LPARAM) { return false; }
7784

GWToolboxdll/ToolboxUIElement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ToolboxUIElement : public ToolboxModule {
99
[[nodiscard]] bool IsUIElement() const override { return true; }
1010

1111
// Draw user interface. Will be called every frame if the element is visible
12-
virtual void Draw(IDirect3DDevice9*) { }
12+
void Draw(IDirect3DDevice9*) override { }
1313

1414
void UpdateLocationAgainstSnappedFrame();
1515
static void UpdateCachedFrameStates();

0 commit comments

Comments
 (0)