* Starts up SDL with all the subsystems and SDL_mixer for audio processing, * creates the display screen and sets up the cursor. * @param title Title of the game window. */
| 51 | * @param title Title of the game window. |
| 52 | */ |
| 53 | Game::Game(const std::string &title) : _screen(0), _cursor(0), _lang(0), _states(), _deleted(), _res(0), _save(0), _rules(0), _quit(false), _init(false), _mouseActive(true), _timeUntilNextFrame(0) |
| 54 | { |
| 55 | Options::reload = false; |
| 56 | Options::mute = false; |
| 57 | |
| 58 | // Initialize SDL |
| 59 | if (SDL_Init(SDL_INIT_VIDEO) < 0) |
| 60 | { |
| 61 | throw Exception(SDL_GetError()); |
| 62 | } |
| 63 | Log(LOG_INFO) << "SDL initialized successfully."; |
| 64 | |
| 65 | // Initialize SDL_mixer |
| 66 | if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) |
| 67 | { |
| 68 | Log(LOG_ERROR) << SDL_GetError(); |
| 69 | Log(LOG_WARNING) << "No sound device detected, audio disabled."; |
| 70 | Options::mute = true; |
| 71 | } |
| 72 | else |
| 73 | { |
| 74 | initAudio(); |
| 75 | } |
| 76 | |
| 77 | // trap the mouse inside the window |
| 78 | SDL_WM_GrabInput(Options::captureMouse); |
| 79 | |
| 80 | // Set the window icon |
| 81 | CrossPlatform::setWindowIcon(103, "openxcom.png"); |
| 82 | |
| 83 | // Set the window caption |
| 84 | SDL_WM_SetCaption(title.c_str(), 0); |
| 85 | |
| 86 | SDL_EnableUNICODE(1); |
| 87 | |
| 88 | // Create display |
| 89 | _screen = new Screen(); |
| 90 | |
| 91 | // Create cursor |
| 92 | _cursor = new Cursor(9, 13); |
| 93 | _cursor->setColor(Palette::blockOffset(15)+12); |
| 94 | |
| 95 | // Create invisible hardware cursor to workaround bug with absolute positioning pointing devices |
| 96 | SDL_ShowCursor(SDL_ENABLE); |
| 97 | Uint8 cursor = 0; |
| 98 | SDL_SetCursor(SDL_CreateCursor(&cursor, &cursor, 1,1,0,0)); |
| 99 | |
| 100 | // Create fps counter |
| 101 | _fpsCounter = new FpsCounter(15, 5, 0, 0); |
| 102 | |
| 103 | // Create blank language |
| 104 | _lang = new Language(); |
| 105 | |
| 106 | _timeOfLastFrame = 0; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Deletes the display screen, cursor, states and shuts down all the SDL subsystems. |
nothing calls this directly
no test coverage detected