-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
Delete button for saveloadwindow, make this window less error prone (and some more) #5674
Delete button for saveloadwindow, make this window less error prone (and some more) #5674
Conversation
1d602e4
to
6aaee7b
Compare
Nice! |
@nozmajner It has, just not used for now. I want to show
Edit: correct me if I wrong. |
350bc77
to
49975c1
Compare
Hope this is last, missed some copypaste error since last time. Sorry for a lot of pushes. |
Rather than displaying another popup that the user has to click through telling them that deleting a save succeeded, I'd recommend simply drawing the status message right-aligned on the same line as the Generally, you want to only interrupt the user's flow to ask them if they're doing a potentially-destructive operation by accident - informational notices should not interrupt the player. If the save or delete operation failed, that can be a valid case for displaying a popup notification, but deleting a savefile shouldn't take three clicks. |
@Web-eWorks DeleteSuccessfulText.mp4 |
Looks good! I'd recommend using the next smaller font size breakpoint (with |
@Web-eWorks |
2be61d4
to
6d23dae
Compare
6d23dae
to
98586c3
Compare
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.
Finally reviewing this now that I have the time available, thank you for the patience.
Code looks good, the new methods in FileSystemPosix/FileSystemWin32 could probably receive another pass at some point for optimization and cleanup (for example, the forbidden characters list on unix is definitely missing a few characters), but overall I think it's fine.
Tested on Linux, if anyone wants to give this a test on Windows before I merge, let me know in the next 24 hours or so.
Adds new message box "OK_CANCEL" with two buttons "OK" and "Cancel". Pressing "OK" will call function specified in "callback" parameter. As the side change, all types of message box will be positioned at the center of the screen.
1. FileSystem::IsValidFilename to check if filename doesn't have forbidden OS characters; 2. FileSourceFS::IsChildOfRoot to check if given path is inside FileSourceFS::m_root; 3. FileSourceFS::RemoveFile to remove file from passed relative path. During method execution, relative path will transform to m_root + relativePath. Deletion is restricted to only delete regular files.
1. All variables that are not going to change their value are marked constant; 2. Adds "return luaL_error", like specified in "TODO's"; 3. All instances where "return 0" was called after "luaL_error" changed simply to "return luaL_error(...)".
Adds new delete button for saveLoadWindow, which enables user to delete any save in the user\\Documents\\savefiles\\ folder. Makes saveLoadWindow and all functions related to saves less error prone. To name a few; 1. Before saving, savefile name will be checked for forbidden symbols (eg. for Windows: '\', ' " ', '\0'); 2. All instances where JoinPathBelow is used is wrapped around try-catch block, because it can throw "std::invalid_argument" exception; 3. Game.SaveGame and Game.LoadGame is pcall'ed to catch any errors that can happen in them. MessageBox will be shown to user to tell, what gone wrong during saving/loading the game. Adds new static method Game::DeleteSave and lua variation l_game_delete_save.
Allow getting time from internal ImGui timer from lua.
Adds new pigui lib "ui-timer" that allows creation of timer that checks timer from internal ImGui timer, rather then Game.time.
Additional changes to saveloadgame.lua to use new ui-timer functionality.
98586c3
to
8cb8c65
Compare
Adds delete button for
saveloadwindow
to allow user to delete any save inuser\\Documents\\Pioneer\\savefiles\\
folder.For this, adds new static method
Game::DeleteSave(const std::string& filename)
and two new methods inFileSystemFS
class:FileSystemFS::RemoveFile(const std::string& relativePath)
, to remove file in theFileSystemFS::m_root
+relativePath
. Deletion is restricted to only delete regular files;FileSystemFS::IsChildOfRoot(const std::string& path)
to check if given path is in theFileSystemFS::m_root
.Makes
saveloadwindow
less error prone, especially when trying tosave
/load
. Will showMessageBox
with a text about whysave
/load
failed.Before saving will check filename with new
FileSystem::IsValidFilename(const std::string& filename)
iffilename
has forbiddenOS
characters.Other changes include optimization for
Game::CanLoadGame
(just tries to open file to check it's existence) andGame::SaveGame
(tries to open file first, if failed, immediatlly throw exception), newMessageBox
type and little refactoring forLuaGame.cpp
.Demonstration (Linux VM, similar functionality in Windows):
Delete.Button.mp4
Update:
saveloadwindow
now showsMessageBox
with confirmation if user really wants to delete save. Next it will show anotherMessageBox
, that tells if save deleted successfully or not;FileSystemFS::IsChildOfRoot(const std::string& path)
.