November 25, 2020, 05:17:56 AM

Author Topic: [bb] StartupPlus - UPDATED for BlitzPlus v1.34 by EOF [ 1+ years ago ]  (Read 780 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : StartupPlus  - UPDATED for BlitzPlus v1.34
Author : EOF
Posted : 1+ years ago

Description : Simple to use display options window.
Just place Include "StartupPlus.bb" at the beginning of the program and call one function.
The GUI will also display an optional 'logo.jpg' image if found in the current directory.
The image size viewed in the panel is 128x128.


Once the user chooses the display options and hits start, the window closes and the graphics mode will be set.
SetBuffer BackBuffer() is also called.
``````````````````````
Function
``````````````````````

NB: ALL PARAMETERS ARE OPTIONAL
Default values are:

title -> BlitzPlus Example
graphics mode -> 640x480 16 Bit
graphics driver -> Native
result=SetDisplay(title$,width,height,depth,fullscreenflag,driver)

Parameters:
-----------
 title$ - Displayed in the main window
 width - default graphics width to use
 height - default graphics height to use
 depth - depth required
 fullscreenflag - True means use full screen else windowed
 driver - graphics driver to use as default

About
---------------------------------
Opens up a display options window.
If the user closes/quits the window the the result returned is 0.
Download <a href="http://homepage.ntlworld.com/config/startupplus/startupplus.zip" target="_blank">source code and example[/url]

Keyboard Shortcuts:
-------------------
RETURN is equivalent to clicking the [Start] button
ESC is equivalent to closing the window


Code :
Code: BlitzBasic
  1. EXAMPLE USAGE
  2. =============
  3.  
  4.  
  5.  
  6. ; StartupPlus - Example
  7. ; Syntax Error
  8.  
  9. Include "StartupPlus.bb"
  10.  
  11. If SetDisplay("SuperDemo 2003",512,384,16,False) = 0 End
  12. sw=GraphicsWidth() : sh=GraphicsHeight() : sd=GraphicsDepth()
  13.  
  14. x=40 : y=90 : dx=4 : dy=3
  15. size=sw*0.15
  16. timer=CreateTimer(60)
  17.  
  18. While Not KeyHit(1) Or MouseHit(1)
  19.         WaitTimer timer
  20.         Cls
  21.         x=x+dx : y=y+dy
  22.         If x<=0 Or x>=sw-size Then dx=-dx
  23.         If y<=0 Or y>=sh-size Then dy=-dy
  24.         Rect x,y,size,size
  25.         Text 5,5,"Driver: "+GfxDriverName$(GFXDriver)
  26.         Text 5,25,"Width="+sw+" Height="+sh+" Depth="+sd
  27.         Flip
  28. Wend
  29.  
  30. End
  31.  
  32.  
  33.  
  34.  
  35.  
  36. THE INCLUDE (StartupPlus.bb)
  37. ============================
  38.  
  39.  
  40.  
  41. ; StartupPlus by Syntax Error
  42. ; Updated for BlitzPlus v1.34
  43.  
  44. ; include file 'StartupPlus.bb"
  45.  
  46. Global GFXDriver=1
  47.  
  48. ; set program display graphics
  49. Function SetDisplay(title$="BlitzPlus Example",w=640,h=480,d=16,full=0,driver=1)
  50.         Local xo=160
  51.         If FileType("logo.jpg")=0 Then xo=0
  52.         win = CreateWindow(title$,307,322,xo+164,182,Desktop(),1)
  53.         ; Graphics Mode
  54.         Label1 = CreateLabel("Graphics Mode",xo+36,8,74,14,win,0)
  55.         Combo1 = CreateComboBox(xo+8,26,138,100,win,0)
  56.         AddGadgetItem Combo1,"Choose Resolution..."
  57.         For g=1 To CountGfxModes()
  58.                 mode$=Str$(GfxModeWidth(g))+" x "+Str$(GfxModeHeight(g))+"  "+Str$(GfxModeDepth(g))+"Bit"
  59.                 AddGadgetItem Combo1,mode$
  60.                 If w=GfxModeWidth(g) And h=GfxModeHeight(g) And d=GfxModeDepth(g)
  61.                         SelectGadgetItem Combo1,g
  62.                 EndIf
  63.         Next
  64.         If SelectedGadgetItem(Combo1)=-1 Then SelectGadgetItem Combo1,0
  65.         ; Graphics Driver
  66.         Label2 = CreateLabel("Graphics Driver",xo+36,52,74,14,win,0)
  67.         Combo2 = CreateComboBox(xo+8,70,138,100,win,0)
  68.         For g=1 To CountGfxDrivers()
  69.                 AddGadgetItem Combo2,GfxDriverName$(g)
  70.         Next
  71.         If driver<1 Then driver=1
  72.         If driver>CountGfxDrivers() Then driver=CountGfxDrivers()
  73.         SelectGadgetItem Combo2,driver-1
  74.         ; FullScreen / Windowed
  75.         RadioButton1 = CreateButton("FullScreen",xo+4,98,76,20,win,3)
  76.         RadioButton2 = CreateButton("Windowed",xo+80,98,70,20,win,3)
  77.         SetButtonState RadioButton1,full=True
  78.         SetButtonState RadioButton2,full=False
  79.         ; Start Button
  80.         Button = CreateButton("Start",xo+4,120,140,26,win,0)
  81.         ; Graphic Image
  82.         If xo>0
  83.                 panel = CreatePanel(16,14,128,128,win)
  84.                 SetPanelImage panel,"logo.jpg"
  85.         EndIf
  86.        
  87.         ; await user response
  88.         Repeat
  89.         Select WaitEvent()
  90.                 Case $103 ; key stroke
  91.                         If EventData()=27 Exit
  92.                         If EventData()=13
  93.                                 If SelectedGadgetItem(Combo1)=0
  94.                                         Notify "Please choose a Graphics mode"
  95.                                 Else
  96.                                         startflag=True : Exit
  97.                                 EndIf
  98.                         EndIf
  99.                 Case $803 ; [x] close window
  100.                         Exit
  101.                 Case $401 ; gadget event
  102.                         If EventSource()=Button
  103.                                 If SelectedGadgetItem(Combo1)=0
  104.                                         Notify "Please choose a graphics mode"
  105.                                 Else
  106.                                         startflag=True : Exit
  107.                                 EndIf
  108.                         EndIf
  109.         End Select
  110.         Forever
  111.  
  112.         ; read combobox selections
  113.         g=SelectedGadgetItem(Combo1)
  114.         GFXDriver=SelectedGadgetItem(Combo2)+1
  115.         If g>0 
  116.                 w=GfxModeWidth(g) : h=GfxModeHeight(g) : d=GfxModeDepth(g)
  117.                 full=ButtonState(radiobutton1)
  118.         EndIf
  119.        
  120.         ; close GUI and created graphics display
  121.         FreeGadget win
  122.         If full=0 Then full=2 ; windowed
  123.         If startflag=True
  124.                 AppTitle title$
  125.                 SetGfxDriver GFXDriver
  126.                 Graphics w,h,d,full
  127.                 SetBuffer BackBuffer()
  128.         EndIf
  129.         Return startflag
  130. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal