fix mounting to fix reading of Prefs.ini
This commit is contained in:
@@ -209,7 +209,7 @@ static RString GetDirOfExecutable( RString argv0 )
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ChangeToDirOfExecutable( RString argv0 )
|
||||
static void ChangeToDirOfExecutable( const RString &argv0 )
|
||||
{
|
||||
RageFileManagerUtil::sInitialWorkingDirectory = GetCwd();
|
||||
RageFileManagerUtil::sDirOfExecutable = GetDirOfExecutable( argv0 );
|
||||
|
||||
@@ -1560,6 +1560,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
||||
<File
|
||||
RelativePath=".\archutils\Win32\arch_time.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\archutils\Win32\CommandLine.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\archutils\Win32\CommandLine.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="archutils\Win32\Crash.cpp">
|
||||
</File>
|
||||
|
||||
@@ -59,10 +59,10 @@ LINK32=link.exe
|
||||
# SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
|
||||
# Begin Special Build Tool
|
||||
IntDir=.\../Debug6
|
||||
TargetDir=\SM Source\stepmania\Program
|
||||
TargetDir=\cvs\stepmania\Program
|
||||
TargetName=StepMania-debug
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -96,10 +96,10 @@ LINK32=link.exe
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
# Begin Special Build Tool
|
||||
IntDir=.\../Release6
|
||||
TargetDir=\SM Source\stepmania\Program
|
||||
TargetDir=\cvs\stepmania\Program
|
||||
TargetName=StepMania
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -1691,6 +1691,14 @@ SOURCE=.\archutils\Win32\arch_time.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\archutils\Win32\CommandLine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\archutils\Win32\CommandLine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\archutils\Win32\Crash.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "global.h"
|
||||
#include "CommandLine.h"
|
||||
#include <windows.h>
|
||||
|
||||
/* Ugh. Windows doesn't give us the argv[] parser; all it gives is CommandLineToArgvW,
|
||||
* which is NT-only, so we have to do this ourself. Don't be fancy; only handle double
|
||||
* quotes. */
|
||||
int GetWin32CmdLine( char** &argv )
|
||||
{
|
||||
char *pCmdLine = GetCommandLine();
|
||||
int argc = 0;
|
||||
argv = NULL;
|
||||
|
||||
int i = 0;
|
||||
while( pCmdLine[i] )
|
||||
{
|
||||
argv = (char **) realloc( argv, (argc+1) * sizeof(char *) );
|
||||
argv[argc] = pCmdLine+i;
|
||||
++argc;
|
||||
|
||||
/* Skip to the end of this argument. */
|
||||
while( pCmdLine[i] && pCmdLine[i] != ' ' )
|
||||
{
|
||||
if( pCmdLine[i] == '"' )
|
||||
{
|
||||
/* Erase the quote. */
|
||||
memmove( pCmdLine+i, pCmdLine+i+1, strlen(pCmdLine+i+1)+1 );
|
||||
|
||||
/* Skip to the close quote. */
|
||||
while( pCmdLine[i] && pCmdLine[i] != '"' )
|
||||
++i;
|
||||
|
||||
/* Erase the close quote. */
|
||||
if( pCmdLine[i] == '"' )
|
||||
memmove( pCmdLine+i, pCmdLine+i+1, strlen(pCmdLine+i+1)+1 );
|
||||
}
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
if( pCmdLine[i] == ' ' )
|
||||
{
|
||||
pCmdLine[i] = '\0';
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return argc;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2006 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef CommandLine_H
|
||||
#define CommandLine_H
|
||||
|
||||
int GetWin32CmdLine( char** &argv );
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -3,54 +3,9 @@
|
||||
#ifdef _WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include "CommandLine.h"
|
||||
|
||||
#if defined(WINDOWS)
|
||||
/* Ugh. Windows doesn't give us the argv[] parser; all it gives is CommandLineToArgvW,
|
||||
* which is NT-only, so we have to do this ourself. Don't be fancy; only handle double
|
||||
* quotes. */
|
||||
int GetWin32CmdLine( char** &argv )
|
||||
{
|
||||
char *pCmdLine = GetCommandLine();
|
||||
int argc = 0;
|
||||
argv = NULL;
|
||||
|
||||
int i = 0;
|
||||
while( pCmdLine[i] )
|
||||
{
|
||||
argv = (char **) realloc( argv, (argc+1) * sizeof(char *) );
|
||||
argv[argc] = pCmdLine+i;
|
||||
++argc;
|
||||
|
||||
/* Skip to the end of this argument. */
|
||||
while( pCmdLine[i] && pCmdLine[i] != ' ' )
|
||||
{
|
||||
if( pCmdLine[i] == '"' )
|
||||
{
|
||||
/* Erase the quote. */
|
||||
memmove( pCmdLine+i, pCmdLine+i+1, strlen(pCmdLine+i+1)+1 );
|
||||
|
||||
/* Skip to the close quote. */
|
||||
while( pCmdLine[i] && pCmdLine[i] != '"' )
|
||||
++i;
|
||||
|
||||
/* Erase the close quote. */
|
||||
if( pCmdLine[i] == '"' )
|
||||
memmove( pCmdLine+i, pCmdLine+i+1, strlen(pCmdLine+i+1)+1 );
|
||||
}
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
if( pCmdLine[i] == ' ' )
|
||||
{
|
||||
pCmdLine[i] = '\0';
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return argc;
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] );
|
||||
int __stdcall WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, char *pCmdLine, int nCmdShow )
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="smpackage\ZipArchive\Debug\ZipArchive.lib"
|
||||
OutputFile="./../Program/tools-debug.exe"
|
||||
OutputFile="../Program/tools-debug.exe"
|
||||
LinkIncremental="0"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
@@ -294,6 +294,12 @@
|
||||
<File
|
||||
RelativePath=".\archutils\Win32\arch_time.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\archutils\Win32\CommandLine.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\archutils\Win32\CommandLine.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\archutils\Win32\DialogUtil.cpp">
|
||||
</File>
|
||||
|
||||
@@ -38,17 +38,18 @@ CSmpackageApp theApp;
|
||||
#include "RageFileManager.h"
|
||||
#include "archutils/Win32/SpecialDirs.h"
|
||||
#include "ProductInfo.h"
|
||||
#include "archutils/Win32/CommandLine.h"
|
||||
extern RString GetLastErrorString();
|
||||
|
||||
static LocalizedString FAILED_TO_OPEN ( "CSmpackageApp", "Failed to open '%s': %s" );
|
||||
static LocalizedString THE_FILE_DOES_NOT_EXIST ( "CSmpackageApp", "The file '%s' does not exist. Aborting installation." );
|
||||
BOOL CSmpackageApp::InitInstance()
|
||||
{
|
||||
TCHAR szCurrentDirectory[MAX_PATH];
|
||||
GetCurrentDirectory( ARRAYSIZE(szCurrentDirectory), szCurrentDirectory );
|
||||
char **argv;
|
||||
int argc = GetWin32CmdLine( argv );
|
||||
|
||||
/* Almost everything uses this to read and write files. Load this early. */
|
||||
FILEMAN = new RageFileManager( szCurrentDirectory );
|
||||
FILEMAN = new RageFileManager( argv[0] );
|
||||
FILEMAN->MountInitialFilesystems();
|
||||
|
||||
/* Set this up next. Do this early, since it's needed for RageException::Throw. */
|
||||
@@ -56,8 +57,11 @@ BOOL CSmpackageApp::InitInstance()
|
||||
|
||||
|
||||
if( DoesFileExist("Songs") ) // this is a SM program directory
|
||||
{
|
||||
TCHAR szCurrentDirectory[MAX_PATH];
|
||||
GetCurrentDirectory( ARRAYSIZE(szCurrentDirectory), szCurrentDirectory );
|
||||
SMPackageUtil::AddStepManiaInstallDir( szCurrentDirectory ); // add this if it doesn't already exist
|
||||
|
||||
}
|
||||
|
||||
// check if there's a .smzip command line argument
|
||||
vector<RString> arrayCommandLineBits;
|
||||
@@ -119,12 +123,13 @@ BOOL CSmpackageApp::InitInstance()
|
||||
// TODO: Use PrefsManager to get the current language instead? PrefsManager would
|
||||
// need to be split up to reduce dependencies
|
||||
IniFile ini;
|
||||
ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH );
|
||||
RString sLanguage;
|
||||
ini.GetValue( "Preferences", "Language", sLanguage );
|
||||
bool bPseudoLocalize;
|
||||
ini.GetValue( "PseudoLocalize", "Language", bPseudoLocalize );
|
||||
|
||||
bool bPseudoLocalize = false;
|
||||
if( ini.ReadFile(SpecialFiles::PREFERENCES_INI_PATH) )
|
||||
{
|
||||
ini.GetValue( "Preferences", "Language", sLanguage );
|
||||
ini.GetValue( "PseudoLocalize", "Language", bPseudoLocalize );
|
||||
}
|
||||
THEME->SwitchThemeAndLanguage( SpecialFiles::BASE_THEME_NAME, sLanguage, bPseudoLocalize );
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user