Install packages using StepMania.exe, not tool.exe. Package installation now just copies the .smzip to the user Packages dir.

This commit is contained in:
Chris Danford
2009-02-17 18:36:16 +00:00
parent d53eb89dbd
commit 811d6c0673
12 changed files with 212 additions and 55 deletions
+106
View File
@@ -9,9 +9,115 @@
#include "ProductInfo.h"
#include "DateTime.h"
#include "Foreach.h"
#include "arch/Dialog/Dialog.h"
#include "RageFileManager.h"
#include "SpecialFiles.h"
const RString INSTALLER_LANGUAGES_DIR = "Themes/_Installer/Languages/";
static const RString TEMP_MOUNT_POINT = "/@tempinstallpackage/";
static bool IsPackageFile( RString sFile )
{
RString sOsDir, sFilename, sExt;
splitpath( sFile, sOsDir, sFilename, sExt );
return sExt.EqualsNoCase(".smzip") || sExt.EqualsNoCase(".zip");
}
static void GetPackageFilesToInstall( vector<RString> &vs )
{
int argc;
char **argv;
GetCommandLineArguments( argc, argv );
for( int i = 1; i<argc; ++i )
vs.push_back( argv[i] );
bool bFoundOne = false;
FOREACH( RString, vs, s )
{
if( IsPackageFile(*s) )
{
bFoundOne = true;
break;
}
}
if( !bFoundOne )
vs.clear();
}
bool ExportStrings::AnyPackageFilesInCommandLine()
{
vector<RString> vs;
GetPackageFilesToInstall( vs );
return !vs.empty();
}
struct FileCopyResult
{
FileCopyResult( RString _sFile, RString _sComment ) : sFile(_sFile), sComment(_sComment) {}
RString sFile, sComment;
};
void ExportStrings::Install()
{
vector<FileCopyResult> vSucceeded;
vector<FileCopyResult> vFailed;
vector<RString> vs;
GetPackageFilesToInstall( vs );
FOREACH_CONST( RString, vs, s )
{
if( !IsPackageFile(*s) )
{
vFailed.push_back( FileCopyResult(*s,"wrong file extension") );
continue;
}
RString sOsDir, sFilename, sExt;
splitpath( *s, sOsDir, sFilename, sExt );
FILEMAN->Mount( "dir", sOsDir, TEMP_MOUNT_POINT );
// TODO: Validate that this zip contains files for this version of StepMania
bool bFileExists = DoesFileExist( SpecialFiles::USER_PACKAGES_DIR + sFilename + sExt );
if( FileCopy( TEMP_MOUNT_POINT + sFilename + sExt, SpecialFiles::USER_PACKAGES_DIR + sFilename + sExt ) )
vSucceeded.push_back( FileCopyResult(*s,bFileExists ? "overwrote existing file" : "") );
else
vFailed.push_back( FileCopyResult(*s,ssprintf("error copying file to '%s'",sOsDir.c_str())) );
FILEMAN->Unmount( "dir", sOsDir, TEMP_MOUNT_POINT );
}
if( vSucceeded.empty() && vFailed.empty() )
{
Dialog::OK( "Install: no files specified" );
return;
}
RString sMessage;
for( int i=0; i<2; i++ )
{
const vector<FileCopyResult> &v = (i==0) ? vSucceeded : vFailed;
if( !v.empty() )
{
sMessage += (i==0) ? "Install succeeded for:\n" : "Install failed for:\n";
FOREACH_CONST( FileCopyResult, v, iter )
{
sMessage += " - " + iter->sFile;
if( !iter->sComment.empty() )
sMessage += " : " + iter->sComment;
sMessage += "\n";
}
sMessage += "\n";
}
}
Dialog::OK( sMessage );
}
void ExportStrings::Nsis()
{
RageFile out;
+2
View File
@@ -3,6 +3,8 @@
namespace ExportStrings
{
bool AnyPackageFilesInCommandLine();
void Install();
void Nsis();
void LuaInformation();
}
+6
View File
@@ -896,6 +896,12 @@ void SetCommandlineArguments( int argc, char **argv )
g_argv = argv;
}
void GetCommandLineArguments( int &argc, char **&argv )
{
argc = g_argc;
argv = g_argv;
}
/*
* Search for the commandline argument given; eg. "test" searches for the
* option "--test". All commandline arguments are getopt_long style: --foo;
+1
View File
@@ -423,6 +423,7 @@ RString DwiEscape( const char *cUnescaped, int len );
RString GetCwd();
void SetCommandlineArguments( int argc, char **argv );
void GetCommandLineArguments( int &argc, char **&argv );
bool GetCommandlineArgument( const RString &option, RString *argument=NULL, int iIndex=0 );
extern int g_argc;
extern char **g_argv;
+2
View File
@@ -1,6 +1,8 @@
#include "global.h"
#include "SpecialFiles.h"
const RString SpecialFiles::USER_PACKAGES_DIR = "UserPackages/";
const RString SpecialFiles::SYSTEM_PACKAGES_DIR = "SystemPackages/";
const RString SpecialFiles::KEYMAPS_PATH = "Save/Keymaps.ini";
const RString SpecialFiles::PREFERENCES_INI_PATH = "Save/Preferences.ini";
const RString SpecialFiles::THEMES_DIR = "Themes/";
+2
View File
@@ -5,6 +5,8 @@
namespace SpecialFiles
{
extern const RString USER_PACKAGES_DIR;
extern const RString SYSTEM_PACKAGES_DIR;
extern const RString KEYMAPS_PATH;
extern const RString PREFERENCES_INI_PATH;
extern const RString THEMES_DIR;
+8
View File
@@ -2356,6 +2356,10 @@
RelativePath="archutils\Win32\RestartProgram.h"
>
</File>
<File
RelativePath=".\archutils\Win32\smzip.ico"
>
</File>
<File
RelativePath=".\archutils\Win32\SpecialDirs.cpp"
>
@@ -6893,6 +6897,10 @@
RelativePath="archutils\Win32\DialogErrorHeader.bmp"
>
</File>
<File
RelativePath=".\smzip.ico"
>
</File>
<File
RelativePath="StepMania.xpm"
>
+68 -28
View File
@@ -70,6 +70,7 @@
#include "MessageManager.h"
#include "StatsManager.h"
#include "GameLoop.h"
#include "SpecialFiles.h"
#if defined(XBOX)
#include "Archutils/Xbox/VirtualMemory.h"
@@ -79,8 +80,6 @@
#include <windows.h>
#endif
#define ZIPS_DIR "Packages/"
static Preference<bool> g_bAllowMultipleInstances( "AllowMultipleInstances", false );
@@ -325,7 +324,7 @@ RString StepMania::GetInitialScreen()
static Preference<int> g_iLastSeenMemory( "LastSeenMemory", 0 );
#endif
static void CheckSettings()
static void AdjustForChangedSystemCapabilities()
{
#if defined(WIN32)
/* Has the amount of memory changed? */
@@ -777,12 +776,15 @@ static void SwitchToLastPlayedGame()
StepMania::ChangeCurrentGame( pGame );
}
static void ReadGamePrefsFromDisk()
void StepMania::ChangeCurrentGame( const Game* g )
{
ASSERT( g );
ASSERT( GAMESTATE );
ASSERT( ANNOUNCER );
ASSERT( THEME );
GAMESTATE->SetCurGame( g );
RString sAnnouncer = PREFSMAN->m_sAnnouncer;
RString sTheme = PREFSMAN->m_sTheme;
@@ -794,15 +796,7 @@ static void ReadGamePrefsFromDisk()
// it's OK to call these functions with names that don't exist.
ANNOUNCER->SwitchAnnouncer( sAnnouncer );
THEME->SwitchThemeAndLanguage( sTheme, PREFSMAN->m_sLanguage, PREFSMAN->m_bPseudoLocalize );
}
void StepMania::ChangeCurrentGame( const Game* g )
{
ASSERT( g );
GAMESTATE->SetCurGame( g );
ReadGamePrefsFromDisk();
/* Set the input scheme for the new game, and load keymaps. */
if( INPUTMAPPER )
@@ -902,6 +896,23 @@ int main(int argc, char* argv[])
SetCommandlineArguments( argc, argv );
enum RunMode
{
RunMode_Normal,
RunMode_Install,
RunMode_ExportNsisStrings,
RunMode_ExportLuaInformation,
};
RunMode runmode = RunMode_Normal;
if( ExportStrings::AnyPackageFilesInCommandLine() )
runmode = RunMode_Install;
else if( GetCommandlineArgument("ExportNsisStrings") )
runmode = RunMode_ExportNsisStrings;
else if( GetCommandlineArgument("ExportLuaInformation") )
runmode = RunMode_ExportLuaInformation;
/* Set up arch hooks first. This may set up crash handling. */
HOOKS = ArchHooks::Create();
HOOKS->Init();
@@ -913,7 +924,7 @@ int main(int argc, char* argv[])
FILEMAN->MountInitialFilesystems();
/* Set this up next. Do this early, since it's needed for RageException::Throw. */
LOG = new RageLog;
LOG = new RageLog;
/* Whew--we should be able to crash safely now! */
@@ -963,7 +974,7 @@ int main(int argc, char* argv[])
FILEMAN->Mount( "dir", dirs[i], "/AdditionalCourses" );
}
MountTreeOfZips( ZIPS_DIR );
MountTreeOfZips( SpecialFiles::SYSTEM_PACKAGES_DIR );
/* One of the above filesystems might contain files that affect preferences, eg Data/Static.ini.
* Re-read preferences. */
@@ -980,9 +991,17 @@ int main(int argc, char* argv[])
GAMESTATE = new GameState;
/* This requires PREFSMAN, for PREFSMAN->m_bShowLoadingWindow. */
LoadingWindow *pLoadingWindow = LoadingWindow::Create();
if( pLoadingWindow == NULL )
RageException::Throw( "%s", COULDNT_OPEN_LOADING_WINDOW.GetValue().c_str() );
LoadingWindow *pLoadingWindow = NULL;
switch( runmode )
{
case RunMode_Normal:
pLoadingWindow = LoadingWindow::Create();
if( pLoadingWindow == NULL )
RageException::Throw( "%s", COULDNT_OPEN_LOADING_WINDOW.GetValue().c_str() );
break;
default:
; // no loading window for other RunModes
}
srand( time(NULL) ); // seed number generator
@@ -996,7 +1015,7 @@ int main(int argc, char* argv[])
LOG->Info( "TLS is %savailable", RageThread::GetSupportsTLS()? "":"not " );
#endif
CheckSettings();
AdjustForChangedSystemCapabilities();
THEME = new ThemeManager;
ANNOUNCER = new AnnouncerManager;
@@ -1005,6 +1024,35 @@ int main(int argc, char* argv[])
/* Switch to the last used game type, and set up the theme and announcer. */
SwitchToLastPlayedGame();
// Handle special RunModes. Some of these depend on ThemeManager being loaded above in SwitchToLastPlayedGame.
switch( runmode )
{
DEFAULT_FAIL( runmode );
case RunMode_Normal:
break;
case RunMode_Install:
case RunMode_ExportNsisStrings:
case RunMode_ExportLuaInformation:
THEME->SwitchThemeAndLanguage( "default", PREFSMAN->m_sLanguage, PREFSMAN->m_bPseudoLocalize );
switch( runmode )
{
DEFAULT_FAIL( runmode );
case RunMode_Install:
ExportStrings::Install();
break;
case RunMode_ExportNsisStrings:
ExportStrings::Nsis();
break;
case RunMode_ExportLuaInformation:
ExportStrings::LuaInformation();
break;
};
exit(0);
}
{
/* Now that THEME is loaded, load the icon for the current theme into the
* loading window. */
@@ -1015,7 +1063,6 @@ int main(int argc, char* argv[])
delete pIcon;
}
if( PREFSMAN->m_iSoundWriteAhead )
LOG->Info( "Sound writeahead has been overridden to %i", PREFSMAN->m_iSoundWriteAhead.Get() );
SOUNDMAN = new RageSoundManager;
@@ -1036,8 +1083,7 @@ int main(int argc, char* argv[])
/* depends on SONGINDEX: */
SONGMAN = new SongManager;
WORKOUTMAN = new WorkoutManager;
if( !GetCommandlineArgument("ExportNsisStrings") && !GetCommandlineArgument("ExportLuaInformation") )
SONGMAN->InitAll( pLoadingWindow ); // this takes a long time
SONGMAN->InitAll( pLoadingWindow ); // this takes a long time
CRYPTMAN = new CryptManager; // need to do this before ProfileMan
if( PREFSMAN->m_bSignProfileData )
CRYPTMAN->GenerateGlobalKeys();
@@ -1103,13 +1149,7 @@ int main(int argc, char* argv[])
NSMAN->DisplayStartupStatus(); // If we're using networking show what happened
/* Run the main loop. */
if( GetCommandlineArgument("ExportNsisStrings") )
ExportStrings::Nsis();
else if( GetCommandlineArgument("ExportLuaInformation") )
ExportStrings::LuaInformation();
else
GameLoop::RunGameLoop();
GameLoop::RunGameLoop();
PREFSMAN->SavePrefsToDisk();
+1
View File
@@ -1095,6 +1095,7 @@ RString ThemeManager::GetString( const RString &sMetricsGroup, const RString &sV
sValueName.Replace( "\r\n", "\\n" );
sValueName.Replace( "\n", "\\n" );
ASSERT( g_pLoadedThemeData );
RString s = GetMetricRaw( g_pLoadedThemeData->iniStrings, sMetricsGroup, sValueName );
FontCharAliases::ReplaceMarkers( s );
@@ -45,13 +45,14 @@
#define IDC_STATIC_BOMBREASON 1284
#define IDC_STATIC_BOMBREASON2 1285
#define IDC_CALL_STACK 1310
#define IDI_ICON1 1311
#define IDM_EXIT 40003
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_RESOURCE_VALUE 134
#define _APS_NEXT_COMMAND_VALUE 40009
#define _APS_NEXT_CONTROL_VALUE 1030
#define _APS_NEXT_SYMED_VALUE 101
@@ -33,13 +33,11 @@ FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,332,35
DEFPUSHBUTTON "Close",IDOK,265,215,60,15
EDITTEXT IDC_EDIT_ERROR,5,59,320,151,ES_MULTILINE | ES_READONLY |
WS_VSCROLL | NOT WS_TABSTOP
EDITTEXT IDC_EDIT_ERROR,5,59,320,151,ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
PUSHBUTTON "View Log",IDC_BUTTON_VIEW_LOG,8,215,74,15
PUSHBUTTON "Report Error",IDC_BUTTON_REPORT,90,215,76,15
PUSHBUTTON "Restart Game",IDC_BUTTON_RESTART,175,215,80,15
LTEXT "Specific details about the error are shown in the box below:",
IDC_STATIC,7,45,319,11
LTEXT "Specific details about the error are shown in the box below:",IDC_STATIC,7,45,319,11
LTEXT "Fatal Error",IDC_STATIC_HEADER_TEXT,5,5,249,23
ICON IDI_ICON,IDC_STATIC_ICON,296,6,21,20
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,0,34,332,1
@@ -49,12 +47,9 @@ IDD_LOADING_DIALOG DIALOG 0, 0, 312, 82
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
CTEXT "line1",IDC_STATIC_MESSAGE1,0,41,310,10,SS_NOPREFIX |
SS_CENTERIMAGE
CTEXT "line2",IDC_STATIC_MESSAGE2,0,54,310,10,SS_NOPREFIX |
SS_CENTERIMAGE
CTEXT "line3",IDC_STATIC_MESSAGE3,0,65,310,10,SS_NOPREFIX |
SS_CENTERIMAGE
CTEXT "line1",IDC_STATIC_MESSAGE1,0,41,310,10,SS_NOPREFIX | SS_CENTERIMAGE
CTEXT "line2",IDC_STATIC_MESSAGE2,0,54,310,10,SS_NOPREFIX | SS_CENTERIMAGE
CTEXT "line3",IDC_STATIC_MESSAGE3,0,65,310,10,SS_NOPREFIX | SS_CENTERIMAGE
CONTROL "",IDC_SPLASH,"Static",SS_BITMAP,0,0,310,25
END
@@ -67,8 +62,7 @@ BEGIN
PUSHBUTTON "Report the &Error",IDC_BUTTON_REPORT,203,73,89,15
PUSHBUTTON "&Restart Game",IDC_BUTTON_RESTART,197,95,78,15
PUSHBUTTON "&Close",IDC_BUTTON_CLOSE,278,95,50,15
LTEXT "A crash has occurred. Diagnostic information has been saved to a file called ""crashinfo.txt"" in the game program directory.",
IDC_STATIC,8,41,312,19
LTEXT "A crash has occurred. Diagnostic information has been saved to a file called ""crashinfo.txt"" in the game program directory.",IDC_STATIC,8,41,312,19
CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,332,35
LTEXT "Program Crash",IDC_STATIC_HEADER_TEXT,5,5,249,23
ICON IDI_ICON,IDC_STATIC_ICON,296,6,20,20
@@ -76,32 +70,25 @@ BEGIN
END
IDD_OK DIALOGEX 0, 0, 336, 98
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP |
WS_CAPTION
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
CAPTION "Prompt"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,143,77,50,14
CONTROL "&Don't display this message again",IDC_HUSH,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,63,181,10
EDITTEXT IDC_MESSAGE,7,7,322,55,ES_CENTER | ES_MULTILINE |
ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER |
WS_VSCROLL
CONTROL "&Don't display this message again",IDC_HUSH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,63,181,10
EDITTEXT IDC_MESSAGE,7,7,322,55,ES_CENTER | ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
END
IDD_REPORT_CRASH DIALOGEX 0, 0, 287, 98
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | DS_CENTERMOUSE | WS_POPUP |
WS_CAPTION
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION
CAPTION "Program Crash"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
PUSHBUTTON "&Send Error Report",IDC_BUTTON_AUTO_REPORT,132,79,89,15
PUSHBUTTON "&View Error Report",IDC_CRASH_SAVE,6,79,86,15
CONTROL "",IDC_PROGRESS,"msctls_progress32",NOT WS_VISIBLE |
WS_BORDER,132,79,89,15
CONTROL "",IDC_PROGRESS,"msctls_progress32",NOT WS_VISIBLE | WS_BORDER,132,79,89,15
PUSHBUTTON "&Don't Send",IDC_BUTTON_CLOSE,224,79,59,15
LTEXT "The program has encountered an error. Click Send Error Report to automatically report the problem and check for updates.",
IDC_MAIN_TEXT,13,48,263,18
LTEXT "The program has encountered an error. Click Send Error Report to automatically report the problem and check for updates.",IDC_MAIN_TEXT,13,48,263,18
CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,287,35
LTEXT "Program Crash",IDC_STATIC_HEADER_TEXT,5,5,249,23
ICON IDI_ICON,IDC_STATIC_ICON,259,6,21,20
@@ -184,6 +171,7 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "smzip.ico"
IDI_ICON ICON "StepMania.ICO"
/////////////////////////////////////////////////////////////////////////////
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB