mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@473 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
// 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 <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Common.h"
|
||||
#include "IniFile.h"
|
||||
#include "BootManager.h"
|
||||
#include "ISOFile.h"
|
||||
#include "Volume.h"
|
||||
#include "VolumeCreator.h"
|
||||
#include "Config.h"
|
||||
#include "Core.h"
|
||||
#include "Frame.h"
|
||||
#include "CodeWindow.h"
|
||||
|
||||
static std::string s_DataBasePath_EUR = "Data_EUR";
|
||||
static std::string s_DataBasePath_USA = "Data_USA";
|
||||
static std::string s_DataBasePath_JAP = "Data_JAP";
|
||||
|
||||
extern CFrame* main_frame;
|
||||
extern CCodeWindow* g_pCodeWindow;
|
||||
|
||||
namespace BootManager
|
||||
{
|
||||
#ifdef _WIN32
|
||||
extern "C" HINSTANCE wxGetInstance();
|
||||
#endif
|
||||
|
||||
bool BootCore(const std::string& _rFilename)
|
||||
{
|
||||
SCoreStartupParameter StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
||||
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
// StartUp.bUseDualCore = code_frame->UseDualCore();
|
||||
StartUp.bUseJIT = !g_pCodeWindow->UseInterpreter();
|
||||
}
|
||||
else
|
||||
{
|
||||
// StartUp.bUseDualCore = false;
|
||||
StartUp.bUseJIT = true;
|
||||
}
|
||||
StartUp.m_BootType = SCoreStartupParameter::BOOT_ISO;
|
||||
StartUp.m_strFilename = _rFilename;
|
||||
StartUp.bRunCompareClient = false;
|
||||
StartUp.bRunCompareServer = false;
|
||||
StartUp.bEnableDebugging = g_pCodeWindow ? true : false; // RUNNING_DEBUG
|
||||
std::string BaseDataPath;
|
||||
#ifdef _WIN32
|
||||
StartUp.hInstance = wxGetInstance();
|
||||
#ifdef _M_X64
|
||||
StartUp.bUseFastMem = true;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ( !StartUp.AutoSetup(SCoreStartupParameter::BOOT_DEFAULT) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load overrides
|
||||
IniFile ini;
|
||||
std::string unique_id = StartUp.GetUniqueID();
|
||||
if (unique_id.size() == 6 && ini.Load(("Patches/" + unique_id + ".ini").c_str()))
|
||||
{
|
||||
ini.Get("Core", "UseDualCore", &StartUp.bUseDualCore, StartUp.bUseDualCore);
|
||||
ini.Get("Core", "OptimizeQuantizers", &StartUp.bOptimizeQuantizers, StartUp.bOptimizeQuantizers);
|
||||
}
|
||||
if(main_frame)
|
||||
StartUp.hMainWindow = main_frame->GetRenderHandle();
|
||||
|
||||
// init the core
|
||||
if (!Core::Init(StartUp))
|
||||
{
|
||||
PanicAlert("Couldn't init the core.\nCheck your configuration.");
|
||||
return(false);
|
||||
}
|
||||
|
||||
Core::SetState(g_pCodeWindow ? Core::CORE_PAUSE : Core::CORE_RUN);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
void Stop()
|
||||
{
|
||||
Core::Stop();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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 _BOOTMANAGER_H
|
||||
#define _BOOTMANAGER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class CISOFile;
|
||||
|
||||
namespace BootManager
|
||||
{
|
||||
bool BootCore(const std::string& _rFilename);
|
||||
|
||||
void Stop();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,122 @@
|
||||
// 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 <string>
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Common.h"
|
||||
#include "IniFile.h"
|
||||
#include "Config.h"
|
||||
|
||||
SConfig SConfig::m_Instance;
|
||||
|
||||
|
||||
SConfig::SConfig()
|
||||
{
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
|
||||
SConfig::~SConfig()
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
|
||||
void SConfig::SaveSettings()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load("Dolphin.ini"); // yes we must load first to not kill unknown stuff
|
||||
|
||||
// misc
|
||||
{
|
||||
ini.Set("General", "LastFilename", m_LastFilename);
|
||||
|
||||
// ISO folders
|
||||
ini.Set("General", "GCMPathes", (int)m_ISOFolder.size());
|
||||
|
||||
for (size_t i = 0; i < m_ISOFolder.size(); i++)
|
||||
{
|
||||
TCHAR tmp[16];
|
||||
sprintf(tmp, "GCMPath%i", (int)i);
|
||||
ini.Set("General", tmp, m_ISOFolder[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// core
|
||||
{
|
||||
ini.Set("Core", "GFXPlugin", m_LocalCoreStartupParameter.m_strVideoPlugin);
|
||||
ini.Set("Core", "DSPPlugin", m_LocalCoreStartupParameter.m_strDSPPlugin);
|
||||
ini.Set("Core", "PadPlugin", m_LocalCoreStartupParameter.m_strPadPlugin);
|
||||
|
||||
ini.Set("Core", "HLEBios", m_LocalCoreStartupParameter.bHLEBios);
|
||||
ini.Set("Core", "UseDynarec", m_LocalCoreStartupParameter.bUseJIT);
|
||||
ini.Set("Core", "UseDualCore", m_LocalCoreStartupParameter.bUseDualCore);
|
||||
ini.Set("Core", "LockThreads", m_LocalCoreStartupParameter.bLockThreads);
|
||||
ini.Set("Core", "DefaultGCM", m_LocalCoreStartupParameter.m_strDefaultGCM);
|
||||
ini.Set("Core", "OptimizeQuantizers", m_LocalCoreStartupParameter.bOptimizeQuantizers);
|
||||
}
|
||||
|
||||
ini.Save("Dolphin.ini");
|
||||
}
|
||||
|
||||
|
||||
void SConfig::LoadSettings()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load("Dolphin.ini");
|
||||
|
||||
// hard coded default plugin
|
||||
{
|
||||
ini.Get("Default", "GFXPlugin", &m_DefaultGFXPlugin);
|
||||
ini.Get("Default", "DSPPlugin", &m_DefaultDSPPlugin);
|
||||
ini.Get("Default", "PadPlugin", &m_DefaultPADPlugin);
|
||||
}
|
||||
|
||||
// misc
|
||||
{
|
||||
ini.Get("General", "LastFilename", &m_LastFilename);
|
||||
|
||||
m_ISOFolder.clear();
|
||||
int numGCMPaths;
|
||||
|
||||
if (ini.Get("General", "GCMPathes", &numGCMPaths, 0))
|
||||
{
|
||||
for (int i = 0; i < numGCMPaths; i++)
|
||||
{
|
||||
TCHAR tmp[16];
|
||||
sprintf(tmp, "GCMPath%i", i);
|
||||
std::string tmpPath;
|
||||
ini.Get("General", tmp, &tmpPath, "");
|
||||
m_ISOFolder.push_back(tmpPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// core
|
||||
{
|
||||
ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str());
|
||||
ini.Get("Core", "DSPPlugin", &m_LocalCoreStartupParameter.m_strDSPPlugin, m_DefaultDSPPlugin.c_str());
|
||||
ini.Get("Core", "PadPlugin", &m_LocalCoreStartupParameter.m_strPadPlugin, m_DefaultPADPlugin.c_str());
|
||||
|
||||
ini.Get("Core", "HLEBios", &m_LocalCoreStartupParameter.bHLEBios, true);
|
||||
ini.Get("Core", "UseDynarec", &m_LocalCoreStartupParameter.bUseJIT, true);
|
||||
ini.Get("Core", "UseDualCore", &m_LocalCoreStartupParameter.bUseDualCore, false);
|
||||
ini.Get("Core", "LockThreads", &m_LocalCoreStartupParameter.bLockThreads, true);
|
||||
ini.Get("Core", "OptimizeQuantizers", &m_LocalCoreStartupParameter.bOptimizeQuantizers, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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/
|
||||
|
||||
#ifndef _CONFIG_H
|
||||
#define _CONFIG_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Boot/Boot.h"
|
||||
|
||||
struct SConfig
|
||||
{
|
||||
// default plugins ... hard coded inside the ini
|
||||
std::string m_DefaultGFXPlugin;
|
||||
std::string m_DefaultDSPPlugin;
|
||||
std::string m_DefaultPADPlugin;
|
||||
|
||||
// name of the last used filename
|
||||
std::string m_LastFilename;
|
||||
|
||||
// gcm folder
|
||||
std::vector<std::string>m_ISOFolder;
|
||||
|
||||
SCoreStartupParameter m_LocalCoreStartupParameter;
|
||||
|
||||
// save settings
|
||||
void SaveSettings();
|
||||
|
||||
|
||||
// load settings
|
||||
void LoadSettings();
|
||||
|
||||
|
||||
static SConfig& GetInstance() {return(m_Instance);}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// constructor
|
||||
SConfig();
|
||||
|
||||
// destructor
|
||||
~SConfig();
|
||||
|
||||
static SConfig m_Instance;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
// 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"
|
||||
#ifndef _WIN32
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "FileSearch.h"
|
||||
|
||||
#include "StringUtil.h"
|
||||
|
||||
|
||||
CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, const CFileSearch::XStringVector& _rDirectories)
|
||||
{
|
||||
// Reverse the loop order for speed?
|
||||
for (size_t j = 0; j < _rSearchStrings.size(); j++)
|
||||
{
|
||||
for (size_t i = 0; i < _rDirectories.size(); i++)
|
||||
{
|
||||
FindFiles(_rSearchStrings[j], _rDirectories[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CFileSearch::FindFiles(const std::string& _searchString, const std::string& _strPath)
|
||||
{
|
||||
std::string GCMSearchPath;
|
||||
BuildCompleteFilename(GCMSearchPath, _strPath, _searchString);
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE FindFirst = FindFirstFile(GCMSearchPath.c_str(), &findData);
|
||||
|
||||
if (FindFirst != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
bool bkeepLooping = true;
|
||||
|
||||
while (bkeepLooping)
|
||||
{
|
||||
std::string strFilename;
|
||||
BuildCompleteFilename(strFilename, _strPath, findData.cFileName);
|
||||
|
||||
m_FileNames.push_back(strFilename);
|
||||
|
||||
bkeepLooping = FindNextFile(FindFirst, &findData) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
size_t dot_pos = _searchString.rfind(".");
|
||||
|
||||
if (dot_pos == std::string::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string ext = _searchString.substr(dot_pos);
|
||||
DIR* dir = opendir(_strPath.c_str());
|
||||
|
||||
if (!dir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dirent* dp;
|
||||
|
||||
while (true)
|
||||
{
|
||||
dp = readdir(dir);
|
||||
|
||||
if (!dp)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
std::string s(dp->d_name);
|
||||
|
||||
if ( (s.size() > ext.size()) && (!strcasecmp(s.substr(s.size() - ext.size()).c_str(), ext.c_str())) )
|
||||
{
|
||||
std::string full_name = _strPath + "/" + s;
|
||||
m_FileNames.push_back(full_name);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
const CFileSearch::XStringVector& CFileSearch::GetFileNames() const
|
||||
{
|
||||
return(m_FileNames);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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 __FILESEARCH_H_
|
||||
#define __FILESEARCH_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CFileSearch
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::vector<std::string>XStringVector;
|
||||
|
||||
CFileSearch(const XStringVector& _rSearchStrings, const XStringVector& _rDirectories);
|
||||
|
||||
const XStringVector& GetFileNames() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void FindFiles(const std::string& _searchString, const std::string& _strPath);
|
||||
|
||||
|
||||
XStringVector m_FileNames;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
#ifndef __FRAME_H_
|
||||
#define __FRAME_H_
|
||||
|
||||
class CGameListCtrl;
|
||||
class CFrame
|
||||
: public wxFrame
|
||||
{
|
||||
public:
|
||||
|
||||
CFrame(wxFrame* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& title = _T("Dolphin"),
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE);
|
||||
|
||||
void* GetRenderHandle() {return(m_Panel->GetHandle());}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CGameListCtrl* m_GameListCtrl;
|
||||
wxPanel* m_Panel;
|
||||
|
||||
enum EBitmaps
|
||||
{
|
||||
Toolbar_FileOpen,
|
||||
Toolbar_Refresh,
|
||||
Toolbar_Browse,
|
||||
Toolbar_Play,
|
||||
Toolbar_Play_Dis,
|
||||
Toolbar_Stop,
|
||||
Toolbar_Stop_Dis,
|
||||
Toolbar_Pause,
|
||||
Toolbar_PluginOptions,
|
||||
Toolbar_PluginOptions_Dis,
|
||||
Toolbar_PluginGFX,
|
||||
Toolbar_PluginDSP,
|
||||
Toolbar_PluginPAD,
|
||||
Toolbar_FullScreen,
|
||||
Toolbar_Help,
|
||||
Bitmaps_Max
|
||||
};
|
||||
|
||||
wxBitmap m_Bitmaps[Bitmaps_Max];
|
||||
wxBitmap m_BitmapsMenu[Bitmaps_Max];
|
||||
|
||||
void InitBitmaps();
|
||||
void PopulateToolbar(wxToolBar* toolBar);
|
||||
void RecreateToolbar();
|
||||
void CreateMenu();
|
||||
|
||||
// event handler
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnHelp(wxCommandEvent& event);
|
||||
void OnRefresh(wxCommandEvent& event);
|
||||
void OnPluginOptions(wxCommandEvent& event);
|
||||
void OnPluginGFX(wxCommandEvent& event);
|
||||
void OnPluginDSP(wxCommandEvent& event);
|
||||
void OnPluginPAD(wxCommandEvent& event);
|
||||
void OnOpen(wxCommandEvent& event);
|
||||
void OnPlay(wxCommandEvent& event);
|
||||
void OnStop(wxCommandEvent& event);
|
||||
void OnBrowse(wxCommandEvent& event);
|
||||
void OnMemcard(wxCommandEvent& event);
|
||||
void OnToggleFullscreen(wxCommandEvent& event);
|
||||
void OnToggleDualCore(wxCommandEvent& event);
|
||||
void OnToggleThrottle(wxCommandEvent& event);
|
||||
void OnToggleToolbar(wxCommandEvent& event);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
void OnHostMessage(wxCommandEvent& event);
|
||||
void OnLoadState(wxCommandEvent& event);
|
||||
void OnSaveState(wxCommandEvent& event);
|
||||
|
||||
|
||||
wxStatusBar* m_pStatusBar;
|
||||
wxMenuBar* m_pMenuBar;
|
||||
|
||||
wxMenuItem* m_pMenuItemPlay;
|
||||
wxMenuItem* m_pMenuItemStop;
|
||||
wxMenuItem* m_pPluginOptions;
|
||||
|
||||
wxMenuItem* m_pMenuItemLoad;
|
||||
wxMenuItem* m_pMenuItemSave;
|
||||
|
||||
wxBusyInfo* m_pBootProcessDialog;
|
||||
|
||||
void UpdateGUI();
|
||||
|
||||
|
||||
// old function that could be cool
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif // __FRAME_H_
|
||||
|
||||
@@ -0,0 +1,491 @@
|
||||
// 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 <wx/imaglist.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "FileSearch.h"
|
||||
#include "FileUtil.h"
|
||||
#include "StringUtil.h"
|
||||
#include "BootManager.h"
|
||||
#include "Config.h"
|
||||
#include "GameListCtrl.h"
|
||||
|
||||
|
||||
#if USE_XPM_BITMAPS
|
||||
#include "../resources/Flag_Europe.xpm"
|
||||
#include "../resources/Flag_France.xpm"
|
||||
#include "../resources/Flag_Japan.xpm"
|
||||
#include "../resources/Flag_USA.xpm"
|
||||
#endif // USE_XPM_BITMAPS
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
|
||||
|
||||
EVT_SIZE(CGameListCtrl::OnSize)
|
||||
EVT_RIGHT_DOWN(CGameListCtrl::OnRightClick)
|
||||
EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, CGameListCtrl::OnColBeginDrag)
|
||||
EVT_LIST_ITEM_SELECTED(LIST_CTRL, CGameListCtrl::OnSelected)
|
||||
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CGameListCtrl::OnActivated)
|
||||
EVT_LIST_COL_END_DRAG(LIST_CTRL, CGameListCtrl::OnColEndDrag)
|
||||
EVT_MENU(IDM_EDITPATCHFILE, CGameListCtrl::OnEditPatchFile)
|
||||
EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxListCtrl(parent, id, pos, size, style) // | wxLC_VIRTUAL)
|
||||
{
|
||||
InitBitmaps();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::InitBitmaps()
|
||||
{
|
||||
m_imageListSmall = new wxImageList(96, 32);
|
||||
SetImageList(m_imageListSmall, wxIMAGE_LIST_SMALL);
|
||||
m_FlagImageIndex.resize(DiscIO::IVolume::NUMBER_OF_COUNTRIES);
|
||||
wxIcon iconTemp;
|
||||
iconTemp.CopyFromBitmap(wxBitmap(Flag_Europe_xpm));
|
||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_EUROPE] = m_imageListSmall->Add(iconTemp);
|
||||
iconTemp.CopyFromBitmap(wxBitmap(Flag_France_xpm));
|
||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_FRANCE] = m_imageListSmall->Add(iconTemp);
|
||||
iconTemp.CopyFromBitmap(wxBitmap(Flag_USA_xpm));
|
||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_USA] = m_imageListSmall->Add(iconTemp);
|
||||
iconTemp.CopyFromBitmap(wxBitmap(Flag_Japan_xpm));
|
||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_JAP] = m_imageListSmall->Add(iconTemp);
|
||||
iconTemp.CopyFromBitmap(wxBitmap(Flag_Europe_xpm));
|
||||
m_FlagImageIndex[DiscIO::IVolume::COUNTRY_UNKNOWN] = m_imageListSmall->Add(iconTemp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::BrowseForDirectory()
|
||||
{
|
||||
wxString dirHome;
|
||||
wxGetHomeDir(&dirHome);
|
||||
|
||||
// browse
|
||||
wxDirDialog dialog(this, _T("Browse directory"), dirHome, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
|
||||
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
SConfig::GetInstance().m_ISOFolder.push_back(
|
||||
std::string(dialog.GetPath().ToAscii())
|
||||
);
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::Update()
|
||||
{
|
||||
Hide();
|
||||
|
||||
ScanForISOs();
|
||||
|
||||
ClearAll();
|
||||
|
||||
if (m_ISOFiles.size() != 0)
|
||||
{
|
||||
// add columns
|
||||
InsertColumn(COLUMN_BANNER, _T("Banner"));
|
||||
InsertColumn(COLUMN_TITLE, _T("Title"));
|
||||
InsertColumn(COLUMN_COMPANY, _T("Company"));
|
||||
InsertColumn(COLUMN_COUNTRY, _T(""));
|
||||
InsertColumn(COLUMN_SIZE, _T("Size"));
|
||||
InsertColumn(COLUMN_EMULATION_STATE, _T("Emulation"), wxLIST_FORMAT_LEFT);
|
||||
|
||||
// add all items
|
||||
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
|
||||
{
|
||||
InsertItemInReportView(i);
|
||||
}
|
||||
SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertColumn(COLUMN_BANNER, _T("No ISOs found"));
|
||||
|
||||
// data
|
||||
wxString buf(_T("Dolphin could not find any GC/Wii ISOs. Doubleclick here to browse for files..."));
|
||||
long item = InsertItem(0, buf, -1);
|
||||
SetItemFont(item, *wxITALIC_FONT);
|
||||
SetColumnWidth(item, wxLIST_AUTOSIZE);
|
||||
SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||
}
|
||||
|
||||
AutomaticColumnWidth();
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
wxColour blend50(const wxColour& c1, const wxColour& c2)
|
||||
{
|
||||
return(((c1.GetPixel() & 0xFEFEFE) >> 1) + ((c2.GetPixel() & 0xFEFEFE) >> 1) + 0x010101);
|
||||
}
|
||||
#endif
|
||||
|
||||
wxString NiceSizeFormat(s64 _size)
|
||||
{
|
||||
const char* sizes[] = {"b", "KB", "MB", "GB", "TB", "PB", "EB"};
|
||||
int s = 0;
|
||||
int frac = 0;
|
||||
|
||||
while (_size > (s64)1024)
|
||||
{
|
||||
s++;
|
||||
frac = (int)_size & 1023;
|
||||
_size /= (s64)1024;
|
||||
}
|
||||
|
||||
float f = (float)_size + ((float)frac / 1024.0f);
|
||||
|
||||
wxString NiceString;
|
||||
char tempstr[32];
|
||||
sprintf(tempstr,"%3.1f %s", f, sizes[s]);
|
||||
NiceString = wxString::FromAscii(tempstr);
|
||||
return(NiceString);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::InsertItemInReportView(size_t _Index)
|
||||
{
|
||||
CISOFile& rISOFile = m_ISOFiles[_Index];
|
||||
|
||||
int ImageIndex = -1;
|
||||
|
||||
if (rISOFile.GetImage().IsOk())
|
||||
{
|
||||
ImageIndex = m_imageListSmall->Add(rISOFile.GetImage());
|
||||
}
|
||||
|
||||
// data
|
||||
wxString buf;
|
||||
long ItemIndex = InsertItem(_Index, buf, ImageIndex);
|
||||
#ifdef _WIN32
|
||||
wxColour color = (_Index & 1) ? blend50(GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_WINDOW)) : GetSysColor(COLOR_WINDOW);
|
||||
#else
|
||||
wxColour color = (_Index & 1) ? 0xFFFFFF : 0xEEEEEE;
|
||||
#endif
|
||||
// background color color
|
||||
{
|
||||
wxListItem item;
|
||||
item.SetId(ItemIndex);
|
||||
item.SetBackgroundColour(color);
|
||||
SetItem(item);
|
||||
}
|
||||
|
||||
// title color
|
||||
{
|
||||
wxListItem item;
|
||||
item.SetId(ItemIndex);
|
||||
item.SetColumn(COLUMN_TITLE);
|
||||
item.SetText(wxString::FromAscii(rISOFile.GetName().c_str()));
|
||||
SetItem(item);
|
||||
}
|
||||
|
||||
// company color
|
||||
{
|
||||
wxListItem item;
|
||||
item.SetId(ItemIndex);
|
||||
item.SetColumn(COLUMN_COMPANY);
|
||||
item.SetText(wxString::FromAscii(rISOFile.GetCompany().c_str()));
|
||||
SetItem(item);
|
||||
}
|
||||
|
||||
// size
|
||||
{
|
||||
wxListItem item;
|
||||
item.SetId(ItemIndex);
|
||||
item.SetColumn(COLUMN_SIZE);
|
||||
item.SetText(NiceSizeFormat(rISOFile.GetFileSize()));
|
||||
SetItem(item);
|
||||
}
|
||||
|
||||
#ifndef __WXMSW__
|
||||
// country
|
||||
{
|
||||
// Can't do this in Windows - we use DrawSubItem instead, see below
|
||||
wxListItem item;
|
||||
item.m_itemId = ItemIndex;
|
||||
item.SetColumn(COLUMN_COUNTRY);
|
||||
item.SetBackgroundColour(color);
|
||||
DiscIO::IVolume::ECountry Country = rISOFile.GetCountry();
|
||||
|
||||
if (size_t(Country) < m_FlagImageIndex.size())
|
||||
{
|
||||
item.SetImage(m_FlagImageIndex[rISOFile.GetCountry()]);
|
||||
}
|
||||
|
||||
SetItem(item);
|
||||
}
|
||||
#endif // __WXMSW__
|
||||
|
||||
// item data
|
||||
SetItemData(ItemIndex, _Index);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::ScanForISOs()
|
||||
{
|
||||
m_ISOFiles.clear();
|
||||
|
||||
CFileSearch::XStringVector Directories(SConfig::GetInstance().m_ISOFolder);
|
||||
|
||||
CFileSearch::XStringVector Extensions;
|
||||
Extensions.push_back("*.iso");
|
||||
Extensions.push_back("*.gcm");
|
||||
Extensions.push_back("*.gcz");
|
||||
|
||||
CFileSearch FileSearch(Extensions, Directories);
|
||||
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
|
||||
|
||||
if (rFilenames.size() > 0)
|
||||
{
|
||||
wxProgressDialog dialog(_T("Scanning for ISOs"),
|
||||
_T("Scanning..."),
|
||||
rFilenames.size(), // range
|
||||
this, // parent
|
||||
wxPD_CAN_ABORT |
|
||||
wxPD_APP_MODAL |
|
||||
// wxPD_AUTO_HIDE | -- try this as well
|
||||
wxPD_ELAPSED_TIME |
|
||||
wxPD_ESTIMATED_TIME |
|
||||
wxPD_REMAINING_TIME |
|
||||
wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
|
||||
);
|
||||
|
||||
dialog.CenterOnParent();
|
||||
|
||||
for (size_t i = 0; i < rFilenames.size(); i++)
|
||||
{
|
||||
std::string FileName;
|
||||
SplitPath(rFilenames[i], NULL, &FileName, NULL);
|
||||
|
||||
wxString msg;
|
||||
char tempstring[128];
|
||||
sprintf(tempstring,"Scanning %s", FileName.c_str());
|
||||
msg = wxString::FromAscii(tempstring);
|
||||
|
||||
bool Cont = dialog.Update(i, msg);
|
||||
|
||||
if (!Cont)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
CISOFile ISOFile(rFilenames[i]);
|
||||
|
||||
if (ISOFile.IsValid())
|
||||
{
|
||||
m_ISOFiles.push_back(ISOFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::sort(m_ISOFiles.begin(), m_ISOFiles.end());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::OnColBeginDrag(wxListEvent& event)
|
||||
{
|
||||
event.Veto();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::OnColEndDrag(wxListEvent& WXUNUSED (event))
|
||||
{
|
||||
AutomaticColumnWidth();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::OnRightClick(wxMouseEvent& event)
|
||||
{
|
||||
// Focus the clicked item.
|
||||
int flags;
|
||||
long item = HitTest(event.GetPosition(), flags);
|
||||
if (item != wxNOT_FOUND) {
|
||||
SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
|
||||
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||
}
|
||||
const CISOFile *selected_iso = GetSelectedISO();
|
||||
if (selected_iso) {
|
||||
std::string unique_id = selected_iso->GetUniqueID();
|
||||
wxMenu popupMenu;
|
||||
std::string menu_text = StringFromFormat("Edit &patch file: %s.ini", unique_id.c_str());
|
||||
popupMenu.Append(IDM_EDITPATCHFILE, wxString::FromAscii(menu_text.c_str())); //Pretty much everything in wxwidgets is a wxString, try to convert to those first!
|
||||
popupMenu.Append(IDM_OPENCONTAININGFOLDER, wxString::FromAscii("Open &containing folder"));
|
||||
PopupMenu(&popupMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::OnActivated(wxListEvent& event)
|
||||
{
|
||||
if (m_ISOFiles.size() == 0)
|
||||
{
|
||||
BrowseForDirectory();
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t Index = event.GetData();
|
||||
if (Index < m_ISOFiles.size())
|
||||
{
|
||||
const CISOFile& rISOFile = m_ISOFiles[Index];
|
||||
BootManager::BootCore(rISOFile.GetFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CISOFile *
|
||||
CGameListCtrl::GetSelectedISO() const
|
||||
{
|
||||
int item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item == -1)
|
||||
return 0;
|
||||
else
|
||||
return &m_ISOFiles[GetItemData(item)];
|
||||
}
|
||||
|
||||
void
|
||||
CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event)) {
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
std::string path;
|
||||
SplitPath(iso->GetFileName(), &path, 0, 0);
|
||||
File::Explore(path);
|
||||
}
|
||||
|
||||
void
|
||||
CGameListCtrl::OnEditPatchFile(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
const CISOFile *iso = GetSelectedISO();
|
||||
if (!iso)
|
||||
return;
|
||||
std::string filename = "Patches/" + iso->GetUniqueID() + ".ini";
|
||||
if (!File::Exists(filename)) {
|
||||
if (AskYesNo("%s.ini does not exist. Do you want to create it?", iso->GetUniqueID().c_str())) {
|
||||
FILE *f = fopen(filename.c_str(), "w");
|
||||
fprintf(f, "# %s - %s\r\n\r\n", iso->GetUniqueID().c_str(), iso->GetName().c_str());
|
||||
fprintf(f, "[OnFrame]\r\n#Add memory patches here.\r\n\r\n");
|
||||
fprintf(f, "[ActionReplay]\r\n#Add decrypted action replay cheats here.\r\n");
|
||||
fclose(f);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
File::Launch(filename);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::OnSelected(wxListEvent& WXUNUSED (event))
|
||||
{}
|
||||
|
||||
|
||||
void CGameListCtrl::OnSize(wxSizeEvent& WXUNUSED (event))
|
||||
{
|
||||
AutomaticColumnWidth();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CGameListCtrl::MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem)
|
||||
{
|
||||
bool Result = false;
|
||||
#ifdef __WXMSW__
|
||||
switch (subitem)
|
||||
{
|
||||
case COLUMN_COUNTRY:
|
||||
{
|
||||
size_t Index = GetItemData(item);
|
||||
|
||||
if (Index < m_ISOFiles.size())
|
||||
{
|
||||
const CISOFile& rISO = m_ISOFiles[Index];
|
||||
wxRect SubItemRect;
|
||||
this->GetSubItemRect(item, subitem, SubItemRect);
|
||||
m_imageListSmall->Draw(m_FlagImageIndex[rISO.GetCountry()], rPaintDC, SubItemRect.GetLeft(), SubItemRect.GetTop());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
#endif
|
||||
|
||||
return(Result);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CGameListCtrl::AutomaticColumnWidth()
|
||||
{
|
||||
wxRect rc(GetClientRect());
|
||||
|
||||
if (GetColumnCount() == 1)
|
||||
{
|
||||
SetColumnWidth(0, rc.GetWidth());
|
||||
}
|
||||
else if (GetColumnCount() > 4)
|
||||
{
|
||||
SetColumnWidth(COLUMN_COUNTRY, 32);
|
||||
SetColumnWidth(COLUMN_BANNER, 106);
|
||||
|
||||
// width
|
||||
for (int i = 0; i < GetColumnCount() - 1; i++)
|
||||
{
|
||||
if ((i != COLUMN_COUNTRY) && (i != COLUMN_BANNER))
|
||||
{
|
||||
SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < GetColumnCount() - 1; i++)
|
||||
{
|
||||
size += GetColumnWidth(i);
|
||||
}
|
||||
|
||||
int rest = rc.GetWidth() - size - 3;
|
||||
|
||||
if (rest > 0)
|
||||
{
|
||||
SetColumnWidth(GetColumnCount() - 1, rest);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetColumnWidth(GetColumnCount() - 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// 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 __GAMELIST_CTRL_H_
|
||||
#define __GAMELIST_CTRL_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
#include "ISOFile.h"
|
||||
|
||||
class CGameListCtrl : public wxListCtrl
|
||||
{
|
||||
public:
|
||||
|
||||
CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
|
||||
void Update();
|
||||
void BrowseForDirectory();
|
||||
const CISOFile *GetSelectedISO() const;
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_BANNER = 0,
|
||||
COLUMN_TITLE,
|
||||
COLUMN_COMPANY,
|
||||
COLUMN_COUNTRY,
|
||||
COLUMN_SIZE,
|
||||
COLUMN_EMULATION_STATE,
|
||||
NUMBER_OF_COLUMN
|
||||
};
|
||||
|
||||
std::vector<int>m_FlagImageIndex;
|
||||
|
||||
bool m_test;
|
||||
std::vector<CISOFile> m_ISOFiles;
|
||||
|
||||
void InitBitmaps();
|
||||
void InsertItemInReportView(size_t _Index);
|
||||
void ScanForISOs();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
// events
|
||||
void OnRightClick(wxMouseEvent& event);
|
||||
|
||||
void OnColBeginDrag(wxListEvent& event);
|
||||
void OnColEndDrag(wxListEvent& event);
|
||||
void OnSelected(wxListEvent& event);
|
||||
void OnActivated(wxListEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEditPatchFile(wxCommandEvent& event);
|
||||
void OnOpenContainingFolder(wxCommandEvent& event);
|
||||
|
||||
virtual bool MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem);
|
||||
|
||||
void AutomaticColumnWidth();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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"
|
||||
@@ -0,0 +1,121 @@
|
||||
// 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 _GLOBALS_H
|
||||
#define _GLOBALS_H
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_LOADSTATE = 200,
|
||||
IDM_SAVESTATE,
|
||||
IDM_SAVESLOT1,
|
||||
IDM_SAVESLOT2,
|
||||
IDM_SAVESLOT3,
|
||||
IDM_SAVESLOT4,
|
||||
IDM_SAVESLOT5,
|
||||
IDM_SAVESLOT6,
|
||||
IDM_SAVESLOT7,
|
||||
IDM_SAVESLOT8,
|
||||
IDM_SAVESLOT9,
|
||||
IDM_SAVESLOT10,
|
||||
IDM_LOADSLOT1,
|
||||
IDM_LOADSLOT2,
|
||||
IDM_LOADSLOT3,
|
||||
IDM_LOADSLOT4,
|
||||
IDM_LOADSLOT5,
|
||||
IDM_LOADSLOT6,
|
||||
IDM_LOADSLOT7,
|
||||
IDM_LOADSLOT8,
|
||||
IDM_LOADSLOT9,
|
||||
IDM_LOADSLOT10,
|
||||
IDM_PLAY,
|
||||
IDM_STOP,
|
||||
IDM_BROWSE,
|
||||
IDM_MEMCARD,
|
||||
IDM_EDITPATCHFILE,
|
||||
IDM_OPENCONTAININGFOLDER,
|
||||
IDM_PLUGIN_OPTIONS,
|
||||
IDM_CONFIG_GFX_PLUGIN,
|
||||
IDM_CONFIG_DSP_PLUGIN,
|
||||
IDM_CONFIG_PAD_PLUGIN,
|
||||
IDM_TOGGLE_FULLSCREEN,
|
||||
IDM_TOGGLE_DUALCORE,
|
||||
IDM_TOGGLE_TOOLBAR,
|
||||
IDM_NOTIFYMAPLOADED,
|
||||
IDM_UPDATELOGDISPLAY,
|
||||
IDM_UPDATEDISASMDIALOG,
|
||||
IDM_UPDATEGUI,
|
||||
IDM_UPDATESTATUSBAR,
|
||||
IDM_UPDATEBREAKPOINTS,
|
||||
IDM_HOST_MESSAGE,
|
||||
IDM_BOOTING_STARTED,
|
||||
IDM_BOOTING_ENDED,
|
||||
IDM_HELPABOUT,
|
||||
IDM_HELPWEBSITE,
|
||||
IDM_HELPGOOGLECODE,
|
||||
ID_TOOLBAR = 500,
|
||||
LIST_CTRL = 1000
|
||||
};
|
||||
|
||||
#define wxUSE_XPM_IN_MSW 1
|
||||
#define USE_XPM_BITMAPS 1
|
||||
|
||||
// For compilers that support precompilation, includes <wx/wx.h>.
|
||||
//#include <wx/wxprec.h>
|
||||
|
||||
//#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
//#endif
|
||||
|
||||
#include <wx/toolbar.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/aboutdlg.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/srchctrl.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/imagpng.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/cmdline.h>
|
||||
#include <wx/busyinfo.h>
|
||||
|
||||
// define this to use XPMs everywhere (by default, BMPs are used under Win)
|
||||
// BMPs use less space, but aren't compiled into the executable on other platforms
|
||||
|
||||
#if USE_XPM_BITMAPS && defined (__WXMSW__) && !wxUSE_XPM_IN_MSW
|
||||
#error You need to enable XPM support to use XPM bitmaps with toolbar!
|
||||
#endif // USE_XPM_BITMAPS
|
||||
|
||||
|
||||
//
|
||||
// custom message macro
|
||||
//
|
||||
|
||||
#define EVT_HOST_COMMAND(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY(\
|
||||
wxEVT_HOST_COMMAND, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxCommandEventFunction, &fn), \
|
||||
(wxObject*) NULL \
|
||||
),
|
||||
|
||||
extern const wxEventType wxEVT_HOST_COMMAND;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
// 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 <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Globals.h"
|
||||
#include "ISOFile.h"
|
||||
|
||||
#include "VolumeCreator.h"
|
||||
#include "Filesystem.h"
|
||||
#include "BannerLoader.h"
|
||||
#include "FileSearch.h"
|
||||
|
||||
#define DVD_BANNER_WIDTH 96
|
||||
#define DVD_BANNER_HEIGHT 32
|
||||
|
||||
static u32 g_ImageTemp[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
|
||||
|
||||
CISOFile::CISOFile(const std::string& _rFileName)
|
||||
: m_FileName(_rFileName),
|
||||
m_FileSize(0),
|
||||
m_Valid(false)
|
||||
{
|
||||
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(_rFileName);
|
||||
|
||||
if (pVolume != NULL)
|
||||
{
|
||||
m_Name = _rFileName;
|
||||
m_Country = pVolume->GetCountry();
|
||||
m_FileSize = pVolume->GetSize();
|
||||
m_Name = pVolume->GetName();
|
||||
m_UniqueID = pVolume->GetUniqueID();
|
||||
|
||||
// check if we can get some infos from the banner file too
|
||||
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(*pVolume);
|
||||
|
||||
if (pFileSystem != NULL)
|
||||
{
|
||||
DiscIO::IBannerLoader* pBannerLoader = DiscIO::CreateBannerLoader(*pFileSystem);
|
||||
|
||||
if (pBannerLoader != NULL)
|
||||
{
|
||||
if (pBannerLoader->IsValid())
|
||||
{
|
||||
pBannerLoader->GetName(m_Name, 0); //m_Country == DiscIO::IVolume::COUNTRY_JAP ? 1 : 0);
|
||||
pBannerLoader->GetCompany(m_Company);
|
||||
|
||||
if (pBannerLoader->GetBanner(g_ImageTemp))
|
||||
{
|
||||
unsigned char* pImage = (unsigned char*)malloc(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3);
|
||||
|
||||
for (size_t i = 0; i < DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT; i++)
|
||||
{
|
||||
pImage[i * 3 + 0] = (g_ImageTemp[i] & 0xFF0000) >> 16;
|
||||
pImage[i * 3 + 1] = (g_ImageTemp[i] & 0x00FF00) >> 8;
|
||||
pImage[i * 3 + 2] = (g_ImageTemp[i] & 0x0000FF) >> 0;
|
||||
}
|
||||
|
||||
m_Image.Create(DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT, pImage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// default banner
|
||||
}
|
||||
|
||||
delete pBannerLoader;
|
||||
}
|
||||
|
||||
delete pFileSystem;
|
||||
}
|
||||
|
||||
delete pVolume;
|
||||
|
||||
m_Valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CISOFile::~CISOFile()
|
||||
{}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// 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 __ISOFILE_H_
|
||||
#define __ISOFILE_H_
|
||||
|
||||
#include "Volume.h"
|
||||
|
||||
class CISOFile
|
||||
{
|
||||
public:
|
||||
|
||||
CISOFile(const std::string& _rFileName);
|
||||
~CISOFile();
|
||||
|
||||
bool IsValid() const {return(m_Valid);}
|
||||
|
||||
const std::string& GetFileName() const {return(m_FileName);}
|
||||
|
||||
const std::string& GetName() const {return(m_Name);}
|
||||
|
||||
const std::string& GetCompany() const {return(m_Company);}
|
||||
|
||||
const std::string& GetUniqueID() const {return(m_UniqueID);}
|
||||
|
||||
DiscIO::IVolume::ECountry GetCountry() const {return(m_Country);}
|
||||
|
||||
u64 GetFileSize() const {return(m_FileSize);}
|
||||
|
||||
const wxImage& GetImage() const {return(m_Image);}
|
||||
|
||||
bool operator < (const CISOFile &other) const {
|
||||
// HACK - they end up in reverse order in the list view
|
||||
return strcmp(m_Name.c_str(), other.m_Name.c_str()) > 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::string m_FileName;
|
||||
std::string m_Name;
|
||||
std::string m_Company;
|
||||
std::string m_UniqueID;
|
||||
|
||||
u64 m_FileSize;
|
||||
|
||||
DiscIO::IVolume::ECountry m_Country;
|
||||
|
||||
wxImage m_Image;
|
||||
|
||||
bool m_Valid;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,276 @@
|
||||
// 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 <vector>
|
||||
#include <string>
|
||||
#ifdef WIN32
|
||||
#include "svnrev.h"
|
||||
#endif
|
||||
#include "CPUDetect.h"
|
||||
#include "Globals.h"
|
||||
#include "Common.h"
|
||||
#include "IniFile.h"
|
||||
#include "Main.h"
|
||||
#include "Frame.h"
|
||||
#include "Config.h"
|
||||
#include "CodeWindow.h"
|
||||
#include "ExtendedTrace.h"
|
||||
|
||||
IMPLEMENT_APP(DolphinApp)
|
||||
|
||||
CFrame* main_frame = NULL;
|
||||
CCodeWindow* g_pCodeWindow = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
//Has no error handling.
|
||||
//I think that if an error occurs here there's no way to handle it anyway.
|
||||
LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
|
||||
//EnterCriticalSection(&g_uefcs);
|
||||
|
||||
FILE* file=NULL;
|
||||
fopen_s(&file, "exceptioninfo.txt", "a");
|
||||
fseek(file, 0, SEEK_END);
|
||||
etfprint(file, "\n");
|
||||
//etfprint(file, g_buildtime);
|
||||
//etfprint(file, "\n");
|
||||
//dumpCurrentDate(file);
|
||||
etfprintf(file, "Unhandled Exception\n Code: 0x%08X\n",
|
||||
e->ExceptionRecord->ExceptionCode);
|
||||
#ifndef _M_X64
|
||||
STACKTRACE2(file, e->ContextRecord->Eip, e->ContextRecord->Esp, e->ContextRecord->Ebp);
|
||||
#else
|
||||
STACKTRACE2(file, e->ContextRecord->Rip, e->ContextRecord->Rsp, e->ContextRecord->Rbp);
|
||||
#endif
|
||||
fclose(file);
|
||||
_flushall();
|
||||
|
||||
//LeaveCriticalSection(&g_uefcs);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
#endif
|
||||
|
||||
// The `main program' equivalent, creating the windows and returning the
|
||||
// main frame
|
||||
bool DolphinApp::OnInit()
|
||||
{
|
||||
DetectCPU();
|
||||
#ifndef _WIN32
|
||||
// RegisterPanicAlertHandler(&wxPanicAlert);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
EXTENDEDTRACEINITIALIZE(".");
|
||||
SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter);
|
||||
|
||||
// TODO: if First Boot
|
||||
if (!cpu_info.bSSE2)
|
||||
{
|
||||
MessageBox(0, _T("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
|
||||
"Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
|
||||
"Sayonara!\n"), "Dolphin", MB_ICONINFORMATION);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (!cpu_info.bSSE2)
|
||||
{
|
||||
printf("%s", "Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
|
||||
"Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
|
||||
"Sayonara!\n");
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool UseDebugger = false;
|
||||
|
||||
#if wxUSE_CMDLINE_PARSER
|
||||
wxCmdLineEntryDesc cmdLineDesc[] =
|
||||
{
|
||||
{wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP},
|
||||
{wxCMD_LINE_SWITCH, _T("d"), _T("debugger"), _T("Opens the debugger")},
|
||||
{wxCMD_LINE_NONE}
|
||||
};
|
||||
|
||||
//gets the passed media files from command line
|
||||
wxCmdLineParser parser(cmdLineDesc, argc, argv);
|
||||
|
||||
// get filenames from the command line
|
||||
if (parser.Parse() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
UseDebugger = parser.Found(_T("debugger"));
|
||||
#endif
|
||||
|
||||
SConfig::GetInstance().LoadSettings();
|
||||
wxInitAllImageHandlers();
|
||||
// Create the main frame window
|
||||
#ifdef _WIN32
|
||||
#ifdef _DEBUG
|
||||
const char *title = "Dolphin Debug SVN R " SVN_REV_STR;
|
||||
#else
|
||||
const char *title = "Dolphin SVN R " SVN_REV_STR;
|
||||
#endif
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
const char *title = "Dolphin Debug SVN Linux";
|
||||
#else
|
||||
const char *title = "Dolphin SVN Linux";
|
||||
#endif
|
||||
#endif
|
||||
main_frame = new CFrame((wxFrame*) NULL, wxID_ANY, wxString::FromAscii(title),
|
||||
wxPoint(100, 100), wxSize(800, 600));
|
||||
|
||||
// create debugger
|
||||
if (UseDebugger)
|
||||
{
|
||||
g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, main_frame);
|
||||
g_pCodeWindow->Show(true);
|
||||
}
|
||||
|
||||
SetTopWindow(main_frame);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DolphinApp::OnEndSession()
|
||||
{
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
|
||||
bool wxPanicAlert(const char* text, bool /*yes_no*/)
|
||||
{
|
||||
wxMessageBox(wxString::FromAscii(text), _T("PANIC ALERT"));
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
void Host_BootingStarted()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_BOOTING_STARTED);
|
||||
wxPostEvent(main_frame, event);
|
||||
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
wxPostEvent(g_pCodeWindow, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Host_BootingEnded()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_BOOTING_ENDED);
|
||||
wxPostEvent(main_frame, event);
|
||||
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
wxPostEvent(g_pCodeWindow, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// OK, this thread boundary is DANGEROUS on linux
|
||||
// wxPostEvent / wxAddPendingEvent is the solution.
|
||||
void Host_NotifyMapLoaded()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFYMAPLOADED);
|
||||
wxPostEvent(main_frame, event);
|
||||
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
wxPostEvent(g_pCodeWindow, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Host_UpdateLogDisplay()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATELOGDISPLAY);
|
||||
wxPostEvent(main_frame, event);
|
||||
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
wxPostEvent(g_pCodeWindow, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Host_UpdateDisasmDialog()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEDISASMDIALOG);
|
||||
wxPostEvent(main_frame, event);
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
wxPostEvent(g_pCodeWindow, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Host_UpdateMainFrame()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEGUI);
|
||||
wxPostEvent(main_frame, event);
|
||||
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
wxPostEvent(g_pCodeWindow, event);
|
||||
}
|
||||
}
|
||||
|
||||
void Host_UpdateBreakPointView()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEBREAKPOINTS);
|
||||
wxPostEvent(main_frame, event);
|
||||
|
||||
if (g_pCodeWindow)
|
||||
{
|
||||
wxPostEvent(g_pCodeWindow, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Host_UpdateMemoryView()
|
||||
{}
|
||||
|
||||
|
||||
void Host_SetDebugMode(bool)
|
||||
{}
|
||||
|
||||
|
||||
void Host_SetWaitCursor(bool enable)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (enable)
|
||||
{
|
||||
SetCursor(LoadCursor(NULL, IDC_WAIT));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Host_UpdateStatusBar(const char* _pText)
|
||||
{
|
||||
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
|
||||
event.SetString(wxString::FromAscii(_pText));
|
||||
|
||||
wxPostEvent(main_frame, event);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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 __MAIN_H_
|
||||
#define __MAIN_H_
|
||||
|
||||
// Define a new application
|
||||
class DolphinApp
|
||||
: public wxApp
|
||||
{
|
||||
public:
|
||||
|
||||
bool OnInit();
|
||||
void OnEndSession();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef _WIN32
|
||||
//#include <curses.h>
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Common.h"
|
||||
#include "ISOFile.h"
|
||||
#include "CPUDetect.h"
|
||||
|
||||
#include "BootManager.h"
|
||||
void* g_pCodeWindow = NULL;
|
||||
void* main_frame = NULL;
|
||||
bool wxPanicAlert(const char* text, bool /*yes_no*/)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
void Host_BootingStarted(){}
|
||||
|
||||
|
||||
void Host_BootingEnded(){}
|
||||
|
||||
|
||||
// OK, this thread boundary is DANGEROUS on linux
|
||||
// wxPostEvent / wxAddPendingEvent is the solution.
|
||||
void Host_NotifyMapLoaded(){}
|
||||
|
||||
|
||||
void Host_UpdateLogDisplay(){}
|
||||
|
||||
|
||||
void Host_UpdateDisasmDialog(){}
|
||||
|
||||
|
||||
void Host_UpdateMainFrame(){}
|
||||
|
||||
void Host_UpdateBreakPointView(){}
|
||||
|
||||
|
||||
void Host_UpdateMemoryView(){}
|
||||
|
||||
|
||||
void Host_SetDebugMode(bool){}
|
||||
|
||||
|
||||
void Host_SetWaitCursor(bool enable){}
|
||||
|
||||
|
||||
void Host_CreateDisplay(){}
|
||||
|
||||
|
||||
void Host_CloseDisplay(){}
|
||||
|
||||
void Host_UpdateStatusBar(const char* _pText){}
|
||||
|
||||
// Include SDL header so it can hijack main().
|
||||
#include <SDL.h>
|
||||
#include "cmdline.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
gengetopt_args_info args_info;
|
||||
|
||||
if (cmdline_parser (argc, argv, &args_info) != 0)
|
||||
return(1);
|
||||
|
||||
if (args_info.inputs_num < 1)
|
||||
{
|
||||
fprintf(stderr, "Please supply at least one argument - the ISO to boot.\n");
|
||||
return(1);
|
||||
}
|
||||
std::string bootFile(args_info.inputs[0]);
|
||||
|
||||
DetectCPU();
|
||||
BootManager::BootCore(bootFile);
|
||||
usleep(2000 * 1000 * 1000);
|
||||
// while (!getch()) {
|
||||
// usleep(20);
|
||||
// }
|
||||
|
||||
cmdline_parser_free (&args_info);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
// 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 "MemcardManager.h"
|
||||
|
||||
#include "wx/mstream.h"
|
||||
|
||||
const u8 hdr[] = {
|
||||
0x42,0x4D,
|
||||
0x38,0x30,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x36,0x00,0x00,0x00,
|
||||
0x28,0x00,0x00,0x00,
|
||||
0x20,0x00,0x00,0x00, //W
|
||||
0x20,0x00,0x00,0x00, //H
|
||||
0x01,0x00,
|
||||
0x20,0x00,
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x02,0x30,0x00,0x00, //data size
|
||||
0x12,0x0B,0x00,0x00,
|
||||
0x12,0x0B,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00
|
||||
};
|
||||
|
||||
wxBitmap wxBitmapFromMemoryRGBA(const unsigned char* data, int width, int height)
|
||||
{
|
||||
int stride = (4*width);
|
||||
|
||||
int bytes = (stride*height) + sizeof(hdr);
|
||||
|
||||
bytes = (bytes+3)&(~3);
|
||||
|
||||
u8 *pdata = new u8[bytes];
|
||||
|
||||
memset(pdata,0,bytes);
|
||||
memcpy(pdata,hdr,sizeof(hdr));
|
||||
|
||||
u8 *pixelData = pdata + sizeof(hdr);
|
||||
|
||||
for(int y=0;y<height;y++)
|
||||
{
|
||||
memcpy(pixelData+y*stride,data+(height-y-1)*stride,stride);
|
||||
}
|
||||
|
||||
*(int*)(pdata+18) = width;
|
||||
*(int*)(pdata+22) = height;
|
||||
*(u32*)(pdata+34) = bytes-sizeof(hdr);
|
||||
|
||||
wxMemoryInputStream is(pdata, bytes);
|
||||
wxBitmap map(wxImage(is, wxBITMAP_TYPE_BMP, -1), -1);
|
||||
|
||||
delete pdata;
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(CMemcardManager, wxDialog)
|
||||
EVT_CLOSE(CMemcardManager::OnClose)
|
||||
EVT_BUTTON(ID_COPYRIGHT,CMemcardManager::CopyDeleteClick)
|
||||
EVT_BUTTON(ID_COPYLEFT,CMemcardManager::CopyDeleteClick)
|
||||
EVT_BUTTON(ID_DELETERIGHT,CMemcardManager::CopyDeleteClick)
|
||||
EVT_BUTTON(ID_DELETELEFT,CMemcardManager::CopyDeleteClick)
|
||||
EVT_FILEPICKER_CHANGED(ID_MEMCARD1PATH,CMemcardManager::OnPathChange)
|
||||
EVT_FILEPICKER_CHANGED(ID_MEMCARD2PATH,CMemcardManager::OnPathChange)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
||||
: wxDialog(parent, id, title, position, size, style)
|
||||
{
|
||||
memoryCard[0]=NULL;
|
||||
memoryCard[1]=NULL;
|
||||
CreateGUIControls();
|
||||
}
|
||||
|
||||
CMemcardManager::~CMemcardManager()
|
||||
{
|
||||
if (memoryCard[0]) {
|
||||
delete memoryCard[0];
|
||||
memoryCard[0] = NULL;
|
||||
}
|
||||
if (memoryCard[1]) {
|
||||
delete memoryCard[1];
|
||||
memoryCard[1] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CMemcardManager::CreateGUIControls()
|
||||
{
|
||||
// buttons
|
||||
m_CopyRight = new wxButton(this, ID_COPYRIGHT, wxT("->Copy->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_CopyLeft = new wxButton(this, ID_COPYLEFT, wxT("<-Copy<-"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
|
||||
m_DeleteRight = new wxButton(this, ID_DELETERIGHT, wxT("Delete->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_DeleteLeft = new wxButton(this, ID_DELETELEFT, wxT("<-Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
|
||||
// sizers that double as wxStaticBoxes
|
||||
sMemcard1 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Memory Card 1"));
|
||||
sMemcard2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Memory Card 2"));
|
||||
|
||||
// create the controls for both memcards
|
||||
// will change Mem*.raw to *.raw, when loading invalid .raw files doesn't crash the app :/
|
||||
m_Memcard1Path = new wxFilePickerCtrl(this, ID_MEMCARD1PATH, wxEmptyString, wxT("Choose a memory card:"),
|
||||
wxT("Dolphin memcards (Mem*.raw)|Mem*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN);
|
||||
m_Memcard2Path = new wxFilePickerCtrl(this, ID_MEMCARD2PATH, wxEmptyString, wxT("Choose a memory card:"),
|
||||
wxT("Dolphin memcards (Mem*.raw)|Mem*.raw"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_FILE_MUST_EXIST|wxFLP_OPEN);
|
||||
|
||||
m_MemcardList[0] = new wxListCtrl(this, ID_MEMCARD1LIST, wxDefaultPosition, wxSize(350,400),
|
||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
|
||||
m_MemcardList[1] = new wxListCtrl(this, ID_MEMCARD2LIST, wxDefaultPosition, wxSize(350,400),
|
||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL);
|
||||
|
||||
m_MemcardList[0]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
|
||||
m_MemcardList[1]->AssignImageList(new wxImageList(96,32),wxIMAGE_LIST_SMALL);
|
||||
|
||||
// mmmm sizer goodness
|
||||
wxBoxSizer* sButtons;
|
||||
sButtons = new wxBoxSizer(wxVERTICAL);
|
||||
sButtons->AddStretchSpacer(1);
|
||||
sButtons->Add(m_CopyRight, 0, 0, 5);
|
||||
sButtons->Add(m_CopyLeft, 0, 0, 5);
|
||||
sButtons->AddStretchSpacer(2);
|
||||
sButtons->Add(m_DeleteRight, 0, 0, 5);
|
||||
sButtons->Add(m_DeleteLeft, 0, 0, 5);
|
||||
sButtons->AddStretchSpacer(1);
|
||||
|
||||
sMemcard1->Add(m_Memcard1Path, 0, wxEXPAND|wxALL, 5);
|
||||
sMemcard1->Add(m_MemcardList[0], 1, wxEXPAND|wxALL, 5);
|
||||
sMemcard2->Add(m_Memcard2Path, 0, wxEXPAND|wxALL, 5);
|
||||
sMemcard2->Add(m_MemcardList[1], 1, wxEXPAND|wxALL, 5);
|
||||
|
||||
//wxBoxSizer* sMain;
|
||||
sMain = new wxBoxSizer(wxHORIZONTAL);
|
||||
sMain->Add(sMemcard1, 1, wxEXPAND|wxALL, 5);
|
||||
sMain->Add(sButtons, 0, wxEXPAND, 0);
|
||||
sMain->Add(sMemcard2, 1, wxEXPAND|wxALL, 5);
|
||||
|
||||
CenterOnParent();
|
||||
this->SetSizer(sMain);
|
||||
sMain->SetSizeHints(this);
|
||||
}
|
||||
|
||||
void CMemcardManager::OnClose(wxCloseEvent& WXUNUSED (event))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
|
||||
{
|
||||
switch(event.GetId())
|
||||
{
|
||||
case ID_MEMCARD1PATH:
|
||||
ReloadMemcard(event.GetPath().mb_str(), 0);
|
||||
break;
|
||||
case ID_MEMCARD2PATH:
|
||||
ReloadMemcard(event.GetPath().mb_str(), 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
|
||||
{
|
||||
int index0 = m_MemcardList[0]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);;
|
||||
int index1 = m_MemcardList[1]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);;
|
||||
|
||||
switch(event.GetId())
|
||||
{
|
||||
case ID_COPYRIGHT:
|
||||
if(index0 != -1 && m_MemcardList[1]->GetItemCount() > 0)
|
||||
{
|
||||
memoryCard[1]->CopyFrom(*memoryCard[0], index0);
|
||||
memoryCard[1]->Save();
|
||||
ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1);
|
||||
}
|
||||
break;
|
||||
case ID_COPYLEFT:
|
||||
if(index1 != -1 && m_MemcardList[0]->GetItemCount() > 0)
|
||||
{
|
||||
memoryCard[0]->CopyFrom(*memoryCard[1], index1);
|
||||
memoryCard[0]->Save();
|
||||
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
|
||||
}
|
||||
break;
|
||||
case ID_DELETERIGHT:
|
||||
if(index1 != -1)
|
||||
{
|
||||
memoryCard[1]->RemoveFile(index1);
|
||||
memoryCard[1]->Save();
|
||||
ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1);
|
||||
}
|
||||
break;
|
||||
case ID_DELETELEFT:
|
||||
if(index0 != -1)
|
||||
{
|
||||
memoryCard[0]->RemoveFile(index0);
|
||||
memoryCard[0]->Save();
|
||||
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CMemcardManager::ReloadMemcard(const char *fileName, int card)
|
||||
{
|
||||
if(memoryCard[card]) delete memoryCard[card];
|
||||
|
||||
// TODO: add error checking and banners/icons
|
||||
memoryCard[card] = new GCMemcard(fileName);
|
||||
|
||||
m_MemcardList[card]->Hide();
|
||||
m_MemcardList[card]->ClearAll();
|
||||
m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _T("Banner"));
|
||||
m_MemcardList[card]->InsertColumn(COLUMN_TITLE, _T("Title"));
|
||||
m_MemcardList[card]->InsertColumn(COLUMN_COMMENT, _T("Comment"));
|
||||
m_MemcardList[card]->InsertColumn(COLUMN_ICON, _T("Icon"));
|
||||
|
||||
wxImageList *list=m_MemcardList[card]->GetImageList(wxIMAGE_LIST_SMALL);
|
||||
list->RemoveAll();
|
||||
|
||||
int nFiles = memoryCard[card]->GetNumFiles();
|
||||
|
||||
int *images = new int[nFiles*2];
|
||||
for(int i=0;i<nFiles;i++)
|
||||
{
|
||||
static u32 pxdata[96*32];
|
||||
static u8 animDelay[8];
|
||||
static u32 animData[32*32*8];
|
||||
|
||||
int numFrames = memoryCard[card]->ReadAnimRGBA8(i,animData,animDelay);
|
||||
|
||||
if(!memoryCard[card]->ReadBannerRGBA8(i,pxdata))
|
||||
{
|
||||
memset(pxdata,0,96*32*4);
|
||||
|
||||
if(numFrames>0) // just use the first one
|
||||
{
|
||||
u32 *icdata = animData;
|
||||
|
||||
for(int y=0;y<32;y++)
|
||||
{
|
||||
for(int x=0;x<32;x++)
|
||||
{
|
||||
pxdata[y*96+x+32] = icdata[y*32+x] /* | 0xFF000000 */;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxBitmap map = wxBitmapFromMemoryRGBA((u8*)pxdata,96,32);
|
||||
images[i*2] = list->Add(map);
|
||||
|
||||
if(numFrames>0)
|
||||
{
|
||||
memset(pxdata,0,96*32*4);
|
||||
for(int y=0;y<32;y++)
|
||||
{
|
||||
for(int x=0;x<32;x++)
|
||||
{
|
||||
pxdata[y*96+x] = animData[y*32+x];
|
||||
}
|
||||
}
|
||||
|
||||
wxBitmap icon = wxBitmapFromMemoryRGBA((u8*)pxdata,96,32);
|
||||
images[i*2+1] = list->Add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0;i<nFiles;i++)
|
||||
{
|
||||
char title[32];
|
||||
char comment[32];
|
||||
|
||||
if(!memoryCard[card]->GetComment1(i,title)) title[0]=0;
|
||||
if(!memoryCard[card]->GetComment2(i,comment)) comment[0]=0;
|
||||
|
||||
int index = m_MemcardList[card]->InsertItem(i, wxString::FromAscii("row"));
|
||||
m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxString::FromAscii(""));
|
||||
m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxString::FromAscii(title));
|
||||
m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxString::FromAscii(comment));
|
||||
m_MemcardList[card]->SetItem(index, COLUMN_ICON, wxString::FromAscii(""));
|
||||
|
||||
if(images[i]>=0)
|
||||
{
|
||||
m_MemcardList[card]->SetItemImage(index, images[i*2]);
|
||||
m_MemcardList[card]->SetItemColumnImage(index, COLUMN_ICON, images[i*2+1]);
|
||||
}
|
||||
}
|
||||
m_MemcardList[card]->Show();
|
||||
|
||||
delete[] images;
|
||||
|
||||
// automatic column width
|
||||
for (int i = 0; i < m_MemcardList[card]->GetColumnCount(); i++)
|
||||
{
|
||||
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// 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 __MEMCARD_MANAGER_h__
|
||||
#define __MEMCARD_MANAGER_h__
|
||||
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/imaglist.h>
|
||||
|
||||
#include "MemoryCards/GCMemcard.h"
|
||||
|
||||
#undef MEMCARD_MANAGER_STYLE
|
||||
#define MEMCARD_MANAGER_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX | wxRESIZE_BORDER | wxMAXIMIZE_BOX
|
||||
|
||||
class CMemcardManager
|
||||
: public wxDialog
|
||||
{
|
||||
public:
|
||||
|
||||
CMemcardManager(wxWindow* parent, wxWindowID id = 1, const wxString& title = wxT("Memory Card Manager WARNING-Make backups before using, will probably mangle stuff!"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = MEMCARD_MANAGER_STYLE);
|
||||
virtual ~CMemcardManager();
|
||||
|
||||
private:
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
wxBoxSizer* sMain;
|
||||
wxButton* m_CopyRight;
|
||||
wxButton* m_CopyLeft;
|
||||
wxButton* m_DeleteRight;
|
||||
wxButton* m_DeleteLeft;
|
||||
wxStaticBoxSizer* sMemcard1;
|
||||
wxStaticBoxSizer* sMemcard2;
|
||||
wxFilePickerCtrl* m_Memcard1Path;
|
||||
wxFilePickerCtrl* m_Memcard2Path;
|
||||
wxListCtrl* m_MemcardList[2];
|
||||
wxTimer* m_Timer;
|
||||
|
||||
int nframe;
|
||||
|
||||
enum
|
||||
{
|
||||
ID_COPYRIGHT = 1000,
|
||||
ID_COPYLEFT,
|
||||
ID_DELETERIGHT,
|
||||
ID_DELETELEFT,
|
||||
ID_MEMCARD1PATH,
|
||||
ID_MEMCARD2PATH,
|
||||
ID_MEMCARD1LIST,
|
||||
ID_MEMCARD2LIST,
|
||||
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_BANNER = 0,
|
||||
COLUMN_TITLE,
|
||||
COLUMN_COMMENT,
|
||||
COLUMN_ICON,
|
||||
NUMBER_OF_COLUMN
|
||||
};
|
||||
|
||||
GCMemcard *memoryCard[2];
|
||||
|
||||
void CreateGUIControls();
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void CopyDeleteClick(wxCommandEvent& event);
|
||||
void ReloadMemcard(const char *fileName, int card);
|
||||
void OnPathChange(wxFileDirPickerEvent& event);
|
||||
void OnTimer(wxTimerEvent& event);
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user