Files
itgmania212121/stepmania/src/ThemeManager.cpp
T

223 lines
12 KiB
C++
Raw Normal View History

2002-01-16 10:01:32 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
2002-02-28 19:40:40 +00:00
Class: ThemeManager
2002-01-16 10:01:32 +00:00
2002-02-28 19:40:40 +00:00
Desc: See header.
2002-01-16 10:01:32 +00:00
2002-02-28 19:40:40 +00:00
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
Chris Danford
2002-01-16 10:01:32 +00:00
-----------------------------------------------------------------------------
*/
#include "ThemeManager.h"
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
CString ThemeManager::ElementToAssetPath( ThemeElement te )
{
2002-01-16 10:01:32 +00:00
CString sAssetPath; // fill this in below
switch( te )
{
case GRAPHIC_TITLE_MENU_BACKGROUND: sAssetPath = "Graphics\\title menu background"; break;
case GRAPHIC_SELECT_STYLE_BACKGROUND: sAssetPath = "Graphics\\select style background"; break;
case GRAPHIC_SELECT_MUSIC_BACKGROUND: sAssetPath = "Graphics\\select music background"; break;
case GRAPHIC_RESULT_BACKGROUND: sAssetPath = "Graphics\\result background"; break;
case GRAPHIC_SELECT_STYLE_TOP_EDGE: sAssetPath = "Graphics\\select style top edge"; break;
case GRAPHIC_SELECT_MUSIC_TOP_EDGE: sAssetPath = "Graphics\\select music top edge"; break;
case GRAPHIC_GAME_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\game options top edge"; break;
case GRAPHIC_PLAYER_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\player options top edge"; break;
case GRAPHIC_MUSIC_OPTIONS_TOP_EDGE: sAssetPath = "Graphics\\music options top edge"; break;
case GRAPHIC_RESULT_TOP_EDGE: sAssetPath = "Graphics\\result top edge"; break;
case GRAPHIC_FALLBACK_BANNER: sAssetPath = "Graphics\\Fallback Banner"; break;
case GRAPHIC_FALLBACK_BACKGROUND: sAssetPath = "Graphics\\Fallback Background"; break;
case GRAPHIC_COLOR_ARROW_GRAY_PART: sAssetPath = "Graphics\\Color Arrow gray part 2x2"; break;
case GRAPHIC_COLOR_ARROW_COLOR_PART:sAssetPath = "Graphics\\Color Arrow color part"; break;
case GRAPHIC_GHOST_ARROW: sAssetPath = "Graphics\\ghost arrow"; break;
2002-02-24 01:43:11 +00:00
case GRAPHIC_BRIGHT_GHOST_ARROW: sAssetPath = "Graphics\\bright ghost arrow"; break;
2002-01-16 10:01:32 +00:00
case GRAPHIC_HOLD_GHOST_ARROW: sAssetPath = "Graphics\\hold ghost arrow"; break;
case GRAPHIC_GRAY_ARROW: sAssetPath = "Graphics\\gray arrow"; break;
case GRAPHIC_JUDGEMENT: sAssetPath = "Graphics\\judgement 1x9"; break;
case GRAPHIC_MENU_BOTTOM_EDGE: sAssetPath = "Graphics\\menu bottom edge"; break;
case GRAPHIC_SCORE_FRAME: sAssetPath = "Graphics\\score frame"; break;
case GRAPHIC_LIFEMETER_FRAME: sAssetPath = "Graphics\\Life Meter Frame"; break;
case GRAPHIC_LIFEMETER_PILLS: sAssetPath = "Graphics\\life meter pills 17x1"; break;
case GRAPHIC_COMBO: sAssetPath = "Graphics\\combo"; break;
case GRAPHIC_CLOSING_STAR: sAssetPath = "Graphics\\closing star"; break;
case GRAPHIC_OPENING_STAR: sAssetPath = "Graphics\\opening star"; break;
case GRAPHIC_CAUTION: sAssetPath = "Graphics\\Caution"; break;
case GRAPHIC_READY: sAssetPath = "Graphics\\Ready"; break;
case GRAPHIC_HERE_WE_GO: sAssetPath = "Graphics\\here we go"; break;
case GRAPHIC_CLEARED: sAssetPath = "Graphics\\cleared"; break;
case GRAPHIC_FAILED: sAssetPath = "Graphics\\failed"; break;
case GRAPHIC_GRADES: sAssetPath = "Graphics\\grades 1x8"; break;
case GRAPHIC_KEEP_ALIVE: sAssetPath = "Graphics\\keep alive"; break;
case GRAPHIC_DANCER_P1: sAssetPath = "Graphics\\dancer p1"; break;
case GRAPHIC_DANCER_P2: sAssetPath = "Graphics\\dancer p2"; break;
case GRAPHIC_PAD_SINGLE: sAssetPath = "Graphics\\Pad single"; break;
case GRAPHIC_PAD_DOUBLE: sAssetPath = "Graphics\\Pad double"; break;
case GRAPHIC_PAD_SOLO: sAssetPath = "Graphics\\Pad solo"; break;
case GRAPHIC_STYLE_ICONS: sAssetPath = "Graphics\\style icons 1x5"; break;
case GRAPHIC_STYLE_EXPLANATIONS: sAssetPath = "Graphics\\style explanations 1x10"; break;
2002-01-16 10:01:32 +00:00
case GRAPHIC_MUSIC_SELECTION_HIGHLIGHT: sAssetPath = "Graphics\\music selection highlight"; break;
case GRAPHIC_STEPS_DESCRIPTION: sAssetPath = "Graphics\\steps description 1x8"; break;
case GRAPHIC_SECTION_BACKGROUND: sAssetPath = "Graphics\\section background"; break;
2002-02-24 01:43:11 +00:00
case GRAPHIC_MUSIC_SORT_ICONS: sAssetPath = "Graphics\\music sort icons 1x4"; break;
2002-01-16 10:01:32 +00:00
case GRAPHIC_MUSIC_STATUS_ICONS: sAssetPath = "Graphics\\music status icons 1x4"; break;
2002-02-02 05:11:12 +00:00
case GRAPHIC_DANGER_TEXT: sAssetPath = "Graphics\\danger text"; break;
2002-01-20 07:51:09 +00:00
case GRAPHIC_DANGER_BACKGROUND: sAssetPath = "Graphics\\danger background"; break;
2002-02-11 04:46:31 +00:00
case GRAPHIC_ARROWS_LEFT: sAssetPath = "Graphics\\arrows left 1x4"; break;
case GRAPHIC_ARROWS_RIGHT: sAssetPath = "Graphics\\arrows right 1x4"; break;
2002-02-25 08:28:01 +00:00
case GRAPHIC_EDIT_BACKGROUND: sAssetPath = "Graphics\\edit background"; break;
2002-02-28 19:40:40 +00:00
case GRAPHIC_EDIT_SNAP_INDICATOR: sAssetPath = "Graphics\\edit snap indicator"; break;
2002-03-09 06:19:40 +00:00
case GRAPHIC_GAME_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\game options background"; break;
case GRAPHIC_PLAYER_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\player options background"; break;
case GRAPHIC_MUSIC_OPTIONS_BACKGROUND: sAssetPath = "Graphics\\music options background"; break;
case GRAPHIC_SYNCHRONIZE_BACKGROUND: sAssetPath = "Graphics\\synchronize background"; break;
case GRAPHIC_SYNCHRONIZE_TOP_EDGE: sAssetPath = "Graphics\\synchronize top edge"; break;
2002-01-16 10:01:32 +00:00
case SOUND_FAILED: sAssetPath = "Sounds\\failed"; break;
case SOUND_ASSIST: sAssetPath = "Sounds\\Assist"; break;
case SOUND_SELECT: sAssetPath = "Sounds\\select"; break;
case SOUND_SWITCH_STYLE: sAssetPath = "Sounds\\switch style"; break;
case SOUND_SWITCH_MUSIC: sAssetPath = "Sounds\\switch music"; break;
case SOUND_SWITCH_SORT: sAssetPath = "Sounds\\switch sort"; break;
case SOUND_EXPAND: sAssetPath = "Sounds\\expand"; break;
case SOUND_SWITCH_STEPS: sAssetPath = "Sounds\\switch steps"; break;
case SOUND_TITLE_CHANGE: sAssetPath = "Sounds\\title change"; break;
case SOUND_MENU_SWOOSH: sAssetPath = "Sounds\\menu swoosh"; break;
case SOUND_MENU_BACK: sAssetPath = "Sounds\\menu back"; break;
case SOUND_TRAINING_MUSIC: sAssetPath = "Sounds\\training music"; break;
2002-01-21 09:27:34 +00:00
case SOUND_INVALID: sAssetPath = "Sounds\\invalid"; break;
2002-02-28 19:40:40 +00:00
case SOUND_EDIT_CHANGE_LINE: sAssetPath = "Sounds\\edit change line"; break;
case SOUND_EDIT_CHANGE_SNAP: sAssetPath = "Sounds\\edit change snap"; break;
2002-01-16 10:01:32 +00:00
case FONT_OUTLINE: sAssetPath = "Fonts\\Outline"; break;
case FONT_NORMAL: sAssetPath = "Fonts\\Normal"; break;
case FONT_FUTURISTIC: sAssetPath = "Fonts\\Futuristic"; break;
case FONT_BOLD_NUMBERS: sAssetPath = "Fonts\\Bold Numbers"; break;
case FONT_LCD_NUMBERS: sAssetPath = "Fonts\\LCD Numbers"; break;
case FONT_FEET: sAssetPath = "Fonts\\Feet"; break;
case FONT_COMBO_NUMBERS: sAssetPath = "Fonts\\MAX Numbers"; break;
case FONT_SCORE_NUMBERS: sAssetPath = "Fonts\\Bold Numbers"; break;
case ANNOUNCER_ATTRACT: sAssetPath = "Announcer\\attract"; break;
case ANNOUNCER_BAD_COMMENT: sAssetPath = "Announcer\\bad comment"; break;
case ANNOUNCER_CAUTION: sAssetPath = "Announcer\\caution"; break;
case ANNOUNCER_CLEARED: sAssetPath = "Announcer\\cleared"; break;
case ANNOUNCER_FAIL_COMMENT: sAssetPath = "Announcer\\fail comment"; break;
case ANNOUNCER_GAME_OVER: sAssetPath = "Announcer\\game over"; break;
case ANNOUNCER_GOOD_COMMENT: sAssetPath = "Announcer\\good comment"; break;
case ANNOUNCER_HERE_WE_GO: sAssetPath = "Announcer\\here we go"; break;
case ANNOUNCER_MUSIC_COMMENT: sAssetPath = "Announcer\\music comment"; break;
case ANNOUNCER_READY: sAssetPath = "Announcer\\ready"; break;
case ANNOUNCER_READY_LAST: sAssetPath = "Announcer\\ready last"; break;
case ANNOUNCER_RESULT_AAA: sAssetPath = "Announcer\\result aaa"; break;
case ANNOUNCER_RESULT_AA: sAssetPath = "Announcer\\result aa"; break;
case ANNOUNCER_RESULT_A: sAssetPath = "Announcer\\result a"; break;
case ANNOUNCER_RESULT_B: sAssetPath = "Announcer\\result b"; break;
case ANNOUNCER_RESULT_C: sAssetPath = "Announcer\\result c"; break;
case ANNOUNCER_RESULT_D: sAssetPath = "Announcer\\result d"; break;
case ANNOUNCER_RESULT_E: sAssetPath = "Announcer\\result e"; break;
case ANNOUNCER_TITLE: sAssetPath = "Announcer\\title"; break;
default:
RageError( ssprintf("Unhandled theme element %d", te) );
}
return sAssetPath;
}
CString ThemeManager::GetPathTo( ThemeElement te, CString sThemeName )
{
CString sThemeDir = ThemeNameToThemeDir( sThemeName );
CString sAssetPath = ElementToAssetPath( te );
2002-01-16 10:01:32 +00:00
CString sAssetDir, sAssetFileName, sThrowAway;
splitrelpath( sAssetPath, sAssetDir, sAssetFileName, sThrowAway );
CStringArray arrayPossibleElementFileNames; // fill this with the possible files
///////////////////////////////////////
// see if the current theme implements this element
///////////////////////////////////////
if( sAssetDir == "Graphics\\" )
{
2002-01-28 21:24:17 +00:00
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + "*.sprite", arrayPossibleElementFileNames );
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + "*.png", arrayPossibleElementFileNames );
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + "*.jpg", arrayPossibleElementFileNames );
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + "*.bmp", arrayPossibleElementFileNames );
2002-01-16 10:01:32 +00:00
}
else if( sAssetDir == "Sounds\\" )
{
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + ".set", arrayPossibleElementFileNames );
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + ".mp3", arrayPossibleElementFileNames );
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + ".wav", arrayPossibleElementFileNames );
2002-01-16 10:01:32 +00:00
}
else if( sAssetDir == "Fonts\\" )
{
GetDirListing( sThemeDir + sAssetDir + sAssetFileName + ".font", arrayPossibleElementFileNames );
2002-01-16 10:01:32 +00:00
}
else if( sAssetDir == "Announcer\\" )
{
// return the directory, and let the SoundSet discover all the samples in that directory
if( DoesFileExist( sThemeDir + sAssetDir + sAssetFileName ) )
return sThemeDir + sAssetDir + sAssetFileName;
2002-01-16 10:01:32 +00:00
}
else
{
RageError( ssprintf("Unknown theme asset dir '%s'.", sAssetDir) );
}
if( arrayPossibleElementFileNames.GetSize() > 0 )
return sThemeDir + sAssetDir + arrayPossibleElementFileNames[0];
2002-01-16 10:01:32 +00:00
///////////////////////////////////////
// the current theme does not implement this element. Fall back to the default path.
///////////////////////////////////////
if( sAssetDir == "Graphics\\" )
{
2002-01-28 21:24:17 +00:00
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + "*.sprite", arrayPossibleElementFileNames );
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + "*.png", arrayPossibleElementFileNames );
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + "*.jpg", arrayPossibleElementFileNames );
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + "*.bmp", arrayPossibleElementFileNames );
2002-01-16 10:01:32 +00:00
}
else if( sAssetDir == "Sounds\\" )
{
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + ".set", arrayPossibleElementFileNames );
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + ".mp3", arrayPossibleElementFileNames );
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + ".wav", arrayPossibleElementFileNames );
}
else if( sAssetDir == "Fonts\\" )
{
GetDirListing( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName + ".font", arrayPossibleElementFileNames );
}
else if( sAssetDir == "Announcer\\" )
{
// return the directory, and let the SoundSet discover all the samples in that directory
if( DoesFileExist( DEFAULT_THEME_DIR + sAssetDir + sAssetFileName ) )
return DEFAULT_THEME_DIR + sAssetDir + sAssetFileName;
}
else
{
RageError( ssprintf("Unknown theme asset dir '%s'.", sAssetDir) );
}
if( arrayPossibleElementFileNames.GetSize() > 0 )
return DEFAULT_THEME_DIR + sAssetDir + arrayPossibleElementFileNames[0];
RageError( ssprintf("The theme element '%s' does not exist in the current theme directory or the default theme directory.", sAssetDir + "\\" + sAssetFileName) );
return "";
}