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 InitializeConfigFiles() { // Hard-coded filenames, guh PackStream::StaticAddPackageFile( "syncer.cpk" ); ConfigManager::Load( PackStream( "Config/syncer.pcf" ) ); PackStream::StaticShutDown(); }
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 InternalLoadConfigFiles() { STATICHASH( NumConfigFiles ); int NumConfigFiles = ConfigManager::GetInt( sNumConfigFiles ); for( int i = 0; i < NumConfigFiles; ++i ) { const char* ConfigFile = ConfigManager::GetSequenceString( "ConfigFile%d", i ); if( ConfigFile ) { ConfigManager::Load( PackStream( ConfigFile ) ); } } }
/*virtual*/ void Framework3D::Initialize() { XTRACE_FUNCTION; m_IsInitializing = true; #if BUILD_SDL const int Error = SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE ); ASSERT( 0 == Error ); Unused( Error ); if( 0 != Error ) { PRINTF( "SDL_Init: %s\n", SDL_GetError() ); } SDL_DisableScreenSaver(); #endif STATICHASH( Framework ); #if BUILD_WINDOWS #if BUILD_FINAL STATICHASH( ShowConsole ); const bool ShowConsole = ConfigManager::GetBool( sShowConsole, false, sFramework ); if( ShowConsole ) #endif { Console::GetInstance()->SetPos( 0, 0 ); } #endif STATICHASH( UseRandomSeed ); const bool UseRandomSeed = ConfigManager::GetBool( sUseRandomSeed, false, sFramework ); STATICHASH( RandomSeed ); const int RandomSeed = ConfigManager::GetInt( sRandomSeed, 0, sFramework ); if( UseRandomSeed ) { Math::SeedGenerator( RandomSeed ); } else { Math::SeedGenerator(); } STATICHASH( UseFixedFrameTime ); m_UseFixedFrameTime = ConfigManager::GetBool( sUseFixedFrameTime, true, sFramework ); STATICHASH( FixedFrameTime ); m_FixedFrameTime = ConfigManager::GetFloat( sFixedFrameTime, 1.0f / 60.0f, sFramework ); STATICHASH( FramesLimit ); const int FramesLimit = ConfigManager::GetInt( sFramesLimit, 5, sFramework ); m_FrameTimeLimit = m_FixedFrameTime * static_cast<float>( FramesLimit ); STATICHASH( DoVideoCapture ); m_DoVideoCapture = ConfigManager::GetBool( sDoVideoCapture, false, sFramework ); STATICHASH( VideoCaptureFixedFrameTime ); m_VideoCaptureFixedFrameTime = ConfigManager::GetFloat( sVideoCaptureFixedFrameTime, 1.0f / 30.0f, sFramework ); uint DisplayWidth = 0; uint DisplayHeight = 0; SimpleString WindowTitle; // Loads display parameters from config, so GetInitialDisplaySize can use that. m_Display = new Display; // Make sure that we use a supported resolution regardless of what the config file said. const SDisplayMode BestDisplayMode = m_Display->GetBestDisplayMode( m_Display->m_Width, m_Display->m_Height ); m_Display->SetResolution( BestDisplayMode.Width, BestDisplayMode.Height ); uint WindowIcon = 0; GetInitialWindowIcon( WindowIcon ); GetInitialDisplaySize( DisplayWidth, DisplayHeight ); GetInitialWindowTitle( WindowTitle ); CreateSplashWindow( WindowIcon, WindowTitle.CStr() ); m_Window = new Window; #if BUILD_WINDOWS_NO_SDL DWORD WindowStyle = 0; if( m_Display->m_Fullscreen || ( m_Display->m_ScreenWidth == m_Display->m_Width && m_Display->m_ScreenHeight == m_Display->m_Height ) ) { WindowStyle = WS_POPUP; } else { WindowStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; } m_Window->Init( WindowTitle.CStr(), "Class1", WindowStyle, 0, DisplayWidth, DisplayHeight, m_hInstance, WindowProc, WindowIcon, m_Display->m_ScreenWidth, m_Display->m_ScreenHeight ); #elif BUILD_SDL uint WindowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN; if( m_Display->m_Fullscreen || ( m_Display->m_ScreenWidth == m_Display->m_Width && m_Display->m_ScreenHeight == m_Display->m_Height ) ) { WindowFlags |= SDL_WINDOW_BORDERLESS; } // TODO SDL: Unify interface? m_Window->Init( WindowTitle.CStr(), WindowFlags, DisplayWidth, DisplayHeight ); STATICHASH( IconImage ); const char* const pIconImage = ConfigManager::GetString( sIconImage, NULL, sFramework ); ASSERT( pIconImage ); const Surface IconSurface = Surface( PackStream( pIconImage ), Surface::ESFT_BMP ); SDL_SetWindowIcon( m_Window->GetSDLWindow(), IconSurface.GetSDLSurface() ); #endif m_Window->SetFullscreen( m_Display->m_Fullscreen ); if( m_Display->m_Fullscreen ) { m_Window->SetPosition( 0, 0 ); } m_Clock = new Clock; XTRACE_BEGIN( InitializeDevices ); m_Keyboard = new Keyboard; #if BUILD_WINDOWS_NO_SDL m_Mouse = new Mouse( m_hInstance, m_Window->GetHWnd() ); #elif BUILD_SDL m_Mouse = new Mouse( m_Window ); #endif XTRACE_END; InitializeUIInputMap(); XTRACE_BEGIN( InitializeAudioSystem ); InitializeAudioSystem(); XTRACE_END; XTRACE_BEGIN( InitializeRenderer ); #if BUILD_WINDOWS_NO_SDL STATICHASH( OpenGL ); const bool OpenGL = ConfigManager::GetBool( sOpenGL ); if( OpenGL ) #endif { PRINTF( "Using OpenGL renderer.\n" ); m_Renderer = CreateGL2Renderer( m_Window ); } #if BUILD_WINDOWS_NO_SDL else { PRINTF( "Using Direct3D renderer.\n" ); m_Renderer = CreateD3D9Renderer( m_Window->GetHWnd(), m_Display->m_Fullscreen ); } #endif IRenderer::SRestoreDeviceCallback Callback; Callback.m_Callback = &Framework3D::RendererRestoreDeviceCallback; Callback.m_Void = this; m_Renderer->SetRestoreDeviceCallback( Callback ); InitializeRender(); m_Renderer->Initialize(); m_Renderer->SetDisplay( m_Display ); m_Renderer->SetClock( m_Clock ); XTRACE_END; if( ShowWindowASAP() ) { SafeDelete( m_SplashWindow ); #if BUILD_WINDOWS_NO_SDL m_Window->Show( m_CmdShow ); #elif BUILD_SDL m_Window->Show(); #endif // Reattach GL context if needed. m_Renderer->Refresh(); } if( UseClassicTargetManager() ) { m_TargetManager = new TargetManager( m_Renderer, DisplayWidth, DisplayHeight ); } XTRACE_BEGIN( InitializeUI ); SimpleString UIManagerDefinitionName; GetUIManagerDefinitionName( UIManagerDefinitionName ); m_UIManager = new UIManagerFramework( this ); m_UIManager->InitializeFromDefinition( UIManagerDefinitionName ); m_UIManager->GetUIStack()->SetFadeOverlay( m_UIManager->GetScreen( "Fade" ) ); UIScreen::UpdateMouseButtonsSwapped(); XTRACE_END; m_IsInitializing = false; }
/*virtual*/ IPixelShader* D3D9Renderer::CreatePixelShader( const SimpleString& Filename) { D3D9PixelShader* const pPixelShader = new D3D9PixelShader; pPixelShader->Initialize(m_D3DDevice, PackStream(Filename.CStr())); return pPixelShader; }
void FrameworkUtil::MinimalLoadConfigFiles( const char* RootFilename ) { ConfigManager::Load( PackStream( RootFilename ) ); InternalLoadConfigFiles(); }