void EldritchGame::Initialize() { if( GetSaveLoad()->TryLoadMaster() ) { // We're good! Don't flush the master file; if the game crashes, we still want it around! } else { // There was no master file, or the master file didn't have a world state (was saved // when the player was dead, etc.). Create a new world, but don't mess with persistence. STATICHASH( EldritchWorld ); STATICHASH( InitialLevel ); SetCurrentLevelName( ConfigManager::GetString( sInitialLevel, "", sEldritchWorld ) ); MAKEHASH( m_CurrentLevelName ); STATICHASH( WorldDef ); const HashedString InitialWorldDef = ConfigManager::GetHash( sWorldDef, HashedString::NullString, sm_CurrentLevelName ); EldritchFramework* const pFramework = EldritchFramework::GetInstance(); EldritchWorld* const pWorld = pFramework->GetWorld(); pWorld->SetCurrentWorld( InitialWorldDef ); pWorld->Create(); pFramework->InitializeTools(); RefreshUIReturnToHubEnabled(); } }
void Framework3D::ConditionalRefreshDisplay() { XTRACE_FUNCTION; // We shouldn't mess with this during initialization! if( m_IsInitializing || m_IsShuttingDown ) { return; } // Resync display after changing config vars out from under it. STATICHASH( Fullscreen ); const bool Fullscreen = ConfigManager::GetBool( sFullscreen ); STATICHASH( DisplayWidth ); const uint DisplayWidth = ConfigManager::GetInt( sDisplayWidth ); STATICHASH( DisplayHeight ); const uint DisplayHeight = ConfigManager::GetInt( sDisplayHeight ); ASSERT( m_Display ); if( m_Display->NeedsUpdate() || m_Display->m_Fullscreen != Fullscreen || m_Display->m_Width != DisplayWidth || m_Display->m_Height != DisplayHeight ) { RefreshDisplay( Fullscreen, DisplayWidth, DisplayHeight ); } }
void WBCompEldWallet::AddMoney(const uint Money, const bool ShowPickupScreen) { m_Money = Min(m_Money + Money, m_Limit); PublishToHUD(); if (ShowPickupScreen) { // Show the money pickup screen and hide it after some time STATICHASH(MoneyPickup); STATICHASH(Money); ConfigManager::SetInt(sMoney, Money, sMoneyPickup); STATIC_HASHED_STRING(MoneyPickupScreen); { WB_MAKE_EVENT(PushUIScreen, NULL); WB_SET_AUTO(PushUIScreen, Hash, Screen, sMoneyPickupScreen); WB_DISPATCH_EVENT(GetEventManager(), PushUIScreen, NULL); } { // Remove previously queued hide event if any GetEventManager()->UnqueueEvent(m_HidePickupScreenUID); WB_MAKE_EVENT(RemoveUIScreen, NULL); WB_SET_AUTO(RemoveUIScreen, Hash, Screen, sMoneyPickupScreen); m_HidePickupScreenUID = WB_QUEUE_EVENT_DELAY( GetEventManager(), RemoveUIScreen, NULL, m_HidePickupScreenDelay); } } }
void EldritchFramework::InitializeDLC() { STATICHASH(NumDLC); const uint NumDLC = ConfigManager::GetInt(sNumDLC); for (uint DLCIndex = 0; DLCIndex < NumDLC; ++DLCIndex) { const SimpleString DLCName = ConfigManager::GetSequenceString("DLC%d", DLCIndex, ""); MAKEHASH(DLCName); STATICHASH(PackageFilename); const SimpleString PackageFilename = ConfigManager::GetString(sPackageFilename, "", sDLCName); // DLC will always preempt base content (so it can be used for patching as // well as DLC per se). PackStream::StaticAddPackageFile(PackageFilename.CStr(), true); // Load config files for DLC, if DLC was successfully loaded. // (We can't check a return value from StaticAddPackageFile, because I won't // have package // files during development but it still needs to load loose DLC files.) STATICHASH(NumConfigFiles); const uint NumConfigFiles = ConfigManager::GetInt(sNumConfigFiles, 0, sDLCName); for (uint ConfigFileIndex = 0; ConfigFileIndex < NumConfigFiles; ++ConfigFileIndex) { const SimpleString ConfigFile = ConfigManager::GetSequenceString( "ConfigFile%d", ConfigFileIndex, "", sDLCName); if (PackStream::StaticFileExists(ConfigFile.CStr())) { ConfigManager::Load(PackStream(ConfigFile.CStr())); } } } }
void RodinBTNodeSendEvent::InitializeFromDefinition( const SimpleString& DefinitionName ) { MAKEHASH( DefinitionName ); STATICHASH( EventName ); m_EventName = ConfigManager::GetHash( sEventName, "", sDefinitionName ); STATICHASH( QueueEvent ); m_QueueEvent = ConfigManager::GetBool( sQueueEvent, false, sDefinitionName ); STATICHASH( DispatchDelay ); m_DispatchDelay = ConfigManager::GetFloat( sDispatchDelay, 0.0f, sDefinitionName ); STATICHASH( Recipient ); const SimpleString RecipientDef = ConfigManager::GetString( sRecipient, "", sDefinitionName ); m_RecipientPE.InitializeFromDefinition( RecipientDef ); STATICHASH( NumParameters ); const uint NumParameters = ConfigManager::GetInt( sNumParameters, 0, sDefinitionName ); for( uint ParameterIndex = 0; ParameterIndex < NumParameters; ++ParameterIndex ) { const HashedString Name = ConfigManager::GetSequenceHash( "Parameter%dName", ParameterIndex, HashedString::NullString, sDefinitionName ); const SimpleString ValuePEDef = ConfigManager::GetSequenceString( "Parameter%dValue", ParameterIndex, "", sDefinitionName ); SNamedParameter& Parameter = m_Parameters.PushBack(); Parameter.m_Name = Name; Parameter.m_ValuePE.InitializeFromDefinition( ValuePEDef ); } }
bool CheckForRelaunch() { STATICHASH( ContentSyncer ); STATICHASH( Self ); STATICHASH( TempSelf ); STATICHASH( RelaunchArg ); SimpleString RelaunchArg = ConfigManager::GetString( sRelaunchArg, "", sContentSyncer ); SimpleString SelfExe = ConfigManager::GetString( sSelf, "", sContentSyncer ); SimpleString TempSelfExe = ConfigManager::GetString( sTempSelf, "", sContentSyncer ); if( HasCommandLineArgument( RelaunchArg ) ) { if( FileUtil::Copy( TempSelfExe.CStr(), SelfExe.CStr(), false ) ) { if( RelaunchTrueSelf() ) { return true; } } } else { // Clean up the relauncher if needed if( FileUtil::Exists( TempSelfExe.CStr() ) ) { FileUtil::RemoveFile( TempSelfExe.CStr() ); } } return false; }
void WBCompEldEndgameCounter::PublishToHUD() const { STATICHASH(HUD); STATICHASH(EndgameCount); ConfigManager::SetInt(sEndgameCount, m_Count, sHUD); SetHUDHidden(false); }
void EldritchGame::LaunchRIPTweet() { STATICHASH( RIPFormat ); const SimpleString RIPFormat = ConfigManager::GetLocalizedString( sRIPFormat, "" ); STATICHASH( RIPURL ); const SimpleString RIPURL = ConfigManager::GetLocalizedString( sRIPURL, "" ); STATICHASH( RIPHashtags ); const SimpleString RIPHashtags = ConfigManager::GetLocalizedString( sRIPHashtags, "" ); STATICHASH( RIPTwitter ); const SimpleString RIPTwitter = ConfigManager::GetLocalizedString( sRIPTwitter, "" ); const SimpleString RIPDamage = GetRIPDamage(); const SimpleString RIPLevel = GetRIPLevel(); const SimpleString RIPFormatted = SimpleString::PrintF( RIPFormat.CStr(), RIPDamage.CStr(), RIPLevel.CStr() ); const SimpleString RIPEncoded = RIPFormatted.URLEncodeUTF8(); const SimpleString RIPTweet = SimpleString::PrintF( RIPTwitter.CStr(), RIPEncoded.CStr(), RIPHashtags.CStr(), RIPURL.CStr() ); #if BUILD_WINDOWS ShellExecute( NULL, "open", RIPTweet.CStr(), NULL, NULL, SW_SHOWNORMAL ); #elif BUILD_MAC const SimpleString Command = SimpleString::PrintF( "open %s", RIPTweet.CStr() ); system( Command.CStr() ); #elif BUILD_LINUX const SimpleString Command = SimpleString::PrintF( "xdg-open %s", RIPTweet.CStr() ); system( Command.CStr() ); #endif }
/*virtual*/ void EldritchFramework::HandleEvent(const WBEvent& Event) { XTRACE_FUNCTION; Framework3D::HandleEvent(Event); STATIC_HASHED_STRING(ToggleInvertY); STATIC_HASHED_STRING(ToggleFullscreen); STATIC_HASHED_STRING(OnSliderChanged); STATIC_HASHED_STRING(WritePrefsConfig); STATIC_HASHED_STRING(CheckForUpdates); const HashedString EventName = Event.GetEventName(); if (EventName == sToggleInvertY) { XTRACE_NAMED(ToggleInvertY); // TODO: Also invert controller? Or on a separate button? STATIC_HASHED_STRING(TurnY); const bool InvertY = !m_InputSystem->GetMouseInvert(sTurnY); m_InputSystem->SetMouseInvert(sTurnY, InvertY); m_InputSystem->SetControllerInvert(sTurnY, InvertY); // Publish config var so UI can reflect the change. // I could make input system publish config vars for each adjustment, but // that seems wasteful since most inputs currently have no adjustment. STATICHASH(InvertY); ConfigManager::SetBool(sInvertY, InvertY); } else if (EventName == sToggleFullscreen) { XTRACE_NAMED(ToggleFullscreen); ToggleFullscreen(); } else if (EventName == sOnSliderChanged) { XTRACE_NAMED(OnSliderChanged); STATIC_HASHED_STRING(SliderName); const HashedString SliderName = Event.GetHash(sSliderName); STATIC_HASHED_STRING(SliderValue); const float SliderValue = Event.GetFloat(sSliderValue); HandleUISliderEvent(SliderName, SliderValue); } else if (EventName == sWritePrefsConfig) { XTRACE_NAMED(WritePrefsConfig); WritePrefsConfig(); } else if (EventName == sCheckForUpdates) { #if BUILD_WINDOWS && !BUILD_STEAM XTRACE_NAMED(CheckForUpdates); // So I can compile updating out of certain builds. STATICHASH(Framework); STATICHASH(CheckForUpdates); const bool CheckForUpdates = ConfigManager::GetBool(sCheckForUpdates, true, sFramework); if (CheckForUpdates) { m_CheckForUpdates->Check(false, true); } #endif } }
void Framework3D::CreateSplashWindow(const uint WindowIcon, const char* const Title) { XTRACE_FUNCTION; STATICHASH(Framework); STATICHASH(SplashImage); const char* const pSplashImage = ConfigManager::GetString(sSplashImage, nullptr, sFramework); if (!pSplashImage) { return; } const Surface SplashSurface = Surface(PackStream(pSplashImage), Surface::ESFT_BMP); const int SplashWindowWidth = SplashSurface.GetWidth(); const int SplashWindowHeight = SplashSurface.GetHeight(); ASSERT(!m_SplashWindow); m_SplashWindow = new Window; #if BUILD_WINDOWS_NO_SDL const DWORD WindowStyle = WS_POPUP; const DWORD WindowExStyle = WS_EX_TOOLWINDOW; // Prevents this window appearing in the taskbar const int ScreenWidth = m_Display->m_Fullscreen ? m_Display->m_Width : m_Display->m_ScreenWidth; const int ScreenHeight = m_Display->m_Fullscreen ? m_Display->m_Height : m_Display->m_ScreenHeight; m_SplashWindow->Init(Title, "SplashWindowClass", WindowStyle, WindowExStyle, SplashWindowWidth, SplashWindowHeight, m_hInstance, NULL, WindowIcon, ScreenWidth, ScreenHeight); // The window needs to be shown before we can blit to it. m_SplashWindow->Show(m_CmdShow); #endif #if BUILD_SDL // TODO SDL: Unify interface? const uint Flags = SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS; m_SplashWindow->Init(Title, Flags, SplashWindowWidth, SplashWindowHeight); // Load icon from package file instead of compiled resource. Unused(WindowIcon); STATICHASH(IconImage); const char* const pIconImage = ConfigManager::GetString(sIconImage, nullptr, sFramework); if(pIconImage) { ASSERT(pIconImage); const Surface IconSurface = Surface(PackStream(pIconImage), Surface::ESFT_BMP); SDL_SetWindowIcon(m_SplashWindow->GetSDLWindow(), IconSurface.GetSDLSurface()); } #endif SplashSurface.BlitToWindow(m_SplashWindow); }
void WBCompEldWallet::PublishToHUD() const { STATICHASH(HUD); STATICHASH(Money); ConfigManager::SetInt(sMoney, m_Money, sHUD); STATICHASH(Bank); STATICHASH(WalletMoney); ConfigManager::SetInt(sWalletMoney, m_Money, sBank); }
bool RelaunchTrueSelf() { STATICHASH( ContentSyncer ); STATICHASH( Self ); SimpleString CommandLine = ConfigManager::GetString( sSelf, "", sContentSyncer ); return Launch( CommandLine ); }
Clock::MultiplierRequest* Clock::AddMultiplierRequest( const SimpleString& DefinitionName ) { STATICHASH( Duration ); STATICHASH( Multiplier ); MAKEHASH( DefinitionName ); return AddMultiplierRequest( ConfigManager::GetFloat( sDuration, 0.0f, sDefinitionName ), ConfigManager::GetFloat( sMultiplier, 0.0f, sDefinitionName ) ); }
void EldritchSound3DListener::Initialize() { STATICHASH( AudioSystem ); STATICHASH( VerticalScalar ); m_VerticalScalar = ConfigManager::GetFloat( sVerticalScalar, 1.0f, sAudioSystem ); STATICHASH( OccludedFalloffRadius ); m_OccludedFalloffRadius = ConfigManager::GetFloat( sOccludedFalloffRadius, 0.0f, sAudioSystem ); }
/*virtual*/ void WBPEEldGetItem::InitializeFromDefinition( const SimpleString& DefinitionName ) { MAKEHASH( DefinitionName ); STATICHASH( EntityPE ); m_EntityPE = WBParamEvaluatorFactory::Create( ConfigManager::GetString( sEntityPE, "", sDefinitionName ) ); STATICHASH( SlotPE ); m_SlotPE = WBParamEvaluatorFactory::Create( ConfigManager::GetString( sSlotPE, "", sDefinitionName ) ); }
void UIScreenEldBindInputs::CreateCompositeWidgetDefinition() { m_CompositeWidgetDefinitionName = SimpleString::PrintF( "_BindComposite%d", m_ExposedInputIndex ); MAKEHASH( m_CompositeWidgetDefinitionName ); STATICHASH( UIWidgetType ); ConfigManager::SetString( sUIWidgetType, "Composite", sm_CompositeWidgetDefinitionName ); STATICHASH( Focus ); ConfigManager::SetBool( sFocus, true, sm_CompositeWidgetDefinitionName ); STATICHASH( NumChildren ); ConfigManager::SetInt( sNumChildren, 4, sm_CompositeWidgetDefinitionName ); STATICHASH( Child0 ); ConfigManager::SetString( sChild0, m_LabelWidgetDefinitionName.CStr(), sm_CompositeWidgetDefinitionName ); STATICHASH( Child1 ); ConfigManager::SetString( sChild1, m_KeyboardWidgetDefinitionName.CStr(), sm_CompositeWidgetDefinitionName ); STATICHASH( Child2 ); ConfigManager::SetString( sChild2, m_MouseWidgetDefinitionName.CStr(), sm_CompositeWidgetDefinitionName ); STATICHASH( Child3 ); ConfigManager::SetString( sChild3, m_ControllerWidgetDefinitionName.CStr(), sm_CompositeWidgetDefinitionName ); STATICHASH( NumActions ); ConfigManager::SetInt( sNumActions, 1, sm_CompositeWidgetDefinitionName ); STATICHASH( Action0 ); ConfigManager::SetString( sAction0, m_BindActionDefinitionName.CStr(), sm_CompositeWidgetDefinitionName ); }
void Reinit() { // Reload launcher config InitializeConfigFiles(); STATICHASH( ContentSyncer ); STATICHASH( Application ); g_CommandLine->m_App = ConfigManager::GetString( sApplication, "", sContentSyncer ); ResolveCommandLine(); }
bool RelaunchTempSelf() { STATICHASH( ContentSyncer ); STATICHASH( TempSelf ); STATICHASH( RelaunchArg ); SimpleString CommandLine = SimpleString::PrintF( "%s %s", ConfigManager::GetString( sTempSelf, "", sContentSyncer ), ConfigManager::GetString( sRelaunchArg, "", sContentSyncer ) ); return Launch( CommandLine ); }
/*virtual*/ void WBActionEldCheckLine::InitializeFromDefinition( const SimpleString& DefinitionName ) { WBAction::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); STATICHASH( LineLength ); m_LineLength = ConfigManager::GetFloat( sLineLength, 0.0f, sDefinitionName ); STATICHASH( CheckTag ); m_CheckTag = ConfigManager::GetHash( sCheckTag, HashedString::NullString, sDefinitionName ); }
void WBPEEldHardSwitch::InitializeFromDefinition( const SimpleString& DefinitionName ) { STATICHASH( Normal ); STATICHASH( Hard ); MAKEHASH( DefinitionName ); m_NormalInput = WBParamEvaluatorFactory::Create( ConfigManager::GetString( sNormal, "", sDefinitionName ) ); m_HardInput = WBParamEvaluatorFactory::Create( ConfigManager::GetString( sHard, "", sDefinitionName ) ); ASSERT( m_NormalInput ); ASSERT( m_HardInput ); }
void Display::SetResolution( uint Width, uint Height ) { m_Width = Width; m_Height = Height; m_AspectRatio = ( float )m_Width / ( float )m_Height; // Keep config vars in sync with display STATICHASH( DisplayWidth ); STATICHASH( DisplayHeight ); ConfigManager::SetInt( sDisplayWidth, m_Width ); ConfigManager::SetInt( sDisplayHeight, m_Height ); }
/*virtual*/ void WBCompEldMapMarker::InitializeFromDefinition( const SimpleString& DefinitionName ) { Super::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); STATICHASH( MarkAsRoom ); m_MarkAsRoom = ConfigManager::GetInheritedBool( sMarkAsRoom, false, sDefinitionName ); STATICHASH( Texture ); m_Texture = ConfigManager::GetInheritedString( sTexture, "", sDefinitionName ); }
/*virtual*/ void WBCompEldFaction::InitializeFromDefinition( const SimpleString& DefinitionName ) { Super::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); STATICHASH( Faction ); m_Faction = ConfigManager::GetInheritedHash( sFaction, HashedString::NullString, sDefinitionName ); STATICHASH( Immutable ); m_Immutable = ConfigManager::GetInheritedBool( sImmutable, false, sDefinitionName ); }
/*virtual*/ void WBActionTriggerStatMod::InitializeFromDefinition( const SimpleString& DefinitionName ) { WBAction::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); STATICHASH( StatModEvent ); m_StatModEvent = ConfigManager::GetHash( sStatModEvent, HashedString::NullString, sDefinitionName ); STATICHASH( Trigger ); m_Trigger = ConfigManager::GetBool( sTrigger, true, sDefinitionName ); }
/*virtual*/ void WBCompEldWeapon::InitializeFromDefinition( const SimpleString& DefinitionName ) { Super::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); STATICHASH( Ammo ); m_Ammo = ConfigManager::GetInheritedHash( sAmmo, HashedString::NullString, sDefinitionName ); STATICHASH( WeaponIcon ); m_WeaponIcon = ConfigManager::GetInheritedString( sWeaponIcon, "", sDefinitionName ); }
/*virtual*/ void WBCompEldLock::InitializeFromDefinition( const SimpleString& DefinitionName ) { Super::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); STATICHASH( Locked ); m_Locked = ConfigManager::GetInheritedBool( sLocked, false, sDefinitionName ); STATICHASH( Key ); m_Key = ConfigManager::GetInheritedHash( sKey, HashedString::NullString, sDefinitionName ); }
/*virtual*/ void WBPEGetVariable::InitializeFromDefinition( const SimpleString& DefinitionName) { MAKEHASH(DefinitionName); STATICHASH(EntityPE); m_EntityPE = WBParamEvaluatorFactory::Create( ConfigManager::GetString(sEntityPE, "", sDefinitionName)); STATICHASH(VariableName); m_VariableName = ConfigManager::GetHash( sVariableName, HashedString::NullString, sDefinitionName); }
void RodinBTNodeBlackboardWrite::InitializeFromDefinition( const SimpleString& DefinitionName) { MAKEHASH(DefinitionName); STATICHASH(BlackboardKey); m_BlackboardKey = ConfigManager::GetHash( sBlackboardKey, HashedString::NullString, sDefinitionName); STATICHASH(ValuePE); m_ValuePE.InitializeFromDefinition( ConfigManager::GetString(sValuePE, "", sDefinitionName)); }
void MusicManager::UpdateMusicLevel() { STATICHASH( MusicLevelBase ); STATICHASH( MusicLevelStep ); STATICHASH( MusicLevel ); float MusicLevel = ConfigManager::GetFloat( sMusicLevelBase ) + ConfigManager::GetFloat( sMusicLevelStep ) * (float)( ConfigManager::GetInt( sMusicLevel ) - 1 ); m_AudioSystem->SetCategoryVolume( "Music", MusicLevel, 0.0f ); }
void UIScreenEldBindInputs::CreateBindingActionDefinition() { m_BindActionDefinitionName = SimpleString::PrintF( "_BindAction%d", m_ExposedInputIndex ); MAKEHASH( m_BindActionDefinitionName ); STATICHASH( ActionType ); ConfigManager::SetString( sActionType, "EldBindInput", sm_BindActionDefinitionName ); STATICHASH( Input ); ConfigManager::SetString( sInput, m_ExposedInput.CStr(), sm_BindActionDefinitionName ); }