X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsystem.c;h=33246588592ebf6dab8b5da904fb314f9bd97492;hb=969000b44b047ef2d77619bd3882a3f09eb1787d;hp=6f063d1c01b0d79df41f2989b8d4dec35bae12a0;hpb=727d3b5fc7cac6f59652eaa23f1ed9e991ae50bd;p=rocksndiamonds.git diff --git a/src/libgame/system.c b/src/libgame/system.c index 6f063d1c..33246588 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; @@ -86,10 +87,10 @@ void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir, program.cookie_prefix = cookie_prefix; + program.version_super = VERSION_SUPER(program_version); program.version_major = VERSION_MAJOR(program_version); program.version_minor = VERSION_MINOR(program_version); program.version_patch = VERSION_PATCH(program_version); - program.version_build = VERSION_BUILD(program_version); program.version_ident = program_version; program.version_string = program_version_string; @@ -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,17 +306,116 @@ void InitGfxOtherSettings() gfx.cursor_mode = CURSOR_DEFAULT; } +void InitTileCursorInfo() +{ + tile_cursor.enabled = FALSE; + tile_cursor.active = FALSE; + tile_cursor.moving = 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; + + tile_cursor.sx = 0; + tile_cursor.sy = 0; +} + void InitOverlayInfo() { + static char *default_grid_button[6][2] = + { + { " ", " ^^ " }, + { " ", " ^^ " }, + { " ", "<< >>" }, + { " ", "<< >>" }, + { "111222", " vv " }, + { "111222", " vv " } + }; + int min_xsize, min_ysize; + int startx, starty; + int x, y; + + min_xsize = MIN(6, DEFAULT_GRID_XSIZE); + min_ysize = MIN(6, DEFAULT_GRID_YSIZE); + + startx = DEFAULT_GRID_XSIZE - min_xsize; + starty = DEFAULT_GRID_YSIZE - min_ysize; + overlay.enabled = FALSE; overlay.active = FALSE; + overlay.show_grid = FALSE; + overlay.show_grid_buttons = FALSE; + + overlay.grid_xsize = DEFAULT_GRID_XSIZE; + overlay.grid_ysize = DEFAULT_GRID_YSIZE; + + for (x = 0; x < MAX_GRID_XSIZE; x++) + for (y = 0; y < MAX_GRID_YSIZE; y++) + overlay.grid_button[x][y] = CHAR_GRID_BUTTON_NONE; + + for (x = 0; x < min_xsize; x++) + for (y = 0; y < min_ysize; y++) + overlay.grid_button[x][starty + y] = + default_grid_button[y][0][x]; + + for (x = 0; x < min_xsize; x++) + for (y = 0; y < min_ysize; y++) + overlay.grid_button[startx + x][starty + y] = + default_grid_button[y][1][x]; + + overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE; + #if defined(PLATFORM_ANDROID) if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS)) overlay.enabled = TRUE; #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 = tile_cursor.sx + x * gfx.game_tile_size; + tile_cursor.target_y = tile_cursor.sy + y * gfx.game_tile_size; + + tile_cursor.moving = TRUE; +} + +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; + + tile_cursor.moving = FALSE; +} + +void SetTileCursorSXSY(int sx, int sy) +{ + tile_cursor.sx = sx; + tile_cursor.sy = sy; +} + void SetOverlayEnabled(boolean enabled) { overlay.enabled = enabled; @@ -321,6 +426,17 @@ void SetOverlayActive(boolean active) overlay.active = active; } +void SetOverlayShowGrid(boolean show_grid) +{ + overlay.show_grid = show_grid; + overlay.show_grid_buttons = show_grid; + + SetOverlayActive(show_grid); + + if (show_grid) + SetOverlayEnabled(TRUE); +} + boolean GetOverlayActive() { return overlay.active; @@ -421,6 +537,11 @@ void LimitScreenUpdates(boolean enable) SDLLimitScreenUpdates(enable); } +void InitVideoDefaults(void) +{ + video.default_depth = 32; +} + void InitVideoDisplay(void) { if (program.headless) @@ -466,7 +587,7 @@ void InitVideoBuffer(int width, int height, int depth, boolean fullscreen) SDLInitVideoBuffer(fullscreen); - video.initialized = TRUE; + video.initialized = !program.headless; drawto = backbuffer; } @@ -914,6 +1035,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++) @@ -949,6 +1073,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; @@ -959,6 +1086,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); }