Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide robots for two seconds #802

Merged
merged 7 commits into from
Oct 31, 2022
Merged

Hide robots for two seconds #802

merged 7 commits into from
Oct 31, 2022

Conversation

xsebek
Copy link
Member

@xsebek xsebek commented Oct 29, 2022

restyled-io bot and others added 2 commits October 29, 2022 22:12
Co-authored-by: Restyled.io <commits@restyled.io>
Otherwise they aren't hidden until the next time the world gets redrawn.
Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

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

Looks good to me after the small fix I pushed. Take a look and see what you think.

@@ -261,7 +261,8 @@ handleMainEvent ev = do
MetaKey 'h' -> do
t <- liftIO $ getTime Monotonic
uiState . uiHideRobotsUntil .= t + TimeSpec 2 0 -- hide for two seconds
-- pausing and stepping
invalidateCacheEntry WorldCache
Copy link
Member

Choose a reason for hiding this comment

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

@xsebek I wondered why it took up to a second or so for robots to disappear after I hit M-h. Then I figured it out --- we try hard NOT to redraw the world on every event because it is slow. So when the world actually needs to be redrawn we have to signal it explicitly. I fixed it by calling invalidateCacheEntry WorldCache here.

I also realized we should do the same fix for Ctrl-v. Don't know whether you want to just include that fix with this PR or put it in a separate one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting, I originally had code to not change anything for one second.

Might as well include it again if some player decides to hold down the H key. 😅

src/Swarm/TUI/View.hs Show resolved Hide resolved
robots =
if showRobots
then map (view robotDisplay) (robotsAtLocation (W.coordsToLoc coords) g)
else []
Copy link
Member

Choose a reason for hiding this comment

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

Looks much cleaner than my original code, thanks. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

STAN shows me warnings about unsafe functions in HLS and in this case, it got me thinking about refactoring to use the NonEmpty list constructor instead of fromList.

I usually just ignore them (they are not intrusive) but here it worked nicely. 😁

@xsebek xsebek added the merge me Trigger the merge process of the Pull request. label Oct 31, 2022
@mergify mergify bot merged commit 2293f33 into main Oct 31, 2022
@mergify mergify bot deleted the hide-robots branch October 31, 2022 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A way to "peek" under the robots
2 participants