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

Debugconsole and input history improvements #5944

Merged
merged 46 commits into from Aug 26, 2023

Conversation

tothxa
Copy link
Member

@tothxa tothxa commented Jun 18, 2023

Type of change
New feature / Refactoring

Issue(s) closed
Fixes #5793
Fixes #1668
Fixes #2066

New behavior

  • Save history to file
  • Also adds new command line option to allow enabling the developer features in release builds. More extensive reporting of usage of these features in network games.
  • Pass textinput to the input field when any part of the chat or script console window is focused and switch focus to input field on textinput

Possible regressions
EditBox and chat/script console behaviour and history handling

Additional context
Postponed:

  • UI file selection for dofile()
  • autosave for history? when?

Scrapped:

  • Configurable history size

@tothxa tothxa added enhancement New feature or request cleanup & refactoring Improving our code quality lua Lua scripts and scripting interface chat Multiplayer chat system labels Jun 18, 2023
@tothxa tothxa self-assigned this Jun 18, 2023
@Noordfrees
Copy link
Member

Code LGTM, tested and working.
However before we can merge this we need to check that all advantages conferred upon players who use this are communicated to others in network games. Opening a field/object debug window and using the chat console's builtin functions (switchplayer and mapobject) needs a system chat message like we have for running Lua commands and entering cheat mode. There may be others as well, we'll need to check this carefully now that just checking for "release" as part of the version string is no longer a reliable indicator that cheats are disabled.

@tothxa
Copy link
Member Author

tothxa commented Jun 18, 2023

However before we can merge this we need to check that all advantages conferred upon players who use this are communicated to others in network games.

Yes, of course, that was my intention too.

@tothxa
Copy link
Member Author

tothxa commented Jun 18, 2023

@Noordfrees Regarding #1668, IMO this PR already does what's reasonable. Any more separation would require jumping through hoops back and forth between EditBox and GameChatPanel. Do you agree we can close #1668 with this PR without any further changes?

@Noordfrees Noordfrees added this to the v1.2 milestone Jun 18, 2023
@tothxa
Copy link
Member Author

tothxa commented Aug 11, 2023

I believe the last commit solves the remaining part of #2066.

@tothxa tothxa marked this pull request as ready for review August 11, 2023 09:03
@tothxa
Copy link
Member Author

tothxa commented Aug 11, 2023

OK, this is big enough now, and the important parts are in place. No more new features for this PR.

@tothxa tothxa changed the title Debugconsole history improvements Debugconsole and input history improvements Aug 11, 2023
@tothxa tothxa requested a review from Noordfrees August 15, 2023 20:49
Copy link
Member

@Noordfrees Noordfrees left a comment

Choose a reason for hiding this comment

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

Tested this again. I was a bit surprised that saving the script console history to file had to be explicitly enabled, IMO we could remove the option and do that always.

I also don't see the value of letting the user configure the history size, why not just hardcode this with a size of 64 of both (or even more, maybe 256, this shouldn't take up that much memory?).

Other than that, working well, great feature :) Code LGTM, one nit.

src/ui_basic/textinput.cc Outdated Show resolved Hide resolved
@tothxa
Copy link
Member Author

tothxa commented Aug 16, 2023

Tested this again. I was a bit surprised that saving the script console history to file had to be explicitly enabled, IMO we could remove the option and do that always.

OK, though I was afraid that it might be a privacy issue for some, like the chat history.

I also don't see the value of letting the user configure the history size, why not just hardcode this with a size of 64 of both (or even more, maybe 256, this shouldn't take up that much memory?).

OK. Then I'll revert it to 64. If somebody needs more, then they should probably create helper scripts that they can use with do_file().

@tothxa
Copy link
Member Author

tothxa commented Aug 16, 2023

(sorry for the incomplete pushes)

There's one more thing I'm thinking about: should the histories be saved regularly to keep more of them on crashes? (the script console in particular is supposed to be used in conditions where crashes are more likely)

One obvious place for saving would be after each autosave, but it would bring in a new dependency on a file from wui for save_handler.cc, while there's already a TODO comment in CMakeLists to eliminate even the existing one. Also maybe on exiting the editor or a game, but that's usually too late WRT crashes.

Or I could keep a counter of new entries, and save e.g. on every 10th, but that's probably too much overhead.

@frankystone
Copy link
Contributor

Mostly i get Lua errors and no complete crashes when working with the lua console. So i am not sure if a regular file save is needed.

@tothxa tothxa requested a review from Noordfrees August 26, 2023 13:26
Copy link
Member

@Noordfrees Noordfrees left a comment

Choose a reason for hiding this comment

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

Thanks :)

@Noordfrees Noordfrees merged commit 9bb7f4f into widelands:master Aug 26, 2023
33 checks passed
@tothxa tothxa deleted the debugconsole-history branch August 26, 2023 14:34
@tothxa
Copy link
Member Author

tothxa commented Aug 26, 2023

Thanks for the reviews. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat Multiplayer chat system cleanup & refactoring Improving our code quality enhancement New feature or request lua Lua scripts and scripting interface
Projects
None yet
3 participants