Skip to content

fix: alignment on unit stats and make drawing OOP#982

Merged
OH296 merged 4 commits intoAdeptus-Dominus:mainfrom
OH296:text_alignment_issues
Aug 21, 2025
Merged

fix: alignment on unit stats and make drawing OOP#982
OH296 merged 4 commits intoAdeptus-Dominus:mainfrom
OH296:text_alignment_issues

Conversation

@OH296
Copy link
Copy Markdown
Collaborator

@OH296 OH296 commented Aug 20, 2025

Purpose and Description

  • Self-descriptive.

Testing done

  • None, and I understand the risks.

Related things and/or additional context

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 20, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced a labelled icon UI element used across the unit management screen with hover tooltips.
    • Reworked unit stats display (Armour, Health, Experience, Damage Resistance, Melee/Ranged Attack and Burden, Bionics, Psyker) into consistent, icon-based panels.
    • Added Psyker icon and enriched tooltips, including STC bonus annotations for armour.
  • Refactor

    • Consolidated per-unit UI setup into a single reset routine for faster, more consistent refreshes.
    • Streamlined save/load to omit transient UI data, reducing unnecessary persistence.

Walkthrough

Litany 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

Cohort / File(s) Summary
Controller serialisation
objects/obj_controller/Create_0.gml
serialize() excludes tooltips, last_unit, unit_manage_constants; no control-flow changes.
Controller step → UI state reset
objects/obj_controller/Step_0.gml
Replaced large per-unit UI build with reset_manage_unit_constants(unit); removed temp-variable assembly and tooltip construction.
UI widgets
scripts/scr_buttons/scr_buttons.gml
Added LabeledIcon(icon, text, x1, y1, data): layout, hit-testing, draw, tooltip; supports update() for data-driven rendering.
Manage UI refactor
scripts/scr_ui_manage/scr_ui_manage.gml
Added reset_manage_unit_constants(unit); migrated to icon-based rendering with LabeledIcons; reworked tooltips access; layout/position updates; STC bonus annotation; temp[121]/[122] handling adjusted.
Sprite metadata
sprites/spr_icon_bionics/spr_icon_bionics.yy
Added seqWidth/seqHeight (128); updated frame keyframe channel metadata format.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

PR: Fix, PR: Sprites, Size: Big

Suggested reviewers

  • EttyKitty
  • Blogaugis

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Area: Sprites Changes to sprites/images or their under-the-hood functionality Size: Huge Type: Fix This is a fix for a bug labels Aug 20, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 32da776 and 633122e.

📒 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.

Files:

  • objects/obj_controller/Create_0.gml
  • scripts/scr_buttons/scr_buttons.gml
  • objects/obj_controller/Step_0.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
**/*.*

⚙️ CodeRabbit Configuration File

**/*.*: - Having humanly understandable and maintainable code is always the top most priority.

Files:

  • objects/obj_controller/Create_0.gml
  • scripts/scr_buttons/scr_buttons.gml
  • sprites/spr_icon_bionics/spr_icon_bionics.yy
  • objects/obj_controller/Step_0.gml
  • scripts/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, both tooltips and unit_manage_constants are rebuilt before any use—no further action required.
• Draw_0.gml (line 4): calls scr_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 change

objects/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).

OH296 and others added 3 commits August 21, 2025 01:04
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@OH296 OH296 merged commit 83d3660 into Adeptus-Dominus:main Aug 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Sprites Changes to sprites/images or their under-the-hood functionality Size: Huge Type: Fix This is a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant