WX: HiDPI: CheatsWindow

Changed the Cheat Search tab to disable the scan buttons while there is
not a game running and enable when it starts. Also added double-click to
create code to the result list.
This commit is contained in:
EmptyChaos 2016-10-03 06:56:45 +00:00
parent 8fe94c3c50
commit c893447913
7 changed files with 186 additions and 123 deletions

View File

@ -27,10 +27,7 @@
#include "DolphinWX/Cheats/CreateCodeDialog.h" #include "DolphinWX/Cheats/CreateCodeDialog.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
namespace static constexpr unsigned int MAX_CHEAT_SEARCH_RESULTS_DISPLAY = 1024;
{
const unsigned int MAX_CHEAT_SEARCH_RESULTS_DISPLAY = 1024;
}
CheatSearchTab::CheatSearchTab(wxWindow* const parent) : wxPanel(parent) CheatSearchTab::CheatSearchTab(wxWindow* const parent) : wxPanel(parent)
{ {
@ -39,13 +36,25 @@ CheatSearchTab::CheatSearchTab(wxWindow* const parent) : wxPanel(parent)
// first scan button // first scan button
m_btn_init_scan = new wxButton(this, wxID_ANY, _("New Scan")); m_btn_init_scan = new wxButton(this, wxID_ANY, _("New Scan"));
m_btn_init_scan->SetToolTip(_("Perform a full index of the game's RAM at the current Data Size. "
"Required before any Searching can be performed."));
m_btn_init_scan->Bind(wxEVT_BUTTON, &CheatSearchTab::OnNewScanClicked, this); m_btn_init_scan->Bind(wxEVT_BUTTON, &CheatSearchTab::OnNewScanClicked, this);
m_btn_init_scan->Disable();
// next scan button // next scan button
m_btn_next_scan = new wxButton(this, wxID_ANY, _("Next Scan")); m_btn_next_scan = new wxButton(this, wxID_ANY, _("Next Scan"));
m_btn_next_scan->SetToolTip(_("Eliminate items from the current scan results that do not match "
"the current Search settings."));
m_btn_next_scan->Bind(wxEVT_BUTTON, &CheatSearchTab::OnNextScanClicked, this); m_btn_next_scan->Bind(wxEVT_BUTTON, &CheatSearchTab::OnNextScanClicked, this);
m_btn_next_scan->Disable(); m_btn_next_scan->Disable();
m_label_scan_disabled = new wxStaticText(this, wxID_ANY, _("No game is running."));
// create AR code button
m_btn_create_code = new wxButton(this, wxID_ANY, _("Create AR Code"));
m_btn_create_code->Bind(wxEVT_BUTTON, &CheatSearchTab::OnCreateARCodeClicked, this);
m_btn_create_code->Disable();
// data sizes radiobox // data sizes radiobox
std::array<wxString, 3> data_size_names = {{_("8-bit"), _("16-bit"), _("32-bit")}}; std::array<wxString, 3> data_size_names = {{_("8-bit"), _("16-bit"), _("32-bit")}};
m_data_sizes = new wxRadioBox(this, wxID_ANY, _("Data Size"), wxDefaultPosition, wxDefaultSize, m_data_sizes = new wxRadioBox(this, wxID_ANY, _("Data Size"), wxDefaultPosition, wxDefaultSize,
@ -54,30 +63,39 @@ CheatSearchTab::CheatSearchTab(wxWindow* const parent) : wxPanel(parent)
// ListView for search results // ListView for search results
m_lview_search_results = new wxListView(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_lview_search_results = new wxListView(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxLC_SINGLE_SEL); wxLC_REPORT | wxLC_SINGLE_SEL);
ResetListViewColumns(); m_lview_search_results->AppendColumn(_("Address"));
m_lview_search_results->AppendColumn(_("Value"));
m_lview_search_results->AppendColumn(_("Value (float)"));
m_lview_search_results->AppendColumn(_("Value (double)"));
m_lview_search_results->Bind(wxEVT_LIST_ITEM_ACTIVATED, &CheatSearchTab::OnListViewItemActivated,
this);
m_lview_search_results->Bind(wxEVT_LIST_ITEM_SELECTED, &CheatSearchTab::OnListViewItemSelected,
this);
m_lview_search_results->Bind(wxEVT_LIST_ITEM_DESELECTED, &CheatSearchTab::OnListViewItemSelected,
this);
// Result count // Result count
m_label_results_count = new wxStaticText(this, wxID_ANY, _("Count:")); m_label_results_count = new wxStaticText(this, wxID_ANY, _("Count:"));
// create AR code button const int space5 = FromDIP(5);
wxButton* const button_cheat_search_copy_address =
new wxButton(this, wxID_ANY, _("Create AR Code"));
button_cheat_search_copy_address->Bind(wxEVT_BUTTON, &CheatSearchTab::OnCreateARCodeClicked,
this);
// results groupbox // results groupbox
wxStaticBoxSizer* const sizer_cheat_search_results = wxStaticBoxSizer* const sizer_cheat_search_results =
new wxStaticBoxSizer(wxVERTICAL, this, _("Results")); new wxStaticBoxSizer(wxVERTICAL, this, _("Results"));
sizer_cheat_search_results->Add(m_label_results_count, 0, wxALIGN_LEFT | wxALL, 5); sizer_cheat_search_results->AddSpacer(space5);
sizer_cheat_search_results->Add(m_lview_search_results, 1, wxEXPAND | wxALL, 5); sizer_cheat_search_results->Add(m_label_results_count, 0, wxLEFT | wxRIGHT, space5);
sizer_cheat_search_results->Add(button_cheat_search_copy_address, 0, sizer_cheat_search_results->AddSpacer(space5);
wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5); sizer_cheat_search_results->Add(m_lview_search_results, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
sizer_cheat_search_results->AddSpacer(space5);
sizer_cheat_search_results->Add(m_btn_create_code, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
sizer_cheat_search_results->AddSpacer(space5);
// search value textbox // search value textbox
m_textctrl_value_x = new wxTextCtrl(this, wxID_ANY, "0x0", wxDefaultPosition, wxSize(96, -1)); m_textctrl_value_x = new wxTextCtrl(this, wxID_ANY, "0x0");
m_textctrl_value_x->SetMinSize(WxUtils::GetTextWidgetMinSize(m_textctrl_value_x, "0x00000000 "));
wxBoxSizer* const sizer_cheat_filter_text = new wxBoxSizer(wxHORIZONTAL); m_textctrl_value_x->SetToolTip(
sizer_cheat_filter_text->Add(m_textctrl_value_x, 1, wxALIGN_CENTER_VERTICAL, 5); _("Value to match against. Can be Hex (\"0x\"), Octal (\"0\") or Decimal. "
"Leave blank to filter each result against its own previous value."));
// Filter types in the compare dropdown // Filter types in the compare dropdown
// TODO: Implement between search // TODO: Implement between search
@ -93,33 +111,46 @@ CheatSearchTab::CheatSearchTab(wxWindow* const parent) : wxPanel(parent)
wxStaticBoxSizer* const sizer_cheat_search_filter = wxStaticBoxSizer* const sizer_cheat_search_filter =
new wxStaticBoxSizer(wxVERTICAL, this, _("Search (clear to use previous value)")); new wxStaticBoxSizer(wxVERTICAL, this, _("Search (clear to use previous value)"));
sizer_cheat_search_filter->Add(sizer_cheat_filter_text, 0, wxALL | wxEXPAND, 5); sizer_cheat_search_filter->AddSpacer(space5);
sizer_cheat_search_filter->Add(m_search_type, 0, wxALL, 5); sizer_cheat_search_filter->Add(m_textctrl_value_x, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
sizer_cheat_search_filter->AddSpacer(space5);
// left sizer sizer_cheat_search_filter->Add(m_search_type, 0, wxLEFT | wxRIGHT, space5);
wxBoxSizer* const sizer_left = new wxBoxSizer(wxVERTICAL); sizer_cheat_search_filter->AddSpacer(space5);
sizer_left->Add(sizer_cheat_search_results, 1, wxEXPAND, 5);
// button sizer // button sizer
wxBoxSizer* boxButtons = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* boxButtons = new wxBoxSizer(wxHORIZONTAL);
boxButtons->Add(m_btn_init_scan, 1, wxRIGHT, 5); boxButtons->Add(m_btn_init_scan, 1);
boxButtons->Add(m_btn_next_scan, 1); boxButtons->Add(m_btn_next_scan, 1, wxLEFT, space5);
// right sizer // right sizer
wxBoxSizer* const sizer_right = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const sizer_right = new wxBoxSizer(wxVERTICAL);
sizer_right->Add(m_data_sizes, 0, wxEXPAND | wxBOTTOM, 5); sizer_right->Add(m_data_sizes, 0, wxEXPAND);
sizer_right->Add(sizer_cheat_search_filter, 0, wxEXPAND | wxBOTTOM, 5); sizer_right->Add(sizer_cheat_search_filter, 0, wxEXPAND | wxTOP, space5);
sizer_right->AddStretchSpacer(1); sizer_right->AddStretchSpacer(1);
sizer_right->Add(boxButtons, 0, wxTOP | wxEXPAND, 5); sizer_right->Add(m_label_scan_disabled, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, space5);
sizer_right->Add(boxButtons, 0, wxEXPAND | wxTOP, space5);
// main sizer // main sizer
wxBoxSizer* const sizer_main = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const sizer_main = new wxBoxSizer(wxHORIZONTAL);
sizer_main->Add(sizer_left, 1, wxEXPAND | wxALL, 5); sizer_main->AddSpacer(space5);
sizer_main->Add(sizer_right, 0, wxEXPAND | wxALL, 5); sizer_main->Add(sizer_cheat_search_results, 1, wxEXPAND | wxTOP | wxBOTTOM, space5);
sizer_main->AddSpacer(space5);
sizer_main->Add(sizer_right, 0, wxEXPAND | wxTOP | wxBOTTOM, space5);
sizer_main->AddSpacer(space5);
SetSizerAndFit(sizer_main); SetSizerAndFit(sizer_main);
} }
void CheatSearchTab::UpdateGUI()
{
bool core_running = Core::IsRunning();
m_btn_init_scan->Enable(core_running);
m_btn_next_scan->Enable(core_running && m_scan_is_initialized);
m_label_scan_disabled->Show(!core_running);
Layout(); // Label shown/hidden may require layout adjustment
}
void CheatSearchTab::OnNewScanClicked(wxCommandEvent& WXUNUSED(event)) void CheatSearchTab::OnNewScanClicked(wxCommandEvent& WXUNUSED(event))
{ {
if (!Core::IsRunningAndStarted()) if (!Core::IsRunningAndStarted())
@ -136,6 +167,7 @@ void CheatSearchTab::OnNewScanClicked(wxCommandEvent& WXUNUSED(event))
m_search_results.reserve(Memory::RAM_SIZE / m_search_type_size); m_search_results.reserve(Memory::RAM_SIZE / m_search_type_size);
// Enable the "Next Scan" button. // Enable the "Next Scan" button.
m_scan_is_initialized = true;
m_btn_next_scan->Enable(); m_btn_next_scan->Enable();
CheatSearchResult r; CheatSearchResult r;
@ -183,6 +215,21 @@ void CheatSearchTab::OnCreateARCodeClicked(wxCommandEvent&)
arcode_dlg.ShowModal(); arcode_dlg.ShowModal();
} }
void CheatSearchTab::OnListViewItemActivated(wxListEvent&)
{
if (!m_btn_create_code->IsEnabled())
return;
wxCommandEvent fake(wxEVT_BUTTON, m_btn_create_code->GetId());
m_btn_create_code->GetEventHandler()->ProcessEvent(fake);
}
void CheatSearchTab::OnListViewItemSelected(wxListEvent&)
{
// Toggle "Create AR Code" Button
m_btn_create_code->Enable(m_lview_search_results->GetSelectedItemCount() > 0);
}
void CheatSearchTab::OnTimerUpdate(wxTimerEvent&) void CheatSearchTab::OnTimerUpdate(wxTimerEvent&)
{ {
if (Core::GetState() != Core::CORE_RUN) if (Core::GetState() != Core::CORE_RUN)
@ -190,8 +237,8 @@ void CheatSearchTab::OnTimerUpdate(wxTimerEvent&)
// Only update the currently visible list rows. // Only update the currently visible list rows.
long first = m_lview_search_results->GetTopItem(); long first = m_lview_search_results->GetTopItem();
long last = long last = std::min<long>(m_lview_search_results->GetItemCount(),
std::min(m_lview_search_results->GetItemCount(), m_lview_search_results->GetCountPerPage()); first + m_lview_search_results->GetCountPerPage());
m_lview_search_results->Freeze(); m_lview_search_results->Freeze();
@ -207,8 +254,8 @@ void CheatSearchTab::OnTimerUpdate(wxTimerEvent&)
void CheatSearchTab::UpdateCheatSearchResultsList() void CheatSearchTab::UpdateCheatSearchResultsList()
{ {
m_update_timer.Stop(); m_update_timer.Stop();
m_lview_search_results->ClearAll(); m_lview_search_results->DeleteAllItems();
ResetListViewColumns(); m_btn_create_code->Disable();
wxString count_label = wxString::Format(_("Count: %lu"), (unsigned long)m_search_results.size()); wxString count_label = wxString::Format(_("Count: %lu"), (unsigned long)m_search_results.size());
if (m_search_results.size() > MAX_CHEAT_SEARCH_RESULTS_DISPLAY) if (m_search_results.size() > MAX_CHEAT_SEARCH_RESULTS_DISPLAY)
@ -312,14 +359,6 @@ void CheatSearchTab::FilterCheatSearchResults(u32 value, bool prev)
m_search_results.swap(filtered_results); m_search_results.swap(filtered_results);
} }
void CheatSearchTab::ResetListViewColumns()
{
m_lview_search_results->AppendColumn(_("Address"));
m_lview_search_results->AppendColumn(_("Value"));
m_lview_search_results->AppendColumn(_("Value (float)"));
m_lview_search_results->AppendColumn(_("Value (double)"));
}
bool CheatSearchTab::ParseUserEnteredValue(u32* out) const bool CheatSearchTab::ParseUserEnteredValue(u32* out) const
{ {
unsigned long parsed_x_val = 0; unsigned long parsed_x_val = 0;

View File

@ -11,6 +11,7 @@
class wxButton; class wxButton;
class wxChoice; class wxChoice;
class wxFocusEvent; class wxFocusEvent;
class wxListEvent;
class wxListView; class wxListView;
class wxRadioBox; class wxRadioBox;
class wxRadioButton; class wxRadioButton;
@ -22,6 +23,8 @@ class CheatSearchTab final : public wxPanel
public: public:
CheatSearchTab(wxWindow* const parent); CheatSearchTab(wxWindow* const parent);
void UpdateGUI();
private: private:
class CheatSearchResult final class CheatSearchResult final
{ {
@ -34,25 +37,29 @@ private:
void UpdateCheatSearchResultsList(); void UpdateCheatSearchResultsList();
void UpdateCheatSearchResultItem(long index); void UpdateCheatSearchResultItem(long index);
void FilterCheatSearchResults(u32 value, bool prev); void FilterCheatSearchResults(u32 value, bool prev);
void ResetListViewColumns();
bool ParseUserEnteredValue(u32* out) const; bool ParseUserEnteredValue(u32* out) const;
u32 SwapValue(u32 value) const; u32 SwapValue(u32 value) const;
void OnNewScanClicked(wxCommandEvent&); void OnNewScanClicked(wxCommandEvent&);
void OnNextScanClicked(wxCommandEvent&); void OnNextScanClicked(wxCommandEvent&);
void OnCreateARCodeClicked(wxCommandEvent&); void OnCreateARCodeClicked(wxCommandEvent&);
void OnListViewItemActivated(wxListEvent&);
void OnListViewItemSelected(wxListEvent&);
void OnTimerUpdate(wxTimerEvent&); void OnTimerUpdate(wxTimerEvent&);
std::vector<CheatSearchResult> m_search_results; std::vector<CheatSearchResult> m_search_results;
unsigned int m_search_type_size; unsigned int m_search_type_size;
bool m_scan_is_initialized = false;
wxChoice* m_search_type; wxChoice* m_search_type;
wxListView* m_lview_search_results; wxListView* m_lview_search_results;
wxStaticText* m_label_results_count; wxStaticText* m_label_results_count;
wxTextCtrl* m_textctrl_value_x; wxTextCtrl* m_textctrl_value_x;
wxButton* m_btn_create_code;
wxButton* m_btn_init_scan; wxButton* m_btn_init_scan;
wxButton* m_btn_next_scan; wxButton* m_btn_next_scan;
wxStaticText* m_label_scan_disabled;
wxRadioBox* m_data_sizes; wxRadioBox* m_data_sizes;

View File

@ -55,13 +55,14 @@ wxCheatsWindow::wxCheatsWindow(wxWindow* const parent)
wxDIALOG_NO_PARENT) wxDIALOG_NO_PARENT)
{ {
// Create the GUI controls // Create the GUI controls
Init_ChildControls(); CreateGUI();
// load codes // load codes
UpdateGUI(); UpdateGUI();
wxTheApp->Bind(DOLPHIN_EVT_LOCAL_INI_CHANGED, &wxCheatsWindow::OnLocalGameIniModified, this); wxTheApp->Bind(DOLPHIN_EVT_LOCAL_INI_CHANGED, &wxCheatsWindow::OnLocalGameIniModified, this);
SetSize(wxSize(-1, 600)); SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER);
Center(); Center();
Show(); Show();
} }
@ -71,8 +72,11 @@ wxCheatsWindow::~wxCheatsWindow()
main_frame->g_CheatsWindow = nullptr; main_frame->g_CheatsWindow = nullptr;
} }
void wxCheatsWindow::Init_ChildControls() void wxCheatsWindow::CreateGUI()
{ {
const int space5 = FromDIP(5);
const int space10 = FromDIP(10);
// Main Notebook // Main Notebook
m_notebook_main = new wxNotebook(this, wxID_ANY); m_notebook_main = new wxNotebook(this, wxID_ANY);
@ -84,13 +88,15 @@ void wxCheatsWindow::Init_ChildControls()
new ActionReplayCodesPanel(tab_cheats, ActionReplayCodesPanel::STYLE_SIDE_PANEL | new ActionReplayCodesPanel(tab_cheats, ActionReplayCodesPanel::STYLE_SIDE_PANEL |
ActionReplayCodesPanel::STYLE_MODIFY_BUTTONS); ActionReplayCodesPanel::STYLE_MODIFY_BUTTONS);
wxBoxSizer* sizer_tab_cheats = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_tab_cheats = new wxBoxSizer(wxVERTICAL);
sizer_tab_cheats->Add(m_ar_codes_panel, 1, wxEXPAND | wxALL, 5); sizer_tab_cheats->AddSpacer(space5);
sizer_tab_cheats->Add(m_ar_codes_panel, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
sizer_tab_cheats->AddSpacer(space5);
tab_cheats->SetSizerAndFit(sizer_tab_cheats); tab_cheats->SetSizerAndFit(sizer_tab_cheats);
// Cheat Search Tab // Cheat Search Tab
wxPanel* const tab_cheat_search = new CheatSearchTab(m_notebook_main); m_tab_cheat_search = new CheatSearchTab(m_notebook_main);
// Log Tab // Log Tab
m_tab_log = new wxPanel(m_notebook_main, wxID_ANY); m_tab_log = new wxPanel(m_notebook_main, wxID_ANY);
@ -105,25 +111,30 @@ void wxCheatsWindow::Init_ChildControls()
&wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange, this); &wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange, this);
m_checkbox_log_ar->SetValue(ActionReplay::IsSelfLogging()); m_checkbox_log_ar->SetValue(ActionReplay::IsSelfLogging());
m_textctrl_log = new wxTextCtrl(m_tab_log, wxID_ANY, "", wxDefaultPosition, wxSize(100, -1), m_textctrl_log = new wxTextCtrl(m_tab_log, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
wxBoxSizer* HStrip1 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* log_control_sizer = new wxBoxSizer(wxHORIZONTAL);
HStrip1->Add(m_checkbox_log_ar, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); log_control_sizer->Add(m_checkbox_log_ar, 0, wxALIGN_CENTER_VERTICAL);
HStrip1->Add(button_updatelog, 0, wxALL, 5); log_control_sizer->Add(button_updatelog, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space10);
HStrip1->Add(button_clearlog, 0, wxALL, 5); log_control_sizer->Add(button_clearlog, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space10);
wxBoxSizer* sTabLog = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sTabLog = new wxBoxSizer(wxVERTICAL);
sTabLog->Add(HStrip1, 0, wxALL, 5); sTabLog->AddSpacer(space5);
sTabLog->Add(m_textctrl_log, 1, wxALL | wxEXPAND, 5); sTabLog->Add(log_control_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space10);
sTabLog->AddSpacer(space5);
sTabLog->Add(m_textctrl_log, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
sTabLog->AddSpacer(space5);
m_tab_log->SetSizerAndFit(sTabLog); m_tab_log->SetSizerAndFit(sTabLog);
// Gecko tab
m_geckocode_panel = new Gecko::CodeConfigPanel(m_notebook_main);
// Add Tabs to Notebook // Add Tabs to Notebook
m_notebook_main->AddPage(tab_cheats, _("AR Codes")); m_notebook_main->AddPage(tab_cheats, _("AR Codes"));
m_geckocode_panel = new Gecko::CodeConfigPanel(m_notebook_main);
m_notebook_main->AddPage(m_geckocode_panel, _("Gecko Codes")); m_notebook_main->AddPage(m_geckocode_panel, _("Gecko Codes"));
m_notebook_main->AddPage(tab_cheat_search, _("Cheat Search")); m_notebook_main->AddPage(m_tab_cheat_search, _("Cheat Search"));
m_notebook_main->AddPage(m_tab_log, _("Logging")); m_notebook_main->AddPage(m_tab_log, _("Logging"));
Bind(wxEVT_BUTTON, &wxCheatsWindow::OnEvent_ApplyChanges_Press, this, wxID_APPLY); Bind(wxEVT_BUTTON, &wxCheatsWindow::OnEvent_ApplyChanges_Press, this, wxID_APPLY);
@ -137,18 +148,23 @@ void wxCheatsWindow::Init_ChildControls()
SetAffirmativeId(wxID_CANCEL); SetAffirmativeId(wxID_CANCEL);
wxBoxSizer* const sMain = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(m_notebook_main, 1, wxEXPAND | wxALL, 5); sMain->AddSpacer(space5);
sMain->Add(sButtons, 0, wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 5); sMain->Add(m_notebook_main, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
sMain->AddSpacer(space5);
sMain->Add(sButtons, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
sMain->AddSpacer(space5);
sMain->SetMinSize(FromDIP(wxSize(-1, 600)));
SetSizerAndFit(sMain); SetSizerAndFit(sMain);
} }
void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED(event)) void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent&)
{ {
Close(); Close();
} }
void wxCheatsWindow::OnEvent_Close(wxCloseEvent& ev) void wxCheatsWindow::OnEvent_Close(wxCloseEvent&)
{ {
// This dialog is created on the heap instead of the stack so we have to destroy ourself.
Destroy(); Destroy();
} }
@ -164,6 +180,7 @@ void wxCheatsWindow::UpdateGUI()
m_gameini_local_path = File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"; m_gameini_local_path = File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini";
Load_ARCodes(); Load_ARCodes();
Load_GeckoCodes(); Load_GeckoCodes();
m_tab_cheat_search->UpdateGUI();
// enable controls // enable controls
m_button_apply->Enable(Core::IsRunning()); m_button_apply->Enable(Core::IsRunning());
@ -194,8 +211,7 @@ void wxCheatsWindow::Load_ARCodes()
void wxCheatsWindow::Load_GeckoCodes() void wxCheatsWindow::Load_GeckoCodes()
{ {
m_geckocode_panel->LoadCodes(m_gameini_default, m_gameini_local, m_geckocode_panel->LoadCodes(m_gameini_default, m_gameini_local, m_game_id, true);
SConfig::GetInstance().GetUniqueID(), true);
} }
void wxCheatsWindow::OnNewARCodeCreated(wxCommandEvent& ev) void wxCheatsWindow::OnNewARCodeCreated(wxCommandEvent& ev)
@ -243,7 +259,7 @@ void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev)
ev.Skip(); ev.Skip();
} }
void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED(event)) void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent&)
{ {
wxBeginBusyCursor(); wxBeginBusyCursor();
m_textctrl_log->Freeze(); m_textctrl_log->Freeze();
@ -284,7 +300,7 @@ void wxCheatsWindow::OnClearActionReplayLog(wxCommandEvent& event)
OnEvent_ButtonUpdateLog_Press(event); OnEvent_ButtonUpdateLog_Press(event);
} }
void wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange(wxCommandEvent& WXUNUSED(event)) void wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange(wxCommandEvent&)
{ {
ActionReplay::EnableSelfLogging(m_checkbox_log_ar->IsChecked()); ActionReplay::EnableSelfLogging(m_checkbox_log_ar->IsChecked());
} }

View File

@ -7,13 +7,13 @@
#include <cstddef> #include <cstddef>
#include <string> #include <string>
#include <vector> #include <vector>
#include <wx/arrstr.h>
#include <wx/dialog.h> #include <wx/dialog.h>
#include <wx/panel.h> #include <wx/panel.h>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/IniFile.h" #include "Common/IniFile.h"
class CheatSearchTab;
class wxButton; class wxButton;
class wxCheckBox; class wxCheckBox;
class wxNotebook; class wxNotebook;
@ -41,6 +41,7 @@ private:
wxButton* m_button_apply; wxButton* m_button_apply;
wxNotebook* m_notebook_main; wxNotebook* m_notebook_main;
CheatSearchTab* m_tab_cheat_search;
wxPanel* m_tab_log; wxPanel* m_tab_log;
wxCheckBox* m_checkbox_log_ar; wxCheckBox* m_checkbox_log_ar;
@ -57,7 +58,7 @@ private:
bool m_ignore_ini_callback = false; bool m_ignore_ini_callback = false;
void Init_ChildControls(); void CreateGUI();
void Load_ARCodes(); void Load_ARCodes();
void Load_GeckoCodes(); void Load_GeckoCodes();

View File

@ -19,8 +19,8 @@ CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address)
: wxDialog(parent, wxID_ANY, _("Create AR Code")), m_code_address(address) : wxDialog(parent, wxID_ANY, _("Create AR Code")), m_code_address(address)
{ {
wxStaticText* const label_name = new wxStaticText(this, wxID_ANY, _("Name: ")); wxStaticText* const label_name = new wxStaticText(this, wxID_ANY, _("Name: "));
m_textctrl_name = m_textctrl_name = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(256, -1)); wxDLG_UNIT(this, wxSize(180, -1)));
wxStaticText* const label_code = new wxStaticText(this, wxID_ANY, _("Code: ")); wxStaticText* const label_code = new wxStaticText(this, wxID_ANY, _("Code: "));
m_textctrl_code = new wxTextCtrl(this, wxID_ANY, wxString::Format("0x%08x", address)); m_textctrl_code = new wxTextCtrl(this, wxID_ANY, wxString::Format("0x%08x", address));
@ -33,22 +33,31 @@ CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address)
m_checkbox_use_hex->SetValue(true); m_checkbox_use_hex->SetValue(true);
wxBoxSizer* const sizer_value_label = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const sizer_value_label = new wxBoxSizer(wxHORIZONTAL);
sizer_value_label->Add(label_value, 0, wxRIGHT, 5); const int space5 = FromDIP(5);
sizer_value_label->Add(m_checkbox_use_hex); sizer_value_label->Add(label_value);
sizer_value_label->Add(m_checkbox_use_hex, 0, wxLEFT, space5);
// main sizer // main sizer
wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL);
sizer_main->Add(label_name, 0, wxALL, 5); sizer_main->AddSpacer(space5);
sizer_main->Add(m_textctrl_name, 0, wxALL, 5); sizer_main->Add(label_name, 0, wxLEFT | wxRIGHT, space5);
sizer_main->Add(label_code, 0, wxALL, 5); sizer_main->AddSpacer(space5);
sizer_main->Add(m_textctrl_code, 0, wxALL, 5); sizer_main->Add(m_textctrl_name, 0, wxLEFT | wxRIGHT, space5);
sizer_main->Add(sizer_value_label, 0, wxALL, 5); sizer_main->AddSpacer(space5);
sizer_main->Add(m_textctrl_value, 0, wxALL, 5); sizer_main->Add(label_code, 0, wxLEFT | wxRIGHT, space5);
sizer_main->Add(CreateButtonSizer(wxOK | wxCANCEL | wxNO_DEFAULT), 0, wxALL, 5); sizer_main->AddSpacer(space5);
sizer_main->Add(m_textctrl_code, 0, wxLEFT | wxRIGHT, space5);
sizer_main->AddSpacer(space5);
sizer_main->Add(sizer_value_label, 0, wxLEFT | wxRIGHT, space5);
sizer_main->AddSpacer(space5);
sizer_main->Add(m_textctrl_value, 0, wxLEFT | wxRIGHT, space5);
sizer_main->AddSpacer(space5);
sizer_main->Add(CreateButtonSizer(wxOK | wxCANCEL | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT,
space5);
sizer_main->AddSpacer(space5);
// NOTE: Use default wxCANCEL handling.
Bind(wxEVT_BUTTON, &CreateCodeDialog::PressOK, this, wxID_OK); Bind(wxEVT_BUTTON, &CreateCodeDialog::PressOK, this, wxID_OK);
Bind(wxEVT_BUTTON, &CreateCodeDialog::PressCancel, this, wxID_CANCEL);
Bind(wxEVT_CLOSE_WINDOW, &CreateCodeDialog::OnEvent_Close, this);
SetSizerAndFit(sizer_main); SetSizerAndFit(sizer_main);
SetFocus(); SetFocus();
@ -82,15 +91,6 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev)
add_event.SetClientData(&new_cheat); add_event.SetClientData(&new_cheat);
GetParent()->GetEventHandler()->ProcessEvent(add_event); GetParent()->GetEventHandler()->ProcessEvent(add_event);
Close(); // Allow base class to process. wxDialog will set the return code and hide the window.
} ev.Skip();
void CreateCodeDialog::PressCancel(wxCommandEvent& ev)
{
Close();
}
void CreateCodeDialog::OnEvent_Close(wxCloseEvent& ev)
{
Destroy();
} }

View File

@ -26,6 +26,4 @@ private:
wxCheckBox* m_checkbox_use_hex; wxCheckBox* m_checkbox_use_hex;
void PressOK(wxCommandEvent&); void PressOK(wxCommandEvent&);
void PressCancel(wxCommandEvent&);
void OnEvent_Close(wxCloseEvent& ev);
}; };

View File

@ -27,8 +27,9 @@ wxDEFINE_EVENT(DOLPHIN_EVT_GECKOCODE_TOGGLED, wxCommandEvent);
namespace Gecko namespace Gecko
{ {
static const wxString wxstr_name(wxTRANSLATE("Name: ")), wxstr_notes(wxTRANSLATE("Notes: ")), static const char str_name[] = wxTRANSLATE("Name: ");
wxstr_creator(wxTRANSLATE("Creator: ")); static const char str_notes[] = wxTRANSLATE("Notes: ");
static const char str_creator[] = wxTRANSLATE("Creator: ");
CodeConfigPanel::CodeConfigPanel(wxWindow* const parent) : wxPanel(parent) CodeConfigPanel::CodeConfigPanel(wxWindow* const parent) : wxPanel(parent)
{ {
@ -36,40 +37,41 @@ CodeConfigPanel::CodeConfigPanel(wxWindow* const parent) : wxPanel(parent)
m_listbox_gcodes->Bind(wxEVT_LISTBOX, &CodeConfigPanel::UpdateInfoBox, this); m_listbox_gcodes->Bind(wxEVT_LISTBOX, &CodeConfigPanel::UpdateInfoBox, this);
m_listbox_gcodes->Bind(wxEVT_CHECKLISTBOX, &CodeConfigPanel::ToggleCode, this); m_listbox_gcodes->Bind(wxEVT_CHECKLISTBOX, &CodeConfigPanel::ToggleCode, this);
m_infobox.label_name = new wxStaticText(this, wxID_ANY, wxGetTranslation(wxstr_name)); m_infobox.label_name = new wxStaticText(this, wxID_ANY, wxGetTranslation(str_name));
m_infobox.label_creator = new wxStaticText(this, wxID_ANY, wxGetTranslation(wxstr_creator)); m_infobox.label_creator = new wxStaticText(this, wxID_ANY, wxGetTranslation(str_creator));
m_infobox.label_notes = new wxStaticText(this, wxID_ANY, wxGetTranslation(wxstr_notes)); m_infobox.label_notes = new wxStaticText(this, wxID_ANY, wxGetTranslation(str_notes));
m_infobox.textctrl_notes = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, m_infobox.textctrl_notes = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxSize(64, -1), wxTE_MULTILINE | wxTE_READONLY); wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
m_infobox.listbox_codes = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 64)); m_infobox.listbox_codes =
new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, 48)));
// TODO: buttons to add/edit codes // TODO: buttons to add/edit codes
// sizers // sizers
const int space5 = FromDIP(5);
wxBoxSizer* const sizer_infobox = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const sizer_infobox = new wxBoxSizer(wxVERTICAL);
sizer_infobox->Add(m_infobox.label_name, 0, wxBOTTOM, 5); sizer_infobox->Add(m_infobox.label_name);
sizer_infobox->Add(m_infobox.label_creator, 0, wxBOTTOM, 5); sizer_infobox->Add(m_infobox.label_creator, 0, wxTOP, space5);
sizer_infobox->Add(m_infobox.label_notes, 0, wxBOTTOM, 5); sizer_infobox->Add(m_infobox.label_notes, 0, wxTOP, space5);
sizer_infobox->Add(m_infobox.textctrl_notes, 0, wxBOTTOM | wxEXPAND, 5); sizer_infobox->Add(m_infobox.textctrl_notes, 0, wxEXPAND | wxTOP, space5);
sizer_infobox->Add(m_infobox.listbox_codes, 1, wxEXPAND, 5); sizer_infobox->Add(m_infobox.listbox_codes, 1, wxEXPAND | wxTOP, space5);
// button sizer // button sizer
wxBoxSizer* const sizer_buttons = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const sizer_buttons = new wxBoxSizer(wxHORIZONTAL);
btn_download = new wxButton(this, wxID_ANY, _("Download Codes (WiiRD Database)"), btn_download = new wxButton(this, wxID_ANY, _("Download Codes (WiiRD Database)"));
wxDefaultPosition, wxSize(128, -1));
btn_download->Disable(); btn_download->Disable();
btn_download->Bind(wxEVT_BUTTON, &CodeConfigPanel::DownloadCodes, this); btn_download->Bind(wxEVT_BUTTON, &CodeConfigPanel::DownloadCodes, this);
sizer_buttons->AddStretchSpacer(1); sizer_buttons->AddStretchSpacer(1);
sizer_buttons->Add(btn_download, 1, wxEXPAND); sizer_buttons->Add(WxUtils::GiveMinSizeDIP(btn_download, wxSize(128, -1)), 1, wxEXPAND);
// horizontal sizer
wxBoxSizer* const sizer_vert = new wxBoxSizer(wxVERTICAL);
sizer_vert->Add(sizer_infobox, 1, wxEXPAND);
sizer_vert->Add(sizer_buttons, 0, wxEXPAND | wxTOP, 5);
wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL);
sizer_main->Add(m_listbox_gcodes, 1, wxALL | wxEXPAND, 5); sizer_main->AddSpacer(space5);
sizer_main->Add(sizer_vert, 0, wxALL | wxEXPAND, 5); sizer_main->Add(m_listbox_gcodes, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
sizer_main->AddSpacer(space5);
sizer_main->Add(sizer_infobox, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
sizer_main->AddSpacer(space5);
sizer_main->Add(sizer_buttons, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
sizer_main->AddSpacer(space5);
SetSizerAndFit(sizer_main); SetSizerAndFit(sizer_main);
} }
@ -83,7 +85,7 @@ void CodeConfigPanel::UpdateCodeList(bool checkRunning)
// add the codes to the listbox // add the codes to the listbox
for (const GeckoCode& code : m_gcodes) for (const GeckoCode& code : m_gcodes)
{ {
m_listbox_gcodes->Append(StrToWxStr(code.name)); m_listbox_gcodes->Append(m_listbox_gcodes->EscapeMnemonics(StrToWxStr(code.name)));
if (code.enabled) if (code.enabled)
{ {
m_listbox_gcodes->Check(m_listbox_gcodes->GetCount() - 1, true); m_listbox_gcodes->Check(m_listbox_gcodes->GetCount() - 1, true);
@ -126,7 +128,7 @@ void CodeConfigPanel::UpdateInfoBox(wxCommandEvent&)
if (sel > -1) if (sel > -1)
{ {
m_infobox.label_name->SetLabel(wxGetTranslation(wxstr_name) + StrToWxStr(m_gcodes[sel].name)); m_infobox.label_name->SetLabel(wxGetTranslation(str_name) + StrToWxStr(m_gcodes[sel].name));
// notes textctrl // notes textctrl
m_infobox.textctrl_notes->Clear(); m_infobox.textctrl_notes->Clear();
@ -136,7 +138,7 @@ void CodeConfigPanel::UpdateInfoBox(wxCommandEvent&)
} }
m_infobox.textctrl_notes->ScrollLines(-99); // silly m_infobox.textctrl_notes->ScrollLines(-99); // silly
m_infobox.label_creator->SetLabel(wxGetTranslation(wxstr_creator) + m_infobox.label_creator->SetLabel(wxGetTranslation(str_creator) +
StrToWxStr(m_gcodes[sel].creator)); StrToWxStr(m_gcodes[sel].creator));
// add codes to info listbox // add codes to info listbox
@ -147,9 +149,9 @@ void CodeConfigPanel::UpdateInfoBox(wxCommandEvent&)
} }
else else
{ {
m_infobox.label_name->SetLabel(wxGetTranslation(wxstr_name)); m_infobox.label_name->SetLabel(wxGetTranslation(str_name));
m_infobox.textctrl_notes->Clear(); m_infobox.textctrl_notes->Clear();
m_infobox.label_creator->SetLabel(wxGetTranslation(wxstr_creator)); m_infobox.label_creator->SetLabel(wxGetTranslation(str_creator));
} }
} }