mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 12:02:40 +02:00
confirm on local save delete, ESC to exit local save browser, don't allow empty save names
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
#include "simulation/SaveRenderer.h"
|
#include "simulation/SaveRenderer.h"
|
||||||
#include "dialogues/TextPrompt.h"
|
#include "dialogues/TextPrompt.h"
|
||||||
|
#include "dialogues/ConfirmPrompt.h"
|
||||||
#include "dialogues/ErrorMessage.h"
|
#include "dialogues/ErrorMessage.h"
|
||||||
|
|
||||||
class Thumbnail;
|
class Thumbnail;
|
||||||
@@ -176,19 +177,28 @@ void FileBrowserActivity::SelectSave(SaveFile * file)
|
|||||||
|
|
||||||
void FileBrowserActivity::DeleteSave(SaveFile * file)
|
void FileBrowserActivity::DeleteSave(SaveFile * file)
|
||||||
{
|
{
|
||||||
remove(file->GetName().c_str());
|
std::string deleteMessage = "Are you sure you want to delete " + file->GetDisplayName() + ".cps?";
|
||||||
loadDirectory(directory, "");
|
if (ConfirmPrompt::Blocking("Delete Save", deleteMessage))
|
||||||
|
{
|
||||||
|
remove(file->GetName().c_str());
|
||||||
|
loadDirectory(directory, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowserActivity::RenameSave(SaveFile * file)
|
void FileBrowserActivity::RenameSave(SaveFile * file)
|
||||||
{
|
{
|
||||||
std::string newName = TextPrompt::Blocking("Rename", "Change save name", file->GetDisplayName(), "", 0);
|
std::string newName = TextPrompt::Blocking("Rename", "Change save name", file->GetDisplayName(), "", 0);
|
||||||
newName = directory + PATH_SEP + newName + ".cps";
|
if (newName.length())
|
||||||
int ret = rename(file->GetName().c_str(), newName.c_str());
|
{
|
||||||
if (ret)
|
newName = directory + PATH_SEP + newName + ".cps";
|
||||||
ErrorMessage::Blocking("Error", "Could not rename file");
|
int ret = rename(file->GetName().c_str(), newName.c_str());
|
||||||
|
if (ret)
|
||||||
|
ErrorMessage::Blocking("Error", "Could not rename file");
|
||||||
|
else
|
||||||
|
loadDirectory(directory, "");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
loadDirectory(directory, "");
|
ErrorMessage::Blocking("Error", "No save name given");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowserActivity::loadDirectory(std::string directory, std::string search)
|
void FileBrowserActivity::loadDirectory(std::string directory, std::string search)
|
||||||
@@ -246,6 +256,11 @@ void FileBrowserActivity::OnMouseDown(int x, int y, unsigned button)
|
|||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileBrowserActivity::OnTryExit(ExitMethod method)
|
||||||
|
{
|
||||||
|
Exit();
|
||||||
|
}
|
||||||
|
|
||||||
void FileBrowserActivity::NotifyError(Task * task)
|
void FileBrowserActivity::NotifyError(Task * task)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -49,6 +49,7 @@ public:
|
|||||||
FileBrowserActivity(std::string directory, FileSelectedCallback * callback);
|
FileBrowserActivity(std::string directory, FileSelectedCallback * callback);
|
||||||
virtual void OnDraw();
|
virtual void OnDraw();
|
||||||
virtual void OnTick(float dt);
|
virtual void OnTick(float dt);
|
||||||
|
virtual void OnTryExit(ExitMethod method);
|
||||||
virtual void OnMouseDown(int x, int y, unsigned button);
|
virtual void OnMouseDown(int x, int y, unsigned button);
|
||||||
void loadDirectory(std::string directory, std::string search);
|
void loadDirectory(std::string directory, std::string search);
|
||||||
void SelectSave(SaveFile * file);
|
void SelectSave(SaveFile * file);
|
||||||
|
Reference in New Issue
Block a user