-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add game information report and SDL screenshot (#2) #30313
Conversation
- check for nullptr - check for no loaded mods - Idiomatic c++
- Check if the SDL copy to clipboard function error-ed or not. - Manual astyle...
- Remove check on world validity. The world is already playing at this point.
- Name it take_screenshot() in game.[h; cpp]. - This is the only location where we can access the SDL renderer (except catatiles.cpp but it's really more meaningful in sdltiles.cpp).
- Reorder menu.
Integrated all suggestions from #30244. I think it's ready for review now. |
Side note: for an unknown reason both Astyle 3.1 and 3.0.1 (windows binaries) fail to format the very end of the |
- Remove unused header.
- It is fine to have it outside since it returns false if SDL/TILES are not used.
- Otherwise the code in game.cpp can't find it. - It returns false if TILES is not defined - Remove obsolete function comment.
- As sdltiles is the only file where the renderer can be accessed, but obviously is only usable when TILES is defined, you can only use save_screenshot() if SDL is defined. - Make it so that game::take_screenshot() returns false if TILES is not defined.
…s... - Make a global context capture.
It compiles :) there's an error on a test but this PR didn't touch any core game components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good.
src/debug.cpp
Outdated
return string_format( "%s [%s]", mod->name(), mod->ident.str() ); | ||
} ); | ||
|
||
auto result = join( mod_names, ",\n " ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point in the trailing blanks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 spaces before the mod name:
- Mods loaded: [
Dark Days Ahead [dda],
Disable NPC Needs [no_npc_food],
Filthy Clothing [filthy_morale],
...
]
It acts like a tabulation but I never liked \t
because it looks different depending on the font you use, unless it is a fixed font... A pet peeve of mine.
I prefer to have the mod names with a slight offset, it looks better in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor style fixups required for consistency with the rest of the code.
Co-Authored-By: ZhilkinSerg <[email protected]>
Co-Authored-By: ZhilkinSerg <[email protected]>
Co-Authored-By: ZhilkinSerg <[email protected]>
Co-Authored-By: ZhilkinSerg <[email protected]>
Thank you for your review! |
// Get the key for an action, used in the action menu to give each action the | ||
// hotkey it is bound to. | ||
// We ignore bindings to '?' because that will already do something else in | ||
// this menu (open the menu keybindings). | ||
long hotkey_for_action( action_id action ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't return values properly for function keys, e.g. if debug action is set for F10, hotkey_for_action
would return -1, thus rendering debug menu unavailable (tested on Windows with VS and MSYS).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep you're right, I can confirm this behavior, functions keys are not understood by keys_bound_to
. Hmmm I don't know exactly what should be the next step here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the check that returns the bound key from keys_bound_to
(which returns nothing at the moment):
Lines 667 to 670 in f2df59c
if( events_event.type == CATA_INPUT_KEYBOARD && events_event.sequence.size() == 1 && | |
events_event.sequence.front() < 0xFF && isprint( events_event.sequence.front() ) ) { | |
result.push_back( static_cast<char>( events_event.sequence.front() ) ); | |
} |
The above comparison with F9 bound to the debug menu:
events_event.type == CATA_INPUT_KEYBOARD
: trueevents_event.sequence.size() == 1
: trueevents_event.sequence.front() < 0xFF
: false (0x111 for F9 for ex.)isprint( events_event.sequence.front()
: false (0x111 is not printable)
So technically there's a bound key but the check enforces that it must be a 8-bit key code and be printable...
Is it worth a new function or a patch? should I kill this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can address this in another PR. It is not your fault and this function behavior existed before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok understood! Thanks for your feedback. I'll try to address this in another PR as you suggested. Thank you!
Summary
SUMMARY: Features "Add game information report and SDL screenshot."
Purpose of change
(Note: this is a replay of #30244 after having messed up my branch)
Describe the solution
Following Night-Pryanik and DracoGriffin suggestions the debug menu is visible from the main menu under some circumstances:
Debug > Info
menu.The report , as of now, looks like this:
Except for the mod list, all the other information are collected through compiler defines, it's obviously not perfect but:
The above report is written to the
debug.log
file and in the clipboard (for SDL).I intended to do it for bug reporting, but while coding it I thought that taking a screenshot while the process heap might be in a bad shape was a probably bad idea. The code was there so I left it.
The screen shot is basically a copy of the SDL viewport (so, not the screen, just the game view) translated into a PNG. The file is saved into the game save world, into a "screenshots" folder.
So if your current workd is named
Amidon
the screenshots are in/save/Amidon/screenshots
.The naming scheme of the screenshots is:
[<character_name>]_YYYY-MM-DD_HH-MM-SS_<GMT_OFFSET>
So for example:
[Julian 'Fish' Willis]_2019-05-04_15-49-08_+0100
The date format is similar to ISO 8601, except for some characters that are replaced because they are not allowed on some file systems.
I also added a function (filesystem.[h,cpp]) that filters possible invalid characters from the player name when building the filename.
Describe alternatives you've considered
N/A.
Additional context
In the end I'd like to do a semi-automatic reporting:
debug.log
(with the above game info report)I'd also like to get more information about the system, like the distribution and its version for Unices (e.g. Ubuntu 18.04) and the Major and Minor versions for Windows (e.g. Windows 10 1809).