HelpScreen.c 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567
  1. #ifdef PRECOMPILEDHEADERS
  2. #include "JA2 All.h"
  3. #include "HelpScreen.h"
  4. #include "HelpScreenText.h"
  5. #include "Line.h"
  6. #else
  7. #include "sgp.h"
  8. #include "sys globals.h"
  9. #include "sysutil.h"
  10. #include "vobject_blitters.h"
  11. #include "wcheck.h"
  12. #include "cursors.h"
  13. #include "font control.h"
  14. #include "cursor control.h"
  15. #include "render dirty.h"
  16. #include "GameScreen.h"
  17. #include "Text.h"
  18. #include "Utilities.h"
  19. #include "WordWrap.h"
  20. #include "Font Control.h"
  21. #include "text.h"
  22. #include "Multi Language Graphic Utils.h"
  23. #include "HelpScreen.h"
  24. #include "HelpScreenText.h"
  25. #include "Line.h"
  26. #endif
  27. extern INT16 gsVIEWPORT_END_Y;
  28. extern void PrintDate( void );
  29. extern void PrintNumberOnTeam( void );
  30. extern void PrintBalance( void );
  31. extern BOOLEAN fMapScreenBottomDirty;
  32. extern BOOLEAN fCharacterInfoPanelDirty;
  33. extern BOOLEAN fTeamPanelDirty;
  34. extern BOOLEAN fMapScreenBottomDirty;
  35. extern BOOLEAN fMapPanelDirty;
  36. extern BOOLEAN gfGamePaused;
  37. extern BOOLEAN fShowMapInventoryPool;
  38. extern BOOLEAN BltVSurfaceUsingDD( HVSURFACE hDestVSurface, HVSURFACE hSrcVSurface, UINT32 fBltFlags, INT32 iDestX, INT32 iDestY, RECT *SrcRect );
  39. #define HELP_SCREEN_ACTIVE 0x00000001
  40. //The defualt size and placement of the screen
  41. #define HELP_SCREEN_DEFUALT_LOC_X 155
  42. #define HELP_SCREEN_DEFUALT_LOC_Y 105
  43. #define HELP_SCREEN_DEFUALT_LOC_WIDTH HELP_SCREEN_SMALL_LOC_WIDTH + HELP_SCREEN_BUTTON_BORDER_WIDTH
  44. #define HELP_SCREEN_DEFUALT_LOC_HEIGHT 292//300
  45. #define HELP_SCREEN_BUTTON_BORDER_WIDTH 92
  46. #define HELP_SCREEN_SMALL_LOC_WIDTH 320
  47. #define HELP_SCREEN_SMALL_LOC_HEIGHT HELP_SCREEN_DEFUALT_LOC_HEIGHT //224
  48. #define HELP_SCREEN_BTN_OFFSET_X 11
  49. #define HELP_SCREEN_BTN_OFFSET_Y 12//50
  50. #define HELP_SCREEN_BTN_FONT_ON_COLOR 73
  51. #define HELP_SCREEN_BTN_FONT_OFF_COLOR FONT_MCOLOR_WHITE
  52. #define HELP_SCREEN_BTN_FONT_BACK_COLOR 50
  53. #define HELP_SCREEN_BTN_FONT FONT10ARIAL
  54. #define HELP_SCREEN_BTN_WIDTH 77
  55. #define HELP_SCREEN_BTN_HEIGHT 22
  56. #define HELP_SCREEN_GAP_BN_BTNS 8
  57. #define HELP_SCREEN_MARGIN_SIZE 10
  58. #define HELP_SCREEN_TEXT_RIGHT_MARGIN_SPACE 36
  59. #define HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN ( HELP_SCREEN_BUTTON_BORDER_WIDTH + 5 + HELP_SCREEN_MARGIN_SIZE )
  60. #define HELP_SCREEN_TEXT_LEFT_MARGIN ( 5 + HELP_SCREEN_MARGIN_SIZE )
  61. #define HELP_SCREEN_TEXT_OFFSET_Y 48
  62. #define HELP_SCREEN_GAP_BTN_LINES 2
  63. #define HELP_SCREEN_TITLE_BODY_FONT FONT12ARIAL
  64. #define HELP_SCREEN_TITLE_BODY_COLOR FONT_MCOLOR_WHITE//FONT_NEARBLACK
  65. #define HELP_SCREEN_TEXT_BODY_FONT FONT10ARIAL
  66. #define HELP_SCREEN_TEXT_BODY_COLOR FONT_MCOLOR_WHITE//FONT_NEARBLACK
  67. #define HELP_SCREEN_TEXT_BACKGROUND 0//NO_SHADOW//FONT_MCOLOR_WHITE
  68. #define HELP_SCREEN_TITLE_OFFSET_Y 7
  69. #define HELP_SCREEN_HELP_REMINDER_Y HELP_SCREEN_TITLE_OFFSET_Y + 15
  70. #define HELP_SCREEN_NUM_BTNS 8
  71. #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X 4
  72. #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y 18
  73. #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_X 25 + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X
  74. #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_Y ( HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y )
  75. #define HELP_SCREEN_EXIT_BTN_OFFSET_X 291
  76. #define HELP_SCREEN_EXIT_BTN_LOC_Y 9
  77. #define HELP_SCREEN_
  78. //the type of help screen
  79. #define HLP_SCRN_DEFAULT_TYPE 9
  80. #define HLP_SCRN_BUTTON_BORDER 8
  81. //this is the size of the text buffer where everything will be blitted.
  82. // 2 ( bytest for char ) * width of buffer * height of 1 line * # of text lines
  83. //#define HLP_SCRN__NUMBER_BYTES_IN_TEXT_BUFFER ( 2 * HLP_SCRN__WIDTH_OF_TEXT_BUFFER * HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER * HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER )
  84. #define HLP_SCRN__WIDTH_OF_TEXT_BUFFER 280
  85. #define HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER 170//100
  86. #define HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER ( GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT ) + HELP_SCREEN_GAP_BTN_LINES )
  87. #define HLP_SCRN__MAX_NUMBER_PIXELS_DISPLAYED_IN_TEXT_BUFFER HELP_SCREEN_DEFUALT_LOC_HEIGHT
  88. #define HLP_SCRN__HEIGHT_OF_TEXT_BUFFER ( HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER * HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER )
  89. #define HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER ( HLP_SCRN__HEIGHT_OF_TEXT_AREA / HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER )
  90. #define HLP_SCRN__HEIGHT_OF_TEXT_AREA 228
  91. #define HLP_SCRN__HEIGHT_OF_SCROLL_AREA 182
  92. #define HLP_SCRN__WIDTH_OF_SCROLL_AREA 20
  93. #define HLP_SCRN__SCROLL_POSX 292
  94. #define HLP_SCRN__SCROLL_POSY ( gHelpScreen.usScreenLocY + 63 )
  95. #define HLP_SCRN__SCROLL_UP_ARROW_X 292
  96. #define HLP_SCRN__SCROLL_UP_ARROW_Y 43
  97. #define HLP_SCRN__SCROLL_DWN_ARROW_X HLP_SCRN__SCROLL_UP_ARROW_X
  98. #define HLP_SCRN__SCROLL_DWN_ARROW_Y HLP_SCRN__SCROLL_UP_ARROW_Y + 202
  99. //enums for the different dirty levels
  100. enum
  101. {
  102. HLP_SCRN_DRTY_LVL_NOT_DIRTY,
  103. HLP_SCRN_DRTY_LVL_REFRESH_TEXT,
  104. HLP_SCRN_DRTY_LVL_REFRESH_ALL,
  105. };
  106. //new screen:
  107. enum
  108. {
  109. HLP_SCRN_MPSCRN_SCTR_OVERVIEW,
  110. };
  111. //mapscreen, welcome to arulco
  112. enum
  113. {
  114. HLP_SCRN_MPSCRN_OVERVIEW,
  115. HLP_SCRN_MPSCRN_ASSIGNMENTS,
  116. HLP_SCRN_MPSCRN_DESTINATIONS,
  117. HLP_SCRN_MPSCRN_MAP,
  118. HLP_SCRN_MPSCRN_MILITIA,
  119. HLP_SCRN_MPSCRN_AIRSPACE,
  120. HLP_SCRN_MPSCRN_ITEMS,
  121. HLP_SCRN_MPSCRN_KEYBOARD,
  122. HLP_SCRN_NUM_MPSCRN_BTNS,
  123. };
  124. //laptop sub pages
  125. enum
  126. {
  127. HLP_SCRN_LPTP_OVERVIEW,
  128. HLP_SCRN_LPTP_EMAIL,
  129. HLP_SCRN_LPTP_WEB,
  130. HLP_SCRN_LPTP_FILES,
  131. HLP_SCRN_LPTP_HISTORY,
  132. HLP_SCRN_LPTP_PERSONNEL,
  133. HLP_SCRN_LPTP_FINANCIAL,
  134. HLP_SCRN_LPTP_MERC_STATS,
  135. HLP_SCRN_LPTP_NUM_PAGES,
  136. };
  137. //Mapscreen no one hired yet pages
  138. enum
  139. {
  140. HLP_SCRN_NO_ONE_HIRED,
  141. HLP_SCRN_NUM_MAPSCREEN_NO_1_HIRED_YET_PAGES,
  142. };
  143. //mapscreen no 1 hired yet pages
  144. enum
  145. {
  146. HLP_SCRN_NOT_IN_ARULCO,
  147. HLP_SCRN_NUM_NOT_IN_ARULCO_PAGES,
  148. };
  149. //Tactical
  150. enum
  151. {
  152. HLP_SCRN_TACTICAL_OVERVIEW,
  153. HLP_SCRN_TACTICAL_MOVEMENT,
  154. HLP_SCRN_TACTICAL_SIGHT,
  155. HLP_SCRN_TACTICAL_ATTACKING,
  156. HLP_SCRN_TACTICAL_ITEMS,
  157. HLP_SCRN_TACTICAL_KEYBOARD,
  158. HLP_SCRN_NUM_TACTICAL_PAGES,
  159. };
  160. //ddd
  161. HELP_SCREEN_STRUCT gHelpScreen;
  162. typedef struct
  163. {
  164. INT32 iButtonTextNum[ HELP_SCREEN_NUM_BTNS ];
  165. } HELP_SCREEN_BTN_TEXT_RECORD;
  166. //An array of record nums for the text on the help buttons
  167. HELP_SCREEN_BTN_TEXT_RECORD gHelpScreenBtnTextRecordNum[ HELP_SCREEN_NUMBER_OF_HELP_SCREENS ] =
  168. {
  169. //new screen:
  170. //Laptop button record nums
  171. // HELP_SCREEN_LAPTOP,
  172. { HLP_TXT_LAPTOP_BUTTON_1,
  173. HLP_TXT_LAPTOP_BUTTON_2,
  174. HLP_TXT_LAPTOP_BUTTON_3,
  175. HLP_TXT_LAPTOP_BUTTON_4,
  176. HLP_TXT_LAPTOP_BUTTON_5,
  177. HLP_TXT_LAPTOP_BUTTON_6,
  178. HLP_TXT_LAPTOP_BUTTON_7,
  179. HLP_TXT_LAPTOP_BUTTON_8, },
  180. // HELP_SCREEN_MAPSCREEN,
  181. { HLP_TXT_WELCOM_TO_ARULCO_BUTTON_1,
  182. HLP_TXT_WELCOM_TO_ARULCO_BUTTON_2,
  183. HLP_TXT_WELCOM_TO_ARULCO_BUTTON_3,
  184. HLP_TXT_WELCOM_TO_ARULCO_BUTTON_4,
  185. HLP_TXT_WELCOM_TO_ARULCO_BUTTON_5,
  186. HLP_TXT_WELCOM_TO_ARULCO_BUTTON_6,
  187. HLP_TXT_WELCOM_TO_ARULCO_BUTTON_7,
  188. HLP_TXT_WELCOM_TO_ARULCO_BUTTON_8, },
  189. // HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED,
  190. { -1, -1, -1, -1, -1, -1, -1, -1, },
  191. // HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO,
  192. { -1, -1, -1, -1, -1, -1, -1, -1, },
  193. // HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY,
  194. { -1, -1, -1, -1, -1, -1, -1, -1, },
  195. // HELP_SCREEN_TACTICAL,
  196. { HLP_TXT_TACTICAL_BUTTON_1,
  197. HLP_TXT_TACTICAL_BUTTON_2,
  198. HLP_TXT_TACTICAL_BUTTON_3,
  199. HLP_TXT_TACTICAL_BUTTON_4,
  200. HLP_TXT_TACTICAL_BUTTON_5,
  201. HLP_TXT_TACTICAL_BUTTON_6,
  202. -1, -1, },
  203. // HELP_SCREEN_OPTIONS,
  204. { -1, -1, -1, -1, -1, -1, -1, -1, },
  205. // HELP_SCREEN_LOAD_GAME,
  206. { -1, -1, -1, -1, -1, -1, -1, -1, },
  207. };
  208. BOOLEAN gfHelpScreenEntry = TRUE;
  209. BOOLEAN gfHelpScreenExit = FALSE;
  210. UINT32 guiHelpScreenBackGround;
  211. UINT32 guiHelpScreenTextBufferSurface;
  212. BOOLEAN gfScrollBoxIsScrolling = FALSE;
  213. BOOLEAN gfHaveRenderedFirstFrameToSaveBuffer=FALSE;
  214. // must use this cause you have ur cursor over a button when entering the help screen, the button will burn though.
  215. //It does this cause that region loses it focus so it draws the button again.
  216. UINT8 gubRenderHelpScreenTwiceInaRow=0;
  217. //mmm
  218. // region to mask the background
  219. MOUSE_REGION gHelpScreenFullScreenMask;
  220. //void SelectHelpTextFullScreenMaskCallBack(MOUSE_REGION * pRegion, INT32 iReason );
  221. // region to mask the background
  222. MOUSE_REGION gHelpScreenScrollArea;
  223. void SelectHelpScrollAreaMovementCallBack( MOUSE_REGION * pRegion, INT32 iReason );
  224. void SelectHelpScrollAreaCallBack( MOUSE_REGION * pRegion, INT32 iReason );
  225. // region to mask the background
  226. MOUSE_REGION gHelpScreenScrollAreaArrows;
  227. void SelectHelpScrollAreaArrowsCallBack( MOUSE_REGION * pRegion, INT32 iReason );
  228. //checkbox to toggle show help again toggle
  229. UINT32 gHelpScreenDontShowHelpAgainToggle;
  230. void BtnHelpScreenDontShowHelpAgainCallback(GUI_BUTTON *btn,INT32 reason);
  231. //MOUSE_REGION HelpScreenDontShowHelpAgainToggleTextRegion;
  232. //void HelpScreenDontShowHelpAgainToggleTextRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
  233. INT32 giHelpScreenButtonsImage[ HELP_SCREEN_NUM_BTNS ];
  234. UINT32 guiHelpScreenBtns[ HELP_SCREEN_NUM_BTNS ];
  235. void BtnHelpScreenBtnsCallback(GUI_BUTTON *btn,INT32 reason);
  236. INT32 giExitBtnImage;
  237. UINT32 guiHelpScreenExitBtn;
  238. void BtnHelpScreenExitCallback(GUI_BUTTON *btn,INT32 reason);
  239. INT32 giHelpScreenScrollArrows[2];
  240. UINT32 guiHelpScreenScrollArrowImage[2];
  241. void BtnHelpScreenScrollArrowsCallback(GUI_BUTTON *btn,INT32 reason);
  242. //ggg
  243. BOOLEAN EnterHelpScreen();
  244. void HandleHelpScreen();
  245. void RenderHelpScreen();
  246. void ExitHelpScreen();
  247. void GetHelpScreenUserInput();
  248. void HelpScreenSpecialExitCode();
  249. void SetSizeAndPropertiesOfHelpScreen();
  250. BOOLEAN DrawHelpScreenBackGround();
  251. void PrepareToExitHelpScreen();
  252. void SpecialHandlerCode();
  253. UINT16 RenderSpecificHelpScreen();
  254. UINT16 RenderLaptopHelpScreen();
  255. UINT16 RenderTacticalHelpScreen();
  256. UINT16 RenderMapScreenHelpScreen();
  257. UINT16 RenderMapScreenNoOneHiredYetHelpScreen();
  258. UINT16 RenderMapScreenNotYetInArulcoHelpScreen();
  259. UINT16 RenderMapScreenSectorInventoryHelpScreen();
  260. void GetHelpScreenTextPositions( UINT16 *pusPosX, UINT16 *pusPosY, UINT16 *pusWidth );
  261. void DisplayCurrentScreenTitleAndFooter();
  262. void GetHelpScreenText( UINT32 uiRecordToGet, STR16 pText );
  263. UINT16 GetAndDisplayHelpScreenText( UINT32 uiRecord, UINT16 usPosX, UINT16 usPosY, UINT16 usWidth );
  264. void CreateHelpScreenButtons();
  265. void RefreshAllHelpScreenButtons();
  266. void RenderTextBufferToScreen();
  267. void RenderCurrentHelpScreenTextToBuffer();
  268. void DestroyHelpScreenTextBuffer();
  269. BOOLEAN CreateHelpScreenTextBuffer();
  270. void ChangeHelpScreenSubPage();
  271. void ClearHelpScreenTextBuffer();
  272. void ChangeTopLineInTextBufferByAmount( INT32 iAmouontToMove );
  273. void DisplayHelpScreenTextBufferScrollBox();
  274. void CalculateHeightAndPositionForHelpScreenScrollBox( INT32 *piHeightOfScrollBox, INT32 *iTopOfScrollBox );
  275. void HelpScreenMouseMoveScrollBox( INT32 usMousePosY );
  276. void CreateScrollAreaButtons();
  277. void DeleteScrollArrowButtons();
  278. void ChangeToHelpScreenSubPage( INT8 bNewPage );
  279. BOOLEAN AreWeClickingOnScrollBar( INT32 usMousePosY );
  280. //ppp
  281. void InitHelpScreenSystem()
  282. {
  283. //set some values
  284. memset( &gHelpScreen, 0, sizeof( gHelpScreen ) );
  285. //set it up so we can enter the screen
  286. gfHelpScreenEntry = TRUE;
  287. gfHelpScreenExit = FALSE;
  288. gHelpScreen.bCurrentHelpScreenActiveSubPage = -1;
  289. gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = FALSE;
  290. }
  291. BOOLEAN ShouldTheHelpScreenComeUp( UINT8 ubScreenID, BOOLEAN fForceHelpScreenToComeUp )
  292. {
  293. //if the screen is being forsced to come up ( user pressed 'h' )
  294. if( fForceHelpScreenToComeUp )
  295. {
  296. //Set thefact that the user broughtthe help screen up
  297. gHelpScreen.fForceHelpScreenToComeUp = TRUE;
  298. goto HELP_SCREEN_SHOULD_COME_UP;
  299. }
  300. //if we are already in the help system, return true
  301. if( gHelpScreen.uiFlags & HELP_SCREEN_ACTIVE )
  302. {
  303. return( TRUE );
  304. }
  305. //has the player been in the screen before
  306. if( ( gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen >> ubScreenID ) & 0x01 )
  307. {
  308. goto HELP_SCREEN_WAIT_1_FRAME;
  309. }
  310. //if we have already been in the screen, and the user DIDNT press 'h', leave
  311. if( gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen )
  312. {
  313. return( FALSE );
  314. }
  315. //should the screen come up, based on the users choice for it automatically coming up
  316. // if( !( gHelpScreen.fHideHelpInAllScreens ) )
  317. {
  318. // goto HELP_SCREEN_WAIT_1_FRAME;
  319. }
  320. //the help screen shouldnt come up
  321. return( FALSE );
  322. HELP_SCREEN_WAIT_1_FRAME:
  323. // we have to wait 1 frame while the screen renders
  324. if( gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount < 2 )
  325. {
  326. gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount += 1;
  327. UnmarkButtonsDirty( );
  328. return( FALSE );
  329. }
  330. HELP_SCREEN_SHOULD_COME_UP:
  331. //Record which screen it is
  332. //if its mapscreen
  333. if( ubScreenID == HELP_SCREEN_MAPSCREEN )
  334. {
  335. //determine which screen it is ( is any mercs hired, did game just start )
  336. gHelpScreen.bCurrentHelpScreen = HelpScreenDetermineWhichMapScreenHelpToShow();
  337. }
  338. else
  339. {
  340. gHelpScreen.bCurrentHelpScreen = ubScreenID;
  341. }
  342. //mark it that the help screnn is enabled
  343. gHelpScreen.uiFlags |= HELP_SCREEN_ACTIVE;
  344. // reset
  345. gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount = 0;
  346. return( TRUE );
  347. }
  348. void HelpScreenHandler()
  349. {
  350. //if we are just entering the help screen
  351. if( gfHelpScreenEntry )
  352. {
  353. //setup the help screen
  354. EnterHelpScreen();
  355. gfHelpScreenEntry = FALSE;
  356. gfHelpScreenExit = FALSE;
  357. }
  358. RestoreBackgroundRects();
  359. //get the mouse and keyboard inputs
  360. GetHelpScreenUserInput();
  361. //handle the help screen
  362. HandleHelpScreen();
  363. //if the help screen is dirty, re-render it
  364. if( gHelpScreen.ubHelpScreenDirty != HLP_SCRN_DRTY_LVL_NOT_DIRTY )
  365. {
  366. //temp
  367. // gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
  368. RenderHelpScreen();
  369. gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_NOT_DIRTY;
  370. }
  371. // render buttons marked dirty
  372. // MarkButtonsDirty( );
  373. RenderButtons( );
  374. SaveBackgroundRects( );
  375. RenderButtonsFastHelp();
  376. ExecuteBaseDirtyRectQueue();
  377. EndFrameBufferRender();
  378. //if we are leaving the help screen
  379. if( gfHelpScreenExit )
  380. {
  381. gfHelpScreenExit = FALSE;
  382. gfHelpScreenEntry = TRUE;
  383. //exit mouse regions etc..
  384. ExitHelpScreen();
  385. //reset the helpscreen id
  386. gHelpScreen.bCurrentHelpScreen = -1;
  387. }
  388. }
  389. BOOLEAN EnterHelpScreen()
  390. {
  391. VOBJECT_DESC VObjectDesc;
  392. UINT16 usPosX, usPosY;//, usWidth, usHeight;
  393. // INT32 iStartLoc;
  394. // CHAR16 zText[1024];
  395. //Clear out all the save background rects
  396. EmptyBackgroundRects( );
  397. UnmarkButtonsDirty( );
  398. // remeber if the game was paused or not ( so when we exit we know what to do )
  399. gHelpScreen.fWasTheGamePausedPriorToEnteringHelpScreen = gfGamePaused;
  400. //pause the game
  401. PauseGame( );
  402. //Determine the help screen size, based off the help screen
  403. SetSizeAndPropertiesOfHelpScreen();
  404. //Create a mouse region 'mask' the entrire screen
  405. MSYS_DefineRegion( &gHelpScreenFullScreenMask, 0, 0, 640, 480, MSYS_PRIORITY_HIGHEST,
  406. gHelpScreen.usCursor, MSYS_NO_CALLBACK, MSYS_NO_CALLBACK );
  407. MSYS_AddRegion( &gHelpScreenFullScreenMask );
  408. //Create the exit button
  409. if( gHelpScreen.bNumberOfButtons != 0 )
  410. usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_EXIT_BTN_OFFSET_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
  411. else
  412. usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_EXIT_BTN_OFFSET_X;
  413. usPosY = gHelpScreen.usScreenLocY + HELP_SCREEN_EXIT_BTN_LOC_Y;
  414. //Create the exit buttons
  415. giExitBtnImage = LoadButtonImage("INTERFACE\\HelpScreen.sti", -1,0,4,2,6 );
  416. guiHelpScreenExitBtn = CreateIconAndTextButton( giExitBtnImage, L"", HELP_SCREEN_BTN_FONT,
  417. HELP_SCREEN_BTN_FONT_ON_COLOR, DEFAULT_SHADOW,
  418. HELP_SCREEN_BTN_FONT_OFF_COLOR, DEFAULT_SHADOW,
  419. TEXT_CJUSTIFIED,
  420. usPosX, usPosY, BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  421. DEFAULT_MOVE_CALLBACK, BtnHelpScreenExitCallback );
  422. SetButtonFastHelpText( guiHelpScreenExitBtn, gzHelpScreenText[HLP_SCRN_TXT__EXIT_SCREEN] );
  423. SetButtonCursor( guiHelpScreenExitBtn, gHelpScreen.usCursor);
  424. //Create the buttons needed for the screen
  425. CreateHelpScreenButtons();
  426. //if there are buttons
  427. if( gHelpScreen.bNumberOfButtons != 0 )
  428. usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
  429. else
  430. usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X;
  431. usPosY = gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight - HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y;
  432. if( !gHelpScreen.fForceHelpScreenToComeUp)
  433. {
  434. gHelpScreenDontShowHelpAgainToggle = CreateCheckBoxButton( usPosX, (UINT16)(usPosY-3),
  435. "INTERFACE\\OptionsCheckBoxes.sti", MSYS_PRIORITY_HIGHEST,
  436. BtnHelpScreenDontShowHelpAgainCallback );
  437. SetButtonCursor( gHelpScreenDontShowHelpAgainToggle, gHelpScreen.usCursor );
  438. // Set the state of the chec box
  439. if( gGameSettings.fHideHelpInAllScreens )
  440. ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags |= BUTTON_CLICKED_ON;
  441. else
  442. ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags &= ~BUTTON_CLICKED_ON;
  443. }
  444. /*
  445. ///creatre a region for the text that says ' [ x ] click to continue seeing ....'
  446. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_CONSTANT_FOOTER;
  447. LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
  448. usWidth = StringPixLength( zText, HELP_SCREEN_TEXT_BODY_FONT );
  449. usHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  450. /*
  451. MSYS_DefineRegion( &HelpScreenDontShowHelpAgainToggleTextRegion, usPosX, usPosY, (UINT16)(usPosX+usWidth), (UINT16)(usPosY+usHeight), MSYS_PRIORITY_HIGHEST-1,
  452. gHelpScreen.usCursor, MSYS_NO_CALLBACK, HelpScreenDontShowHelpAgainToggleTextRegionCallBack );
  453. MSYS_AddRegion( &HelpScreenDontShowHelpAgainToggleTextRegion );
  454. */
  455. // load the help screen background graphic and add it
  456. VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
  457. FilenameForBPP("INTERFACE\\HelpScreen.sti", VObjectDesc.ImageFile);
  458. CHECKF(AddVideoObject(&VObjectDesc, &guiHelpScreenBackGround));
  459. //create the text buffer
  460. CreateHelpScreenTextBuffer();
  461. //make sure we redraw everything
  462. gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
  463. //mark it that we have been in since we enter the current screen
  464. gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = TRUE;
  465. //set the fact that we have been to the screen
  466. gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen &= ~( 1 << gHelpScreen.bCurrentHelpScreen );
  467. //always start at the top
  468. gHelpScreen.iLineAtTopOfTextBuffer = 0;
  469. //set it so there was no previous click
  470. gHelpScreen.iLastMouseClickY = -1;
  471. //Create the scroll box, and scroll arrow regions/buttons
  472. CreateScrollAreaButtons();
  473. //render the active page to the text buffer
  474. ChangeHelpScreenSubPage();
  475. //reset scroll box flag
  476. gfScrollBoxIsScrolling = FALSE;
  477. //reset first frame buffer
  478. gfHaveRenderedFirstFrameToSaveBuffer = FALSE;
  479. gubRenderHelpScreenTwiceInaRow = 0;
  480. return( TRUE );
  481. }
  482. void HandleHelpScreen()
  483. {
  484. //if any of the possible screens need to have a some code done every loop.. its done in here
  485. SpecialHandlerCode();
  486. if( gfScrollBoxIsScrolling )
  487. {
  488. if( gfLeftButtonState )
  489. {
  490. HelpScreenMouseMoveScrollBox( gusMouseYPos );
  491. }
  492. else
  493. {
  494. gfScrollBoxIsScrolling = FALSE;
  495. gHelpScreen.iLastMouseClickY = -1;
  496. }
  497. }
  498. if( gubRenderHelpScreenTwiceInaRow < 3 )
  499. {
  500. //test
  501. // gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
  502. gubRenderHelpScreenTwiceInaRow++;
  503. UnmarkButtonsDirty( );
  504. }
  505. // refresh all of help screens buttons
  506. RefreshAllHelpScreenButtons();
  507. }
  508. void RenderHelpScreen()
  509. {
  510. //rrr
  511. if( gfHaveRenderedFirstFrameToSaveBuffer )
  512. {
  513. //Restore the background before blitting the text back on
  514. RestoreExternBackgroundRect( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenWidth, gHelpScreen.usScreenHeight );
  515. }
  516. if( gHelpScreen.ubHelpScreenDirty == HLP_SCRN_DRTY_LVL_REFRESH_ALL )
  517. {
  518. //Display the helpscreen background
  519. DrawHelpScreenBackGround();
  520. //Display the current screens title, and footer info
  521. DisplayCurrentScreenTitleAndFooter();
  522. }
  523. if( !gfHaveRenderedFirstFrameToSaveBuffer )
  524. {
  525. gfHaveRenderedFirstFrameToSaveBuffer = TRUE;
  526. //blit everything to the save buffer ( cause the save buffer can bleed through )
  527. BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, (UINT16)(gHelpScreen.usScreenLocX+gHelpScreen.usScreenWidth), (UINT16)(gHelpScreen.usScreenLocY+gHelpScreen.usScreenHeight) );
  528. UnmarkButtonsDirty( );
  529. }
  530. //render the text buffer to the screen
  531. if( gHelpScreen.ubHelpScreenDirty >= HLP_SCRN_DRTY_LVL_REFRESH_TEXT )
  532. {
  533. RenderTextBufferToScreen();
  534. }
  535. }
  536. void ExitHelpScreen()
  537. {
  538. INT32 i;
  539. if( !gHelpScreen.fForceHelpScreenToComeUp )
  540. {
  541. //Get the current value of the checkbox
  542. if( ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags & BUTTON_CLICKED_ON )
  543. {
  544. gGameSettings.fHideHelpInAllScreens = TRUE;
  545. gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen = 0;
  546. }
  547. else
  548. {
  549. gGameSettings.fHideHelpInAllScreens = FALSE;
  550. }
  551. //remove the mouse region for the '[ ] dont show help...'
  552. RemoveButton( gHelpScreenDontShowHelpAgainToggle );
  553. }
  554. //mark it that the help screen is not active
  555. gHelpScreen.uiFlags &= ~HELP_SCREEN_ACTIVE;
  556. //remove the mouse region that blankets
  557. MSYS_RemoveRegion( &gHelpScreenFullScreenMask );
  558. //checkbox to toggle show help again toggle
  559. // MSYS_RemoveRegion( &HelpScreenDontShowHelpAgainToggleTextRegion );
  560. //remove the hepl graphic
  561. DeleteVideoObjectFromIndex( guiHelpScreenBackGround );
  562. //remove the exit button
  563. RemoveButton( guiHelpScreenExitBtn );
  564. //if there are any buttons, remove them
  565. if( gHelpScreen.bNumberOfButtons != 0 )
  566. {
  567. for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
  568. {
  569. UnloadButtonImage( giHelpScreenButtonsImage[i] );
  570. RemoveButton( guiHelpScreenBtns[i] );
  571. }
  572. }
  573. //destroy the text buffer for the help screen
  574. DestroyHelpScreenTextBuffer();
  575. //Handles the dirtying of any special screen we are about to reenter
  576. HelpScreenSpecialExitCode();
  577. //if the game was NOT paused
  578. if( gHelpScreen.fWasTheGamePausedPriorToEnteringHelpScreen == FALSE )
  579. {
  580. //un pause the game
  581. UnPauseGame( );
  582. }
  583. //Delete the scroll box, and scroll arrow regions/buttons
  584. DeleteScrollArrowButtons();
  585. //reset
  586. gHelpScreen.fForceHelpScreenToComeUp = FALSE;
  587. SaveGameSettings();
  588. }
  589. BOOLEAN DrawHelpScreenBackGround()
  590. {
  591. HVOBJECT hPixHandle;
  592. UINT16 usPosX;
  593. //Get and display the background image
  594. GetVideoObject(&hPixHandle, guiHelpScreenBackGround );
  595. usPosX = gHelpScreen.usScreenLocX;
  596. //if there are buttons, blit the button border
  597. if( gHelpScreen.bNumberOfButtons != 0 )
  598. {
  599. BltVideoObject(FRAME_BUFFER, hPixHandle, HLP_SCRN_BUTTON_BORDER, usPosX, gHelpScreen.usScreenLocY, VO_BLT_SRCTRANSPARENCY,NULL);
  600. usPosX += HELP_SCREEN_BUTTON_BORDER_WIDTH;
  601. }
  602. BltVideoObject(FRAME_BUFFER, hPixHandle, HLP_SCRN_DEFAULT_TYPE, usPosX, gHelpScreen.usScreenLocY, VO_BLT_SRCTRANSPARENCY,NULL);
  603. InvalidateRegion( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenLocX+gHelpScreen.usScreenWidth, gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight );
  604. return( TRUE );
  605. }
  606. void SetSizeAndPropertiesOfHelpScreen()
  607. {
  608. //new screen:
  609. gHelpScreen.bNumberOfButtons = 0;
  610. //
  611. //these are the default settings, so if the screen uses different then defualt, set them in the switch
  612. //
  613. {
  614. gHelpScreen.usScreenWidth = HELP_SCREEN_DEFUALT_LOC_WIDTH;
  615. gHelpScreen.usScreenHeight = HELP_SCREEN_DEFUALT_LOC_HEIGHT;
  616. gHelpScreen.usScreenLocX = ( 640 - gHelpScreen.usScreenWidth ) / 2;
  617. gHelpScreen.usScreenLocY = ( 480 - gHelpScreen.usScreenHeight ) / 2;
  618. gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
  619. gHelpScreen.usCursor = CURSOR_NORMAL;
  620. }
  621. switch( gHelpScreen.bCurrentHelpScreen )
  622. {
  623. case HELP_SCREEN_LAPTOP:
  624. gHelpScreen.bNumberOfButtons = HLP_SCRN_LPTP_NUM_PAGES;
  625. gHelpScreen.usCursor = CURSOR_LAPTOP_SCREEN;
  626. //center the screen inside the laptop screen
  627. gHelpScreen.usScreenLocX = LAPTOP_SCREEN_UL_X + ( LAPTOP_SCREEN_WIDTH - gHelpScreen.usScreenWidth ) / 2;
  628. gHelpScreen.usScreenLocY = LAPTOP_SCREEN_UL_Y + ( LAPTOP_SCREEN_HEIGHT - gHelpScreen.usScreenHeight ) / 2;
  629. break;
  630. case HELP_SCREEN_MAPSCREEN:
  631. gHelpScreen.bNumberOfButtons = HLP_SCRN_NUM_MPSCRN_BTNS;
  632. //calc the center position based on the current panel thats being displayed
  633. gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
  634. break;
  635. case HELP_SCREEN_TACTICAL:
  636. gHelpScreen.bNumberOfButtons = HLP_SCRN_NUM_TACTICAL_PAGES;
  637. //calc the center position based on the current panel thats being displayed
  638. gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
  639. break;
  640. case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
  641. case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
  642. case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
  643. gHelpScreen.usScreenWidth = HELP_SCREEN_SMALL_LOC_WIDTH;
  644. gHelpScreen.usScreenHeight = HELP_SCREEN_SMALL_LOC_HEIGHT;
  645. //calc screen position since we just set the width and height
  646. gHelpScreen.usScreenLocX = ( 640 - gHelpScreen.usScreenWidth ) / 2;
  647. //calc the center position based on the current panel thats being displayed
  648. gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
  649. gHelpScreen.bNumberOfButtons = 0;
  650. gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
  651. break;
  652. case HELP_SCREEN_OPTIONS:
  653. case HELP_SCREEN_LOAD_GAME:
  654. break;
  655. default:
  656. #ifdef JA2BETAVERSION
  657. AssertMsg( 0, "Error in help screen. DF 0" );
  658. #else
  659. break;
  660. #endif
  661. }
  662. //if there are buttons
  663. if( gHelpScreen.bNumberOfButtons != 0 )
  664. gHelpScreen.usLeftMarginPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN;
  665. else
  666. gHelpScreen.usLeftMarginPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_TEXT_LEFT_MARGIN;
  667. }
  668. void CreateHelpScreenButtons()
  669. {
  670. UINT16 usPosX, usPosY;
  671. CHAR16 sText[1024];
  672. INT32 i;
  673. //if there are buttons to create
  674. if( gHelpScreen.bNumberOfButtons != 0 )
  675. {
  676. usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_BTN_OFFSET_X;
  677. usPosY = HELP_SCREEN_BTN_OFFSET_Y + gHelpScreen.usScreenLocY;
  678. //loop through all the buttons, and create them
  679. for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
  680. {
  681. //get the text for the button
  682. GetHelpScreenText( gHelpScreenBtnTextRecordNum[ gHelpScreen.bCurrentHelpScreen ].iButtonTextNum[i], sText );
  683. /*
  684. guiHelpScreenBtns[i] = CreateTextButton( sText, HELP_SCREEN_BTN_FONT, HELP_SCREEN_BTN_FONT_COLOR, HELP_SCREEN_BTN_FONT_BACK_COLOR,
  685. BUTTON_USE_DEFAULT, usPosX, usPosY, HELP_SCREEN_BTN_WIDTH, HELP_SCREEN_BTN_HEIGHT,
  686. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST, BUTTON_NO_CALLBACK, BtnHelpScreenBtnsCallback );
  687. */
  688. giHelpScreenButtonsImage[i] = UseLoadedButtonImage( giExitBtnImage, -1,1,5,3,7 );
  689. guiHelpScreenBtns[i] = CreateIconAndTextButton( giHelpScreenButtonsImage[i], sText, HELP_SCREEN_BTN_FONT,
  690. HELP_SCREEN_BTN_FONT_ON_COLOR, DEFAULT_SHADOW,
  691. HELP_SCREEN_BTN_FONT_OFF_COLOR, DEFAULT_SHADOW,
  692. TEXT_CJUSTIFIED,
  693. usPosX, usPosY, BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  694. DEFAULT_MOVE_CALLBACK, BtnHelpScreenBtnsCallback);
  695. SetButtonCursor( guiHelpScreenBtns[i], gHelpScreen.usCursor);
  696. MSYS_SetBtnUserData( guiHelpScreenBtns[i], 0, i);
  697. // SpecifyButtonTextOffsets( guiHelpScreenBtns[i], 19, 9, TRUE );
  698. usPosY += HELP_SCREEN_BTN_HEIGHT + HELP_SCREEN_GAP_BN_BTNS;
  699. }
  700. ButtonList[ guiHelpScreenBtns[0] ]->uiFlags |= BUTTON_CLICKED_ON;
  701. }
  702. }
  703. void GetHelpScreenUserInput()
  704. {
  705. InputAtom Event;
  706. POINT MousePos;
  707. GetCursorPos(&MousePos);
  708. while( DequeueEvent( &Event ) )
  709. {
  710. // HOOK INTO MOUSE HOOKS
  711. switch( Event.usEvent)
  712. {
  713. case LEFT_BUTTON_DOWN:
  714. MouseSystemHook(LEFT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  715. break;
  716. case LEFT_BUTTON_UP:
  717. MouseSystemHook(LEFT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y ,_LeftButtonDown, _RightButtonDown);
  718. break;
  719. case RIGHT_BUTTON_DOWN:
  720. MouseSystemHook(RIGHT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  721. break;
  722. case RIGHT_BUTTON_UP:
  723. MouseSystemHook(RIGHT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  724. break;
  725. case RIGHT_BUTTON_REPEAT:
  726. MouseSystemHook(RIGHT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  727. break;
  728. case LEFT_BUTTON_REPEAT:
  729. MouseSystemHook(LEFT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
  730. break;
  731. }
  732. if( !HandleTextInput( &Event ) && Event.usEvent == KEY_UP )
  733. {
  734. switch( Event.usParam )
  735. {
  736. case ESC:
  737. PrepareToExitHelpScreen();
  738. break;
  739. case DNARROW:
  740. {
  741. ChangeTopLineInTextBufferByAmount( 1 );
  742. }
  743. break;
  744. case UPARROW:
  745. {
  746. ChangeTopLineInTextBufferByAmount( -1 );
  747. }
  748. break;
  749. case PGUP:
  750. {
  751. ChangeTopLineInTextBufferByAmount( -( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
  752. }
  753. break;
  754. case PGDN:
  755. {
  756. ChangeTopLineInTextBufferByAmount( ( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
  757. }
  758. break;
  759. case LEFTARROW:
  760. ChangeToHelpScreenSubPage( (INT8)( gHelpScreen.bCurrentHelpScreenActiveSubPage - 1 ) );
  761. break;
  762. case RIGHTARROW:
  763. ChangeToHelpScreenSubPage( (INT8)( gHelpScreen.bCurrentHelpScreenActiveSubPage + 1 ) );
  764. break;
  765. /*
  766. case LEFTARROW:
  767. {
  768. }
  769. break;
  770. case RIGHTARROW:
  771. {
  772. }
  773. break;
  774. */
  775. #ifdef JA2TESTVERSION
  776. //rerender the hepl screen
  777. case 'r':
  778. gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
  779. break;
  780. case 'i':
  781. InvalidateRegion( 0, 0, 640, 480 );
  782. break;
  783. case 'd':
  784. InvalidateRegion( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenLocX+gHelpScreen.usScreenWidth, gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight );
  785. break;
  786. #endif
  787. }
  788. }
  789. if( !HandleTextInput( &Event ) && Event.usEvent == KEY_REPEAT )
  790. {
  791. switch( Event.usParam )
  792. {
  793. case DNARROW:
  794. {
  795. ChangeTopLineInTextBufferByAmount( 1 );
  796. }
  797. break;
  798. case UPARROW:
  799. {
  800. ChangeTopLineInTextBufferByAmount( -1 );
  801. }
  802. break;
  803. case PGUP:
  804. {
  805. ChangeTopLineInTextBufferByAmount( -( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
  806. }
  807. break;
  808. case PGDN:
  809. {
  810. ChangeTopLineInTextBufferByAmount( ( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
  811. }
  812. break;
  813. }
  814. }
  815. }
  816. }
  817. //Handles anything spcial that must be done when exiting the specific screen we are about to reenter ( eg. dirtying of the screen )
  818. void HelpScreenSpecialExitCode()
  819. {
  820. //switch on the current screen
  821. switch( gHelpScreen.bCurrentHelpScreen )
  822. {
  823. case HELP_SCREEN_LAPTOP:
  824. fReDrawScreenFlag = TRUE;
  825. break;
  826. case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
  827. case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
  828. case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
  829. case HELP_SCREEN_MAPSCREEN:
  830. fCharacterInfoPanelDirty = TRUE;
  831. fTeamPanelDirty = TRUE;
  832. fMapScreenBottomDirty = TRUE;
  833. fMapPanelDirty=TRUE;
  834. break;
  835. case HELP_SCREEN_TACTICAL:
  836. fInterfacePanelDirty = DIRTYLEVEL2;
  837. SetRenderFlags(RENDER_FLAG_FULL);
  838. break;
  839. case HELP_SCREEN_OPTIONS:
  840. break;
  841. case HELP_SCREEN_LOAD_GAME:
  842. break;
  843. default:
  844. #ifdef JA2BETAVERSION
  845. AssertMsg( 0, "Error in help screen. DF 0" );
  846. #else
  847. break;
  848. #endif
  849. }
  850. }
  851. void PrepareToExitHelpScreen()
  852. {
  853. gfHelpScreenExit = TRUE;
  854. }
  855. //Handles anything special that must be done when exiting the specific screen we are about to reenter ( eg. dirtying of the screen )
  856. void SpecialHandlerCode()
  857. {
  858. //switch on the current screen
  859. switch( gHelpScreen.bCurrentHelpScreen )
  860. {
  861. case HELP_SCREEN_LAPTOP:
  862. PrintDate( );
  863. PrintBalance( );
  864. PrintNumberOnTeam( );
  865. break;
  866. case HELP_SCREEN_MAPSCREEN:
  867. break;
  868. case HELP_SCREEN_TACTICAL:
  869. break;
  870. case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
  871. break;
  872. case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
  873. break;
  874. case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
  875. break;
  876. break;
  877. case HELP_SCREEN_OPTIONS:
  878. break;
  879. case HELP_SCREEN_LOAD_GAME:
  880. break;
  881. default:
  882. #ifdef JA2BETAVERSION
  883. AssertMsg( 0, "Error in help screen: SpecialHandlerCode(). DF 0" );
  884. #else
  885. break;
  886. #endif
  887. }
  888. }
  889. UINT16 RenderSpecificHelpScreen()
  890. {
  891. UINT16 usNumVerticalPixelsDisplayed = 0;
  892. //new screen:
  893. //set the buffer for the text to go to
  894. // SetFontDestBuffer( guiHelpScreenTextBufferSurface, gHelpScreen.usLeftMarginPosX, gHelpScreen.usScreenLocY + HELP_SCREEN_TEXT_OFFSET_Y,
  895. // HLP_SCRN__WIDTH_OF_TEXT_BUFFER, HLP_SCRN__NUMBER_BYTES_IN_TEXT_BUFFER, FALSE );
  896. SetFontDestBuffer( guiHelpScreenTextBufferSurface, 0, 0,
  897. HLP_SCRN__WIDTH_OF_TEXT_BUFFER, HLP_SCRN__HEIGHT_OF_TEXT_BUFFER, FALSE );
  898. //switch on the current screen
  899. switch( gHelpScreen.bCurrentHelpScreen )
  900. {
  901. case HELP_SCREEN_LAPTOP:
  902. usNumVerticalPixelsDisplayed = RenderLaptopHelpScreen();
  903. break;
  904. case HELP_SCREEN_MAPSCREEN:
  905. usNumVerticalPixelsDisplayed = RenderMapScreenHelpScreen();
  906. break;
  907. case HELP_SCREEN_TACTICAL:
  908. usNumVerticalPixelsDisplayed = RenderTacticalHelpScreen();
  909. break;
  910. case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
  911. usNumVerticalPixelsDisplayed = RenderMapScreenNoOneHiredYetHelpScreen();
  912. break;
  913. case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
  914. usNumVerticalPixelsDisplayed = RenderMapScreenNotYetInArulcoHelpScreen();
  915. break;
  916. case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
  917. usNumVerticalPixelsDisplayed = RenderMapScreenSectorInventoryHelpScreen();
  918. break;
  919. case HELP_SCREEN_OPTIONS:
  920. break;
  921. case HELP_SCREEN_LOAD_GAME:
  922. break;
  923. default:
  924. #ifdef JA2BETAVERSION
  925. SetFontDestBuffer( FRAME_BUFFER, 0, 0, 640, 480, FALSE );
  926. AssertMsg( 0, "Error in help screen: RenderSpecificHelpScreen(). DF 0" );
  927. #else
  928. break;
  929. #endif
  930. }
  931. SetFontDestBuffer( FRAME_BUFFER, 0, 0, 640, 480, FALSE );
  932. //add 1 line to the bottom of the buffer
  933. usNumVerticalPixelsDisplayed += 10;
  934. return( usNumVerticalPixelsDisplayed );
  935. }
  936. void GetHelpScreenTextPositions( UINT16 *pusPosX, UINT16 *pusPosY, UINT16 *pusWidth )
  937. {
  938. //if there are buttons
  939. if( pusPosX != NULL )
  940. *pusPosX = 0;
  941. if( pusWidth != NULL )
  942. *pusWidth = HLP_SCRN__WIDTH_OF_TEXT_BUFFER - 1 * HELP_SCREEN_MARGIN_SIZE; //DEF was 2
  943. if( pusPosY != NULL )
  944. *pusPosY = 0;
  945. }
  946. void DisplayCurrentScreenTitleAndFooter()
  947. {
  948. INT32 iStartLoc = -1;
  949. CHAR16 zText[1024];
  950. UINT16 usPosX=0, usPosY=0, usWidth=0;
  951. //new screen:
  952. //switch on the current screen
  953. switch( gHelpScreen.bCurrentHelpScreen )
  954. {
  955. case HELP_SCREEN_LAPTOP:
  956. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_LAPTOP_TITLE;
  957. break;
  958. case HELP_SCREEN_MAPSCREEN:
  959. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_WELCOM_TO_ARULCO_TITLE;
  960. break;
  961. case HELP_SCREEN_TACTICAL:
  962. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_TACTICAL_TITLE;
  963. break;
  964. case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
  965. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_MPSCRN_NO_1_HIRED_YET_TITLE;
  966. break;
  967. case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
  968. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_MPSCRN_NOT_IN_ARULCO_TITLE;
  969. break;
  970. case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
  971. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_SECTOR_INVTRY_TITLE;
  972. break;
  973. case HELP_SCREEN_OPTIONS:
  974. break;
  975. case HELP_SCREEN_LOAD_GAME:
  976. break;
  977. default:
  978. #ifdef JA2BETAVERSION
  979. AssertMsg( 0, "Error in help screen: DisplayCurrentScreenTitleAndFooter(). DF 0" );
  980. #else
  981. break;
  982. #endif
  983. }
  984. // GetHelpScreenTextPositions( NULL, NULL, &usWidth );
  985. if( gHelpScreen.bNumberOfButtons != 0 )
  986. usWidth = gHelpScreen.usScreenWidth - HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN - HELP_SCREEN_TEXT_RIGHT_MARGIN_SPACE;
  987. else
  988. usWidth = gHelpScreen.usScreenWidth - HELP_SCREEN_TEXT_LEFT_MARGIN - HELP_SCREEN_TEXT_RIGHT_MARGIN_SPACE;
  989. //if this screen has a valid title
  990. if( iStartLoc != -1 )
  991. {
  992. LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
  993. SetFontShadow( NO_SHADOW );
  994. usPosX = gHelpScreen.usLeftMarginPosX;
  995. // DrawTextToScreen( zText, usPosX, (UINT16)(gHelpScreen.usScreenLocY+HELP_SCREEN_TITLE_OFFSET_Y), usWidth,
  996. // HELP_SCREEN_TITLE_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, HELP_SCREEN_TEXT_BACKGROUND, FALSE, CENTER_JUSTIFIED );
  997. //Display the Title
  998. IanDisplayWrappedString( usPosX, (UINT16)(gHelpScreen.usScreenLocY+HELP_SCREEN_TITLE_OFFSET_Y), usWidth, HELP_SCREEN_GAP_BTN_LINES,
  999. HELP_SCREEN_TITLE_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, zText,
  1000. HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
  1001. }
  1002. //Display the '( press H to get help... )'
  1003. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_CONSTANT_SUBTITLE;
  1004. LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
  1005. usPosX = gHelpScreen.usLeftMarginPosX;
  1006. usPosY = gHelpScreen.usScreenLocY+HELP_SCREEN_HELP_REMINDER_Y;
  1007. // DrawTextToScreen( zText, usPosX, usPosY, usWidth,
  1008. // HELP_SCREEN_TEXT_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, HELP_SCREEN_TEXT_BACKGROUND, FALSE, CENTER_JUSTIFIED );
  1009. IanDisplayWrappedString( usPosX, usPosY, usWidth, HELP_SCREEN_GAP_BTN_LINES,
  1010. HELP_SCREEN_TITLE_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, zText,
  1011. HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
  1012. if( !gHelpScreen.fForceHelpScreenToComeUp )
  1013. {
  1014. //calc location for the ' [ x ] Dont display again...'
  1015. iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_CONSTANT_FOOTER;
  1016. LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
  1017. usPosX = gHelpScreen.usLeftMarginPosX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_X;
  1018. usPosY = gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight - HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_Y + 2;
  1019. //Display the ' [ x ] Dont display again...'
  1020. IanDisplayWrappedString( usPosX, usPosY, usWidth, HELP_SCREEN_GAP_BTN_LINES,
  1021. HELP_SCREEN_TEXT_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, zText,
  1022. HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
  1023. }
  1024. SetFontShadow( DEFAULT_SHADOW );
  1025. }
  1026. void BtnHelpScreenBtnsCallback(GUI_BUTTON *btn,INT32 reason)
  1027. {
  1028. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  1029. {
  1030. // btn->uiFlags |= BUTTON_CLICKED_ON;
  1031. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1032. }
  1033. if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  1034. {
  1035. //Get the btn id
  1036. INT8 bRetValue = (UINT8)MSYS_GetBtnUserData( btn, 0 );
  1037. ChangeToHelpScreenSubPage( bRetValue );
  1038. /*
  1039. //change the current page to the new one
  1040. gHelpScreen.bCurrentHelpScreenActiveSubPage = ( bRetValue > gHelpScreen.bNumberOfButtons ) ? gHelpScreen.bNumberOfButtons-1 : bRetValue;
  1041. gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_TEXT;
  1042. for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
  1043. {
  1044. ButtonList[ guiHelpScreenBtns[i] ]->uiFlags &= (~BUTTON_CLICKED_ON );
  1045. }
  1046. //change the current sub page, and render it to the buffer
  1047. ChangeHelpScreenSubPage();
  1048. */
  1049. btn->uiFlags |= BUTTON_CLICKED_ON;
  1050. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1051. }
  1052. if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
  1053. {
  1054. // btn->uiFlags &= (~BUTTON_CLICKED_ON );
  1055. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1056. }
  1057. }
  1058. void ChangeToHelpScreenSubPage( INT8 bNewPage )
  1059. {
  1060. INT8 i;
  1061. //if for some reason, we are assigning a lower number
  1062. if( bNewPage < 0 )
  1063. {
  1064. gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
  1065. }
  1066. //for some reason if the we are passing in a # that is greater then the max, set it to the max
  1067. else if( bNewPage >= gHelpScreen.bNumberOfButtons )
  1068. {
  1069. gHelpScreen.bCurrentHelpScreenActiveSubPage = ( gHelpScreen.bNumberOfButtons == 0 ) ? 0: gHelpScreen.bNumberOfButtons -1;
  1070. }
  1071. //if we are selecting the current su page, exit
  1072. else if( bNewPage == gHelpScreen.bCurrentHelpScreenActiveSubPage )
  1073. {
  1074. return;
  1075. }
  1076. //else assign the new subpage
  1077. else
  1078. {
  1079. gHelpScreen.bCurrentHelpScreenActiveSubPage = bNewPage;
  1080. }
  1081. //refresh the screen
  1082. gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_TEXT;
  1083. //'undepress' all the buttons
  1084. for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
  1085. {
  1086. ButtonList[ guiHelpScreenBtns[i] ]->uiFlags &= (~BUTTON_CLICKED_ON );
  1087. }
  1088. //depress the proper button
  1089. ButtonList[ guiHelpScreenBtns[ gHelpScreen.bCurrentHelpScreenActiveSubPage ] ]->uiFlags |= BUTTON_CLICKED_ON;
  1090. //change the current sub page, and render it to the buffer
  1091. ChangeHelpScreenSubPage();
  1092. }
  1093. void GetHelpScreenText( UINT32 uiRecordToGet, STR16 pText )
  1094. {
  1095. INT32 iStartLoc = -1;
  1096. iStartLoc = HELPSCREEN_RECORD_SIZE * uiRecordToGet;
  1097. LoadEncryptedDataFromFile(HELPSCREEN_FILE, pText, iStartLoc, HELPSCREEN_RECORD_SIZE );
  1098. }
  1099. //returns the number of vertical pixels printed
  1100. UINT16 GetAndDisplayHelpScreenText( UINT32 uiRecord, UINT16 usPosX, UINT16 usPosY, UINT16 usWidth )
  1101. {
  1102. CHAR16 zText[1024];
  1103. UINT16 usNumVertPixels = 0;
  1104. UINT32 uiStartLoc;
  1105. SetFontShadow( NO_SHADOW );
  1106. GetHelpScreenText( uiRecord, zText );
  1107. //Get the record
  1108. uiStartLoc = HELPSCREEN_RECORD_SIZE * uiRecord;
  1109. LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, uiStartLoc, HELPSCREEN_RECORD_SIZE );
  1110. //Display the text
  1111. usNumVertPixels = IanDisplayWrappedString( usPosX, usPosY, usWidth, HELP_SCREEN_GAP_BTN_LINES,
  1112. HELP_SCREEN_TEXT_BODY_FONT, HELP_SCREEN_TEXT_BODY_COLOR, zText,
  1113. HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
  1114. SetFontShadow( DEFAULT_SHADOW );
  1115. return( usNumVertPixels );
  1116. }
  1117. void BtnHelpScreenDontShowHelpAgainCallback( GUI_BUTTON *btn, INT32 reason )
  1118. {
  1119. // UINT8 ubButton = (UINT8)MSYS_GetBtnUserData( btn, 0 );
  1120. if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  1121. {
  1122. }
  1123. else if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  1124. {
  1125. /*
  1126. btn->uiFlags &= ~BUTTON_CLICKED_ON;
  1127. if( gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen & ( 1 << gHelpScreen.bCurrentHelpScreen ) )
  1128. {
  1129. //
  1130. gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen &= ~( 1 << gHelpScreen.bCurrentHelpScreen );
  1131. }
  1132. else
  1133. {
  1134. // gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen |= ( 1 << gHelpScreen.bCurrentHelpScreen );
  1135. }
  1136. // btn->uiFlags |= BUTTON_CLICKED_ON;
  1137. */
  1138. }
  1139. }
  1140. /*
  1141. void HelpScreenDontShowHelpAgainToggleTextRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason )
  1142. {
  1143. if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
  1144. {
  1145. InvalidateRegion(pRegion->RegionTopLeftX, pRegion->RegionTopLeftY, pRegion->RegionBottomRightX, pRegion->RegionBottomRightY);
  1146. }
  1147. else if( iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  1148. {
  1149. if( gGameSettings.fOptions[ ubButton ] )
  1150. {
  1151. }
  1152. else
  1153. {
  1154. }
  1155. }
  1156. }
  1157. */
  1158. //set the fact the we have chmaged to a new screen
  1159. void NewScreenSoResetHelpScreen( )
  1160. {
  1161. gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = FALSE;
  1162. gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount = 0;
  1163. }
  1164. void BtnHelpScreenExitCallback(GUI_BUTTON *btn,INT32 reason)
  1165. {
  1166. if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  1167. {
  1168. btn->uiFlags |= BUTTON_CLICKED_ON;
  1169. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1170. }
  1171. if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  1172. {
  1173. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1174. PrepareToExitHelpScreen();
  1175. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  1176. }
  1177. if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
  1178. {
  1179. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  1180. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1181. }
  1182. }
  1183. UINT16 RenderLaptopHelpScreen()
  1184. {
  1185. UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
  1186. UINT8 ubCnt;
  1187. UINT16 usTotalNumberOfVerticalPixels=0;
  1188. UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  1189. if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
  1190. {
  1191. return( 0 );
  1192. }
  1193. //Get the position for the text
  1194. GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
  1195. //switch on the current screen
  1196. switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
  1197. {
  1198. case HLP_SCRN_LPTP_OVERVIEW:
  1199. //Display all the paragraphs
  1200. for( ubCnt=0; ubCnt<2; ubCnt++ )
  1201. {
  1202. //Display the text, and get the number of pixels it used to display it
  1203. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
  1204. //move the next text down by the right amount
  1205. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1206. //add the total amount of pixels used
  1207. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1208. }
  1209. /*
  1210. //Display the first paragraph
  1211. usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_OVERVIEW_P1, usPosX, usPosY, usWidth );
  1212. usPosY = usPosY+ usNumVertPixels + GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  1213. //Display the second paragraph
  1214. usTotalNumberOfVerticalPixels += GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_OVERVIEW_P2, usPosX, usPosY, usWidth );
  1215. */
  1216. break;
  1217. case HLP_SCRN_LPTP_EMAIL:
  1218. //Display the first paragraph
  1219. usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_EMAIL_P1, usPosX, usPosY, usWidth );
  1220. break;
  1221. case HLP_SCRN_LPTP_WEB:
  1222. //Display the first paragraph
  1223. usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_WEB_P1, usPosX, usPosY, usWidth );
  1224. break;
  1225. case HLP_SCRN_LPTP_FILES:
  1226. //Display the first paragraph
  1227. usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_FILES_P1, usPosX, usPosY, usWidth );
  1228. break;
  1229. case HLP_SCRN_LPTP_HISTORY:
  1230. //Display the first paragraph
  1231. usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_HISTORY_P1, usPosX, usPosY, usWidth );
  1232. break;
  1233. case HLP_SCRN_LPTP_PERSONNEL:
  1234. //Display the first paragraph
  1235. usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_PERSONNEL_P1, usPosX, usPosY, usWidth );
  1236. break;
  1237. case HLP_SCRN_LPTP_FINANCIAL:
  1238. //Display all the paragraphs
  1239. for( ubCnt=0; ubCnt<2; ubCnt++ )
  1240. {
  1241. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_FINANCES_P1+ubCnt, usPosX, usPosY, usWidth );
  1242. //move the next text down by the right amount
  1243. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1244. //add the total amount of pixels used
  1245. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1246. }
  1247. break;
  1248. case HLP_SCRN_LPTP_MERC_STATS:
  1249. //Display all the paragraphs
  1250. for( ubCnt=0; ubCnt<15; ubCnt++ )
  1251. {
  1252. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_MERC_STATS_P1+ubCnt, usPosX, usPosY, usWidth );
  1253. //move the next text down by the right amount
  1254. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1255. //add the total amount of pixels used
  1256. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1257. }
  1258. break;
  1259. }
  1260. return( usTotalNumberOfVerticalPixels );
  1261. }
  1262. UINT16 RenderMapScreenNoOneHiredYetHelpScreen()
  1263. {
  1264. UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
  1265. UINT8 ubCnt;
  1266. UINT16 usTotalNumberOfVerticalPixels=0;
  1267. UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  1268. if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
  1269. {
  1270. return( 0 );
  1271. }
  1272. //Get the position for the text
  1273. GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
  1274. //switch on the current screen
  1275. switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
  1276. {
  1277. case HLP_SCRN_NO_ONE_HIRED:
  1278. //Display all the paragraphs
  1279. for( ubCnt=0; ubCnt<2; ubCnt++ )
  1280. {
  1281. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_MPSCRN_NO_1_HIRED_YET_P1+ubCnt, usPosX, usPosY, usWidth );
  1282. //move the next text down by the right amount
  1283. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1284. //add the total amount of pixels used
  1285. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1286. }
  1287. break;
  1288. }
  1289. return( usTotalNumberOfVerticalPixels );
  1290. }
  1291. UINT16 RenderMapScreenNotYetInArulcoHelpScreen()
  1292. {
  1293. UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
  1294. UINT8 ubCnt;
  1295. UINT16 usTotalNumberOfVerticalPixels=0;
  1296. UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  1297. if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
  1298. {
  1299. return( 0 );
  1300. }
  1301. //Get the position for the text
  1302. GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
  1303. //switch on the current screen
  1304. switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
  1305. {
  1306. case HLP_SCRN_NOT_IN_ARULCO:
  1307. //Display all the paragraphs
  1308. for( ubCnt=0; ubCnt<3; ubCnt++ )
  1309. {
  1310. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_MPSCRN_NOT_IN_ARULCO_P1+ubCnt, usPosX, usPosY, usWidth );
  1311. //move the next text down by the right amount
  1312. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1313. //add the total amount of pixels used
  1314. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1315. }
  1316. break;
  1317. }
  1318. return( usTotalNumberOfVerticalPixels );
  1319. }
  1320. UINT16 RenderMapScreenSectorInventoryHelpScreen()
  1321. {
  1322. UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
  1323. UINT8 ubCnt;
  1324. UINT16 usTotalNumberOfVerticalPixels=0;
  1325. UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  1326. if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
  1327. {
  1328. return( 0 );
  1329. }
  1330. //Get the position for the text
  1331. GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
  1332. //switch on the current screen
  1333. switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
  1334. {
  1335. case HLP_SCRN_MPSCRN_SCTR_OVERVIEW:
  1336. //Display all the paragraphs
  1337. for( ubCnt=0; ubCnt<2; ubCnt++ )
  1338. {
  1339. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_SECTOR_INVTRY_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
  1340. //move the next text down by the right amount
  1341. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1342. //add the total amount of pixels used
  1343. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1344. }
  1345. break;
  1346. }
  1347. return( usTotalNumberOfVerticalPixels );
  1348. }
  1349. UINT16 RenderTacticalHelpScreen()
  1350. {
  1351. UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
  1352. UINT8 ubCnt;
  1353. UINT16 usTotalNumberOfVerticalPixels=0;
  1354. UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  1355. if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
  1356. {
  1357. return( 0 );
  1358. }
  1359. //Get the position for the text
  1360. GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
  1361. //switch on the current screen
  1362. switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
  1363. {
  1364. case HLP_SCRN_TACTICAL_OVERVIEW:
  1365. //Display all the paragraph
  1366. for( ubCnt=0; ubCnt<4; ubCnt++ )
  1367. {
  1368. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
  1369. //move the next text down by the right amount
  1370. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1371. //add the total amount of pixels used
  1372. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1373. }
  1374. break;
  1375. case HLP_SCRN_TACTICAL_MOVEMENT:
  1376. //Display all the paragraphs
  1377. for( ubCnt=0; ubCnt<4; ubCnt++ )
  1378. {
  1379. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_MOVEMENT_P1+ubCnt, usPosX, usPosY, usWidth );
  1380. //move the next text down by the right amount
  1381. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1382. //add the total amount of pixels used
  1383. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1384. }
  1385. break;
  1386. case HLP_SCRN_TACTICAL_SIGHT:
  1387. //Display all the paragraphs
  1388. for( ubCnt=0; ubCnt<4; ubCnt++ )
  1389. {
  1390. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_SIGHT_P1+ubCnt, usPosX, usPosY, usWidth );
  1391. //move the next text down by the right amount
  1392. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1393. //add the total amount of pixels used
  1394. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1395. }
  1396. break;
  1397. case HLP_SCRN_TACTICAL_ATTACKING:
  1398. //Display all the paragraphs
  1399. for( ubCnt=0; ubCnt<3; ubCnt++ )
  1400. {
  1401. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_ATTACKING_P1+ubCnt, usPosX, usPosY, usWidth );
  1402. //move the next text down by the right amount
  1403. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1404. //add the total amount of pixels used
  1405. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1406. }
  1407. break;
  1408. case HLP_SCRN_TACTICAL_ITEMS:
  1409. //Display all the paragraphs
  1410. for( ubCnt=0; ubCnt<4; ubCnt++ )
  1411. {
  1412. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_ITEMS_P1+ubCnt, usPosX, usPosY, usWidth );
  1413. //move the next text down by the right amount
  1414. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1415. //add the total amount of pixels used
  1416. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1417. }
  1418. break;
  1419. case HLP_SCRN_TACTICAL_KEYBOARD:
  1420. //Display all the paragraphs
  1421. for( ubCnt=0; ubCnt<8; ubCnt++ )
  1422. {
  1423. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_KEYBOARD_P1+ubCnt, usPosX, usPosY, usWidth );
  1424. //move the next text down by the right amount
  1425. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1426. //add the total amount of pixels used
  1427. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1428. }
  1429. break;
  1430. }
  1431. return( usTotalNumberOfVerticalPixels );
  1432. }
  1433. UINT16 RenderMapScreenHelpScreen()
  1434. {
  1435. UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
  1436. UINT8 ubCnt;
  1437. UINT16 usTotalNumberOfVerticalPixels=0;
  1438. UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
  1439. if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
  1440. {
  1441. return( 0 );
  1442. }
  1443. //Get the position for the text
  1444. GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
  1445. //switch on the current screen
  1446. switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
  1447. {
  1448. case HLP_SCRN_MPSCRN_OVERVIEW:
  1449. //Display all the paragraph
  1450. for( ubCnt=0; ubCnt<3; ubCnt++ )
  1451. {
  1452. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
  1453. //move the next text down by the right amount
  1454. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1455. //add the total amount of pixels used
  1456. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1457. }
  1458. break;
  1459. case HLP_SCRN_MPSCRN_ASSIGNMENTS:
  1460. //Display all the paragraphs
  1461. for( ubCnt=0; ubCnt<4; ubCnt++ )
  1462. {
  1463. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_ASSNMNT_P1+ubCnt, usPosX, usPosY, usWidth );
  1464. //move the next text down by the right amount
  1465. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1466. //add the total amount of pixels used
  1467. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1468. }
  1469. break;
  1470. case HLP_SCRN_MPSCRN_DESTINATIONS:
  1471. //Display all the paragraphs
  1472. for( ubCnt=0; ubCnt<5; ubCnt++ )
  1473. {
  1474. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_DSTINATION_P1+ubCnt, usPosX, usPosY, usWidth );
  1475. //move the next text down by the right amount
  1476. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1477. //add the total amount of pixels used
  1478. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1479. }
  1480. break;
  1481. case HLP_SCRN_MPSCRN_MAP:
  1482. //Display all the paragraphs
  1483. for( ubCnt=0; ubCnt<3; ubCnt++ )
  1484. {
  1485. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_MAP_P1+ubCnt, usPosX, usPosY, usWidth );
  1486. //move the next text down by the right amount
  1487. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1488. //add the total amount of pixels used
  1489. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1490. }
  1491. break;
  1492. case HLP_SCRN_MPSCRN_MILITIA:
  1493. //Display all the paragraphs
  1494. for( ubCnt=0; ubCnt<3; ubCnt++ )
  1495. {
  1496. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_MILITIA_P1+ubCnt, usPosX, usPosY, usWidth );
  1497. //move the next text down by the right amount
  1498. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1499. //add the total amount of pixels used
  1500. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1501. }
  1502. break;
  1503. case HLP_SCRN_MPSCRN_AIRSPACE:
  1504. //Display all the paragraphs
  1505. for( ubCnt=0; ubCnt<2; ubCnt++ )
  1506. {
  1507. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_AIRSPACE_P1+ubCnt, usPosX, usPosY, usWidth );
  1508. //move the next text down by the right amount
  1509. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1510. //add the total amount of pixels used
  1511. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1512. }
  1513. break;
  1514. case HLP_SCRN_MPSCRN_ITEMS:
  1515. //Display all the paragraphs
  1516. for( ubCnt=0; ubCnt<1; ubCnt++ )
  1517. {
  1518. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_ITEMS_P1+ubCnt, usPosX, usPosY, usWidth );
  1519. //move the next text down by the right amount
  1520. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1521. //add the total amount of pixels used
  1522. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1523. }
  1524. break;
  1525. case HLP_SCRN_MPSCRN_KEYBOARD:
  1526. //Display all the paragraphs
  1527. for( ubCnt=0; ubCnt<4; ubCnt++ )
  1528. {
  1529. usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_KEYBOARD_P1+ubCnt, usPosX, usPosY, usWidth );
  1530. //move the next text down by the right amount
  1531. usPosY = usPosY+ usNumVertPixels + usFontHeight;
  1532. //add the total amount of pixels used
  1533. usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
  1534. }
  1535. break;
  1536. }
  1537. return( usTotalNumberOfVerticalPixels );
  1538. }
  1539. void RefreshAllHelpScreenButtons()
  1540. {
  1541. UINT8 i;
  1542. //loop through all the buttons, and refresh them
  1543. for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
  1544. {
  1545. ButtonList[ guiHelpScreenBtns[i] ]->uiFlags |= BUTTON_DIRTY;
  1546. }
  1547. ButtonList[ guiHelpScreenExitBtn ]->uiFlags |= BUTTON_DIRTY;
  1548. if( !gHelpScreen.fForceHelpScreenToComeUp )
  1549. {
  1550. ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags |= BUTTON_DIRTY;
  1551. }
  1552. ButtonList[ giHelpScreenScrollArrows[0] ]->uiFlags |= BUTTON_DIRTY;
  1553. ButtonList[ giHelpScreenScrollArrows[1] ]->uiFlags |= BUTTON_DIRTY;
  1554. }
  1555. INT8 HelpScreenDetermineWhichMapScreenHelpToShow()
  1556. {
  1557. if( fShowMapInventoryPool )
  1558. {
  1559. return( HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY );
  1560. }
  1561. if( AnyMercsHired() == FALSE )
  1562. {
  1563. return( HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED );
  1564. }
  1565. if( gTacticalStatus.fDidGameJustStart )
  1566. {
  1567. return( HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO );
  1568. }
  1569. return( HELP_SCREEN_MAPSCREEN );
  1570. }
  1571. BOOLEAN CreateHelpScreenTextBuffer()
  1572. {
  1573. VSURFACE_DESC vs_desc;
  1574. // Create a background video surface to blt the face onto
  1575. vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
  1576. vs_desc.usWidth = HLP_SCRN__WIDTH_OF_TEXT_BUFFER;
  1577. vs_desc.usHeight = HLP_SCRN__HEIGHT_OF_TEXT_BUFFER;
  1578. vs_desc.ubBitDepth = 16;
  1579. CHECKF( AddVideoSurface( &vs_desc, &guiHelpScreenTextBufferSurface) );
  1580. return( TRUE );
  1581. }
  1582. void DestroyHelpScreenTextBuffer()
  1583. {
  1584. DeleteVideoSurfaceFromIndex( guiHelpScreenTextBufferSurface );
  1585. }
  1586. void RenderCurrentHelpScreenTextToBuffer()
  1587. {
  1588. //clear the buffer ( use 0, black as a transparent color
  1589. ClearHelpScreenTextBuffer();
  1590. //Render the current screen, and get the number of pixels it used to display
  1591. gHelpScreen.usTotalNumberOfPixelsInBuffer = RenderSpecificHelpScreen();
  1592. //calc the number of lines in the buffer
  1593. gHelpScreen.usTotalNumberOfLinesInBuffer = gHelpScreen.usTotalNumberOfPixelsInBuffer / ( HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER );
  1594. }
  1595. void RenderTextBufferToScreen()
  1596. {
  1597. HVSURFACE hDestVSurface, hSrcVSurface;
  1598. SGPRect SrcRect;
  1599. GetVideoSurface( &hDestVSurface, guiRENDERBUFFER );
  1600. GetVideoSurface( &hSrcVSurface, guiHelpScreenTextBufferSurface );
  1601. SrcRect.iLeft = 0;
  1602. SrcRect.iTop = gHelpScreen.iLineAtTopOfTextBuffer * HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER;
  1603. SrcRect.iRight = HLP_SCRN__WIDTH_OF_TEXT_BUFFER;
  1604. SrcRect.iBottom = SrcRect.iTop + HLP_SCRN__HEIGHT_OF_TEXT_AREA - ( 2 * 8 );
  1605. BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, gHelpScreen.usLeftMarginPosX, ( gHelpScreen.usScreenLocY + HELP_SCREEN_TEXT_OFFSET_Y ), (RECT*)&SrcRect );
  1606. DisplayHelpScreenTextBufferScrollBox();
  1607. }
  1608. void ChangeHelpScreenSubPage()
  1609. {
  1610. //reset
  1611. gHelpScreen.iLineAtTopOfTextBuffer = 0;
  1612. RenderCurrentHelpScreenTextToBuffer();
  1613. //enable or disable the help screen arrow buttons
  1614. if( gHelpScreen.usTotalNumberOfLinesInBuffer <= HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER )
  1615. {
  1616. DisableButton( giHelpScreenScrollArrows[0] );
  1617. DisableButton( giHelpScreenScrollArrows[1] );
  1618. }
  1619. else
  1620. {
  1621. EnableButton( giHelpScreenScrollArrows[0] );
  1622. EnableButton( giHelpScreenScrollArrows[1] );
  1623. }
  1624. }
  1625. void ClearHelpScreenTextBuffer()
  1626. {
  1627. UINT32 uiDestPitchBYTES;
  1628. UINT8 *pDestBuf;
  1629. // CLEAR THE FRAME BUFFER
  1630. pDestBuf = LockVideoSurface( guiHelpScreenTextBufferSurface, &uiDestPitchBYTES );
  1631. memset(pDestBuf, 0, HLP_SCRN__HEIGHT_OF_TEXT_BUFFER * uiDestPitchBYTES );
  1632. UnLockVideoSurface( guiHelpScreenTextBufferSurface );
  1633. InvalidateScreen( );
  1634. }
  1635. // - is up, + is down
  1636. void ChangeTopLineInTextBufferByAmount( INT32 iAmouontToMove )
  1637. {
  1638. //if we are moving up
  1639. if( iAmouontToMove < 0 )
  1640. {
  1641. if( gHelpScreen.iLineAtTopOfTextBuffer + iAmouontToMove >= 0 )
  1642. {
  1643. //if we can move up by the requested amount
  1644. if( ( gHelpScreen.usTotalNumberOfLinesInBuffer - gHelpScreen.iLineAtTopOfTextBuffer ) > iAmouontToMove )
  1645. {
  1646. gHelpScreen.iLineAtTopOfTextBuffer += iAmouontToMove;
  1647. }
  1648. //else, trying to move past the top
  1649. else
  1650. {
  1651. gHelpScreen.iLineAtTopOfTextBuffer = 0;
  1652. }
  1653. }
  1654. else
  1655. {
  1656. gHelpScreen.iLineAtTopOfTextBuffer = 0;
  1657. }
  1658. }
  1659. //else we are moving down
  1660. else
  1661. {
  1662. //if we dont have to scroll cause there is not enough text
  1663. if( gHelpScreen.usTotalNumberOfLinesInBuffer <= HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER )
  1664. {
  1665. gHelpScreen.iLineAtTopOfTextBuffer = 0;
  1666. }
  1667. else
  1668. {
  1669. if( ( gHelpScreen.iLineAtTopOfTextBuffer + HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER + iAmouontToMove ) <= gHelpScreen.usTotalNumberOfLinesInBuffer )
  1670. {
  1671. gHelpScreen.iLineAtTopOfTextBuffer += iAmouontToMove;
  1672. }
  1673. else
  1674. {
  1675. gHelpScreen.iLineAtTopOfTextBuffer = gHelpScreen.usTotalNumberOfLinesInBuffer - HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER;
  1676. }
  1677. }
  1678. }
  1679. // RenderCurrentHelpScreenTextToBuffer();
  1680. gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_TEXT;
  1681. }
  1682. void DisplayHelpScreenTextBufferScrollBox()
  1683. {
  1684. INT32 iSizeOfBox;
  1685. INT32 iTopPosScrollBox=0;
  1686. UINT8 *pDestBuf;
  1687. UINT32 uiDestPitchBYTES;
  1688. UINT16 usPosX;
  1689. if( gHelpScreen.bNumberOfButtons != 0 )
  1690. {
  1691. usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX + HELP_SCREEN_BUTTON_BORDER_WIDTH;
  1692. }
  1693. else
  1694. {
  1695. usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX;
  1696. }
  1697. //
  1698. //first calculate the height of the scroll box
  1699. //
  1700. CalculateHeightAndPositionForHelpScreenScrollBox( &iSizeOfBox, &iTopPosScrollBox );
  1701. //
  1702. // next draw the box
  1703. //
  1704. //if there ARE scroll bars, draw the
  1705. if( !( gHelpScreen.usTotalNumberOfLinesInBuffer <= HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER ) )
  1706. {
  1707. ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, iTopPosScrollBox, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox+iSizeOfBox-1, Get16BPPColor( FROMRGB( 227, 198, 88 ) ) );
  1708. //display the line
  1709. pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
  1710. SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, 640, 480);
  1711. // draw the gold highlite line on the top and left
  1712. LineDraw(FALSE, usPosX, iTopPosScrollBox, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox, Get16BPPColor( FROMRGB( 235, 222, 171 ) ), pDestBuf);
  1713. LineDraw(FALSE, usPosX, iTopPosScrollBox, usPosX, iTopPosScrollBox+iSizeOfBox-1, Get16BPPColor( FROMRGB( 235, 222, 171 ) ), pDestBuf);
  1714. // draw the shadow line on the bottom and right
  1715. LineDraw(FALSE, usPosX, iTopPosScrollBox+iSizeOfBox-1, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox+iSizeOfBox-1, Get16BPPColor( FROMRGB( 65, 49, 6 ) ), pDestBuf);
  1716. LineDraw(FALSE, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox+iSizeOfBox-1, Get16BPPColor( FROMRGB( 65, 49, 6 ) ), pDestBuf);
  1717. // unlock frame buffer
  1718. UnLockVideoSurface( FRAME_BUFFER );
  1719. }
  1720. }
  1721. void CreateScrollAreaButtons()
  1722. {
  1723. UINT16 usPosX, usWidth, usPosY;
  1724. INT32 iPosY, iHeight;
  1725. if( gHelpScreen.bNumberOfButtons != 0 )
  1726. {
  1727. usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX + HELP_SCREEN_BUTTON_BORDER_WIDTH;
  1728. }
  1729. else
  1730. {
  1731. usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX;
  1732. }
  1733. usWidth = HLP_SCRN__WIDTH_OF_SCROLL_AREA;
  1734. //Get the height and position of the scroll box
  1735. CalculateHeightAndPositionForHelpScreenScrollBox( &iHeight, &iPosY );
  1736. //Create a mouse region 'mask' the entrire screen
  1737. MSYS_DefineRegion( &gHelpScreenScrollArea, usPosX, (UINT16)iPosY, (UINT16)(usPosX+usWidth), (UINT16)(iPosY+HLP_SCRN__HEIGHT_OF_SCROLL_AREA), MSYS_PRIORITY_HIGHEST,
  1738. gHelpScreen.usCursor, SelectHelpScrollAreaMovementCallBack, SelectHelpScrollAreaCallBack );
  1739. MSYS_AddRegion( &gHelpScreenScrollArea );
  1740. guiHelpScreenScrollArrowImage[ 0 ] = LoadButtonImage( "INTERFACE\\HelpScreen.sti", 14,10, 11, 12 ,13 );
  1741. guiHelpScreenScrollArrowImage[ 1 ] = UseLoadedButtonImage( guiHelpScreenScrollArrowImage[ 0 ] ,19,15,16,17,18 );
  1742. if( gHelpScreen.bNumberOfButtons != 0 )
  1743. usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_UP_ARROW_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
  1744. else
  1745. usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_UP_ARROW_X;
  1746. usPosY = gHelpScreen.usScreenLocY + HLP_SCRN__SCROLL_UP_ARROW_Y;
  1747. //Create the scroll arrows
  1748. giHelpScreenScrollArrows[ 0 ] = QuickCreateButton( guiHelpScreenScrollArrowImage[ 0 ], usPosX, usPosY,
  1749. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  1750. DEFAULT_MOVE_CALLBACK, BtnHelpScreenScrollArrowsCallback );
  1751. MSYS_SetBtnUserData( giHelpScreenScrollArrows[0],0,0);
  1752. SetButtonCursor( giHelpScreenScrollArrows[0], gHelpScreen.usCursor );
  1753. usPosY = gHelpScreen.usScreenLocY + HLP_SCRN__SCROLL_DWN_ARROW_Y;
  1754. //Create the scroll arrows
  1755. giHelpScreenScrollArrows[ 1 ] = QuickCreateButton( guiHelpScreenScrollArrowImage[ 1 ], usPosX, usPosY,
  1756. BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
  1757. DEFAULT_MOVE_CALLBACK, BtnHelpScreenScrollArrowsCallback );
  1758. MSYS_SetBtnUserData( giHelpScreenScrollArrows[1],0,1);
  1759. SetButtonCursor( giHelpScreenScrollArrows[1], gHelpScreen.usCursor );
  1760. }
  1761. void DeleteScrollArrowButtons()
  1762. {
  1763. INT8 i;
  1764. //remove the mouse region that blankets
  1765. MSYS_RemoveRegion( &gHelpScreenScrollArea );
  1766. for( i=0; i<2; i++)
  1767. {
  1768. RemoveButton( giHelpScreenScrollArrows[ i ] );
  1769. UnloadButtonImage( guiHelpScreenScrollArrowImage[ i ] );
  1770. }
  1771. }
  1772. void CalculateHeightAndPositionForHelpScreenScrollBox( INT32 *piHeightOfScrollBox, INT32 *piTopOfScrollBox )
  1773. {
  1774. INT32 iSizeOfBox, iTopPosScrollBox;
  1775. FLOAT dPercentSizeOfBox = 0;
  1776. FLOAT dTemp=0;
  1777. dPercentSizeOfBox = HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER / (FLOAT ) gHelpScreen.usTotalNumberOfLinesInBuffer;
  1778. //if the # is >= 1 then the box is the full size of the scroll area
  1779. if( dPercentSizeOfBox >= 1.0 )
  1780. {
  1781. iSizeOfBox = HLP_SCRN__HEIGHT_OF_SCROLL_AREA;
  1782. //no need to calc the top spot for the box
  1783. iTopPosScrollBox = HLP_SCRN__SCROLL_POSY;
  1784. }
  1785. else
  1786. {
  1787. iSizeOfBox = (INT32)( dPercentSizeOfBox * HLP_SCRN__HEIGHT_OF_SCROLL_AREA + 0.5 );
  1788. //
  1789. //next, calculate the top position of the box
  1790. //
  1791. dTemp = ( HLP_SCRN__HEIGHT_OF_SCROLL_AREA / ( FLOAT ) gHelpScreen.usTotalNumberOfLinesInBuffer ) * gHelpScreen.iLineAtTopOfTextBuffer;
  1792. iTopPosScrollBox = (INT32)( dTemp +.5 ) + HLP_SCRN__SCROLL_POSY;
  1793. }
  1794. if( piHeightOfScrollBox != NULL )
  1795. *piHeightOfScrollBox = iSizeOfBox;
  1796. if( piTopOfScrollBox != NULL )
  1797. *piTopOfScrollBox = iTopPosScrollBox;
  1798. }
  1799. void SelectHelpScrollAreaCallBack(MOUSE_REGION * pRegion, INT32 iReason )
  1800. {
  1801. if (iReason & MSYS_CALLBACK_REASON_INIT)
  1802. {
  1803. }
  1804. else if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
  1805. {
  1806. gfScrollBoxIsScrolling = FALSE;
  1807. gHelpScreen.iLastMouseClickY = -1;
  1808. }
  1809. else if( iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  1810. {
  1811. gfScrollBoxIsScrolling = TRUE;
  1812. HelpScreenMouseMoveScrollBox( pRegion->MouseYPos );
  1813. }
  1814. else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
  1815. {
  1816. }
  1817. }
  1818. void SelectHelpScrollAreaMovementCallBack(MOUSE_REGION * pRegion, INT32 iReason )
  1819. {
  1820. if( iReason & MSYS_CALLBACK_REASON_LOST_MOUSE )
  1821. {
  1822. // InvalidateRegion(pRegion->RegionTopLeftX, pRegion->RegionTopLeftY, pRegion->RegionBottomRightX, pRegion->RegionBottomRightY);
  1823. }
  1824. else if( iReason & MSYS_CALLBACK_REASON_GAIN_MOUSE )
  1825. {
  1826. }
  1827. else if( iReason & MSYS_CALLBACK_REASON_MOVE )
  1828. {
  1829. if( gfLeftButtonState )
  1830. {
  1831. HelpScreenMouseMoveScrollBox( pRegion->MouseYPos );
  1832. }
  1833. }
  1834. }
  1835. void HelpScreenMouseMoveScrollBox( INT32 usMousePosY )
  1836. {
  1837. INT32 iPosY, iHeight;
  1838. INT32 iNumberOfIncrements=0;
  1839. FLOAT dSizeOfIncrement = ( HLP_SCRN__HEIGHT_OF_SCROLL_AREA / ( FLOAT ) gHelpScreen.usTotalNumberOfLinesInBuffer );
  1840. FLOAT dTemp;
  1841. INT32 iNewPosition;
  1842. CalculateHeightAndPositionForHelpScreenScrollBox( &iHeight, &iPosY );
  1843. if( AreWeClickingOnScrollBar( usMousePosY ) || gHelpScreen.iLastMouseClickY != -1 )
  1844. {
  1845. if( gHelpScreen.iLastMouseClickY == -1 )
  1846. gHelpScreen.iLastMouseClickY = usMousePosY;
  1847. if( usMousePosY < gHelpScreen.iLastMouseClickY )
  1848. {
  1849. // iNewPosition = iPosY - ( UINT16)( dSizeOfIncrement + .5);
  1850. iNewPosition = iPosY - ( gHelpScreen.iLastMouseClickY - usMousePosY );
  1851. }
  1852. else if( usMousePosY > gHelpScreen.iLastMouseClickY )
  1853. {
  1854. // iNewPosition = iPosY + ( UINT16)( dSizeOfIncrement + .5);
  1855. iNewPosition = iPosY + usMousePosY - gHelpScreen.iLastMouseClickY;
  1856. }
  1857. else
  1858. {
  1859. return;
  1860. }
  1861. dTemp = ( iNewPosition - iPosY ) / dSizeOfIncrement;
  1862. if( dTemp < 0 )
  1863. iNumberOfIncrements = (INT32)( dTemp - 0.5 );
  1864. else
  1865. iNumberOfIncrements = (INT32)( dTemp + 0.5 );
  1866. gHelpScreen.iLastMouseClickY = usMousePosY;
  1867. // return;
  1868. }
  1869. else
  1870. {
  1871. //if the mouse is higher then the top of the scroll area, set it to the top of the scroll area
  1872. if( usMousePosY < HLP_SCRN__SCROLL_POSY )
  1873. usMousePosY = HLP_SCRN__SCROLL_POSY;
  1874. dTemp = ( usMousePosY - iPosY ) / dSizeOfIncrement;
  1875. if( dTemp < 0 )
  1876. iNumberOfIncrements = (INT32)( dTemp - 0.5 );
  1877. else
  1878. iNumberOfIncrements = (INT32)( dTemp + 0.5 );
  1879. }
  1880. //if there has been a change
  1881. if( iNumberOfIncrements != 0 )
  1882. {
  1883. ChangeTopLineInTextBufferByAmount( iNumberOfIncrements );
  1884. }
  1885. }
  1886. void BtnHelpScreenScrollArrowsCallback(GUI_BUTTON *btn,INT32 reason)
  1887. {
  1888. if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
  1889. {
  1890. btn->uiFlags &= (~BUTTON_CLICKED_ON );
  1891. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1892. }
  1893. if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
  1894. {
  1895. INT32 iButtonID = MSYS_GetBtnUserData( btn, 0);
  1896. btn->uiFlags |= BUTTON_CLICKED_ON;
  1897. //if up
  1898. if( iButtonID == 0 )
  1899. {
  1900. ChangeTopLineInTextBufferByAmount( -1 );
  1901. }
  1902. else
  1903. {
  1904. ChangeTopLineInTextBufferByAmount( 1 );
  1905. }
  1906. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1907. }
  1908. if( reason & MSYS_CALLBACK_REASON_LBUTTON_REPEAT )
  1909. {
  1910. INT32 iButtonID = MSYS_GetBtnUserData( btn, 0);
  1911. //if up
  1912. if( iButtonID == 0 )
  1913. {
  1914. ChangeTopLineInTextBufferByAmount( -1 );
  1915. }
  1916. else
  1917. {
  1918. ChangeTopLineInTextBufferByAmount( 1 );
  1919. }
  1920. InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
  1921. }
  1922. }
  1923. BOOLEAN AreWeClickingOnScrollBar( INT32 usMousePosY )
  1924. {
  1925. INT32 iPosY, iHeight;
  1926. CalculateHeightAndPositionForHelpScreenScrollBox( &iHeight, &iPosY );
  1927. if( usMousePosY >= iPosY && usMousePosY < ( iPosY + iHeight ) )
  1928. return( TRUE );
  1929. else
  1930. return( FALSE );
  1931. }