mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Opps, forgot to add the files.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1334 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ca3e5befd9
commit
2f528a3de4
178
Source/Core/DolphinWX/Src/CheatsWindow.cpp
Normal file
178
Source/Core/DolphinWX/Src/CheatsWindow.cpp
Normal file
@ -0,0 +1,178 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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, version 2.0.
|
||||
|
||||
// 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 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CheatsWindow.h"
|
||||
#include "ActionReplay.h"
|
||||
#include "Core.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(wxCheatsWindow, wxWindow)
|
||||
EVT_SIZE( wxCheatsWindow::OnEvent_Window_Resize)
|
||||
EVT_CLOSE( wxCheatsWindow::OnEvent_Window_Close)
|
||||
EVT_BUTTON(ID_BUTTON_CLOSE, wxCheatsWindow::OnEvent_ButtonClose_Press)
|
||||
EVT_LISTBOX(ID_CHECKLISTBOX_CHEATSLIST, wxCheatsWindow::OnEvent_CheatsList_ItemSelected)
|
||||
EVT_CHECKLISTBOX(ID_CHECKLISTBOX_CHEATSLIST, wxCheatsWindow::OnEvent_CheatsList_ItemToggled)
|
||||
EVT_BUTTON(ID_BUTTON_APPLYCODES, wxCheatsWindow::OnEvent_ButtonUpdateCodes_Press)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxCheatsWindow::wxCheatsWindow(wxFrame* parent, const wxPoint& pos, const wxSize& size) : wxFrame(parent, wxID_ANY, _T("Action Replay"), pos, size, wxCHEATSWINDOW_STYLE)
|
||||
{
|
||||
// Create the GUI controls
|
||||
Init_ChildControls();
|
||||
|
||||
// Setup Window
|
||||
SetBackgroundColour(m_Notebook_Main->GetBackgroundColour());
|
||||
SetSize(size);
|
||||
SetPosition(pos);
|
||||
|
||||
// Load Data
|
||||
Load_ARCodes();
|
||||
|
||||
Layout();
|
||||
Show();
|
||||
}
|
||||
|
||||
wxCheatsWindow::~wxCheatsWindow()
|
||||
{
|
||||
// On Disposal
|
||||
}
|
||||
|
||||
void wxCheatsWindow::Init_ChildControls()
|
||||
{
|
||||
// Main Notebook
|
||||
m_Notebook_Main = new wxNotebook(this, ID_NOTEBOOK_MAIN, wxDefaultPosition, wxDefaultSize);
|
||||
// --- Tabs ---
|
||||
// $ Cheats List Tab
|
||||
m_Tab_Cheats = new wxPanel(m_Notebook_Main, ID_TAB_CHEATS, wxDefaultPosition, wxDefaultSize);
|
||||
m_CheckListBox_CheatsList = new wxCheckListBox(m_Tab_Cheats, ID_CHECKLISTBOX_CHEATSLIST, wxDefaultPosition, wxSize(300, 0), m_CheatStringList, wxLB_HSCROLL, wxDefaultValidator);
|
||||
m_Label_Codename = new wxStaticText(m_Tab_Cheats, ID_LABEL_CODENAME, _T("Name: "), wxDefaultPosition, wxDefaultSize);
|
||||
m_GroupBox_Info = new wxStaticBox(m_Tab_Cheats, ID_GROUPBOX_INFO, _T("Code Info"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Button_ApplyCodes = new wxButton(m_Tab_Cheats, ID_BUTTON_APPLYCODES, _T("Apply Changes"), wxDefaultPosition, wxDefaultSize);
|
||||
m_Label_NumCodes = new wxStaticText(m_Tab_Cheats, ID_LABEL_NUMCODES, _T("Number Of Codes: "), wxDefaultPosition, wxDefaultSize);
|
||||
m_ListBox_CodesList = new wxListBox(m_Tab_Cheats, ID_LISTBOX_CODESLIST, wxDefaultPosition, wxSize(120, 150), 0, 0, wxLB_HSCROLL);
|
||||
|
||||
wxBoxSizer* sCheatsListH = new wxBoxSizer(wxHORIZONTAL);
|
||||
sCheatsListH->Add(m_CheckListBox_CheatsList, 1, wxALL|wxEXPAND, 5);
|
||||
|
||||
wxStaticBoxSizer* sGroupBoxInfo = new wxStaticBoxSizer(m_GroupBox_Info, wxVERTICAL);
|
||||
sGroupBoxInfo->Add(m_Label_Codename, 0, wxALL, 5);
|
||||
sGroupBoxInfo->Add(m_Label_NumCodes, 0, wxALL, 5);
|
||||
sGroupBoxInfo->Add(m_ListBox_CodesList, 0, wxALL, 5);
|
||||
|
||||
wxBoxSizer* sB1 = new wxBoxSizer(wxVERTICAL);
|
||||
sB1->Add(m_Button_ApplyCodes, 0, wxALL, 5);
|
||||
sB1->Add(sGroupBoxInfo, 0, wxALL, 5);
|
||||
|
||||
m_Sizer_TabCheats = new wxGridBagSizer();
|
||||
m_Sizer_TabCheats->AddGrowableRow(0);
|
||||
m_Sizer_TabCheats->Add(sCheatsListH, wxGBPosition(0, 0), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
||||
m_Sizer_TabCheats->Add(sB1, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_LEFT|wxALL, 5);
|
||||
|
||||
m_Tab_Cheats->SetSizer(m_Sizer_TabCheats);
|
||||
m_Tab_Cheats->Layout();
|
||||
|
||||
|
||||
// $ Log Tab
|
||||
m_Tab_Log = new wxPanel(m_Notebook_Main, ID_TAB_LOG, wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
// Add Tabs to Notebook
|
||||
m_Notebook_Main->AddPage(m_Tab_Cheats, _T("Codes List"));
|
||||
m_Notebook_Main->AddPage(m_Tab_Log, _T("Logging"));
|
||||
|
||||
// Button Strip
|
||||
m_Button_Close = new wxButton(this, ID_BUTTON_CLOSE, _T("Close"), wxDefaultPosition, wxDefaultSize);
|
||||
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
|
||||
sButtons->Add(m_Button_Close, 0, wxALL, 5);
|
||||
|
||||
wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
|
||||
sMain->Add(m_Notebook_Main, 1, wxEXPAND|wxALL, 5);
|
||||
sMain->Add(sButtons, 0, wxALL, 5);
|
||||
SetSizer(sMain);
|
||||
Layout();
|
||||
|
||||
Fit();
|
||||
}
|
||||
void wxCheatsWindow::OnEvent_Window_Resize(wxSizeEvent& WXUNUSED (event))
|
||||
{
|
||||
Layout();
|
||||
}
|
||||
void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
void wxCheatsWindow::OnEvent_Window_Close(wxCloseEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
void wxCheatsWindow::Load_ARCodes()
|
||||
{
|
||||
indexList.clear();
|
||||
size_t size = ActionReplay_GetCodeListSize();
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
ARCode code = ActionReplay_GetARCode(i);
|
||||
ARCodeIndex ind;
|
||||
u32 index = m_CheckListBox_CheatsList->Append(wxString::FromAscii(code.name.c_str()));
|
||||
m_CheckListBox_CheatsList->Check(index, code.active);
|
||||
ind.index = i;
|
||||
ind.uiIndex = index;
|
||||
indexList.push_back(ind);
|
||||
}
|
||||
}
|
||||
void wxCheatsWindow::OnEvent_CheatsList_ItemSelected(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
int index = m_CheckListBox_CheatsList->GetSelection();
|
||||
for (size_t i = 0; i < indexList.size(); i++)
|
||||
{
|
||||
if ((int)indexList[i].uiIndex == index)
|
||||
{
|
||||
ARCode code = ActionReplay_GetARCode(i);
|
||||
m_Label_Codename->SetLabel("Name: " + wxString::FromAscii(code.name.c_str()));
|
||||
char text[CHAR_MAX];
|
||||
char* numcodes = text;
|
||||
sprintf(numcodes, "Number of Codes: %i", code.ops.size());
|
||||
m_Label_NumCodes->SetLabel(numcodes);
|
||||
m_ListBox_CodesList->Clear();
|
||||
for (size_t j = 0; j < code.ops.size(); j++)
|
||||
{
|
||||
char text2[CHAR_MAX];
|
||||
char* ops = text2;
|
||||
sprintf(ops, "%08x %08x", code.ops[j].cmd_addr, code.ops[j].value);
|
||||
m_ListBox_CodesList->Append(ops);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Sizer_TabCheats->Layout();
|
||||
}
|
||||
void wxCheatsWindow::OnEvent_CheatsList_ItemToggled(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
int index = m_CheckListBox_CheatsList->GetSelection();
|
||||
for (size_t i = 0; i < indexList.size(); i++)
|
||||
{
|
||||
if ((int)indexList[i].uiIndex == index)
|
||||
{
|
||||
ActionReplay_SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(index), indexList[i].index);
|
||||
}
|
||||
}
|
||||
}
|
||||
void wxCheatsWindow::OnEvent_ButtonUpdateCodes_Press(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
for (size_t i = 0; i < indexList.size(); i++)
|
||||
{
|
||||
ActionReplay_SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(indexList[i].uiIndex), indexList[i].index);
|
||||
}
|
||||
}
|
119
Source/Core/DolphinWX/Src/CheatsWindow.h
Normal file
119
Source/Core/DolphinWX/Src/CheatsWindow.h
Normal file
@ -0,0 +1,119 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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, version 2.0.
|
||||
|
||||
// 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 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef __CHEATSWINDOW_H__
|
||||
#define __CHEATSWINDOW_H__
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <string>
|
||||
|
||||
#include "ActionReplay.h"
|
||||
|
||||
#include "Filesystem.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#undef wxCHEATSWINDOW_STYLE
|
||||
#define wxCHEATSWINDOW_STYLE wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE
|
||||
|
||||
class wxCheatsWindow : public wxFrame
|
||||
{
|
||||
public:
|
||||
|
||||
wxCheatsWindow(wxFrame* parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||
|
||||
virtual ~wxCheatsWindow();
|
||||
|
||||
protected:
|
||||
|
||||
struct ARCodeIndex {
|
||||
u32 uiIndex;
|
||||
size_t index;
|
||||
};
|
||||
|
||||
// Event Table
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
// --- GUI Controls ---
|
||||
wxGridBagSizer* m_Sizer_TabCheats;
|
||||
|
||||
wxNotebook *m_Notebook_Main;
|
||||
|
||||
wxPanel *m_Tab_Cheats;
|
||||
wxPanel *m_Tab_Log;
|
||||
|
||||
wxButton *m_Button_Close;
|
||||
wxButton *m_Button_ApplyCodes;
|
||||
|
||||
wxStaticText *m_Label_Codename;
|
||||
wxStaticText *m_Label_NumCodes;
|
||||
|
||||
wxCheckListBox *m_CheckListBox_CheatsList;
|
||||
|
||||
wxListBox *m_ListBox_CodesList;
|
||||
|
||||
wxStaticBox *m_GroupBox_Info;
|
||||
|
||||
wxArrayString m_CheatStringList;
|
||||
|
||||
std::vector<ARCodeIndex> indexList;
|
||||
|
||||
// GUI IDs
|
||||
enum
|
||||
{
|
||||
ID_NOTEBOOK_MAIN,
|
||||
ID_TAB_CHEATS,
|
||||
ID_TAB_LOG,
|
||||
ID_BUTTON_CLOSE,
|
||||
ID_CHECKLISTBOX_CHEATSLIST,
|
||||
ID_LABEL_CODENAME,
|
||||
ID_GROUPBOX_INFO,
|
||||
ID_BUTTON_APPLYCODES,
|
||||
ID_LABEL_NUMCODES,
|
||||
ID_LISTBOX_CODESLIST
|
||||
};
|
||||
|
||||
void Init_ChildControls();
|
||||
|
||||
void Load_ARCodes();
|
||||
|
||||
// --- Wx Events Handlers ---
|
||||
// $ Window
|
||||
void OnEvent_Window_Resize(wxSizeEvent& event);
|
||||
void OnEvent_Window_Close(wxCloseEvent& event);
|
||||
|
||||
// $ Close Button
|
||||
void OnEvent_ButtonClose_Press(wxCommandEvent& event);
|
||||
|
||||
// $ Cheats List
|
||||
void OnEvent_CheatsList_ItemSelected(wxCommandEvent& event);
|
||||
void OnEvent_CheatsList_ItemToggled(wxCommandEvent& event);
|
||||
|
||||
// $ Update Active Codes Button
|
||||
void OnEvent_ButtonUpdateCodes_Press(wxCommandEvent& event);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user