Skip to content

fix: various issues from new creation screen works#975

Merged
OH296 merged 3 commits intoAdeptus-Dominus:mainfrom
OH296:role_colour_hotfix
Aug 17, 2025
Merged

fix: various issues from new creation screen works#975
OH296 merged 3 commits intoAdeptus-Dominus:mainfrom
OH296:role_colour_hotfix

Conversation

@OH296
Copy link
Copy Markdown
Collaborator

@OH296 OH296 commented Aug 17, 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 17, 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

    • Added new Roles controls: Equal Specialist Distribution toggle, Load to Ships options (On Planet / Load to Ships / Load sans Escorts), and toggles for Distribute Scouts and Distribute Veterans.
  • UI/UX

    • Improved radio/toggle rendering, sizing, and alignment; optional in-draw click handling.
    • Repositioned Advanced Helmet Livery option.
    • More consistent gear slot selection behaviour (0–4 indexing).
  • Bug Fixes

    • Prevented invalid selections causing errors in colour kits and radio sets.
    • Safer handling when no option is selected.

Walkthrough

By the Omnissiah: gear-slot indexing moved to 0-based, several UI initialisers scoped to the obj_creation instance, RadioSet/ToggleButton draw/selection behaviour and ToggleButton.draw signature changed, draw-return context wrappers added, colour-role selection hardened, and role setup converted to widget-driven UI with new globals.

Changes

Cohort / File(s) Summary
Creation flow & context
objects/obj_creation_popup/Draw_0.gml, scripts/scr_creation/scr_creation.gml
Scoped calls into with (obj_creation) { ... }. Converted gear slot mappings from 1–5 → 0–4 across both selection flows and updated guarding conditionals to 0-based. Repositioned advanced_helmet_livery. Added role_setup_objects() call when moving CHAPTERLIVERY→CHAPTERROLES.
UI widgets (RadioSet / ToggleButton)
scripts/scr_buttons/scr_buttons.gml
Guarded RadioSet title draw with length check; track selection changes during draw; selection_val returns noone on -1. ToggleButton.draw signature changed to draw(is_active); added clicked_check_defualt; adjusted “box” sizing, label/icon positions and optional in-draw click handling.
Role setup overhaul
scripts/scr_role_setup/scr_role_setup.gml
Added role_setup_objects() creating specialist_distribution_box, load_to_ship_radio, distribute_scouts_box, distribute_vets_box and initialised selection. Refactored scr_role_setup to use add/pop draw-return, draw header, and read/write role-related globals via the new widgets (replacing manual per-role drawing).
Livery / Colour systems hardening
scripts/scr_livery_setup/scr_livery_setup.gml, scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml
Wrapped livery draw sequence with add_draw_return_values()/pop_draw_return_values(). In ColourItem.swap_role_set, clamp sentinel values (noone → 0, -1 → 1) before indexing _full_livs/_comp_livs to avoid invalid indexing.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

PR: Fix, PR: Refactor

Suggested reviewers

  • Blogaugis
  • EttyKitty

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.

@OH296 OH296 changed the title fix: fix various issues from new creation screen works fix: various issues from new creation screen works Aug 17, 2025
@github-actions github-actions bot added the Type: Fix This is a fix for a bug label Aug 17, 2025
@OH296
Copy link
Copy Markdown
Collaborator Author

OH296 commented Aug 17, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 9

🔭 Outside diff range comments (1)
scripts/scr_buttons/scr_buttons.gml (1)

530-538: Title layout gate uses draw_title (bool) instead of title (string).

string_length(draw_title) is nonsensical and will not behave as intended. Use title.

Apply this diff:

-        if (max_width > 0 && string_length(draw_title) < max_width){
+        if (max_width > 0 && string_length(title) < max_width){
             if (draw_title){
-                draw_text(x1+(max_width/2) - (string_length(draw_title)/2), y1, title);
+                draw_text(x1 + (max_width/2) - (string_length(title)/2), y1, title);
             }
         } else {
             if (draw_title){
-                draw_text(x1 + (string_length(draw_title)/2), y1, title);
+                draw_text(x1 + (string_length(title)/2), y1, title);
             }           
         }
📜 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 ff0440e and ec557fe.

📒 Files selected for processing (6)
  • objects/obj_creation_popup/Draw_0.gml (4 hunks)
  • scripts/scr_buttons/scr_buttons.gml (7 hunks)
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml (2 hunks)
  • scripts/scr_creation/scr_creation.gml (2 hunks)
  • scripts/scr_livery_setup/scr_livery_setup.gml (2 hunks)
  • scripts/scr_role_setup/scr_role_setup.gml (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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:

  • scripts/scr_livery_setup/scr_livery_setup.gml
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml
  • scripts/scr_creation/scr_creation.gml
  • objects/obj_creation_popup/Draw_0.gml
  • scripts/scr_buttons/scr_buttons.gml
  • scripts/scr_role_setup/scr_role_setup.gml
**/*.*

⚙️ CodeRabbit Configuration File

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

Files:

  • scripts/scr_livery_setup/scr_livery_setup.gml
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml
  • scripts/scr_creation/scr_creation.gml
  • objects/obj_creation_popup/Draw_0.gml
  • scripts/scr_buttons/scr_buttons.gml
  • scripts/scr_role_setup/scr_role_setup.gml
🔇 Additional comments (15)
objects/obj_creation_popup/Draw_0.gml (2)

61-63: Scoped call to set_complex_livery_buttons() is correct.

Executing within obj_creation avoids accidental scope bleed. Approved.


193-195: Refreshing roles UI within obj_creation is appropriate.

This ensures RadioSet is rebuilt against the correct instance state after persisting custom role. Sanctioned.

scripts/scr_buttons/scr_buttons.gml (4)

551-553: Explicitly driving ToggleButton active state is good.

Assigning active based on current_selection clarifies state derivation and prevents stale toggles. Blessed.


577-580: Safe selection_val when nothing is selected.

Returning noone on current_selection == -1 prevents invalid array access. Machine-spirits appeased.


616-618: Box button sizing update looks sensible.

Using full string_width and a fixed icon height produces more predictable hitboxes. Approved.


642-699: Verify draw(is_active = active) Calls for Button Objects

The extension of the draw(is_active = active) API is sound, but we must be sure we only pass the boolean state to button-type objects (those created via scripts/scr_buttons/scr_buttons.gml) rather than positional parameters.

Bullet‐point action items:

  • Only calls of the form
    myButton.draw(true / false)
    should target buttons from scripts/scr_buttons/scr_buttons.gml.
  • All other .draw(x, y, …) usages are Slate, Panel, Sprite, DataSlate, etc., and must keep their original signatures.
  • Please audit each .draw( site on your button structs (e.g. tab_buttons.*, specialist_distribution_box, distribute_scouts_box, transfer_button, etc.) to confirm they now only pass a boolean and not coordinates or labels.

Example locations to review:

  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml around lines 405–418
  • scripts/scr_ui_manage/scr_ui_manage.gml lines 164–168, 185–189, 203–207, 215–217, 272–276, 1079–1227 (multiple)
  • scripts/scr_transfer_marines/scr_transfer_marines.gml:17
  • scripts/scr_trade/scr_trade.gml:508
  • scripts/scr_role_setup/scr_role_setup.gml:85–87, 98–103
  • scripts/scr_reequip_units/scr_reequip_units.gml:377–379, 700–702
  • scripts/scr_manage_tags/scr_manage_tags.gml:156–158, 201–203, 242–246
  • and so on for every .draw( that references a *_box, *_button, or tab_buttons.*

No code snippet changes are required here—just verify and correct any mis-scoped .draw calls so that only true button objects receive the single-boolean argument.

scripts/scr_livery_setup/scr_livery_setup.gml (2)

4-4: Draw state capture added.

Capturing draw state up-front aligns with the new draw-return pattern elsewhere. Approved.


226-226: Draw state restore at end.

pop_draw_return_values at the tail maintains render determinism. Ensure no early returns bypass it (none observed). Confirmed.

scripts/scr_creation/scr_creation.gml (2)

248-249: Position adjustment of advanced_helmet_livery.

UI shift to x1: 477, y1: 515 is benign and matches bulk_armour_pattern positioning. Approved.


321-321: Affirmed: role_setup_objects symbol present
The function is declared at scripts/scr_role_setup/scr_role_setup.gml:1 with zero arity. No missing symbols detected—proceed unhindered by the Omnissiah.

scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml (2)

29-31: Guarding role_set against noone is sane.

Mapping no selection to 0 for full_liveries averts sentinel indexing faults. Approved.


38-41: Harden role_set indexing with clamping
Replace the manual –1 check in scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml (lines 38–41):

-                if (role_set == -1){
-                    role_set = 1;
-                }
+                // clamp role_set to [1 … last valid index]
+                role_set = clamp(role_set, 1, max(1, array_length(_comp_livs) - 1));

• Location: scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml:38–41
• Verify that _comp_livs is initialised with length ≥ 2 so that array_length(_comp_livs) – 1 ≥ 1.

Optional: apply the same clamp pattern to any full_liveries index usages if that array can vary.

scripts/scr_role_setup/scr_role_setup.gml (3)

58-64: Draw context management is correctly paired

add_draw_return_values() is symmetrically closed with pop_draw_return_values(). No leaks of draw-state blessings detected.

Also applies to: 268-268


69-69: roles_radio initialization is guaranteed before use
By the Omnissiah, the artefact is rightly consecrated prior to invocation—no null instance will manifest.

  • In scripts/scr_creation/scr_creation.gml (line 65), roles_radio is constructed via new RadioSet(...).
  • The creation routine then calls role_setup_objects() (line 320) before any draw‐event script runs.

The update/draw in scr_role_setup.gml therefore always has a valid roles_radio to work with. Original concern may be ignored.

Likely an incorrect or invalid review comment.


14-34: Fix tooltip newline escape; RadioSet API confirmed

Replaced the incorrect “/n” with “\n” in the first option’s tooltip (and lowercased “start”), and verified that current_selection is indeed the correct RadioSet property.

--- a/scripts/scr_role_setup/scr_role_setup.gml
+++ b/scripts/scr_role_setup/scr_role_setup.gml
@@ -17,7 +17,7 @@
         str1 : "On Planet",
         font : fnt_40k_12,
         style : "box",
-        tooltip : $"On Planet/nCheck to have your Astartes Start on your home planet.",
+        tooltip : $"On Planet\nCheck to have your Astartes start on your home planet.",
     },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Medium Type: Fix This is a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant