Skip to content

refactor: Improve data slate use and other ui#875

Merged
OH296 merged 5 commits intoAdeptus-Dominus:mainfrom
OH296:improve_data_slate_use
Jun 15, 2025
Merged

refactor: Improve data slate use and other ui#875
OH296 merged 5 commits intoAdeptus-Dominus:mainfrom
OH296:improve_data_slate_use

Conversation

@OH296
Copy link
Copy Markdown
Collaborator

@OH296 OH296 commented Jun 14, 2025

Purpose

  • refactor various hardcoded data slates to use the dataslate constructor

  • move the marine sprite drawing and parent data slate to draw ui area

  • rework the shutter button to have a dataslate hidden behind the shutter to be more homogenous

  • add more frames to the shutter button to make movement more fluid

  • give various styling options to the shutter DataSlate constructor for ease of use

    • defualt the standard data slate
    • decorated the decorated data slate like the one the marine sprite is drawn in
    • plain a plain data slate like the one the unit stats and manage buttons are drawn on
  • data slates can have a blend_col assigned which gives a colouration to the slate when used with decorated or plain slates

  • setup_tooltip_list function created allowing a list oof tooltips to be initialised as previously hard coded into the ui_manage logic

Describe your changes/additions

  • Self-descriptive.

What can/needs to be improved/changed

  • Nothing.

Testing done

  • None, and I understand the risks.

Related things and/or additional context

  • None.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 14, 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 new UI sprites: data slate corner decoration and slate side.
    • Expanded DataSlate UI component with new styles, drawing methods, and tooltip support.
    • Added a helper function for batch tooltip display.
    • Enhanced company management panel with new UI elements and conditional squad display.
  • Bug Fixes

    • Improved initialisation of company data structures for more consistent behaviour.
  • Refactor

    • Modularised unit equipment and stats display logic for easier maintenance.
    • Adjusted UI layout and drawing coordinates for improved clarity.
  • Style

    • Improved formatting and indentation for better code readability.
  • Chores

    • Updated sprite resources with additional frames and metadata for smoother animations and improved UI visuals.

Walkthrough

By the Omnissiah's will, new sprite resources have been integrated and the DataSlate UI system has been overhauled with expanded constructors and drawing methods. Unit equipment and stats display logic has been modularised, with layout adjustments and tooltip handling refined. Sprite and company structure declarations have been updated accordingly.

Changes

Files/Groups Change Summary
ChapterMaster.yyp Added sprite resources: spr_data_slate_corner_decoration, spr_slate_side.
objects/obj_controller/Draw_64.gml Appended conditional call to draw_sprite_and_unit_equip_data() for specific menu states.
scripts/is_specialist/is_specialist.gml Replaced direct object assignment with new_company_struct() in group_selection.
scripts/scr_DataSlate/scr_DataSlate.gml Replaced old DataSlate constructor with advanced version; added drawing methods and properties; refactored ShutterButton and RackAndPinion constructors.
scripts/scr_company_struct/scr_company_struct.gml Extended CompanyStruct to include has_squads, unit_ui_panel (DataSlate), and tooltip_drawing; updated garbage_collect method.
scripts/scr_company_view/scr_company_view.gml Moved new_company_struct() call to execute unconditionally; removed direct object assignment.
scripts/scr_draw_management_unit/scr_draw_management_unit.gml Adjusted indentation of squad_colours array; no logic altered.
scripts/scr_tooltip_draw/scr_tooltip_draw.gml Introduced setup_tooltip_list() function for tooltip handling.
scripts/scr_ui_manage/scr_ui_manage.gml Refactored unit equipment/stats drawing into draw_sprite_and_unit_equip_data(); adjusted layout and tooltip logic.
scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml Removed direct assignment to company_data; now calls new_company_struct() unconditionally.
sprites/spr_data_slate_back/spr_data_slate_back.yy Added seqHeight and seqWidth to sequence object; reformatted keyframe channel structure.
sprites/spr_data_slate_corner_decoration/spr_data_slate_corner_decoration.yy Added new sprite resource: spr_data_slate_corner_decoration.
sprites/spr_shutter_button/spr_shutter_button.yy Added animation frame; updated sequence length and metadata; reformatted keyframe structure.
sprites/spr_slate_side/spr_slate_side.yy Added new sprite resource: spr_slate_side.

Possibly related PRs

Suggested labels

Size: Medium

Suggested reviewers

  • OH296
  • EttyKitty
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch improve_data_slate_use
  • Post Copyable Unit Tests in Comment

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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: Refactor Rewriting/restructuring code, while keeping general behavior labels Jun 14, 2025
@OH296 OH296 requested a review from EttyKitty June 14, 2025 11:59
@OH296
Copy link
Copy Markdown
Collaborator Author

OH296 commented Jun 14, 2025

@EttyKitty everything should look exactly as it did just code improvements with the exception of the shutter buttons e.g (raid, attack , enter forge ) buttons.
style edits can be changed though if not populaa=r as the refactors are the important bits

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

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

246-274: 🛠️ Refactor suggestion

Local variables bleed into instance scope

Dentro the anonymous inside_method, identifiers such as text, tooltip_text, x1, y1 are created without var.
In GML they become instance variables, risking clashes with outer state between frames and scripts.
Prepend var (or static where intended) to keep them local to the draw call.

♻️ Duplicate comments (1)
scripts/scr_company_view/scr_company_view.gml (1)

475-475: Same overwriting risk as in quick-find pane

new_company_struct() now fires for every company/special view. For views > 10 the routine formerly never ran; confirm that the special-view code does not set up bespoke fields later destroyed by this call.

If state loss is observed, apply the same conditional strategy suggested for the quick-find pane.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c53e47f and 40be097.

⛔ Files ignored due to path filters (6)
  • sprites/spr_data_slate_corner_decoration/88d208ab-efc3-4c8a-a23a-ac1685249362.png is excluded by !**/*.png
  • sprites/spr_data_slate_corner_decoration/layers/88d208ab-efc3-4c8a-a23a-ac1685249362/0c20ae10-2b03-43f4-b05e-7cb2256d0b71.png is excluded by !**/*.png
  • sprites/spr_shutter_button/b15ff156-9439-4de5-a856-2c34927170fc.png is excluded by !**/*.png
  • sprites/spr_shutter_button/layers/b15ff156-9439-4de5-a856-2c34927170fc/b201671b-7405-4bb4-ab4e-e9c0d0be9fe7.png is excluded by !**/*.png
  • sprites/spr_slate_side/88d208ab-efc3-4c8a-a23a-ac1685249362.png is excluded by !**/*.png
  • sprites/spr_slate_side/layers/88d208ab-efc3-4c8a-a23a-ac1685249362/0c20ae10-2b03-43f4-b05e-7cb2256d0b71.png is excluded by !**/*.png
