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

feat: togglable message log window size #2511

Merged
merged 22 commits into from
Apr 9, 2023

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Mar 31, 2023

Summary

SUMMARY: Interface "Toggleable message log window size"

Purpose of change

Describe the solution

now width and height of message log can be toggled via w and h respectively.

Core logic

Such things aren't standardised, we don't have a UI library for that.
You'll want to call .mark_resize() on the ui_adaptor for that window, and in on_screen_resize callback, choose the size based on a boolean.

logic help from @olanti-p.

flowchart:

  1. in input, toggle_wide_display() is triggered.
  2. ui is marked to be resized. it triggers init().
  3. new window is drawn using init(). new size is selected when set_size() is triggered.

Describe alternatives you've considered

pain

Testing

image

output

tried restarting game after changing display size. it was persistent.
also, as olanti requested, key help correctly works.

@github-actions github-actions bot added the src changes related to source code. label Mar 31, 2023
@scarf005 scarf005 changed the title Expand message log window to full height Enlarge message log window Mar 31, 2023
@scarf005
Copy link
Member Author

As to the log window - would it be possible to make it toggleable?
As in, with a hotkey - expand/collapse, not game option

keeping it draft for a while until adding toggleable hotkey @olanti-p requested.

@scarf005 scarf005 marked this pull request as draft March 31, 2023 14:36
@scarf005 scarf005 marked this pull request as ready for review March 31, 2023 23:20
@scarf005
Copy link
Member Author

spent 3 hours and inputs.h is a pain, i guess toggleable panel could be done in another PR

@olanti-p
Copy link
Contributor

Why would you be looking in input.h?

The message window lives entirely in messages.cpp, and already defines a bunch of hotkeys. You just have to find the place where it creates its own local input_context, see how it defines and then queries actions, and replicate that for your new key.
JSON side of hotkeys lives in data/raw/, you can grep for any message window's action id and input_context category to see which exact hotkeys correspond to defined actions, and add a new one.

@scarf005
Copy link
Member Author

...oh wait it was Messages::dialog::input

@github-actions github-actions bot added the JSON related to game datas in JSON format. label Apr 1, 2023
@scarf005 scarf005 marked this pull request as draft April 1, 2023 00:37
@scarf005
Copy link
Member Author

scarf005 commented Apr 3, 2023

@olanti-p, i'm having difficulty toggling then refreshing the window. could you check b00b5c0? it contains my (failed) attempt to refresh the messages screen.

@scarf005 scarf005 force-pushed the panel-height branch 2 times, most recently from 6e0ef28 to 86b574a Compare April 4, 2023 10:29
@scarf005 scarf005 marked this pull request as ready for review April 4, 2023 10:29
@scarf005
Copy link
Member Author

scarf005 commented Apr 4, 2023

...wait again, nevermind. had a nap and fixed it.

src/input.cpp Outdated Show resolved Hide resolved
src/messages.cpp Outdated Show resolved Hide resolved
src/messages.cpp Outdated Show resolved Hide resolved
@olanti-p
Copy link
Contributor

olanti-p commented Apr 4, 2023

When I wrote

would it be possible to make it toggleable?

I was referring to the window height, and to make it expandable, not expanded-by-default. On the screenshot, it's very hard to make out the text or follow what time the messages refer to because of the enormous height.
It's actually tolerable on the more common 1920x1080, so that's a matter of taste I guess.

@scarf005
Copy link
Member Author

scarf005 commented Apr 4, 2023

I was referring to the window height, and to make it expandable, not expanded-by-default.

...oh, i thought you meant about the width. could you clarify how should i change the behavior?

  1. expandable width and height.
  2. expandable height only.

nevermind, i'm adding both

@scarf005 scarf005 requested a review from olanti-p April 4, 2023 16:05
@scarf005 scarf005 changed the title Enlarge message log window Togglable message log window size Apr 4, 2023
@scarf005
Copy link
Member Author

scarf005 commented Apr 4, 2023

@olanti-p ready to review. now message logs are default collapsed down per your request, and their width and height can be both widened via w and h shortcut. the preferences are persistent during the game.

Copy link
Contributor

@olanti-p olanti-p left a comment

Choose a reason for hiding this comment

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

Works nicely. Could you also add a hint for users somewhere?

You could extend the existing hint in Messages::dialog::show() e.g. from

_( "< Press %s to filter, %s to reset >" )

to

_( "< Press %s to filter, %s to reset, %s or %s to adjust size >" )

data/raw/keybindings/messages.json Outdated Show resolved Hide resolved
src/messages.cpp Outdated Show resolved Hide resolved
src/messages.cpp Outdated Show resolved Hide resolved
src/messages.cpp Outdated Show resolved Hide resolved
src/options.cpp Show resolved Hide resolved
@scarf005 scarf005 requested a review from olanti-p April 7, 2023 14:21
@scarf005 scarf005 changed the title Togglable message log window size feat: togglable message log window size Apr 7, 2023
src/uistate.h Outdated Show resolved Hide resolved
Co-authored-by: olanti-p <olanti-p@yandex.ru>
@scarf005 scarf005 merged commit e70c60b into cataclysmbnteam:upload Apr 9, 2023
@scarf005 scarf005 deleted the panel-height branch August 22, 2023 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

heighten message log same to window size
2 participants