From 6a07121323778ac262549a4cc251798ba5676c79 Mon Sep 17 00:00:00 2001 From: William JCM Date: Thu, 16 Jan 2020 01:21:25 +0100 Subject: [PATCH] MainFrame: update command state on staging selection. --- GUI/EvtMainFrame.cpp | 7 ++++++- GUI/EvtMainFrame.h | 1 + GUI/MainFrame.cpp | 2 ++ GUI/MainFrame.fbp | 1 + GUI/MainFrame.h | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/GUI/EvtMainFrame.cpp b/GUI/EvtMainFrame.cpp index 2af7451..5f38a80 100644 --- a/GUI/EvtMainFrame.cpp +++ b/GUI/EvtMainFrame.cpp @@ -199,6 +199,10 @@ void EvtMainFrame::openSaveDirEvent(wxCommandEvent&) { wxExecute("explorer.exe " + Utility::Directory::toNativeSeparators(_manager.saveDirectory())); } +void EvtMainFrame::stagingSelectionEvent(wxCommandEvent&) { + updateCommandsState(); +} + void EvtMainFrame::stagingButtonEvent(wxCommandEvent&) { wxExecute("explorer.exe " + Utility::Directory::toNativeSeparators(_manager.stagingAreaDirectory())); } @@ -379,10 +383,11 @@ void EvtMainFrame::getActiveSlot() { void EvtMainFrame::updateCommandsState() { long selection = _installedListView->GetFirstSelected(); + int staged_selection = _stagingList->GetSelection(); GameState game_state = _manager.gameState(); HangarState hangar_state = _manager.hangarState(selection); - _importButton->Enable(selection != -1 && game_state != GameState::Running); + _importButton->Enable(selection != -1 && staged_selection != -1 && game_state != GameState::Running); _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); diff --git a/GUI/EvtMainFrame.h b/GUI/EvtMainFrame.h index ed006c2..c7efaf3 100644 --- a/GUI/EvtMainFrame.h +++ b/GUI/EvtMainFrame.h @@ -39,6 +39,7 @@ class EvtMainFrame: public MainFrame { void deleteEvent(wxCommandEvent&); void backupEvent(wxCommandEvent&); void openSaveDirEvent(wxCommandEvent&); + void stagingSelectionEvent(wxCommandEvent&); void stagingButtonEvent(wxCommandEvent&); void installedSelectionEvent(wxListEvent&); void listColumnDragEvent(wxListEvent&); diff --git a/GUI/MainFrame.cpp b/GUI/MainFrame.cpp index 41e4dc5..eb3b10e 100644 --- a/GUI/MainFrame.cpp +++ b/GUI/MainFrame.cpp @@ -130,6 +130,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co _openSaveDirButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openSaveDirEvent ), NULL, this ); _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 ); _stagingAreaButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::stagingButtonEvent ), NULL, this ); this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( MainFrame::gameCheckTimerEvent ) ); } @@ -143,6 +144,7 @@ MainFrame::~MainFrame() _openSaveDirButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::openSaveDirEvent ), NULL, this ); _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 ); _stagingAreaButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrame::stagingButtonEvent ), NULL, this ); this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( MainFrame::gameCheckTimerEvent ) ); diff --git a/GUI/MainFrame.fbp b/GUI/MainFrame.fbp index ca42d6c..727a02a 100644 --- a/GUI/MainFrame.fbp +++ b/GUI/MainFrame.fbp @@ -691,6 +691,7 @@ + stagingSelectionEvent diff --git a/GUI/MainFrame.h b/GUI/MainFrame.h index 5fabfef..bc9ccbc 100644 --- a/GUI/MainFrame.h +++ b/GUI/MainFrame.h @@ -59,6 +59,7 @@ class MainFrame : public wxFrame virtual void openSaveDirEvent( wxCommandEvent& event ) { event.Skip(); } virtual void importEvent( wxCommandEvent& event ) { event.Skip(); } virtual void exportEvent( wxCommandEvent& event ) { event.Skip(); } + virtual void stagingSelectionEvent( wxCommandEvent& event ) { event.Skip(); } virtual void stagingButtonEvent( wxCommandEvent& event ) { event.Skip(); } virtual void gameCheckTimerEvent( wxTimerEvent& event ) { event.Skip(); }