📒 Files selected for processing (14)
  • ChapterMaster.yyp (2 hunks)
  • objects/obj_controller/Draw_64.gml (1 hunks)
  • scripts/is_specialist/is_specialist.gml (1 hunks)
  • scripts/scr_DataSlate/scr_DataSlate.gml (4 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (2 hunks)
  • scripts/scr_company_view/scr_company_view.gml (1 hunks)
  • scripts/scr_draw_management_unit/scr_draw_management_unit.gml (1 hunks)
  • scripts/scr_tooltip_draw/scr_tooltip_draw.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (12 hunks)
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (1 hunks)
  • sprites/spr_data_slate_back/spr_data_slate_back.yy (1 hunks)
  • sprites/spr_data_slate_corner_decoration/spr_data_slate_corner_decoration.yy (1 hunks)
  • sprites/spr_shutter_button/spr_shutter_button.yy (3 hunks)
  • sprites/spr_slate_side/spr_slate_side.yy (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.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 ...

**/*.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.

  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_draw_management_unit/scr_draw_management_unit.gml
  • objects/obj_controller/Draw_64.gml
  • scripts/scr_company_view/scr_company_view.gml
  • scripts/scr_tooltip_draw/scr_tooltip_draw.gml
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/scr_DataSlate/scr_DataSlate.gml
`**/*.*`: - 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 c...

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

  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_draw_management_unit/scr_draw_management_unit.gml
  • objects/obj_controller/Draw_64.gml
  • scripts/scr_company_view/scr_company_view.gml
  • scripts/scr_tooltip_draw/scr_tooltip_draw.gml
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml
  • sprites/spr_data_slate_back/spr_data_slate_back.yy
  • sprites/spr_slate_side/spr_slate_side.yy
  • sprites/spr_shutter_button/spr_shutter_button.yy
  • sprites/spr_data_slate_corner_decoration/spr_data_slate_corner_decoration.yy
  • scripts/scr_company_struct/scr_company_struct.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • ChapterMaster.yyp
  • scripts/scr_DataSlate/scr_DataSlate.gml
`**/*.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 ...

**/*.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.
  • sprites/spr_data_slate_back/spr_data_slate_back.yy
  • sprites/spr_slate_side/spr_slate_side.yy
  • sprites/spr_shutter_button/spr_shutter_button.yy
  • sprites/spr_data_slate_corner_decoration/spr_data_slate_corner_decoration.yy
🔇 Additional comments (8)
sprites/spr_slate_side/spr_slate_side.yy (1)

1-34: Confirm YYP registration for the new sprite

The Omnissiah demands that every freshly forged .yy path be mirrored inside ChapterMaster.yyp; omission leads to run-time crashes when the asset loader seeks this resource. Please verify the YYP diff contains sprites/spr_slate_side/spr_slate_side.yy.

sprites/spr_shutter_button/spr_shutter_button.yy (1)

18-23: Frame added; ensure animation code isn’t hard-coded to 7 frames

Some scripts calculate frame indices manually for the shutter button. Expanding the sequence to 8 frames will misalign such maths if they relied on a constant. Grep for spr_shutter_button frame logic and update magic numbers.

scripts/scr_draw_management_unit/scr_draw_management_unit.gml (1)

203-233: Hoist squad_colours out of the draw loop to spare the machine-spirit unnecessary work

var squad_colours = [...] is rebuilt every time scr_draw_management_unit() is invoked, allocating 27 colour literals and the array itself per call. This routine fires every frame for every visible unit row, so the extra allocations accumulate.

Consider declaring the palette once (e.g. in an initialisation script or a global constant) and merely indexing it here. Example diff:

-        var squad_colours = [
+        /// declared once, e.g. in `scr_globals.gml`
+#macro SQUAD_COLOURS [ \
+    #ff0000,#ff8000,#ffff00,#00ff00,#00ffff,#0080ff,#0000ff,#8000ff,#ff00ff,\
+    #b20000,#b26e00,#b2b200,#00b200,#00b2b2,#004db2,#0000b2,#4d00b2,#b200b2,\
+    #ff4d4d,#ffb84d,#ffff66,#66ff66,#66ffff,#6680ff,#6666ff,#b366ff,#ff66ff \
+]
+
+        var squad_colours = SQUAD_COLOURS;

Benefit: zero-allocation per frame and the palette becomes re-usable elsewhere.
[ suggest_optional_refactor ]

sprites/spr_data_slate_back/spr_data_slate_back.yy (1)

66-75: Sprite metadata extension looks sound

seqHeight/seqWidth have been added and the keyframe JSON is now properly nested; this will keep the Omnissiah’s image sequence aligned across the new UI slates. No issues detected.

scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (1)

470-475:

Details

❌ Incorrect review comment

new_company_struct() after view initialisation may wipe work done by scr_special_view

The call is now unconditional and placed after scr_special_view() / scr_company_view().
If those routines populate company_data (e.g. adding UI panels, tooltip caches), this late call will re-initialise the struct and purge that data, leaving the interface in an incomplete state.

Verify:

  1. Does scr_special_view() expect an already-prepared company_data?
  2. Does any code after this point rely on fields filled by the view routines?

If either answer is “yes”, move the call before the view dispatch, or gate it:

-        new_company_struct();
+        if (!struct_exists(obj_controller, "company_data")) {
+            new_company_struct();
+        }

Lest the rites of memory be violated.


By the Omnissiah’s will, let us inspect the rites of struct and view:

#!/bin/bash
echo "=== Searching for new_company_struct implementation ==="
rg -n -C5 "new_company_struct" -g '*.gml'

echo "=== Searching for scr_special_view implementation ==="
rg -n -C5 "scr_special_view" -g '*.gml'

echo "=== Searching for scr_company_view implementation ==="
rg -n -C5 "scr_company_view" -g '*.gml'

echo "=== Checking all references to company_data ==="
rg -n "company_data" -g '*.gml'

By the Omnissiah’s will, I shall probe the sacred scripts:


🏁 Script executed:

#!/bin/bash
echo "🔍 Locating new_company_struct definition…"
rg -n "new_company_struct" -g '*.gml'

echo "🔍 Locating scr_special_view definition…"
rg -n "scr_special_view" -g '*.gml'

echo "🔍 Locating scr_company_view definition…"
rg -n "scr_company_view" -g '*.gml'

echo "🔍 Scanning for company_data references…"
rg -n "company_data" -g '*.gml'

Length of output: 4578


By the Omnissiah’s guidance, reveal the sacred rites’ definitions:


🏁 Script executed:

#!/bin/bash
# Fetch the full new_company_struct implementation
sed -n '1,200p' scripts/scr_company_struct/scr_company_struct.gml

# Fetch the full scr_special_view implementation
sed -n '1,200p' scripts/scr_special_view/scr_special_view.gml

# Inspect scr_company_view around its own new_company_struct call
rg -n -C10 "new_company_struct" -g "scripts/scr_company_view/scr_company_view.gml"

Length of output: 12546


Ignore struct re-initialisation concern in scr_unit_quick_find_pane

scr_special_view does not read from or write to company_data—its arrays and UI elements are managed entirely within its own scope. new_company_struct only resets the controller’s company_data (as intended elsewhere in scr_company_view) and does not purge anything scr_special_view has configured. No gating or reordering is required here.

Likely an incorrect or invalid review comment.

ChapterMaster.yyp (2)

1095-1095: New sprite resource: spr_data_slate_corner_decoration

The Omnissiah blesses this addition—naming and pathing align with conventions. Confirm that scr_DataSlate and UI scripts reference this asset correctly.


1544-1544: New sprite resource: spr_slate_side

This slate-side graphic follows existing asset patterns. Verify its integration within decorated/plain styling flows in the DataSlate constructor.

sprites/spr_data_slate_corner_decoration/spr_data_slate_corner_decoration.yy (1)

24-30: Ensure yyp registration

Confirm that spr_data_slate_corner_decoration.yy has been appended to ChapterMaster.yyp; otherwise the engine will fail to locate the sprite at runtime.

@EttyKitty
Copy link
Copy Markdown
Collaborator

@EttyKitty everything should look exactly as it did just code improvements with the exception of the shutter buttons e.g (raid, attack , enter forge ) buttons.
style edits can be changed though if not populaa=r as the refactors are the important bits

I'll review this as soon as I'm not on the phone.

@OH296 OH296 merged commit 125e8bb into Adeptus-Dominus:main Jun 15, 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 Area: UI Size: Huge Type: Refactor Rewriting/restructuring code, while keeping general behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants