#include "files.h"
#include "init.h"
+#include "screens.h"
#include "tools.h"
#include "tape.h"
#include "config.h"
#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 41
#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 42
#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 43
+#define SETUP_TOKEN_TOUCH_TRANSPARENCY 44
+#define SETUP_TOKEN_TOUCH_DRAW_OUTLINED 45
+#define SETUP_TOKEN_TOUCH_DRAW_PRESSED 46
+#define SETUP_TOKEN_TOUCH_GRID_XSIZE_0 47
+#define SETUP_TOKEN_TOUCH_GRID_YSIZE_0 48
+#define SETUP_TOKEN_TOUCH_GRID_XSIZE_1 49
+#define SETUP_TOKEN_TOUCH_GRID_YSIZE_1 50
-#define NUM_GLOBAL_SETUP_TOKENS 44
+#define NUM_GLOBAL_SETUP_TOKENS 51
/* auto setup */
#define SETUP_TOKEN_AUTO_EDITOR_ZOOM_TILESIZE 0
{ TYPE_STRING, &si.touch.control_type, "touch.control_type" },
{ TYPE_INTEGER,&si.touch.move_distance, "touch.move_distance" },
{ TYPE_INTEGER,&si.touch.drop_distance, "touch.drop_distance" },
+ { TYPE_INTEGER,&si.touch.transparency, "touch.transparency" },
+ { TYPE_INTEGER,&si.touch.draw_outlined, "touch.draw_outlined" },
+ { TYPE_INTEGER,&si.touch.draw_pressed, "touch.draw_pressed" },
+ { TYPE_INTEGER,&si.touch.grid_xsize[0], "touch.virtual_buttons.0.xsize" },
+ { TYPE_INTEGER,&si.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize" },
+ { TYPE_INTEGER,&si.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize" },
+ { TYPE_INTEGER,&si.touch.grid_ysize[1], "touch.virtual_buttons.1.ysize" },
};
static struct TokenInfo auto_setup_tokens[] =
si->touch.control_type = getStringCopy(TOUCH_CONTROL_DEFAULT);
si->touch.move_distance = TOUCH_MOVE_DISTANCE_DEFAULT; /* percent */
si->touch.drop_distance = TOUCH_DROP_DISTANCE_DEFAULT; /* percent */
+ si->touch.transparency = TOUCH_TRANSPARENCY_DEFAULT; /* percent */
+ si->touch.draw_outlined = TRUE;
+ si->touch.draw_pressed = TRUE;
+
+ 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;
return hide_setup_token;
}
-static void setHideSetupEntry(void *setup_value_raw)
+void setHideSetupEntry(void *setup_value)
{
- /* !!! DIRTY WORKAROUND; TO BE FIXED AFTER THE MM ENGINE RELEASE !!! */
- void *setup_value = setup_value_raw - (void *)&si + (void *)&setup;
-
char *hide_setup_token = getHideSetupToken(setup_value);
if (setup_value != NULL)
setHashEntry(hide_setup_hash, hide_setup_token, "");
}
+static void setHideSetupEntryRaw(char *token_text, void *setup_value_raw)
+{
+ /* !!! DIRTY WORKAROUND; TO BE FIXED AFTER THE MM ENGINE RELEASE !!! */
+ void *setup_value = setup_value_raw - (void *)&si + (void *)&setup;
+
+ setHideSetupEntry(setup_value);
+}
+
boolean hideSetupEntry(void *setup_value)
{
char *hide_setup_token = getHideSetupToken(setup_value);
/* check if this setup option should be hidden in the setup menu */
if (token_hide_value != NULL && get_boolean_from_string(token_hide_value))
- setHideSetupEntry(token_info[token_nr].value);
+ setHideSetupEntryRaw(token_text, token_info[token_nr].value);
}
static void setSetupInfoFromTokenInfo(SetupFileHash *setup_file_hash,
setSetupInfoFromTokenInfo(setup_file_hash, global_setup_tokens, i);
setup = si;
+ /* virtual buttons setup */
+ setup.touch.grid_initialized = TRUE;
+ for (i = 0; i < 2; i++)
+ {
+ int grid_xsize = setup.touch.grid_xsize[i];
+ int grid_ysize = setup.touch.grid_ysize[i];
+ int x, y;
+
+ // if virtual buttons are not loaded from setup file, repeat initializing
+ // virtual buttons grid with default values later when video is initialized
+ if (grid_xsize == -1 ||
+ grid_ysize == -1)
+ {
+ setup.touch.grid_initialized = FALSE;
+
+ continue;
+ }
+
+ for (y = 0; y < grid_ysize; y++)
+ {
+ char token_string[MAX_LINE_LEN];
+
+ sprintf(token_string, "touch.virtual_buttons.%d.%02d", i, y);
+
+ char *value_string = getHashEntry(setup_file_hash, token_string);
+
+ if (value_string == NULL)
+ continue;
+
+ for (x = 0; x < grid_xsize; x++)
+ {
+ char c = value_string[x];
+
+ setup.touch.grid_button[i][x][y] =
+ (c == '.' ? CHAR_GRID_BUTTON_NONE : c);
+ }
+ }
+ }
+
/* editor setup */
sei = setup.editor;
for (i = 0; i < NUM_EDITOR_SETUP_TOKENS; i++)
for (i = 0; i < NUM_OPTIONS_SETUP_TOKENS; i++)
setSetupInfoFromTokenInfo(setup_file_hash, options_setup_tokens, i);
setup.options = soi;
+
+ setHideRelatedSetupEntries();
}
static void decodeSetupFileHash_AutoSetup(SetupFileHash *setup_file_hash)
if (i == SETUP_TOKEN_PLAYER_NAME + 1 ||
i == SETUP_TOKEN_GRAPHICS_SET ||
i == SETUP_TOKEN_VOLUME_SIMPLE ||
- i == SETUP_TOKEN_TOUCH_CONTROL_TYPE)
+ i == SETUP_TOKEN_TOUCH_CONTROL_TYPE ||
+ i == SETUP_TOKEN_TOUCH_GRID_XSIZE_0 ||
+ i == SETUP_TOKEN_TOUCH_GRID_XSIZE_1)
fprintf(file, "\n");
fprintf(file, "%s\n", getSetupLine(global_setup_tokens, "", i));
}
+ /* virtual buttons setup */
+ for (i = 0; i < 2; i++)
+ {
+ int grid_xsize = setup.touch.grid_xsize[i];
+ int grid_ysize = setup.touch.grid_ysize[i];
+ int x, y;
+
+ fprintf(file, "\n");
+
+ for (y = 0; y < grid_ysize; y++)
+ {
+ char token_string[MAX_LINE_LEN];
+ char value_string[MAX_LINE_LEN];
+
+ sprintf(token_string, "touch.virtual_buttons.%d.%02d", i, y);
+
+ for (x = 0; x < grid_xsize; x++)
+ {
+ char c = setup.touch.grid_button[i][x][y];
+
+ value_string[x] = (c == CHAR_GRID_BUTTON_NONE ? '.' : c);
+ }
+
+ value_string[grid_xsize] = '\0';
+
+ fprintf(file, "%s\n", getFormattedSetupEntry(token_string, value_string));
+ }
+ }
+
/* editor setup */
sei = setup.editor;
fprintf(file, "\n");