iphone_wolf.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /*
  2. Copyright (C) 2009 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // define this to get only the first episode on selections, and the
  16. // automatic sell screen at the end of episode 1
  17. #define EPISODE_ONE_ONLY
  18. // this is the version number displayed on the menu screen
  19. #define DOOM_IPHONE_VERSION 0.1
  20. // if defined, the game runs in a separate thread from the app event loop
  21. #define USE_GAME_THREAD
  22. typedef enum menuState {
  23. IPM_GAME,
  24. IPM_MAIN,
  25. IPM_MAPS,
  26. IPM_MULTIPLAYER,
  27. IPM_MASTER,
  28. IPM_CONTROLS,
  29. IPM_OPTIONS,
  30. IPM_HUDEDIT
  31. } menuState_t;
  32. extern menuState_t menuState;
  33. void iphoneDrawMenus();
  34. #define VID_WIDTH 480
  35. #define VID_HEIGHT 320
  36. #define MAX_SKILLS 5
  37. #define MAX_MAPS 200
  38. #define MF_TRIED 1
  39. #define MF_COMPLETED 2
  40. #define MF_KILLS 4
  41. #define MF_SECRETS 8
  42. #define MF_TREASURE 16
  43. #define MF_TIME 32
  44. // we want to track mapStats for downloaded content, so we
  45. // won't have a known number of these
  46. typedef struct {
  47. int dataset;
  48. int episode;
  49. int map;
  50. int completionFlags[MAX_SKILLS];
  51. } mapStats_t;
  52. // this structure is saved out at the head of the binary save file,
  53. // and allows all the menus to work without having to load a game save
  54. typedef struct {
  55. int version;
  56. int episode;
  57. int map;
  58. int skill;
  59. int mapsStarted; // when 0, resume game will just be a new game
  60. // if someone downloads more than MAX_MAPS, they won't get stat tracking on them.
  61. int numMapStats;
  62. mapStats_t mapStats[MAX_MAPS];
  63. } currentMap_t;
  64. extern currentMap_t currentMap;
  65. extern boolean levelHasBeenLoaded; // determines if "resume game" does a loadGame and exiting does a saveGame
  66. extern pkTexture_t *fontTexture;
  67. extern pkTexture_t *numberPics[10];
  68. extern int iphoneFrameNum;
  69. extern int levelLoadFrameNum;
  70. extern int consoleActive;
  71. extern cvar_t *skill;
  72. extern cvar_t *episode;
  73. extern cvar_t *controlScheme;
  74. extern cvar_t *stickMove;
  75. extern cvar_t *stickTurn;
  76. extern cvar_t *rotorTurn;
  77. extern cvar_t *stickDeadBand;
  78. extern cvar_t *tiltTurn;
  79. extern cvar_t *tiltMove;
  80. extern cvar_t *tiltDeadBand;
  81. extern cvar_t *tiltAverages;
  82. extern cvar_t *music;
  83. extern cvar_t *showTilt;
  84. extern cvar_t *showTime;
  85. extern cvar_t *cropSprites;
  86. extern cvar_t *revLand;
  87. extern cvar_t *mapScale;
  88. extern cvar_t *hideControls;
  89. extern cvar_t *tapFire;
  90. extern cvar_t *skipSleep;
  91. extern cvar_t *autoUse;
  92. extern cvar_t *statusBar;
  93. extern cvar_t *touchClick;
  94. extern int numTouches;
  95. extern int touches[5][2]; // [0] = x, [1] = y in landscape mode, raster order with y = 0 at top
  96. // so we can detect button releases
  97. extern int numPrevTouches;
  98. extern int prevTouches[5][2];
  99. extern float tilt; // -1.0 to 1.0
  100. extern float tiltPitch;
  101. extern boolean drawWeaponSelect; // true when the weapon select overlay is up
  102. extern int weaponSelected; // -1 for no change
  103. typedef unsigned char color4_t[4];
  104. typedef unsigned char color3_t[3];
  105. typedef struct {
  106. int enterFrame;
  107. int beforeSwap;
  108. int afterSwap;
  109. int afterSleep;
  110. } logTime_t;
  111. #define MAX_LOGGED_TIMES 512
  112. extern logTime_t loggedTimes[MAX_LOGGED_TIMES]; // indexed by iphoneFrameNum
  113. void LoadWallTexture( int wallPicNum );
  114. int TouchDown( int x, int y, int w, int h );
  115. int TouchReleased( int x, int y, int w, int h );
  116. int iphoneDrawText( int x, int y, const char *str );
  117. int iphoneCenterText( int x, int y, const char *str );
  118. void iphoneDrawNumber( int x, int y, int number, int charWidth, int charHeight );
  119. void iphoneDrawPic( int x, int y, int w, int h, const char *pic );
  120. int iphoneDrawPicWithTouch( int x, int y, int w, int h, const char *pic );
  121. void StartGame();
  122. void iphoneOpenAutomap();
  123. void iphoneDrawNotifyText();
  124. void iphoneSet2D( void );
  125. bool TextButton( const char *title, int x, int y, int w, int h );
  126. void R_Draw_Fill( int x, int y, int w, int h, color3_t c );
  127. void R_Draw_Blend( int x, int y, int w, int h, color4_t c );
  128. void InitImmediateModeGL();
  129. int iphoneRotateForLandscape();
  130. void iphoneCheckForLandscapeReverse();
  131. void iphonePacifierUpdate();
  132. void iphoneDrawScreen();
  133. extern int damageflash;
  134. extern int bonusFrameNum;
  135. extern int attackDirTime[2];
  136. #define HF_DISABLED 1
  137. #define HF_NODRAW 2 // invisible button
  138. typedef struct {
  139. int x, y; // mdpoint
  140. int drawWidth, drawHeight;
  141. int touchWidth, touchHeight; // allow touches outside the actual bounds
  142. pkTexture_t *texture;
  143. boolean drawAsLimit; // draw with red tint to show further movement won't do anything
  144. float touchState;
  145. float drawState; // offsets for rotors
  146. int hudFlags;
  147. struct touch_s *touch;
  148. } hudPic_t;
  149. typedef struct {
  150. hudPic_t forwardStick;
  151. hudPic_t sideStick;
  152. hudPic_t turnStick;
  153. hudPic_t turnRotor;
  154. hudPic_t fire;
  155. hudPic_t menu;
  156. hudPic_t map;
  157. hudPic_t weaponSelect;
  158. } hud_t;
  159. extern hud_t huds;
  160. void HudSetForScheme( int schemeNum );
  161. void HudSetTexnums();
  162. void HudEditFrame();
  163. void Sound_StartLocalSound( const char *sound );
  164. void Sound_StartLocalSoundAtVolume( const char *sound, float volume );
  165. int BackButton();
  166. void ResumeGame();
  167. //---------------------------------------
  168. // Touch and button
  169. //---------------------------------------
  170. typedef struct touch_s {
  171. boolean down;
  172. int x, y;
  173. int prevX, prevY; // will be set to x, y on first touch, copied after each game frame
  174. int stateCount; // set to 1 on first event that state changes, incremented each game frame
  175. void *controlOwner;
  176. void *identification;
  177. } touch_t;
  178. #define MAX_TOUCHES 5
  179. extern touch_t sysTouches[MAX_TOUCHES];
  180. extern touch_t gameTouches[MAX_TOUCHES];
  181. extern pthread_mutex_t eventMutex; // used to sync between game and event threads
  182. touch_t *TapInBounds( int x, int y, int w, int h );
  183. touch_t *TouchInBounds( int x, int y, int w, int h );
  184. touch_t *UpdateHudTouch( hudPic_t *hud );
  185. typedef struct {
  186. pkTexture_t *texture;
  187. const char *title;
  188. int x, y, w, h;
  189. touch_t *touch;
  190. float scale; // ramps up and down after touches
  191. int frameNum; // reset scale if not checked on previous frame
  192. } ibutton_t;
  193. void SetButtonPics( ibutton_t *button, const char *picName, const char *title, int x, int y );
  194. void SetButtonText( ibutton_t *button, const char *title, int x, int y, int w, int h );
  195. boolean HandleButton( ibutton_t *button );
  196. //---------------------------------------
  197. // Doom stuff we call directly
  198. //---------------------------------------
  199. void G_DoSaveGame (boolean menu);
  200. //---------------------------------------
  201. // iphone_mapSelect.c
  202. //---------------------------------------
  203. void DisplayLoadingScreen();
  204. void iphoneMapSelectMenu();
  205. //---------------------------------------
  206. // interfaces from the original game code
  207. //---------------------------------------
  208. void iphoneSetNotifyText( const char *str, ... );
  209. void iphoneIntermission( wbstartstruct_t* wbstartstruct );
  210. //---------------------------------------
  211. // interfaces to Objective-C land
  212. //---------------------------------------
  213. // The event thread will fill this after hitting enter
  214. // on the console. The game thread should check it,
  215. // execute it, and clear it under mutex.
  216. extern char consoleCommand[1024];
  217. void SysIPhoneSwapBuffers();
  218. void SysIPhoneVibrate();
  219. void SysIPhoneOpenURL( const char *url );
  220. void SysIPhoneSetUIKitOrientation( int isLandscapeRight );
  221. const char * SysIPhoneGetConsoleTextField();
  222. void SysIPhoneSetConsoleTextField(const char *);
  223. void SysIPhoneInitAudioSession();
  224. int SysIPhoneOtherAudioIsPlaying();
  225. int SysIphoneMilliseconds();
  226. int SysIphoneMicroseconds();
  227. const char * SysIphoneGetAppDir();
  228. const char * SysIphoneGetDocDir();
  229. //---------------------------------------
  230. // interfaces from Objective-C land
  231. //---------------------------------------
  232. void iphoneStartup();
  233. void iphoneShutdown();
  234. void iphoneFrame();
  235. void iphoneTiltEvent( float *tilts );
  236. void iphoneTouchEvent( int numTouches, int touches[16] );
  237. void iphoneActivateConsole();
  238. void iphoneDeactivateConsole();
  239. void iphoneExecuteCommandLine();