mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Update svn:eol-style=native ( r1442 ) for Source/*.cpp
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2384 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,145 +1,145 @@
|
||||
// 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 "ARCodeAddEdit.h"
|
||||
|
||||
extern std::vector<ActionReplay::ARCode> arCodes;
|
||||
|
||||
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
|
||||
EVT_CLOSE(CARCodeAddEdit::OnClose)
|
||||
EVT_BUTTON(wxID_OK, CARCodeAddEdit::SaveCheatData)
|
||||
EVT_SPIN(ID_ENTRY_SELECT, CARCodeAddEdit::ChangeEntry)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CARCodeAddEdit::CARCodeAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
||||
: wxDialog(parent, id, title, position, size, style)
|
||||
{
|
||||
selection = _selection;
|
||||
CreateGUIControls(selection);
|
||||
}
|
||||
|
||||
CARCodeAddEdit::~CARCodeAddEdit()
|
||||
{
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::CreateGUIControls(int _selection)
|
||||
{
|
||||
wxString currentName = wxT("<Insert name here>");
|
||||
|
||||
if (_selection == -1)
|
||||
{
|
||||
tempEntries.name = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
currentName = wxString::FromAscii(arCodes.at(_selection).name.c_str());
|
||||
tempEntries = arCodes.at(_selection);
|
||||
}
|
||||
|
||||
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
|
||||
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Code"));
|
||||
wxStaticText* EditCheatNameText = new wxStaticText(this, ID_EDITCHEAT_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize);
|
||||
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
||||
EditCheatName->SetValue(currentName);
|
||||
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL);
|
||||
EntrySelection->SetRange(0, (int)arCodes.size()-1);
|
||||
EntrySelection->SetValue((int)arCodes.size()-1 - _selection);
|
||||
EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
|
||||
UpdateTextCtrl(tempEntries);
|
||||
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
||||
sgEntry->AddGrowableCol(1);
|
||||
sgEntry->AddGrowableRow(1);
|
||||
sgEntry->Add(EditCheatNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxALL, 5);
|
||||
sgEntry->Add(EditCheatName, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
||||
sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(2, 1), wxEXPAND|wxALL, 5);
|
||||
sgEntry->Add(EditCheatCode, wxGBPosition(1, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
|
||||
sbEntry->Add(sgEntry, 1, wxEXPAND);
|
||||
sEditCheat->Add(sbEntry, 1, wxEXPAND|wxALL, 5);
|
||||
wxBoxSizer* sEditCheatButtons = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxButton* bOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
wxButton* bCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
sEditCheatButtons->Add(0, 0, 1, wxEXPAND, 5);
|
||||
sEditCheatButtons->Add(bOK, 0, wxALL, 5);
|
||||
sEditCheatButtons->Add(bCancel, 0, wxALL, 5);
|
||||
sEditCheat->Add(sEditCheatButtons, 0, wxEXPAND, 5);
|
||||
this->SetSizer(sEditCheat);
|
||||
sEditCheat->Layout();
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::OnClose(wxCloseEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
|
||||
{
|
||||
ActionReplay::ARCode currentCode = arCodes.at((int)arCodes.size()-1 - event.GetPosition());
|
||||
EditCheatName->SetValue(wxString::FromAscii(currentCode.name.c_str()));
|
||||
UpdateTextCtrl(currentCode);
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
|
||||
std::vector<ActionReplay::AREntry> tempEntries;
|
||||
std::string cheatValues = std::string(EditCheatCode->GetValue().mb_str());
|
||||
bool bWhile = true; size_t line = 0;
|
||||
|
||||
while (bWhile)
|
||||
{
|
||||
bWhile = false;
|
||||
u32 addr, value;
|
||||
|
||||
addr = strtol(std::string(cheatValues.substr(line, line+8)).c_str(), NULL, 16); // cmd_addr of ArCode
|
||||
value = strtol(std::string(cheatValues.substr(line+9, line+17)).c_str(), NULL, 16); // value of ArCode
|
||||
|
||||
tempEntries.push_back(ActionReplay::AREntry(addr, value));
|
||||
|
||||
line = cheatValues.find("\n", line);
|
||||
|
||||
if (line != std::string::npos && cheatValues.length() > (line+17))
|
||||
bWhile = true; // newline found, if not empty, go on
|
||||
|
||||
line++;
|
||||
}
|
||||
|
||||
if (selection == -1)
|
||||
{
|
||||
ActionReplay::ARCode newCheat;
|
||||
newCheat.name = std::string(EditCheatName->GetValue().mb_str());
|
||||
newCheat.ops = tempEntries;
|
||||
|
||||
newCheat.active = true;
|
||||
|
||||
arCodes.push_back(newCheat);
|
||||
}
|
||||
else
|
||||
{
|
||||
arCodes.at(selection).name = std::string(EditCheatName->GetValue().mb_str());
|
||||
arCodes.at(selection).ops = tempEntries;
|
||||
}
|
||||
|
||||
AcceptAndClose();
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
|
||||
{
|
||||
EditCheatCode->Clear();
|
||||
|
||||
for (u32 i = 0; i < arCode.ops.size(); i++)
|
||||
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), arCode.ops.at(i).cmd_addr, arCode.ops.at(i).value));
|
||||
}
|
||||
// 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 "ARCodeAddEdit.h"
|
||||
|
||||
extern std::vector<ActionReplay::ARCode> arCodes;
|
||||
|
||||
BEGIN_EVENT_TABLE(CARCodeAddEdit, wxDialog)
|
||||
EVT_CLOSE(CARCodeAddEdit::OnClose)
|
||||
EVT_BUTTON(wxID_OK, CARCodeAddEdit::SaveCheatData)
|
||||
EVT_SPIN(ID_ENTRY_SELECT, CARCodeAddEdit::ChangeEntry)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CARCodeAddEdit::CARCodeAddEdit(int _selection, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
||||
: wxDialog(parent, id, title, position, size, style)
|
||||
{
|
||||
selection = _selection;
|
||||
CreateGUIControls(selection);
|
||||
}
|
||||
|
||||
CARCodeAddEdit::~CARCodeAddEdit()
|
||||
{
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::CreateGUIControls(int _selection)
|
||||
{
|
||||
wxString currentName = wxT("<Insert name here>");
|
||||
|
||||
if (_selection == -1)
|
||||
{
|
||||
tempEntries.name = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
currentName = wxString::FromAscii(arCodes.at(_selection).name.c_str());
|
||||
tempEntries = arCodes.at(_selection);
|
||||
}
|
||||
|
||||
wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL);
|
||||
wxStaticBoxSizer* sbEntry = new wxStaticBoxSizer(wxVERTICAL, this, _("Code"));
|
||||
wxStaticText* EditCheatNameText = new wxStaticText(this, ID_EDITCHEAT_NAME_TEXT, _("Name:"), wxDefaultPosition, wxDefaultSize);
|
||||
EditCheatName = new wxTextCtrl(this, ID_EDITCHEAT_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
|
||||
EditCheatName->SetValue(currentName);
|
||||
EntrySelection = new wxSpinButton(this, ID_ENTRY_SELECT, wxDefaultPosition, wxDefaultSize, wxVERTICAL);
|
||||
EntrySelection->SetRange(0, (int)arCodes.size()-1);
|
||||
EntrySelection->SetValue((int)arCodes.size()-1 - _selection);
|
||||
EditCheatCode = new wxTextCtrl(this, ID_EDITCHEAT_CODE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
|
||||
UpdateTextCtrl(tempEntries);
|
||||
wxGridBagSizer* sgEntry = new wxGridBagSizer(0, 0);
|
||||
sgEntry->AddGrowableCol(1);
|
||||
sgEntry->AddGrowableRow(1);
|
||||
sgEntry->Add(EditCheatNameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxEXPAND|wxALL, 5);
|
||||
sgEntry->Add(EditCheatName, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
|
||||
sgEntry->Add(EntrySelection, wxGBPosition(0, 2), wxGBSpan(2, 1), wxEXPAND|wxALL, 5);
|
||||
sgEntry->Add(EditCheatCode, wxGBPosition(1, 0), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
|
||||
sbEntry->Add(sgEntry, 1, wxEXPAND);
|
||||
sEditCheat->Add(sbEntry, 1, wxEXPAND|wxALL, 5);
|
||||
wxBoxSizer* sEditCheatButtons = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxButton* bOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
wxButton* bCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
sEditCheatButtons->Add(0, 0, 1, wxEXPAND, 5);
|
||||
sEditCheatButtons->Add(bOK, 0, wxALL, 5);
|
||||
sEditCheatButtons->Add(bCancel, 0, wxALL, 5);
|
||||
sEditCheat->Add(sEditCheatButtons, 0, wxEXPAND, 5);
|
||||
this->SetSizer(sEditCheat);
|
||||
sEditCheat->Layout();
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::OnClose(wxCloseEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
|
||||
{
|
||||
ActionReplay::ARCode currentCode = arCodes.at((int)arCodes.size()-1 - event.GetPosition());
|
||||
EditCheatName->SetValue(wxString::FromAscii(currentCode.name.c_str()));
|
||||
UpdateTextCtrl(currentCode);
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
|
||||
std::vector<ActionReplay::AREntry> tempEntries;
|
||||
std::string cheatValues = std::string(EditCheatCode->GetValue().mb_str());
|
||||
bool bWhile = true; size_t line = 0;
|
||||
|
||||
while (bWhile)
|
||||
{
|
||||
bWhile = false;
|
||||
u32 addr, value;
|
||||
|
||||
addr = strtol(std::string(cheatValues.substr(line, line+8)).c_str(), NULL, 16); // cmd_addr of ArCode
|
||||
value = strtol(std::string(cheatValues.substr(line+9, line+17)).c_str(), NULL, 16); // value of ArCode
|
||||
|
||||
tempEntries.push_back(ActionReplay::AREntry(addr, value));
|
||||
|
||||
line = cheatValues.find("\n", line);
|
||||
|
||||
if (line != std::string::npos && cheatValues.length() > (line+17))
|
||||
bWhile = true; // newline found, if not empty, go on
|
||||
|
||||
line++;
|
||||
}
|
||||
|
||||
if (selection == -1)
|
||||
{
|
||||
ActionReplay::ARCode newCheat;
|
||||
newCheat.name = std::string(EditCheatName->GetValue().mb_str());
|
||||
newCheat.ops = tempEntries;
|
||||
|
||||
newCheat.active = true;
|
||||
|
||||
arCodes.push_back(newCheat);
|
||||
}
|
||||
else
|
||||
{
|
||||
arCodes.at(selection).name = std::string(EditCheatName->GetValue().mb_str());
|
||||
arCodes.at(selection).ops = tempEntries;
|
||||
}
|
||||
|
||||
AcceptAndClose();
|
||||
}
|
||||
|
||||
void CARCodeAddEdit::UpdateTextCtrl(ActionReplay::ARCode arCode)
|
||||
{
|
||||
EditCheatCode->Clear();
|
||||
|
||||
for (u32 i = 0; i < arCode.ops.size(); i++)
|
||||
EditCheatCode->AppendText(wxString::Format(wxT("%08X %08X\n"), arCode.ops.at(i).cmd_addr, arCode.ops.at(i).value));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,484 +1,484 @@
|
||||
// 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
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include "Globals.h"
|
||||
#include "Frame.h"
|
||||
#include "FileUtil.h"
|
||||
#include "StringUtil.h"
|
||||
#include "ConsoleWindow.h"
|
||||
|
||||
#include "GameListCtrl.h"
|
||||
#include "BootManager.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "Setup.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "Core.h"
|
||||
#include "State.h"
|
||||
#include "ConfigMain.h"
|
||||
#include "PluginManager.h"
|
||||
#include "MemcardManager.h"
|
||||
#include "CheatsWindow.h"
|
||||
#include "AboutDolphin.h"
|
||||
|
||||
#include <wx/statusbr.h>
|
||||
/////////////////////////////////////////
|
||||
|
||||
|
||||
namespace WiimoteLeds
|
||||
{
|
||||
int LED_SIZE_X = 8;
|
||||
int LED_SIZE_Y = 8;
|
||||
int SPEAKER_SIZE_X = 8;
|
||||
int SPEAKER_SIZE_Y = 8;
|
||||
|
||||
int ConnectionStatusWidth = 103; // These widths need to be revised, for vista at least
|
||||
int ConnectionStatusOnlyAdj = 7;
|
||||
int RightmostMargin = 6;
|
||||
int SpIconMargin = 11;
|
||||
int LedIconMargin = 11;
|
||||
|
||||
// The necessary recording status width, allow Frame to be at last of the form 100,000
|
||||
#ifdef RERECORDING
|
||||
static const int RerecordingStatusWidth = 340;
|
||||
#endif
|
||||
|
||||
// Leds only
|
||||
static const int LdWidthsOn[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth,
|
||||
(LedIconMargin + LED_SIZE_X) * 4 + RightmostMargin
|
||||
};
|
||||
static const int StylesFieldOn[] = { wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL };
|
||||
|
||||
// Speakers only
|
||||
static const int SpWidthsOn[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth,
|
||||
( SpIconMargin + SPEAKER_SIZE_X ) * 3 + RightmostMargin
|
||||
};
|
||||
static const int SpStylesFieldOn[] = { wxSB_NORMAL,
|
||||
#ifdef RERECORDING
|
||||
wxSB_NORMAL,
|
||||
#endif
|
||||
wxSB_NORMAL, wxSB_NORMAL };
|
||||
|
||||
// Both
|
||||
static const int LdSpWidthsOn[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth,
|
||||
(SpIconMargin + SPEAKER_SIZE_X) * 3,
|
||||
(LedIconMargin + LED_SIZE_X) * 4 + RightmostMargin
|
||||
};
|
||||
static const int LdSpStylesFieldOn[] = { wxSB_NORMAL,
|
||||
#ifdef RERECORDING
|
||||
wxSB_NORMAL,
|
||||
#endif
|
||||
wxSB_NORMAL, wxSB_NORMAL };
|
||||
|
||||
// Only the Wiimote connection Status
|
||||
static const int WidthsOff[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth + ConnectionStatusOnlyAdj + RightmostMargin
|
||||
};
|
||||
static const int StylesFieldOff[] = { wxSB_NORMAL,
|
||||
#ifdef RERECORDING
|
||||
wxSB_NORMAL,
|
||||
#endif
|
||||
wxSB_NORMAL };
|
||||
|
||||
// GC mode
|
||||
static const int WidthsOffGC[] = { -1
|
||||
#ifdef RERECORDING
|
||||
, RerecordingStatusWidth
|
||||
#endif
|
||||
};
|
||||
static const int StylesFieldOffGC[] = { wxSB_NORMAL
|
||||
#ifdef RERECORDING
|
||||
, wxSB_NORMAL
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
// =======================================================
|
||||
// Modify status bar
|
||||
// -------------
|
||||
void CFrame::ModifyStatusBar()
|
||||
{
|
||||
// Get settings
|
||||
bool LedsOn = SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiLeds;
|
||||
bool SpeakersOn = SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiSpeakers;
|
||||
|
||||
// Don't use this for GC games, or before a game is loaded
|
||||
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
{ LedsOn = false; SpeakersOn = false; }
|
||||
|
||||
// Declarations
|
||||
int Fields = 0;
|
||||
int *Widths = 0;
|
||||
int *StylesFields = 0;
|
||||
|
||||
// ---------------------------------------
|
||||
// Leds only
|
||||
// -------------
|
||||
if(LedsOn && !SpeakersOn)
|
||||
{
|
||||
Fields = 3;
|
||||
Widths = (int*)WiimoteLeds::LdWidthsOn;
|
||||
StylesFields = (int*)WiimoteLeds::StylesFieldOn;
|
||||
}
|
||||
// ---------------------------------------
|
||||
// Speaker only
|
||||
// -------------
|
||||
else if(!LedsOn && SpeakersOn)
|
||||
{
|
||||
Fields = 3;
|
||||
Widths = (int*)WiimoteLeds::SpWidthsOn;
|
||||
StylesFields = (int*)WiimoteLeds::SpStylesFieldOn;
|
||||
}
|
||||
// ---------------------------------------
|
||||
// Both on
|
||||
// -------------
|
||||
else if(LedsOn && SpeakersOn)
|
||||
{
|
||||
Fields = 4;
|
||||
Widths = (int*)WiimoteLeds::LdSpWidthsOn;
|
||||
StylesFields = (int*)WiimoteLeds::LdSpStylesFieldOn;
|
||||
}
|
||||
// ---------------------------------------
|
||||
// Both off
|
||||
// -------------
|
||||
else if(!LedsOn && !SpeakersOn)
|
||||
{
|
||||
Fields = 2;
|
||||
Widths = (int*)WiimoteLeds::WidthsOff;
|
||||
StylesFields = (int*)WiimoteLeds::StylesFieldOff;
|
||||
|
||||
// Maybe we should even go down to one field
|
||||
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
{
|
||||
Fields = 1;
|
||||
Widths = (int*)WiimoteLeds::WidthsOffGC;
|
||||
StylesFields = (int*)WiimoteLeds::StylesFieldOffGC;
|
||||
}
|
||||
}
|
||||
|
||||
// Add a filed for the rerecording status
|
||||
#ifdef RERECORDING
|
||||
Fields++;
|
||||
#endif
|
||||
|
||||
// Update the settings
|
||||
m_pStatusBar->SetFieldsCount(Fields);
|
||||
m_pStatusBar->SetStatusWidths(Fields, Widths);
|
||||
m_pStatusBar->SetStatusStyles(Fields, StylesFields);
|
||||
|
||||
/* Destroy and create all, and check for HaveLeds and HaveSpeakers in case we have
|
||||
gotten a confirmed on or off setting, in which case we don't do anything */
|
||||
if(!LedsOn && HaveLeds) CreateDestroy(DESTROYLEDS);
|
||||
if(!SpeakersOn && HaveSpeakers) CreateDestroy(DESTROYSPEAKERS);
|
||||
if(LedsOn && !HaveLeds) CreateDestroy(CREATELEDS);
|
||||
if(SpeakersOn && !HaveSpeakers) CreateDestroy(CREATESPEAKERS);
|
||||
|
||||
DoMoveIcons();
|
||||
m_pStatusBar->Refresh(); // avoid small glitches that can occur
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create and destroy leds and speakers icons
|
||||
// -------------
|
||||
void CFrame::CreateDestroy(int Case)
|
||||
{
|
||||
switch(Case)
|
||||
{
|
||||
case CREATELEDS:
|
||||
{
|
||||
CreateLeds();
|
||||
UpdateLeds();
|
||||
HaveLeds = true;
|
||||
break;
|
||||
}
|
||||
case DESTROYLEDS:
|
||||
{
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
m_StatBmp[i]->Destroy();
|
||||
}
|
||||
HaveLeds = false;
|
||||
break;
|
||||
}
|
||||
case CREATESPEAKERS:
|
||||
{
|
||||
CreateSpeakers();
|
||||
HaveSpeakers = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case DESTROYSPEAKERS:
|
||||
{
|
||||
for(int i = 4; i < 7; i++)
|
||||
{
|
||||
m_StatBmp[i]->Destroy();
|
||||
}
|
||||
HaveSpeakers = false;
|
||||
break;
|
||||
}
|
||||
} // end of switch
|
||||
|
||||
DoMoveIcons();
|
||||
}
|
||||
// =============
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create and update leds
|
||||
// -------------
|
||||
void CFrame::CreateLeds()
|
||||
{
|
||||
// Begin with blank ones
|
||||
memset(&g_Leds, 0, sizeof(g_Leds));
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
m_StatBmp[i] = new wxStaticBitmap(m_pStatusBar, wxID_ANY,
|
||||
CreateBitmapForLeds(g_Leds[i] == 1));
|
||||
}
|
||||
}
|
||||
// Update leds
|
||||
void CFrame::UpdateLeds()
|
||||
{
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
m_StatBmp[i]->SetBitmap(CreateBitmapForLeds(g_Leds[i] != 0));
|
||||
}
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create and speaker icons
|
||||
// -------------
|
||||
void CFrame::CreateSpeakers()
|
||||
{
|
||||
// Begin with blank ones
|
||||
memset(&g_Speakers, 0, sizeof(g_Speakers));
|
||||
memset(&g_Speakers_, 0, sizeof(g_Speakers_));
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
m_StatBmp[i+4] = new wxStaticBitmap(m_pStatusBar, wxID_ANY,
|
||||
CreateBitmapForSpeakers(i, g_Speakers[i] != 0));
|
||||
}
|
||||
}
|
||||
// Update icons
|
||||
void CFrame::UpdateSpeakers()
|
||||
{
|
||||
/*if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC)
|
||||
{ PanicAlert("Not NTSC");}
|
||||
|
||||
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
{ PanicAlert("Not Wii");}*/
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
m_StatBmp[i+4]->SetBitmap(CreateBitmapForSpeakers(i, g_Speakers[i] != 0));
|
||||
}
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create the Leds bitmap
|
||||
// -------------
|
||||
wxBitmap CFrame::CreateBitmapForLeds(bool On)
|
||||
{
|
||||
wxBitmap bitmap(WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
|
||||
// Set outline and fill colors
|
||||
wxBrush LightBlueBrush(_T("#0383f0"));
|
||||
wxPen LightBluePen(_T("#80c5fd"));
|
||||
wxPen LightGrayPen(_T("#909090"));
|
||||
dc.SetPen(On ? LightBluePen : LightGrayPen);
|
||||
dc.SetBrush(On ? LightBlueBrush : *wxWHITE_BRUSH);
|
||||
|
||||
dc.Clear();
|
||||
dc.DrawRectangle(0, 0, WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create the Speaker bitmap
|
||||
// -------------
|
||||
wxBitmap CFrame::CreateBitmapForSpeakers(int BitmapType, bool On)
|
||||
{
|
||||
wxBitmap bitmap(WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
wxBrush BackgroundGrayBrush(_T("#ece9d8")); // the right color in windows
|
||||
|
||||
switch(BitmapType)
|
||||
{
|
||||
case 0: // Speaker on
|
||||
{
|
||||
// Set outline and fill colors
|
||||
dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN);
|
||||
dc.SetBrush(On ? *wxGREEN_BRUSH : *wxWHITE_BRUSH);
|
||||
dc.SetBackground(BackgroundGrayBrush);
|
||||
dc.Clear();
|
||||
dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
case 1: // Speaker unmuted
|
||||
{
|
||||
// Set outline and fill colors
|
||||
dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN);
|
||||
dc.SetBrush(On ? *wxBLUE_BRUSH : *wxWHITE_BRUSH);
|
||||
dc.SetBackground(BackgroundGrayBrush);
|
||||
dc.Clear();
|
||||
dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
case 2: // Speaker activity
|
||||
{
|
||||
// Set outline and fill colors
|
||||
dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN);
|
||||
dc.SetBrush(On ? *wxGREEN_BRUSH : *wxWHITE_BRUSH);
|
||||
dc.SetBackground(BackgroundGrayBrush);
|
||||
dc.Clear();
|
||||
dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Move the bitmaps
|
||||
// -------------
|
||||
void CFrame::DoMoveIcons()
|
||||
{
|
||||
if(HaveLeds) MoveLeds();
|
||||
if(HaveSpeakers) MoveSpeakers();
|
||||
|
||||
// If there is not room for the led icons hide them
|
||||
if(m_pStatusBar->GetFieldsCount() >= 2 && HaveLeds)
|
||||
{
|
||||
wxRect Rect;
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 4 : 3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 3 : 2, Rect);
|
||||
#endif
|
||||
if(Rect.GetWidth() < 20)
|
||||
for (int i = 0; i < 4; i++) m_StatBmp[i]->Hide();
|
||||
else // if(!m_StatBmp[0]->IsShown())
|
||||
for (int i = 0; i < 4; i++) m_StatBmp[i]->Show();
|
||||
//Console::Print("LED: %i ", Rect.GetWidth());
|
||||
}
|
||||
|
||||
// If there is not room for the speaker icons hide them
|
||||
if(m_pStatusBar->GetFieldsCount() >= 2 && HaveSpeakers)
|
||||
{
|
||||
wxRect Rect;
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect(3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect(2, Rect);
|
||||
#endif
|
||||
if(Rect.GetWidth() < 20)
|
||||
for(int i = 0; i < 3; i++) m_StatBmp[i + 4]->Hide();
|
||||
else // if(!m_StatBmp[4]->IsShown())
|
||||
for (int i = 0; i < 3; i++) m_StatBmp[i + 4]->Show();
|
||||
//Console::Print("Speaker: %i\n", Rect.GetWidth());
|
||||
}
|
||||
}
|
||||
|
||||
void CFrame::MoveLeds()
|
||||
{
|
||||
wxRect Rect;
|
||||
// Get the bitmap field coordinates
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 4 : 3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 3 : 2, Rect);
|
||||
#endif
|
||||
wxSize Size = m_StatBmp[0]->GetSize(); // Get the bitmap size
|
||||
|
||||
//wxMessageBox(wxString::Format("%i", Rect.x));
|
||||
int x = Rect.x + 10;
|
||||
int Dist = WiimoteLeds::LED_SIZE_X + 7;
|
||||
int y = Rect.y + (Rect.height - Size.y) / 2;
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
if(i > 0) x = m_StatBmp[i-1]->GetPosition().x + Dist;
|
||||
m_StatBmp[i]->Move(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void CFrame::MoveSpeakers()
|
||||
{
|
||||
wxRect Rect;
|
||||
// Get the bitmap field coordinates
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect(3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect(2, Rect);
|
||||
#endif
|
||||
|
||||
// Get the actual bitmap size, currently it's the same as SPEAKER_SIZE_Y
|
||||
wxSize Size = m_StatBmp[4]->GetSize();
|
||||
|
||||
//wxMessageBox(wxString::Format("%i", Rect.x));
|
||||
int x = Rect.x + 9;
|
||||
int Dist = WiimoteLeds::SPEAKER_SIZE_X + 7;
|
||||
int y = Rect.y + (Rect.height - Size.y) / 2;
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
if(i > 0) x = m_StatBmp[i-1+4]->GetPosition().x + Dist;
|
||||
m_StatBmp[i + 4]->Move(x, y);
|
||||
}
|
||||
}
|
||||
// ==============
|
||||
// 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
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include "Globals.h"
|
||||
#include "Frame.h"
|
||||
#include "FileUtil.h"
|
||||
#include "StringUtil.h"
|
||||
#include "ConsoleWindow.h"
|
||||
|
||||
#include "GameListCtrl.h"
|
||||
#include "BootManager.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "Setup.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "Core.h"
|
||||
#include "State.h"
|
||||
#include "ConfigMain.h"
|
||||
#include "PluginManager.h"
|
||||
#include "MemcardManager.h"
|
||||
#include "CheatsWindow.h"
|
||||
#include "AboutDolphin.h"
|
||||
|
||||
#include <wx/statusbr.h>
|
||||
/////////////////////////////////////////
|
||||
|
||||
|
||||
namespace WiimoteLeds
|
||||
{
|
||||
int LED_SIZE_X = 8;
|
||||
int LED_SIZE_Y = 8;
|
||||
int SPEAKER_SIZE_X = 8;
|
||||
int SPEAKER_SIZE_Y = 8;
|
||||
|
||||
int ConnectionStatusWidth = 103; // These widths need to be revised, for vista at least
|
||||
int ConnectionStatusOnlyAdj = 7;
|
||||
int RightmostMargin = 6;
|
||||
int SpIconMargin = 11;
|
||||
int LedIconMargin = 11;
|
||||
|
||||
// The necessary recording status width, allow Frame to be at last of the form 100,000
|
||||
#ifdef RERECORDING
|
||||
static const int RerecordingStatusWidth = 340;
|
||||
#endif
|
||||
|
||||
// Leds only
|
||||
static const int LdWidthsOn[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth,
|
||||
(LedIconMargin + LED_SIZE_X) * 4 + RightmostMargin
|
||||
};
|
||||
static const int StylesFieldOn[] = { wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL };
|
||||
|
||||
// Speakers only
|
||||
static const int SpWidthsOn[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth,
|
||||
( SpIconMargin + SPEAKER_SIZE_X ) * 3 + RightmostMargin
|
||||
};
|
||||
static const int SpStylesFieldOn[] = { wxSB_NORMAL,
|
||||
#ifdef RERECORDING
|
||||
wxSB_NORMAL,
|
||||
#endif
|
||||
wxSB_NORMAL, wxSB_NORMAL };
|
||||
|
||||
// Both
|
||||
static const int LdSpWidthsOn[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth,
|
||||
(SpIconMargin + SPEAKER_SIZE_X) * 3,
|
||||
(LedIconMargin + LED_SIZE_X) * 4 + RightmostMargin
|
||||
};
|
||||
static const int LdSpStylesFieldOn[] = { wxSB_NORMAL,
|
||||
#ifdef RERECORDING
|
||||
wxSB_NORMAL,
|
||||
#endif
|
||||
wxSB_NORMAL, wxSB_NORMAL };
|
||||
|
||||
// Only the Wiimote connection Status
|
||||
static const int WidthsOff[] =
|
||||
{
|
||||
-1,
|
||||
#ifdef RERECORDING
|
||||
RerecordingStatusWidth,
|
||||
#endif
|
||||
ConnectionStatusWidth + ConnectionStatusOnlyAdj + RightmostMargin
|
||||
};
|
||||
static const int StylesFieldOff[] = { wxSB_NORMAL,
|
||||
#ifdef RERECORDING
|
||||
wxSB_NORMAL,
|
||||
#endif
|
||||
wxSB_NORMAL };
|
||||
|
||||
// GC mode
|
||||
static const int WidthsOffGC[] = { -1
|
||||
#ifdef RERECORDING
|
||||
, RerecordingStatusWidth
|
||||
#endif
|
||||
};
|
||||
static const int StylesFieldOffGC[] = { wxSB_NORMAL
|
||||
#ifdef RERECORDING
|
||||
, wxSB_NORMAL
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
// =======================================================
|
||||
// Modify status bar
|
||||
// -------------
|
||||
void CFrame::ModifyStatusBar()
|
||||
{
|
||||
// Get settings
|
||||
bool LedsOn = SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiLeds;
|
||||
bool SpeakersOn = SConfig::GetInstance().m_LocalCoreStartupParameter.bWiiSpeakers;
|
||||
|
||||
// Don't use this for GC games, or before a game is loaded
|
||||
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
{ LedsOn = false; SpeakersOn = false; }
|
||||
|
||||
// Declarations
|
||||
int Fields = 0;
|
||||
int *Widths = 0;
|
||||
int *StylesFields = 0;
|
||||
|
||||
// ---------------------------------------
|
||||
// Leds only
|
||||
// -------------
|
||||
if(LedsOn && !SpeakersOn)
|
||||
{
|
||||
Fields = 3;
|
||||
Widths = (int*)WiimoteLeds::LdWidthsOn;
|
||||
StylesFields = (int*)WiimoteLeds::StylesFieldOn;
|
||||
}
|
||||
// ---------------------------------------
|
||||
// Speaker only
|
||||
// -------------
|
||||
else if(!LedsOn && SpeakersOn)
|
||||
{
|
||||
Fields = 3;
|
||||
Widths = (int*)WiimoteLeds::SpWidthsOn;
|
||||
StylesFields = (int*)WiimoteLeds::SpStylesFieldOn;
|
||||
}
|
||||
// ---------------------------------------
|
||||
// Both on
|
||||
// -------------
|
||||
else if(LedsOn && SpeakersOn)
|
||||
{
|
||||
Fields = 4;
|
||||
Widths = (int*)WiimoteLeds::LdSpWidthsOn;
|
||||
StylesFields = (int*)WiimoteLeds::LdSpStylesFieldOn;
|
||||
}
|
||||
// ---------------------------------------
|
||||
// Both off
|
||||
// -------------
|
||||
else if(!LedsOn && !SpeakersOn)
|
||||
{
|
||||
Fields = 2;
|
||||
Widths = (int*)WiimoteLeds::WidthsOff;
|
||||
StylesFields = (int*)WiimoteLeds::StylesFieldOff;
|
||||
|
||||
// Maybe we should even go down to one field
|
||||
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
{
|
||||
Fields = 1;
|
||||
Widths = (int*)WiimoteLeds::WidthsOffGC;
|
||||
StylesFields = (int*)WiimoteLeds::StylesFieldOffGC;
|
||||
}
|
||||
}
|
||||
|
||||
// Add a filed for the rerecording status
|
||||
#ifdef RERECORDING
|
||||
Fields++;
|
||||
#endif
|
||||
|
||||
// Update the settings
|
||||
m_pStatusBar->SetFieldsCount(Fields);
|
||||
m_pStatusBar->SetStatusWidths(Fields, Widths);
|
||||
m_pStatusBar->SetStatusStyles(Fields, StylesFields);
|
||||
|
||||
/* Destroy and create all, and check for HaveLeds and HaveSpeakers in case we have
|
||||
gotten a confirmed on or off setting, in which case we don't do anything */
|
||||
if(!LedsOn && HaveLeds) CreateDestroy(DESTROYLEDS);
|
||||
if(!SpeakersOn && HaveSpeakers) CreateDestroy(DESTROYSPEAKERS);
|
||||
if(LedsOn && !HaveLeds) CreateDestroy(CREATELEDS);
|
||||
if(SpeakersOn && !HaveSpeakers) CreateDestroy(CREATESPEAKERS);
|
||||
|
||||
DoMoveIcons();
|
||||
m_pStatusBar->Refresh(); // avoid small glitches that can occur
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create and destroy leds and speakers icons
|
||||
// -------------
|
||||
void CFrame::CreateDestroy(int Case)
|
||||
{
|
||||
switch(Case)
|
||||
{
|
||||
case CREATELEDS:
|
||||
{
|
||||
CreateLeds();
|
||||
UpdateLeds();
|
||||
HaveLeds = true;
|
||||
break;
|
||||
}
|
||||
case DESTROYLEDS:
|
||||
{
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
m_StatBmp[i]->Destroy();
|
||||
}
|
||||
HaveLeds = false;
|
||||
break;
|
||||
}
|
||||
case CREATESPEAKERS:
|
||||
{
|
||||
CreateSpeakers();
|
||||
HaveSpeakers = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case DESTROYSPEAKERS:
|
||||
{
|
||||
for(int i = 4; i < 7; i++)
|
||||
{
|
||||
m_StatBmp[i]->Destroy();
|
||||
}
|
||||
HaveSpeakers = false;
|
||||
break;
|
||||
}
|
||||
} // end of switch
|
||||
|
||||
DoMoveIcons();
|
||||
}
|
||||
// =============
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create and update leds
|
||||
// -------------
|
||||
void CFrame::CreateLeds()
|
||||
{
|
||||
// Begin with blank ones
|
||||
memset(&g_Leds, 0, sizeof(g_Leds));
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
m_StatBmp[i] = new wxStaticBitmap(m_pStatusBar, wxID_ANY,
|
||||
CreateBitmapForLeds(g_Leds[i] == 1));
|
||||
}
|
||||
}
|
||||
// Update leds
|
||||
void CFrame::UpdateLeds()
|
||||
{
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
m_StatBmp[i]->SetBitmap(CreateBitmapForLeds(g_Leds[i] != 0));
|
||||
}
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create and speaker icons
|
||||
// -------------
|
||||
void CFrame::CreateSpeakers()
|
||||
{
|
||||
// Begin with blank ones
|
||||
memset(&g_Speakers, 0, sizeof(g_Speakers));
|
||||
memset(&g_Speakers_, 0, sizeof(g_Speakers_));
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
m_StatBmp[i+4] = new wxStaticBitmap(m_pStatusBar, wxID_ANY,
|
||||
CreateBitmapForSpeakers(i, g_Speakers[i] != 0));
|
||||
}
|
||||
}
|
||||
// Update icons
|
||||
void CFrame::UpdateSpeakers()
|
||||
{
|
||||
/*if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bNTSC)
|
||||
{ PanicAlert("Not NTSC");}
|
||||
|
||||
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
{ PanicAlert("Not Wii");}*/
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
m_StatBmp[i+4]->SetBitmap(CreateBitmapForSpeakers(i, g_Speakers[i] != 0));
|
||||
}
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create the Leds bitmap
|
||||
// -------------
|
||||
wxBitmap CFrame::CreateBitmapForLeds(bool On)
|
||||
{
|
||||
wxBitmap bitmap(WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
|
||||
// Set outline and fill colors
|
||||
wxBrush LightBlueBrush(_T("#0383f0"));
|
||||
wxPen LightBluePen(_T("#80c5fd"));
|
||||
wxPen LightGrayPen(_T("#909090"));
|
||||
dc.SetPen(On ? LightBluePen : LightGrayPen);
|
||||
dc.SetBrush(On ? LightBlueBrush : *wxWHITE_BRUSH);
|
||||
|
||||
dc.Clear();
|
||||
dc.DrawRectangle(0, 0, WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Create the Speaker bitmap
|
||||
// -------------
|
||||
wxBitmap CFrame::CreateBitmapForSpeakers(int BitmapType, bool On)
|
||||
{
|
||||
wxBitmap bitmap(WiimoteLeds::LED_SIZE_X, WiimoteLeds::LED_SIZE_Y);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
wxBrush BackgroundGrayBrush(_T("#ece9d8")); // the right color in windows
|
||||
|
||||
switch(BitmapType)
|
||||
{
|
||||
case 0: // Speaker on
|
||||
{
|
||||
// Set outline and fill colors
|
||||
dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN);
|
||||
dc.SetBrush(On ? *wxGREEN_BRUSH : *wxWHITE_BRUSH);
|
||||
dc.SetBackground(BackgroundGrayBrush);
|
||||
dc.Clear();
|
||||
dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
case 1: // Speaker unmuted
|
||||
{
|
||||
// Set outline and fill colors
|
||||
dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN);
|
||||
dc.SetBrush(On ? *wxBLUE_BRUSH : *wxWHITE_BRUSH);
|
||||
dc.SetBackground(BackgroundGrayBrush);
|
||||
dc.Clear();
|
||||
dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
case 2: // Speaker activity
|
||||
{
|
||||
// Set outline and fill colors
|
||||
dc.SetPen(On ? *wxMEDIUM_GREY_PEN : *wxMEDIUM_GREY_PEN);
|
||||
dc.SetBrush(On ? *wxGREEN_BRUSH : *wxWHITE_BRUSH);
|
||||
dc.SetBackground(BackgroundGrayBrush);
|
||||
dc.Clear();
|
||||
dc.DrawEllipse(0, 0, WiimoteLeds::SPEAKER_SIZE_X, WiimoteLeds::SPEAKER_SIZE_Y);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Move the bitmaps
|
||||
// -------------
|
||||
void CFrame::DoMoveIcons()
|
||||
{
|
||||
if(HaveLeds) MoveLeds();
|
||||
if(HaveSpeakers) MoveSpeakers();
|
||||
|
||||
// If there is not room for the led icons hide them
|
||||
if(m_pStatusBar->GetFieldsCount() >= 2 && HaveLeds)
|
||||
{
|
||||
wxRect Rect;
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 4 : 3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 3 : 2, Rect);
|
||||
#endif
|
||||
if(Rect.GetWidth() < 20)
|
||||
for (int i = 0; i < 4; i++) m_StatBmp[i]->Hide();
|
||||
else // if(!m_StatBmp[0]->IsShown())
|
||||
for (int i = 0; i < 4; i++) m_StatBmp[i]->Show();
|
||||
//Console::Print("LED: %i ", Rect.GetWidth());
|
||||
}
|
||||
|
||||
// If there is not room for the speaker icons hide them
|
||||
if(m_pStatusBar->GetFieldsCount() >= 2 && HaveSpeakers)
|
||||
{
|
||||
wxRect Rect;
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect(3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect(2, Rect);
|
||||
#endif
|
||||
if(Rect.GetWidth() < 20)
|
||||
for(int i = 0; i < 3; i++) m_StatBmp[i + 4]->Hide();
|
||||
else // if(!m_StatBmp[4]->IsShown())
|
||||
for (int i = 0; i < 3; i++) m_StatBmp[i + 4]->Show();
|
||||
//Console::Print("Speaker: %i\n", Rect.GetWidth());
|
||||
}
|
||||
}
|
||||
|
||||
void CFrame::MoveLeds()
|
||||
{
|
||||
wxRect Rect;
|
||||
// Get the bitmap field coordinates
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 4 : 3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect((HaveLeds && HaveSpeakers) ? 3 : 2, Rect);
|
||||
#endif
|
||||
wxSize Size = m_StatBmp[0]->GetSize(); // Get the bitmap size
|
||||
|
||||
//wxMessageBox(wxString::Format("%i", Rect.x));
|
||||
int x = Rect.x + 10;
|
||||
int Dist = WiimoteLeds::LED_SIZE_X + 7;
|
||||
int y = Rect.y + (Rect.height - Size.y) / 2;
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
if(i > 0) x = m_StatBmp[i-1]->GetPosition().x + Dist;
|
||||
m_StatBmp[i]->Move(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void CFrame::MoveSpeakers()
|
||||
{
|
||||
wxRect Rect;
|
||||
// Get the bitmap field coordinates
|
||||
#ifdef RERECORDING
|
||||
m_pStatusBar->GetFieldRect(3, Rect);
|
||||
#else
|
||||
m_pStatusBar->GetFieldRect(2, Rect);
|
||||
#endif
|
||||
|
||||
// Get the actual bitmap size, currently it's the same as SPEAKER_SIZE_Y
|
||||
wxSize Size = m_StatBmp[4]->GetSize();
|
||||
|
||||
//wxMessageBox(wxString::Format("%i", Rect.x));
|
||||
int x = Rect.x + 9;
|
||||
int Dist = WiimoteLeds::SPEAKER_SIZE_X + 7;
|
||||
int y = Rect.y + (Rect.height - Size.y) / 2;
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
if(i > 0) x = m_StatBmp[i-1+4]->GetPosition().x + Dist;
|
||||
m_StatBmp[i + 4]->Move(x, y);
|
||||
}
|
||||
}
|
||||
// ==============
|
||||
|
@ -1,63 +1,63 @@
|
||||
// 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 "SDCardWindow.h"
|
||||
#include "Globals.h"
|
||||
#include "IPC_HLE/HW/SDInterface.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSDCardWindow, wxWindow)
|
||||
EVT_CLOSE( wxSDCardWindow::OnEvent_Window_Close)
|
||||
EVT_BUTTON(ID_BUTTON_CLOSE, wxSDCardWindow::OnEvent_ButtonClose_Press)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxSDCardWindow::wxSDCardWindow(wxWindow* parent) :
|
||||
wxDialog(parent, wxID_ANY, _T("SDCard Mounter"), wxDefaultPosition, wxSize(400, 400), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
{
|
||||
Init_ChildControls();
|
||||
Layout();
|
||||
Show();
|
||||
}
|
||||
|
||||
wxSDCardWindow::~wxSDCardWindow()
|
||||
{
|
||||
// On Disposal
|
||||
}
|
||||
|
||||
void wxSDCardWindow::Init_ChildControls()
|
||||
{
|
||||
// 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(sButtons, 0, wxALL, 5);
|
||||
SetSizer(sMain);
|
||||
Layout();
|
||||
|
||||
Fit();
|
||||
}
|
||||
|
||||
void wxSDCardWindow::OnEvent_Window_Close(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
EndModal(0);
|
||||
}
|
||||
|
||||
void wxSDCardWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
EndModal(0);
|
||||
// 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 "SDCardWindow.h"
|
||||
#include "Globals.h"
|
||||
#include "IPC_HLE/HW/SDInterface.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSDCardWindow, wxWindow)
|
||||
EVT_CLOSE( wxSDCardWindow::OnEvent_Window_Close)
|
||||
EVT_BUTTON(ID_BUTTON_CLOSE, wxSDCardWindow::OnEvent_ButtonClose_Press)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxSDCardWindow::wxSDCardWindow(wxWindow* parent) :
|
||||
wxDialog(parent, wxID_ANY, _T("SDCard Mounter"), wxDefaultPosition, wxSize(400, 400), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
{
|
||||
Init_ChildControls();
|
||||
Layout();
|
||||
Show();
|
||||
}
|
||||
|
||||
wxSDCardWindow::~wxSDCardWindow()
|
||||
{
|
||||
// On Disposal
|
||||
}
|
||||
|
||||
void wxSDCardWindow::Init_ChildControls()
|
||||
{
|
||||
// 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(sButtons, 0, wxALL, 5);
|
||||
SetSizer(sMain);
|
||||
Layout();
|
||||
|
||||
Fit();
|
||||
}
|
||||
|
||||
void wxSDCardWindow::OnEvent_Window_Close(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
EndModal(0);
|
||||
}
|
||||
|
||||
void wxSDCardWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
EndModal(0);
|
||||
}
|
Reference in New Issue
Block a user