Ooops
January 26, 2021, 12:07:38 PM

Author Topic: [bmx] Mousewheel Menu by zoqfotpik [ 1+ years ago ]  (Read 627 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Mousewheel Menu by zoqfotpik [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Mousewheel Menu
Author : zoqfotpik
Posted : 1+ years ago

Description : This is a menu that is activated and selected by the mousewheel.  There are a lot of things you could do with this, like bind function pointers to the menu options, etc, but right now it just toggles the variable "currentitem."

This is from an editor of mine and I intended it to be simple.  You could bind keyboard commands to it or whatever.


Code :
Code: BlitzMax
  1. Strict
  2.  
  3. Global numitems = 7    
  4. Global currentitem:Int  ' Which item is currently selected
  5. Global olditem:Int
  6.  
  7. Global currenttextline:Int
  8. Graphics 640,480
  9.  
  10. Global ticks = 0
  11. Global namearray:String[100]
  12. Global menufadeouttimer:Int ' When this has elapsed, the menu disappears automatically
  13.  
  14. namearray[0]="Thing1"
  15. namearray[1]="Thing2"
  16. namearray[2]="Redthing"
  17. namearray[3]="Bluething"
  18. namearray[4]="BarThing"
  19. namearray[5]="FooThing"
  20. namearray[6]="Exit"
  21.  
  22. While Not KeyDown(KEY_ESCAPE) And Not (currentitem=6 And menufadeouttimer<0)
  23.         ticks = ticks + 1
  24.         Cls
  25.         currenttextline=0
  26.         olditem= currentitem
  27.         currentitem= Abs(MouseZ()) Mod numitems ' Mousewheel Switches Tile Types
  28.         If olditem<> currentitem
  29.                 menufadeouttimer = 60
  30.         EndIf
  31.         menufadeouttimer:-1            
  32.         If menufadeouttimer > 0 drawmenu()
  33.         Flip
  34. Wend
  35.  
  36. Function drawmenu()
  37.         SetBlend alphablend
  38.         SetAlpha .5  ' draw semi-transparent menu background
  39.         SetColor 0,0,0
  40.         DrawRect 0,0,200,1000
  41.         SetAlpha 1
  42.         If menufadeouttimer < 50 And menufadeouttimer > 0 SetAlpha 1*(51/menufadeouttimer)
  43.         'SetColor 255,0,0
  44.         Local recty = 0*12
  45.         DrawRect 0,recty,200,24
  46.         SetScale 2,2
  47. SetColor 255,0,0
  48.         DrawText namearray[currentitem], 0,-2
  49.         SetScale 1,1
  50.         SetColor 255,255,255
  51.         recty = currentitem*12 + 24
  52.         DrawRect 0,recty,200,12
  53.         For Local i = 0 To numitems
  54.                 If i = currentitem
  55.                         SetColor 0,0,0
  56.                 Else
  57.                         SetColor 255,255,255
  58.                 EndIf
  59.                 DrawText namearray[i], 10,i*12 + 24
  60.                 SetColor 255,255,255
  61.         Next
  62.         SetAlpha 1
  63. End Function
  64.  
  65. Function consoleprint(toprint$)
  66.         currenttextline:+12
  67.         DrawText(toprint$,10,currenttextline)
  68. End Function


Comments :


dw817(Posted 7 months ago)

 Marvelous work ! I was completely unaware that BlitzMAX could read the roller. That has to be impressive !


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal