Add staged M.A.S.S. deletion.

This commit is contained in:
Guillaume Jacquemin 2020-01-16 01:21:47 +01:00
parent 8bf2866a17
commit 5a51a70ec8
7 changed files with 101 additions and 0 deletions

View File

@ -203,6 +203,14 @@ void EvtMainFrame::stagingSelectionEvent(wxCommandEvent&) {
updateCommandsState();
}
void EvtMainFrame::deleteStagedEvent(wxCommandEvent&) {
int selection = _stagingList->GetSelection();
if(selection != wxNOT_FOUND) {
_manager.deleteStagedMass(selection);
}
}
void EvtMainFrame::stagingButtonEvent(wxCommandEvent&) {
wxExecute("explorer.exe " + Utility::Directory::toNativeSeparators(_manager.stagingAreaDirectory()));
}

View File

@ -40,6 +40,7 @@ class EvtMainFrame: public MainFrame {
void backupEvent(wxCommandEvent&);
void openSaveDirEvent(wxCommandEvent&);
void stagingSelectionEvent(wxCommandEvent&);
void deleteStagedEvent(wxCommandEvent&);
void stagingButtonEvent(wxCommandEvent&);
void installedSelectionEvent(wxListEvent&);
void listColumnDragEvent(wxListEvent&);

View File

@ -78,6 +78,9 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
_stagingList = new wxListBox( sbSizerStagingArea->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB|wxLB_SINGLE );
sbSizerStagingArea->Add( _stagingList, 1, wxALL|wxEXPAND, 5 );
_deleteStagedButton = new wxButton( sbSizerStagingArea->GetStaticBox(), wxID_ANY, wxT("Delete staged M.A.S.S."), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerStagingArea->Add( _deleteStagedButton, 0, wxALL|wxEXPAND, 5 );
_stagingAreaButton = new wxButton( sbSizerStagingArea->GetStaticBox(), wxID_ANY, wxT("Open staging area directory"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerStagingArea->Add( _stagingAreaButton, 0, wxALL|wxEXPAND, 5 );
@ -131,6 +134,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
_importButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::importEvent ), NULL, this );
_exportButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::exportEvent ), NULL, this );
_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::stagingButtonEvent ), NULL, this );
this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( MainFrame::gameCheckTimerEvent ) );
}
@ -145,6 +149,7 @@ MainFrame::~MainFrame()
_importButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::importEvent ), NULL, this );
_exportButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::exportEvent ), NULL, this );
_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::stagingButtonEvent ), NULL, this );
this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( MainFrame::gameCheckTimerEvent ) );

View File

@ -694,6 +694,79 @@
<event name="OnListBox">stagingSelectionEvent</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Delete staged M.A.S.S.</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">_deleteStagedButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">deleteStagedEvent</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>

View File

@ -45,6 +45,7 @@ class MainFrame : public wxFrame
wxButton* _importButton;
wxButton* _exportButton;
wxListBox* _stagingList;
wxButton* _deleteStagedButton;
wxButton* _stagingAreaButton;
wxStaticText* _riskLabel;
wxStaticText* _gameStatusLabel;
@ -60,6 +61,7 @@ class MainFrame : public wxFrame
virtual void importEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void exportEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void stagingSelectionEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void deleteStagedEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void stagingButtonEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void gameCheckTimerEvent( wxTimerEvent& event ) { event.Skip(); }

View File

@ -471,6 +471,16 @@ auto MassManager::removeStagedMass(const std::string& filename) -> int {
return -1;
}
void MassManager::deleteStagedMass(int index) {
int i = 0;
for(auto it = _stagedMasses.begin(); it != _stagedMasses.end(); ++it, ++i) {
if(i == index) {
Utility::Directory::rm(Utility::Directory::join(_stagingAreaDirectory, it->first));
break;
}
}
}
std::string MassManager::stagedMassName(int index) {
int i = 0;
for(const auto& mass_info : _stagedMasses) {

View File

@ -74,6 +74,8 @@ class MassManager {
auto updateStagedMass(const std::string& filename) -> int;
auto removeStagedMass(const std::string& filename) -> int;
void deleteStagedMass(int index);
auto stagedMassName(int index) -> std::string;
auto stagedMassName(const std::string& filename) -> std::string;