Skip to content

Save and load and bugs#20

Merged
deanblackborough merged 8 commits intomainfrom
save-and-load-and-bugs
Apr 18, 2026
Merged

Save and load and bugs#20
deanblackborough merged 8 commits intomainfrom
save-and-load-and-bugs

Conversation

@deanblackborough
Copy link
Copy Markdown
Owner

@deanblackborough deanblackborough commented Apr 18, 2026

  • Fix viewport size.
  • Show viewport size in the stats panel

Summary by CodeRabbit

  • New Features

    • Window resizing fully supported: viewport updates immediately when window size changes.
    • Stats panel shows live viewport Width and Height.
    • Outliner spawn-placement finds free space and respects grid snapping.
  • Improvements

    • Window creation respects resizable/fullscreen settings and refreshes size on startup.
    • Scene exposes viewport sizing so tools can query current dimensions.
    • Outliner and Inspector use persistent input buffers for smoother search and renaming.

@deanblackborough deanblackborough self-assigned this Apr 18, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

App::handle_event now switches on SDL window sub-events: it handles SDL_WINDOWEVENT_CLOSE by stopping the main loop and SDL_WINDOWEVENT_SIZE_CHANGED by calling Window::refresh_size() and, if a scene exists, updating the scene viewport via SandboxScene::set_viewport_size(width, height). Window creation now composes SDL window flags from config (resizable/fullscreen), calls refresh_size() after creating the renderer, and refresh_size() prefers renderer output size then falls back to SDL_GetWindowSize. SandboxScene exposes viewport setters/getters. Tooling changes propagate viewport and grid state through Outliner, Inspector and Stats; Outliner gained spawn-placement helpers and persistent search state; Inspector gained a persistent rename buffer and grid-aware clone offset.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Camera and world space #17 — Overlaps with tooling/UI and viewport propagation into Stats and Outliner call sites.
  • Imgui panel #2 — Touches App event handling and SDL window event processing similar to App::handle_event changes.
  • Minor tweaks #1 — Modifies SandboxScene and window/viewport-related logic that likely interacts with the new viewport API.
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic—'Save and load and bugs' uses non-descriptive language that doesn't convey meaningful information about the actual changeset, which focuses on viewport sizing and display. Consider a more specific title like 'Fix viewport sizing and display in stats panel' that clearly reflects the primary changes in the PR.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch save-and-load-and-bugs

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label Apr 18, 2026
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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5f355668-b509-417a-b132-0d56e85a5d84

📥 Commits

Reviewing files that changed from the base of the PR and between 03e2bb4 and 735c021.

📒 Files selected for processing (8)
  • src/prune/app/app.cpp
  • src/prune/core/window.cpp
  • src/prune/core/window.hpp
  • src/prune/scene/sandbox_scene.cpp
  • src/prune/scene/sandbox_scene.hpp
  • src/prune/tooling/stats.cpp
  • src/prune/tooling/stats.hpp
  • src/prune/tooling/ui.cpp

Comment thread src/prune/core/window.cpp
Comment thread src/prune/tooling/stats.cpp
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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 062b6ecf-91ad-4c48-935d-897c6eb0f052

📥 Commits

Reviewing files that changed from the base of the PR and between 735c021 and e0203b4.

📒 Files selected for processing (2)
  • src/prune/core/window.cpp
  • src/prune/tooling/stats.cpp

Comment thread src/prune/tooling/stats.cpp
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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 736055d9-57de-4176-9ffb-0b0f0ccd08a0

📥 Commits

Reviewing files that changed from the base of the PR and between bc4b94e and abdbd22.

📒 Files selected for processing (2)
  • src/prune/tooling/inspector.cpp
  • src/prune/tooling/inspector.hpp

