November 25, 2020, 05:28:12 AM

Author Topic: [bb] Start Screen by Nicstt [ 1+ years ago ]  (Read 680 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Start Screen by Nicstt [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Start Screen
Author : Nicstt
Posted : 1+ years ago

Description : The code below is split into two .bb files - the first is called 'Main Game Loop.bb', the second is 'Opening Screen.bb' which is an include called by Main Game Loop

Code :
Code: BlitzBasic
  1. ; ************************************************************************************************************************
  2. ; Written by Nicholas Tindall
  3. ; ************************************************************************************************************************
  4. AppTitle "version 0"
  5. SeedRnd MilliSecs()
  6.  
  7. Include "Opening Screen.bb"
  8.  
  9. ;---------------------------------------------------------------------------------------
  10. ; constants that should be adjusted depending on requirements - see: Opening Screen.bb
  11. ;---------------------------------------------------------------------------------------
  12.  
  13. ; SETUP_Help                    ; used to inform Opening Screen if addition help/instructions available - true or false - disables the radio button if false
  14. ; SETUP_Prefs                   ; not used atm,  true or false - disables the radio button if false
  15. ; SETUP_TwoPlayer               ; true or false - disables the radio button if false
  16. ; SETUP_CompPlayer              ; true or false - disables the radio button if false
  17. ; SETUP_Full                    ; true of false - disables the radio button if false
  18. ; SETUP_Windowed                ; true of false - disables the radio button if false
  19. ; SETUP_Psudo                   ; true of false - disables the radio button if false
  20.  
  21. ;---------------------------------------------------------------------------------------
  22. ; info passed to these from Opening Screen.bb
  23. ;---------------------------------------------------------------------------------------
  24.  
  25. ; screenWidth                   ; width of game screen
  26. ; screenHeight                  ; height of game screen
  27. ; screenDepth                   ; depth of game screen
  28. ; screenType                    ; type is windowed or full screen - 1 = full screen, 2 = windowed, 3 = Psuedo, will be reset to 1 by main game loop
  29. ; playerNumber                  ; 1 = one, 2 = two, 3 = computer oponent
  30.  
  31. ;---------------------------------------------------------------------------------------
  32. ; Opening Screen.bb uses them to determine actions - .StartGameSetup is where game starts
  33. ;---------------------------------------------------------------------------------------
  34. ; COMBO_position                = 0             ; what number the combo box should begin, ie first in list or further
  35.  
  36. ; HELP_frame                    = 18    ; how many lines of text per page of help displayed
  37. ; HELP_title                    = True  ; set to false if no title lines - otherwise displays first line of help centered and in a larger font
  38.                                                                         ; displays first page with title line regardless
  39.  
  40. .StartGameSetup                 ; main game starts from here
  41. HidePointer
  42. ;---------------------------------------------------------------------------------------------------------------------------------------
  43. ; ... Constants and Globals ...
  44. ;---------------------------------------------------------------------------------------------------------------------------------------
  45.  
  46.  
  47. ;---------------------------------------------------------------------------------------------------------------------------------------
  48. ; ... Type Setup ...
  49. ;---------------------------------------------------------------------------------------------------------------------------------------
  50.  
  51.  
  52. ;---------------------------------------------------------------------------------------------------------------------------------------
  53. ; ... Sound Setup ...
  54. ;---------------------------------------------------------------------------------------------------------------------------------------
  55.  
  56.  
  57. ;---------------------------------------------------------------------------------------------------------------------------------------
  58. ; ... Graphics Setup ...
  59. ;---------------------------------------------------------------------------------------------------------------------------------------
  60.  
  61. If (screenType > 0) And (screenType < 3)
  62.         Graphics screenWidth, screenHeight, screenDepth, screenType
  63. ElseIf screenType = 3
  64.         screenType = 2
  65.         Graphics screenWidth, screenHeight, screenDepth, screenType
  66. ElseIf screenType = 0
  67.         RuntimeError "ERROR on screenType - Problem with depth"
  68. EndIf
  69.  
  70.  
  71. SetBuffer(BackBuffer()) : ClsColor 0, 0, 0 : Cls : Flip
  72. ;*************************************************************************************************************************************************************************
  73. ; * * * * * * * * *  M A I N  L O O P  * * * * * * * * * *
  74. ;*************************************************************************************************************************************************************************
  75. Global delay_timer = CreateTimer(60)
  76. Repeat
  77.  
  78.  
  79.  
  80.  
  81.        
  82.  
  83.         If KeyHit(1) Then Exit
  84. Forever
  85.  
  86. Gosub clearandfreestuff: EndGraphics
  87. FlushKeys : FlushEvents()
  88. Goto startoptionscreen
  89. End
  90. ;*************************************************************************************************************************************************************************
  91. ; * * * * * * * * * *  F U N C T I O N S  * * * * * * * * * *
  92. ;*************************************************************************************************************************************************************************
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. ;*************************************************************************************************************************************************************************
  103. ; * * * * * * * * * *  S U B - R O U T I N E S  * * * * * * * * * *
  104. ;*************************************************************************************************************************************************************************
  105.  
  106.  
  107.  
  108.  
  109.  
  110. ; clear and free stuff
  111. .clearandfreestuff
  112.  
  113.  
  114. Return
  115.  
  116. ;---------------------------------------------------------------------------------------------------------------------------------------
  117. ; ... Data ...
  118. ;---------------------------------------------------------------------------------------------------------------------------------------
  119.  
  120. ***************************************************************************************************
  121. ***************************************************************************************************
  122. ***************************************************************************************************
  123. SEPERATE CODE FILE - - - SEPERATE CODE FILE - - - SEPERATE CODE FILE - - - SEPERATE CODE FILE - - -
  124. ***************************************************************************************************
  125. .startoptionscreen
  126. If CountGfxModes()=0 RuntimeError "No fullscreen gfx modes detected"
  127.  
  128. ; -----------------------------------------------------------------------------
  129. ; ...Button Controls and globals for game/program, some info to be passed to main program...
  130. ; -----------------------------------------------------------------------------
  131. ; constants that should be adjusted depending on requirements
  132. Const SETUP_Help                        = False         ; used to inform Opening Screen if addition help/instructions available - true or false - NOT disabled
  133. Const SETUP_Prefs                       = False         ; not used atm,  true or false - disables the radio button if false
  134. Const SETUP_TwoPlayer           = False         ; true or false - disables the radio button if false
  135. Const SETUP_CompPlayer          = False         ; true or false - disables the radio button if false
  136. Const SETUP_Full                        = True          ; true of false - disables the radio button if false
  137. Const SETUP_Windowed            = True          ; true of false - disables the radio button if false
  138. Const SETUP_Psudo                       = True          ; true of false - disables the radio button if false - will be disabled if current Windows mode not one of options available
  139. ; info passed to Main Game.bb
  140. Global screenWidth                      = 0             ; width of game screen
  141. Global screenHeight                     = 0             ; height of game screen
  142. Global screenDepth                      = 0             ; depth of game screen
  143. Global screenType                       = 0             ; type is windowed or full screen - 1 = full screen, 2 = windowed, 3 = Psuedo, will be reset to 1 by main program
  144. Global playerNumber                     = 1             ; 1 = one, 2 = two, 3 = computer oponent
  145.                
  146. ; instructions and/or help,
  147. Const HELP_frame                        = 18    ; how many lines of text per page of help displayed
  148. Const HELP_title                        = True  ; set to false if no title lines - otherwise displays first line of help centered and in a larger font
  149.                                                                         ; displays first page with title line regardless
  150.  
  151. ; useful during game creation to always start at specific resolution, i think so anyway :)
  152. Const COMBO_position            = 0             ; what number the combo box should begin, ie first in list or further
  153.  
  154. ; -----------------------------------------------------------------------------
  155. ; ...Event definitions...
  156. ; -----------------------------------------------------------------------------
  157. Const EVENT_None                = $0            ; No event (eg. a WaitEvent timeout)
  158. Const EVENT_KeyDown             = $101          ; Key pressed
  159. Const EVENT_KeyUp               = $102          ; Key released
  160. Const EVENT_ASCII               = $103          ; ASCII key pressed
  161. Const EVENT_MouseDown   = $201          ; Mouse button pressed
  162. Const EVENT_MouseUp             = $202          ; Mouse button released
  163. Const EVENT_MouseMove   = $203          ; Mouse moved
  164. Const EVENT_Gadget              = $401          ; Gadget clicked
  165. Const EVENT_Move                = $801          ; Window moved
  166. Const EVENT_Size                = $802          ; Window resized
  167. Const EVENT_Close               = $803          ; Window closed
  168. Const EVENT_Front               = $804          ; Window brought to front
  169. Const EVENT_Menu                = $1001         ; Menu item selected
  170. Const EVENT_LostFocus   = $2001         ; App lost focus
  171. Const EVENT_GotFocus    = $2002         ; App got focus
  172. Const EVENT_Timer               = $4001         ; Timer event occurred
  173.  
  174.  
  175. Type gfxTypes
  176.         Field width
  177.         Field height
  178.         Field depth
  179.         Field count
  180. End Type
  181.  
  182. Type helptext
  183.         Field linetext$
  184.         Field page
  185.         Field linenumber
  186. End Type
  187.  
  188.  
  189. ; -----------------------------------------------------------------------------
  190. ; ...Main Window Setup...
  191. ; -----------------------------------------------------------------------------
  192. ; help window
  193. Global helpwindow, canvasPreview, panelButtonHelp, buttonQuitHelp, buttonPreviousHelp, buttonNextHelp
  194. ; * * * info for main window in the function
  195. Global mainwindow = CenterWindow ("Setup Screen", 390, 200, 0, 3) ; name, width, height, group, style
  196. SetMinWindowSize mainwindow, 390, 200
  197.  
  198. ;icon=ExtractIconA(QueryObject(mainwindow,1),"OWN ICON HERE.ico",0) ; used to display own icon if have the required userlibs in blitz
  199. ;SetClassLongA(QueryObject(mainwindow,1),-14,icon) ; thx to Grey Alien for that:)
  200. ; ******
  201.  
  202. ; * * * CreateButton( text$,x,y,width,height,group[,style] )
  203. Global panelButton = CreatePanel ( 260, 5, 114, 159, mainwindow, 0 )
  204. Global buttonQuit  = CreateButton( "'Q'uit",   0, 0,  110, 35, panelButton , 1 )
  205. Global buttonStart = CreateButton( "'S'tart",  0, 41, 110, 35, panelButton , 1 ) ; start game
  206. Global buttonHelp  = CreateButton( "'H'elp",   0, 82, 110, 35, panelButton , 1 ) ; show instructions / help
  207. Global buttonPrefs= CreateButton( "'P'references",   0, 123, 110, 35, panelButton , 1 ) ;
  208. SetGadgetLayout panelButton, 2, 2, 2, 2 : SetGadgetLayout buttonQuit, 2, 2, 2, 2 : SetGadgetLayout buttonStart, 2, 2, 2, 2
  209. SetGadgetLayout buttonHelp, 2, 2, 2, 2  : SetGadgetLayout buttonPrefs, 2, 2, 2, 2
  210. ; ******
  211.  
  212. ; * * * panel and label for full screen or windowed mode
  213. Global panelRadio = CreatePanel ( 10, 5, 119, 120, mainwindow, 1 ) ; 0 = no border, 1 = sunken border
  214. Global labelRadio =     CreateLabel ( "     Screen Options", 1, 0, 100, 15, panelRadio, 0 ) ; 0 = no border, 1 = border, 3 = sunken border
  215. Global radioWind =      CreateButton( "Window Mode",         2, 22, 94, 20, panelRadio, 3 )
  216. Global radioFull =      CreateButton( "Full Screen",         2, 53, 94, 20, panelRadio, 3 )
  217. Global radioPsudo =     CreateButton( "Psuedo Full Screen",  2, 84, 114, 20, panelRadio, 3 )
  218. SetGadgetLayout panelRadio, 2, 2, 2, 2 : SetGadgetLayout labelRadio, 2, 2, 2, 2 : SetGadgetLayout radioWind, 2, 2, 2, 2
  219. SetGadgetLayout radioFull, 2, 2, 2, 2 : SetGadgetLayout radioPsudo, 2, 2, 2, 2 : SetButtonState radioWind, 1
  220. ; ******
  221.  
  222. ; * * * panel and label for one or two players
  223. Global panelRadio2 =            CreatePanel ( 140, 5, 110, 120, mainwindow, 1 ) ; 0 = no border, 1 = sunken border
  224. Global labelRadio2 =            CreateLabel ( "  Number of Players", 1, 0, 100, 15, panelRadio2, 0 ) ; 0 = no border, 1 = border, 3 = sunken border
  225. Global radio2OnePlayer =        CreateButton( "One Player",             2, 22, 94, 20, panelRadio2, 3 )
  226. Global radio2TwoPlayer =        CreateButton( "Two Players",            2, 53, 94, 20, panelRadio2, 3 )
  227. Global radio2CompPlayer =       CreateButton( "Computer Player",        2, 84, 104, 20, panelRadio2, 3 )
  228. SetGadgetLayout panelRadio2, 2, 2, 2, 2 : SetGadgetLayout labelRadio2, 2, 2, 2, 2 : SetGadgetLayout radio2OnePlayer, 2, 2, 2, 2
  229. SetGadgetLayout radio2TwoPlayer, 2, 2, 2, 2 : SetGadgetLayout radio2CompPlayer, 2, 2, 2, 2 : SetButtonState radio2OnePlayer, 1
  230. ; ******
  231.  
  232. ; * * * adds combo box then checks for graphics modes and adds them to combo box
  233. Global comboGraphics = CreateComboBox( 10, 140, 240, 24, mainwindow )
  234. GfxModesWindowed()      ; adds the gfx modes to combo box
  235. SetGadgetLayout comboGraphics, 2, 2, 2, 2 ; SelectGadgetItem comboGraphics, 0 - sets combo box To display specific entry - 0 is First entry - is set in specific function
  236. ; ******
  237.  
  238.  
  239. ; -----------------------------------------------------------------------------
  240. ; ...Disable the buttons not required...
  241. ; -----------------------------------------------------------------------------
  242.  
  243. If SETUP_Prefs = False Then DisableGadget buttonPrefs
  244. If SETUP_TwoPlayer = False Then DisableGadget radio2TwoPlayer
  245. If SETUP_CompPlayer = False Then DisableGadget radio2CompPlayer
  246. If SETUP_Full = False Then DisableGadget radioFull
  247. If SETUP_Windowed = False Then DisableGadget radioWind
  248. If SETUP_Psudo = False Then DisableGadget radioPsudo
  249. If SETUP_TwoPlayer = False And SETUP_CompPlayer = False Then DisableGadget radio2OnePlayer
  250. If SETUP_Full = False And SETUP_Psudo = False Then DisableGadget radioWind
  251.  
  252.  
  253.  
  254. ;*************************************************************************************************************************************************************************
  255. ; * * * * * * * * *  M A I N  L O O P  * * * * * * * * * *
  256. ;*************************************************************************************************************************************************************************
  257. Repeat
  258.         Select WaitEvent(1)
  259.                 Case EVENT_Gadget       ; gadget clicked $401
  260.                         Select EventSource()
  261.                                 Case buttonStart
  262.                                         GameStart()
  263.                                         Gosub freeallgadgets : EndGraphics
  264.                                         FlushKeys : FlushEvents()
  265.                                         Goto StartGameSetup
  266.                                 Case buttonHelp
  267.                                         HideGadget mainwindow
  268.                                         helpwindow = CenterWindow ("Help", 485, 514 + 60, 0, 17)
  269.                                         ShowHelp() ; handles help window
  270.                                         ShowGadget mainwindow
  271.                                         ActivateGadget mainwindow
  272.                                 Case buttonPrefs
  273.                                         ; nothing setup
  274.                                         ActivateGadget mainwindow
  275.                                 Case buttonQuit
  276.                                         If Confirm( "Confirm Quit?" ) = True
  277.                                                 Gosub freeallgadgets : EndGraphics : End
  278.                                         EndIf
  279.                                         ActivateGadget mainwindow
  280.                                 Case radioWind
  281.                                         GfxModesWindowed()
  282.                                         ActivateGadget mainwindow
  283.                                 Case radioFull
  284.                                         GfxModesFull()
  285.                                         ActivateGadget mainwindow
  286.                                 Case radioPsudo
  287.                                         GfxModesPsudo()
  288.                                         ActivateGadget mainwindow
  289.                                 Case comboGraphics
  290.                                         ActivateGadget mainwindow
  291.                         End Select
  292.                 Case EVENT_Close        ;window close
  293.                         Gosub freeallgadgets : EndGraphics : End
  294.                 Case EVENT_LostFocus    ;suspend!
  295.                         While WaitEvent() <> EVENT_GotFocus
  296.                         Wend
  297.                         ActivateGadget mainwindow
  298.                 Case EVENT_KeyUp
  299.                         If EventData() = 16 ; quit
  300.                                 If Confirm( "Confirm Quit?" ) = True
  301.                                         Gosub freeallgadgets : EndGraphics : End
  302.                                 EndIf
  303.                                 ActivateGadget mainwindow
  304.                         EndIf
  305.                         If EventData() = 35 ; help
  306.                                 HideGadget mainwindow
  307.                                 helpwindow = CenterWindow ("Help", 485, 514 + 60, 0, 17)
  308.                                 ShowHelp() ; handles help window
  309.                                 ShowGadget mainwindow
  310.                                 ActivateGadget mainwindow
  311.                         EndIf
  312.                         If EventData() = 31 ; start
  313.                                 GameStart()
  314.                                 Gosub freeallgadgets : EndGraphics
  315.                                 FlushKeys : FlushEvents()
  316.                                 Goto StartGameSetup
  317.                         EndIf
  318.                         If EventData() = 25 ; preferences
  319.  
  320.                         EndIf
  321.         End Select
  322. Forever
  323.  
  324. Gosub freeallgadgets : EndGraphics : End
  325.  
  326. ;*************************************************************************************************************************************************************************
  327. ; * * * * * * * * * *  F U N C T I O N S  * * * * * * * * * *
  328. ;*************************************************************************************************************************************************************************
  329. Function GameStart()
  330.         mode1=SelectedGadgetItem(comboGraphics) + 1
  331.         For mode.gfxTypes = Each gfxTypes
  332.                 If modecount = mode1
  333.                         screenWidth = modewidth
  334.                         screenHeight = modeheight
  335.                         screenDepth = modedepth
  336.                 EndIf
  337.         Next
  338.         If ( ButtonState (radioPsudo) = 1 )
  339.                 screenType = 3
  340.         ElseIf ( ButtonState (radioWind) = 1 )
  341.                 screenType = 2
  342.         ElseIf ( ButtonState (radioFull) = 1 )
  343.                 screenType = 1
  344.         EndIf
  345.         If ( ButtonState (radio2OnePlayer) = 1 )
  346.                 playerNumber = 1
  347.         ElseIf ( ButtonState (radio2TwoPlayer) = 1 )
  348.                 playerNumber = 2
  349.         ElseIf ( ButtonState (radio2CompPlayer) = 1 )
  350.                 playerNumber = 3
  351.         EndIf
  352. End Function
  353.  
  354. Function GfxModesPsudo()
  355.         ClearGadgetItems(comboGraphics)
  356.         For mode.gfxTypes = Each gfxTypes : Delete mode : Next
  357.         count = 1
  358.         For k1 = 1 To CountGfxModes() ; 640, 480 / 800, 600 / 1024, 768 / 1280, 1024 / 1600, 1200
  359.                 t1$ = GfxModeWidth(k1) + " width   x   " + GfxModeHeight(k1) + " height   x   " + GfxModeDepth(k1) + " depth"
  360. ;               If ( GfxModeWidth(k1) = 640 Or GfxModeWidth(k1) = 800 Or GfxModeWidth(k1) = 1024 Or GfxModeWidth(k1) = 1280 Or GfxModeWidth(k1) = 1600 ) And ( GfxModeHeight(k1) = 480 Or GfxModeHeight(k1) = 600 Or GfxModeHeight(k1) = 768 Or GfxModeHeight(k1) = 1024 Or GfxModeHeight(k1) = 1200 )
  361.                 If ( GfxModeWidth(k1) = 640 And GfxModeHeight(k1) = 480 ) Or ( GfxModeWidth(k1) = 800 And GfxModeHeight(k1) = 600 ) Or ( GfxModeWidth(k1) = 1024 And GfxModeHeight(k1) = 768 ) Or ( GfxModeWidth(k1) = 1280 And GfxModeHeight(k1) = 1024 ) Or ( GfxModeWidth(k1) = 1600 And GfxModeHeight(k1) = 1200 )
  362.                         If GraphicsWidth() = GfxModeWidth(k1) And GraphicsHeight() =  GfxModeHeight(k1) And GraphicsDepth() = GfxModeDepth(k1)
  363.                                 AddGadgetItem comboGraphics, t1$
  364.                                 mode.gfxTypes = New gfxTypes
  365.                                 modewidth = GfxModeWidth(k1)
  366.                                 modeheight = GfxModeHeight(k1)
  367.                                 modedepth = GfxModeDepth(k1)
  368.                                 modecount = count
  369.                                 count = count + 1
  370.                                 SelectGadgetItem comboGraphics, COMBO_position
  371.                         EndIf
  372.                 EndIf
  373.         Next
  374.         count = 0
  375.         If CountGadgetItems(comboGraphics) = 0 Then SetButtonState radioPsudo, 0 : DisableGadget radioPsudo : DisableGadget buttonStart
  376.         If CountGadgetItems(comboGraphics) > 0 Then EnableGadget buttonStart
  377. End Function
  378.  
  379. Function GfxModesWindowed()
  380.         ClearGadgetItems(comboGraphics)
  381.         For mode.gfxTypes = Each gfxTypes : Delete mode : Next
  382.         count = 1
  383.         For k1 = 1 To CountGfxModes() ; 640, 480 / 800, 600 / 1024, 768 / 1280, 1024 / 1600, 1200
  384.                 t1$ = GfxModeWidth(k1) + " width   x   " + GfxModeHeight(k1) + " height   x   " + GfxModeDepth(k1) + " depth"
  385. ;               If ( GfxModeWidth(k1) = 640 Or GfxModeWidth(k1) = 800 Or GfxModeWidth(k1) = 1024 Or GfxModeWidth(k1) = 1280 Or GfxModeWidth(k1) = 1600 ) And ( GfxModeHeight(k1) = 480 Or GfxModeHeight(k1) = 600 Or GfxModeHeight(k1) = 768 Or GfxModeHeight(k1) = 1024 Or GfxModeHeight(k1) = 1200 )
  386.                 If ( GfxModeWidth(k1) = 640 And GfxModeHeight(k1) = 480 ) Or ( GfxModeWidth(k1) = 800 And GfxModeHeight(k1) = 600 ) Or ( GfxModeWidth(k1) = 1024 And GfxModeHeight(k1) = 768 ) Or ( GfxModeWidth(k1) = 1280 And GfxModeHeight(k1) = 1024 ) Or ( GfxModeWidth(k1) = 1600 And GfxModeHeight(k1) = 1200 )
  387.                         If GraphicsWidth() >= GfxModeWidth(k1) And GraphicsHeight() >=  GfxModeHeight(k1) And GraphicsDepth() >= GfxModeDepth(k1)
  388.                                 AddGadgetItem comboGraphics, t1$
  389.                                 mode.gfxTypes = New gfxTypes
  390.                                 modewidth = GfxModeWidth(k1)
  391.                                 modeheight = GfxModeHeight(k1)
  392.                                 modedepth = GfxModeDepth(k1)
  393.                                 modecount = count
  394.                                 count = count + 1
  395.                                 SelectGadgetItem comboGraphics, COMBO_position
  396.                         EndIf
  397.                 EndIf
  398.         Next
  399.         count = 0
  400.         If CountGadgetItems(comboGraphics) = 0 Then DisableGadget radioWind : SetButtonState radioWind, 0 : DisableGadget buttonStart
  401.         If CountGadgetItems(comboGraphics) > 0 Then EnableGadget buttonStart
  402. End Function
  403.  
  404. Function GfxModesFull()
  405.         ClearGadgetItems(comboGraphics)
  406.         For mode.gfxTypes = Each gfxTypes : Delete mode : Next
  407.         count = 1
  408.         For k1 = 1 To CountGfxModes() ; 640, 480 / 800, 600 / 1024, 768 / 1280, 1024 / 1600, 1200
  409.                 t1$ = GfxModeWidth(k1) + " width   x   " + GfxModeHeight(k1) + " height   x   " + GfxModeDepth(k1) + " depth"
  410. ;               If ( GfxModeWidth(k1) = 640 Or GfxModeWidth(k1) = 800 Or GfxModeWidth(k1) = 1024 Or GfxModeWidth(k1) = 1280 Or GfxModeWidth(k1) = 1600 ) And ( GfxModeHeight(k1) = 480 Or GfxModeHeight(k1) = 600 Or GfxModeHeight(k1) = 768 Or GfxModeHeight(k1) = 1024 Or GfxModeHeight(k1) = 1200 )
  411.                 If ( GfxModeWidth(k1) = 640 And GfxModeHeight(k1) = 480 ) Or ( GfxModeWidth(k1) = 800 And GfxModeHeight(k1) = 600 ) Or ( GfxModeWidth(k1) = 1024 And GfxModeHeight(k1) = 768 ) Or ( GfxModeWidth(k1) = 1280 And GfxModeHeight(k1) = 1024 ) Or ( GfxModeWidth(k1) = 1600 And GfxModeHeight(k1) = 1200 )
  412.                         AddGadgetItem comboGraphics, t1$
  413.                         mode.gfxTypes = New gfxTypes
  414.                         modewidth = GfxModeWidth(k1)
  415.                         modeheight = GfxModeHeight(k1)
  416.                         modedepth = GfxModeDepth(k1)
  417.                         modecount = count
  418.                         count = count + 1
  419.                         SelectGadgetItem comboGraphics, COMBO_position
  420.                 EndIf
  421.         Next
  422.         count = 0
  423.         If CountGadgetItems(comboGraphics) = 0 Then DisableGadget radioFull : SetButtonState radioFull, 0 : DisableGadget buttonStart
  424.         If CountGadgetItems(comboGraphics) > 0 Then EnableGadget buttonStart
  425. End Function
  426.  
  427.  
  428.  
  429. Function ShowHelp()
  430.         ;SETUP_Help - if true extra info GFX_HelpFrames - 15 lines of text
  431.         canvasPreview = CreateCanvas (0, 0, ClientWidth (helpwindow), ClientHeight(helpwindow) - 40, helpwindow)
  432.         panelButtonHelp = CreatePanel ( 5, ClientHeight (helpwindow) - 30, ClientWidth(helpwindow) - 10, 25, helpwindow, 0 )
  433.         buttonQuitHelp  = CreateButton( "Exit Help",    200, 1,  60, 20, panelButtonHelp , 1 )
  434.         buttonPreviousHelp = CreateButton( "Previous",  1, 1, 50, 20, panelButtonHelp , 1 )
  435.         buttonNextHelp  = CreateButton( "Next",         415, 1, 50, 20, panelButtonHelp , 1 )
  436.         SetBuffer CanvasBuffer (canvasPreview)
  437.         ClsColor 255, 255, 255 : Cls  ; maskimage set to 254, 254, 254
  438.         Color 0, 0, 0
  439.         fntTimes30B = LoadFont("Times New Roman", 30, True, False, False) : If fntTimes30B = False Then RuntimeError "Can't locate the 'Font File'."
  440.         fntTimes20 = LoadFont("Times New Roman", 20, False, False, False) : If fntTimes20 = False Then RuntimeError "Can't locate the 'Font File'."
  441.  
  442.         Restore anyhelpdata
  443.         Read helpdata$
  444.         count = 1 : page = 1
  445.         While helpdata$ <> "END OF HELP DATA"
  446.                 If helpdata$ = "" RuntimeError "Insufficient Help Data Available"
  447.                 help.helptext = New helptext
  448.                         helplinetext$           = helpdata$
  449.                         helppage                        = page
  450.                         helplinenumber          = count
  451.                 Read helpdata$
  452.                 count = count + 1
  453.                 If count > HELP_frame Then count = 1 : page = page + 1  ; HELP_frame is how many lines per page
  454.                 If helppage = 1
  455.                         If helplinenumber = 1
  456.                                 SetFont fntTimes30B : Text ClientWidth (helpwindow) / 2, 5 + helplinenumber * 18, helplinetext$, True, False
  457.                         Else
  458.                                 SetFont fntTimes20 : Text 50, 25 + helplinenumber * 25, helplinetext$, False, False
  459.                         EndIf
  460.                 EndIf
  461.         Wend
  462.         HelpTotalFrames = helppage
  463.         If HelpTotalFrames = 1
  464.                 DisableGadget buttonPreviousHelp : DisableGadget buttonNextHelp
  465.         Else
  466.                 DisableGadget buttonPreviousHelp
  467.         EndIf
  468.         FlipCanvas canvasPreview
  469.         maxpage = page : page = 1
  470.         Repeat
  471.                 Select WaitEvent(1)
  472.                         Case EVENT_Gadget       ; gadget clicked $401
  473.                                 Select EventSource()
  474.                                         Case buttonQuitHelp
  475.                                                 Exit
  476.                                         Case buttonPreviousHelp
  477.                                                 page = page - 1 : EnableGadget buttonNextHelp
  478.                                                 If  page = 1
  479.                                                         DisableGadget buttonPreviousHelp : EnableGadget buttonNextHelp : page = 1
  480.                                                 EndIf
  481.                                                 Cls
  482.                                                 For help.helptext = Each helptext
  483.                                                         If helppage = page
  484.                                                                 If helplinenumber = 1 And HELP_title = True
  485.                                                                         SetFont fntTimes30B : Text ClientWidth (helpwindow) / 2, 5 + helplinenumber * 18, helplinetext$, True, False
  486.                                                                 Else
  487.                                                                         SetFont fntTimes20 : Text 50, 25 + helplinenumber * 25, helplinetext$, False, False
  488.                                                                 EndIf
  489.                                                         EndIf
  490.                                                 Next
  491.                                                 FlipCanvas canvasPreview
  492.                                         Case buttonNextHelp
  493.                                                 page = page + 1 : EnableGadget buttonPreviousHelp
  494.                                                 If  page + 1 = maxpage
  495.                                                         DisableGadget buttonNextHelp : EnableGadget buttonPreviousHelp
  496.                                                 EndIf
  497.                                                 Cls
  498.                                                 For help.helptext = Each helptext
  499.                                                         If helppage = page
  500.                                                                 If helplinenumber = 1 And HELP_title = True
  501.                                                                         SetFont fntTimes30B : Text ClientWidth (helpwindow) / 2, 5 + helplinenumber * 18, helplinetext$, True, False
  502.                                                                 Else
  503.                                                                         SetFont fntTimes20 : Text 50, 25 + helplinenumber * 25, helplinetext$, False, False
  504.                                                                 EndIf
  505.                                                         EndIf
  506.                                                 Next
  507.                                                 FlipCanvas canvasPreview
  508.                                 End Select
  509.                         Case EVENT_Close        ;window close - returns to main window
  510.                                 Exit
  511.                         Case EVENT_LostFocus    ;suspend!
  512.                                 While WaitEvent() <> EVENT_GotFocus
  513.                                 Wend
  514.                 End Select
  515.                 If KeyHit(1) Then Exit
  516.         Forever
  517.         FreeGadget canvasPreview : FreeGadget buttonQuitHelp : FreeGadget buttonPreviousHelp : FreeGadget buttonNextHelp
  518.         FreeGadget panelButtonHelp : FreeGadget helpwindow
  519.         FreeFont fntTimes30B :  FreeFont fntTimes20
  520. End Function
  521.  
  522.  
  523. Function CenterWindow (title$, width, height, group, style)
  524.         ;CreateWindow( title$,x,y,width,height[,group[,style]] )
  525.         Return CreateWindow (title$, (ClientWidth (Desktop ()) / 2) - (width / 2), (ClientHeight (Desktop ()) / 2) - (height / 2), width, height, group, style)
  526. End Function
  527.  
  528.  
  529. ;*************************************************************************************************************************************************************************
  530. ; * * * * * * * * * *  S U B - R O U T I N E S  * * * * * * * * * *
  531. ;*************************************************************************************************************************************************************************
  532. ; tidies up after option screen window
  533. .freeallgadgets
  534. If gfxHelp = True Then FreeImage gfxHelp
  535. FreeGadget buttonQuit : FreeGadget buttonStart : FreeGadget buttonHelp : FreeGadget buttonPrefs
  536. FreeGadget comboGraphics : FreeGadget labelRadio : FreeGadget radioWind : FreeGadget radioFull : FreeGadget radioPsudo
  537. FreeGadget labelRadio2 : FreeGadget radio2OnePlayer : FreeGadget radio2TwoPlayer : FreeGadget radio2CompPlayer
  538.  
  539.  
  540. FreeGadget panelButton
  541. FreeGadget panelRadio
  542. FreeGadget panelRadio2
  543.  
  544.  
  545. FreeGadget mainwindow
  546.  
  547. FreeFont fntTimes30B : FreeFont fntTimes20
  548.  
  549. Return
  550.  
  551. .anyhelpdata
  552. ; * * * help info page one * * *
  553. Data "I N S T R U C T I O N S", "Select Windowed or Full Screen Mode.", "Psuedo Full Screen uses Desktop graphics settings,"
  554. Data "but plays without the normal sized windows border.", "The three Screen Options will affect the Graphics"
  555. Data "Modes available.", "Select the required Screen Resolution, ideally", "after the required Screen Option has been chosen."
  556. Data "Number of Players when highlighted allows for One", "Player, Two Players or for One Player to compete", "against a Computer Opponent."
  557. Data "Quit Button quits to Desktop.", "Start Button starts the Game with the requied settings.", "Help Button displays the instructions here, plus the"
  558. Data "possible option to view further instructions or help", "if it'savailable.", "Preferences Button when highlighted allows for various"
  559. Data "Game Customisation options."
  560. ; * * * help info page two * * *
  561.  
  562.  
  563. Data "END OF HELP DATA" ; use this to denote no more data to be read, place at end of data
  564. ;.StartGameSetup
  565. ;End


Comments :


Nicstt(Posted 1+ years ago)

 deleted


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal