feat: make suspend persist on controller edit#659
feat: make suspend persist on controller edit#659utkarshdalal merged 1 commit intoutkarshdalal:masterfrom
Conversation
📝 WalkthroughWalkthroughThis PR introduces a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt (1)
1241-1246: Consider extracting the resume logic into a helper function.This 5-line resume pattern is repeated 5 times throughout the file (lines 1241-1246, 1267-1272, 1377-1382, 1394-1399, 1420-1425). Extracting it into a local function would improve maintainability and reduce the risk of inconsistent updates.
♻️ Suggested refactor
Add a helper function at the beginning of
XServerScreen:// Inside XServerScreen composable, after state declarations fun resumeFromEditor() { keepPausedForEditor = false if (PluviaApp.isOverlayPaused) { PluviaApp.xEnvironment?.onResume() isOverlayPaused = false PluviaApp.isOverlayPaused = false } }Then replace each occurrence with a single call to
resumeFromEditor().🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt` around lines 1241 - 1246, Extract the repeated 5-line resume pattern into a local helper function (e.g., resumeFromEditor) inside the XServerScreen composable: move the logic that sets keepPausedForEditor = false, checks PluviaApp.isOverlayPaused, calls PluviaApp.xEnvironment?.onResume(), and clears isOverlayPaused and PluviaApp.isOverlayPaused into that function, then replace each repeated block with a single call to resumeFromEditor(); ensure the helper is visible to the scope where keepPausedForEditor and isOverlayPaused are defined so the function can update those variables directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt`:
- Around line 1241-1246: Extract the repeated 5-line resume pattern into a local
helper function (e.g., resumeFromEditor) inside the XServerScreen composable:
move the logic that sets keepPausedForEditor = false, checks
PluviaApp.isOverlayPaused, calls PluviaApp.xEnvironment?.onResume(), and clears
isOverlayPaused and PluviaApp.isOverlayPaused into that function, then replace
each repeated block with a single call to resumeFromEditor(); ensure the helper
is visible to the scope where keepPausedForEditor and isOverlayPaused are
defined so the function can update those variables directly.
| var showPhysicalControllerDialog by remember { mutableStateOf(false) } | ||
| var isOverlayPaused by remember { mutableStateOf(false) } | ||
| var keyboardRequestedFromOverlay by remember { mutableStateOf(false) } | ||
| var keepPausedForEditor by remember { mutableStateOf(false) } |
There was a problem hiding this comment.
Small idea, would it not be best to pause the game when we bring up the menu regardless?
Also, do we need a separate bool for this considering we have a paused bool already?
There was a problem hiding this comment.
When osc editor is up, overlay is not which is why in target it's not staying suspended in first place right?
There was a problem hiding this comment.
I suppose so.
Overall think this is a good change, just a question of if there's a nice way to apply it to all the options without much hassle
makes game stay suspended when edit on screen controls view is up, so sockpuppet stops dying.
verified other cases where we do not want suspend to persist do not regress: invoke keyboard (primary or ext screen like thor), show/hide controller states, invoke overlay and dismiss while in already suspended state of edit controller overlay does not resume in undesired way.
Summary by cubic
Keep the game suspended while editing on-screen or physical controller settings so gameplay doesn’t resume unexpectedly. The game resumes only after the editor is closed, saved, or dismissed.
Written for commit 4c1c38d. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes