Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;c2l
- Global RunDir.s = GetPathPart(ProgramFilename())
- Global PlayButtonChanged,SettingsButtonChanged,ExitButtonChanged
- UsePNGImageDecoder()
- Background = CatchImage(0,?Background)
- BackgroundOver = CatchImage(1,?BackgroundOver)
- SettingsButton = CatchImage(2,?SettingsButton)
- SettingsButtonMin = CatchImage(3,?SettingsButtonMin)
- ExitButton = CatchImage(4,?ExitButton)
- ExitButtonMin = CatchImage(5,?ExitButtonMin)
- VideoButton = CatchImage(6,?VideoButton)
- CarButton = CatchImage(7,?CarButton)
- EditButton = CatchImage(8,?EditButton)
- DataSection
- Background:
- IncludeBinary "back.png"
- BackgroundOver:
- IncludeBinary "back_over.png"
- SettingsButton:
- IncludeBinary "settings.png"
- SettingsButtonMin:
- IncludeBinary "settings_min.png"
- ExitButton:
- IncludeBinary "exit.png"
- ExitButtonMin:
- IncludeBinary "exit_min.png"
- VideoButton:
- IncludeBinary "video.ico"
- CarButton:
- IncludeBinary "car.ico"
- EditButton:
- IncludeBinary "edit.ico"
- EndDataSection
- Procedure.b MouseOverGadget(window.l, gadget.l, offsetX.l=0, offsetY.l=0)
- gadgetX.l = GadgetX(gadget) + offsetX
- gadgetY.l = GadgetY(gadget) + offsetY
- gadgetW.l = GadgetWidth(gadget)
- gadgetH.l = GadgetHeight(gadget)
- mouseX.l = WindowMouseX(window)
- mouseY.l = WindowMouseY(window)
- If (mouseX >= gadgetX) And (mouseY >= gadgetY) And (mouseX <= (gadgetX + gadgetW - 1)) And (mouseY <= (gadgetY + gadgetH - 1))
- ProcedureReturn #True
- Else
- ProcedureReturn #False
- EndIf
- EndProcedure
- Procedure.b MouseOverDude()
- X.l = 120
- Y.l = 0
- W.l = 240
- H.l = 240
- mouseX.l = WindowMouseX(window)
- mouseY.l = WindowMouseY(window)
- If (mouseX >= X) And (mouseY >= Y) And (mouseX <= (X + W - 1)) And (mouseY <= (Y + H - 1))
- ProcedureReturn #True
- Else
- ProcedureReturn #False
- EndIf
- EndProcedure
- If OpenWindow(0,#PB_Ignore,#PB_Ignore,480,240,"C2",#PB_Window_ScreenCentered|#PB_Window_BorderLess|#PB_Window_Invisible)
- AddKeyboardShortcut(0,#PB_Shortcut_Escape,100)
- AddKeyboardShortcut(0,#PB_Shortcut_Return,101)
- If CreatePopupImageMenu(1)
- MenuItem(1,"Video settings",VideoButton)
- MenuItem(2,"Carstockalypse",CarButton)
- MenuItem(3,"Game editor",EditButton)
- EndIf
- ImageGadget(0,0,0,480,240,Background)
- DisableGadget(0,1)
- ;hbrBackground = CreatePatternBrush_(Background)
- ;SetClassLong_(WindowID(0),#GCL_HBRBACKGROUND,hbrBackground)
- ImageGadget(1,8,8,32,32,SettingsButton)
- ImageGadget(2,440,8,32,32,ExitButton)
- ;SetWindowCallback(@WCB(),0)
- RedrawWindow_(WindowID(0),0,0,#RDW_INVALIDATE)
- HideWindow(0,0)
- EndIf
- Repeat
- ev = WaitWindowEvent(50)
- If ev = #PB_Event_Gadget And EventType() = #PB_EventType_LeftClick
- Select EventGadget()
- Case 1:
- ; settings
- DisplayPopupMenu(1,WindowID(0))
- Case 2:
- ; exit
- End
- EndSelect
- Else
- If MouseOverGadget(0,1) And SettingsButtonChanged = 0
- SetGadgetState(1,SettingsButtonMin)
- SettingsButtonChanged = 1
- EndIf
- If Not MouseOverGadget(0,1) And SettingsButtonChanged = 1
- SetGadgetState(1,SettingsButton)
- SettingsButtonChanged = 0
- EndIf
- If MouseOverGadget(0,2) And ExitButtonChanged = 0
- SetGadgetState(2,ExitButtonMin)
- ExitButtonChanged = 1
- EndIf
- If Not MouseOverGadget(0,2) And ExitButtonChanged = 1
- SetGadgetState(2,ExitButton)
- ExitButtonChanged = 0
- EndIf
- If MouseOverDude() And PlayButtonChanged = 0
- ;Debug "over"
- SetGadgetState(0,BackgroundOver)
- SetGadgetState(1,SettingsButton)
- SetGadgetState(2,ExitButton)
- ;DisableGadget(0,1)
- ;RedrawWindow_(WindowID(0),0,0,#RDW_INVALIDATE)
- PlayButtonChanged = 1
- EndIf
- If Not MouseOverDude() And PlayButtonChanged = 1
- ;Debug "not over"
- SetGadgetState(0,Background)
- SetGadgetState(1,SettingsButton)
- SetGadgetState(2,ExitButton)
- ;DisableGadget(0,1)
- ;RedrawWindow_(WindowID(0),0,0,#RDW_INVALIDATE)
- PlayButtonChanged = 0
- EndIf
- If MouseOverDude() And ev = #WM_LBUTTONDOWN
- If FileSize("Carma2_HW.exe") > 0
- RunProgram("Carma2_HW.exe","","")
- End
- Else
- MessageRequester("Error!","Can't find `Carma2_HW.exe`")
- EndIf
- EndIf
- If ev = #WM_LBUTTONDOWN And WindowMouseX(0) < 600 And WindowMouseY(0) < 400 And GetActiveWindow() = 0
- SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN,#HTCAPTION,0)
- EndIf
- If ev = #PB_Event_Menu
- Select EventMenu()
- Case 1:
- HideWindow(0,1)
- If FileSize("nglide_config.exe") > 0
- RunProgram("nglide_config.exe","","",#PB_Program_Wait)
- Else
- MessageRequester("Error!","Can't find `nglide_config.exe`")
- EndIf
- HideWindow(0,0)
- Case 2:
- HideWindow(0,1)
- If FileSize("carstockalypse.exe") > 0
- RunProgram("carstockalypse.exe","","",#PB_Program_Wait)
- Else
- MessageRequester("Error!","Can't find `carstockalypse.exe`")
- EndIf
- HideWindow(0,0)
- Case 3:
- HideWindow(0,1)
- If FileSize("c2edit.exe") > 0
- RunProgram("c2edit.exe","","",#PB_Program_Wait)
- Else
- MessageRequester("Error!","Can't find `c2edit.exe`")
- EndIf
- HideWindow(0,0)
- Case 100:
- End
- Case 101:
- If FileSize("Carma2_HW.exe") > 0
- RunProgram("Carma2_HW.exe","","")
- End
- Else
- MessageRequester("Error!","Can't find `Carma2_HW.exe`")
- EndIf
- EndSelect
- EndIf
- EndIf
- Until ev = #PB_Event_CloseWindow
- ; IDE Options = PureBasic 5.20 LTS (Windows - x86)
- ; CursorPosition = 35
- ; FirstLine = 16
- ; Folding = -
- ; EnableXP
- ; CompileSourceDirectory
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement