12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567 |
- #ifdef PRECOMPILEDHEADERS
- #include "JA2 All.h"
- #include "HelpScreen.h"
- #include "HelpScreenText.h"
- #include "Line.h"
- #else
- #include "sgp.h"
- #include "sys globals.h"
- #include "sysutil.h"
- #include "vobject_blitters.h"
- #include "wcheck.h"
- #include "cursors.h"
- #include "font control.h"
- #include "cursor control.h"
- #include "render dirty.h"
- #include "GameScreen.h"
- #include "Text.h"
- #include "Utilities.h"
- #include "WordWrap.h"
- #include "Font Control.h"
- #include "text.h"
- #include "Multi Language Graphic Utils.h"
- #include "HelpScreen.h"
- #include "HelpScreenText.h"
- #include "Line.h"
- #endif
- extern INT16 gsVIEWPORT_END_Y;
- extern void PrintDate( void );
- extern void PrintNumberOnTeam( void );
- extern void PrintBalance( void );
- extern BOOLEAN fMapScreenBottomDirty;
- extern BOOLEAN fCharacterInfoPanelDirty;
- extern BOOLEAN fTeamPanelDirty;
- extern BOOLEAN fMapScreenBottomDirty;
- extern BOOLEAN fMapPanelDirty;
- extern BOOLEAN gfGamePaused;
- extern BOOLEAN fShowMapInventoryPool;
- extern BOOLEAN BltVSurfaceUsingDD( HVSURFACE hDestVSurface, HVSURFACE hSrcVSurface, UINT32 fBltFlags, INT32 iDestX, INT32 iDestY, RECT *SrcRect );
- #define HELP_SCREEN_ACTIVE 0x00000001
- //The defualt size and placement of the screen
- #define HELP_SCREEN_DEFUALT_LOC_X 155
- #define HELP_SCREEN_DEFUALT_LOC_Y 105
- #define HELP_SCREEN_DEFUALT_LOC_WIDTH HELP_SCREEN_SMALL_LOC_WIDTH + HELP_SCREEN_BUTTON_BORDER_WIDTH
- #define HELP_SCREEN_DEFUALT_LOC_HEIGHT 292//300
- #define HELP_SCREEN_BUTTON_BORDER_WIDTH 92
- #define HELP_SCREEN_SMALL_LOC_WIDTH 320
- #define HELP_SCREEN_SMALL_LOC_HEIGHT HELP_SCREEN_DEFUALT_LOC_HEIGHT //224
- #define HELP_SCREEN_BTN_OFFSET_X 11
- #define HELP_SCREEN_BTN_OFFSET_Y 12//50
- #define HELP_SCREEN_BTN_FONT_ON_COLOR 73
- #define HELP_SCREEN_BTN_FONT_OFF_COLOR FONT_MCOLOR_WHITE
- #define HELP_SCREEN_BTN_FONT_BACK_COLOR 50
- #define HELP_SCREEN_BTN_FONT FONT10ARIAL
- #define HELP_SCREEN_BTN_WIDTH 77
- #define HELP_SCREEN_BTN_HEIGHT 22
- #define HELP_SCREEN_GAP_BN_BTNS 8
- #define HELP_SCREEN_MARGIN_SIZE 10
- #define HELP_SCREEN_TEXT_RIGHT_MARGIN_SPACE 36
- #define HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN ( HELP_SCREEN_BUTTON_BORDER_WIDTH + 5 + HELP_SCREEN_MARGIN_SIZE )
- #define HELP_SCREEN_TEXT_LEFT_MARGIN ( 5 + HELP_SCREEN_MARGIN_SIZE )
- #define HELP_SCREEN_TEXT_OFFSET_Y 48
- #define HELP_SCREEN_GAP_BTN_LINES 2
- #define HELP_SCREEN_TITLE_BODY_FONT FONT12ARIAL
- #define HELP_SCREEN_TITLE_BODY_COLOR FONT_MCOLOR_WHITE//FONT_NEARBLACK
- #define HELP_SCREEN_TEXT_BODY_FONT FONT10ARIAL
- #define HELP_SCREEN_TEXT_BODY_COLOR FONT_MCOLOR_WHITE//FONT_NEARBLACK
- #define HELP_SCREEN_TEXT_BACKGROUND 0//NO_SHADOW//FONT_MCOLOR_WHITE
- #define HELP_SCREEN_TITLE_OFFSET_Y 7
- #define HELP_SCREEN_HELP_REMINDER_Y HELP_SCREEN_TITLE_OFFSET_Y + 15
- #define HELP_SCREEN_NUM_BTNS 8
- #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X 4
- #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y 18
- #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_X 25 + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X
- #define HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_Y ( HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y )
- #define HELP_SCREEN_EXIT_BTN_OFFSET_X 291
- #define HELP_SCREEN_EXIT_BTN_LOC_Y 9
- #define HELP_SCREEN_
- //the type of help screen
- #define HLP_SCRN_DEFAULT_TYPE 9
- #define HLP_SCRN_BUTTON_BORDER 8
- //this is the size of the text buffer where everything will be blitted.
- // 2 ( bytest for char ) * width of buffer * height of 1 line * # of text lines
- //#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 )
- #define HLP_SCRN__WIDTH_OF_TEXT_BUFFER 280
- #define HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER 170//100
- #define HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER ( GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT ) + HELP_SCREEN_GAP_BTN_LINES )
- #define HLP_SCRN__MAX_NUMBER_PIXELS_DISPLAYED_IN_TEXT_BUFFER HELP_SCREEN_DEFUALT_LOC_HEIGHT
- #define HLP_SCRN__HEIGHT_OF_TEXT_BUFFER ( HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER * HLP_SCRN__MAX_NUMBER_OF_LINES_IN_BUFFER )
- #define HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER ( HLP_SCRN__HEIGHT_OF_TEXT_AREA / HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER )
- #define HLP_SCRN__HEIGHT_OF_TEXT_AREA 228
- #define HLP_SCRN__HEIGHT_OF_SCROLL_AREA 182
- #define HLP_SCRN__WIDTH_OF_SCROLL_AREA 20
- #define HLP_SCRN__SCROLL_POSX 292
- #define HLP_SCRN__SCROLL_POSY ( gHelpScreen.usScreenLocY + 63 )
- #define HLP_SCRN__SCROLL_UP_ARROW_X 292
- #define HLP_SCRN__SCROLL_UP_ARROW_Y 43
- #define HLP_SCRN__SCROLL_DWN_ARROW_X HLP_SCRN__SCROLL_UP_ARROW_X
- #define HLP_SCRN__SCROLL_DWN_ARROW_Y HLP_SCRN__SCROLL_UP_ARROW_Y + 202
- //enums for the different dirty levels
- enum
- {
- HLP_SCRN_DRTY_LVL_NOT_DIRTY,
- HLP_SCRN_DRTY_LVL_REFRESH_TEXT,
- HLP_SCRN_DRTY_LVL_REFRESH_ALL,
- };
- //new screen:
- enum
- {
- HLP_SCRN_MPSCRN_SCTR_OVERVIEW,
- };
- //mapscreen, welcome to arulco
- enum
- {
- HLP_SCRN_MPSCRN_OVERVIEW,
- HLP_SCRN_MPSCRN_ASSIGNMENTS,
- HLP_SCRN_MPSCRN_DESTINATIONS,
- HLP_SCRN_MPSCRN_MAP,
- HLP_SCRN_MPSCRN_MILITIA,
- HLP_SCRN_MPSCRN_AIRSPACE,
- HLP_SCRN_MPSCRN_ITEMS,
- HLP_SCRN_MPSCRN_KEYBOARD,
- HLP_SCRN_NUM_MPSCRN_BTNS,
- };
- //laptop sub pages
- enum
- {
- HLP_SCRN_LPTP_OVERVIEW,
- HLP_SCRN_LPTP_EMAIL,
- HLP_SCRN_LPTP_WEB,
- HLP_SCRN_LPTP_FILES,
- HLP_SCRN_LPTP_HISTORY,
- HLP_SCRN_LPTP_PERSONNEL,
- HLP_SCRN_LPTP_FINANCIAL,
- HLP_SCRN_LPTP_MERC_STATS,
- HLP_SCRN_LPTP_NUM_PAGES,
- };
- //Mapscreen no one hired yet pages
- enum
- {
- HLP_SCRN_NO_ONE_HIRED,
- HLP_SCRN_NUM_MAPSCREEN_NO_1_HIRED_YET_PAGES,
- };
- //mapscreen no 1 hired yet pages
- enum
- {
- HLP_SCRN_NOT_IN_ARULCO,
- HLP_SCRN_NUM_NOT_IN_ARULCO_PAGES,
- };
- //Tactical
- enum
- {
- HLP_SCRN_TACTICAL_OVERVIEW,
- HLP_SCRN_TACTICAL_MOVEMENT,
- HLP_SCRN_TACTICAL_SIGHT,
- HLP_SCRN_TACTICAL_ATTACKING,
- HLP_SCRN_TACTICAL_ITEMS,
- HLP_SCRN_TACTICAL_KEYBOARD,
- HLP_SCRN_NUM_TACTICAL_PAGES,
- };
- //ddd
- HELP_SCREEN_STRUCT gHelpScreen;
- typedef struct
- {
- INT32 iButtonTextNum[ HELP_SCREEN_NUM_BTNS ];
- } HELP_SCREEN_BTN_TEXT_RECORD;
- //An array of record nums for the text on the help buttons
- HELP_SCREEN_BTN_TEXT_RECORD gHelpScreenBtnTextRecordNum[ HELP_SCREEN_NUMBER_OF_HELP_SCREENS ] =
- {
- //new screen:
- //Laptop button record nums
- // HELP_SCREEN_LAPTOP,
- { HLP_TXT_LAPTOP_BUTTON_1,
- HLP_TXT_LAPTOP_BUTTON_2,
- HLP_TXT_LAPTOP_BUTTON_3,
- HLP_TXT_LAPTOP_BUTTON_4,
- HLP_TXT_LAPTOP_BUTTON_5,
- HLP_TXT_LAPTOP_BUTTON_6,
- HLP_TXT_LAPTOP_BUTTON_7,
- HLP_TXT_LAPTOP_BUTTON_8, },
-
- // HELP_SCREEN_MAPSCREEN,
- { HLP_TXT_WELCOM_TO_ARULCO_BUTTON_1,
- HLP_TXT_WELCOM_TO_ARULCO_BUTTON_2,
- HLP_TXT_WELCOM_TO_ARULCO_BUTTON_3,
- HLP_TXT_WELCOM_TO_ARULCO_BUTTON_4,
- HLP_TXT_WELCOM_TO_ARULCO_BUTTON_5,
- HLP_TXT_WELCOM_TO_ARULCO_BUTTON_6,
- HLP_TXT_WELCOM_TO_ARULCO_BUTTON_7,
- HLP_TXT_WELCOM_TO_ARULCO_BUTTON_8, },
- // HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED,
- { -1, -1, -1, -1, -1, -1, -1, -1, },
- // HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO,
- { -1, -1, -1, -1, -1, -1, -1, -1, },
- // HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY,
- { -1, -1, -1, -1, -1, -1, -1, -1, },
- // HELP_SCREEN_TACTICAL,
- { HLP_TXT_TACTICAL_BUTTON_1,
- HLP_TXT_TACTICAL_BUTTON_2,
- HLP_TXT_TACTICAL_BUTTON_3,
- HLP_TXT_TACTICAL_BUTTON_4,
- HLP_TXT_TACTICAL_BUTTON_5,
- HLP_TXT_TACTICAL_BUTTON_6,
- -1, -1, },
- // HELP_SCREEN_OPTIONS,
- { -1, -1, -1, -1, -1, -1, -1, -1, },
- // HELP_SCREEN_LOAD_GAME,
- { -1, -1, -1, -1, -1, -1, -1, -1, },
- };
- BOOLEAN gfHelpScreenEntry = TRUE;
- BOOLEAN gfHelpScreenExit = FALSE;
- UINT32 guiHelpScreenBackGround;
- UINT32 guiHelpScreenTextBufferSurface;
- BOOLEAN gfScrollBoxIsScrolling = FALSE;
- BOOLEAN gfHaveRenderedFirstFrameToSaveBuffer=FALSE;
- // must use this cause you have ur cursor over a button when entering the help screen, the button will burn though.
- //It does this cause that region loses it focus so it draws the button again.
- UINT8 gubRenderHelpScreenTwiceInaRow=0;
- //mmm
- // region to mask the background
- MOUSE_REGION gHelpScreenFullScreenMask;
- //void SelectHelpTextFullScreenMaskCallBack(MOUSE_REGION * pRegion, INT32 iReason );
- // region to mask the background
- MOUSE_REGION gHelpScreenScrollArea;
- void SelectHelpScrollAreaMovementCallBack( MOUSE_REGION * pRegion, INT32 iReason );
- void SelectHelpScrollAreaCallBack( MOUSE_REGION * pRegion, INT32 iReason );
- // region to mask the background
- MOUSE_REGION gHelpScreenScrollAreaArrows;
- void SelectHelpScrollAreaArrowsCallBack( MOUSE_REGION * pRegion, INT32 iReason );
- //checkbox to toggle show help again toggle
- UINT32 gHelpScreenDontShowHelpAgainToggle;
- void BtnHelpScreenDontShowHelpAgainCallback(GUI_BUTTON *btn,INT32 reason);
- //MOUSE_REGION HelpScreenDontShowHelpAgainToggleTextRegion;
- //void HelpScreenDontShowHelpAgainToggleTextRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason );
- INT32 giHelpScreenButtonsImage[ HELP_SCREEN_NUM_BTNS ];
- UINT32 guiHelpScreenBtns[ HELP_SCREEN_NUM_BTNS ];
- void BtnHelpScreenBtnsCallback(GUI_BUTTON *btn,INT32 reason);
- INT32 giExitBtnImage;
- UINT32 guiHelpScreenExitBtn;
- void BtnHelpScreenExitCallback(GUI_BUTTON *btn,INT32 reason);
- INT32 giHelpScreenScrollArrows[2];
- UINT32 guiHelpScreenScrollArrowImage[2];
- void BtnHelpScreenScrollArrowsCallback(GUI_BUTTON *btn,INT32 reason);
- //ggg
- BOOLEAN EnterHelpScreen();
- void HandleHelpScreen();
- void RenderHelpScreen();
- void ExitHelpScreen();
- void GetHelpScreenUserInput();
- void HelpScreenSpecialExitCode();
- void SetSizeAndPropertiesOfHelpScreen();
- BOOLEAN DrawHelpScreenBackGround();
- void PrepareToExitHelpScreen();
- void SpecialHandlerCode();
- UINT16 RenderSpecificHelpScreen();
- UINT16 RenderLaptopHelpScreen();
- UINT16 RenderTacticalHelpScreen();
- UINT16 RenderMapScreenHelpScreen();
- UINT16 RenderMapScreenNoOneHiredYetHelpScreen();
- UINT16 RenderMapScreenNotYetInArulcoHelpScreen();
- UINT16 RenderMapScreenSectorInventoryHelpScreen();
- void GetHelpScreenTextPositions( UINT16 *pusPosX, UINT16 *pusPosY, UINT16 *pusWidth );
- void DisplayCurrentScreenTitleAndFooter();
- void GetHelpScreenText( UINT32 uiRecordToGet, STR16 pText );
- UINT16 GetAndDisplayHelpScreenText( UINT32 uiRecord, UINT16 usPosX, UINT16 usPosY, UINT16 usWidth );
- void CreateHelpScreenButtons();
- void RefreshAllHelpScreenButtons();
- void RenderTextBufferToScreen();
- void RenderCurrentHelpScreenTextToBuffer();
- void DestroyHelpScreenTextBuffer();
- BOOLEAN CreateHelpScreenTextBuffer();
- void ChangeHelpScreenSubPage();
- void ClearHelpScreenTextBuffer();
- void ChangeTopLineInTextBufferByAmount( INT32 iAmouontToMove );
- void DisplayHelpScreenTextBufferScrollBox();
- void CalculateHeightAndPositionForHelpScreenScrollBox( INT32 *piHeightOfScrollBox, INT32 *iTopOfScrollBox );
- void HelpScreenMouseMoveScrollBox( INT32 usMousePosY );
- void CreateScrollAreaButtons();
- void DeleteScrollArrowButtons();
- void ChangeToHelpScreenSubPage( INT8 bNewPage );
- BOOLEAN AreWeClickingOnScrollBar( INT32 usMousePosY );
- //ppp
- void InitHelpScreenSystem()
- {
- //set some values
- memset( &gHelpScreen, 0, sizeof( gHelpScreen ) );
- //set it up so we can enter the screen
- gfHelpScreenEntry = TRUE;
- gfHelpScreenExit = FALSE;
- gHelpScreen.bCurrentHelpScreenActiveSubPage = -1;
- gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = FALSE;
- }
- BOOLEAN ShouldTheHelpScreenComeUp( UINT8 ubScreenID, BOOLEAN fForceHelpScreenToComeUp )
- {
- //if the screen is being forsced to come up ( user pressed 'h' )
- if( fForceHelpScreenToComeUp )
- {
- //Set thefact that the user broughtthe help screen up
- gHelpScreen.fForceHelpScreenToComeUp = TRUE;
- goto HELP_SCREEN_SHOULD_COME_UP;
- }
- //if we are already in the help system, return true
- if( gHelpScreen.uiFlags & HELP_SCREEN_ACTIVE )
- {
- return( TRUE );
- }
- //has the player been in the screen before
- if( ( gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen >> ubScreenID ) & 0x01 )
- {
- goto HELP_SCREEN_WAIT_1_FRAME;
- }
- //if we have already been in the screen, and the user DIDNT press 'h', leave
- if( gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen )
- {
- return( FALSE );
- }
- //should the screen come up, based on the users choice for it automatically coming up
- // if( !( gHelpScreen.fHideHelpInAllScreens ) )
- {
- // goto HELP_SCREEN_WAIT_1_FRAME;
- }
- //the help screen shouldnt come up
- return( FALSE );
- HELP_SCREEN_WAIT_1_FRAME:
- // we have to wait 1 frame while the screen renders
- if( gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount < 2 )
- {
- gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount += 1;
- UnmarkButtonsDirty( );
- return( FALSE );
- }
- HELP_SCREEN_SHOULD_COME_UP:
-
- //Record which screen it is
- //if its mapscreen
- if( ubScreenID == HELP_SCREEN_MAPSCREEN )
- {
- //determine which screen it is ( is any mercs hired, did game just start )
- gHelpScreen.bCurrentHelpScreen = HelpScreenDetermineWhichMapScreenHelpToShow();
- }
- else
- {
- gHelpScreen.bCurrentHelpScreen = ubScreenID;
- }
- //mark it that the help screnn is enabled
- gHelpScreen.uiFlags |= HELP_SCREEN_ACTIVE;
- // reset
- gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount = 0;
- return( TRUE );
- }
- void HelpScreenHandler()
- {
- //if we are just entering the help screen
- if( gfHelpScreenEntry )
- {
- //setup the help screen
- EnterHelpScreen();
- gfHelpScreenEntry = FALSE;
- gfHelpScreenExit = FALSE;
- }
- RestoreBackgroundRects();
- //get the mouse and keyboard inputs
- GetHelpScreenUserInput();
- //handle the help screen
- HandleHelpScreen();
- //if the help screen is dirty, re-render it
- if( gHelpScreen.ubHelpScreenDirty != HLP_SCRN_DRTY_LVL_NOT_DIRTY )
- {
- //temp
- // gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
- RenderHelpScreen();
- gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_NOT_DIRTY;
- }
- // render buttons marked dirty
- // MarkButtonsDirty( );
- RenderButtons( );
- SaveBackgroundRects( );
- RenderButtonsFastHelp();
- ExecuteBaseDirtyRectQueue();
- EndFrameBufferRender();
- //if we are leaving the help screen
- if( gfHelpScreenExit )
- {
- gfHelpScreenExit = FALSE;
- gfHelpScreenEntry = TRUE;
- //exit mouse regions etc..
- ExitHelpScreen();
- //reset the helpscreen id
- gHelpScreen.bCurrentHelpScreen = -1;
- }
- }
- BOOLEAN EnterHelpScreen()
- {
- VOBJECT_DESC VObjectDesc;
- UINT16 usPosX, usPosY;//, usWidth, usHeight;
- // INT32 iStartLoc;
- // CHAR16 zText[1024];
- //Clear out all the save background rects
- EmptyBackgroundRects( );
-
- UnmarkButtonsDirty( );
- // remeber if the game was paused or not ( so when we exit we know what to do )
- gHelpScreen.fWasTheGamePausedPriorToEnteringHelpScreen = gfGamePaused;
- //pause the game
- PauseGame( );
- //Determine the help screen size, based off the help screen
- SetSizeAndPropertiesOfHelpScreen();
- //Create a mouse region 'mask' the entrire screen
- MSYS_DefineRegion( &gHelpScreenFullScreenMask, 0, 0, 640, 480, MSYS_PRIORITY_HIGHEST,
- gHelpScreen.usCursor, MSYS_NO_CALLBACK, MSYS_NO_CALLBACK );
- MSYS_AddRegion( &gHelpScreenFullScreenMask );
- //Create the exit button
- if( gHelpScreen.bNumberOfButtons != 0 )
- usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_EXIT_BTN_OFFSET_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
- else
- usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_EXIT_BTN_OFFSET_X;
- usPosY = gHelpScreen.usScreenLocY + HELP_SCREEN_EXIT_BTN_LOC_Y;
- //Create the exit buttons
- giExitBtnImage = LoadButtonImage("INTERFACE\\HelpScreen.sti", -1,0,4,2,6 );
- guiHelpScreenExitBtn = CreateIconAndTextButton( giExitBtnImage, L"", HELP_SCREEN_BTN_FONT,
- HELP_SCREEN_BTN_FONT_ON_COLOR, DEFAULT_SHADOW,
- HELP_SCREEN_BTN_FONT_OFF_COLOR, DEFAULT_SHADOW,
- TEXT_CJUSTIFIED,
- usPosX, usPosY, BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
- DEFAULT_MOVE_CALLBACK, BtnHelpScreenExitCallback );
- SetButtonFastHelpText( guiHelpScreenExitBtn, gzHelpScreenText[HLP_SCRN_TXT__EXIT_SCREEN] );
- SetButtonCursor( guiHelpScreenExitBtn, gHelpScreen.usCursor);
- //Create the buttons needed for the screen
- CreateHelpScreenButtons();
- //if there are buttons
- if( gHelpScreen.bNumberOfButtons != 0 )
- usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
- else
- usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_X;
- usPosY = gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight - HELP_SCREEN_SHOW_HELP_AGAIN_REGION_OFFSET_Y;
- if( !gHelpScreen.fForceHelpScreenToComeUp)
- {
- gHelpScreenDontShowHelpAgainToggle = CreateCheckBoxButton( usPosX, (UINT16)(usPosY-3),
- "INTERFACE\\OptionsCheckBoxes.sti", MSYS_PRIORITY_HIGHEST,
- BtnHelpScreenDontShowHelpAgainCallback );
- SetButtonCursor( gHelpScreenDontShowHelpAgainToggle, gHelpScreen.usCursor );
- // Set the state of the chec box
- if( gGameSettings.fHideHelpInAllScreens )
- ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags |= BUTTON_CLICKED_ON;
- else
- ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags &= ~BUTTON_CLICKED_ON;
- }
- /*
- ///creatre a region for the text that says ' [ x ] click to continue seeing ....'
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_CONSTANT_FOOTER;
- LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
- usWidth = StringPixLength( zText, HELP_SCREEN_TEXT_BODY_FONT );
- usHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- /*
- MSYS_DefineRegion( &HelpScreenDontShowHelpAgainToggleTextRegion, usPosX, usPosY, (UINT16)(usPosX+usWidth), (UINT16)(usPosY+usHeight), MSYS_PRIORITY_HIGHEST-1,
- gHelpScreen.usCursor, MSYS_NO_CALLBACK, HelpScreenDontShowHelpAgainToggleTextRegionCallBack );
- MSYS_AddRegion( &HelpScreenDontShowHelpAgainToggleTextRegion );
- */
- // load the help screen background graphic and add it
- VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
- FilenameForBPP("INTERFACE\\HelpScreen.sti", VObjectDesc.ImageFile);
- CHECKF(AddVideoObject(&VObjectDesc, &guiHelpScreenBackGround));
- //create the text buffer
- CreateHelpScreenTextBuffer();
- //make sure we redraw everything
- gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
- //mark it that we have been in since we enter the current screen
- gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = TRUE;
- //set the fact that we have been to the screen
- gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen &= ~( 1 << gHelpScreen.bCurrentHelpScreen );
- //always start at the top
- gHelpScreen.iLineAtTopOfTextBuffer = 0;
- //set it so there was no previous click
- gHelpScreen.iLastMouseClickY = -1;
- //Create the scroll box, and scroll arrow regions/buttons
- CreateScrollAreaButtons();
- //render the active page to the text buffer
- ChangeHelpScreenSubPage();
- //reset scroll box flag
- gfScrollBoxIsScrolling = FALSE;
- //reset first frame buffer
- gfHaveRenderedFirstFrameToSaveBuffer = FALSE;
- gubRenderHelpScreenTwiceInaRow = 0;
- return( TRUE );
- }
- void HandleHelpScreen()
- {
- //if any of the possible screens need to have a some code done every loop.. its done in here
- SpecialHandlerCode();
- if( gfScrollBoxIsScrolling )
- {
- if( gfLeftButtonState )
- {
- HelpScreenMouseMoveScrollBox( gusMouseYPos );
- }
- else
- {
- gfScrollBoxIsScrolling = FALSE;
- gHelpScreen.iLastMouseClickY = -1;
- }
- }
- if( gubRenderHelpScreenTwiceInaRow < 3 )
- {
- //test
- // gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
- gubRenderHelpScreenTwiceInaRow++;
- UnmarkButtonsDirty( );
- }
- // refresh all of help screens buttons
- RefreshAllHelpScreenButtons();
- }
- void RenderHelpScreen()
- {
- //rrr
- if( gfHaveRenderedFirstFrameToSaveBuffer )
- {
- //Restore the background before blitting the text back on
- RestoreExternBackgroundRect( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenWidth, gHelpScreen.usScreenHeight );
- }
- if( gHelpScreen.ubHelpScreenDirty == HLP_SCRN_DRTY_LVL_REFRESH_ALL )
- {
- //Display the helpscreen background
- DrawHelpScreenBackGround();
- //Display the current screens title, and footer info
- DisplayCurrentScreenTitleAndFooter();
- }
- if( !gfHaveRenderedFirstFrameToSaveBuffer )
- {
- gfHaveRenderedFirstFrameToSaveBuffer = TRUE;
- //blit everything to the save buffer ( cause the save buffer can bleed through )
- BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, (UINT16)(gHelpScreen.usScreenLocX+gHelpScreen.usScreenWidth), (UINT16)(gHelpScreen.usScreenLocY+gHelpScreen.usScreenHeight) );
- UnmarkButtonsDirty( );
- }
- //render the text buffer to the screen
- if( gHelpScreen.ubHelpScreenDirty >= HLP_SCRN_DRTY_LVL_REFRESH_TEXT )
- {
- RenderTextBufferToScreen();
- }
- }
- void ExitHelpScreen()
- {
- INT32 i;
- if( !gHelpScreen.fForceHelpScreenToComeUp )
- {
- //Get the current value of the checkbox
- if( ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags & BUTTON_CLICKED_ON )
- {
- gGameSettings.fHideHelpInAllScreens = TRUE;
- gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen = 0;
- }
- else
- {
- gGameSettings.fHideHelpInAllScreens = FALSE;
- }
- //remove the mouse region for the '[ ] dont show help...'
- RemoveButton( gHelpScreenDontShowHelpAgainToggle );
- }
- //mark it that the help screen is not active
- gHelpScreen.uiFlags &= ~HELP_SCREEN_ACTIVE;
- //remove the mouse region that blankets
- MSYS_RemoveRegion( &gHelpScreenFullScreenMask );
- //checkbox to toggle show help again toggle
- // MSYS_RemoveRegion( &HelpScreenDontShowHelpAgainToggleTextRegion );
-
- //remove the hepl graphic
- DeleteVideoObjectFromIndex( guiHelpScreenBackGround );
- //remove the exit button
- RemoveButton( guiHelpScreenExitBtn );
- //if there are any buttons, remove them
- if( gHelpScreen.bNumberOfButtons != 0 )
- {
- for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
- {
- UnloadButtonImage( giHelpScreenButtonsImage[i] );
- RemoveButton( guiHelpScreenBtns[i] );
- }
- }
- //destroy the text buffer for the help screen
- DestroyHelpScreenTextBuffer();
- //Handles the dirtying of any special screen we are about to reenter
- HelpScreenSpecialExitCode();
- //if the game was NOT paused
- if( gHelpScreen.fWasTheGamePausedPriorToEnteringHelpScreen == FALSE )
- {
- //un pause the game
- UnPauseGame( );
- }
- //Delete the scroll box, and scroll arrow regions/buttons
- DeleteScrollArrowButtons();
- //reset
- gHelpScreen.fForceHelpScreenToComeUp = FALSE;
- SaveGameSettings();
- }
- BOOLEAN DrawHelpScreenBackGround()
- {
- HVOBJECT hPixHandle;
- UINT16 usPosX;
- //Get and display the background image
- GetVideoObject(&hPixHandle, guiHelpScreenBackGround );
- usPosX = gHelpScreen.usScreenLocX;
- //if there are buttons, blit the button border
- if( gHelpScreen.bNumberOfButtons != 0 )
- {
- BltVideoObject(FRAME_BUFFER, hPixHandle, HLP_SCRN_BUTTON_BORDER, usPosX, gHelpScreen.usScreenLocY, VO_BLT_SRCTRANSPARENCY,NULL);
- usPosX += HELP_SCREEN_BUTTON_BORDER_WIDTH;
- }
- BltVideoObject(FRAME_BUFFER, hPixHandle, HLP_SCRN_DEFAULT_TYPE, usPosX, gHelpScreen.usScreenLocY, VO_BLT_SRCTRANSPARENCY,NULL);
- InvalidateRegion( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenLocX+gHelpScreen.usScreenWidth, gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight );
- return( TRUE );
- }
- void SetSizeAndPropertiesOfHelpScreen()
- {
- //new screen:
- gHelpScreen.bNumberOfButtons = 0;
- //
- //these are the default settings, so if the screen uses different then defualt, set them in the switch
- //
- {
- gHelpScreen.usScreenWidth = HELP_SCREEN_DEFUALT_LOC_WIDTH;
- gHelpScreen.usScreenHeight = HELP_SCREEN_DEFUALT_LOC_HEIGHT;
- gHelpScreen.usScreenLocX = ( 640 - gHelpScreen.usScreenWidth ) / 2;
- gHelpScreen.usScreenLocY = ( 480 - gHelpScreen.usScreenHeight ) / 2;
- gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
- gHelpScreen.usCursor = CURSOR_NORMAL;
- }
- switch( gHelpScreen.bCurrentHelpScreen )
- {
- case HELP_SCREEN_LAPTOP:
- gHelpScreen.bNumberOfButtons = HLP_SCRN_LPTP_NUM_PAGES;
- gHelpScreen.usCursor = CURSOR_LAPTOP_SCREEN;
- //center the screen inside the laptop screen
- gHelpScreen.usScreenLocX = LAPTOP_SCREEN_UL_X + ( LAPTOP_SCREEN_WIDTH - gHelpScreen.usScreenWidth ) / 2;
- gHelpScreen.usScreenLocY = LAPTOP_SCREEN_UL_Y + ( LAPTOP_SCREEN_HEIGHT - gHelpScreen.usScreenHeight ) / 2;
- break;
- case HELP_SCREEN_MAPSCREEN:
- gHelpScreen.bNumberOfButtons = HLP_SCRN_NUM_MPSCRN_BTNS;
- //calc the center position based on the current panel thats being displayed
- gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
- break;
- case HELP_SCREEN_TACTICAL:
- gHelpScreen.bNumberOfButtons = HLP_SCRN_NUM_TACTICAL_PAGES;
- //calc the center position based on the current panel thats being displayed
- gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
- break;
- case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
- case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
- case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
- gHelpScreen.usScreenWidth = HELP_SCREEN_SMALL_LOC_WIDTH;
- gHelpScreen.usScreenHeight = HELP_SCREEN_SMALL_LOC_HEIGHT;
- //calc screen position since we just set the width and height
- gHelpScreen.usScreenLocX = ( 640 - gHelpScreen.usScreenWidth ) / 2;
- //calc the center position based on the current panel thats being displayed
- gHelpScreen.usScreenLocY = ( gsVIEWPORT_END_Y - gHelpScreen.usScreenHeight ) / 2;
- gHelpScreen.bNumberOfButtons = 0;
- gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
- break;
- case HELP_SCREEN_OPTIONS:
- case HELP_SCREEN_LOAD_GAME:
- break;
- default:
- #ifdef JA2BETAVERSION
- AssertMsg( 0, "Error in help screen. DF 0" );
- #else
- break;
- #endif
- }
- //if there are buttons
- if( gHelpScreen.bNumberOfButtons != 0 )
- gHelpScreen.usLeftMarginPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN;
- else
- gHelpScreen.usLeftMarginPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_TEXT_LEFT_MARGIN;
- }
- void CreateHelpScreenButtons()
- {
- UINT16 usPosX, usPosY;
- CHAR16 sText[1024];
- INT32 i;
- //if there are buttons to create
- if( gHelpScreen.bNumberOfButtons != 0 )
- {
- usPosX = gHelpScreen.usScreenLocX + HELP_SCREEN_BTN_OFFSET_X;
- usPosY = HELP_SCREEN_BTN_OFFSET_Y + gHelpScreen.usScreenLocY;
- //loop through all the buttons, and create them
- for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
- {
- //get the text for the button
- GetHelpScreenText( gHelpScreenBtnTextRecordNum[ gHelpScreen.bCurrentHelpScreen ].iButtonTextNum[i], sText );
- /*
- guiHelpScreenBtns[i] = CreateTextButton( sText, HELP_SCREEN_BTN_FONT, HELP_SCREEN_BTN_FONT_COLOR, HELP_SCREEN_BTN_FONT_BACK_COLOR,
- BUTTON_USE_DEFAULT, usPosX, usPosY, HELP_SCREEN_BTN_WIDTH, HELP_SCREEN_BTN_HEIGHT,
- BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST, BUTTON_NO_CALLBACK, BtnHelpScreenBtnsCallback );
- */
- giHelpScreenButtonsImage[i] = UseLoadedButtonImage( giExitBtnImage, -1,1,5,3,7 );
-
- guiHelpScreenBtns[i] = CreateIconAndTextButton( giHelpScreenButtonsImage[i], sText, HELP_SCREEN_BTN_FONT,
- HELP_SCREEN_BTN_FONT_ON_COLOR, DEFAULT_SHADOW,
- HELP_SCREEN_BTN_FONT_OFF_COLOR, DEFAULT_SHADOW,
- TEXT_CJUSTIFIED,
- usPosX, usPosY, BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
- DEFAULT_MOVE_CALLBACK, BtnHelpScreenBtnsCallback);
- SetButtonCursor( guiHelpScreenBtns[i], gHelpScreen.usCursor);
- MSYS_SetBtnUserData( guiHelpScreenBtns[i], 0, i);
- // SpecifyButtonTextOffsets( guiHelpScreenBtns[i], 19, 9, TRUE );
- usPosY += HELP_SCREEN_BTN_HEIGHT + HELP_SCREEN_GAP_BN_BTNS;
- }
- ButtonList[ guiHelpScreenBtns[0] ]->uiFlags |= BUTTON_CLICKED_ON;
- }
- }
- void GetHelpScreenUserInput()
- {
- InputAtom Event;
- POINT MousePos;
- GetCursorPos(&MousePos);
- while( DequeueEvent( &Event ) )
- {
- // HOOK INTO MOUSE HOOKS
- switch( Event.usEvent)
- {
- case LEFT_BUTTON_DOWN:
- MouseSystemHook(LEFT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
- break;
- case LEFT_BUTTON_UP:
- MouseSystemHook(LEFT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y ,_LeftButtonDown, _RightButtonDown);
- break;
- case RIGHT_BUTTON_DOWN:
- MouseSystemHook(RIGHT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
- break;
- case RIGHT_BUTTON_UP:
- MouseSystemHook(RIGHT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
- break;
- case RIGHT_BUTTON_REPEAT:
- MouseSystemHook(RIGHT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
- break;
- case LEFT_BUTTON_REPEAT:
- MouseSystemHook(LEFT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
- break;
- }
-
- if( !HandleTextInput( &Event ) && Event.usEvent == KEY_UP )
- {
- switch( Event.usParam )
- {
- case ESC:
- PrepareToExitHelpScreen();
- break;
- case DNARROW:
- {
- ChangeTopLineInTextBufferByAmount( 1 );
- }
- break;
- case UPARROW:
- {
- ChangeTopLineInTextBufferByAmount( -1 );
- }
- break;
- case PGUP:
- {
- ChangeTopLineInTextBufferByAmount( -( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
- }
- break;
- case PGDN:
- {
- ChangeTopLineInTextBufferByAmount( ( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
- }
- break;
- case LEFTARROW:
- ChangeToHelpScreenSubPage( (INT8)( gHelpScreen.bCurrentHelpScreenActiveSubPage - 1 ) );
- break;
- case RIGHTARROW:
- ChangeToHelpScreenSubPage( (INT8)( gHelpScreen.bCurrentHelpScreenActiveSubPage + 1 ) );
- break;
- /*
- case LEFTARROW:
- {
- }
- break;
- case RIGHTARROW:
- {
- }
- break;
- */
- #ifdef JA2TESTVERSION
- //rerender the hepl screen
- case 'r':
- gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_ALL;
- break;
- case 'i':
- InvalidateRegion( 0, 0, 640, 480 );
- break;
- case 'd':
- InvalidateRegion( gHelpScreen.usScreenLocX, gHelpScreen.usScreenLocY, gHelpScreen.usScreenLocX+gHelpScreen.usScreenWidth, gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight );
- break;
- #endif
- }
- }
- if( !HandleTextInput( &Event ) && Event.usEvent == KEY_REPEAT )
- {
- switch( Event.usParam )
- {
- case DNARROW:
- {
- ChangeTopLineInTextBufferByAmount( 1 );
- }
- break;
- case UPARROW:
- {
- ChangeTopLineInTextBufferByAmount( -1 );
- }
- break;
- case PGUP:
- {
- ChangeTopLineInTextBufferByAmount( -( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
- }
- break;
- case PGDN:
- {
- ChangeTopLineInTextBufferByAmount( ( HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER -1 ) );
- }
- break;
- }
- }
- }
- }
- //Handles anything spcial that must be done when exiting the specific screen we are about to reenter ( eg. dirtying of the screen )
- void HelpScreenSpecialExitCode()
- {
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreen )
- {
- case HELP_SCREEN_LAPTOP:
- fReDrawScreenFlag = TRUE;
- break;
- case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
- case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
- case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
- case HELP_SCREEN_MAPSCREEN:
- fCharacterInfoPanelDirty = TRUE;
- fTeamPanelDirty = TRUE;
- fMapScreenBottomDirty = TRUE;
- fMapPanelDirty=TRUE;
- break;
- case HELP_SCREEN_TACTICAL:
- fInterfacePanelDirty = DIRTYLEVEL2;
- SetRenderFlags(RENDER_FLAG_FULL);
- break;
- case HELP_SCREEN_OPTIONS:
- break;
- case HELP_SCREEN_LOAD_GAME:
- break;
- default:
- #ifdef JA2BETAVERSION
- AssertMsg( 0, "Error in help screen. DF 0" );
- #else
- break;
- #endif
- }
- }
- void PrepareToExitHelpScreen()
- {
- gfHelpScreenExit = TRUE;
- }
- //Handles anything special that must be done when exiting the specific screen we are about to reenter ( eg. dirtying of the screen )
- void SpecialHandlerCode()
- {
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreen )
- {
- case HELP_SCREEN_LAPTOP:
- PrintDate( );
- PrintBalance( );
- PrintNumberOnTeam( );
- break;
- case HELP_SCREEN_MAPSCREEN:
- break;
- case HELP_SCREEN_TACTICAL:
- break;
- case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
- break;
- case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
- break;
- case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
- break;
- break;
- case HELP_SCREEN_OPTIONS:
- break;
- case HELP_SCREEN_LOAD_GAME:
- break;
- default:
- #ifdef JA2BETAVERSION
- AssertMsg( 0, "Error in help screen: SpecialHandlerCode(). DF 0" );
- #else
- break;
- #endif
- }
- }
- UINT16 RenderSpecificHelpScreen()
- {
- UINT16 usNumVerticalPixelsDisplayed = 0;
- //new screen:
- //set the buffer for the text to go to
- // SetFontDestBuffer( guiHelpScreenTextBufferSurface, gHelpScreen.usLeftMarginPosX, gHelpScreen.usScreenLocY + HELP_SCREEN_TEXT_OFFSET_Y,
- // HLP_SCRN__WIDTH_OF_TEXT_BUFFER, HLP_SCRN__NUMBER_BYTES_IN_TEXT_BUFFER, FALSE );
- SetFontDestBuffer( guiHelpScreenTextBufferSurface, 0, 0,
- HLP_SCRN__WIDTH_OF_TEXT_BUFFER, HLP_SCRN__HEIGHT_OF_TEXT_BUFFER, FALSE );
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreen )
- {
- case HELP_SCREEN_LAPTOP:
- usNumVerticalPixelsDisplayed = RenderLaptopHelpScreen();
- break;
- case HELP_SCREEN_MAPSCREEN:
- usNumVerticalPixelsDisplayed = RenderMapScreenHelpScreen();
- break;
- case HELP_SCREEN_TACTICAL:
- usNumVerticalPixelsDisplayed = RenderTacticalHelpScreen();
- break;
- case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
- usNumVerticalPixelsDisplayed = RenderMapScreenNoOneHiredYetHelpScreen();
- break;
- case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
- usNumVerticalPixelsDisplayed = RenderMapScreenNotYetInArulcoHelpScreen();
- break;
- case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
- usNumVerticalPixelsDisplayed = RenderMapScreenSectorInventoryHelpScreen();
- break;
- case HELP_SCREEN_OPTIONS:
- break;
- case HELP_SCREEN_LOAD_GAME:
- break;
- default:
- #ifdef JA2BETAVERSION
- SetFontDestBuffer( FRAME_BUFFER, 0, 0, 640, 480, FALSE );
- AssertMsg( 0, "Error in help screen: RenderSpecificHelpScreen(). DF 0" );
- #else
- break;
- #endif
- }
- SetFontDestBuffer( FRAME_BUFFER, 0, 0, 640, 480, FALSE );
- //add 1 line to the bottom of the buffer
- usNumVerticalPixelsDisplayed += 10;
- return( usNumVerticalPixelsDisplayed );
- }
- void GetHelpScreenTextPositions( UINT16 *pusPosX, UINT16 *pusPosY, UINT16 *pusWidth )
- {
- //if there are buttons
- if( pusPosX != NULL )
- *pusPosX = 0;
- if( pusWidth != NULL )
- *pusWidth = HLP_SCRN__WIDTH_OF_TEXT_BUFFER - 1 * HELP_SCREEN_MARGIN_SIZE; //DEF was 2
- if( pusPosY != NULL )
- *pusPosY = 0;
- }
- void DisplayCurrentScreenTitleAndFooter()
- {
- INT32 iStartLoc = -1;
- CHAR16 zText[1024];
- UINT16 usPosX=0, usPosY=0, usWidth=0;
- //new screen:
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreen )
- {
- case HELP_SCREEN_LAPTOP:
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_LAPTOP_TITLE;
- break;
- case HELP_SCREEN_MAPSCREEN:
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_WELCOM_TO_ARULCO_TITLE;
- break;
- case HELP_SCREEN_TACTICAL:
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_TACTICAL_TITLE;
- break;
- case HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED:
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_MPSCRN_NO_1_HIRED_YET_TITLE;
- break;
- case HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO:
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_MPSCRN_NOT_IN_ARULCO_TITLE;
- break;
- case HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY:
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_SECTOR_INVTRY_TITLE;
- break;
- case HELP_SCREEN_OPTIONS:
- break;
- case HELP_SCREEN_LOAD_GAME:
- break;
- default:
- #ifdef JA2BETAVERSION
- AssertMsg( 0, "Error in help screen: DisplayCurrentScreenTitleAndFooter(). DF 0" );
- #else
- break;
- #endif
- }
- // GetHelpScreenTextPositions( NULL, NULL, &usWidth );
- if( gHelpScreen.bNumberOfButtons != 0 )
- usWidth = gHelpScreen.usScreenWidth - HELP_SCREEN_TEXT_LEFT_MARGIN_WITH_BTN - HELP_SCREEN_TEXT_RIGHT_MARGIN_SPACE;
- else
- usWidth = gHelpScreen.usScreenWidth - HELP_SCREEN_TEXT_LEFT_MARGIN - HELP_SCREEN_TEXT_RIGHT_MARGIN_SPACE;
- //if this screen has a valid title
- if( iStartLoc != -1 )
- {
- LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
- SetFontShadow( NO_SHADOW );
- usPosX = gHelpScreen.usLeftMarginPosX;
- // DrawTextToScreen( zText, usPosX, (UINT16)(gHelpScreen.usScreenLocY+HELP_SCREEN_TITLE_OFFSET_Y), usWidth,
- // HELP_SCREEN_TITLE_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, HELP_SCREEN_TEXT_BACKGROUND, FALSE, CENTER_JUSTIFIED );
- //Display the Title
- IanDisplayWrappedString( usPosX, (UINT16)(gHelpScreen.usScreenLocY+HELP_SCREEN_TITLE_OFFSET_Y), usWidth, HELP_SCREEN_GAP_BTN_LINES,
- HELP_SCREEN_TITLE_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, zText,
- HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
- }
- //Display the '( press H to get help... )'
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_CONSTANT_SUBTITLE;
- LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
- usPosX = gHelpScreen.usLeftMarginPosX;
- usPosY = gHelpScreen.usScreenLocY+HELP_SCREEN_HELP_REMINDER_Y;
- // DrawTextToScreen( zText, usPosX, usPosY, usWidth,
- // HELP_SCREEN_TEXT_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, HELP_SCREEN_TEXT_BACKGROUND, FALSE, CENTER_JUSTIFIED );
- IanDisplayWrappedString( usPosX, usPosY, usWidth, HELP_SCREEN_GAP_BTN_LINES,
- HELP_SCREEN_TITLE_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, zText,
- HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
- if( !gHelpScreen.fForceHelpScreenToComeUp )
- {
- //calc location for the ' [ x ] Dont display again...'
- iStartLoc = HELPSCREEN_RECORD_SIZE * HLP_TXT_CONSTANT_FOOTER;
- LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, iStartLoc, HELPSCREEN_RECORD_SIZE );
- usPosX = gHelpScreen.usLeftMarginPosX + HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_X;
- usPosY = gHelpScreen.usScreenLocY + gHelpScreen.usScreenHeight - HELP_SCREEN_SHOW_HELP_AGAIN_REGION_TEXT_OFFSET_Y + 2;
- //Display the ' [ x ] Dont display again...'
- IanDisplayWrappedString( usPosX, usPosY, usWidth, HELP_SCREEN_GAP_BTN_LINES,
- HELP_SCREEN_TEXT_BODY_FONT, HELP_SCREEN_TITLE_BODY_COLOR, zText,
- HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
- }
- SetFontShadow( DEFAULT_SHADOW );
- }
- void BtnHelpScreenBtnsCallback(GUI_BUTTON *btn,INT32 reason)
- {
- if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
- {
- // btn->uiFlags |= BUTTON_CLICKED_ON;
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
- {
- //Get the btn id
- INT8 bRetValue = (UINT8)MSYS_GetBtnUserData( btn, 0 );
- ChangeToHelpScreenSubPage( bRetValue );
- /*
- //change the current page to the new one
- gHelpScreen.bCurrentHelpScreenActiveSubPage = ( bRetValue > gHelpScreen.bNumberOfButtons ) ? gHelpScreen.bNumberOfButtons-1 : bRetValue;
- gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_TEXT;
- for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
- {
- ButtonList[ guiHelpScreenBtns[i] ]->uiFlags &= (~BUTTON_CLICKED_ON );
- }
- //change the current sub page, and render it to the buffer
- ChangeHelpScreenSubPage();
- */
- btn->uiFlags |= BUTTON_CLICKED_ON;
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
- {
- // btn->uiFlags &= (~BUTTON_CLICKED_ON );
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- }
- void ChangeToHelpScreenSubPage( INT8 bNewPage )
- {
- INT8 i;
- //if for some reason, we are assigning a lower number
- if( bNewPage < 0 )
- {
- gHelpScreen.bCurrentHelpScreenActiveSubPage = 0;
- }
- //for some reason if the we are passing in a # that is greater then the max, set it to the max
- else if( bNewPage >= gHelpScreen.bNumberOfButtons )
- {
- gHelpScreen.bCurrentHelpScreenActiveSubPage = ( gHelpScreen.bNumberOfButtons == 0 ) ? 0: gHelpScreen.bNumberOfButtons -1;
- }
- //if we are selecting the current su page, exit
- else if( bNewPage == gHelpScreen.bCurrentHelpScreenActiveSubPage )
- {
- return;
- }
- //else assign the new subpage
- else
- {
- gHelpScreen.bCurrentHelpScreenActiveSubPage = bNewPage;
- }
- //refresh the screen
- gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_TEXT;
- //'undepress' all the buttons
- for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
- {
- ButtonList[ guiHelpScreenBtns[i] ]->uiFlags &= (~BUTTON_CLICKED_ON );
- }
- //depress the proper button
- ButtonList[ guiHelpScreenBtns[ gHelpScreen.bCurrentHelpScreenActiveSubPage ] ]->uiFlags |= BUTTON_CLICKED_ON;
- //change the current sub page, and render it to the buffer
- ChangeHelpScreenSubPage();
- }
- void GetHelpScreenText( UINT32 uiRecordToGet, STR16 pText )
- {
- INT32 iStartLoc = -1;
- iStartLoc = HELPSCREEN_RECORD_SIZE * uiRecordToGet;
- LoadEncryptedDataFromFile(HELPSCREEN_FILE, pText, iStartLoc, HELPSCREEN_RECORD_SIZE );
- }
- //returns the number of vertical pixels printed
- UINT16 GetAndDisplayHelpScreenText( UINT32 uiRecord, UINT16 usPosX, UINT16 usPosY, UINT16 usWidth )
- {
- CHAR16 zText[1024];
- UINT16 usNumVertPixels = 0;
- UINT32 uiStartLoc;
- SetFontShadow( NO_SHADOW );
- GetHelpScreenText( uiRecord, zText );
- //Get the record
- uiStartLoc = HELPSCREEN_RECORD_SIZE * uiRecord;
- LoadEncryptedDataFromFile(HELPSCREEN_FILE, zText, uiStartLoc, HELPSCREEN_RECORD_SIZE );
- //Display the text
- usNumVertPixels = IanDisplayWrappedString( usPosX, usPosY, usWidth, HELP_SCREEN_GAP_BTN_LINES,
- HELP_SCREEN_TEXT_BODY_FONT, HELP_SCREEN_TEXT_BODY_COLOR, zText,
- HELP_SCREEN_TEXT_BACKGROUND, FALSE, 0 );
- SetFontShadow( DEFAULT_SHADOW );
- return( usNumVertPixels );
- }
- void BtnHelpScreenDontShowHelpAgainCallback( GUI_BUTTON *btn, INT32 reason )
- {
- // UINT8 ubButton = (UINT8)MSYS_GetBtnUserData( btn, 0 );
- if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
- {
- }
- else if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
- {
- /*
- btn->uiFlags &= ~BUTTON_CLICKED_ON;
- if( gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen & ( 1 << gHelpScreen.bCurrentHelpScreen ) )
- {
- //
- gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen &= ~( 1 << gHelpScreen.bCurrentHelpScreen );
- }
- else
- {
- // gHelpScreen.usHasPlayerSeenHelpScreenInCurrentScreen |= ( 1 << gHelpScreen.bCurrentHelpScreen );
- }
- // btn->uiFlags |= BUTTON_CLICKED_ON;
- */
- }
- }
- /*
- void HelpScreenDontShowHelpAgainToggleTextRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason )
- {
- if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
- {
- InvalidateRegion(pRegion->RegionTopLeftX, pRegion->RegionTopLeftY, pRegion->RegionBottomRightX, pRegion->RegionBottomRightY);
- }
- else if( iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
- {
- if( gGameSettings.fOptions[ ubButton ] )
- {
- }
- else
- {
- }
- }
- }
- */
- //set the fact the we have chmaged to a new screen
- void NewScreenSoResetHelpScreen( )
- {
- gHelpScreen.fHaveAlreadyBeenInHelpScreenSinceEnteringCurrenScreen = FALSE;
- gHelpScreen.bDelayEnteringHelpScreenBy1FrameCount = 0;
- }
- void BtnHelpScreenExitCallback(GUI_BUTTON *btn,INT32 reason)
- {
- if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
- {
- btn->uiFlags |= BUTTON_CLICKED_ON;
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
- {
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- PrepareToExitHelpScreen();
- btn->uiFlags &= (~BUTTON_CLICKED_ON );
- }
- if(reason & MSYS_CALLBACK_REASON_LOST_MOUSE)
- {
- btn->uiFlags &= (~BUTTON_CLICKED_ON );
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- }
- UINT16 RenderLaptopHelpScreen()
- {
- UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
- UINT8 ubCnt;
- UINT16 usTotalNumberOfVerticalPixels=0;
- UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
- {
- return( 0 );
- }
- //Get the position for the text
- GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
- {
- case HLP_SCRN_LPTP_OVERVIEW:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<2; ubCnt++ )
- {
- //Display the text, and get the number of pixels it used to display it
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- /*
- //Display the first paragraph
- usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_OVERVIEW_P1, usPosX, usPosY, usWidth );
- usPosY = usPosY+ usNumVertPixels + GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- //Display the second paragraph
- usTotalNumberOfVerticalPixels += GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_OVERVIEW_P2, usPosX, usPosY, usWidth );
- */
- break;
- case HLP_SCRN_LPTP_EMAIL:
- //Display the first paragraph
- usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_EMAIL_P1, usPosX, usPosY, usWidth );
- break;
- case HLP_SCRN_LPTP_WEB:
- //Display the first paragraph
- usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_WEB_P1, usPosX, usPosY, usWidth );
- break;
- case HLP_SCRN_LPTP_FILES:
- //Display the first paragraph
- usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_FILES_P1, usPosX, usPosY, usWidth );
- break;
- case HLP_SCRN_LPTP_HISTORY:
- //Display the first paragraph
- usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_HISTORY_P1, usPosX, usPosY, usWidth );
- break;
- case HLP_SCRN_LPTP_PERSONNEL:
- //Display the first paragraph
- usTotalNumberOfVerticalPixels = GetAndDisplayHelpScreenText( HLP_TXT_LAPTOP_PERSONNEL_P1, usPosX, usPosY, usWidth );
- break;
- case HLP_SCRN_LPTP_FINANCIAL:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<2; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_FINANCES_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_LPTP_MERC_STATS:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<15; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_MERC_STATS_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- }
- return( usTotalNumberOfVerticalPixels );
- }
- UINT16 RenderMapScreenNoOneHiredYetHelpScreen()
- {
- UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
- UINT8 ubCnt;
- UINT16 usTotalNumberOfVerticalPixels=0;
- UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
- {
- return( 0 );
- }
- //Get the position for the text
- GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
- {
- case HLP_SCRN_NO_ONE_HIRED:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<2; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_MPSCRN_NO_1_HIRED_YET_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- }
- return( usTotalNumberOfVerticalPixels );
- }
- UINT16 RenderMapScreenNotYetInArulcoHelpScreen()
- {
- UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
- UINT8 ubCnt;
- UINT16 usTotalNumberOfVerticalPixels=0;
- UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
- {
- return( 0 );
- }
- //Get the position for the text
- GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
- {
- case HLP_SCRN_NOT_IN_ARULCO:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<3; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_MPSCRN_NOT_IN_ARULCO_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- }
- return( usTotalNumberOfVerticalPixels );
- }
- UINT16 RenderMapScreenSectorInventoryHelpScreen()
- {
- UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
- UINT8 ubCnt;
- UINT16 usTotalNumberOfVerticalPixels=0;
- UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
- {
- return( 0 );
- }
- //Get the position for the text
- GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
- {
- case HLP_SCRN_MPSCRN_SCTR_OVERVIEW:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<2; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_SECTOR_INVTRY_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- }
- return( usTotalNumberOfVerticalPixels );
- }
- UINT16 RenderTacticalHelpScreen()
- {
- UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
- UINT8 ubCnt;
- UINT16 usTotalNumberOfVerticalPixels=0;
- UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
- {
- return( 0 );
- }
- //Get the position for the text
- GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
- {
- case HLP_SCRN_TACTICAL_OVERVIEW:
- //Display all the paragraph
- for( ubCnt=0; ubCnt<4; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_TACTICAL_MOVEMENT:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<4; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_MOVEMENT_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_TACTICAL_SIGHT:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<4; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_SIGHT_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_TACTICAL_ATTACKING:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<3; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_ATTACKING_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_TACTICAL_ITEMS:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<4; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_ITEMS_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_TACTICAL_KEYBOARD:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<8; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_TACTICAL_KEYBOARD_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- }
- return( usTotalNumberOfVerticalPixels );
- }
- UINT16 RenderMapScreenHelpScreen()
- {
- UINT16 usPosX, usPosY, usWidth, usNumVertPixels;
- UINT8 ubCnt;
- UINT16 usTotalNumberOfVerticalPixels=0;
- UINT16 usFontHeight = GetFontHeight( HELP_SCREEN_TEXT_BODY_FONT );
- if( gHelpScreen.bCurrentHelpScreenActiveSubPage == -1 )
- {
- return( 0 );
- }
- //Get the position for the text
- GetHelpScreenTextPositions( &usPosX, &usPosY, &usWidth );
- //switch on the current screen
- switch( gHelpScreen.bCurrentHelpScreenActiveSubPage )
- {
- case HLP_SCRN_MPSCRN_OVERVIEW:
- //Display all the paragraph
- for( ubCnt=0; ubCnt<3; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_OVERVIEW_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_MPSCRN_ASSIGNMENTS:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<4; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_ASSNMNT_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_MPSCRN_DESTINATIONS:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<5; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_DSTINATION_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_MPSCRN_MAP:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<3; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_MAP_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_MPSCRN_MILITIA:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<3; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_MILITIA_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_MPSCRN_AIRSPACE:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<2; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_AIRSPACE_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_MPSCRN_ITEMS:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<1; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_ITEMS_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- case HLP_SCRN_MPSCRN_KEYBOARD:
- //Display all the paragraphs
- for( ubCnt=0; ubCnt<4; ubCnt++ )
- {
- usNumVertPixels = GetAndDisplayHelpScreenText( HLP_TXT_WELCOM_TO_ARULCO_KEYBOARD_P1+ubCnt, usPosX, usPosY, usWidth );
- //move the next text down by the right amount
- usPosY = usPosY+ usNumVertPixels + usFontHeight;
- //add the total amount of pixels used
- usTotalNumberOfVerticalPixels += usNumVertPixels + usFontHeight;
- }
- break;
- }
- return( usTotalNumberOfVerticalPixels );
- }
- void RefreshAllHelpScreenButtons()
- {
- UINT8 i;
- //loop through all the buttons, and refresh them
- for( i=0; i< gHelpScreen.bNumberOfButtons; i++ )
- {
- ButtonList[ guiHelpScreenBtns[i] ]->uiFlags |= BUTTON_DIRTY;
- }
- ButtonList[ guiHelpScreenExitBtn ]->uiFlags |= BUTTON_DIRTY;
-
- if( !gHelpScreen.fForceHelpScreenToComeUp )
- {
- ButtonList[ gHelpScreenDontShowHelpAgainToggle ]->uiFlags |= BUTTON_DIRTY;
- }
- ButtonList[ giHelpScreenScrollArrows[0] ]->uiFlags |= BUTTON_DIRTY;
- ButtonList[ giHelpScreenScrollArrows[1] ]->uiFlags |= BUTTON_DIRTY;
- }
- INT8 HelpScreenDetermineWhichMapScreenHelpToShow()
- {
- if( fShowMapInventoryPool )
- {
- return( HELP_SCREEN_MAPSCREEN_SECTOR_INVENTORY );
- }
- if( AnyMercsHired() == FALSE )
- {
- return( HELP_SCREEN_MAPSCREEN_NO_ONE_HIRED );
- }
- if( gTacticalStatus.fDidGameJustStart )
- {
- return( HELP_SCREEN_MAPSCREEN_NOT_IN_ARULCO );
- }
- return( HELP_SCREEN_MAPSCREEN );
- }
- BOOLEAN CreateHelpScreenTextBuffer()
- {
- VSURFACE_DESC vs_desc;
- // Create a background video surface to blt the face onto
- vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
- vs_desc.usWidth = HLP_SCRN__WIDTH_OF_TEXT_BUFFER;
- vs_desc.usHeight = HLP_SCRN__HEIGHT_OF_TEXT_BUFFER;
- vs_desc.ubBitDepth = 16;
- CHECKF( AddVideoSurface( &vs_desc, &guiHelpScreenTextBufferSurface) );
- return( TRUE );
- }
- void DestroyHelpScreenTextBuffer()
- {
- DeleteVideoSurfaceFromIndex( guiHelpScreenTextBufferSurface );
- }
- void RenderCurrentHelpScreenTextToBuffer()
- {
- //clear the buffer ( use 0, black as a transparent color
- ClearHelpScreenTextBuffer();
- //Render the current screen, and get the number of pixels it used to display
- gHelpScreen.usTotalNumberOfPixelsInBuffer = RenderSpecificHelpScreen();
- //calc the number of lines in the buffer
- gHelpScreen.usTotalNumberOfLinesInBuffer = gHelpScreen.usTotalNumberOfPixelsInBuffer / ( HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER );
- }
- void RenderTextBufferToScreen()
- {
- HVSURFACE hDestVSurface, hSrcVSurface;
- SGPRect SrcRect;
- GetVideoSurface( &hDestVSurface, guiRENDERBUFFER );
- GetVideoSurface( &hSrcVSurface, guiHelpScreenTextBufferSurface );
- SrcRect.iLeft = 0;
- SrcRect.iTop = gHelpScreen.iLineAtTopOfTextBuffer * HLP_SCRN__HEIGHT_OF_1_LINE_IN_BUFFER;
- SrcRect.iRight = HLP_SCRN__WIDTH_OF_TEXT_BUFFER;
- SrcRect.iBottom = SrcRect.iTop + HLP_SCRN__HEIGHT_OF_TEXT_AREA - ( 2 * 8 );
- BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, gHelpScreen.usLeftMarginPosX, ( gHelpScreen.usScreenLocY + HELP_SCREEN_TEXT_OFFSET_Y ), (RECT*)&SrcRect );
- DisplayHelpScreenTextBufferScrollBox();
- }
- void ChangeHelpScreenSubPage()
- {
- //reset
- gHelpScreen.iLineAtTopOfTextBuffer = 0;
- RenderCurrentHelpScreenTextToBuffer();
- //enable or disable the help screen arrow buttons
- if( gHelpScreen.usTotalNumberOfLinesInBuffer <= HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER )
- {
- DisableButton( giHelpScreenScrollArrows[0] );
- DisableButton( giHelpScreenScrollArrows[1] );
- }
- else
- {
- EnableButton( giHelpScreenScrollArrows[0] );
- EnableButton( giHelpScreenScrollArrows[1] );
- }
- }
- void ClearHelpScreenTextBuffer()
- {
- UINT32 uiDestPitchBYTES;
- UINT8 *pDestBuf;
- // CLEAR THE FRAME BUFFER
- pDestBuf = LockVideoSurface( guiHelpScreenTextBufferSurface, &uiDestPitchBYTES );
- memset(pDestBuf, 0, HLP_SCRN__HEIGHT_OF_TEXT_BUFFER * uiDestPitchBYTES );
- UnLockVideoSurface( guiHelpScreenTextBufferSurface );
- InvalidateScreen( );
- }
- // - is up, + is down
- void ChangeTopLineInTextBufferByAmount( INT32 iAmouontToMove )
- {
- //if we are moving up
- if( iAmouontToMove < 0 )
- {
- if( gHelpScreen.iLineAtTopOfTextBuffer + iAmouontToMove >= 0 )
- {
- //if we can move up by the requested amount
- if( ( gHelpScreen.usTotalNumberOfLinesInBuffer - gHelpScreen.iLineAtTopOfTextBuffer ) > iAmouontToMove )
- {
- gHelpScreen.iLineAtTopOfTextBuffer += iAmouontToMove;
- }
- //else, trying to move past the top
- else
- {
- gHelpScreen.iLineAtTopOfTextBuffer = 0;
- }
- }
- else
- {
- gHelpScreen.iLineAtTopOfTextBuffer = 0;
- }
- }
- //else we are moving down
- else
- {
- //if we dont have to scroll cause there is not enough text
- if( gHelpScreen.usTotalNumberOfLinesInBuffer <= HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER )
- {
- gHelpScreen.iLineAtTopOfTextBuffer = 0;
- }
- else
- {
- if( ( gHelpScreen.iLineAtTopOfTextBuffer + HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER + iAmouontToMove ) <= gHelpScreen.usTotalNumberOfLinesInBuffer )
- {
- gHelpScreen.iLineAtTopOfTextBuffer += iAmouontToMove;
- }
- else
- {
- gHelpScreen.iLineAtTopOfTextBuffer = gHelpScreen.usTotalNumberOfLinesInBuffer - HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER;
- }
- }
- }
- // RenderCurrentHelpScreenTextToBuffer();
- gHelpScreen.ubHelpScreenDirty = HLP_SCRN_DRTY_LVL_REFRESH_TEXT;
- }
- void DisplayHelpScreenTextBufferScrollBox()
- {
- INT32 iSizeOfBox;
- INT32 iTopPosScrollBox=0;
- UINT8 *pDestBuf;
- UINT32 uiDestPitchBYTES;
- UINT16 usPosX;
- if( gHelpScreen.bNumberOfButtons != 0 )
- {
- usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX + HELP_SCREEN_BUTTON_BORDER_WIDTH;
- }
- else
- {
- usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX;
- }
- //
- //first calculate the height of the scroll box
- //
- CalculateHeightAndPositionForHelpScreenScrollBox( &iSizeOfBox, &iTopPosScrollBox );
- //
- // next draw the box
- //
- //if there ARE scroll bars, draw the
- if( !( gHelpScreen.usTotalNumberOfLinesInBuffer <= HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER ) )
- {
- ColorFillVideoSurfaceArea( FRAME_BUFFER, usPosX, iTopPosScrollBox, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox+iSizeOfBox-1, Get16BPPColor( FROMRGB( 227, 198, 88 ) ) );
- //display the line
- pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
- SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, 640, 480);
- // draw the gold highlite line on the top and left
- LineDraw(FALSE, usPosX, iTopPosScrollBox, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox, Get16BPPColor( FROMRGB( 235, 222, 171 ) ), pDestBuf);
- LineDraw(FALSE, usPosX, iTopPosScrollBox, usPosX, iTopPosScrollBox+iSizeOfBox-1, Get16BPPColor( FROMRGB( 235, 222, 171 ) ), pDestBuf);
- // draw the shadow line on the bottom and right
- LineDraw(FALSE, usPosX, iTopPosScrollBox+iSizeOfBox-1, usPosX+HLP_SCRN__WIDTH_OF_SCROLL_AREA, iTopPosScrollBox+iSizeOfBox-1, Get16BPPColor( FROMRGB( 65, 49, 6 ) ), pDestBuf);
- 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);
-
- // unlock frame buffer
- UnLockVideoSurface( FRAME_BUFFER );
- }
- }
- void CreateScrollAreaButtons()
- {
- UINT16 usPosX, usWidth, usPosY;
- INT32 iPosY, iHeight;
- if( gHelpScreen.bNumberOfButtons != 0 )
- {
- usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX + HELP_SCREEN_BUTTON_BORDER_WIDTH;
- }
- else
- {
- usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_POSX;
- }
- usWidth = HLP_SCRN__WIDTH_OF_SCROLL_AREA;
- //Get the height and position of the scroll box
- CalculateHeightAndPositionForHelpScreenScrollBox( &iHeight, &iPosY );
- //Create a mouse region 'mask' the entrire screen
- MSYS_DefineRegion( &gHelpScreenScrollArea, usPosX, (UINT16)iPosY, (UINT16)(usPosX+usWidth), (UINT16)(iPosY+HLP_SCRN__HEIGHT_OF_SCROLL_AREA), MSYS_PRIORITY_HIGHEST,
- gHelpScreen.usCursor, SelectHelpScrollAreaMovementCallBack, SelectHelpScrollAreaCallBack );
- MSYS_AddRegion( &gHelpScreenScrollArea );
- guiHelpScreenScrollArrowImage[ 0 ] = LoadButtonImage( "INTERFACE\\HelpScreen.sti", 14,10, 11, 12 ,13 );
- guiHelpScreenScrollArrowImage[ 1 ] = UseLoadedButtonImage( guiHelpScreenScrollArrowImage[ 0 ] ,19,15,16,17,18 );
- if( gHelpScreen.bNumberOfButtons != 0 )
- usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_UP_ARROW_X + HELP_SCREEN_BUTTON_BORDER_WIDTH;
- else
- usPosX = gHelpScreen.usScreenLocX + HLP_SCRN__SCROLL_UP_ARROW_X;
- usPosY = gHelpScreen.usScreenLocY + HLP_SCRN__SCROLL_UP_ARROW_Y;
- //Create the scroll arrows
- giHelpScreenScrollArrows[ 0 ] = QuickCreateButton( guiHelpScreenScrollArrowImage[ 0 ], usPosX, usPosY,
- BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
- DEFAULT_MOVE_CALLBACK, BtnHelpScreenScrollArrowsCallback );
- MSYS_SetBtnUserData( giHelpScreenScrollArrows[0],0,0);
- SetButtonCursor( giHelpScreenScrollArrows[0], gHelpScreen.usCursor );
- usPosY = gHelpScreen.usScreenLocY + HLP_SCRN__SCROLL_DWN_ARROW_Y;
- //Create the scroll arrows
- giHelpScreenScrollArrows[ 1 ] = QuickCreateButton( guiHelpScreenScrollArrowImage[ 1 ], usPosX, usPosY,
- BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST,
- DEFAULT_MOVE_CALLBACK, BtnHelpScreenScrollArrowsCallback );
- MSYS_SetBtnUserData( giHelpScreenScrollArrows[1],0,1);
- SetButtonCursor( giHelpScreenScrollArrows[1], gHelpScreen.usCursor );
- }
- void DeleteScrollArrowButtons()
- {
- INT8 i;
- //remove the mouse region that blankets
- MSYS_RemoveRegion( &gHelpScreenScrollArea );
- for( i=0; i<2; i++)
- {
- RemoveButton( giHelpScreenScrollArrows[ i ] );
- UnloadButtonImage( guiHelpScreenScrollArrowImage[ i ] );
- }
- }
- void CalculateHeightAndPositionForHelpScreenScrollBox( INT32 *piHeightOfScrollBox, INT32 *piTopOfScrollBox )
- {
- INT32 iSizeOfBox, iTopPosScrollBox;
- FLOAT dPercentSizeOfBox = 0;
- FLOAT dTemp=0;
- dPercentSizeOfBox = HLP_SCRN__MAX_NUMBER_DISPLAYED_LINES_IN_BUFFER / (FLOAT ) gHelpScreen.usTotalNumberOfLinesInBuffer;
- //if the # is >= 1 then the box is the full size of the scroll area
- if( dPercentSizeOfBox >= 1.0 )
- {
- iSizeOfBox = HLP_SCRN__HEIGHT_OF_SCROLL_AREA;
- //no need to calc the top spot for the box
- iTopPosScrollBox = HLP_SCRN__SCROLL_POSY;
- }
- else
- {
- iSizeOfBox = (INT32)( dPercentSizeOfBox * HLP_SCRN__HEIGHT_OF_SCROLL_AREA + 0.5 );
- //
- //next, calculate the top position of the box
- //
- dTemp = ( HLP_SCRN__HEIGHT_OF_SCROLL_AREA / ( FLOAT ) gHelpScreen.usTotalNumberOfLinesInBuffer ) * gHelpScreen.iLineAtTopOfTextBuffer;
- iTopPosScrollBox = (INT32)( dTemp +.5 ) + HLP_SCRN__SCROLL_POSY;
- }
- if( piHeightOfScrollBox != NULL )
- *piHeightOfScrollBox = iSizeOfBox;
- if( piTopOfScrollBox != NULL )
- *piTopOfScrollBox = iTopPosScrollBox;
- }
- void SelectHelpScrollAreaCallBack(MOUSE_REGION * pRegion, INT32 iReason )
- {
- if (iReason & MSYS_CALLBACK_REASON_INIT)
- {
- }
- else if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
- {
- gfScrollBoxIsScrolling = FALSE;
- gHelpScreen.iLastMouseClickY = -1;
- }
- else if( iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
- {
- gfScrollBoxIsScrolling = TRUE;
- HelpScreenMouseMoveScrollBox( pRegion->MouseYPos );
- }
- else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
- {
- }
- }
- void SelectHelpScrollAreaMovementCallBack(MOUSE_REGION * pRegion, INT32 iReason )
- {
- if( iReason & MSYS_CALLBACK_REASON_LOST_MOUSE )
- {
- // InvalidateRegion(pRegion->RegionTopLeftX, pRegion->RegionTopLeftY, pRegion->RegionBottomRightX, pRegion->RegionBottomRightY);
- }
- else if( iReason & MSYS_CALLBACK_REASON_GAIN_MOUSE )
- {
- }
- else if( iReason & MSYS_CALLBACK_REASON_MOVE )
- {
- if( gfLeftButtonState )
- {
- HelpScreenMouseMoveScrollBox( pRegion->MouseYPos );
- }
- }
- }
- void HelpScreenMouseMoveScrollBox( INT32 usMousePosY )
- {
- INT32 iPosY, iHeight;
- INT32 iNumberOfIncrements=0;
- FLOAT dSizeOfIncrement = ( HLP_SCRN__HEIGHT_OF_SCROLL_AREA / ( FLOAT ) gHelpScreen.usTotalNumberOfLinesInBuffer );
- FLOAT dTemp;
- INT32 iNewPosition;
- CalculateHeightAndPositionForHelpScreenScrollBox( &iHeight, &iPosY );
- if( AreWeClickingOnScrollBar( usMousePosY ) || gHelpScreen.iLastMouseClickY != -1 )
- {
- if( gHelpScreen.iLastMouseClickY == -1 )
- gHelpScreen.iLastMouseClickY = usMousePosY;
- if( usMousePosY < gHelpScreen.iLastMouseClickY )
- {
- // iNewPosition = iPosY - ( UINT16)( dSizeOfIncrement + .5);
- iNewPosition = iPosY - ( gHelpScreen.iLastMouseClickY - usMousePosY );
- }
- else if( usMousePosY > gHelpScreen.iLastMouseClickY )
- {
- // iNewPosition = iPosY + ( UINT16)( dSizeOfIncrement + .5);
- iNewPosition = iPosY + usMousePosY - gHelpScreen.iLastMouseClickY;
- }
- else
- {
- return;
- }
- dTemp = ( iNewPosition - iPosY ) / dSizeOfIncrement;
- if( dTemp < 0 )
- iNumberOfIncrements = (INT32)( dTemp - 0.5 );
- else
- iNumberOfIncrements = (INT32)( dTemp + 0.5 );
- gHelpScreen.iLastMouseClickY = usMousePosY;
- // return;
- }
- else
- {
- //if the mouse is higher then the top of the scroll area, set it to the top of the scroll area
- if( usMousePosY < HLP_SCRN__SCROLL_POSY )
- usMousePosY = HLP_SCRN__SCROLL_POSY;
- dTemp = ( usMousePosY - iPosY ) / dSizeOfIncrement;
- if( dTemp < 0 )
- iNumberOfIncrements = (INT32)( dTemp - 0.5 );
- else
- iNumberOfIncrements = (INT32)( dTemp + 0.5 );
- }
- //if there has been a change
- if( iNumberOfIncrements != 0 )
- {
- ChangeTopLineInTextBufferByAmount( iNumberOfIncrements );
- }
- }
- void BtnHelpScreenScrollArrowsCallback(GUI_BUTTON *btn,INT32 reason)
- {
- if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
- {
- btn->uiFlags &= (~BUTTON_CLICKED_ON );
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
- {
- INT32 iButtonID = MSYS_GetBtnUserData( btn, 0);
- btn->uiFlags |= BUTTON_CLICKED_ON;
- //if up
- if( iButtonID == 0 )
- {
- ChangeTopLineInTextBufferByAmount( -1 );
- }
- else
- {
- ChangeTopLineInTextBufferByAmount( 1 );
- }
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- if( reason & MSYS_CALLBACK_REASON_LBUTTON_REPEAT )
- {
- INT32 iButtonID = MSYS_GetBtnUserData( btn, 0);
- //if up
- if( iButtonID == 0 )
- {
- ChangeTopLineInTextBufferByAmount( -1 );
- }
- else
- {
- ChangeTopLineInTextBufferByAmount( 1 );
- }
- InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY);
- }
- }
- BOOLEAN AreWeClickingOnScrollBar( INT32 usMousePosY )
- {
- INT32 iPosY, iHeight;
- CalculateHeightAndPositionForHelpScreenScrollBox( &iHeight, &iPosY );
- if( usMousePosY >= iPosY && usMousePosY < ( iPosY + iHeight ) )
- return( TRUE );
- else
- return( FALSE );
- }
|