// save active virtual buttons (in case of just configuring them)
for (x = 0; x < MAX_GRID_XSIZE; x++)
for (y = 0; y < MAX_GRID_YSIZE; y++)
- overlay.grid_button_all[nr][x][y] = overlay.grid_button[x][y];
+ setup.touch.grid_button[nr][x][y] = overlay.grid_button[x][y];
}
nr = GRID_ACTIVE_NR();
- overlay.grid_xsize = overlay.grid_xsize_all[nr];
- overlay.grid_ysize = overlay.grid_ysize_all[nr];
+ overlay.grid_xsize = setup.touch.grid_xsize[nr];
+ overlay.grid_ysize = setup.touch.grid_ysize[nr];
for (x = 0; x < MAX_GRID_XSIZE; x++)
for (y = 0; y < MAX_GRID_YSIZE; y++)
- overlay.grid_button[x][y] = overlay.grid_button_all[nr][x][y];
+ overlay.grid_button[x][y] = setup.touch.grid_button[nr][x][y];
}
}
}
si->touch.move_distance = TOUCH_MOVE_DISTANCE_DEFAULT; /* percent */
si->touch.drop_distance = TOUCH_DROP_DISTANCE_DEFAULT; /* percent */
+ for (i = 0; i < 2; i++)
+ {
+ char *default_grid_button[6][2] =
+ {
+ { " ", " ^^ " },
+ { " ", " ^^ " },
+ { " ", "<< >>" },
+ { " ", "<< >>" },
+ { "111222", " vv " },
+ { "111222", " vv " }
+ };
+ int grid_xsize = DEFAULT_GRID_XSIZE(i);
+ int grid_ysize = DEFAULT_GRID_YSIZE(i);
+ int min_xsize = MIN(6, grid_xsize);
+ int min_ysize = MIN(6, grid_ysize);
+ int startx = grid_xsize - min_xsize;
+ int starty = grid_ysize - min_ysize;
+ int x, y;
+
+ // virtual buttons grid can only be set to defaults if video is initialized
+ // (this will be repeated if virtual buttons are not loaded from setup file)
+ if (video.initialized)
+ {
+ si->touch.grid_xsize[i] = grid_xsize;
+ si->touch.grid_ysize[i] = grid_ysize;
+ }
+ else
+ {
+ si->touch.grid_xsize[i] = -1;
+ si->touch.grid_ysize[i] = -1;
+ }
+
+ for (x = 0; x < MAX_GRID_XSIZE; x++)
+ for (y = 0; y < MAX_GRID_YSIZE; y++)
+ si->touch.grid_button[i][x][y] = CHAR_GRID_BUTTON_NONE;
+
+ for (x = 0; x < min_xsize; x++)
+ for (y = 0; y < min_ysize; y++)
+ si->touch.grid_button[i][x][starty + y] =
+ default_grid_button[y][0][x];
+
+ for (x = 0; x < min_xsize; x++)
+ for (y = 0; y < min_ysize; y++)
+ si->touch.grid_button[i][startx + x][starty + y] =
+ default_grid_button[y][1][x];
+ }
+
+ si->touch.grid_initialized = video.initialized;
+
si->editor.el_boulderdash = TRUE;
si->editor.el_emerald_mine = TRUE;
si->editor.el_emerald_mine_club = TRUE;
StartMixer();
}
+static void InitVideoOverlay()
+{
+ // if virtual buttons are not loaded from setup file, repeat initializing
+ // virtual buttons grid with default values now that video is initialized
+ if (!setup.touch.grid_initialized)
+ InitSetup();
+
+ InitTileCursorInfo();
+ InitOverlayInfo();
+}
+
void InitGfxBuffers()
{
static int win_xsize_last = -1;
InitVideoDefaults();
InitVideoDisplay();
InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
-
- InitTileCursorInfo();
- InitOverlayInfo();
+ InitVideoOverlay();
print_timestamp_time("[init video stuff]");
void InitOverlayInfo()
{
- static char *default_grid_button[6][2] =
- {
- { " ", " ^^ " },
- { " ", " ^^ " },
- { " ", "<< >>" },
- { " ", "<< >>" },
- { "111222", " vv " },
- { "111222", " vv " }
- };
int nr = GRID_ACTIVE_NR();
- int i, x, y;
+ int x, y;
overlay.enabled = FALSE;
overlay.active = FALSE;
overlay.show_grid = FALSE;
- for (i = 0; i < 2; i++)
- {
- int grid_xsize = DEFAULT_GRID_XSIZE(i);
- int grid_ysize = DEFAULT_GRID_YSIZE(i);
- int min_xsize = MIN(6, grid_xsize);
- int min_ysize = MIN(6, grid_ysize);
- int startx = grid_xsize - min_xsize;
- int starty = grid_ysize - min_ysize;
-
- overlay.grid_xsize_all[i] = grid_xsize;
- overlay.grid_ysize_all[i] = grid_ysize;
-
- for (x = 0; x < MAX_GRID_XSIZE; x++)
- for (y = 0; y < MAX_GRID_YSIZE; y++)
- overlay.grid_button_all[i][x][y] = CHAR_GRID_BUTTON_NONE;
-
- for (x = 0; x < min_xsize; x++)
- for (y = 0; y < min_ysize; y++)
- overlay.grid_button_all[i][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_all[i][startx + x][starty + y] =
- default_grid_button[y][1][x];
- }
-
- overlay.grid_xsize = overlay.grid_xsize_all[nr];
- overlay.grid_ysize = overlay.grid_ysize_all[nr];
+ overlay.grid_xsize = setup.touch.grid_xsize[nr];
+ overlay.grid_ysize = setup.touch.grid_ysize[nr];
for (x = 0; x < MAX_GRID_XSIZE; x++)
for (y = 0; y < MAX_GRID_YSIZE; y++)
- overlay.grid_button[x][y] = overlay.grid_button_all[nr][x][y];
+ overlay.grid_button[x][y] = setup.touch.grid_button[nr][x][y];
overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE;
#define MIN_GRID_YSIZE 3
#define MAX_GRID_XSIZE 32
#define MAX_GRID_YSIZE 32
-#define GRID_REAL_WIDTH MAX(video.screen_width, \
- video.screen_height)
-#define GRID_REAL_HEIGHT MIN(video.screen_width, \
- video.screen_height)
+#define GRID_REAL_WIDTH MAX(1, MAX(video.screen_width, \
+ video.screen_height))
+#define GRID_REAL_HEIGHT MAX(1, MIN(video.screen_width, \
+ video.screen_height))
#define DEFAULT_GRID_XSIZE_0 18
#define DEFAULT_GRID_YSIZE_0 MIN(MAX(MIN_GRID_YSIZE, \
DEFAULT_GRID_XSIZE_0 * \
boolean show_grid;
- int grid_xsize_all[2];
- int grid_ysize_all[2];
int grid_xsize;
int grid_ysize;
- char grid_button_all[2][MAX_GRID_XSIZE][MAX_GRID_YSIZE];
char grid_button[MAX_GRID_XSIZE][MAX_GRID_YSIZE];
char grid_button_highlight;
};
char *control_type;
int move_distance;
int drop_distance;
+
+ int grid_xsize[2];
+ int grid_ysize[2];
+
+ char grid_button[2][MAX_GRID_XSIZE][MAX_GRID_YSIZE];
+
+ boolean grid_initialized;
};
struct SetupInputInfo
for (x = 0; x < MAX_GRID_XSIZE; x++)
for (y = 0; y < MAX_GRID_YSIZE; y++)
- overlay.grid_button_all[nr][x][y] = overlay.grid_button[x][y];
+ setup.touch.grid_button[nr][x][y] = overlay.grid_button[x][y];
overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE;