Fixed GUI issues and added android save on quit (has some problems)
This commit is contained in:
parent
45dbde5da5
commit
d3e4524589
9 changed files with 51 additions and 23 deletions
|
|
@ -50,12 +50,11 @@ void FileSelectScreen::gui_layout_run() {
|
|||
|
||||
void FileSelectScreen::update_file_list(std::vector<FileInfo>& fL, const std::filesystem::path& savePath, bool trashUpdate) {
|
||||
constexpr SDL_Time NS_IN_DAY = SDL_SECONDS_TO_NS(24 * 3600);
|
||||
constexpr int64_t DAYS_TO_DELETION = 30;
|
||||
|
||||
SDL_Time currentTime;
|
||||
SDL_GetCurrentTime(¤tTime);
|
||||
|
||||
SDL_Time afterThirtyDays = currentTime + NS_IN_DAY * 30;
|
||||
|
||||
fL.clear();
|
||||
int globCount;
|
||||
char** filesInPath = SDL_GlobDirectory(savePath.string().c_str(), "*", 0, &globCount);
|
||||
|
|
@ -77,22 +76,21 @@ void FileSelectScreen::update_file_list(std::vector<FileInfo>& fL, const std::fi
|
|||
else
|
||||
fileInfoToAdd.lastModifyTime = it->second.trashTime;
|
||||
|
||||
if(fileInfoToAdd.lastModifyTime >= afterThirtyDays) {
|
||||
int64_t daysSinceMovedToTrash = (currentTime - fileInfoToAdd.lastModifyTime) / NS_IN_DAY;
|
||||
|
||||
if(daysSinceMovedToTrash >= DAYS_TO_DELETION) {
|
||||
// Remove file and thumbnail
|
||||
SDL_RemovePath(fullPath.string().c_str());
|
||||
SDL_RemovePath((savePath / fileInfoToAdd.fileName / ".jpg").string().c_str());
|
||||
trashInfo.files.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
int64_t daysToDeletion = (afterThirtyDays - fileInfoToAdd.lastModifyTime) / NS_IN_DAY;
|
||||
|
||||
if(daysToDeletion == 0)
|
||||
else if(daysSinceMovedToTrash == 29)
|
||||
fileInfoToAdd.lastModifyDate = "Today";
|
||||
else if(daysToDeletion == 1)
|
||||
else if(daysSinceMovedToTrash == 28)
|
||||
fileInfoToAdd.lastModifyDate = "Tomorrow";
|
||||
else
|
||||
fileInfoToAdd.lastModifyDate = std::to_string(daysToDeletion) + " days";
|
||||
fileInfoToAdd.lastModifyDate = std::to_string(DAYS_TO_DELETION - daysSinceMovedToTrash - 1) + " days";
|
||||
}
|
||||
else {
|
||||
SDL_PathInfo pathInfo;
|
||||
|
|
@ -209,7 +207,7 @@ void FileSelectScreen::create_file_button() {
|
|||
.isClient = false,
|
||||
.filePathEmptyAutoSaveDir = savePath
|
||||
});
|
||||
main.screen = std::make_unique<PhoneDrawingProgramScreen>(main);
|
||||
main.set_screen(std::make_unique<PhoneDrawingProgramScreen>(main));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -738,7 +736,7 @@ void FileSelectScreen::start_edit_mode() {
|
|||
|
||||
void FileSelectScreen::input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) {
|
||||
main.create_new_tab(openFile);
|
||||
main.screen = std::make_unique<PhoneDrawingProgramScreen>(main);
|
||||
main.set_screen(std::make_unique<PhoneDrawingProgramScreen>(main));
|
||||
}
|
||||
|
||||
void FileSelectScreen::input_global_back_button_callback() {
|
||||
|
|
@ -746,6 +744,8 @@ void FileSelectScreen::input_global_back_button_callback() {
|
|||
mainMenuOpenAnim->animation_trigger_reverse();
|
||||
else if(editMode)
|
||||
editMode = false;
|
||||
else
|
||||
main.setToQuit = true;
|
||||
main.g.gui.set_to_layout();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "../GUIStuff/ElementHelpers/LayoutHelpers.hpp"
|
||||
#include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
||||
#include "FileSelectScreen.hpp"
|
||||
#include <Helpers/Logger.hpp>
|
||||
|
||||
using namespace GUIStuff;
|
||||
using namespace ElementHelpers;
|
||||
|
|
@ -58,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.screen = std::make_unique<FileSelectScreen>(main);
|
||||
main.set_screen(std::make_unique<FileSelectScreen>(main));
|
||||
}
|
||||
});
|
||||
text_label(gui, main.world->name);
|
||||
|
|
@ -69,6 +70,15 @@ 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.screen = std::make_unique<FileSelectScreen>(main);
|
||||
main.set_screen(std::make_unique<FileSelectScreen>(main));
|
||||
main.g.gui.set_to_layout();
|
||||
}
|
||||
|
||||
bool PhoneDrawingProgramScreen::app_close_requested() {
|
||||
main.world->save_to_file(main.world->filePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PhoneDrawingProgramScreen::input_app_terminate_callback() {
|
||||
main.world->save_to_file(main.world->filePath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ 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;
|
||||
private:
|
||||
void top_toolbar();
|
||||
void main_display();
|
||||
|
|
|
|||
|
|
@ -29,5 +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() {}
|
||||
|
||||
Screen::~Screen() {}
|
||||
|
|
|
|||
|
|
@ -31,6 +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 ~Screen();
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue