diff --git a/gamemgr/bggame.cc b/gamemgr/bggame.cc index 99ea0a8cf..d3e916414 100644 --- a/gamemgr/bggame.cc +++ b/gamemgr/bggame.cc @@ -42,6 +42,7 @@ #include "mappatch.h" #include "miscinf.h" #include "modmgr.h" +#include "mouse.h" #include "palette.h" #include "shapeid.h" #include "touchui.h" @@ -2182,6 +2183,13 @@ bool BG_Game::new_game(Vga_file& shapes) { const int menuy = topy + 110; std::shared_ptr font = fontManager.get_font("MENU_FONT"); + IExultDataSource mouse_data(MAINSHP_FLX, PATCH_MAINSHP, 19); + newgame_mouse = new Mouse(gwin, mouse_data); + Mouse::mouse = newgame_mouse; + if (newgame_mouse + && !Mouse::use_touch_input) { // If not primarily touch input + newgame_mouse->show(); // Attempt to make the mouse visible initially + } Vga_file faces_vga; // Need to know if SI is installed const bool si_installed @@ -2242,6 +2250,7 @@ bool BG_Game::new_game(Vga_file& shapes) { do { Delay(); if (redraw) { + Mouse::mouse->hide(); gwin->clear_screen(); sman->paint_shape( topx, topy, shapes.get_shape(0x2, 0), false, @@ -2282,8 +2291,13 @@ bool BG_Game::new_game(Vga_file& shapes) { } font->draw_text( ibuf, topx + 60, menuy + 10, disp_name, transto.data()); + Mouse::mouse->show(); gwin->get_win()->ShowFillGuardBand(); redraw = false; + } else { + if (Mouse::mouse && Mouse::mouse->is_onscreen()) { + gwin->get_win()->ShowFillGuardBand(); + } } SDL_Renderer* renderer = SDL_GetRenderer(gwin->get_win()->get_screen_window()); @@ -2292,6 +2306,18 @@ bool BG_Game::new_game(Vga_file& shapes) { Uint16 keysym_unicode = 0; bool isTextInput = false; SDL_ConvertEventToRenderCoordinates(renderer, &event); + + if (event.type == SDL_EVENT_MOUSE_MOTION) { + int mx ; + int my; + gwin->get_win()->screen_to_game( + event.motion.x, event.motion.y, gwin->get_fastmouse(), mx, my); + Mouse::mouse->hide(); + Mouse::mouse->move(mx, my); + Mouse::mouse_update = true; + Mouse::mouse->show(); + } + if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN || event.type == SDL_EVENT_MOUSE_BUTTON_UP) { const SDL_Rect rectName = {topx + 10, menuy + 10, 130, 16}; diff --git a/gamemgr/bggame.h b/gamemgr/bggame.h index 14938742b..8a4d1439a 100644 --- a/gamemgr/bggame.h +++ b/gamemgr/bggame.h @@ -22,6 +22,7 @@ #include "game.h" struct File_spec; +class Mouse; class BG_Game : public Game { public: @@ -55,6 +56,7 @@ class BG_Game : public Game { void scene_guardian(); void scene_desk(); void scene_moongate(); + Mouse* newgame_mouse; }; #endif