diff --git a/CMakeLists.txt b/CMakeLists.txt index d01b8a5..4dea64f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,8 +63,6 @@ add_executable(wxMASSManager WIN32 Profile/Profile.cpp ProfileManager/ProfileManager.h ProfileManager/ProfileManager.cpp - ScreenshotManager/ScreenshotManager.h - ScreenshotManager/ScreenshotManager.cpp resource.rc) target_compile_options(wxMASSManager PRIVATE -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -fpermissive) diff --git a/GUI/EvtMainFrame.cpp b/GUI/EvtMainFrame.cpp index d753075..7ed974c 100644 --- a/GUI/EvtMainFrame.cpp +++ b/GUI/EvtMainFrame.cpp @@ -107,8 +107,6 @@ EvtMainFrame::EvtMainFrame(wxWindow* parent): wxFSW_EVENT_CREATE|wxFSW_EVENT_DELETE|wxFSW_EVENT_MODIFY|wxFSW_EVENT_RENAME, "*.sav"); _gameCheckTimer.Start(2000); - - _screenshotsList->SetImageList(&_screenshotThumbs, wxIMAGE_LIST_NORMAL); } EvtMainFrame::~EvtMainFrame() { @@ -397,63 +395,8 @@ void EvtMainFrame::listColumnDragEvent(wxListEvent& event) { event.Veto(); } -void EvtMainFrame::screenshotListSelectionEvent(wxListEvent&) { - updateCommandsState(); -} - -void EvtMainFrame::screenshotFilenameSortingEvent(wxCommandEvent&) { - _screenshotManager->sortScreenshots(SortType::Filename); - updateScreenshotList(); -} - -void EvtMainFrame::screenshotCreationDateSortingEvent(wxCommandEvent&) { - _screenshotManager->sortScreenshots(SortType::CreationDate); - updateScreenshotList(); -} - -void EvtMainFrame::screenshotAscendingSortingEvent(wxCommandEvent&) { - _screenshotManager->sortScreenshots(SortOrder::Ascending); - updateScreenshotList(); -} - -void EvtMainFrame::screenshotDescendingSortingEvent(wxCommandEvent&) { - _screenshotManager->sortScreenshots(SortOrder::Descending); - updateScreenshotList(); -} - -void EvtMainFrame::viewScreenshotEvent(wxCommandEvent&) { - viewScreenshot(); -} - -void EvtMainFrame::viewScreenshotEvent(wxListEvent&) { - viewScreenshot(); -} - -void EvtMainFrame::deleteScreenshotEvent(wxCommandEvent&) { - if(wxMessageBox("Are you sure you want to delete the selected screenshot ? This operation cannot be undone.", - "Are you sure ?", wxYES_NO|wxCENTRE|wxICON_QUESTION, this) == wxNO) { - return; - } - - long selection = _screenshotsList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - - if(selection != -1) { - _screenshotManager->deleteScreenshot(selection); - } -} - void EvtMainFrame::openScreenshotDirEvent(wxCommandEvent&) { - wxExecute("explorer.exe " + Utility::Directory::toNativeSeparators(_screenshotManager->screenshotDirectory())); -} - -void EvtMainFrame::tabChangeEvent(wxNotebookEvent& event) { - if(event.GetSelection() == 2 && !_screenshotManager) { - wxBusyInfo busy{"Loading screenshots...", this}; - _screenshotManager.emplace(_mbManager.saveDirectory()); - _watcher.AddTree(wxFileName(Utility::Directory::toNativeSeparators(_screenshotManager->screenshotDirectory()), wxPATH_WIN), - wxFSW_EVENT_CREATE|wxFSW_EVENT_DELETE, "*.png"); // Not monitoring MODIFY or RENAME, because they're a massive pain to handle. Ugh. - updateScreenshotList(); - } + wxExecute("explorer.exe " + Utility::Directory::toNativeSeparators(Utility::Directory::join(_profileManager.profileDirectory(), "../Screenshots/WindowsNoEditor"))); } void EvtMainFrame::fileUpdateEvent(wxFileSystemWatcherEvent& event) { @@ -475,9 +418,6 @@ void EvtMainFrame::fileUpdateEvent(wxFileSystemWatcherEvent& event) { else if(_massManager && event_path == Utility::Directory::toNativeSeparators(_massManager->stagingAreaDirectory())) { stagingFileEventHandler(event_type, event_file, event); } - else if(_screenshotManager && event_path == Utility::Directory::toNativeSeparators(_screenshotManager->screenshotDirectory())) { - screenshotFileEventHandler(event_type, event_file); - } _lastWatcherEventType = event_type; @@ -599,24 +539,6 @@ void EvtMainFrame::stagingFileEventHandler(int event_type, const wxString& event } } -void EvtMainFrame::screenshotFileEventHandler(int event_type, const wxString& event_file) { - int index = -1; - - switch(event_type) { - case wxFSW_EVENT_CREATE: - _screenshotManager->updateScreenshot(event_file.ToUTF8().data()); - updateScreenshotList(); - break; - case wxFSW_EVENT_DELETE: - index = _screenshotsList->FindItem(-1, event_file, true); - if(index != -1) { - _screenshotManager->removeScreenshot(index); - _screenshotsList->DeleteItem(index); - } - break; - } -} - void EvtMainFrame::updateProfileStats() { Profile* current_profile = _profileManager.currentProfile(); _companyName->SetLabel(current_profile->getCompanyName()); @@ -711,10 +633,6 @@ void EvtMainFrame::updateCommandsState() { _deleteButton->Enable(selection != -1 && (_unsafeMode == true || game_state == GameState::NotRunning) && mass_state != MassState::Empty); _renameButton->Enable(selection != -1 && (_unsafeMode == true || game_state == GameState::NotRunning) && mass_state == MassState::Valid); _deleteStagedButton->Enable(staged_selection != -1); - - long screenshot_selection = _screenshotsList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - _viewScreenshotButton->Enable(screenshot_selection != -1); - _deleteScreenshotButton->Enable(screenshot_selection != -1); } void EvtMainFrame::refreshHangar(int slot) { @@ -737,53 +655,6 @@ void EvtMainFrame::refreshHangar(int slot) { } } -void EvtMainFrame::updateScreenshotList() { - _screenshotsList->DeleteAllItems(); - _screenshotThumbs.RemoveAll(); - - int index = 0; - for(const Screenshot& s : _screenshotManager->screenshots()) { - _screenshotsList->InsertItem(index, - wxString::Format("%s\n%s", wxString::FromUTF8(s._filename.c_str()), s._creationDate.Format("%d/%m/%Y %H:%M:%S")), - _screenshotThumbs.Add(s._thumbnail)); - - ++index; - } -} - -void EvtMainFrame::viewScreenshot() { - long selection = _screenshotsList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if(selection == -1) { - return; - } - - wxBitmap image(Utility::Directory::toNativeSeparators(Utility::Directory::join(_screenshotManager->screenshotDirectory(), - _screenshotManager->screenshots().at(selection)._filename)), wxBITMAP_TYPE_PNG); - - wxDialog view_dialog; - view_dialog.Create(this, wxID_ANY, "Screenshot viewer", wxDefaultPosition, wxSize{1024, 576}, wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU); - - wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); - wxScrolledWindow* scroller = new wxScrolledWindow(&view_dialog, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxHSCROLL); - scroller->SetScrollRate(5, 5); - - wxBoxSizer* scroller_sizer = new wxBoxSizer(wxVERTICAL); - wxStaticBitmap* screenshot = new wxStaticBitmap(scroller, wxID_ANY, image); - scroller_sizer->Add(screenshot, 1, wxEXPAND, 5); - - scroller->SetSizer(scroller_sizer); - scroller->Layout(); - scroller_sizer->FitInside(scroller); - sizer->Add(scroller, 1, wxEXPAND, 5); - - view_dialog.SetSizer(sizer); - view_dialog.Layout(); - sizer->FitInside(&view_dialog); - view_dialog.Centre(); - - view_dialog.ShowModal(); -} - void EvtMainFrame::infoMessage(const wxString& message) { wxMessageBox(message, "Information", wxOK|wxCENTRE|wxICON_INFORMATION, this); } diff --git a/GUI/EvtMainFrame.h b/GUI/EvtMainFrame.h index 7d10c8f..fb0106d 100644 --- a/GUI/EvtMainFrame.h +++ b/GUI/EvtMainFrame.h @@ -28,7 +28,6 @@ #include "../MassBuilderManager/MassBuilderManager.h" #include "../Profile/Profile.h" #include "../ProfileManager/ProfileManager.h" -#include "../ScreenshotManager/ScreenshotManager.h" #include "MainFrame.h" @@ -61,18 +60,9 @@ class EvtMainFrame: public MainFrame { void listColumnDragEvent(wxListEvent&); // Screenshot-related events - void screenshotListSelectionEvent(wxListEvent&); - void screenshotFilenameSortingEvent(wxCommandEvent&); - void screenshotCreationDateSortingEvent(wxCommandEvent&); - void screenshotAscendingSortingEvent(wxCommandEvent&); - void screenshotDescendingSortingEvent(wxCommandEvent&); - void viewScreenshotEvent(wxCommandEvent&); - void viewScreenshotEvent(wxListEvent&); - void deleteScreenshotEvent(wxCommandEvent&); void openScreenshotDirEvent(wxCommandEvent&); // General events - void tabChangeEvent(wxNotebookEvent& event); void fileUpdateEvent(wxFileSystemWatcherEvent& event); void gameCheckTimerEvent(wxTimerEvent&); void unsafeCheckboxEvent(wxCommandEvent& event); @@ -80,7 +70,6 @@ class EvtMainFrame: public MainFrame { private: void saveFileEventHandler(int event_type, const wxString& event_file, const wxFileSystemWatcherEvent& event); void stagingFileEventHandler(int event_type, const wxString& event_file, const wxFileSystemWatcherEvent& event); - void screenshotFileEventHandler(int event_type, const wxString& event_file); void updateProfileStats(); @@ -91,9 +80,6 @@ class EvtMainFrame: public MainFrame { void updateCommandsState(); void refreshHangar(int slot); - void updateScreenshotList(); - void viewScreenshot(); - void infoMessage(const wxString& message); void warningMessage(const wxString& message); void errorMessage(const wxString& message); @@ -103,12 +89,9 @@ class EvtMainFrame: public MainFrame { MassBuilderManager _mbManager; ProfileManager _profileManager; Containers::Pointer _massManager; - Containers::Pointer _screenshotManager; wxFileSystemWatcher _watcher; int _lastWatcherEventType = 0; - - wxImageList _screenshotThumbs{160, 160, true, 0}; }; #endif // __EvtMainFrame__ diff --git a/GUI/MainFrame.cpp b/GUI/MainFrame.cpp index be52d30..fd932b2 100644 --- a/GUI/MainFrame.cpp +++ b/GUI/MainFrame.cpp @@ -37,6 +37,9 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co _backupSelectedButton = new wxButton( _mainPanel, wxID_ANY, wxT("Backup selected profile"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerProfile->Add( _backupSelectedButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + _openScreenshotDirButton = new wxButton( _mainPanel, wxID_ANY, wxT("Open screenshots folder"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerProfile->Add( _openScreenshotDirButton, 0, wxALL, 5 ); + bSizerProfile->Add( 0, 0, 1, wxEXPAND, 5 ); @@ -193,65 +196,6 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co _massPanel->Layout(); bSizerMassPanel->Fit( _massPanel ); _managerNotebook->AddPage( _massPanel, wxT("M.A.S.S.es"), false ); - _screenshotsPanel = new wxPanel( _managerNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerScreenshotsPanel; - bSizerScreenshotsPanel = new wxBoxSizer( wxHORIZONTAL ); - - _screenshotsList = new wxListCtrl( _screenshotsPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ALIGN_TOP|wxLC_AUTOARRANGE|wxLC_ICON|wxLC_SINGLE_SEL ); - bSizerScreenshotsPanel->Add( _screenshotsList, 1, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* bSizerScreenshotCommands; - bSizerScreenshotCommands = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* sbSizerSorting; - sbSizerSorting = new wxStaticBoxSizer( new wxStaticBox( _screenshotsPanel, wxID_ANY, wxT("Sorting") ), wxVERTICAL ); - - wxBoxSizer* bSizerSortType; - bSizerSortType = new wxBoxSizer( wxHORIZONTAL ); - - _nameRadio = new wxRadioButton( sbSizerSorting->GetStaticBox(), wxID_ANY, wxT("Filename"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - _nameRadio->SetValue( true ); - bSizerSortType->Add( _nameRadio, 1, wxALL, 5 ); - - _creationDateRadio = new wxRadioButton( sbSizerSorting->GetStaticBox(), wxID_ANY, wxT("Creation date"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerSortType->Add( _creationDateRadio, 1, wxALL, 5 ); - - - sbSizerSorting->Add( bSizerSortType, 1, wxEXPAND, 5 ); - - wxBoxSizer* bSizerSortOrder; - bSizerSortOrder = new wxBoxSizer( wxHORIZONTAL ); - - _ascendingRadio = new wxRadioButton( sbSizerSorting->GetStaticBox(), wxID_ANY, wxT("Ascending"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); - _ascendingRadio->SetValue( true ); - bSizerSortOrder->Add( _ascendingRadio, 1, wxALL, 5 ); - - _descendingRadio = new wxRadioButton( sbSizerSorting->GetStaticBox(), wxID_ANY, wxT("Descending"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerSortOrder->Add( _descendingRadio, 1, wxALL, 5 ); - - - sbSizerSorting->Add( bSizerSortOrder, 1, wxEXPAND, 5 ); - - - bSizerScreenshotCommands->Add( sbSizerSorting, 0, wxEXPAND|wxALL, 5 ); - - _viewScreenshotButton = new wxButton( _screenshotsPanel, wxID_ANY, wxT("View"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerScreenshotCommands->Add( _viewScreenshotButton, 0, wxALL|wxEXPAND, 5 ); - - _deleteScreenshotButton = new wxButton( _screenshotsPanel, wxID_ANY, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerScreenshotCommands->Add( _deleteScreenshotButton, 0, wxALL|wxEXPAND, 5 ); - - _screenshotDirButton = new wxButton( _screenshotsPanel, wxID_ANY, wxT("Open directory"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerScreenshotCommands->Add( _screenshotDirButton, 0, wxALL|wxEXPAND, 5 ); - - - bSizerScreenshotsPanel->Add( bSizerScreenshotCommands, 0, wxEXPAND, 5 ); - - - _screenshotsPanel->SetSizer( bSizerScreenshotsPanel ); - _screenshotsPanel->Layout(); - bSizerScreenshotsPanel->Fit( _screenshotsPanel ); - _managerNotebook->AddPage( _screenshotsPanel, wxT("Photo mode shots"), false ); bSizerMainPanel->Add( _managerNotebook, 1, wxEXPAND, 5 ); @@ -303,8 +247,8 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co // Connect Events _profileChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( MainFrame::profileSelectionEvent ), NULL, this ); _backupSelectedButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::backupSelectedProfileEvent ), NULL, this ); + _openScreenshotDirButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openScreenshotDirEvent ), NULL, this ); _unsafeCheckbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainFrame::unsafeCheckboxEvent ), NULL, this ); - _managerNotebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( MainFrame::tabChangeEvent ), NULL, this ); _companyName->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MainFrame::companyRenameEvent ), NULL, this ); _moveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::moveMassEvent ), NULL, this ); _deleteButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteMassEvent ), NULL, this ); @@ -315,16 +259,6 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co _stagingList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( MainFrame::stagingSelectionEvent ), NULL, this ); _deleteStagedButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteStagedEvent ), NULL, this ); _stagingAreaButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openStagingDirEvent ), NULL, this ); - _screenshotsList->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( MainFrame::viewScreenshotEvent ), NULL, this ); - _screenshotsList->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( MainFrame::screenshotListSelectionEvent ), NULL, this ); - _screenshotsList->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( MainFrame::screenshotListSelectionEvent ), NULL, this ); - _nameRadio->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotFilenameSortingEvent ), NULL, this ); - _creationDateRadio->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotCreationDateSortingEvent ), NULL, this ); - _ascendingRadio->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotAscendingSortingEvent ), NULL, this ); - _descendingRadio->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotDescendingSortingEvent ), NULL, this ); - _viewScreenshotButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::viewScreenshotEvent ), NULL, this ); - _deleteScreenshotButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteScreenshotEvent ), NULL, this ); - _screenshotDirButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openScreenshotDirEvent ), NULL, this ); this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( MainFrame::gameCheckTimerEvent ) ); } @@ -333,8 +267,8 @@ MainFrame::~MainFrame() // Disconnect Events _profileChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( MainFrame::profileSelectionEvent ), NULL, this ); _backupSelectedButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::backupSelectedProfileEvent ), NULL, this ); + _openScreenshotDirButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openScreenshotDirEvent ), NULL, this ); _unsafeCheckbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainFrame::unsafeCheckboxEvent ), NULL, this ); - _managerNotebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( MainFrame::tabChangeEvent ), NULL, this ); _companyName->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MainFrame::companyRenameEvent ), NULL, this ); _moveButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::moveMassEvent ), NULL, this ); _deleteButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteMassEvent ), NULL, this ); @@ -345,16 +279,6 @@ MainFrame::~MainFrame() _stagingList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( MainFrame::stagingSelectionEvent ), NULL, this ); _deleteStagedButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteStagedEvent ), NULL, this ); _stagingAreaButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openStagingDirEvent ), NULL, this ); - _screenshotsList->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( MainFrame::viewScreenshotEvent ), NULL, this ); - _screenshotsList->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( MainFrame::screenshotListSelectionEvent ), NULL, this ); - _screenshotsList->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( MainFrame::screenshotListSelectionEvent ), NULL, this ); - _nameRadio->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotFilenameSortingEvent ), NULL, this ); - _creationDateRadio->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotCreationDateSortingEvent ), NULL, this ); - _ascendingRadio->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotAscendingSortingEvent ), NULL, this ); - _descendingRadio->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MainFrame::screenshotDescendingSortingEvent ), NULL, this ); - _viewScreenshotButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::viewScreenshotEvent ), NULL, this ); - _deleteScreenshotButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteScreenshotEvent ), NULL, this ); - _screenshotDirButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openScreenshotDirEvent ), NULL, this ); this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( MainFrame::gameCheckTimerEvent ) ); } diff --git a/GUI/MainFrame.fbp b/GUI/MainFrame.fbp index 1f32dfc..3bee0e7 100644 --- a/GUI/MainFrame.fbp +++ b/GUI/MainFrame.fbp @@ -327,6 +327,79 @@ backupSelectedProfileEvent + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Open screenshots folder + + 0 + + 0 + + + 0 + + 1 + _openScreenshotDirButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + openScreenshotDirEvent + + 5 wxEXPAND @@ -461,7 +534,6 @@ - tabChangeEvent Profile details and stats @@ -1883,660 +1955,6 @@ - - - Photo mode shots - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - _screenshotsPanel - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - bSizerScreenshotsPanel - wxHORIZONTAL - none - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - _screenshotsList - 1 - - - protected - 1 - - Resizable - 1 - - wxLC_ALIGN_TOP|wxLC_AUTOARRANGE|wxLC_ICON|wxLC_SINGLE_SEL - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - viewScreenshotEvent - screenshotListSelectionEvent - screenshotListSelectionEvent - - - - 5 - wxEXPAND - 0 - - - bSizerScreenshotCommands - wxVERTICAL - none - - 5 - wxEXPAND|wxALL - 0 - - wxID_ANY - Sorting - - sbSizerSorting - wxVERTICAL - 1 - none - - 5 - wxEXPAND - 1 - - - bSizerSortType - wxHORIZONTAL - none - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Filename - - 0 - - - 0 - - 1 - _nameRadio - 1 - - - protected - 1 - - Resizable - 1 - - wxRB_GROUP - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 1 - - - - screenshotFilenameSortingEvent - - - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Creation date - - 0 - - - 0 - - 1 - _creationDateRadio - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - screenshotCreationDateSortingEvent - - - - - - 5 - wxEXPAND - 1 - - - bSizerSortOrder - wxHORIZONTAL - none - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Ascending - - 0 - - - 0 - - 1 - _ascendingRadio - 1 - - - protected - 1 - - Resizable - 1 - - wxRB_GROUP - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 1 - - - - screenshotAscendingSortingEvent - - - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Descending - - 0 - - - 0 - - 1 - _descendingRadio - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - 0 - - - - screenshotDescendingSortingEvent - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - View - - 0 - - 0 - - - 0 - - 1 - _viewScreenshotButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - viewScreenshotEvent - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Delete - - 0 - - 0 - - - 0 - - 1 - _deleteScreenshotButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - deleteScreenshotEvent - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Open directory - - 0 - - 0 - - - 0 - - 1 - _screenshotDirButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - openScreenshotDirEvent - - - - - - - diff --git a/GUI/MainFrame.h b/GUI/MainFrame.h index 028ac22..fac2176 100644 --- a/GUI/MainFrame.h +++ b/GUI/MainFrame.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -47,6 +46,7 @@ class MainFrame : public wxFrame wxStaticText* _profileLabel; wxChoice* _profileChoice; wxButton* _backupSelectedButton; + wxButton* _openScreenshotDirButton; wxCheckBox* _unsafeCheckbox; wxNotebook* _managerNotebook; wxPanel* _profilePanel; @@ -69,15 +69,6 @@ class MainFrame : public wxFrame wxListBox* _stagingList; wxButton* _deleteStagedButton; wxButton* _stagingAreaButton; - wxPanel* _screenshotsPanel; - wxListCtrl* _screenshotsList; - wxRadioButton* _nameRadio; - wxRadioButton* _creationDateRadio; - wxRadioButton* _ascendingRadio; - wxRadioButton* _descendingRadio; - wxButton* _viewScreenshotButton; - wxButton* _deleteScreenshotButton; - wxButton* _screenshotDirButton; wxStaticText* _riskLabel; wxStaticText* _gameStatusLabel; wxStaticText* _gameStatus; @@ -88,8 +79,8 @@ class MainFrame : public wxFrame // Virtual event handlers, overide them in your derived class virtual void profileSelectionEvent( wxCommandEvent& event ) { event.Skip(); } virtual void backupSelectedProfileEvent( wxCommandEvent& event ) { event.Skip(); } + virtual void openScreenshotDirEvent( wxCommandEvent& event ) { event.Skip(); } virtual void unsafeCheckboxEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void tabChangeEvent( wxNotebookEvent& event ) { event.Skip(); } virtual void companyRenameEvent( wxMouseEvent& event ) { event.Skip(); } virtual void moveMassEvent( wxCommandEvent& event ) { event.Skip(); } virtual void deleteMassEvent( wxCommandEvent& event ) { event.Skip(); } @@ -100,15 +91,6 @@ class MainFrame : public wxFrame virtual void stagingSelectionEvent( wxCommandEvent& event ) { event.Skip(); } virtual void deleteStagedEvent( wxCommandEvent& event ) { event.Skip(); } virtual void openStagingDirEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void viewScreenshotEvent( wxListEvent& event ) { event.Skip(); } - virtual void screenshotListSelectionEvent( wxListEvent& event ) { event.Skip(); } - virtual void screenshotFilenameSortingEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void screenshotCreationDateSortingEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void screenshotAscendingSortingEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void screenshotDescendingSortingEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void viewScreenshotEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void deleteScreenshotEvent( wxCommandEvent& event ) { event.Skip(); } - virtual void openScreenshotDirEvent( wxCommandEvent& event ) { event.Skip(); } virtual void gameCheckTimerEvent( wxTimerEvent& event ) { event.Skip(); } diff --git a/ScreenshotManager/ScreenshotManager.cpp b/ScreenshotManager/ScreenshotManager.cpp deleted file mode 100644 index 63bc9d2..0000000 --- a/ScreenshotManager/ScreenshotManager.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// wxMASSManager -// Copyright (C) 2020 Guillaume Jacquemin -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include - -#if !(CORRADE_VERSION_YEAR * 100 + CORRADE_VERSION_MONTH >= 202006) - #error This application requires Corrade 2020.06 or later to build. -#endif - -#include - -#include -#include - -#include - -#include "ScreenshotManager.h" - -using namespace Corrade; - -ScreenshotManager::ScreenshotManager(const std::string& base_path) { - _screenshotDirectory = Utility::Directory::join(base_path, "Saved/Screenshots/WindowsNoEditor"); - - if(!Utility::Directory::exists(_screenshotDirectory)) { - Utility::Directory::mkpath(_screenshotDirectory); - } - - using Utility::Directory::Flag; - std::vector file_list = Utility::Directory::list(_screenshotDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot); - - auto iter = std::remove_if(file_list.begin(), file_list.end(), [](std::string& file){ - return !Utility::String::endsWith(file, ".png"); - }); - - file_list.erase(iter, file_list.end()); - - _screenshots.reserve(file_list.size()); - - for(const std::string& file : file_list) { - addScreenshot(file); - } -} - -auto ScreenshotManager::screenshotDirectory() -> std::string const& { - return _screenshotDirectory; -} - -auto ScreenshotManager::screenshots() -> std::vector const& { - return _screenshots; -} - -void ScreenshotManager::sortScreenshots(SortType type) { - _sortType = type; - sortScreenshots(); -} - -void ScreenshotManager::sortScreenshots(SortOrder order) { - _sortOrder = order; - sortScreenshots(); -} - -void ScreenshotManager::sortScreenshots() { - auto predicate = [this](const Screenshot& item_1, const Screenshot& item_2)->bool{ - switch(_sortType) { - case SortType::Filename: - return wxString::FromUTF8(item_1._filename.c_str()).CmpNoCase(wxString::FromUTF8(item_2._filename.c_str())) < 0; - case SortType::CreationDate: - return item_1._creationDate.IsEarlierThan(item_2._creationDate); - } - - return true; - }; - - switch(_sortOrder) { - case SortOrder::Ascending: - std::stable_sort(_screenshots.begin(), _screenshots.end(), predicate); - break; - case SortOrder::Descending: - std::stable_sort(_screenshots.rbegin(), _screenshots.rend(), predicate); - break; - } -} - -auto ScreenshotManager::updateScreenshot(const std::string& filename) -> int { - addScreenshot(filename); - sortScreenshots(); - int index = 0; - for(const Screenshot& s : _screenshots) { - if(s._filename == filename) { - return index; - } - } - - return -1; -} - -void ScreenshotManager::removeScreenshot(int index) { - if(static_cast(index + 1) > _screenshots.size()) { - return; - } - - auto it = _screenshots.begin() + index; - _screenshots.erase(it); -} - -void ScreenshotManager::deleteScreenshot(int index) { - if(static_cast(index + 1) > _screenshots.size()) { - return; - } - - Utility::Directory::rm(Utility::Directory::join(_screenshotDirectory, _screenshots[index]._filename)); -} - -void ScreenshotManager::addScreenshot(const std::string& filename) { - std::string screenshot_path = Utility::Directory::toNativeSeparators(Utility::Directory::join(_screenshotDirectory, filename)); - - wxFileName screenshot_meta(screenshot_path); - wxDateTime creation_date; - screenshot_meta.GetTimes(nullptr, nullptr, &creation_date); - - wxImage thumb{screenshot_path, wxBITMAP_TYPE_PNG}; - - wxSize size = thumb.GetSize(); - if(size.GetWidth() > size.GetHeight()) { - size.Set(160, (size.GetHeight() * 160) / size.GetWidth()); - } - else if(size.GetHeight() > size.GetWidth()) { - size.Set((size.GetWidth() * 160) / size.GetHeight(), 160); - } - else { - size.Set(160, 160); - } - - thumb.Rescale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH) - .Resize(wxSize{160, 160}, wxPoint{(160 - size.GetWidth()) / 2, (160 - size.GetHeight()) / 2}); - - _screenshots.push_back(Screenshot{filename, creation_date, thumb}); -} diff --git a/ScreenshotManager/ScreenshotManager.h b/ScreenshotManager/ScreenshotManager.h deleted file mode 100644 index 122bdd0..0000000 --- a/ScreenshotManager/ScreenshotManager.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef SCREENSHOTMANAGER_H -#define SCREENSHOTMANAGER_H - -// wxMASSManager -// Copyright (C) 2020 Guillaume Jacquemin -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include -#include - -#include -#include - -enum class SortType : uint8_t { - Filename, CreationDate -}; - -enum class SortOrder: uint8_t { - Ascending, Descending -}; - -struct Screenshot { - std::string _filename; - wxDateTime _creationDate; - wxImage _thumbnail; -}; - -class ScreenshotManager { - public: - ScreenshotManager(const std::string& base_path); - - auto screenshotDirectory() -> std::string const&; - - auto screenshots() -> std::vector const&; - - void sortScreenshots(SortType type); - void sortScreenshots(SortOrder order); - void sortScreenshots(); - - auto updateScreenshot(const std::string& filename) -> int; - void removeScreenshot(int index); - void deleteScreenshot(int index); - - private: - void addScreenshot(const std::string& filename); - - std::string _screenshotDirectory = ""; - - std::vector _screenshots; - - SortType _sortType = SortType::Filename; - SortOrder _sortOrder = SortOrder::Ascending; -}; - -#endif //SCREENSHOTMANAGER_H