X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsystem.c;h=dea7258d009e5cef1816ed53fd17742a5e98035b;hp=4f90a2d120835da09bda46a89f3877979b700ed5;hb=c9308ba3e7ddea2d7e44b4d98f0dfbb19e18f04f;hpb=cba1a8ce5ba37f1e0a826ce63cf491044573681a diff --git a/src/libgame/system.c b/src/libgame/system.c index 4f90a2d1..dea7258d 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -33,6 +33,7 @@ struct OptionInfo options; struct VideoSystemInfo video; struct AudioSystemInfo audio; struct GfxInfo gfx; +struct TileCursorInfo tile_cursor; struct OverlayInfo overlay; struct ArtworkInfo artwork; struct JoystickInfo joystick; @@ -286,6 +287,11 @@ void InitGfxDrawGlobalBorderFunction(void (*draw_global_border_function)(int)) gfx.draw_global_border_function = draw_global_border_function; } +void InitGfxDrawTileCursorFunction(void (*draw_tile_cursor_function)(int)) +{ + gfx.draw_tile_cursor_function = draw_tile_cursor_function; +} + void InitGfxCustomArtworkInfo() { gfx.override_level_graphics = FALSE; @@ -300,6 +306,19 @@ void InitGfxOtherSettings() gfx.cursor_mode = CURSOR_DEFAULT; } +void InitTileCursorInfo() +{ + tile_cursor.enabled = FALSE; + tile_cursor.active = FALSE; + + tile_cursor.xpos = 0; + tile_cursor.ypos = 0; + tile_cursor.x = 0; + tile_cursor.y = 0; + tile_cursor.target_x = 0; + tile_cursor.target_y = 0; +} + void InitOverlayInfo() { overlay.enabled = FALSE; @@ -311,6 +330,37 @@ void InitOverlayInfo() #endif } +void SetTileCursorEnabled(boolean enabled) +{ + tile_cursor.enabled = enabled; +} + +void SetTileCursorActive(boolean active) +{ + tile_cursor.active = active; +} + +void SetTileCursorTargetXY(int x, int y) +{ + // delayed placement of tile selection cursor at target position + // (tile cursor will be moved to target position step by step) + + tile_cursor.xpos = x; + tile_cursor.ypos = y; + tile_cursor.target_x = gfx.sx + x * gfx.game_tile_size; + tile_cursor.target_y = gfx.sy + y * gfx.game_tile_size; +} + +void SetTileCursorXY(int x, int y) +{ + // immediate placement of tile selection cursor at target position + + SetTileCursorTargetXY(x, y); + + tile_cursor.x = tile_cursor.target_x; + tile_cursor.y = tile_cursor.target_y; +} + void SetOverlayEnabled(boolean enabled) { overlay.enabled = enabled; @@ -421,6 +471,11 @@ void LimitScreenUpdates(boolean enable) SDLLimitScreenUpdates(enable); } +void InitVideoDefaults(void) +{ + video.default_depth = 32; +} + void InitVideoDisplay(void) { if (program.headless) @@ -466,7 +521,7 @@ void InitVideoBuffer(int width, int height, int depth, boolean fullscreen) SDLInitVideoBuffer(fullscreen); - video.initialized = TRUE; + video.initialized = !program.headless; drawto = backbuffer; } @@ -600,6 +655,17 @@ inline static boolean CheckDrawingArea(int x, int y, int width, int height, return FALSE; } +boolean DrawingDeactivatedField() +{ + if (program.headless) + return TRUE; + + if (gfx.draw_deactivation_mask & REDRAW_FIELD) + return TRUE; + + return FALSE; +} + boolean DrawingDeactivated(int x, int y, int width, int height) { return CheckDrawingArea(x, y, width, height, gfx.draw_deactivation_mask); @@ -903,6 +969,9 @@ void DrawLine(Bitmap *bitmap, int from_x, int from_y, { int x, y; + if (program.headless) + return; + for (x = 0; x < line_width; x++) { for (y = 0; y < line_width; y++) @@ -938,6 +1007,9 @@ void DrawLines(Bitmap *bitmap, struct XY *points, int num_points, Pixel pixel) Pixel GetPixel(Bitmap *bitmap, int x, int y) { + if (program.headless) + return BLACK_PIXEL; + if (x < 0 || x >= bitmap->width || y < 0 || y >= bitmap->height) return BLACK_PIXEL; @@ -948,6 +1020,9 @@ Pixel GetPixel(Bitmap *bitmap, int x, int y) Pixel GetPixelFromRGB(Bitmap *bitmap, unsigned int color_r, unsigned int color_g, unsigned int color_b) { + if (program.headless) + return BLACK_PIXEL; + return SDL_MapRGB(bitmap->surface->format, color_r, color_g, color_b); } @@ -1493,9 +1568,9 @@ boolean PendingEvent(void) return (SDL_PollEvent(NULL) ? TRUE : FALSE); } -void NextEvent(Event *event) +void WaitEvent(Event *event) { - SDLNextEvent(event); + SDLWaitEvent(event); } void PeekEvent(Event *event) @@ -1507,6 +1582,12 @@ void PeekEvent(Event *event) #endif } +void CheckQuitEvent(void) +{ + if (SDL_QuitRequested()) + program.exit_function(0); +} + Key GetEventKey(KeyEvent *event, boolean with_modifiers) { #if defined(TARGET_SDL2)