Skip to content

unify(gadget): Merge and move GUI gadgets and related code#2672

Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom
DevGeniusCode:unify/merge-move-gadgets
May 2, 2026
Merged

unify(gadget): Merge and move GUI gadgets and related code#2672
xezon merged 2 commits intoTheSuperHackers:mainfrom
DevGeniusCode:unify/merge-move-gadgets

Conversation

@DevGeniusCode
Copy link
Copy Markdown

@DevGeniusCode DevGeniusCode commented May 2, 2026

This PR initiates the unification of the GUI categories by merging and moving the Gadgets group (including their W3D implementations) into the shared core folder, 34 files.

In Base Generals, the text margin logic was hardcoded directly in W3DTextEntry. Zero Hour refactored this by moving the initialization into GameWindowManagerScript.cpp. To unify the behavior between both games, I replicated this shift for Base Generals as well. Note that GameWindowManagerScript.cpp is only receiving this small logic merge and isn't being moved yet, as it belongs to the Core GUI group which will be handled later.

Inherited Zero Hour Features (Base Generals)

  • Mouse Down Triggers: Added WIN_STATUS_ON_MOUSE_DOWN support via buttonTriggersOnMouseDown(), allowing specific buttons to execute their actions immediately on click rather than waiting for the mouse button to be released.
  • Instant Checkboxes: Checkboxes (WIN_STATUS_CHECK_LIKE) now implicitly and universally trigger their logic on Mouse Down rather than Mouse Up.
  • Shortcut Button Text Offsets: Added handling for WIN_STATUS_SHORTCUT_BUTTON to forcefully align text to the top-left corner of the button.
--- MERGE FIRST ---
GameEngine/Include/GameClient/Gadget.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DTextEntry.cpp
GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp (Partial merge for margin logic only)

--- ONLY MOVE ---
GameEngine/Source/GameClient/GUI/Gadget/GadgetCheckBox.cpp
GameEngine/Include/GameClient/GadgetCheckBox.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetComboBox.cpp
GameEngine/Include/GameClient/GadgetComboBox.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp
GameEngine/Include/GameClient/GadgetListBox.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetProgressBar.cpp
GameEngine/Include/GameClient/GadgetProgressBar.h
GameEngine/Include/GameClient/GadgetPushButton.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetRadioButton.cpp
GameEngine/Include/GameClient/GadgetRadioButton.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetStaticText.cpp
GameEngine/Include/GameClient/GadgetStaticText.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetTabControl.cpp
GameEngine/Include/GameClient/GadgetTabControl.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetTextEntry.cpp
GameEngine/Include/GameClient/GadgetTextEntry.h
GameEngine/Source/GameClient/GUI/Gadget/GadgetHorizontalSlider.cpp
GameEngine/Source/GameClient/GUI/Gadget/GadgetVerticalSlider.cpp
GameEngine/Include/GameClient/GadgetSlider.h

GameEngineDevice/Include/W3DDevice/GameClient/W3DGadget.h
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DCheckBox.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DComboBox.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DHorizontalSlider.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DListBox.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DProgressBar.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DRadioButton.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DStaticText.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DTabControl.cpp
GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DVerticalSlider.cpp

@DevGeniusCode DevGeniusCode added the Unify Unifies code between Generals and Zero Hour label May 2, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 2, 2026

Greptile Summary

This PR migrates 34 GUI gadget source and header files from game-specific directories (Generals/, GeneralsMD/) into the shared Core/ folder, updating all CMakeLists.txt references accordingly. Alongside the file moves, it merges three Zero Hour features into Base Generals: WIN_STATUS_ON_MOUSE_DOWN support via buttonTriggersOnMouseDown(), implicit mouse-down triggering for checkbox-style buttons, and shortcut button top-left text alignment; it also ports the ZH pattern of initializing static text margins in GameWindowManagerScript.cpp rather than in W3DTextEntry.cpp.

Confidence Score: 5/5

Safe to merge — moves are clean renames, merged logic is correct, and the margin init change exactly mirrors existing ZH behaviour.

No P0 or P1 findings. The file migrations are mechanical moves, the new buttonTriggersOnMouseDown logic is correct and mirrors the ZH source it was ported from, and the GameWindowManagerScript margin defaults match the hardcoded values previously in W3DTextEntry.

