Fixed file saving issues and grid element overlap
This commit is contained in:
parent
d3e4524589
commit
962665ffd4
11 changed files with 67 additions and 42 deletions
|
|
@ -207,7 +207,7 @@ void FileSelectScreen::create_file_button() {
|
|||
.isClient = false,
|
||||
.filePathEmptyAutoSaveDir = savePath
|
||||
});
|
||||
main.set_screen(std::make_unique<PhoneDrawingProgramScreen>(main));
|
||||
main.set_screen([&] (std::unique_ptr<Screen>) { return std::make_unique<PhoneDrawingProgramScreen>(main); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -257,6 +257,7 @@ void FileSelectScreen::move_selected_files(const std::filesystem::path& fromPath
|
|||
for(const FileInfo& f : fileList) {
|
||||
if(f.selected) {
|
||||
std::string newFileName = ensure_string_unique(toFolderListNames, f.fileName);
|
||||
toFolderListNames.emplace_back(newFileName);
|
||||
std::filesystem::path filePath = fromPath / (f.fileName + World::DOT_FILE_EXTENSION);
|
||||
std::filesystem::path thumbnailPath = fromPath / (f.fileName + ".jpg");
|
||||
std::filesystem::path newFilePath = toPath / (newFileName + World::DOT_FILE_EXTENSION);
|
||||
|
|
@ -290,6 +291,7 @@ void FileSelectScreen::duplicate_selected_files(const std::filesystem::path& inP
|
|||
for(const FileInfo& f : fileList) {
|
||||
if(f.selected) {
|
||||
std::string newFileName = ensure_string_unique(toFolderListNames, f.fileName);
|
||||
toFolderListNames.emplace_back(newFileName);
|
||||
std::filesystem::path filePath = inPath / (f.fileName + World::DOT_FILE_EXTENSION);
|
||||
std::filesystem::path thumbnailPath = inPath / (f.fileName + ".jpg");
|
||||
std::filesystem::path newFilePath = inPath / (newFileName + World::DOT_FILE_EXTENSION);
|
||||
|
|
@ -670,15 +672,15 @@ void FileSelectScreen::file_view() {
|
|||
Vector2f iconSize{0.0f, 0.0f};
|
||||
switch(fileViewType) {
|
||||
case FileViewType::LARGE_GRID:
|
||||
entrySize = {170.0f, 190.0f};
|
||||
entrySize = {170.0f, 210.0f};
|
||||
iconSize = {130.0f, 130.0f};
|
||||
break;
|
||||
case FileViewType::MEDIUM_GRID:
|
||||
entrySize = {140.0f, 160.0f};
|
||||
entrySize = {140.0f, 180.0f};
|
||||
iconSize = {100.0f, 100.0f};
|
||||
break;
|
||||
case FileViewType::SMALL_GRID:
|
||||
entrySize = {110.0f, 130.0f};
|
||||
entrySize = {110.0f, 150.0f};
|
||||
iconSize = {70.0f, 70.0f};
|
||||
break;
|
||||
default:
|
||||
|
|
@ -736,7 +738,7 @@ void FileSelectScreen::start_edit_mode() {
|
|||
|
||||
void FileSelectScreen::input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) {
|
||||
main.create_new_tab(openFile);
|
||||
main.set_screen(std::make_unique<PhoneDrawingProgramScreen>(main));
|
||||
main.set_screen([&] (std::unique_ptr<Screen>) { return std::make_unique<PhoneDrawingProgramScreen>(main); });
|
||||
}
|
||||
|
||||
void FileSelectScreen::input_global_back_button_callback() {
|
||||
|
|
@ -753,9 +755,19 @@ void FileSelectScreen::draw(SkCanvas* canvas) {
|
|||
canvas->clear(main.g.gui.io.theme->backColor0);
|
||||
}
|
||||
|
||||
FileSelectScreen::~FileSelectScreen() {
|
||||
void FileSelectScreen::save_files() {
|
||||
nlohmann::json j;
|
||||
nlohmann::to_json(j, trashInfo);
|
||||
std::string saveJson = nlohmann::to_string(j);
|
||||
SDL_SaveFile(trashInfoPath.string().c_str(), saveJson.c_str(), saveJson.size());
|
||||
}
|
||||
|
||||
void FileSelectScreen::input_app_about_to_go_to_background_callback() {
|
||||
save_files();
|
||||
}
|
||||
|
||||
FileSelectScreen::~FileSelectScreen() {
|
||||
#ifndef __ANDROID__
|
||||
save_files();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "Screen.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "../GUIStuff/GUIManager.hpp"
|
||||
#include "../GUIStuff/GUIFloatAnimation.hpp"
|
||||
|
||||
class FileSelectScreen : public Screen {
|
||||
public:
|
||||
|
|
@ -10,6 +10,7 @@ class FileSelectScreen : public Screen {
|
|||
virtual void draw(SkCanvas* canvas) override;
|
||||
virtual void input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) override;
|
||||
virtual void input_global_back_button_callback() override;
|
||||
virtual void input_app_about_to_go_to_background_callback() override;
|
||||
|
||||
struct TrashInfo {
|
||||
struct TrashFile {
|
||||
|
|
@ -26,6 +27,8 @@ class FileSelectScreen : public Screen {
|
|||
std::filesystem::path trashPath;
|
||||
std::filesystem::path trashInfoPath;
|
||||
|
||||
void save_files();
|
||||
|
||||
struct FileInfo {
|
||||
std::string fileName;
|
||||
SDL_Time lastModifyTime;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void PhoneDrawingProgramScreen::top_toolbar() {
|
|||
.onClick = [&] {
|
||||
main.world->save_to_file(main.world->filePath);
|
||||
main.set_tab_to_close(main.world.get());
|
||||
main.set_screen(std::make_unique<FileSelectScreen>(main));
|
||||
main.set_screen([&] (std::unique_ptr<Screen>) { return std::make_unique<FileSelectScreen>(main); });
|
||||
}
|
||||
});
|
||||
text_label(gui, main.world->name);
|
||||
|
|
@ -70,15 +70,10 @@ void PhoneDrawingProgramScreen::top_toolbar() {
|
|||
void PhoneDrawingProgramScreen::input_global_back_button_callback() {
|
||||
main.world->save_to_file(main.world->filePath);
|
||||
main.set_tab_to_close(main.world.get());
|
||||
main.set_screen(std::make_unique<FileSelectScreen>(main));
|
||||
main.g.gui.set_to_layout();
|
||||
main.set_screen([&] (std::unique_ptr<Screen>) { return std::make_unique<FileSelectScreen>(main); });
|
||||
}
|
||||
|
||||
bool PhoneDrawingProgramScreen::app_close_requested() {
|
||||
main.world->save_to_file(main.world->filePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PhoneDrawingProgramScreen::input_app_terminate_callback() {
|
||||
void PhoneDrawingProgramScreen::input_app_about_to_go_to_background_callback() {
|
||||
main.world->save_to_file(main.world->filePath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ class PhoneDrawingProgramScreen : public DrawingProgramScreen {
|
|||
virtual void update() override;
|
||||
virtual void gui_layout_run() override;
|
||||
virtual void input_global_back_button_callback() override;
|
||||
virtual bool app_close_requested() override;
|
||||
virtual void input_app_terminate_callback() override;
|
||||
virtual void input_app_about_to_go_to_background_callback() override;
|
||||
private:
|
||||
void save_files();
|
||||
void top_toolbar();
|
||||
void main_display();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,6 +29,6 @@ void Screen::input_finger_touch_callback(const InputManager::FingerTouchCallback
|
|||
void Screen::input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) {}
|
||||
void Screen::input_window_resize_callback(const InputManager::WindowResizeCallbackArgs& w) {}
|
||||
void Screen::input_window_scale_callback(const InputManager::WindowScaleCallbackArgs& w) {}
|
||||
void Screen::input_app_terminate_callback() {}
|
||||
void Screen::input_app_about_to_go_to_background_callback() {}
|
||||
|
||||
Screen::~Screen() {}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Screen {
|
|||
virtual void input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion);
|
||||
virtual void input_window_resize_callback(const InputManager::WindowResizeCallbackArgs& w);
|
||||
virtual void input_window_scale_callback(const InputManager::WindowScaleCallbackArgs& w);
|
||||
virtual void input_app_terminate_callback();
|
||||
virtual void input_app_about_to_go_to_background_callback();
|
||||
|
||||
virtual ~Screen();
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue