added "passthrough" option for clickable global animations
[rocksndiamonds.git] / src / libgame / system.h
index c645089b6a3e91d49cce74042daa62280a2ee43d..e396a369212db4e87817f1a6f8b7e8d5e063ff80 100644 (file)
 
 #define TOUCH_MOVE_DISTANCE_DEFAULT    2
 #define TOUCH_DROP_DISTANCE_DEFAULT    5
+#define TOUCH_TRANSPARENCY_DEFAULT     50
 
+#define ALPHA_FROM_TRANSPARENCY(x)     ((100 - x) * SDL_ALPHA_OPAQUE / 100)
+#define ALPHA_FADING_STEPSIZE(x)       ((x) / 25)
 
 /* values for special settings for mobile devices */
 #if defined(PLATFORM_ANDROID)
 #define SCREEN_KEYBOARD_POS(h)         ((h) / 2)
 #endif
 
-
 /* default input keys */
 #define DEFAULT_KEY_LEFT               KSYM_Left
 #define DEFAULT_KEY_RIGHT              KSYM_Right
 #define STYLE_INNER_CORNERS    (1 << 1)
 #define STYLE_REVERSE          (1 << 2)
 
+/* values for special event handling style (used for global animation) */
+#define STYLE_PASSTHROUGH      (1 << 3)
+
 #define STYLE_DEFAULT          STYLE_NONE
 
 /* values for special global animation events */
 
 #define ANIM_EVENT_DEFAULT     ANIM_EVENT_NONE
 
+/* values for special global animation event actions */
+#define ANIM_EVENT_ACTION_NONE -1
+
 /* values for fade mode */
 #define FADE_TYPE_NONE         0
 #define FADE_TYPE_FADE_IN      (1 << 0)
 #define MAX_GLOBAL_ANIMS               32
 #define MAX_GLOBAL_ANIM_PARTS          32
 
+/* minimum/maximum/default x/y grid size for virtual buttons */
+#define MIN_GRID_XSIZE                 3
+#define MIN_GRID_YSIZE                 3
+#define MAX_GRID_XSIZE                 32
+#define MAX_GRID_YSIZE                 32
+#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 *  \
+                                               GRID_REAL_HEIGHT /      \
+                                               GRID_REAL_WIDTH),       \
+                                           MAX_GRID_YSIZE)
+#define DEFAULT_GRID_XSIZE_1           13
+#define DEFAULT_GRID_YSIZE_1           MIN(MAX(MIN_GRID_YSIZE,         \
+                                               DEFAULT_GRID_XSIZE_1 *  \
+                                               GRID_REAL_WIDTH /       \
+                                               GRID_REAL_HEIGHT),      \
+                                           MAX_GRID_YSIZE)
+
+#define DEFAULT_GRID_XSIZE(n)          ((n) == 0 ? DEFAULT_GRID_XSIZE_0 : \
+                                        DEFAULT_GRID_XSIZE_1)
+#define DEFAULT_GRID_YSIZE(n)          ((n) == 0 ? DEFAULT_GRID_YSIZE_0 : \
+                                        DEFAULT_GRID_YSIZE_1)
+
+#define GRID_ACTIVE_NR()               (video.screen_width >   \
+                                        video.screen_height ? 0 : 1)
+
+/* values for grid button characters for virtual buttons */
+#define CHAR_GRID_BUTTON_NONE          ' '
+#define CHAR_GRID_BUTTON_LEFT          '<'
+#define CHAR_GRID_BUTTON_RIGHT         '>'
+#define CHAR_GRID_BUTTON_UP            '^'
+#define CHAR_GRID_BUTTON_DOWN          'v'
+#define CHAR_GRID_BUTTON_SNAP          '1'
+#define CHAR_GRID_BUTTON_DROP          '2'
+
+#define GET_ACTION_FROM_GRID_BUTTON(c) ((c) == CHAR_GRID_BUTTON_LEFT ?  \
+                                        JOY_LEFT :                      \
+                                        (c) == CHAR_GRID_BUTTON_RIGHT ? \
+                                        JOY_RIGHT :                     \
+                                        (c) == CHAR_GRID_BUTTON_UP ?    \
+                                        JOY_UP :                        \
+                                        (c) == CHAR_GRID_BUTTON_DOWN ?  \
+                                        JOY_DOWN :                      \
+                                        (c) == CHAR_GRID_BUTTON_SNAP ?  \
+                                        JOY_BUTTON_1 :                  \
+                                        (c) == CHAR_GRID_BUTTON_DROP ?  \
+                                        JOY_BUTTON_2 :                  \
+                                        JOY_NO_ACTION)
+
 /* default name for empty highscore entry */
 #define EMPTY_PLAYER_NAME      "no name"
 
@@ -976,6 +1037,16 @@ struct OverlayInfo
 {
   boolean enabled;             /* overlay generally enabled or disabled */
   boolean active;              /* overlay activated (depending on game mode) */
+
+  boolean show_grid;
+
+  int grid_xsize;
+  int grid_ysize;
+
+  char grid_button[MAX_GRID_XSIZE][MAX_GRID_YSIZE];
+  char grid_button_highlight;
+
+  int grid_button_action;
 };
 
 struct JoystickInfo
@@ -1004,6 +1075,17 @@ struct SetupTouchInfo
   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];
+
+  int transparency;            /* in percent (0 == opaque, 100 == invisible) */
+  boolean draw_outlined;
+  boolean draw_pressed;
+
+  boolean grid_initialized;
 };
 
 struct SetupInputInfo
@@ -1544,6 +1626,7 @@ void SetTileCursorXY(int, int);
 void SetTileCursorSXSY(int, int);
 void SetOverlayEnabled(boolean);
 void SetOverlayActive(boolean);
+void SetOverlayShowGrid(boolean);
 boolean GetOverlayActive();
 void SetDrawDeactivationMask(int);
 int GetDrawDeactivationMask(void);