void OSystem_SDL::initBackend() { // Check if backend has not been initialized assert(!_inited); const int maxNameLen = 20; char sdlDriverName[maxNameLen]; sdlDriverName[0] = '\0'; SDL_VideoDriverName(sdlDriverName, maxNameLen); // Using printf rather than debug() here as debug()/logging // is not active by this point. debug(1, "Using SDL Video Driver \"%s\"", sdlDriverName); // Create the default event source, in case a custom backend // manager didn't provide one yet. if (_eventSource == 0) _eventSource = new SdlEventSource(); #ifdef USE_OPENGL // Query the desktop resolution. We simply hope nothing tried to change // the resolution so far. const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); if (videoInfo && videoInfo->current_w > 0 && videoInfo->current_h > 0) { _desktopWidth = videoInfo->current_w; _desktopHeight = videoInfo->current_h; } #endif if (_graphicsManager == 0) { #ifdef USE_OPENGL // Setup a list with both SDL and OpenGL graphics modes. We only do // this whenever the subclass did not already set up an graphics // manager yet. This is because we don't know the type of the graphics // manager of the subclass, thus we cannot easily switch between the // OpenGL one and the set up one. It also is to be expected that the // subclass does not want any switching of graphics managers anyway. setupGraphicsModes(); if (ConfMan.hasKey("gfx_mode")) { // If the gfx_mode is from OpenGL, create the OpenGL graphics manager Common::String gfxMode(ConfMan.get("gfx_mode")); for (uint i = _firstGLMode; i < _graphicsModeIds.size(); ++i) { if (!scumm_stricmp(_graphicsModes[i].name, gfxMode.c_str())) { _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); _graphicsMode = i; break; } } } #endif if (_graphicsManager == 0) { _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); } } if (_savefileManager == 0) _savefileManager = new DefaultSaveFileManager(); if (_mixerManager == 0) { _mixerManager = new SdlMixerManager(); // Setup and start mixer _mixerManager->init(); } #ifdef ENABLE_EVENTRECORDER g_eventRec.registerMixerManager(_mixerManager); g_eventRec.registerTimerManager(new SdlTimerManager()); #else if (_timerManager == 0) _timerManager = new SdlTimerManager(); #endif if (_audiocdManager == 0) { // Audio CD support was removed with SDL 1.3 #if SDL_VERSION_ATLEAST(1, 3, 0) _audiocdManager = new DefaultAudioCDManager(); #else _audiocdManager = new SdlAudioCDManager(); #endif } // Setup a custom program icon. setupIcon(); _inited = true; ModularBackend::initBackend(); // We have to initialize the graphics manager before the event manager // so the virtual keyboard can be initialized, but we have to add the // graphics manager as an event observer after initializing the event // manager. dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->activateManager(); }
void OSystem_SDL::initBackend() { // Check if backend has not been initialized assert(!_inited); // Create the default event source, in case a custom backend // manager didn't provide one yet. if (_eventSource == 0) _eventSource = new SdlEventSource(); int graphicsManagerType = 0; if (_graphicsManager == 0) { #ifdef USE_OPENGL if (ConfMan.hasKey("gfx_mode")) { Common::String gfxMode(ConfMan.get("gfx_mode")); bool use_opengl = false; const OSystem::GraphicsMode *mode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); while (mode->name) { if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0) use_opengl = true; mode++; } // If the gfx_mode is from OpenGL, create the OpenGL graphics manager if (use_opengl) { _graphicsManager = new OpenGLSdlGraphicsManager(); graphicsManagerType = 1; } } #endif if (_graphicsManager == 0) { _graphicsManager = new SdlGraphicsManager(_eventSource); graphicsManagerType = 0; } } // Creates the backend managers, if they don't exist yet (we check // for this to allow subclasses to provide their own). if (_eventManager == 0) _eventManager = new DefaultEventManager(_eventSource); // We have to initialize the graphics manager before the event manager // so the virtual keyboard can be initialized, but we have to add the // graphics manager as an event observer after initializing the event // manager. if (graphicsManagerType == 0) ((SdlGraphicsManager *)_graphicsManager)->initEventObserver(); #ifdef USE_OPENGL else if (graphicsManagerType == 1) ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); #endif if (_savefileManager == 0) _savefileManager = new DefaultSaveFileManager(); if (_mixerManager == 0) { _mixerManager = new SdlMixerManager(); // Setup and start mixer _mixerManager->init(); } if (_audiocdManager == 0) _audiocdManager = new SdlAudioCDManager(); // Setup a custom program icon. setupIcon(); _inited = true; }
void OptionsDialog::open() { Dialog::open(); // Reset result value setResult(0); // Graphic options if (_fullscreenCheckbox) { _gfxPopUp->setSelected(0); if (ConfMan.hasKey("gfx_mode", _domain)) { const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes(); String gfxMode(ConfMan.get("gfx_mode", _domain)); int gfxCount = 1; while (gm->name) { gfxCount++; if (scumm_stricmp(gm->name, gfxMode.c_str()) == 0) _gfxPopUp->setSelected(gfxCount); gm++; } } _renderModePopUp->setSelected(0); if (ConfMan.hasKey("render_mode", _domain)) { const Common::RenderModeDescription *p = Common::g_renderModes; const Common::RenderMode renderMode = Common::parseRenderMode(ConfMan.get("render_mode", _domain)); int sel = 0; for (int i = 0; p->code; ++p, ++i) { if (renderMode == p->id) sel = i + 2; } _renderModePopUp->setSelected(sel); } #ifndef SMALL_SCREEN_DEVICE // Fullscreen setting _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain)); // Aspect ratio setting _aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain)); #endif } // Audio options if (_midiPopUp) { // Music driver const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers(); int i = 0; const int midiDriver = ConfMan.hasKey("music_driver", _domain) ? MidiDriver::parseMusicDriver(ConfMan.get("music_driver", _domain)) : MD_AUTO; while (md->name && md->id != midiDriver) { i++; md++; } _midiPopUp->setSelected(md->name ? i : 0); } if (_multiMidiCheckbox) { // Multi midi setting _multiMidiCheckbox->setState(ConfMan.getBool("multi_midi", _domain)); // Native mt32 setting _mt32Checkbox->setState(ConfMan.getBool("native_mt32", _domain)); // GS extensions setting _enableGSCheckbox->setState(ConfMan.getBool("enable_gs", _domain)); String soundFont(ConfMan.get("soundfont", _domain)); if (soundFont.empty() || !ConfMan.hasKey("soundfont", _domain)) _soundFont->setLabel("None"); else _soundFont->setLabel(soundFont); // MIDI gain setting char buf[10]; _midiGainSlider->setValue(ConfMan.getInt("midi_gain", _domain)); sprintf(buf, "%.2f", (double)_midiGainSlider->getValue() / 100.0); _midiGainLabel->setLabel(buf); } // Volume options if (_musicVolumeSlider) { int vol; vol = ConfMan.getInt("music_volume", _domain); _musicVolumeSlider->setValue(vol); _musicVolumeLabel->setValue(vol); vol = ConfMan.getInt("sfx_volume", _domain); _sfxVolumeSlider->setValue(vol); _sfxVolumeLabel->setValue(vol); vol = ConfMan.getInt("speech_volume", _domain); _speechVolumeSlider->setValue(vol); _speechVolumeLabel->setValue(vol); } // Subtitle options if (_subToggleButton) { int speed; int sliderMaxValue = _subSpeedSlider->getMaxValue(); _subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute")); _subToggleButton->setLabel(_subModeDesc[_subMode]); // Engines that reuse the subtitle speed widget set their own max value. // Scale the config value accordingly (see addSubtitleControls) speed = (ConfMan.getInt("talkspeed", _domain) * sliderMaxValue + 255 / 2) / 255; _subSpeedSlider->setValue(speed); _subSpeedLabel->setValue(speed); } }
void OSystem_SDL::initBackend() { // Check if backend has not been initialized assert(!_inited); // Create the default event source, in case a custom backend // manager didn't provide one yet. if (_eventSource == 0) _eventSource = new SdlEventSource(); int graphicsManagerType = 0; if (_graphicsManager == 0) { #ifdef USE_OPENGL if (ConfMan.hasKey("gfx_mode")) { Common::String gfxMode(ConfMan.get("gfx_mode")); bool use_opengl = false; const OSystem::GraphicsMode *mode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); int i = 0; while (mode->name) { if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0) { _graphicsMode = i + _sdlModesCount; use_opengl = true; } mode++; ++i; } // If the gfx_mode is from OpenGL, create the OpenGL graphics manager if (use_opengl) { _graphicsManager = new OpenGLSdlGraphicsManager(_eventSource); graphicsManagerType = 1; } } #endif if (_graphicsManager == 0) { _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); graphicsManagerType = 0; } } if (_savefileManager == 0) _savefileManager = new DefaultSaveFileManager(); if (_mixerManager == 0) { _mixerManager = new SdlMixerManager(); // Setup and start mixer _mixerManager->init(); } if (_audiocdManager == 0) { // Audio CD support was removed with SDL 1.3 #if SDL_VERSION_ATLEAST(1, 3, 0) _audiocdManager = new DefaultAudioCDManager(); #else _audiocdManager = new SdlAudioCDManager(); #endif } // Setup a custom program icon. setupIcon(); _inited = true; ModularBackend::initBackend(); // We have to initialize the graphics manager before the event manager // so the virtual keyboard can be initialized, but we have to add the // graphics manager as an event observer after initializing the event // manager. if (graphicsManagerType == 0) ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); #ifdef USE_OPENGL else if (graphicsManagerType == 1) ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); #endif }