added tile selection cursor for playing MM levels with keyboard or joystick
[rocksndiamonds.git] / src / libgame / system.h
index 40a1a5d18ad4375bf397d596a4450078b4f08323..a2226a78d8228e9b5229a43618122060eb734a7b 100644 (file)
 #endif
 
 /* values for touch control */
+#define TOUCH_CONTROL_OFF              "off"
 #define TOUCH_CONTROL_VIRTUAL_BUTTONS  "virtual_buttons"
 #define TOUCH_CONTROL_WIPE_GESTURES    "wipe_gestures"
 #define TOUCH_CONTROL_FOLLOW_FINGER    "follow_finger"
 
+#if defined(PLATFORM_ANDROID)
 #define TOUCH_CONTROL_DEFAULT          TOUCH_CONTROL_VIRTUAL_BUTTONS
+#else
+#define TOUCH_CONTROL_DEFAULT          TOUCH_CONTROL_OFF
+#endif
 
 #define TOUCH_MOVE_DISTANCE_DEFAULT    2
 #define TOUCH_DROP_DISTANCE_DEFAULT    5
 #define STYLE_NONE             0
 #define STYLE_ACCURATE_BORDERS (1 << 0)
 #define STYLE_INNER_CORNERS    (1 << 1)
+#define STYLE_REVERSE          (1 << 2)
 
 #define STYLE_DEFAULT          STYLE_NONE
 
+/* values for special global animation events */
 #define ANIM_EVENT_NONE                0
-#define ANIM_EVENT_CLICK_ANIM_1        (1 << 0)
-#define ANIM_EVENT_CLICK_ANIM_2        (1 << 1)
-#define ANIM_EVENT_CLICK_ANIM_3        (1 << 2)
-#define ANIM_EVENT_CLICK_ANIM_4        (1 << 3)
-#define ANIM_EVENT_CLICK_ANIM_5        (1 << 4)
-#define ANIM_EVENT_CLICK_ANIM_6        (1 << 5)
-#define ANIM_EVENT_CLICK_ANIM_7        (1 << 6)
-#define ANIM_EVENT_CLICK_ANIM_8        (1 << 7)
-#define ANIM_EVENT_CLICK_PART_1        (1 << 8)
-#define ANIM_EVENT_CLICK_PART_2        (1 << 9)
-#define ANIM_EVENT_CLICK_PART_3        (1 << 10)
-#define ANIM_EVENT_CLICK_PART_4        (1 << 11)
-#define ANIM_EVENT_CLICK_PART_5        (1 << 12)
-#define ANIM_EVENT_CLICK_PART_6        (1 << 13)
-#define ANIM_EVENT_CLICK_PART_7        (1 << 14)
-#define ANIM_EVENT_CLICK_PART_8        (1 << 15)
-#define ANIM_EVENT_CLICK_SELF  (1 << 16)
-#define ANIM_EVENT_CLICK_ANY   (1 << 17)
-
-#define ANIM_EVENT_CLICK_ANIM_ALL      (ANIM_EVENT_CLICK_ANIM_1 |      \
-                                         ANIM_EVENT_CLICK_ANIM_2 |     \
-                                         ANIM_EVENT_CLICK_ANIM_3 |     \
-                                         ANIM_EVENT_CLICK_ANIM_4 |     \
-                                         ANIM_EVENT_CLICK_ANIM_5 |     \
-                                         ANIM_EVENT_CLICK_ANIM_6 |     \
-                                         ANIM_EVENT_CLICK_ANIM_7 |     \
-                                         ANIM_EVENT_CLICK_ANIM_8)
-
-#define ANIM_EVENT_CLICK_PART_ALL      (ANIM_EVENT_CLICK_PART_1 |      \
-                                         ANIM_EVENT_CLICK_PART_2 |     \
-                                         ANIM_EVENT_CLICK_PART_3 |     \
-                                         ANIM_EVENT_CLICK_PART_4 |     \
-                                         ANIM_EVENT_CLICK_PART_5 |     \
-                                         ANIM_EVENT_CLICK_PART_6 |     \
-                                         ANIM_EVENT_CLICK_PART_7 |     \
-                                         ANIM_EVENT_CLICK_PART_8)
+#define ANIM_EVENT_SELF                (1 << 16)
+#define ANIM_EVENT_ANY         (1 << 17)
+
+#define ANIM_EVENT_ANIM_BIT    0
+#define ANIM_EVENT_PART_BIT    8
+
+#define ANIM_EVENT_ANIM_MASK   (0xff << ANIM_EVENT_ANIM_BIT)
+#define ANIM_EVENT_PART_MASK   (0xff << ANIM_EVENT_PART_BIT)
 
 #define ANIM_EVENT_DEFAULT     ANIM_EVENT_NONE
 
 /* maximum number of levels in a level set */
 #define MAX_LEVELS             1000
 
+/* maximum number of global animation and parts */
+#define MAX_GLOBAL_ANIMS               32
+#define MAX_GLOBAL_ANIM_PARTS          32
+
 /* default name for empty highscore entry */
 #define EMPTY_PLAYER_NAME      "no name"
 
 #define SCORES_DIRECTORY       "scores"
 #define DOCS_DIRECTORY         "docs"
 #define CACHE_DIRECTORY                "cache"
+#define CONF_DIRECTORY         "conf"
 
 #define GFX_CLASSIC_SUBDIR     "gfx_classic"
 #define SND_CLASSIC_SUBDIR     "snd_classic"
 /* file names and filename extensions */
 #define LEVELSETUP_DIRECTORY   "levelsetup"
 #define SETUP_FILENAME         "setup.conf"
+#define AUTOSETUP_FILENAME     "autosetup.conf"
 #define LEVELSETUP_FILENAME    "levelsetup.conf"
 #define EDITORSETUP_FILENAME   "editorsetup.conf"
 #define EDITORCASCADE_FILENAME "editorcascade.conf"
 #define TAPEFILE_EXTENSION     "tape"
 #define SCOREFILE_EXTENSION    "score"
 
+#define GAMECONTROLLER_BASENAME        "gamecontrollerdb.txt"
+
 #define LOG_OUT_BASENAME       "stdout.txt"
 #define LOG_ERR_BASENAME       "stderr.txt"
 
@@ -799,6 +786,8 @@ struct ProgramInfo
   int version_build;
   int version_ident;
 
+  char *version_string;
+
   char *(*window_title_function)(void);
   void (*exit_message_function)(char *, va_list);
   void (*exit_function)(int);
@@ -821,6 +810,7 @@ struct OptionInfo
   char *sounds_directory;
   char *music_directory;
   char *docs_directory;
+  char *conf_directory;
 
   char *execute_command;
 
@@ -886,8 +876,11 @@ struct FontBitmapInfo
 {
   Bitmap *bitmap;
 
-  int src_x, src_y;            /* start position of animation frames */
-  int width, height;           /* width/height of each animation frame */
+  int src_x, src_y;            /* start position of font characters */
+  int width, height;           /* width / height of font characters */
+
+  int offset_x;                        /* offset to next font character */
+  int offset_y;                        /* offset to next font character */
 
   int draw_xoffset;            /* offset for drawing font characters */
   int draw_yoffset;            /* offset for drawing font characters */
@@ -956,19 +949,31 @@ struct GfxInfo
   void (*draw_busy_anim_function)(void);
   void (*draw_global_anim_function)(int, int);
   void (*draw_global_border_function)(int);
+  void (*draw_tile_cursor_function)(int);
 
   int cursor_mode;
 };
 
+struct TileCursorInfo
+{
+  boolean enabled;             /* tile cursor generally enabled or disabled */
+  boolean active;              /* tile cursor activated (depending on game) */
+
+  int xpos, ypos;              /* tile cursor level playfield position */
+  int x, y;                    /* tile cursor current screen position */
+  int target_x, target_y;      /* tile cursor target screen position */
+};
+
 struct OverlayInfo
 {
-  boolean active;
+  boolean enabled;             /* overlay generally enabled or disabled */
+  boolean active;              /* overlay activated (depending on game mode) */
 };
 
 struct JoystickInfo
 {
   int status;
-  int fd[MAX_PLAYERS];         /* file descriptor of player's joystick */
+  int nr[MAX_PLAYERS];         /* joystick number for each player */
 };
 
 struct SetupJoystickInfo
@@ -1010,6 +1015,10 @@ struct SetupEditorInfo
   boolean el_supaplex;
   boolean el_diamond_caves;
   boolean el_dx_boulderdash;
+
+  boolean el_mirror_magic;
+  boolean el_deflektor;
+
   boolean el_chars;
   boolean el_steel_chars;
 
@@ -1028,6 +1037,11 @@ struct SetupEditorInfo
   boolean use_template_for_new_levels;
 };
 
+struct SetupAutoSetupInfo
+{
+  int editor_zoom_tilesize;
+};
+
 struct SetupEditorCascadeInfo
 {
   boolean el_bd;
@@ -1038,6 +1052,8 @@ struct SetupEditorCascadeInfo
   boolean el_sp;
   boolean el_dc;
   boolean el_dx;
+  boolean el_mm;
+  boolean el_df;
   boolean el_chars;
   boolean el_steel_chars;
   boolean el_ce;
@@ -1083,6 +1099,7 @@ struct SetupSystemInfo
 struct SetupInternalInfo
 {
   char *program_title;
+  char *program_version;
   char *program_author;
   char *program_email;
   char *program_website;
@@ -1105,6 +1122,7 @@ struct SetupInternalInfo
   int default_window_height;
 
   boolean choose_from_top_leveldir;
+  boolean show_scaling_in_title;
 };
 
 struct SetupDebugInfo
@@ -1113,6 +1131,7 @@ struct SetupDebugInfo
   Key frame_delay_key[10];
   boolean frame_delay_use_mod_key;
   boolean frame_delay_game_only;
+  boolean show_frames_per_second;
 };
 
 struct SetupInfo
@@ -1162,6 +1181,7 @@ struct SetupInfo
   int volume_loops;
   int volume_music;
 
+  struct SetupAutoSetupInfo auto_setup;
   struct SetupEditorInfo editor;
   struct SetupEditorCascadeInfo editor_cascade;
   struct SetupShortcutInfo shortcut;
@@ -1196,6 +1216,11 @@ struct TreeInfo
   char *name_sorting;  /* optional sorting name for correct name sorting */
   char *author;                /* level or artwork author name */
   char *year;          /* optional year of creation for levels or artwork */
+
+  char *program_title;    /* optional alternative text for program title */
+  char *program_copyright; /* optional alternative text for program copyright */
+  char *program_company;   /* optional alternative text for program company */
+
   char *imported_from; /* optional comment for imported levels or artwork */
   char *imported_by;   /* optional comment for imported levels or artwork */
   char *tested_by;     /* optional comment to name people who tested a set */
@@ -1415,6 +1440,16 @@ struct TextPosInfo
   boolean draw_player;         /* special case for network player buttons */
   int sort_priority;           /* also used for suffix ".draw_order" */
   int id;
+
+  int direction;               /* needed for panel time/health graphics */
+  int class;                   /* needed for panel time/health graphics */
+  int style;                   /* needed for panel time/health graphics */
+};
+
+struct MouseActionInfo
+{
+  int lx, ly;
+  int button;
 };
 
 struct LevelStats
@@ -1433,6 +1468,7 @@ extern struct OptionInfo  options;
 extern struct VideoSystemInfo  video;
 extern struct AudioSystemInfo  audio;
 extern struct GfxInfo          gfx;
+extern struct TileCursorInfo   tile_cursor;
 extern struct OverlayInfo      overlay;
 extern struct AnimInfo         anim;
 extern struct ArtworkInfo      artwork;
@@ -1465,7 +1501,7 @@ extern int                        FrameCounter;
 /* function definitions */
 
 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
-                    int);
+                    char *, int);
 
 void InitScoresInfo();
 void SetWindowTitle();
@@ -1487,12 +1523,20 @@ void InitGfxClipRegion(boolean, int, int, int, int);
 void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void));
 void InitGfxDrawGlobalAnimFunction(void (*draw_global_anim_function)(int, int));
 void InitGfxDrawGlobalBorderFunction(void (*draw_global_border_function)(int));
+void InitGfxDrawTileCursorFunction(void (*draw_tile_cursor_function)(int));
 void InitGfxCustomArtworkInfo();
 void InitGfxOtherSettings();
+void InitTileCursorInfo();
 void InitOverlayInfo();
+void SetTileCursorEnabled(boolean);
+void SetTileCursorActive(boolean);
+void SetTileCursorTargetXY(int, int);
+void SetTileCursorXY(int, int);
+void SetOverlayEnabled(boolean);
 void SetOverlayActive(boolean);
 boolean GetOverlayActive();
 void SetDrawDeactivationMask(int);
+int GetDrawDeactivationMask(void);
 void SetDrawBackgroundMask(int);
 void SetWindowBackgroundBitmap(Bitmap *);
 void SetMainBackgroundBitmap(Bitmap *);
@@ -1501,6 +1545,7 @@ void SetRedrawMaskFromArea(int, int, int, int);
 
 void LimitScreenUpdates(boolean);
 
+void InitVideoDefaults(void);
 void InitVideoDisplay(void);
 void CloseVideoDisplay(void);
 void InitVideoBuffer(int, int, int, boolean);
@@ -1516,6 +1561,7 @@ void FillRectangle(Bitmap *, int, int, int, int, Pixel);
 void ClearRectangle(Bitmap *, int, int, int, int);
 void ClearRectangleOnBackground(Bitmap *, int, int, int, int);
 void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int);
+boolean DrawingDeactivatedField(void);
 boolean DrawingDeactivated(int, int, int, int);
 boolean DrawingOnBackground(int, int);
 boolean DrawingAreaChanged();
@@ -1555,8 +1601,9 @@ void CloseAudio(void);
 void SetAudioMode(boolean);
 
 boolean PendingEvent(void);
-void NextEvent(Event *event);
+void WaitEvent(Event *event);
 void PeekEvent(Event *event);
+void CheckQuitEvent(void);
 Key GetEventKey(KeyEvent *, boolean);
 KeyMod HandleKeyModState(Key, int);
 KeyMod GetKeyModState();
@@ -1567,5 +1614,7 @@ boolean CheckCloseWindowEvent(ClientMessageEvent *);
 
 void InitJoysticks();
 boolean ReadJoystick(int, int *, int *, boolean *, boolean *);
+boolean CheckJoystickOpened(int);
+void ClearJoystickState();
 
 #endif /* SYSTEM_H */