Comment on lines +53 to +59
selected->name = objects.make_unique_name(m_rename_buffer.data(), selected->id);
std::snprintf(
m_rename_buffer.data(),
m_rename_buffer.size(),
"%s",
selected->name.c_str()
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Prevent silent name truncation before persisting edits.

Line [223] copies into a fixed 128-byte buffer, and Line [53] persists from that buffer. Since names are unbounded strings, long names can be truncated and then saved back as shortened values.

Suggested fix direction (dynamic buffer)
- std::array<char, 128> m_rename_buffer{};
+ std::vector<char> m_rename_buffer = std::vector<char>(128, '\0');
 void Inspector::sync_rename_buffer(const GameObject* selected)
 {
     if (!selected) {
         m_rename_target_id.reset();
-        m_rename_buffer[0] = '\0';
+        if (!m_rename_buffer.empty()) {
+            m_rename_buffer[0] = '\0';
+        }
         return;
     }

     if (m_rename_target_id.has_value() && m_rename_target_id.value() == selected->id) {
         return;
     }

     m_rename_target_id = selected->id;
+    const std::size_t required = selected->name.size() + 64;
+    if (m_rename_buffer.size() < required) {
+        m_rename_buffer.resize(required, '\0');
+    }
     std::snprintf(m_rename_buffer.data(), m_rename_buffer.size(), "%s", selected->name.c_str());
 }
 if (ImGui::IsItemDeactivatedAfterEdit()) {
     selected->name = objects.make_unique_name(m_rename_buffer.data(), selected->id);
+    const std::size_t required = selected->name.size() + 64;
+    if (m_rename_buffer.size() < required) {
+        m_rename_buffer.resize(required, '\0');
+    }
     std::snprintf(
         m_rename_buffer.data(),
         m_rename_buffer.size(),
         "%s",
         selected->name.c_str()
     );
 }

Also applies to: 210-224

coderabbitai[bot]
coderabbitai Bot previously requested changes Apr 18, 2026
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: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a5a89249-8583-4f4c-ac7a-94ef9e67f31e

📥 Commits

Reviewing files that changed from the base of the PR and between abdbd22 and edd7768.

📒 Files selected for processing (5)
  • src/prune/tooling/inspector.cpp
  • src/prune/tooling/inspector.hpp
  • src/prune/tooling/outliner.cpp
  • src/prune/tooling/outliner.hpp
  • src/prune/tooling/ui.cpp

Comment on lines +35 to +36
std::optional<GameObjectId> m_rename_target_id;
std::array<char, 128> m_rename_buffer{};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Inconsistent indentation detected.

Look at line 36 closely—there's a tab character sneaking in there among your spaces. In game engines, consistent formatting isn't just pedantry; it prevents merge conflicts and keeps diffs clean when multiple people are touching the same files.

♻️ Suggested fix
         std::optional<GameObjectId> m_rename_target_id;
-		std::array<char, 128> m_rename_buffer{};
+        std::array<char, 128> m_rename_buffer{};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
std::optional<GameObjectId> m_rename_target_id;
std::array<char, 128> m_rename_buffer{};
std::optional<GameObjectId> m_rename_target_id;
std::array<char, 128> m_rename_buffer{};

Comment thread src/prune/tooling/outliner.cpp
Comment on lines +13 to +21
void draw(
GameObjectManager& objects,
float camera_x,
float camera_y,
int viewport_width,
int viewport_height,
bool snap_to_grid,
int grid_size
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider consolidating parameters in future.

Seven parameters on draw() is starting to push the limits of cognitive load. In game engine code, when you see this pattern, it's often a signal that a "context" or "config" struct might be warranted. Something like OutlinerDrawContext holding viewport, camera, and grid info.

Not blocking—this works fine for now. Just file it away as technical debt for when this inevitably grows.

int width,
int height
) const;
bool contains_case_insensitive(std::string_view text, std::string_view query) const;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Add [[nodiscard]] for consistency.

Static analysis correctly points out that contains_case_insensitive should be marked [[nodiscard]] too. It's a pure predicate—discarding its result makes no sense.

♻️ Suggested fix
-        bool contains_case_insensitive(std::string_view text, std::string_view query) const;
+        [[nodiscard]] bool contains_case_insensitive(std::string_view text, std::string_view query) const;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bool contains_case_insensitive(std::string_view text, std::string_view query) const;
[[nodiscard]] bool contains_case_insensitive(std::string_view text, std::string_view query) const;
🧰 Tools
🪛 Clang (14.0.6)

[warning] 50-50: function 'contains_case_insensitive' should be marked [[nodiscard]]

(modernize-use-nodiscard)


[warning] 50-50: use a trailing return type for this function

(modernize-use-trailing-return-type)

Comment thread src/prune/tooling/ui.cpp
}

} // namespace prune No newline at end of file
} No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Missing newline at end of file.

Most style guides and version control systems prefer a trailing newline at EOF. It's a Unix convention that prevents "no newline at end of file" warnings in diffs. Trivial fix, but good habit to build.

@deanblackborough deanblackborough merged commit b26e470 into main Apr 18, 2026
2 checks passed
@deanblackborough deanblackborough deleted the save-and-load-and-bugs branch April 18, 2026 18:58
This was referenced Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant