fix: alignment on unit stats and make drawing OOP#982
fix: alignment on unit stats and make drawing OOP#982OH296 merged 4 commits intoAdeptus-Dominus:mainfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughSummary by CodeRabbit
WalkthroughLitany of change: serialisation now omits additional fields; Step logic delegates per-unit UI assembly to a reset function; new LabeledIcon UI widget added; manage UI refactored to icon-driven, data-based rendering with a reset entry point; sprite metadata updated. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 10
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scripts/scr_ui_manage/scr_ui_manage.gml (1)
731-744: Unify Psyker display via LabeledIcon for consistency.You hand-draw the psy icon and text; other stats use LabeledIcon with hit/tooltip logic. Standardise to reduce divergence and future maintenance.
Proposed insertion (conceptual):
unit_manage_constants.psionic_icon = new LabeledIcon(spr_icon_psyker, text, x3, y3, { icon_width: 24, icon_height: 24, tooltip: tooltip_text, colour: CM_GREEN_COLOR }); unit_manage_constants.psionic_icon.draw();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
objects/obj_controller/Create_0.gml(1 hunks)objects/obj_controller/Step_0.gml(1 hunks)scripts/scr_buttons/scr_buttons.gml(1 hunks)scripts/scr_ui_manage/scr_ui_manage.gml(8 hunks)sprites/spr_icon_bionics/spr_icon_bionics.yy(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.gml
⚙️ CodeRabbit Configuration File
**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e.#macro ARR_body_parts["arm"]will crash the game, because there is no space between the array and the name of the macro.
- Color codes in the code shouldn't have any spaces in their id. I.e., color code
# 80bf40will crash the game.- All code should comply with the main GML documentation: https://manual.gamemaker.io/beta/en/GameMaker_Language/GML_Reference/GML_Reference.htm
Files:
objects/obj_controller/Create_0.gmlscripts/scr_buttons/scr_buttons.gmlobjects/obj_controller/Step_0.gmlscripts/scr_ui_manage/scr_ui_manage.gml
**/*.*
⚙️ CodeRabbit Configuration File
**/*.*: - Having humanly understandable and maintainable code is always the top most priority.
- DRY (Don't repeat yourself) principle is also very important.
- Ensure that the code is compliant with the CODE_STYLE.MD: https://github.com/Adeptus-Dominus/ChapterMaster/blob/main/docs/CODE_STYLE.md
- If a TODO comment is added, ask the user if you should create a GitHub issue for this TODO.
- If a TODO comment is deleted, remind the user if there is an active GitHub issue related to that comment.
Files:
objects/obj_controller/Create_0.gmlscripts/scr_buttons/scr_buttons.gmlsprites/spr_icon_bionics/spr_icon_bionics.yyobjects/obj_controller/Step_0.gmlscripts/scr_ui_manage/scr_ui_manage.gml
**/*.yy
⚙️ CodeRabbit Configuration File
**/*.yy: - When any script or sprite .yy files are deleted, their paths should also be deleted from the .yyp file, otherwise the game will crash.
- When any script or sprite .yy files are created, their paths should be added to the .yyp file, otherwise they'll fail.
Files:
sprites/spr_icon_bionics/spr_icon_bionics.yy
🔇 Additional comments (6)
sprites/spr_icon_bionics/spr_icon_bionics.yy (2)
66-67: seqHeight/seqWidth match sprite dimensions — sanctified.128x128 sequence metadata aligns with the resource’s width/height. No alignment heresy detected.
73-75: Keyframe Channels structure — verify IDE normalisation.The Channels payload targets channel "0" with a valid Id and path. Confirm your GameMaker IDE doesn’t auto-rewrite this block on next save (some versions re-order or reshape channels), to avoid noisy diffs.
objects/obj_controller/Create_0.gml (2)
1223-1224: Excluding volatile UI/state from saves — approved.tooltips, last_unit, and unit_manage_constants are runtime artefacts and should not be serialised. Good containment.
1223-1224: Rehydration paths confirmed
By the Omnissiah’s decree, bothtooltipsandunit_manage_constantsare rebuilt before any use—no further action required.
• Draw_0.gml (line 4): callsscr_ui_manage(), which initialises
• scr_ui_manage.gml (lines 130–131):
tooltips = {};
unit_manage_constants = {};
• Step_0.gml (line 448):reset_manage_unit_constants(unit)rebuilds on unit changeobjects/obj_controller/Step_0.gml (1)
441-449: On-demand UI reset when selection changes — sound logic.Gate by (company, marine_number) to avoid redundant work. Blessed efficiency.
scripts/scr_ui_manage/scr_ui_manage.gml (1)
395-424: Invalid API: struct_exists() is not a GML function.Use variable_struct_exists() (2.3+) for struct members, or check is_undefined(...).
Apply this diff:
- for (var part = 0; part < array_length(_body_parts); part++) { - if (struct_exists(unit.body[$ _body_parts[part]], "bionic")) { + for (var part = 0; part < array_length(_body_parts); part++) { + if (variable_struct_exists(unit.body[$ _body_parts[part]], "bionic")) { var part_display = _body_parts_display[part]; _bionic_tool += $"Bionic {part_display}"; switch (part_display) {If body parts are arrays (not structs), fetch the entry and then test with is_undefined(entry.bionic) == false.
⛔ Skipped due to learnings
Learnt from: EttyKitty PR: Adeptus-Dominus/ChapterMaster#580 File: objects/obj_pnunit/Alarm_5.gml:45-49 Timestamp: 2025-03-11T04:31:05.120Z Learning: In GameMaker Studio 2 (as of the 2023.4 update), `struct_exists(struct, name)` is a valid function that checks if a specified variable exists within a given struct. It's an alias for the older `variable_struct_exists(struct, name)` function, reflecting GameMaker's updated naming conventions. Both functions perform identical operations, accepting two parameters - the struct reference and the name of the variable to check (as a string).
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Purpose and Description
Testing done
Related things and/or additional context