MainFrame: expose renaming in the UI.
This commit is contained in:
parent
667a2929a7
commit
c0e88ec90e
5 changed files with 108 additions and 0 deletions
|
@ -22,6 +22,8 @@
|
|||
#include <Corrade/Containers/Optional.h>
|
||||
#include <Corrade/Utility/Directory.h>
|
||||
|
||||
#include "EvtNameChangeDialog.h"
|
||||
|
||||
#include "EvtMainFrame.h"
|
||||
|
||||
using namespace Corrade;
|
||||
|
@ -177,6 +179,30 @@ void EvtMainFrame::deleteEvent(wxCommandEvent&) {
|
|||
}
|
||||
}
|
||||
|
||||
void EvtMainFrame::renameMassEvent(wxCommandEvent&) {
|
||||
const static std::string error_prefix = "Rename failed:\n\n";
|
||||
|
||||
EvtNameChangeDialog dialog{this};
|
||||
dialog.setName(*(_manager.massName(_installedListView->GetFirstSelected())));
|
||||
int result = dialog.ShowModal();
|
||||
|
||||
if(result == wxID_OK) {
|
||||
switch(_manager.gameState()) {
|
||||
case GameState::Unknown:
|
||||
errorMessage(error_prefix + "For security reasons, renaming a M.A.S.S. is disabled if the game's status is unknown.");
|
||||
break;
|
||||
case GameState::NotRunning:
|
||||
if(!_manager.renameMass(_installedListView->GetFirstSelected(), dialog.getName())) {
|
||||
errorMessage(error_prefix + _manager.lastError());
|
||||
}
|
||||
break;
|
||||
case GameState::Running:
|
||||
errorMessage(error_prefix + "Renaming a M.A.S.S. is disabled while the game is running.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EvtMainFrame::backupEvent(wxCommandEvent&) {
|
||||
const static std::string error_prefix = "Backup failed:\n\n";
|
||||
|
||||
|
@ -399,6 +425,7 @@ void EvtMainFrame::updateCommandsState() {
|
|||
_exportButton->Enable(selection != -1);
|
||||
_moveButton->Enable(selection != -1 && game_state != GameState::Running && hangar_state != HangarState::Empty && hangar_state != HangarState::Invalid);
|
||||
_deleteButton->Enable(selection != -1 && game_state != GameState::Running && hangar_state != HangarState::Empty);
|
||||
_renameButton->Enable(selection != -1 && game_state != GameState::Running && hangar_state != HangarState::Empty);
|
||||
_deleteStagedButton->Enable(staged_selection != -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class EvtMainFrame: public MainFrame {
|
|||
void exportEvent(wxCommandEvent&);
|
||||
void moveEvent(wxCommandEvent&);
|
||||
void deleteEvent(wxCommandEvent&);
|
||||
void renameMassEvent(wxCommandEvent&);
|
||||
void backupEvent(wxCommandEvent&);
|
||||
void openSaveDirEvent(wxCommandEvent&);
|
||||
void stagingSelectionEvent(wxCommandEvent&);
|
||||
|
|
|
@ -37,6 +37,9 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
|
|||
_deleteButton = new wxButton( sbSizerButtons->GetStaticBox(), wxID_ANY, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizerButtons->Add( _deleteButton, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
_renameButton = new wxButton( sbSizerButtons->GetStaticBox(), wxID_ANY, wxT("Rename"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizerButtons->Add( _renameButton, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
sbSizerInstalled->Add( sbSizerButtons, 0, wxEXPAND, 5 );
|
||||
|
||||
|
@ -132,6 +135,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
|
|||
// Connect Events
|
||||
_moveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::moveEvent ), NULL, this );
|
||||
_deleteButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteEvent ), NULL, this );
|
||||
_renameButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::renameMassEvent ), NULL, this );
|
||||
_zipButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::backupEvent ), NULL, this );
|
||||
_openSaveDirButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openSaveDirEvent ), NULL, this );
|
||||
_importButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::importEvent ), NULL, this );
|
||||
|
@ -147,6 +151,7 @@ MainFrame::~MainFrame()
|
|||
// Disconnect Events
|
||||
_moveButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::moveEvent ), NULL, this );
|
||||
_deleteButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::deleteEvent ), NULL, this );
|
||||
_renameButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::renameMassEvent ), NULL, this );
|
||||
_zipButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::backupEvent ), NULL, this );
|
||||
_openSaveDirButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openSaveDirEvent ), NULL, this );
|
||||
_importButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::importEvent ), NULL, this );
|
||||
|
|
|
@ -300,6 +300,79 @@
|
|||
<event name="OnButtonClick">deleteEvent</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">1</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">Rename</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">_renameButton</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">renameMassEvent</event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
|
|
|
@ -41,6 +41,7 @@ class MainFrame : public wxFrame
|
|||
wxListView* _installedListView;
|
||||
wxButton* _moveButton;
|
||||
wxButton* _deleteButton;
|
||||
wxButton* _renameButton;
|
||||
wxButton* _zipButton;
|
||||
wxButton* _openSaveDirButton;
|
||||
wxButton* _importButton;
|
||||
|
@ -58,6 +59,7 @@ class MainFrame : public wxFrame
|
|||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void moveEvent( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void deleteEvent( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void renameMassEvent( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void backupEvent( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void openSaveDirEvent( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void importEvent( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
|
Loading…
Reference in a new issue