mirror of
https://github.com/libretro/pcsx2.git
synced 2024-12-21 01:08:14 +00:00
Converted the GameDB to use wxWidgets classes.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3188 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
00404edfbc
commit
ff1db14f9d
@ -271,6 +271,10 @@
|
|||||||
RelativePath="..\..\src\Utilities\pxStaticText.cpp"
|
RelativePath="..\..\src\Utilities\pxStaticText.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\Utilities\pxTextStream.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\Utilities\pxWindowTextWriter.cpp"
|
RelativePath="..\..\src\Utilities\pxWindowTextWriter.cpp"
|
||||||
>
|
>
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
|
|
||||||
// Dependencies.h : Contains classes required by all Utilities headers.
|
// Dependencies.h : Contains classes required by all Utilities headers.
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------
|
||||||
|
// Forward Declarations Section
|
||||||
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxOutputStream;
|
||||||
|
class wxInputStream;
|
||||||
|
|
||||||
|
|
||||||
// This should prove useful....
|
// This should prove useful....
|
||||||
#define wxsFormat wxString::Format
|
#define wxsFormat wxString::Format
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ struct ParsedAssignmentString
|
|||||||
ParsedAssignmentString( const wxString& src );
|
ParsedAssignmentString( const wxString& src );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern bool pxParseAssignmentString( const wxString& src, wxString& ldest, wxString& rdest );
|
||||||
|
|
||||||
extern wxString FastFormatString_Ascii(const char* fmt, va_list argptr);
|
extern wxString FastFormatString_Ascii(const char* fmt, va_list argptr);
|
||||||
extern wxString FastFormatString_Unicode(const wxChar* fmt, va_list argptr);
|
extern wxString FastFormatString_Unicode(const wxChar* fmt, va_list argptr);
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <wx/wx.h>
|
|
||||||
#include "wxGuiTools.h"
|
#include "wxGuiTools.h"
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -50,13 +50,23 @@ protected:
|
|||||||
bool m_prev;
|
bool m_prev;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxDoNotLogInThisScope() :
|
wxDoNotLogInThisScope()
|
||||||
m_prev( wxLog::EnableLogging( false ) )
|
|
||||||
{
|
{
|
||||||
|
m_prev = wxLog::EnableLogging( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
~wxDoNotLogInThisScope()
|
virtual ~wxDoNotLogInThisScope() throw()
|
||||||
{
|
{
|
||||||
wxLog::EnableLogging( m_prev );
|
wxLog::EnableLogging( m_prev );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern wxString pxReadLine( wxInputStream& input );
|
||||||
|
extern void pxReadLine( wxInputStream& input, wxString& dest );
|
||||||
|
extern void pxReadLine( wxInputStream& input, wxString& dest, std::string& intermed );
|
||||||
|
extern bool pxReadLine( wxInputStream& input, std::string& dest );
|
||||||
|
extern void pxWriteLine( wxOutputStream& output );
|
||||||
|
extern void pxWriteLine( wxOutputStream& output, const wxString& text );
|
||||||
|
extern void pxWriteMultiline( wxOutputStream& output, const wxString& src );
|
||||||
|
|
||||||
|
@ -807,6 +807,9 @@ extern bool pxDialogExists( const wxString& name );
|
|||||||
extern bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& windowPos );
|
extern bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& windowPos );
|
||||||
extern wxRect wxGetDisplayArea();
|
extern wxRect wxGetDisplayArea();
|
||||||
|
|
||||||
|
extern int pxGetCharHeight( const wxWindow* wind, int rows=1 );
|
||||||
|
extern int pxGetCharHeight( const wxWindow& wind, int rows=1 );
|
||||||
|
|
||||||
extern wxString pxFormatToolTipText( wxWindow* wind, const wxString& src );
|
extern wxString pxFormatToolTipText( wxWindow* wind, const wxString& src );
|
||||||
extern void pxSetToolTip( wxWindow* wind, const wxString& src );
|
extern void pxSetToolTip( wxWindow* wind, const wxString& src );
|
||||||
extern void pxSetToolTip( wxWindow& wind, const wxString& src );
|
extern void pxSetToolTip( wxWindow& wind, const wxString& src );
|
||||||
|
@ -229,7 +229,7 @@ const wxString& ConsoleBuffer_Get()
|
|||||||
void ConsoleBuffer_Clear()
|
void ConsoleBuffer_Clear()
|
||||||
{
|
{
|
||||||
ScopedLock lock( m_bufferlock );
|
ScopedLock lock( m_bufferlock );
|
||||||
m_buffer.Clear();
|
m_buffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flushes the contents of the ConsoleBuffer to the specified destination file stream, and
|
// Flushes the contents of the ConsoleBuffer to the specified destination file stream, and
|
||||||
@ -239,7 +239,7 @@ void ConsoleBuffer_FlushToFile( FILE *fp )
|
|||||||
ScopedLock lock( m_bufferlock );
|
ScopedLock lock( m_bufferlock );
|
||||||
if( fp == NULL || m_buffer.IsEmpty() ) return;
|
if( fp == NULL || m_buffer.IsEmpty() ) return;
|
||||||
px_fputs( fp, m_buffer.ToUTF8() );
|
px_fputs( fp, m_buffer.ToUTF8() );
|
||||||
m_buffer.Clear();
|
m_buffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __concall ConsoleBuffer_DoWrite( const wxString& fmt )
|
static void __concall ConsoleBuffer_DoWrite( const wxString& fmt )
|
||||||
@ -276,7 +276,7 @@ static void __concall Console_wxLogError_DoWriteLn( const wxString& fmt )
|
|||||||
if( !m_buffer.IsEmpty() )
|
if( !m_buffer.IsEmpty() )
|
||||||
{
|
{
|
||||||
wxLogError( m_buffer );
|
wxLogError( m_buffer );
|
||||||
m_buffer.Clear();
|
m_buffer.clear();
|
||||||
}
|
}
|
||||||
wxLogError( fmt );
|
wxLogError( fmt );
|
||||||
}
|
}
|
||||||
@ -309,12 +309,9 @@ wxString IConsoleWriter::_addIndentation( const wxString& src, int glob_indent=0
|
|||||||
const int indent = glob_indent + _imm_indentation;
|
const int indent = glob_indent + _imm_indentation;
|
||||||
if( indent == 0 ) return src;
|
if( indent == 0 ) return src;
|
||||||
|
|
||||||
wxArrayString pieces;
|
wxString result( src );
|
||||||
SplitString( pieces, src, L'\n' );
|
|
||||||
const wxString indentStr( L'\t', indent );
|
const wxString indentStr( L'\t', indent );
|
||||||
wxString result;
|
result.Replace( L"\n", L"\n" + indentStr );
|
||||||
result.reserve( src.Length() + 24 );
|
|
||||||
JoinString( result, pieces, L'\n' + indentStr );
|
|
||||||
return indentStr + result;
|
return indentStr + result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,17 +181,21 @@ bool TryParse( wxRect& dest, const wxString& src, const wxRect& defval, const wx
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns TRUE if the parse is valid, or FALSE if it's a comment.
|
||||||
|
bool pxParseAssignmentString( const wxString& src, wxString& ldest, wxString& rdest )
|
||||||
|
{
|
||||||
|
if( src.StartsWith(L"--") || src.StartsWith( L"//" ) || src.StartsWith( L";" ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ldest = src.BeforeFirst(L'=').Trim(true).Trim(false);
|
||||||
|
rdest = src.AfterFirst(L'=').Trim(true).Trim(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ParsedAssignmentString::ParsedAssignmentString( const wxString& src )
|
ParsedAssignmentString::ParsedAssignmentString( const wxString& src )
|
||||||
{
|
{
|
||||||
IsComment = false;
|
IsComment = pxParseAssignmentString( src, lvalue, rvalue );
|
||||||
if( src.StartsWith( L"//" ) || src.StartsWith( L";" ) )
|
|
||||||
{
|
|
||||||
IsComment = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lvalue = src.BeforeFirst(L'=').Trim(true).Trim(false);
|
|
||||||
rvalue = src.AfterFirst(L'=').Trim(true).Trim(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Performs a cross-platform puts operation, which adds CRs to naked LFs on Win32 platforms,
|
// Performs a cross-platform puts operation, which adds CRs to naked LFs on Win32 platforms,
|
||||||
|
@ -79,9 +79,7 @@ pxStaticText& pxStaticText::SetHeight( int lines )
|
|||||||
if( !pxAssert(lines > 0) ) lines = 2;
|
if( !pxAssert(lines > 0) ) lines = 2;
|
||||||
m_heightInLines = lines;
|
m_heightInLines = lines;
|
||||||
|
|
||||||
int width, height;
|
const int newHeight = (pxGetCharHeight(this)*m_heightInLines) + (m_paddingPix_vert*2);
|
||||||
GetTextExtent( _("MyjS 23"), &width, &height );
|
|
||||||
const int newHeight = ((height+1)*m_heightInLines) + (m_paddingPix_vert*2);
|
|
||||||
SetMinSize( wxSize(GetMinWidth(), newHeight) );
|
SetMinSize( wxSize(GetMinWidth(), newHeight) );
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
98
common/src/Utilities/pxTextStream.cpp
Normal file
98
common/src/Utilities/pxTextStream.cpp
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/* PCSX2 - PS2 Emulator for PCs
|
||||||
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
||||||
|
*
|
||||||
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* PCSX2 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 for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "wxBaseTools.h"
|
||||||
|
#include <wx/stream.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Returns TRUE if the source is UTF8, or FALSE if it's just ASCII crap.
|
||||||
|
bool pxReadLine( wxInputStream& input, std::string& dest )
|
||||||
|
{
|
||||||
|
dest.clear();
|
||||||
|
bool isUTF8 = false;
|
||||||
|
while ( true )
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
input.Read(&c, sizeof(c));
|
||||||
|
if( c == 0 ) break;
|
||||||
|
if( input.Eof() ) break;
|
||||||
|
if( c == '\n' ) break; // eat on UNIX
|
||||||
|
if( c == '\r' )
|
||||||
|
{
|
||||||
|
input.Read(&c, sizeof(c));
|
||||||
|
if( c == 0 ) break;
|
||||||
|
if( input.Eof() ) break;
|
||||||
|
if( c == '\n' ) break;
|
||||||
|
|
||||||
|
input.Ungetch(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dest += c;
|
||||||
|
if( c & 0x80 ) isUTF8 = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isUTF8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pxReadLine( wxInputStream& input, wxString& dest, std::string& intermed )
|
||||||
|
{
|
||||||
|
dest.clear();
|
||||||
|
if( pxReadLine( input, intermed ) )
|
||||||
|
dest = fromUTF8(intermed.c_str());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Optimized ToAscii conversion.
|
||||||
|
// wx3.0 : NOT COMPATIBLE!! (on linux anyway)
|
||||||
|
const char* ascii = intermed.c_str();
|
||||||
|
while( *ascii != 0 ) dest += (wchar_t)(unsigned char)*ascii++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pxReadLine( wxInputStream& input, wxString& dest )
|
||||||
|
{
|
||||||
|
std::string line;
|
||||||
|
pxReadLine( input, dest, line );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString pxReadLine( wxInputStream& input )
|
||||||
|
{
|
||||||
|
wxString result;
|
||||||
|
pxReadLine( input, result );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pxWriteLine( wxOutputStream& output )
|
||||||
|
{
|
||||||
|
output.Write( "\n", 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void pxWriteLine( wxOutputStream& output, const wxString& text )
|
||||||
|
{
|
||||||
|
if( !text.IsEmpty() )
|
||||||
|
output.Write(text.ToUTF8(), text.Length());
|
||||||
|
pxWriteLine( output );
|
||||||
|
}
|
||||||
|
|
||||||
|
void pxWriteMultiline( wxOutputStream& output, const wxString& src )
|
||||||
|
{
|
||||||
|
if( src.IsEmpty() ) return;
|
||||||
|
|
||||||
|
wxString result( src );
|
||||||
|
result.Replace( L"\r\n", L"\n" );
|
||||||
|
result.Replace( L"\r", wxEmptyString );
|
||||||
|
|
||||||
|
output.Write(result.ToUTF8(), result.Length());
|
||||||
|
}
|
@ -372,7 +372,7 @@ wxDialogWithHelpers& wxDialogWithHelpers::SetMinHeight( int newHeight )
|
|||||||
|
|
||||||
int wxDialogWithHelpers::GetCharHeight() const
|
int wxDialogWithHelpers::GetCharHeight() const
|
||||||
{
|
{
|
||||||
return wxClientDC( const_cast<wxDialogWithHelpers*>(this) ).GetCharHeight();
|
return pxGetCharHeight( this, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
@ -450,3 +450,16 @@ wxPanelWithHelpers& wxPanelWithHelpers::SetMinWidth( int newWidth )
|
|||||||
sizer->SetMinSize( wxSize( newWidth, sizer->GetMinSize().GetHeight() ) );
|
sizer->SetMinSize( wxSize( newWidth, sizer->GetMinSize().GetHeight() ) );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pxGetCharHeight( const wxWindow* wind, int rows )
|
||||||
|
{
|
||||||
|
if( !wind ) return 0;
|
||||||
|
wxClientDC dc(wx_const_cast(wxWindow*, wind));
|
||||||
|
dc.SetFont( wind->GetFont() );
|
||||||
|
return (dc.GetCharHeight() + 1 ) * rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pxGetCharHeight( const wxWindow& wind, int rows )
|
||||||
|
{
|
||||||
|
return pxGetCharHeight( &wind, rows );
|
||||||
|
}
|
||||||
|
@ -361,7 +361,7 @@ static __forceinline void _reloadElfInfo(wxString elfpath)
|
|||||||
if (DiscID.IsEmpty()) { // Search for crc if no Serial Code
|
if (DiscID.IsEmpty()) { // Search for crc if no Serial Code
|
||||||
gameSerial = wxString(wxsFormat( L"%8.8x", ElfCRC ));
|
gameSerial = wxString(wxsFormat( L"%8.8x", ElfCRC ));
|
||||||
}
|
}
|
||||||
if (GameDB->setGame(gameSerial.ToUTF8().data())) { // Game Found
|
if (GameDB->setGame(gameSerial)) { // Game Found
|
||||||
Console.WriteLn ("Game = %s (%s)", GameDB->getString("Name").c_str(), GameDB->getString("Region").c_str());
|
Console.WriteLn ("Game = %s (%s)", GameDB->getString("Name").c_str(), GameDB->getString("Region").c_str());
|
||||||
}
|
}
|
||||||
else Console.Warning(L"Game not found in database [%s]", gameSerial.c_str());
|
else Console.Warning(L"Game not found in database [%s]", gameSerial.c_str());
|
||||||
|
@ -6,92 +6,51 @@
|
|||||||
// DataBase_Loader - Private Methods
|
// DataBase_Loader - Private Methods
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
//Fix me
|
void DataBase_Loader::doError(const wxString& line, key_pair& keyPair, bool doMsg) {
|
||||||
#ifndef __LINUX__
|
|
||||||
template<class T> string DataBase_Loader::toString(const T& value) {
|
|
||||||
stringstream ss(ios_base::in | ios_base::out);
|
|
||||||
string tString;
|
|
||||||
ss << value;
|
|
||||||
ss >> tString;
|
|
||||||
return tString;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
string DataBase_Loader::toLower(const string& s) {
|
|
||||||
string retval( s );
|
|
||||||
for (uint i = 0; i < s.length(); i++) {
|
|
||||||
char& c = retval[i];
|
|
||||||
if (c >= 'A' && c <= 'Z') {
|
|
||||||
c += 'a' - 'A';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataBase_Loader::strCompare(const string& s1, const string& s2) {
|
|
||||||
const string t1( toLower(s1) );
|
|
||||||
const string t2( toLower(s2) );
|
|
||||||
return !t1.compare(t2);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataBase_Loader::isComment(const string& s) {
|
|
||||||
const string sub( s.substr(0, 2) );
|
|
||||||
return (sub.compare("--") == 0) || (sub.compare("//") == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataBase_Loader::doError(const string& line, key_pair& keyPair, bool doMsg) {
|
|
||||||
if (doMsg) Console.Error("DataBase_Loader: Bad file data [%s]", line.c_str());
|
if (doMsg) Console.Error("DataBase_Loader: Bad file data [%s]", line.c_str());
|
||||||
keyPair.key.clear();
|
keyPair.key.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataBase_Loader::extractMultiLine(const string& line, key_pair& keyPair, File_Reader& reader, const stringstream& ss) {
|
// Multiline Sections are in the form of:
|
||||||
string t;
|
//
|
||||||
string endString;
|
// [section=value]
|
||||||
endString = "[/" + keyPair.key.substr(1, keyPair.key.length()-1);
|
// content
|
||||||
if (keyPair.key[keyPair.key.length()-1] != ']') {
|
// content
|
||||||
endString += "]";
|
// [/section]
|
||||||
keyPair.key = line;
|
//
|
||||||
|
// ... where the =value part is OPTIONAL.
|
||||||
|
void DataBase_Loader::extractMultiLine(key_pair& keyPair, wxInputStream& ffile) {
|
||||||
|
|
||||||
|
if (!keyPair.key.EndsWith(L"]")) {
|
||||||
|
doError(keyPair.key, keyPair, true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use Mid() to strip off the left and right side brackets.
|
||||||
|
ParsedAssignmentString set( keyPair.key.Mid(1, keyPair.key.Length()-2) );
|
||||||
|
|
||||||
|
wxString endString;
|
||||||
|
endString.Printf( L"[/%s]", set.lvalue.c_str() );
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
t = reader.getLine();
|
pxReadLine( ffile, m_dest, m_intermediate );
|
||||||
|
if (m_dest == endString) break;
|
||||||
if (!t.compare(endString)) break;
|
keyPair.value += m_dest + L"\n";
|
||||||
keyPair.value += t + "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataBase_Loader::extract(const string& line, key_pair& keyPair, File_Reader& reader) {
|
void DataBase_Loader::extract(const wxString& line, key_pair& keyPair, wxInputStream& reader) {
|
||||||
stringstream ss(line);
|
keyPair.key = line;
|
||||||
string t;
|
|
||||||
keyPair.key.clear();
|
|
||||||
keyPair.value.clear();
|
keyPair.value.clear();
|
||||||
ss >> keyPair.key;
|
|
||||||
if (!line.length() || isComment(keyPair.key)) {
|
if( line.IsEmpty() ) return;
|
||||||
doError(line, keyPair);
|
|
||||||
return;
|
if (keyPair.key[0] == L'[') {
|
||||||
}
|
extractMultiLine(keyPair, reader);
|
||||||
if (keyPair.key[0] == '[') {
|
|
||||||
extractMultiLine(line, keyPair, reader, ss);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ss >> t;
|
|
||||||
if (t.compare("=") != 0) {
|
if( !pxParseAssignmentString( line, keyPair.key, keyPair.value ) ) return;
|
||||||
|
if( keyPair.value.IsEmpty() )
|
||||||
doError(line, keyPair, true);
|
doError(line, keyPair, true);
|
||||||
return;
|
|
||||||
}
|
|
||||||
ss >> t;
|
|
||||||
if (isComment(t)) {
|
|
||||||
doError(line, keyPair, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
keyPair.value = t;
|
|
||||||
while (!ss.eof() && !ss.fail()) {
|
|
||||||
ss >> t;
|
|
||||||
if (isComment(t)) break;
|
|
||||||
keyPair.value += " " + t;
|
|
||||||
}
|
|
||||||
if (ss.fail()) {
|
|
||||||
doError(line, keyPair);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,44 +18,36 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "File_Reader.h"
|
#include "File_Reader.h"
|
||||||
#include "AppConfig.h"
|
#include "AppConfig.h"
|
||||||
|
#include <wx\wfstream.h>
|
||||||
|
|
||||||
struct key_pair {
|
struct key_pair {
|
||||||
string key;
|
wxString key;
|
||||||
string value;
|
wxString value;
|
||||||
|
|
||||||
key_pair() {}
|
key_pair() {}
|
||||||
key_pair(const string& _key, const string& _value)
|
key_pair(const wxString& _key, const wxString& _value)
|
||||||
: key(_key) , value(_value) {}
|
: key(_key) , value(_value) {}
|
||||||
string toString() {
|
|
||||||
string t;
|
wxString toString() const {
|
||||||
|
|
||||||
if (key[0] == '[') {
|
if (key[0] == '[') {
|
||||||
t = key + "\n";
|
pxAssumeDev( key.EndsWith(L"]"), "Malformed multiline key detected: missing end bracket!" );
|
||||||
t += value;
|
return wxsFormat( L"%s\n%s\n[/%s\n",
|
||||||
|
key.c_str(), value.c_str(), key.Mid(1, key.length()-1).c_str()
|
||||||
stringstream ss(key);
|
);
|
||||||
string t2;
|
|
||||||
ss >> t2;
|
|
||||||
if (t[t.length()-1] != '\n') t += "\n";
|
|
||||||
t += "[/" + t2.substr(1, t2.length()-1);
|
|
||||||
if (t2.compare(key)) t += "]";
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t = key;
|
// Note: 6 char padding on the l-value makes things look nicer.
|
||||||
for (int a = 6 - key.length(); a > 0; a--) {
|
return wxsFormat(L"%-6s = %s\n", key.c_str(), value.c_str() );
|
||||||
t += " "; // Padding for nice formatting on small key-names
|
|
||||||
}
|
|
||||||
t += " = " + value;
|
|
||||||
}
|
}
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Game_Data {
|
class Game_Data {
|
||||||
public:
|
public:
|
||||||
string id; // Serial Identification Code
|
wxString id; // Serial Identification Code
|
||||||
deque<key_pair> kList; // List of all (key, value) pairs for game data
|
deque<key_pair> kList; // List of all (key, value) pairs for game data
|
||||||
Game_Data(const string& _id)
|
Game_Data(const wxString& _id)
|
||||||
: id(_id) {}
|
: id(_id) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,57 +67,49 @@ public:
|
|||||||
// Such as dbLoader.getString("Region") returns "NTSC-U"
|
// Such as dbLoader.getString("Region") returns "NTSC-U"
|
||||||
|
|
||||||
class DataBase_Loader {
|
class DataBase_Loader {
|
||||||
private:
|
protected:
|
||||||
// Fix me
|
bool isComment(const wxString& s);
|
||||||
#ifdef __LINUX__
|
void doError(const wxString& line, key_pair& keyPair, bool doMsg = false);
|
||||||
template<class T> string toString(const T& value) {
|
void extractMultiLine(key_pair& keyPair, wxInputStream& reader);
|
||||||
stringstream ss(ios_base::in | ios_base::out);
|
void extract(const wxString& line, key_pair& keyPair, wxInputStream& reader);
|
||||||
string tString;
|
|
||||||
ss << value;
|
const wxString m_emptyString; // empty string for returning stuff .. never modify!
|
||||||
ss >> tString;
|
wxString m_dest;
|
||||||
return tString;
|
std::string m_intermediate;
|
||||||
}
|
|
||||||
#else
|
|
||||||
template<class T> string toString(const T& value);
|
|
||||||
#endif
|
|
||||||
string toLower(const string& s);
|
|
||||||
bool strCompare(const string& s1, const string& s2);
|
|
||||||
bool isComment(const string& s);
|
|
||||||
void doError(const string& line, key_pair& keyPair, bool doMsg = false);
|
|
||||||
void extractMultiLine(const string& line, key_pair& keyPair, File_Reader& reader, const stringstream& ss);
|
|
||||||
void extract(const string& line, key_pair& keyPair, File_Reader& reader);
|
|
||||||
public:
|
public:
|
||||||
deque<Game_Data*> gList; // List of all game data
|
deque<Game_Data*> gList; // List of all game data
|
||||||
Game_Data* curGame; // Current game data
|
Game_Data* curGame; // Current game data
|
||||||
String_Stream header; // Header of the database
|
wxString header; // Header of the database
|
||||||
string baseKey; // Key to separate games by ("Serial")
|
wxString baseKey; // Key to separate games by ("Serial")
|
||||||
|
|
||||||
DataBase_Loader(const string& file = "GameIndex.dbf", const string& key = "Serial", const string& value = "" ) {
|
DataBase_Loader(const wxString& file = L"GameIndex.dbf", const wxString& key = L"Serial", const wxString& value = wxEmptyString )
|
||||||
|
: baseKey( key )
|
||||||
|
{
|
||||||
curGame = NULL;
|
curGame = NULL;
|
||||||
baseKey = key;
|
if (!wxFileExists(file)) {
|
||||||
if (!fileExists(file)) {
|
Console.Error(L"DataBase_Loader: DataBase Not Found! [%s]", file.c_str());
|
||||||
Console.Error("DataBase_Loader: DataBase Not Found! [%s]", file.c_str());
|
|
||||||
}
|
}
|
||||||
File_Reader reader(file);
|
wxFFileInputStream reader( file );
|
||||||
key_pair keyPair;
|
key_pair keyPair;
|
||||||
string s0;
|
wxString s0;
|
||||||
Game_Data* game = NULL;
|
Game_Data* game = NULL;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for(;;) {
|
while(!reader.Eof()) {
|
||||||
for(;;) { // Find first game
|
while(!reader.Eof()) { // Find first game
|
||||||
s0 = reader.getLine();
|
pxReadLine(reader, s0, m_intermediate);
|
||||||
extract(s0, keyPair, reader);
|
extract(s0.Trim(true).Trim(false), keyPair, reader);
|
||||||
if (keyPair.key.compare(key) == 0) break;
|
if (keyPair.key == key) break;
|
||||||
header.write(s0);
|
header += s0 + L'\n';
|
||||||
header.write("\n");
|
|
||||||
}
|
}
|
||||||
game = new Game_Data(keyPair.value);
|
game = new Game_Data(keyPair.value);
|
||||||
game->kList.push_back(keyPair);
|
game->kList.push_back(keyPair);
|
||||||
for (;;) { // Fill game data, find new game, repeat...
|
|
||||||
s0 = reader.getLine();
|
while(!reader.Eof()) { // Fill game data, find new game, repeat...
|
||||||
extract(s0, keyPair, reader);
|
pxReadLine(reader, s0, m_intermediate);
|
||||||
if (keyPair.key.compare("") == 0) continue;
|
extract(s0.Trim(true).Trim(false), keyPair, reader);
|
||||||
if (keyPair.key.compare(key) == 0) {
|
if (keyPair.key.IsEmpty()) continue;
|
||||||
|
if (keyPair.key == key) {
|
||||||
gList.push_back(game);
|
gList.push_back(game);
|
||||||
game = new Game_Data(keyPair.value);
|
game = new Game_Data(keyPair.value);
|
||||||
}
|
}
|
||||||
@ -133,27 +117,25 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(int& i) { // Add Last Game if EOF
|
catch( Exception::EndOfStream& ) {}
|
||||||
if (i==1 && game) gList.push_back(game);
|
|
||||||
}
|
if (game) gList.push_back(game);
|
||||||
if (!value.compare("")) return;
|
|
||||||
if (setGame(value)) Console.WriteLn("DataBase_Loader: Found Game! [%s]", value.c_str());
|
if (value.IsEmpty()) return;
|
||||||
else Console.Warning("DataBase_Loader: Game Not Found! [%s]", value.c_str());
|
if (setGame(value)) Console.WriteLn(L"DataBase_Loader: Found Game! [%s]", value.c_str());
|
||||||
|
else Console.Warning(L"DataBase_Loader: Game Not Found! [%s]", value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DataBase_Loader() throw() {
|
virtual ~DataBase_Loader() throw() {
|
||||||
deque<Game_Data*>::iterator it = gList.begin();
|
// deque deletes its contents automatically.
|
||||||
for ( ; it != gList.end(); ++it) {
|
|
||||||
delete *it;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the current game to the one matching the serial id given
|
// Sets the current game to the one matching the serial id given
|
||||||
// Returns true if game found, false if not found...
|
// Returns true if game found, false if not found...
|
||||||
bool setGame(const string& id) {
|
bool setGame(const wxString& id) {
|
||||||
deque<Game_Data*>::iterator it = gList.begin();
|
deque<Game_Data*>::iterator it = gList.begin();
|
||||||
for ( ; it != gList.end(); ++it) {
|
for ( ; it != gList.end(); ++it) {
|
||||||
if (strCompare(it[0]->id, id)) {
|
if (it[0]->id == id) {
|
||||||
curGame = it[0];
|
curGame = it[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -170,22 +152,22 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Saves changes to the database
|
// Saves changes to the database
|
||||||
void saveToFile(const string& file = "GameIndex.dbf") {
|
void saveToFile(const wxString& file = L"GameIndex.dbf") {
|
||||||
File_Writer writer(file);
|
wxFFileOutputStream writer( file );
|
||||||
writer.write(header.toString());
|
pxWriteMultiline(writer, header);
|
||||||
deque<Game_Data*>::iterator it = gList.begin();
|
deque<Game_Data*>::iterator it = gList.begin();
|
||||||
for ( ; it != gList.end(); ++it) {
|
for ( ; it != gList.end(); ++it) {
|
||||||
deque<key_pair>::iterator i = it[0]->kList.begin();
|
deque<key_pair>::iterator i = it[0]->kList.begin();
|
||||||
for ( ; i != it[0]->kList.end(); ++i) {
|
for ( ; i != it[0]->kList.end(); ++i) {
|
||||||
writer.write(i[0].toString() + "\n");
|
pxWriteMultiline(writer, i[0].toString() );
|
||||||
}
|
}
|
||||||
writer.write("---------------------------------------------\n");
|
pxWriteLine(writer, L"---------------------------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds new game data to the database, and sets curGame to the new game...
|
// Adds new game data to the database, and sets curGame to the new game...
|
||||||
// If searchDB is true, it searches the database to see if game already exists.
|
// If searchDB is true, it searches the database to see if game already exists.
|
||||||
void addGame(const string& id, bool searchDB = true) {
|
void addGame(const wxString& id, bool searchDB = true) {
|
||||||
if (searchDB && setGame(id)) return;
|
if (searchDB && setGame(id)) return;
|
||||||
Game_Data* game = new Game_Data(id);
|
Game_Data* game = new Game_Data(id);
|
||||||
key_pair kp(baseKey, id);
|
key_pair kp(baseKey, id);
|
||||||
@ -195,11 +177,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Searches the current game's data to see if the given key exists
|
// Searches the current game's data to see if the given key exists
|
||||||
bool keyExists(const string& key) {
|
bool keyExists(const wxChar* key) {
|
||||||
if (curGame) {
|
if (curGame) {
|
||||||
deque<key_pair>::iterator it = curGame->kList.begin();
|
deque<key_pair>::iterator it = curGame->kList.begin();
|
||||||
for ( ; it != curGame->kList.end(); ++it) {
|
for ( ; it != curGame->kList.end(); ++it) {
|
||||||
if (strCompare(it[0].key, key)) {
|
if (it[0].key == key) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,11 +191,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Totally Deletes the specified key/pair value from the current game's data
|
// Totally Deletes the specified key/pair value from the current game's data
|
||||||
void deleteKey(const string& key) {
|
void deleteKey(const wxChar* key) {
|
||||||
if (curGame) {
|
if (curGame) {
|
||||||
deque<key_pair>::iterator it = curGame->kList.begin();
|
deque<key_pair>::iterator it = curGame->kList.begin();
|
||||||
for ( ; it != curGame->kList.end(); ++it) {
|
for ( ; it != curGame->kList.end(); ++it) {
|
||||||
if (strCompare(it[0].key, key)) {
|
if (it[0].key == key) {
|
||||||
curGame->kList.erase(it);
|
curGame->kList.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -223,55 +205,68 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets a string representation of the 'value' for the given key
|
// Gets a string representation of the 'value' for the given key
|
||||||
string getString(const string& key) {
|
wxString getString(const wxChar* key) {
|
||||||
if (curGame) {
|
if (curGame) {
|
||||||
deque<key_pair>::iterator it = curGame->kList.begin();
|
deque<key_pair>::iterator it = curGame->kList.begin();
|
||||||
for ( ; it != curGame->kList.end(); ++it) {
|
for ( ; it != curGame->kList.end(); ++it) {
|
||||||
if (strCompare(it[0].key, key)) {
|
if (it[0].key == key) {
|
||||||
return it[0].value;
|
return it[0].value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else Console.Error("DataBase_Loader: Game not set!");
|
else Console.Error("DataBase_Loader: Game not set!");
|
||||||
return string();
|
return wxString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a wxString representation of the 'value' for the given key
|
bool sectionExists(const wxChar* key, const wxString& value) {
|
||||||
wxString getStringWX(const string& key) {
|
return keyExists( wxsFormat(L"[%s = %s]", key, value.c_str()) );
|
||||||
return wxString(fromUTF8(getString(key).c_str()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a double representation of the 'value' for the given key
|
wxString getSection(const wxChar* key, const wxString& value) {
|
||||||
double getDouble(const string& key) {
|
return getString( wxsFormat(L"[%s = %s]", key, value.c_str()) );
|
||||||
return atof(getString(key).c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a float representation of the 'value' for the given key
|
|
||||||
float getFloat(const string& key) {
|
|
||||||
return (float)atof(getString(key).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets an integer representation of the 'value' for the given key
|
// Gets an integer representation of the 'value' for the given key
|
||||||
int getInt(const string& key) {
|
int getInt(const wxChar* key) {
|
||||||
return strtoul(getString(key).c_str(), NULL, 0);
|
return wxStrtoul(getString(key), NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a u8 representation of the 'value' for the given key
|
// Gets a u8 representation of the 'value' for the given key
|
||||||
u8 getU8(const string& key) {
|
u8 getU8(const wxChar* key) {
|
||||||
return (u8)atoi(getString(key).c_str());
|
return (u8)wxAtoi(getString(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a bool representation of the 'value' for the given key
|
// Gets a bool representation of the 'value' for the given key
|
||||||
bool getBool(const string& key) {
|
bool getBool(const wxChar* key) {
|
||||||
return !!atoi(getString(key).c_str());
|
return !!wxAtoi(getString(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString getString(const char* key) {
|
||||||
|
return getString(fromUTF8(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool keyExists(const char* key) {
|
||||||
|
return keyExists(fromUTF8(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
int getInt(const char* key) {
|
||||||
|
return getInt(fromUTF8(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 getU8(const char* key) {
|
||||||
|
return getU8(fromUTF8(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getBool(const char* key) {
|
||||||
|
return getBool(fromUTF8(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write a string value to the specified key
|
// Write a string value to the specified key
|
||||||
void writeString(const string& key, const string& value) {
|
void writeString(const wxString& key, const wxString& value) {
|
||||||
if (curGame) {
|
if (curGame) {
|
||||||
deque<key_pair>::iterator it = curGame->kList.begin();
|
deque<key_pair>::iterator it = curGame->kList.begin();
|
||||||
for ( ; it != curGame->kList.end(); ++it) {
|
for ( ; it != curGame->kList.end(); ++it) {
|
||||||
if (strCompare(it[0].key, key)) {
|
if (it[0].key == key) {
|
||||||
it[0].value = value;
|
it[0].value = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -282,52 +277,21 @@ public:
|
|||||||
else Console.Error("DataBase_Loader: Game not set!");
|
else Console.Error("DataBase_Loader: Game not set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write a wxString value to the specified key
|
|
||||||
void writeStringWX(const string& key, const wxString& value) {
|
|
||||||
writeString(key, value.ToUTF8().data());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a double value to the specified key
|
|
||||||
void writeDouble(const string& key, double value) {
|
|
||||||
writeString(key, toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a float value to the specified key
|
|
||||||
void writeFloat(const string& key, float value) {
|
|
||||||
writeString(key, toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write an integer value to the specified key
|
|
||||||
void writeInt(const string& key, int value) {
|
|
||||||
writeString(key, toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a u8 value to the specified key
|
|
||||||
void writeU8(const string& key, u8 value) {
|
|
||||||
writeString(key, toString(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a bool value to the specified key
|
// Write a bool value to the specified key
|
||||||
void writeBool(const string& key, bool value) {
|
void writeBool(const wxString& key, bool value) {
|
||||||
writeString(key, toString(value?1:0));
|
writeString(key, value ? L"1" : L"0");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template string DataBase_Loader::toString<double>(const double& value);
|
|
||||||
template string DataBase_Loader::toString<float> (const float& value);
|
|
||||||
template string DataBase_Loader::toString<int> (const int& value);
|
|
||||||
template string DataBase_Loader::toString<u8> (const u8& value);
|
|
||||||
template string DataBase_Loader::toString<bool> (const bool& value);
|
|
||||||
|
|
||||||
static wxString compatToStringWX(int compat) {
|
static wxString compatToStringWX(int compat) {
|
||||||
switch (compat) {
|
switch (compat) {
|
||||||
case 6: return wxString(L"Perfect");
|
case 6: return L"Perfect";
|
||||||
case 5: return wxString(L"Playable");
|
case 5: return L"Playable";
|
||||||
case 4: return wxString(L"In-Game");
|
case 4: return L"In-Game";
|
||||||
case 3: return wxString(L"Menu");
|
case 3: return L"Menu";
|
||||||
case 2: return wxString(L"Intro");
|
case 2: return L"Intro";
|
||||||
case 1: return wxString(L"Nothing");
|
case 1: return L"Nothing";
|
||||||
default: return wxString(L"Unknown");
|
default: return L"Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,126 +16,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class File_Reader {
|
|
||||||
private:
|
|
||||||
char buff[2048];
|
|
||||||
template<class T> T _read() {
|
|
||||||
if (fs->eof()) throw 1;
|
|
||||||
T t; (*fs) >> t;
|
|
||||||
if (fs->fail()) throw 1;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
fstream* fs;
|
|
||||||
File_Reader(const string& filename) {
|
|
||||||
fs = new fstream(filename.c_str(), ios_base::in);
|
|
||||||
}
|
|
||||||
virtual ~File_Reader() throw() {
|
|
||||||
if (fs) fs->close();
|
|
||||||
delete fs;
|
|
||||||
}
|
|
||||||
template<class T> void read(T &t) {
|
|
||||||
long pos = fs->tellp();
|
|
||||||
string s( _read<string>() );
|
|
||||||
if (s.length() >= 2) {
|
|
||||||
if (s[0] == '/' && s[1] == '/') {
|
|
||||||
fs->seekp(pos);
|
|
||||||
fs->getline(buff, sizeof(buff));
|
|
||||||
read(t);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fs->seekp(pos);
|
|
||||||
t = _read<T>();
|
|
||||||
}
|
|
||||||
void readRaw(void* ptr, int size) {
|
|
||||||
u8* p = (u8*)ptr;
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
p[i] = _read<u8>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void ignoreLine() {
|
|
||||||
fs->getline(buff, sizeof(buff));
|
|
||||||
}
|
|
||||||
string getLine() {
|
|
||||||
if (fs->eof()) throw 1;
|
|
||||||
fs->getline(buff, sizeof(buff));
|
|
||||||
if (fs->fail()) throw 1;
|
|
||||||
|
|
||||||
string ret(buff);
|
|
||||||
int eol = ret.rfind("\r");
|
|
||||||
if (eol != string::npos) ret = ret.substr(0, eol);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class T> void readLine(T& str) {
|
|
||||||
if (fs->eof()) throw 1;
|
|
||||||
fs->getline(buff, sizeof(buff));
|
|
||||||
if (fs->fail()) throw 1;
|
|
||||||
string t(buff);
|
|
||||||
str = t;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class File_Writer {
|
|
||||||
public:
|
|
||||||
ScopedPtr<fstream> fs;
|
|
||||||
File_Writer(const string& filename) {
|
|
||||||
fs = new fstream(filename.c_str(), ios_base::out);
|
|
||||||
}
|
|
||||||
virtual ~File_Writer() throw() { }
|
|
||||||
|
|
||||||
template<class T> void write(const T& t) {
|
|
||||||
(*fs) << t;
|
|
||||||
}
|
|
||||||
void writeRaw(const void* ptr, int size) {
|
|
||||||
const u8* p = (u8*)ptr;
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
write(p[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class String_Stream {
|
|
||||||
private:
|
|
||||||
char buff[2048];
|
|
||||||
public:
|
|
||||||
stringstream* ss;
|
|
||||||
String_Stream() {
|
|
||||||
ss = new stringstream(stringstream::in | stringstream::out);
|
|
||||||
}
|
|
||||||
String_Stream(const string& str) {
|
|
||||||
ss = new stringstream(str, stringstream::in | stringstream::out);
|
|
||||||
}
|
|
||||||
virtual ~String_Stream() throw() {
|
|
||||||
delete ss;
|
|
||||||
}
|
|
||||||
template<class T> void write(const T& t) {
|
|
||||||
(*ss) << t;
|
|
||||||
}
|
|
||||||
template<class T> void read(T& t) {
|
|
||||||
(*ss) >> t;
|
|
||||||
}
|
|
||||||
string toString() {
|
|
||||||
return ss->str();
|
|
||||||
}
|
|
||||||
string getLine() {
|
|
||||||
ss->getline(buff, sizeof(buff));
|
|
||||||
return buff;
|
|
||||||
}
|
|
||||||
wxString getLineWX() {
|
|
||||||
ss->getline(buff, sizeof(buff));
|
|
||||||
return wxString(fromUTF8(buff));
|
|
||||||
}
|
|
||||||
bool finished() {
|
|
||||||
return ss->eof() || ss->fail();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool fileExists(const string& file) {
|
|
||||||
FILE *f = fopen(file.c_str(), "r");
|
|
||||||
if (!f) return false;
|
|
||||||
fclose(f);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -76,13 +76,13 @@ void inifile_trim( wxString& buffer )
|
|||||||
|
|
||||||
if( buffer.Length() <= 1 ) // this I'm not sure about... - air
|
if( buffer.Length() <= 1 ) // this I'm not sure about... - air
|
||||||
{
|
{
|
||||||
buffer.Clear();
|
buffer.Empty();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( buffer.Left( 2 ) == L"//" )
|
if( buffer.Left( 2 ) == L"//" )
|
||||||
{
|
{
|
||||||
buffer.Clear();
|
buffer.Empty();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,14 +120,12 @@ void inifile_command(bool isCheat, const wxString& cmd)
|
|||||||
|
|
||||||
// This routine receives a string containing patches, trims it,
|
// This routine receives a string containing patches, trims it,
|
||||||
// Then sends the command to be parsed.
|
// Then sends the command to be parsed.
|
||||||
void TrimPatches(string& s)
|
void TrimPatches(wxString& s)
|
||||||
{
|
{
|
||||||
String_Stream ss(s);
|
wxStringTokenizer tkn( s, L"\n" );
|
||||||
wxString buff;
|
|
||||||
while (!ss.finished()) {
|
while(tkn.HasMoreTokens()) {
|
||||||
buff = ss.getLineWX();
|
inifile_command(0, tkn.GetNextToken());
|
||||||
inifile_trim(buff);
|
|
||||||
if (!buff.IsEmpty()) inifile_command(0, buff);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,17 +134,17 @@ void TrimPatches(string& s)
|
|||||||
int InitPatches(const wxString& name)
|
int InitPatches(const wxString& name)
|
||||||
{
|
{
|
||||||
bool patchFound = false;
|
bool patchFound = false;
|
||||||
string patch;
|
wxString patch;
|
||||||
string crc = string(name.ToUTF8().data());
|
const wxString crc( L"[patches = " + name + L"]" );
|
||||||
patchnumber = 0;
|
patchnumber = 0;
|
||||||
|
|
||||||
if (GameDB && GameDB->gameLoaded()) {
|
if (GameDB && GameDB->gameLoaded()) {
|
||||||
if (GameDB->keyExists("[patches = " + crc + "]")) {
|
if (GameDB->sectionExists(L"patches", name)) {
|
||||||
patch = GameDB->getString("[patches = " + crc + "]");
|
patch = GameDB->getSection(L"patches", name);
|
||||||
patchFound = true;
|
patchFound = true;
|
||||||
}
|
}
|
||||||
else if (GameDB->keyExists("[patches]")) {
|
else if (GameDB->keyExists(L"[patches]")) {
|
||||||
patch = GameDB->getString("[patches]");
|
patch = GameDB->getString(L"[patches]");
|
||||||
patchFound = true;
|
patchFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,8 +587,8 @@ void __fastcall eeGameStarting()
|
|||||||
|
|
||||||
if (GameDB && GameDB->gameLoaded()) {
|
if (GameDB && GameDB->gameLoaded()) {
|
||||||
int compat = GameDB->getInt("Compat");
|
int compat = GameDB->getInt("Compat");
|
||||||
gameName = GameDB->getStringWX("Name");
|
gameName = GameDB->getString("Name");
|
||||||
gameName += L" (" + GameDB->getStringWX("Region") + L")";
|
gameName += L" (" + GameDB->getString("Region") + L")";
|
||||||
gameCompat = L" [Status = "+compatToStringWX(compat)+L"]";
|
gameCompat = L" [Status = "+compatToStringWX(compat)+L"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ void AppLoadSettings()
|
|||||||
g_Conf->LoadSave( loader );
|
g_Conf->LoadSave( loader );
|
||||||
|
|
||||||
if( !wxFile::Exists( g_Conf->CurrentIso ) )
|
if( !wxFile::Exists( g_Conf->CurrentIso ) )
|
||||||
g_Conf->CurrentIso.Clear();
|
g_Conf->CurrentIso.clear();
|
||||||
|
|
||||||
sApp.DispatchEvent( loader );
|
sApp.DispatchEvent( loader );
|
||||||
}
|
}
|
||||||
@ -703,7 +703,7 @@ void AppSaveSettings()
|
|||||||
if( wxGetApp().PostMethodMyself(AppSaveSettings) ) return;
|
if( wxGetApp().PostMethodMyself(AppSaveSettings) ) return;
|
||||||
|
|
||||||
if( !wxFile::Exists( g_Conf->CurrentIso ) )
|
if( !wxFile::Exists( g_Conf->CurrentIso ) )
|
||||||
g_Conf->CurrentIso.Clear();
|
g_Conf->CurrentIso.clear();
|
||||||
|
|
||||||
sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso );
|
sApp.GetRecentIsoManager().Add( g_Conf->CurrentIso );
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ using namespace Panels;
|
|||||||
Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent)
|
Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent)
|
||||||
: BaseConfigurationDialog( parent, _("PS2 Settings - PCSX2"), 580 )
|
: BaseConfigurationDialog( parent, _("PS2 Settings - PCSX2"), 580 )
|
||||||
{
|
{
|
||||||
|
ScopedBusyCursor busy( Cursor_ReallyBusy );
|
||||||
|
|
||||||
CreateListbook( wxGetApp().GetImgList_Config() );
|
CreateListbook( wxGetApp().GetImgList_Config() );
|
||||||
const AppImageIds::ConfigIds& cfgid( wxGetApp().GetImgId().Config );
|
const AppImageIds::ConfigIds& cfgid( wxGetApp().GetImgId().Config );
|
||||||
|
|
||||||
@ -45,6 +47,8 @@ Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent)
|
|||||||
Dialogs::ComponentsConfigDialog::ComponentsConfigDialog(wxWindow* parent)
|
Dialogs::ComponentsConfigDialog::ComponentsConfigDialog(wxWindow* parent)
|
||||||
: BaseConfigurationDialog( parent, _("Application Settings - PCSX2"), 600 )
|
: BaseConfigurationDialog( parent, _("Application Settings - PCSX2"), 600 )
|
||||||
{
|
{
|
||||||
|
ScopedBusyCursor busy( Cursor_ReallyBusy );
|
||||||
|
|
||||||
CreateListbook( wxGetApp().GetImgList_Config() );
|
CreateListbook( wxGetApp().GetImgList_Config() );
|
||||||
const AppImageIds::ConfigIds& cfgid( wxGetApp().GetImgId().Config );
|
const AppImageIds::ConfigIds& cfgid( wxGetApp().GetImgId().Config );
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ using namespace pxSizerFlags;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define placeTextBox(wxBox, txt) { \
|
#define placeTextBox(wxBox, txt) { \
|
||||||
sizer1 += Label(txt); \
|
sizer1 += Label(_(txt)); \
|
||||||
sizer1 += 5; \
|
sizer1 += 5; \
|
||||||
sizer1 += wxBox | pxCenter; \
|
sizer1 += wxBox | pxCenter; \
|
||||||
sizer1 += 5; \
|
sizer1 += 5; \
|
||||||
@ -39,8 +39,8 @@ wxTextCtrl* CreateMultiLineTextCtrl( wxWindow* parent, int digits, long flags =
|
|||||||
return ctrl;
|
return ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Panels::GameDatabasePanel::GameDatabasePanel( wxWindow* parent ) :
|
Panels::GameDatabasePanel::GameDatabasePanel( wxWindow* parent )
|
||||||
BaseApplicableConfigPanel( parent )
|
: BaseApplicableConfigPanel( parent )
|
||||||
{
|
{
|
||||||
if (!GameDB) GameDB = new DataBase_Loader();
|
if (!GameDB) GameDB = new DataBase_Loader();
|
||||||
searchBtn = new wxButton (this, wxID_DEFAULT, L"Search");
|
searchBtn = new wxButton (this, wxID_DEFAULT, L"Search");
|
||||||
@ -65,7 +65,7 @@ Panels::GameDatabasePanel::GameDatabasePanel( wxWindow* parent ) :
|
|||||||
*this += Heading(_("Game Database Editor")).Bold() | StdExpand();
|
*this += Heading(_("Game Database Editor")).Bold() | StdExpand();
|
||||||
*this += Heading(_("This panel lets you add and edit game titles, game fixes, and game patches.")) | StdExpand();
|
*this += Heading(_("This panel lets you add and edit game titles, game fixes, and game patches.")) | StdExpand();
|
||||||
|
|
||||||
wxFlexGridSizer& sizer1(*new wxFlexGridSizer(5));
|
wxFlexGridSizer& sizer1(*new wxFlexGridSizer(5, StdPadding));
|
||||||
sizer1.AddGrowableCol(0);
|
sizer1.AddGrowableCol(0);
|
||||||
|
|
||||||
blankLine();
|
blankLine();
|
||||||
@ -75,11 +75,11 @@ Panels::GameDatabasePanel::GameDatabasePanel( wxWindow* parent ) :
|
|||||||
sizer1 += 5;
|
sizer1 += 5;
|
||||||
sizer1 += searchBtn;
|
sizer1 += searchBtn;
|
||||||
|
|
||||||
placeTextBox(nameBox, L"Name: ");
|
placeTextBox(nameBox, "Name: ");
|
||||||
placeTextBox(regionBox, L"Region: ");
|
placeTextBox(regionBox, "Region: ");
|
||||||
placeTextBox(compatBox, L"Compatibility: ");
|
placeTextBox(compatBox, "Compatibility: ");
|
||||||
placeTextBox(commentBox, L"Comments: ");
|
placeTextBox(commentBox, "Comments: ");
|
||||||
placeTextBox(patchesBox, L"Patches: ");
|
placeTextBox(patchesBox, "Patches: ");
|
||||||
|
|
||||||
blankLine();
|
blankLine();
|
||||||
|
|
||||||
@ -102,12 +102,12 @@ Panels::GameDatabasePanel::GameDatabasePanel( wxWindow* parent ) :
|
|||||||
|
|
||||||
void Panels::GameDatabasePanel::PopulateFields() {
|
void Panels::GameDatabasePanel::PopulateFields() {
|
||||||
if (GameDB->gameLoaded()) {
|
if (GameDB->gameLoaded()) {
|
||||||
serialBox ->SetLabel(GameDB->getStringWX("Serial"));
|
serialBox ->SetLabel(GameDB->getString("Serial"));
|
||||||
nameBox ->SetLabel(GameDB->getStringWX("Name"));
|
nameBox ->SetLabel(GameDB->getString("Name"));
|
||||||
regionBox ->SetLabel(GameDB->getStringWX("Region"));
|
regionBox ->SetLabel(GameDB->getString("Region"));
|
||||||
compatBox ->SetLabel(GameDB->getStringWX("Compat"));
|
compatBox ->SetLabel(GameDB->getString("Compat"));
|
||||||
commentBox->SetLabel(GameDB->getStringWX("[comments]"));
|
commentBox->SetLabel(GameDB->getString("[comments]"));
|
||||||
patchesBox->SetLabel(GameDB->getStringWX("[patches]"));
|
patchesBox->SetLabel(GameDB->getString("[patches]"));
|
||||||
gameFixes[0]->SetValue(GameDB->getBool("VuAddSubHack"));
|
gameFixes[0]->SetValue(GameDB->getBool("VuAddSubHack"));
|
||||||
gameFixes[1]->SetValue(GameDB->getBool("VuClipFlagHack"));
|
gameFixes[1]->SetValue(GameDB->getBool("VuClipFlagHack"));
|
||||||
gameFixes[2]->SetValue(GameDB->getBool("FpuCompareHack"));
|
gameFixes[2]->SetValue(GameDB->getBool("FpuCompareHack"));
|
||||||
@ -131,23 +131,22 @@ void Panels::GameDatabasePanel::PopulateFields() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define writeTextBoxToDB(_key, _value) { \
|
#define writeTextBoxToDB(_key, _value) { \
|
||||||
if (_value.IsEmpty()) GameDB->deleteKey(_key); \
|
if (_value.IsEmpty()) GameDB->deleteKey(wxT(_key)); \
|
||||||
else GameDB->writeStringWX(_key, _value); \
|
else GameDB->writeString(wxT(_key), _value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define writeGameFixToDB(_key, _value) { \
|
#define writeGameFixToDB(_key, _value) { \
|
||||||
if (!_value) GameDB->deleteKey(_key); \
|
if (!_value) GameDB->deleteKey(wxT(_key)); \
|
||||||
else GameDB->writeBool(_key, _value); \
|
else GameDB->writeBool(wxT(_key), _value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panels::GameDatabasePanel::WriteFieldsToDB() {
|
void Panels::GameDatabasePanel::WriteFieldsToDB() {
|
||||||
wxString wxStr = serialBox->GetValue();
|
wxString wxStr( serialBox->GetValue() );
|
||||||
string str = wxStr.ToUTF8().data();
|
|
||||||
|
|
||||||
if (wxStr.IsEmpty()) return;
|
if (wxStr.IsEmpty()) return;
|
||||||
if (str.compare(GameDB->getString("Serial"))) {
|
if (wxStr == GameDB->getString("Serial")) {
|
||||||
GameDB->addGame(str);
|
GameDB->addGame(wxStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeTextBoxToDB("Name", nameBox->GetValue());
|
writeTextBoxToDB("Name", nameBox->GetValue());
|
||||||
@ -168,10 +167,11 @@ void Panels::GameDatabasePanel::WriteFieldsToDB() {
|
|||||||
|
|
||||||
void Panels::GameDatabasePanel::Search_Click(wxCommandEvent& evt) {
|
void Panels::GameDatabasePanel::Search_Click(wxCommandEvent& evt) {
|
||||||
wxString wxStr = serialBox->GetValue();
|
wxString wxStr = serialBox->GetValue();
|
||||||
string str = wxStr.IsEmpty() ? DiscID.ToUTF8().data() : wxStr.ToUTF8().data();
|
|
||||||
|
if( wxStr.IsEmpty() ) wxStr = DiscID;
|
||||||
|
|
||||||
bool bySerial = 1;//searchType->GetSelection()==0;
|
bool bySerial = 1;//searchType->GetSelection()==0;
|
||||||
if (bySerial) GameDB->setGame(str);
|
if (bySerial) GameDB->setGame(wxStr);
|
||||||
|
|
||||||
PopulateFields();
|
PopulateFields();
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
|
@ -20,13 +20,6 @@
|
|||||||
|
|
||||||
using namespace pxSizerFlags;
|
using namespace pxSizerFlags;
|
||||||
|
|
||||||
static int pxGetTextHeight( const wxWindow* wind, int rows )
|
|
||||||
{
|
|
||||||
wxClientDC dc(wx_const_cast(wxWindow *, wind));
|
|
||||||
dc.SetFont( wind->GetFont() );
|
|
||||||
return (dc.GetCharHeight() + 1 ) * rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wxChar* Panels::SpeedHacksPanel::GetEEcycleSliderMsg( int val )
|
const wxChar* Panels::SpeedHacksPanel::GetEEcycleSliderMsg( int val )
|
||||||
{
|
{
|
||||||
switch( val )
|
switch( val )
|
||||||
@ -132,7 +125,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
|
|||||||
|
|
||||||
m_msg_eecycle = new pxStaticHeading( eeSliderPanel );
|
m_msg_eecycle = new pxStaticHeading( eeSliderPanel );
|
||||||
m_msg_eecycle->SetForegroundColour( wxColour( L"Red" ) );
|
m_msg_eecycle->SetForegroundColour( wxColour( L"Red" ) );
|
||||||
m_msg_eecycle->SetMinSize( wxSize( wxDefaultCoord, pxGetTextHeight(m_msg_eecycle, 3) ) );
|
m_msg_eecycle->SetHeight(3);
|
||||||
|
|
||||||
const wxChar* ee_tooltip = pxE( ".Tooltip:Speedhacks:EECycleRate Slider",
|
const wxChar* ee_tooltip = pxE( ".Tooltip:Speedhacks:EECycleRate Slider",
|
||||||
L"Setting higher values on this slider effectively reduces the clock speed of the EmotionEngine's "
|
L"Setting higher values on this slider effectively reduces the clock speed of the EmotionEngine's "
|
||||||
@ -153,7 +146,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
|
|||||||
|
|
||||||
m_msg_vustealer = new pxStaticHeading( vuSliderPanel );
|
m_msg_vustealer = new pxStaticHeading( vuSliderPanel );
|
||||||
m_msg_vustealer->SetForegroundColour( wxColour( L"Red" ) );
|
m_msg_vustealer->SetForegroundColour( wxColour( L"Red" ) );
|
||||||
m_msg_vustealer->SetMinSize( wxSize( wxDefaultCoord, pxGetTextHeight(m_msg_vustealer, 3) ) );
|
m_msg_vustealer->SetHeight(3);
|
||||||
|
|
||||||
const wxChar* vu_tooltip = pxE( ".Tooltip:Speedhacks:VUCycleStealing Slider",
|
const wxChar* vu_tooltip = pxE( ".Tooltip:Speedhacks:VUCycleStealing Slider",
|
||||||
L"This slider controls the amount of cycles the VU unit steals from the EmotionEngine. Higher values increase the number of "
|
L"This slider controls the amount of cycles the VU unit steals from the EmotionEngine. Higher values increase the number of "
|
||||||
|
Loading…
Reference in New Issue
Block a user