Hide Pioneer window and disable audio for galaxy dump.

master
lwho 2014-03-15 00:31:22 +01:00
parent 8252130ab9
commit 7e957541e1
9 changed files with 19 additions and 13 deletions

View File

@ -146,6 +146,7 @@ void ModelViewer::Run(const std::string &modelName)
videoSettings.width = config->Int("ScrWidth");
videoSettings.height = config->Int("ScrHeight");
videoSettings.fullscreen = (config->Int("StartFullscreen") != 0);
videoSettings.hidden = false;
videoSettings.requestedSamples = config->Int("AntiAliasingMode");
videoSettings.vsync = (config->Int("VSync") != 0);
videoSettings.useTextureCompression = (config->Int("UseTextureCompression") != 0);

View File

@ -345,7 +345,7 @@ std::string Pi::GetSaveDir()
return FileSystem::JoinPath(FileSystem::GetUserDir(), Pi::SAVE_DIR_NAME);
}
void Pi::Init(const std::map<std::string,std::string> &options)
void Pi::Init(const std::map<std::string,std::string> &options, bool no_gui)
{
#ifdef PIONEER_PROFILER
Profiler::reset();
@ -361,7 +361,8 @@ void Pi::Init(const std::map<std::string,std::string> &options)
#endif
Pi::config = new GameConfig(options);
KeyBindings::InitBindings();
if (!no_gui) // This re-saves the config file. With no GUI we want to allow multiple instances in parallel.
KeyBindings::InitBindings();
if (config->Int("RedirectStdio"))
OS::RedirectStdio();
@ -390,6 +391,7 @@ void Pi::Init(const std::map<std::string,std::string> &options)
videoSettings.width = config->Int("ScrWidth");
videoSettings.height = config->Int("ScrHeight");
videoSettings.fullscreen = (config->Int("StartFullscreen") != 0);
videoSettings.hidden = no_gui;
videoSettings.requestedSamples = config->Int("AntiAliasingMode");
videoSettings.vsync = (config->Int("VSync") != 0);
videoSettings.useTextureCompression = (config->Int("UseTextureCompression") != 0);
@ -507,7 +509,7 @@ void Pi::Init(const std::map<std::string,std::string> &options)
Sfx::Init(Pi::renderer);
draw_progress(gauge, label, 0.95f);
if (!config->Int("DisableSound")) {
if (!no_gui && !config->Int("DisableSound")) {
Sound::Init();
Sound::SetMasterVolume(config->Float("MasterVolume"));
Sound::SetSfxVolume(config->Float("SfxVolume"));

View File

@ -62,7 +62,7 @@ class Game;
class Pi {
public:
static void Init(const std::map<std::string,std::string> &options);
static void Init(const std::map<std::string,std::string> &options, bool no_gui = false);
static void InitGame();
static void StarportStart(Uint32 starport);
static void StartGame();

View File

@ -19,6 +19,7 @@ namespace Graphics {
// requested video settings
struct Settings {
bool fullscreen;
bool hidden;
bool useTextureCompression;
bool enableDebugMessages;
int vsync;

View File

@ -9,9 +9,9 @@
namespace Graphics {
bool WindowSDL::CreateWindowAndContext(const char *name, int w, int h, bool fullscreen, int samples, int depth_bits) {
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
if (fullscreen) winFlags |= SDL_WINDOW_FULLSCREEN;
bool WindowSDL::CreateWindowAndContext(const char *name, int w, int h, bool fullscreen, bool hidden, int samples, int depth_bits) {
Uint32 winFlags = SDL_WINDOW_OPENGL | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN);
if (!hidden && fullscreen) winFlags |= SDL_WINDOW_FULLSCREEN;
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depth_bits);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
@ -45,26 +45,26 @@ WindowSDL::WindowSDL(const Graphics::Settings &vs, const std::string &name)
// attempt sequence is:
// 1- requested mode
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, vs.requestedSamples, 24);
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, vs.hidden, vs.requestedSamples, 24);
// 2- requested mode with no anti-aliasing (skipped if no AA was requested anyway)
// (skipped if no AA was requested anyway)
if (!ok && vs.requestedSamples) {
Output("Failed to set video mode. (%s). Re-trying without multisampling.\n", SDL_GetError());
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, 0, 24);
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, vs.hidden, 0, 24);
}
// 3- requested mode with 16 bit depth buffer
if (!ok) {
Output("Failed to set video mode. (%s). Re-trying with 16-bit depth buffer\n", SDL_GetError());
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, vs.requestedSamples, 16);
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, vs.hidden, vs.requestedSamples, 16);
}
// 4- requested mode with 16-bit depth buffer and no anti-aliasing
// (skipped if no AA was requested anyway)
if (!ok && vs.requestedSamples) {
Output("Failed to set video mode. (%s). Re-trying with 16-bit depth buffer and no multisampling\n", SDL_GetError());
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, 0, 16);
ok = CreateWindowAndContext(name.c_str(), vs.width, vs.height, vs.fullscreen, vs.hidden, 0, 16);
}
// 5- abort!

View File

@ -21,7 +21,7 @@ public:
void SwapBuffers();
private:
bool CreateWindowAndContext(const char *name, int w, int h, bool fullscreen, int samples, int depth_bits);
bool CreateWindowAndContext(const char *name, int w, int h, bool fullscreen, bool hidden, int samples, int depth_bits);
SDL_Window *m_window;
SDL_GLContext m_glContext;

View File

@ -123,7 +123,7 @@ start:
options[key] = val;
}
}
Pi::Init(options);
Pi::Init(options, mode == MODE_GALAXYDUMP);
if (mode == MODE_GAME)
for (;;) Pi::Start();
else if (mode == MODE_GALAXYDUMP) {

View File

@ -26,6 +26,7 @@ int main(int argc, char **argv)
videoSettings.width = WIDTH;
videoSettings.height = HEIGHT;
videoSettings.fullscreen = false;
videoSettings.hidden = false;
videoSettings.requestedSamples = 0;
videoSettings.vsync = false;
videoSettings.useTextureCompression = false;

View File

@ -118,6 +118,7 @@ int main(int argc, char **argv)
videoSettings.width = WIDTH;
videoSettings.height = HEIGHT;
videoSettings.fullscreen = false;
videoSettings.hidden = false;
videoSettings.requestedSamples = 0;
videoSettings.vsync = false;
videoSettings.useTextureCompression = false;