+ // Try to find absolute path
+ wxString absoluteConfigPath = m_emulatorFilename;
+ if ( !::wxIsAbsolutePath(absoluteConfigPath) )
+ {
+ wxString currDir = wxGetCwd();
+ absoluteConfigPath = currDir + wxString(wxFILE_SEP_PATH) + m_emulatorFilename;
+ if ( !wxFile::Exists(absoluteConfigPath) )
+ {
+ absoluteConfigPath = appDir + wxString(wxFILE_SEP_PATH)
+ + m_emulatorFilename;
+ }
+ }
+
+ if ( !wxFile::Exists(absoluteConfigPath) )
+ {
+ wxString str;
+ str.Printf( wxT("Could not find config file %s"),
+ absoluteConfigPath.c_str() );
+
+ wxMessageBox(str);
+ return false;
+ }
+
+ wxString rootPath = wxPathOnly(absoluteConfigPath);
+
+ {
+ wxFileConfig config(wxT("wxEmulator"), wxT("wxWidgets"),
+ absoluteConfigPath, wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
+
+ config.Read(wxT("/General/title"), & m_emulatorTitle);
+ config.Read(wxT("/General/description"), & m_emulatorDescription);
+ config.Read(wxT("/General/backgroundBitmap"), & m_emulatorBackgroundBitmapName);
+
+ wxString colString;
+ if (config.Read(wxT("/General/backgroundColour"), & colString) ||
+ config.Read(wxT("/General/backgroundColor"), & colString)
+ )
+ {
+ m_emulatorBackgroundColour = wxHexStringToColour(colString);
+ }
+
+ int x = 0, y = 0, w = 0, h = 0, dw = 0, dh = 0;
+ config.Read(wxT("/General/screenX"), & x);
+ config.Read(wxT("/General/screenY"), & y);
+ config.Read(wxT("/General/screenWidth"), & w);
+ config.Read(wxT("/General/screenHeight"), & h);
+ if (config.Read(wxT("/General/deviceWidth"), & dw) && config.Read(wxT("/General/deviceHeight"), & dh))
+ {
+ m_emulatorDeviceSize = wxSize(dw, dh);
+ }
+
+ m_emulatorScreenPosition = wxPoint(x, y);
+ m_emulatorScreenSize = wxSize(w, h);
+ }
+
+ if (!m_emulatorBackgroundBitmapName.empty())
+ {
+ wxString absoluteBackgroundBitmapName = rootPath + wxString(wxFILE_SEP_PATH) + m_emulatorBackgroundBitmapName;
+ if ( !wxFile::Exists(absoluteBackgroundBitmapName) )
+ {
+ wxString str;
+ str.Printf( wxT("Could not find bitmap %s"),
+ absoluteBackgroundBitmapName.c_str() );
+ wxMessageBox(str);
+ return false;
+ }
+
+ wxBitmapType type = wxDetermineImageType(m_emulatorBackgroundBitmapName);
+ if (type == wxBITMAP_TYPE_INVALID)
+ return false;
+
+ if (!m_emulatorBackgroundBitmap.LoadFile(m_emulatorBackgroundBitmapName, type))
+ {
+ wxString str;
+ str.Printf( wxT("Could not load bitmap file %s"),
+ m_emulatorBackgroundBitmapName.c_str() );
+ wxMessageBox(str);
+ return false;
+ }
+
+ m_emulatorDeviceSize = wxSize(m_emulatorBackgroundBitmap.GetWidth(),
+ m_emulatorBackgroundBitmap.GetHeight());
+ }
+ return true;