No files require special attention.

Important Files Changed

Filename Overview
Core/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp Merged ZH features: adds buttonTriggersOnMouseDown() helper and wires it into GWM_LEFT_DOWN / GWM_LEFT_UP handling; logic is correct
Core/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp Adds WIN_STATUS_SHORTCUT_BUTTON text alignment to drawButtonText(); shortcut path hard-codes top-left offset (origin.x+2, origin.y+0)
Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp Adds centeredVertically/leftMargin/topMargin defaults for TextData in parseStaticTextData(), matching ZH behaviour
Core/GameEngine/CMakeLists.txt Uncomments Gadget header and source entries to include Core gadget files in the build
Generals/Code/GameEngine/CMakeLists.txt Comments out Gadget source/header entries now that they live in Core/
scripts/cpp/unify_move_files.py Appends commented-out unify_file() calls recording which gadget files were moved; entries are all commented out (no active execution)
Core/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DTextEntry.cpp ZH version (no hardcoded margin init); margin setup is now handled in GameWindowManagerScript.cpp for both games

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[GWM_LEFT_DOWN received] --> B{buttonTriggersOnMouseDown?}
    B -- WIN_STATUS_ON_MOUSE_DOWN set --> C[Send GBM_SELECTED immediately]
    B -- WIN_STATUS_CHECK_LIKE set --> D[Toggle selected state]
    D --> E[Send GBM_SELECTED immediately]
    B -- Normal button --> F[Set WIN_STATE_SELECTED only]

    G[GWM_LEFT_UP received] --> H{WIN_STATUS_CHECK_LIKE?}
    H -- Yes --> I[Return MSG_IGNORED]
    H -- No, and was selected --> J{buttonTriggersOnMouseDown?}
    J -- Yes already fired --> K[Clear selected, no re-send]
    J -- No --> L[Send GBM_SELECTED now]
    L --> K
Loading

Reviews (3): Last reviewed commit: "unify(gadget): Move Gadget files to Core..." | Re-trigger Greptile

@DevGeniusCode
Copy link
Copy Markdown
Author

Confidence Score: 4/5

Regarding the Greptile findings:

Smoke testing completed on Base Generals. The StaticText gadgets render correctly with no layout regressions.

  1. The double space in the @todo comment is a direct copy from the original Zero Hour source.
  2. The style warnings in unify_move_files.py apply to pre-existing code; the script was not modified in this PR.

@xezon xezon added this to the Code foundation build up milestone May 2, 2026
Copy link
Copy Markdown

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok in principle.

Needs documention in the pull desc what Generals gets. For example it gets ON_MOUSE_DOWN support.

Comment thread Core/GameEngine/Include/GameClient/Gadget.h
Comment thread Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetPushButton.cpp Outdated
DevGeniusCode added a commit to DevGeniusCode/GeneralsGameCode that referenced this pull request May 2, 2026
DevGeniusCode added a commit to DevGeniusCode/GeneralsGameCode that referenced this pull request May 2, 2026
@DevGeniusCode DevGeniusCode force-pushed the unify/merge-move-gadgets branch from df6b718 to f579457 Compare May 2, 2026 13:17
@xezon xezon changed the title unify(gadgets): Merge and Move Gadgets and related code from Zero Hour unify(gadget): Merge and move GUI gadgets and related code May 2, 2026
@xezon
Copy link
Copy Markdown

xezon commented May 2, 2026

Please rename (gadgets) to (gadget) because the gadget code is named "gadget"

@xezon xezon added Gen Relates to Generals ZH Relates to Zero Hour labels May 2, 2026
@DevGeniusCode DevGeniusCode force-pushed the unify/merge-move-gadgets branch from f579457 to 7d65fa6 Compare May 2, 2026 17:52
@DevGeniusCode
Copy link
Copy Markdown
Author

Please rename (gadgets) to (gadget) because the gadget code is named "gadget"

Fixed

@xezon xezon merged commit efabb08 into TheSuperHackers:main May 2, 2026
17 checks passed
@DevGeniusCode DevGeniusCode deleted the unify/merge-move-gadgets branch May 2, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Unify Unifies code between Generals and Zero Hour ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants