diff --git a/desmume/src/wx/IniFile.cpp b/desmume/src/wx/IniFile.cpp deleted file mode 100644 index 1e70fb362..000000000 --- a/desmume/src/wx/IniFile.cpp +++ /dev/null @@ -1,526 +0,0 @@ -// Copyright (C) 2003 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/ -// see IniFile.h - -#include -#include -#include - -#include -#include -#include -#include -#include - -//#include "StringUtil.h" -#include "IniFile.h" - -IniFile::IniFile() -{} - -IniFile::~IniFile() -{} - -Section::Section() - : lines(), name(""), comment("") {} - - -Section::Section(const std::string& _name) - : lines(), name(_name), comment("") {} - - -Section::Section(const Section& other) -{ - name = other.name; - comment = other.comment; - lines = other.lines; -} - -const Section* IniFile::GetSection(const char* sectionName) const -{ - for (std::vector
::const_iterator iter = sections.begin(); iter != sections.end(); ++iter) - if (!strcasecmp(iter->name.c_str(), sectionName)) - return (&(*iter)); - return 0; -} - -Section* IniFile::GetSection(const char* sectionName) -{ - for (std::vector
::iterator iter = sections.begin(); iter != sections.end(); ++iter) - if (!strcasecmp(iter->name.c_str(), sectionName)) - return (&(*iter)); - return 0; -} - -Section* IniFile::GetOrCreateSection(const char* sectionName) -{ - Section* section = GetSection(sectionName); - - if (!section) - { - sections.push_back(Section(sectionName)); - section = §ions[sections.size() - 1]; - } - - return(section); -} - - -bool IniFile::DeleteSection(const char* sectionName) -{ - Section* s = GetSection(sectionName); - - if (!s) - { - return false; - } - - for (std::vector
::iterator iter = sections.begin(); iter != sections.end(); ++iter) - { - if (&(*iter) == s) - { - sections.erase(iter); - return true; - } - } - - return false; -} - -void IniFile::ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut, std::string* commentOut) const -{ - // - int FirstEquals = (int)line.find("=", 0); - int FirstCommentChar = -1; - // Comments - //if (FirstCommentChar < 0) {FirstCommentChar = (int)line.find(";", FirstEquals > 0 ? FirstEquals : 0);} - if (FirstCommentChar < 0) {FirstCommentChar = (int)line.find("#", FirstEquals > 0 ? FirstEquals : 0);} - if (FirstCommentChar < 0) {FirstCommentChar = (int)line.find("//", FirstEquals > 0 ? FirstEquals : 0);} - - // Allow preservation of spacing before comment - if (FirstCommentChar > 0) - { - while (line[FirstCommentChar - 1] == ' ' || line[FirstCommentChar - 1] == 9) // 9 == tab - { - FirstCommentChar--; - } - } - - if ((FirstEquals >= 0) && ((FirstCommentChar < 0) || (FirstEquals < FirstCommentChar))) - { - // Yes, a valid line! - *keyOut = StripSpaces(line.substr(0, FirstEquals)); - if (commentOut) *commentOut = FirstCommentChar > 0 ? line.substr(FirstCommentChar) : std::string(""); - if (valueOut) *valueOut = StripQuotes(StripSpaces(line.substr(FirstEquals + 1, FirstCommentChar - FirstEquals - 1))); - } -} - -std::string* IniFile::GetLine(Section* section, const char* key, std::string* valueOut, std::string* commentOut) -{ - for (std::vector::iterator iter = section->lines.begin(); iter != section->lines.end(); ++iter) - { - std::string& line = *iter; - std::string lineKey; - ParseLine(line, &lineKey, valueOut, commentOut); - - if (!strcasecmp(lineKey.c_str(), key)) - { - return &line; - } - } - - return 0; -} - -bool IniFile::Exists(const char* const sectionName, const char* key) const -{ - - const Section* const section = GetSection(sectionName); - if (!section) - return false; - - for (std::vector::const_iterator iter = section->lines.begin(); iter != section->lines.end(); ++iter) - { - std::string lineKey; - ParseLine(*iter, &lineKey, NULL, NULL); - - if (!strcasecmp(lineKey.c_str(), key)) - { - return true; - } - } - - return false; -} - -void IniFile::SetLines(const char* sectionName, const std::vector &lines) -{ - Section* section = GetOrCreateSection(sectionName); - section->lines.clear(); - - for (std::vector::const_iterator iter = lines.begin(); iter != lines.end(); ++iter) - { - section->lines.push_back(*iter); - } -} - - -bool IniFile::DeleteKey(const char* sectionName, const char* key) -{ - Section* section = GetSection(sectionName); - - if (!section) - { - return false; - } - - std::string* line = GetLine(section, key, 0, 0); - - for (std::vector::iterator liter = section->lines.begin(); liter != section->lines.end(); ++liter) - { - if (line == &(*liter)) - { - section->lines.erase(liter); - return true; - } - } - - return false; //shouldn't happen -} - -// Return a list of all keys in a section -bool IniFile::GetKeys(const char* sectionName, std::vector& keys) const -{ - const Section* section = GetSection(sectionName); - - if (!section) - { - return false; - } - - keys.clear(); - - for (std::vector::const_iterator liter = section->lines.begin(); liter != section->lines.end(); ++liter) - { - std::string key; - ParseLine(*liter, &key, 0, 0); - keys.push_back(key); - } - - return true; -} - -// Return a list of all lines in a section -bool IniFile::GetLines(const char* sectionName, std::vector& lines) const -{ - const Section* section = GetSection(sectionName); - if (!section) - return false; - - lines.clear(); - for (std::vector::const_iterator iter = section->lines.begin(); iter != section->lines.end(); ++iter) - { - std::string line = StripSpaces(*iter); - int commentPos = (int)line.find('#'); - if (commentPos == 0) - { - continue; - } - - if (commentPos != (int)std::string::npos) - { - line = StripSpaces(line.substr(0, commentPos)); - } - - lines.push_back(line); - } - - return true; -} - - -void IniFile::SortSections() -{ - std::sort(sections.begin(), sections.end()); -} - -bool IniFile::Load(const char* filename) -{ - // Maximum number of letters in a line - static const int MAX_BYTES = 1024*32; - - sections.clear(); - sections.push_back(Section("")); - // first section consists of the comments before the first real section - - // Open file - std::ifstream in; - in.open(filename, std::ios::in); - - if (in.fail()) return false; - - while (!in.eof()) - { - char templine[MAX_BYTES]; - in.getline(templine, MAX_BYTES); - std::string line = templine; - -#ifndef _WIN32 - // Check for CRLF eol and convert it to LF - if (!line.empty() && line.at(line.size()-1) == '\r') - { - line.erase(line.size()-1); - } -#endif - - if (in.eof()) break; - - if (line.size() > 0) - { - if (line[0] == '[') - { - size_t endpos = line.find("]"); - - if (endpos != std::string::npos) - { - // New section! - std::string sub = line.substr(1, endpos - 1); - sections.push_back(Section(sub)); - - if (endpos + 1 < line.size()) - { - sections[sections.size() - 1].comment = line.substr(endpos + 1); - } - } - } - else - { - sections[sections.size() - 1].lines.push_back(line); - } - } - } - - in.close(); - return true; -} - -bool IniFile::Save(const char* filename) -{ - std::ofstream out; - out.open(filename, std::ios::out); - - if (out.fail()) - { - return false; - } - - for (std::vector
::const_iterator iter = sections.begin(); iter != sections.end(); ++iter) - { - const Section& section = *iter; - - if (section.name != "") - { - out << "[" << section.name << "]" << section.comment << std::endl; - } - - for (std::vector::const_iterator liter = section.lines.begin(); liter != section.lines.end(); ++liter) - { - std::string s = *liter; - out << s << std::endl; - } - } - - out.close(); - return true; -} - -void IniFile::Set(const char* sectionName, const char* key, const char* newValue) -{ - Section* section = GetOrCreateSection(sectionName); - std::string value, comment; - std::string* line = GetLine(section, key, &value, &comment); - - if (line) - { - // Change the value - keep the key and comment - *line = StripSpaces(key) + " = " + newValue + comment; - } - else - { - // The key did not already exist in this section - let's add it. - section->lines.push_back(std::string(key) + " = " + newValue); - } -} - -void IniFile::Set(const char* sectionName, const char* key, const std::vector& newValues) -{ - std::string temp; - - // Join the strings with , - std::vector::const_iterator it; - for (it = newValues.begin(); it != newValues.end(); ++it) { - - temp = (*it) + ","; - } - - // remove last , - temp.resize(temp.length() - 1); - - Set(sectionName, key, temp.c_str()); -} - -void IniFile::Set(const char* sectionName, const char* key, u32 newValue) -{ - Set(sectionName, key, StringFromFormat("0x%08x", newValue).c_str()); -} - - -void IniFile::Set(const char* sectionName, const char* key, int newValue) -{ - Set(sectionName, key, StringFromInt(newValue).c_str()); -} - - -void IniFile::Set(const char* sectionName, const char* key, bool newValue) -{ - Set(sectionName, key, StringFromBool(newValue).c_str()); -} - -bool IniFile::Get(const char* sectionName, const char* key, std::string* value, const char* defaultValue) -{ - Section* section = GetSection(sectionName); - - if (!section) - { - if (defaultValue) - { - *value = defaultValue; - } - return false; - } - - std::string* line = GetLine(section, key, value, 0); - - if (!line) - { - if (defaultValue) - { - *value = defaultValue; - } - return false; - } - - return true; -} - - -bool IniFile::Get(const char* sectionName, const char* key, std::vector& values) -{ - - std::string temp; - bool retval = Get(sectionName, key, &temp, 0); - - if (! retval || temp.empty()) { - return false; - } - - - // ignore starting , if any - size_t subStart = temp.find_first_not_of(","); - size_t subEnd; - - // split by , - while (subStart != std::string::npos) { - - // Find next , - subEnd = temp.find_first_of(",", subStart); - if (subStart != subEnd) - // take from first char until next , - values.push_back(StripSpaces(temp.substr(subStart, subEnd - subStart))); - - // Find the next non , char - subStart = temp.find_first_not_of(",", subEnd); - } - - return true; -} - -bool IniFile::Get(const char* sectionName, const char* key, int* value, int defaultValue) -{ - std::string temp; - bool retval = Get(sectionName, key, &temp, 0); - - if (retval && TryParseInt(temp.c_str(), value)) - { - return true; - } - - *value = defaultValue; - return false; -} - - -bool IniFile::Get(const char* sectionName, const char* key, u32* value, u32 defaultValue) -{ - std::string temp; - bool retval = Get(sectionName, key, &temp, 0); - - if (retval && TryParseUInt(temp.c_str(), value)) - { - return true; - } - - *value = defaultValue; - return false; -} - - -bool IniFile::Get(const char* sectionName, const char* key, bool* value, bool defaultValue) -{ - std::string temp; - bool retval = Get(sectionName, key, &temp, 0); - - if (retval && TryParseBool(temp.c_str(), value)) - { - return true; - } - - *value = defaultValue; - return false; -} - - -// TODO: Keep this code below? -/* - int main() - { - IniFile ini; - ini.Load("my.ini"); - ini.Set("Hej", "A", "amaskdfl"); - ini.Set("Mossa", "A", "amaskdfl"); - ini.Set("Aissa", "A", "amaskdfl"); - //ini.Read("my.ini"); - std::string x; - ini.Get("Hej", "B", &x, "boo"); - ini.DeleteKey("Mossa", "A"); - ini.DeleteSection("Mossa"); - ini.SortSections(); - ini.Save("my.ini"); - //UpdateVars(ini); - return 0; - } - */ diff --git a/desmume/src/wx/IniFile.h b/desmume/src/wx/IniFile.h deleted file mode 100644 index 975fd47ab..000000000 --- a/desmume/src/wx/IniFile.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2003 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 _INIFILE_H_ -#define _INIFILE_H_ - -#include -#include - -#include "types.h" - -#include "StringUtil.h" - -class Section -{ -public: - Section(); - Section(const std::string& _name); - Section(const Section& other); - std::vectorlines; - std::string name; - std::string comment; - - bool operator<(const Section& other) const - { - return(name < other.name); - } -}; - -class IniFile -{ -public: - IniFile(); - ~IniFile(); - - bool Load(const char* filename); - bool Save(const char* filename); - - void Set(const char* sectionName, const char* key, const char* newValue); - void Set(const char* sectionName, const char* key, int newValue); - void Set(const char* sectionName, const char* key, u32 newValue); - void Set(const char* sectionName, const char* key, bool newValue); - void Set(const char* sectionName, const char* key, const std::string& newValue) {Set(sectionName, key, newValue.c_str());} - void Set(const char* sectionName, const char* key, const std::vector& newValues); - - void SetLines(const char* sectionName, const std::vector &lines); - - // Returns true if exists key in section - bool Exists(const char* sectionName, const char* key) const; - - // getter should be const - bool Get(const char* sectionName, const char* key, std::string* value, const char* defaultValue = ""); - bool Get(const char* sectionName, const char* key, int* value, int defaultValue = 0); - bool Get(const char* sectionName, const char* key, u32* value, u32 defaultValue = 0); - bool Get(const char* sectionName, const char* key, bool* value, bool defaultValue = false); - bool Get(const char* sectionName, const char* key, std::vector& values); - - bool GetKeys(const char* sectionName, std::vector& keys) const; - bool GetLines(const char* sectionName, std::vector& lines) const; - - bool DeleteKey(const char* sectionName, const char* key); - bool DeleteSection(const char* sectionName); - - void SortSections(); - - void ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut, std::string* commentOut) const; - std::string* GetLine(Section* section, const char* key, std::string* valueOut, std::string* commentOut); - -private: - std::vector
sections; - - const Section* GetSection(const char* section) const; - Section* GetSection(const char* section); - Section* GetOrCreateSection(const char* section); - std::string* GetLine(const char* section, const char* key); - void CreateSection(const char* section); -}; - -#endif // _INIFILE_H_ diff --git a/desmume/src/wx/Makefile.am b/desmume/src/wx/Makefile.am index 25769cd85..121ff3e9b 100644 --- a/desmume/src/wx/Makefile.am +++ b/desmume/src/wx/Makefile.am @@ -19,7 +19,6 @@ wxdesmume_SOURCES = \ InputCommon/EventHandler.cpp \ InputCommon/Configuration.cpp \ InputCommon/SDL.cpp \ - IniFile.cpp \ LuaWindow.cpp \ StringUtil.cpp \ wxMain.cpp diff --git a/desmume/src/wx/PadSimple/PadSimple.cpp b/desmume/src/wx/PadSimple/PadSimple.cpp index ae15a9562..2b37396a4 100644 --- a/desmume/src/wx/PadSimple/PadSimple.cpp +++ b/desmume/src/wx/PadSimple/PadSimple.cpp @@ -25,7 +25,7 @@ //#include "LogManager.h" #include "pluginspecs_pad.h" #include "PadSimple.h" -#include "../IniFile.h" +#include //#include "StringUtil.h" //#include "FileUtil.h" //#include "ChunkFile.h" @@ -822,7 +822,6 @@ void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength) //****************************************************************************** // Load and save the configuration //****************************************************************************** -extern std::string executableDirectory; void LoadConfig() { // Initialize first pad to standard controls @@ -916,34 +915,32 @@ void LoadConfig() 46, // Mic (m) }; #endif - IniFile file; - file.Load((executableDirectory + std::string("pad.ini")).c_str()); + wxConfigBase *config = wxConfigBase::Get(); for(int i = 0; i < 4; i++) { - char SectionName[32]; - sprintf(SectionName, "PAD%i", i+1); + config->SetPath(wxString::Format(_T("/PAD%i"), i+1)); - file.Get(SectionName, "UseXPad", &pad[i].bEnableXPad, i==0); - file.Get(SectionName, "DisableOnBackground", &pad[i].bDisable, false); - file.Get(SectionName, "Rumble", &pad[i].bRumble, true); - file.Get(SectionName, "RumbleStrength", &pad[i].RumbleStrength, 8000); - file.Get(SectionName, "XPad#", &pad[i].XPadPlayer); + config->Read(_T("UseXPad"), &pad[i].bEnableXPad, i==0); + config->Read(_T("DisableOnBackground"), &pad[i].bDisable, false); + config->Read(_T("Rumble"), &pad[i].bRumble, true); + config->Read(_T("RumbleStrength"), (long *)&pad[i].RumbleStrength, 8000); + config->Read(_T("XPad#"), &pad[i].XPadPlayer); - file.Get(SectionName, "Trigger_semivalue", &pad[i].Trigger_semivalue, TRIGGER_HALF_DEFAULT); - file.Get(SectionName, "Main_stick_semivalue", &pad[i].Main_stick_semivalue, STICK_HALF_DEFAULT); - file.Get(SectionName, "Sub_stick_semivalue", &pad[i].Sub_stick_semivalue, STICK_HALF_DEFAULT); + config->Read(_T("Trigger_semivalue"), (long *)&pad[i].Trigger_semivalue, TRIGGER_HALF_DEFAULT); + config->Read(_T("Main_stick_semivalue"), (long *)&pad[i].Main_stick_semivalue, STICK_HALF_DEFAULT); + config->Read(_T("Sub_stick_semivalue"), (long *)&pad[i].Sub_stick_semivalue, STICK_HALF_DEFAULT); #ifdef RERECORDING - file.Get(SectionName, "Recording", &pad[0].bRecording, false); - file.Get(SectionName, "Playback", &pad[0].bPlayback, false); + config->Read(_T("Recording"), &pad[0].bRecording, false); + config->Read(_T("Playback"), &pad[0].bPlayback, false); #endif for (int x = 0; x < NUMCONTROLS; x++) { - file.Get(SectionName, controlNames[x], - &pad[i].keyForControl[x], + config->Read(wxString(controlNames[x],wxConvUTF8), + (long *)&pad[i].keyForControl[x], (i==0) ? defaultKeyForControl[x] : 0); #if defined(HAVE_X11) && HAVE_X11 // In linux we have a problem assigning the upper case of the @@ -957,33 +954,30 @@ void LoadConfig() void SaveConfig() { - IniFile file; - file.Load((executableDirectory + std::string("pad.ini")).c_str()); + wxConfigBase *config = wxConfigBase::Get(); for(int i = 0; i < 4; i++) { - char SectionName[32]; - sprintf(SectionName, "PAD%i", i+1); + config->SetPath(wxString::Format(_T("/PAD%i"), i+1)); - file.Set(SectionName, "UseXPad", pad[i].bEnableXPad); - file.Set(SectionName, "DisableOnBackground", pad[i].bDisable); - file.Set(SectionName, "Rumble", pad[i].bRumble); - file.Set(SectionName, "RumbleStrength", pad[i].RumbleStrength); - file.Set(SectionName, "XPad#", pad[i].XPadPlayer); + config->Write(_T("UseXPad"), pad[i].bEnableXPad); + config->Write(_T("DisableOnBackground"), pad[i].bDisable); + config->Write(_T("Rumble"), pad[i].bRumble); + config->Write(_T("RumbleStrength"), (long)pad[i].RumbleStrength); + config->Write(_T("XPad#"), pad[i].XPadPlayer); - file.Set(SectionName, "Trigger_semivalue", pad[i].Trigger_semivalue); - file.Set(SectionName, "Main_stick_semivalue", pad[i].Main_stick_semivalue); - file.Set(SectionName, "Sub_stick_semivalue", pad[i].Sub_stick_semivalue); + config->Write(_T("Trigger_semivalue"), (long)pad[i].Trigger_semivalue); + config->Write(_T("Main_stick_semivalue"), (long)pad[i].Main_stick_semivalue); + config->Write(_T("Sub_stick_semivalue"), (long)pad[i].Sub_stick_semivalue); #ifdef RERECORDING - file.Set(SectionName, "Recording", pad[0].bRecording); - file.Set(SectionName, "Playback", pad[0].bPlayback); + config->Write(_T("Recording"), pad[0].bRecording); + config->Write(_T("Playback"), pad[0].bPlayback); #endif for (int x = 0; x < NUMCONTROLS; x++) { - file.Set(SectionName, controlNames[x], pad[i].keyForControl[x]); + config->Write(wxString(controlNames[x],wxConvUTF8), (long)pad[i].keyForControl[x]); } } - file.Save((executableDirectory + std::string("pad.ini")).c_str()); } diff --git a/desmume/src/wx/wxDeSmuME_2008.vcproj b/desmume/src/wx/wxDeSmuME_2008.vcproj index 16a4efbaa..05257a061 100644 --- a/desmume/src/wx/wxDeSmuME_2008.vcproj +++ b/desmume/src/wx/wxDeSmuME_2008.vcproj @@ -1245,14 +1245,6 @@ - - - - diff --git a/desmume/src/wx/wxMain.cpp b/desmume/src/wx/wxMain.cpp index ec6a8395a..22b42c300 100644 --- a/desmume/src/wx/wxMain.cpp +++ b/desmume/src/wx/wxMain.cpp @@ -35,6 +35,7 @@ #ifdef GDB_STUB #include "gdbstub.h" #endif +#include #define SCREEN_SIZE (256*192*3) #define GAP_DEFAULT 64 @@ -78,7 +79,6 @@ void CloseLuaContext(int) #endif volatile bool execute = false; -std::string executableDirectory; class Desmume: public wxApp { @@ -411,8 +411,12 @@ loop: void Menu_SaveStates(wxCommandEvent &event); void Menu_LoadStates(wxCommandEvent &event); void NDSInitialize(); - void changeRotation(wxCommandEvent &event); + void OnRotation(wxCommandEvent &event); + void ChangeRotation(int rot, bool skip); void onResize(wxSizeEvent &event); + bool LoadSettings(); + bool SaveSettings(); + void OnClose(wxCloseEvent &event); private: #ifdef GDB_STUB @@ -474,11 +478,14 @@ enum void DesmumeFrame::Menu_SaveStates(wxCommandEvent &event){savestate_slot(event.GetId() - wSaveState01);} void DesmumeFrame::Menu_LoadStates(wxCommandEvent &event){loadstate_slot(event.GetId() - wLoadState01);} -void DesmumeFrame::changeRotation(wxCommandEvent &event){ - int rot = (event.GetId() - wRot0)*90; +void DesmumeFrame::OnRotation(wxCommandEvent &event) { + ChangeRotation((event.GetId() - wRot0)*90, true); +} + +void DesmumeFrame::ChangeRotation(int rot, bool skip) { wxSize sizeMin, sizeMax; - if (rot == nds_screen_rotation_angle) + if (skip && rot == nds_screen_rotation_angle) return; SetMinSize(wxSize(-1,-1)); @@ -516,6 +523,7 @@ BEGIN_EVENT_TABLE(DesmumeFrame, wxFrame) EVT_PAINT(DesmumeFrame::onPaint) EVT_IDLE(DesmumeFrame::onIdle) EVT_SIZE(DesmumeFrame::onResize) +EVT_CLOSE(DesmumeFrame::OnClose) EVT_MENU(wxID_EXIT, DesmumeFrame::OnQuit) EVT_MENU(wxID_OPEN, DesmumeFrame::LoadRom) EVT_MENU(wxID_ABOUT,DesmumeFrame::OnAbout) @@ -553,7 +561,7 @@ EVT_MENU(wCloseRom,DesmumeFrame::closeRom) EVT_MENU(wImportBackupMemory,DesmumeFrame::importBackupMemory) EVT_MENU(wExportBackupMemory,DesmumeFrame::exportBackupMemory) -EVT_MENU_RANGE(wRot0,wRot270,DesmumeFrame::changeRotation) +EVT_MENU_RANGE(wRot0,wRot270,DesmumeFrame::OnRotation) EVT_MENU(wSaveScreenshotAs,DesmumeFrame::saveScreenshotAs) EVT_MENU(wQuickScreenshot,DesmumeFrame::quickScreenshot) @@ -600,6 +608,10 @@ bool Desmume::OnInit() OpenConsole(); #endif + SetAppName(_T("desmume")); + //comment for devs: or you may use wxConfig instead of wxFileConfig, so it will be wxRegConfig on MSW and wxFileConfig on other platforms + wxConfigBase *pConfig = new wxFileConfig(); + wxConfigBase::Set(pConfig); wxString emu_version(EMU_DESMUME_NAME_AND_VERSION(), wxConvUTF8); DesmumeFrame *frame = new DesmumeFrame(emu_version); frame->NDSInitialize(); @@ -613,14 +625,6 @@ bool Desmume::OnInit() frame->Show(true); - char *p, *a; - std::string b = std::string(wxStandardPaths::Get().GetExecutablePath().mb_str()); - a = const_cast(b.c_str()); - p = a + lstrlen(a); - while (p >= a && *p != '\\') p--; - if (++p >= a) *p = 0; - - executableDirectory = std::string(a); PADInitialize.padNumber = 1; extern void Initialize(void *init); @@ -727,12 +731,9 @@ DesmumeFrame::DesmumeFrame(const wxString& title) // CreateStatusBar(2); // SetStatusText("Welcome to Desmume!"); - SetClientSize(256,384); - wxSize sizeMin = ClientToWindowSize(wxSize(256,384)); - wxSize sizeMax = sizeMin; - sizeMax.IncBy(0,GAP_MAX); - SetMinSize(sizeMin); - SetMaxSize(sizeMax); + LoadSettings(); + rotateMenu->Check(wRot0+(nds_screen_rotation_angle/90), true); + ChangeRotation(nds_screen_rotation_angle, false); } #ifdef _WIN32 @@ -753,3 +754,19 @@ void joinThread_gdb( void *thread_handle) { } #endif +bool DesmumeFrame::LoadSettings() { + wxConfigBase::Get()->Read(_T("/Screen/Gap"),&nds_gap_size,0); + wxConfigBase::Get()->Read(_T("/Screen/Rotation"),&nds_screen_rotation_angle,0); + return true; +} + +bool DesmumeFrame::SaveSettings() { + wxConfigBase::Get()->Write(_T("/Screen/Gap"),nds_gap_size); + wxConfigBase::Get()->Write(_T("/Screen/Rotation"),nds_screen_rotation_angle); + return true; +} + +void DesmumeFrame::OnClose(wxCloseEvent &event) { + SaveSettings(); + event.Skip(); +}