move localized string to separate file

This commit is contained in:
Chris Danford
2005-12-22 03:10:04 +00:00
parent c0d9825704
commit 74749a19bb
36 changed files with 212 additions and 77 deletions
+1
View File
@@ -11,6 +11,7 @@
#include "Game.h"
#include "Style.h"
#include "SpecialFiles.h"
#include "LocalizedString.h"
static Preference<CString> g_sLastSeenInputDevices( "LastSeenInputDevices", "" );
static Preference<bool> g_bAutoMapOnJoyChange( "AutoMapOnJoyChange", true );
+85
View File
@@ -0,0 +1,85 @@
#include "global.h"
#include "LocalizedString.h"
#include "Foreach.h"
static RString (*g_pfnLocalizer)(const RString&,const RString&) = NULL;
void LocalizedString::RegisterLocalizer( RString (*pfnLocalizer)(const RString&, const RString&) )
{
g_pfnLocalizer = pfnLocalizer;
}
#include "SubscriptionManager.h"
template<>
set<LocalizedString*>* SubscriptionManager<LocalizedString>::s_pSubscribers = NULL;
void LocalizedString::RefreshLocalizedStrings()
{
FOREACHS( LocalizedString*, *SubscriptionManager<LocalizedString>::s_pSubscribers, p )
(*p)->Refresh();
}
CString LocalizedString::LocalizeString( const CString &sSection, const CString &sName )
{
ASSERT( g_pfnLocalizer );
return g_pfnLocalizer( sSection, sName );
}
LocalizedString::LocalizedString( const RString &sSection, const RString &sName )
{
m_bLoaded = false;
m_sSection = sSection;
m_sName = sName;
SubscriptionManager<LocalizedString>::Subscribe( this );
}
LocalizedString::~LocalizedString()
{
SubscriptionManager<LocalizedString>::Unsubscribe( this );
}
LocalizedString::operator RString() const
{
return GetValue();
}
RString LocalizedString::GetValue() const
{
ASSERT(m_bLoaded);
return m_sValue;
}
void LocalizedString::Refresh()
{
m_sValue = LocalizeString( m_sSection, m_sName );
m_bLoaded = true;
}
/*
* Copyright (c) 2001-2005 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.
*/
+51
View File
@@ -0,0 +1,51 @@
/* LocalizedString - */
#ifndef LocalizedString_H
#define LocalizedString_H
class LocalizedString
{
public:
static void RegisterLocalizer( RString (*pfnLocalizer)(const RString&,const RString&) );
static void RefreshLocalizedStrings();
static CString LocalizeString( const CString &sSection, const CString &sName );
LocalizedString( const RString &sSection, const RString &sName );
~LocalizedString();
void Refresh();
operator RString() const;
RString GetValue() const;
private:
RString m_sSection;
RString m_sName;
RString m_sValue;
bool m_bLoaded;
};
#endif
/*
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
* 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.
*/
+31
View File
@@ -0,0 +1,31 @@
#include "global.h"
#include "LocalizedString.h"
#include "LuaFunctions.h"
#include "LuaManager.h"
LuaFunction( LocalizeString, LocalizedString::LocalizeString( SArg(1), SArg(2) ) )
/*
* Copyright (c) 2001-2005 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.
*/
+4 -1
View File
@@ -103,7 +103,10 @@ GameConstantsAndTypes.cpp GameConstantsAndTypes.h \
GameInput.cpp GameInput.h Grade.cpp Grade.h \
HighScore.cpp HighScore.h \
InputEventPlus.h \
Inventory.cpp Inventory.h LuaFunctions.h \
Inventory.cpp Inventory.h \
LocalizedString.cpp LocalizedString.h \
LocalizedStringLua.cpp \
LuaFunctions.h \
LuaReference.cpp LuaReference.h \
LuaExpressionTransform.cpp LuaExpressionTransform.h \
LyricsLoader.cpp LyricsLoader.h MenuInput.h \
+1
View File
@@ -4,6 +4,7 @@
#include "LuaManager.h"
#include "LuaFunctions.h"
#include "crypto/CryptMD5.h"
#include "LocalizedString.h"
NetworkSyncManager *NSMAN;
+1
View File
@@ -40,6 +40,7 @@
#include "StatsManager.h"
#include "Steps.h"
#include "GameCommand.h"
#include "LocalizedString.h"
CString COMBO_X_NAME( size_t p, size_t both_sides ) { return "ComboXOffset" + (both_sides ? CString("BothSides") : ssprintf("OneSideP%d",int(p+1)) ); }
CString ATTACK_DISPLAY_X_NAME( size_t p, size_t both_sides ){ return "AttackDisplayXOffset" + (both_sides ? CString("BothSides") : ssprintf("OneSideP%d",int(p+1)) ); }
+1 -1
View File
@@ -10,6 +10,7 @@
#include "RageTimer.h"
#include "RageSoundReader_Preload.h"
#include "Foreach.h"
#include "LocalizedString.h"
#include "arch/Sound/RageSoundDriver.h"
@@ -36,7 +37,6 @@ RageSoundManager::RageSoundManager()
}
static LocalizedString COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" );
void RageSoundManager::Init( CString sDrivers )
{
m_pDriver = MakeRageSoundDriver( sDrivers );
+1 -52
View File
@@ -4,6 +4,7 @@
#include "RageLog.h"
#include "RageFile.h"
#include "Foreach.h"
#include "LocalizedString.h"
#include <numeric>
#include <ctime>
@@ -1925,58 +1926,6 @@ bool FileCopy( RageFileBasic &in, RageFileBasic &out, RString &sError, bool *bRe
return true;
}
static RString (*g_pfnLocalizer)(const RString&,const RString&) = NULL;
void RegisterLocalizer( RString (*pfnLocalizer)(const RString&, const RString&) )
{
g_pfnLocalizer = pfnLocalizer;
}
#include "SubscriptionManager.h"
template<>
set<LocalizedString*>* SubscriptionManager<LocalizedString>::s_pSubscribers = NULL;
void RefreshLocalizedStrings()
{
FOREACHS( LocalizedString*, *SubscriptionManager<LocalizedString>::s_pSubscribers, p )
(*p)->Refresh();
}
LocalizedString::LocalizedString( const RString &sSection, const RString &sName )
{
m_bLoaded = false;
m_sSection = sSection;
m_sName = sName;
SubscriptionManager<LocalizedString>::Subscribe( this );
}
LocalizedString::~LocalizedString()
{
SubscriptionManager<LocalizedString>::Unsubscribe( this );
}
LocalizedString::operator RString() const
{
return GetValue();
}
RString LocalizedString::GetValue() const
{
ASSERT(m_bLoaded);
return m_sValue;
}
void LocalizedString::Refresh()
{
ASSERT( g_pfnLocalizer );
m_sValue = g_pfnLocalizer( m_sSection, m_sName );
m_bLoaded = true;
}
/*
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
* All rights reserved.
-18
View File
@@ -503,24 +503,6 @@ void GetConnectsDisconnects( const vector<T> &before, const vector<T> &after, ve
GetAsNotInBs( after, before, connects );
}
// String localization
void RegisterLocalizer( RString (*pfnLocalizer)(const RString&,const RString&) );
void RefreshLocalizedStrings();
class LocalizedString
{
public:
LocalizedString( const RString &sSection, const RString &sName );
~LocalizedString();
void Refresh();
operator RString() const;
RString GetValue() const;
private:
RString m_sSection;
RString m_sName;
RString m_sValue;
bool m_bLoaded;
};
#endif
+1
View File
@@ -3,6 +3,7 @@
#include "RageLog.h"
#include "RageUtil.h"
#include "ScreenTextEntry.h"
#include "LocalizedString.h"
AutoScreenMessage( SM_BackFromRoomName )
+1
View File
@@ -9,6 +9,7 @@
#include "HelpDisplay.h"
#include "ScreenDimensions.h"
#include "InputEventPlus.h"
#include "LocalizedString.h"
static ThemeMetric<bool> ALLOW_RESIZE("ScreenCenterImage","AllowResize");
+1
View File
@@ -20,6 +20,7 @@
#include "RageInput.h"
#include "RageDisplay.h"
#include "InputEventPlus.h"
#include "LocalizedString.h"
static bool g_bIsDisplayed = false;
static bool g_bIsSlow = false;
+1
View File
@@ -33,6 +33,7 @@
#include <float.h>
#include "InputEventPlus.h"
#include "NotesWriterSM.h"
#include "LocalizedString.h"
static Preference<float> g_iDefaultRecordLength( "DefaultRecordLength", 4 );
static Preference<bool> g_bEditorShowBGChangesPlay( "EditorShowBGChangesPlay", false );
+1
View File
@@ -14,6 +14,7 @@
#include "CommonMetrics.h"
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#include "LocalizedString.h"
#define EXPLANATION_TEXT( row ) THEME->GetMetric(m_sName,"Explanation"+EditMenuRowToString(row))
#define EDIT_MENU_TYPE THEME->GetMetric(m_sName,"EditMenuType")
+1 -1
View File
@@ -22,7 +22,7 @@
#include "RageLog.h"
#include "song.h"
#include "InputEventPlus.h"
#include "LocalizedString.h"
#define PREV_SCREEN THEME->GetMetric ("ScreenEz2SelectMusic","PrevScreen")
#define SCROLLING_LIST_X THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListX")
+1 -1
View File
@@ -13,7 +13,7 @@ class Style;
#include "ScreenPrompt.h"
#include "ScreenManager.h"
#include "InputEventPlus.h"
#include "LocalizedString.h"
static const CString MultiPlayerStatusNames[] = {
"Joined",
+1
View File
@@ -11,6 +11,7 @@
#include "WheelItemBase.h"
//#include "RageLog.h"
#include "InputEventPlus.h"
#include "LocalizedString.h"
#define TITLEBG_WIDTH THEME->GetMetricF(m_sName,"TitleBGWidth")
#define TITLEBG_HEIGHT THEME->GetMetricF(m_sName,"TitleBGHeight")
+1
View File
@@ -11,6 +11,7 @@
#include "ScreenTextEntry.h"
#include "ScreenPrompt.h"
#include "NetworkSyncServer.h"
#include "LocalizedString.h"
enum {
PO_CONNECTION,
@@ -10,6 +10,7 @@
#include "ScreenMiniMenu.h"
#include "ScreenPrompt.h"
#include "CourseUtil.h"
#include "LocalizedString.h"
enum EditCourseRow
{
@@ -11,6 +11,7 @@
#include "GameManager.h"
#include "Difficulty.h"
#include "CourseUtil.h"
#include "LocalizedString.h"
static void RefreshTrail()
{
@@ -11,6 +11,7 @@
#include "ScreenMiniMenu.h"
#include "RageUtil.h"
#include "RageFileManager.h"
#include "LocalizedString.h"
AutoScreenMessage( SM_BackFromRename )
AutoScreenMessage( SM_BackFromDelete )
@@ -10,6 +10,7 @@
#include "ProfileManager.h"
#include "Profile.h"
#include "OptionRowHandler.h"
#include "LocalizedString.h"
static ThemeMetric<CString> NEW_PROFILE_DEFAULT_NAME( "ScreenOptionsManageProfiles", "NewProfileDefaultName" );
@@ -6,6 +6,7 @@
#include "GameState.h"
#include "ScreenManager.h"
#include "ScreenPrompt.h"
#include "LocalizedString.h"
REGISTER_SCREEN_CLASS( ScreenOptionsMemoryCard );
+1
View File
@@ -12,6 +12,7 @@
#include "ScreenTextEntry.h"
#include "ScreenManager.h"
#include <cstdlib>
#include "LocalizedString.h"
#define EXISTINGBG_WIDTH THEME->GetMetricF(m_sName,"PackagesBGWidth")
#define WEBBG_WIDTH THEME->GetMetricF(m_sName,"WebBGWidth")
+1
View File
@@ -13,6 +13,7 @@
#include "NetworkSyncManager.h"
#include "ScreenTextEntry.h"
#include "Profile.h"
#include "LocalizedString.h"
REGISTER_SCREEN_CLASS(ScreenSMOnlineLogin);
+1
View File
@@ -3,6 +3,7 @@
#include "GameState.h"
#include "song.h"
#include "PrefsManager.h"
#include "LocalizedString.h"
static LocalizedString EARLIER ("ScreenSaveSync","earlier");
+1
View File
@@ -11,6 +11,7 @@
#include "LightsManager.h"
#include "CommonMetrics.h"
#include "Command.h"
#include "LocalizedString.h"
#define ICON_GAIN_FOCUS_COMMAND THEME->GetMetricA(m_sName,"IconGainFocusCommand")
+1
View File
@@ -13,6 +13,7 @@
#include "MemoryCardManager.h"
#include "GameState.h"
#include "PlayerState.h"
#include "LocalizedString.h"
static LocalizedString BOOKKEEPING_DATA_CLEARED( "ScreenServiceAction", "Bookkeeping data cleared." );
static CString ClearBookkeepingData()
+1
View File
@@ -6,6 +6,7 @@
#include "song.h"
#include "PrefsManager.h"
#include "InputEventPlus.h"
#include "LocalizedString.h"
static bool IsGameplay()
{
+1
View File
@@ -18,6 +18,7 @@
#include "ProfileManager.h"
#include "CharacterManager.h"
#include "InputEventPlus.h"
#include "LocalizedString.h"
#define COIN_MODE_CHANGE_SCREEN THEME->GetMetric (m_sName,"CoinModeChangeScreen")
+1 -1
View File
@@ -34,6 +34,7 @@
#include "Profile.h"
#include "CourseLoaderCRS.h"
#include "TitleSubstitution.h"
#include "LocalizedString.h"
SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program
@@ -104,7 +105,6 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld )
static LocalizedString FOLDER_CONTAINS_MUSIC_FILES( "SongManager", "The folder '%s' appears to be a song folder. All song folders must reside in a group folder. For example, 'Songs/Originals/My Song'." );
void SongManager::SanityCheckGroupDir( CString sDir ) const
{
// Check to see if they put a song directly inside the group folder.
+9
View File
@@ -905,6 +905,15 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="Inventory.h">
</File>
<File
RelativePath=".\LocalizedString.cpp">
</File>
<File
RelativePath=".\LocalizedString.h">
</File>
<File
RelativePath=".\LocalizedStringLua.cpp">
</File>
<File
RelativePath="LuaBinding.cpp">
</File>
+3 -2
View File
@@ -15,6 +15,7 @@
#include "RageMath.h"
#include "RageDisplay.h"
#include "RageThreads.h"
#include "LocalizedString.h"
#include "arch/ArchHooks/ArchHooks.h"
#include "arch/LoadingWindow/LoadingWindow.h"
@@ -1062,8 +1063,8 @@ int main(int argc, char* argv[])
delete pIcon;
}
RegisterLocalizer( LocalizeString );
RefreshLocalizedStrings();
LocalizedString::RegisterLocalizer( LocalizeString );
LocalizedString::RefreshLocalizedStrings();
if( PREFSMAN->m_iSoundWriteAhead )
+1
View File
@@ -16,6 +16,7 @@
#include "LuaManager.h"
#include "ScreenDimensions.h"
#include "Command.h"
#include "LocalizedString.h"
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
+1
View File
@@ -9,6 +9,7 @@
#include "arch.h"
#include "arch_platform.h"
#include "Foreach.h"
#include "LocalizedString.h"
#include "InputHandler/Selector_InputHandler.h"
static LocalizedString INPUT_HANDLERS_EMPTY( "Arch", "Input Handlers cannot be empty." );