Advertisement
deseven

c2l

Oct 16th, 2013
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;c2l
  2.  
  3. Global RunDir.s = GetPathPart(ProgramFilename())
  4. Global PlayButtonChanged,SettingsButtonChanged,ExitButtonChanged
  5.  
  6. UsePNGImageDecoder()
  7.  
  8. Background = CatchImage(0,?Background)
  9. BackgroundOver = CatchImage(1,?BackgroundOver)
  10. SettingsButton = CatchImage(2,?SettingsButton)
  11. SettingsButtonMin = CatchImage(3,?SettingsButtonMin)
  12. ExitButton = CatchImage(4,?ExitButton)
  13. ExitButtonMin = CatchImage(5,?ExitButtonMin)
  14. VideoButton = CatchImage(6,?VideoButton)
  15. CarButton = CatchImage(7,?CarButton)
  16. EditButton = CatchImage(8,?EditButton)
  17.  
  18. DataSection
  19.   Background:
  20.   IncludeBinary "back.png"
  21.   BackgroundOver:
  22.   IncludeBinary "back_over.png"
  23.   SettingsButton:
  24.   IncludeBinary "settings.png"
  25.   SettingsButtonMin:
  26.   IncludeBinary "settings_min.png"
  27.   ExitButton:
  28.   IncludeBinary "exit.png"
  29.   ExitButtonMin:
  30.   IncludeBinary "exit_min.png"
  31.   VideoButton:
  32.   IncludeBinary "video.ico"
  33.   CarButton:
  34.   IncludeBinary "car.ico"
  35.   EditButton:
  36.   IncludeBinary "edit.ico"
  37. EndDataSection
  38.  
  39. Procedure.b MouseOverGadget(window.l, gadget.l, offsetX.l=0, offsetY.l=0)
  40.   gadgetX.l = GadgetX(gadget) + offsetX
  41.   gadgetY.l = GadgetY(gadget) + offsetY
  42.   gadgetW.l = GadgetWidth(gadget)
  43.   gadgetH.l = GadgetHeight(gadget)
  44.   mouseX.l = WindowMouseX(window)
  45.   mouseY.l = WindowMouseY(window)
  46.   If (mouseX >= gadgetX) And (mouseY >= gadgetY) And (mouseX <= (gadgetX + gadgetW - 1)) And (mouseY <= (gadgetY + gadgetH - 1))
  47.     ProcedureReturn #True
  48.   Else
  49.     ProcedureReturn #False
  50.   EndIf
  51. EndProcedure
  52.  
  53. Procedure.b MouseOverDude()
  54.   X.l = 120
  55.   Y.l = 0
  56.   W.l = 240
  57.   H.l = 240
  58.   mouseX.l = WindowMouseX(window)
  59.   mouseY.l = WindowMouseY(window)
  60.   If (mouseX >= X) And (mouseY >= Y) And (mouseX <= (X + W - 1)) And (mouseY <= (Y + H - 1))
  61.     ProcedureReturn #True
  62.   Else
  63.     ProcedureReturn #False
  64.   EndIf
  65. EndProcedure
  66.  
  67. If OpenWindow(0,#PB_Ignore,#PB_Ignore,480,240,"C2",#PB_Window_ScreenCentered|#PB_Window_BorderLess|#PB_Window_Invisible)
  68.   AddKeyboardShortcut(0,#PB_Shortcut_Escape,100)
  69.   AddKeyboardShortcut(0,#PB_Shortcut_Return,101)
  70.   If CreatePopupImageMenu(1)
  71.     MenuItem(1,"Video settings",VideoButton)
  72.     MenuItem(2,"Carstockalypse",CarButton)
  73.     MenuItem(3,"Game editor",EditButton)
  74.   EndIf
  75.   ImageGadget(0,0,0,480,240,Background)
  76.   DisableGadget(0,1)
  77.   ;hbrBackground = CreatePatternBrush_(Background)
  78.   ;SetClassLong_(WindowID(0),#GCL_HBRBACKGROUND,hbrBackground)
  79.   ImageGadget(1,8,8,32,32,SettingsButton)
  80.   ImageGadget(2,440,8,32,32,ExitButton)
  81.   ;SetWindowCallback(@WCB(),0)
  82.   RedrawWindow_(WindowID(0),0,0,#RDW_INVALIDATE)
  83.   HideWindow(0,0)
  84. EndIf
  85.  
  86. Repeat
  87.   ev = WaitWindowEvent(50)
  88.   If ev = #PB_Event_Gadget And EventType() = #PB_EventType_LeftClick
  89.     Select EventGadget()
  90.       Case 1:
  91.         ; settings
  92.         DisplayPopupMenu(1,WindowID(0))
  93.       Case 2:
  94.         ; exit
  95.         End
  96.     EndSelect
  97.   Else
  98.     If MouseOverGadget(0,1) And SettingsButtonChanged = 0
  99.       SetGadgetState(1,SettingsButtonMin)
  100.       SettingsButtonChanged = 1
  101.     EndIf
  102.     If Not MouseOverGadget(0,1) And SettingsButtonChanged = 1
  103.       SetGadgetState(1,SettingsButton)
  104.       SettingsButtonChanged = 0
  105.     EndIf
  106.     If MouseOverGadget(0,2) And ExitButtonChanged = 0
  107.       SetGadgetState(2,ExitButtonMin)
  108.       ExitButtonChanged = 1
  109.     EndIf
  110.     If Not MouseOverGadget(0,2) And ExitButtonChanged = 1
  111.       SetGadgetState(2,ExitButton)
  112.       ExitButtonChanged = 0
  113.     EndIf
  114.     If MouseOverDude() And PlayButtonChanged = 0
  115.       ;Debug "over"
  116.       SetGadgetState(0,BackgroundOver)
  117.       SetGadgetState(1,SettingsButton)
  118.       SetGadgetState(2,ExitButton)
  119.       ;DisableGadget(0,1)
  120.       ;RedrawWindow_(WindowID(0),0,0,#RDW_INVALIDATE)
  121.       PlayButtonChanged = 1
  122.     EndIf
  123.     If Not MouseOverDude() And PlayButtonChanged = 1
  124.       ;Debug "not over"
  125.       SetGadgetState(0,Background)
  126.       SetGadgetState(1,SettingsButton)
  127.       SetGadgetState(2,ExitButton)
  128.       ;DisableGadget(0,1)
  129.       ;RedrawWindow_(WindowID(0),0,0,#RDW_INVALIDATE)
  130.       PlayButtonChanged = 0
  131.     EndIf
  132.     If MouseOverDude() And ev = #WM_LBUTTONDOWN
  133.       If FileSize("Carma2_HW.exe") > 0
  134.         RunProgram("Carma2_HW.exe","","")
  135.         End
  136.       Else
  137.         MessageRequester("Error!","Can't find `Carma2_HW.exe`")
  138.       EndIf
  139.     EndIf
  140.     If ev = #WM_LBUTTONDOWN And WindowMouseX(0) < 600 And WindowMouseY(0) < 400 And GetActiveWindow() = 0
  141.       SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN,#HTCAPTION,0)
  142.     EndIf
  143.     If ev = #PB_Event_Menu
  144.       Select EventMenu()
  145.         Case 1:
  146.           HideWindow(0,1)
  147.           If FileSize("nglide_config.exe") > 0
  148.             RunProgram("nglide_config.exe","","",#PB_Program_Wait)
  149.           Else
  150.             MessageRequester("Error!","Can't find `nglide_config.exe`")
  151.           EndIf
  152.           HideWindow(0,0)
  153.         Case 2:
  154.           HideWindow(0,1)
  155.           If FileSize("carstockalypse.exe") > 0
  156.             RunProgram("carstockalypse.exe","","",#PB_Program_Wait)
  157.           Else
  158.             MessageRequester("Error!","Can't find `carstockalypse.exe`")
  159.           EndIf
  160.           HideWindow(0,0)
  161.         Case 3:
  162.           HideWindow(0,1)
  163.           If FileSize("c2edit.exe") > 0
  164.             RunProgram("c2edit.exe","","",#PB_Program_Wait)
  165.           Else
  166.             MessageRequester("Error!","Can't find `c2edit.exe`")
  167.           EndIf
  168.           HideWindow(0,0)
  169.         Case 100:
  170.           End
  171.         Case 101:
  172.           If FileSize("Carma2_HW.exe") > 0
  173.             RunProgram("Carma2_HW.exe","","")
  174.             End
  175.           Else
  176.             MessageRequester("Error!","Can't find `Carma2_HW.exe`")
  177.           EndIf
  178.       EndSelect
  179.     EndIf
  180.   EndIf
  181. Until ev = #PB_Event_CloseWindow
  182.  
  183. ; IDE Options = PureBasic 5.20 LTS (Windows - x86)
  184. ; CursorPosition = 35
  185. ; FirstLine = 16
  186. ; Folding = -
  187. ; EnableXP
  188. ; CompileSourceDirectory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement