automake upgrade
[gdash.git] / src / mainwindow.cpp
blob5f8859028d0755eec7768f035cc8668ee6815538
1 /*
2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
19 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include <glib.h>
26 #include "gtk/gtkmainwindow.hpp"
27 #include "sdl/sdlmainwindow.hpp"
28 #include "misc/logger.hpp"
29 #include "misc/printf.hpp"
30 #include "mainwindow.hpp"
31 #include "settings.hpp"
33 /* The should be in the same order as the enum. */
34 const char *gd_graphics_engine_names[] = {
35 #ifdef HAVE_GTK
36 "GTK+",
37 #endif
38 #ifdef HAVE_SDL
39 "SDL",
40 "OpenGL",
41 #endif
42 NULL
45 void main_window_run_title_screen(CaveSet *caveset, NextAction &na) {
46 /* if some unknown engine, switch to default */
47 if (gd_graphics_engine >= GRAPHICS_ENGINE_MAX)
48 gd_graphics_engine = GraphicsEngine(0);
50 try {
51 switch (GraphicsEngine(gd_graphics_engine)) {
52 #ifdef HAVE_GTK
53 case GRAPHICS_ENGINE_GTK:
54 gd_main_window_gtk_run(caveset, na);
55 break;
56 #endif
57 #ifdef HAVE_SDL
58 case GRAPHICS_ENGINE_SDL:
59 gd_main_window_sdl_run(caveset, na, false);
60 break;
61 case GRAPHICS_ENGINE_OPENGL:
62 gd_main_window_sdl_run(caveset, na, true);
63 break;
64 #endif
65 case GRAPHICS_ENGINE_MAX:
66 g_assert_not_reached();
67 break;
69 } catch (ScreenConfigureException const & ex) {
70 gd_warning(CPrintf("Screen error: %s. Switching to default graphics engine.") % ex.what());
71 gd_graphics_engine = 0;
75 void main_window_run_a_game(GameControl *game) {
76 /* if some unknown engine, switch to default */
77 if (gd_graphics_engine >= GRAPHICS_ENGINE_MAX)
78 gd_graphics_engine = GraphicsEngine(0);
80 try {
81 switch (GraphicsEngine(gd_graphics_engine)) {
82 #ifdef HAVE_GTK
83 case GRAPHICS_ENGINE_GTK:
84 gd_main_window_gtk_run_a_game(game);
85 break;
86 #endif
87 #ifdef HAVE_SDL
88 case GRAPHICS_ENGINE_SDL:
89 gd_main_window_sdl_run_a_game(game, false);
90 break;
91 case GRAPHICS_ENGINE_OPENGL:
92 gd_main_window_sdl_run_a_game(game, true);
93 break;
94 #endif
95 case GRAPHICS_ENGINE_MAX:
96 g_assert_not_reached();
97 break;
99 } catch (ScreenConfigureException const & ex) {
100 gd_warning(CPrintf("Screen error: %s. Switching to default graphics engine.") % ex.what());
101 gd_graphics_engine = 0;