Re #752 WIP track and car select menus (replacing race menu) + improved combobox and checkbox look

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5070 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: acd5add01b7d623d3beed8f1bdfc8a94c6762621
Former-commit-id: 9bd76820cde8667540e00d18a7b291f8959970b8
This commit is contained in:
pouillot 2012-12-16 19:47:58 +00:00
parent 4d58bfeb64
commit 88ce7b56a8
16 changed files with 322 additions and 192 deletions

View file

@ -7,13 +7,15 @@
<Item path="datafiles/imagesets/splash-credits.imageset" type="file" />
<Item path="datafiles/imagesets/splash-main.imageset" type="file" />
<Item path="datafiles/imagesets/splash-options.imageset" type="file" />
<Item path="datafiles/imagesets/splash-race.imageset" type="file" />
<Item path="datafiles/imagesets/splash-carselect.imageset" type="file" />
<Item path="datafiles/imagesets/splash-trackselect.imageset" type="file" />
</Item>
<Item name="Layouts" type="folder">
<Item path="datafiles/layouts/menucredits.layout" type="file" />
<Item path="datafiles/layouts/menumain.layout" type="file" />
<Item path="datafiles/layouts/menuoptions.layout" type="file" />
<Item path="datafiles/layouts/menurace.layout" type="file" />
<Item path="datafiles/layouts/menucarselect.layout" type="file" />
<Item path="datafiles/layouts/menutrackselect.layout" type="file" />
</Item>
<Item name="Schemes" type="folder">
<Item path="datafiles/schemes/ceguidemo.scheme" type="file" />

View file

@ -18,12 +18,12 @@
<Image Height="16" Name="ButtonLeftHighlight" Width="12" XPos="68" YPos="56" />
<Image Height="16" Name="ButtonMiddleHighlight" Width="12" XPos="82" YPos="56" />
<Image Height="16" Name="ButtonRightHighlight" Width="12" XPos="96" YPos="56" />
<Image Height="12" Name="CheckboxNormal" Width="12" XPos="110" YPos="2" />
<Image Height="12" Name="CheckboxHover" Width="12" XPos="110" YPos="30" />
<Image Height="12" Name="CheckboxMark" Width="12" XPos="110" YPos="16" />
<Image Height="12" Name="RadioButtonNormal" Width="12" XPos="124" YPos="2" />
<Image Height="12" Name="RadioButtonHover" Width="12" XPos="124" YPos="30" />
<Image Height="12" Name="RadioButtonMark" Width="12" XPos="124" YPos="16" />
<Image Height="24" Name="CheckboxNormal" Width="24" XPos="110" YPos="1" />
<Image Height="24" Name="CheckboxHover" Width="24" XPos="110" YPos="51" />
<Image Height="24" Name="CheckboxMark" Width="24" XPos="110" YPos="26" />
<Image Height="12" Name="RadioButtonNormal" Width="12" XPos="241" YPos="190" />
<Image Height="12" Name="RadioButtonHover" Width="12" XPos="241" YPos="218" />
<Image Height="12" Name="RadioButtonMark" Width="12" XPos="241" YPos="204" />
<Image Height="16" Name="TitlebarLeft" Width="8" XPos="68" YPos="2" />
<Image Height="16" Name="TitlebarMiddle" Width="8" XPos="78" YPos="2" />
<Image Height="16" Name="TitlebarRight" Width="8" XPos="88" YPos="2" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -0,0 +1,4 @@
<?xml version="1.0" ?>
<Imageset Name="SplashCarSelect" AutoScaled="true" Imagefile="splash-carselect.jpg" NativeHorzRes="800" NativeVertRes="600">
<Image Name="everything" Height="800" Width="1280" XPos="0" YPos="0" />
</Imageset>

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

View file

@ -1,4 +0,0 @@
<?xml version="1.0" ?>
<Imageset Name="SplashRace" AutoScaled="true" Imagefile="splash-race.jpg" NativeHorzRes="800" NativeVertRes="600">
<Image Name="everything" Height="800" Width="1280" XPos="0" YPos="0" />
</Imageset>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" ?>
<Imageset Name="SplashTrackSelect" AutoScaled="true" Imagefile="splash-trackselect.jpg" NativeHorzRes="800" NativeVertRes="600">
<Image Name="everything" Height="800" Width="1280" XPos="0" YPos="0" />
</Imageset>

View file

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View file

@ -163,18 +163,18 @@
</AutoWindow>
</Window>
<Window Name="MenuOptions/CkxFullScreen" Type="CEGUIDemo/Checkbox">
<Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.35,0},{0.6,0},{0.42,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.35,0},{0.70,0},{0.45,0}}" />
<Property Name="Font" Value="MenuSmall" />
</Window>
<Window Name="MenuOptions/RbnVInitBest" Type="CEGUIDemo/RadioButton">
<Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.45,0},{0.65,0},{0.52,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.45,0},{0.70,0},{0.55,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Best" />
<Property Name="GroupID" Value="1" />
<Property Name="Tooltip" Value="Enable best supported features" />
</Window>
<Window Name="MenuOptions/RbnVInitCompat" Type="CEGUIDemo/RadioButton">
<Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.45,0},{0.8,0},{0.52,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.45,0},{0.80,0},{0.55,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Compatible" />
<Property Name="GroupID" Value="1" />
@ -217,11 +217,17 @@
<Property Name="MaxTextLength" Value="4" />
<Property Name="TextFormatting" Value="RightAligned" />
</Window>
<Window Name="MenuOptions/BtnBack" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.43,0},{0.9,0},{0.58,0},{0.95,0}}" />
<Window Name="MenuOptions/BtnAccept" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.23,0},{0.9,0},{0.38,0},{0.95,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Back" />
<Property Name="Tooltip" Value="Back to main benu" />
<Property Name="Text" Value="Accept" />
<Property Name="Tooltip" Value="Accept changes and go back to main benu" />
</Window>
<Window Name="MenuOptions/BtnCancel" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.63,0},{0.9,0},{0.78,0},{0.95,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Cancel" />
<Property Name="Tooltip" Value="Revert changes and go back to main benu" />
</Window>
</Window>
</GUILayout>

View file

@ -1,21 +1,21 @@
<GUILayout>
<Window Name="MenuRace" Type="CEGUIDemo/StaticImage">
<Window Name="MenuTrackSelect" Type="CEGUIDemo/StaticImage">
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
<Property Name="Image" Value="set:SplashRace image:everything" />
<Property Name="Image" Value="set:SplashTrackSelect image:everything" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="FrameEnabled" Value="False" />
<Property Name="BackgroundEnabled" Value="False" />
<Window Name="MenuRace/ImgLogo" Type="CEGUIDemo/StaticImage">
<Window Name="MenuTrackSelect/ImgLogo" Type="CEGUIDemo/StaticImage">
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{0.3,0},{0.25,0}}" />
<Property Name="Image" Value="set:Logo image:everything" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="FrameEnabled" Value="False" />
<Property Name="BackgroundEnabled" Value="False" />
</Window>
<Window Name="MenuRace/TxtTitle" Type="CEGUIDemo/PageTitle">
<Window Name="MenuTrackSelect/TxtTitle" Type="CEGUIDemo/PageTitle">
<Property Name="UnifiedAreaRect" Value="{{0.22,0},{0.1,0},{0.92,0},{0.2,0}}" />
<Property Name="Font" Value="MenuBig" />
<Property Name="Text" Value="Race" />
<Property Name="Text" Value="Select a track" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="Tooltip" Value="Yeah, this is the title of the menu !" />
<Property Name="FrameEnabled" Value="False" />
@ -44,7 +44,7 @@
</AutoWindow>
</AutoWindow>
</Window>
<Window Name="MenuRace/TxtFrameRate" Type="CEGUIDemo/StaticText">
<Window Name="MenuTrackSelect/TxtFrameRate" Type="CEGUIDemo/StaticText">
<Property Name="UnifiedAreaRect" Value="{{0.95,0},{0.01,0},{0.99,0},{0.04,0}}" />
<Property Name="Font" Value="TextSmall" />
<Property Name="Text" Value="99.9" />
@ -80,41 +80,102 @@
</AutoWindow>
</AutoWindow>
</Window>
<Window Name="MenuRace/BtnCredits" Type="CEGUIDemo/Button">
<Window Name="MenuTrackSelect/BtnCredits" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.3,0},{0,0},{0.43,0},{0.05,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Credits" />
<Property Name="Tooltip" Value="Thanks to all contributors !" />
</Window>
<Window Name="MenuRace/BtnProfiles" Type="CEGUIDemo/Button">
<Window Name="MenuTrackSelect/BtnProfiles" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.45,0},{0,-1},{0.58,0},{0.05,-1}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Profiles" />
<Property Name="Tooltip" Value="Configure player input controls / profiles" />
</Window>
<Window Name="MenuRace/BtnOptions" Type="CEGUIDemo/Button">
<Window Name="MenuTrackSelect/BtnOptions" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.6,0},{0,0},{0.73,0},{0.05,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Options" />
<Property Name="Tooltip" Value="Settings for display, graphics, simulation ..." />
</Window>
<Window Name="MenuRace/BtnExit" Type="CEGUIDemo/Button">
<Window Name="MenuTrackSelect/BtnExit" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.75,0},{0,0},{0.88,0},{0.05,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Exit" />
<Property Name="Tooltip" Value="Exit from the game" />
</Window>
<Window Name="MenuRace/BtnBack" Type="CEGUIDemo/Button">
<Window Name="MenuTrackSelect/BtnBack" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.9,0},{0.25,0},{0.95,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Back" />
<Property Name="Tooltip" Value="Back to main benu" />
</Window>
<Window Name="MenuRace/BtnStart" Type="CEGUIDemo/Button">
<Window Name="MenuTrackSelect/BtnNext" Type="CEGUIDemo/Button">
<Property Name="UnifiedAreaRect" Value="{{0.75,0},{0.9,0},{0.9,0},{0.95,0}}" />
<Property Name="Font" Value="MenuMedium" />
<Property Name="Text" Value="Start" />
<Property Name="Tooltip" Value="Start a new race" />
<Property Name="Tooltip" Value="Select you car for the race" />
</Window>
<Window Name="MenuTrackSelect/MclTracks" Type="CEGUIDemo/MultiColumnList">
<Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.346667,0},{0.9,0},{0.845,0}}" />
</Window>
<Window Name="MenuTrackSelect/TxtCategory" Type="CEGUIDemo/StaticText">
<Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.25,0},{0.27625,0},{0.331667,0}}" />
<Property Name="Font" Value="MenuNormal" />
<Property Name="Text" Value="Category :" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="FrameEnabled" Value="False" />
<Property Name="VertFormatting" Value="TopAligned" />
<Property Name="BackgroundEnabled" Value="False" />
</Window>
<Window Name="MenuTrackSelect/CbxCategory" Type="CEGUIDemo/Combobox">
<Property Name="UnifiedAreaRect" Value="{{0.3,0},{0.25,0},{0.9,0},{0.5,0}}" />
<Property Name="Font" Value="MenuNormal" />
<Property Name="ReadOnly" Value="True" />
<Property Name="Tooltip" Value="Choose the category of the track" />
<AutoWindow NameSuffix="__auto_editbox__">
<Property Name="Font" Value="MenuNormal" />
<Property Name="ReadOnly" Value="True" />
<Property Name="Tooltip" Value="Choose the category of the track" />
<Property Name="ActiveSelectionColour" Value="FF6060FF" />
</AutoWindow>
<AutoWindow NameSuffix="__auto_droplist__">
<Property Name="Font" Value="MenuNormal" />
<Property Name="Tooltip" Value="Choose the category of the track" />
<AutoWindow NameSuffix="__auto_hscrollbar__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<AutoWindow NameSuffix="__auto_incbtn__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<Property Name="RestoreOldCapture" Value="True" />
</AutoWindow>
<AutoWindow NameSuffix="__auto_decbtn__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<Property Name="RestoreOldCapture" Value="True" />
</AutoWindow>
<AutoWindow NameSuffix="__auto_thumb__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<Property Name="RestoreOldCapture" Value="True" />
</AutoWindow>
</AutoWindow>
<AutoWindow NameSuffix="__auto_vscrollbar__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<AutoWindow NameSuffix="__auto_incbtn__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<Property Name="RestoreOldCapture" Value="True" />
</AutoWindow>
<AutoWindow NameSuffix="__auto_decbtn__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<Property Name="RestoreOldCapture" Value="True" />
</AutoWindow>
<AutoWindow NameSuffix="__auto_thumb__">
<Property Name="Tooltip" Value="Choose the category of the track" />
<Property Name="RestoreOldCapture" Value="True" />
</AutoWindow>
</AutoWindow>
</AutoWindow>
<AutoWindow NameSuffix="__auto_button__">
<Property Name="Tooltip" Value="Choose the category of the track" />
</AutoWindow>
</Window>
</Window>
</GUILayout>

View file

@ -3,7 +3,8 @@
<Imageset Filename="ceguidemolook.imageset" />
<Imageset Filename="sd-logo.imageset" />
<Imageset Filename="splash-main.imageset" />
<Imageset Filename="splash-race.imageset" />
<Imageset Filename="splash-trackselect.imageset" />
<Imageset Filename="splash-carselect.imageset" />
<Imageset Filename="splash-credits.imageset" />
<Imageset Filename="splash-options.imageset" />
<Font Name="MenuSmall" Filename="menu-small.font" />

View file

@ -0,0 +1,68 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Car selection menu.
"""
# Import: std
import sys
# Import: PyCEGUI
import PyCEGUI
# Import: Configuration
from configuration import TheConfig
# Import: Menu
from menustandard import MenuStandard
from menucredits import MenuCredits
from menuoptions import MenuOptions
# Car selection menu
class MenuCarSelect(MenuStandard):
def __init__(self):
MenuStandard.__init__(self, MenuCredits, MenuOptions) #, MenuProfiles, )
# Initialize
def initialize(self):
name = "MenuCarSelect"
# No code written for this menu : use mandatory layout.
window = MenuStandard.initialize(self, name=name, title="Select a car", layout="menucarselect")
# Retrieve the window descendants created here.
self.btnBack = window.getChild(name + "/BtnBack")
self.btnStart = window.getChild(name + "/BtnStart")
# Complete widget initialization.
# TODO.
return window
# connectHandlers
# - Wrapper method to define the subscription/listener relationships.
# - If there are a lot, it may behoove the coder to encapsulate them in methods, then call those methods here.
def connectHandlers(self):
# Inherited connections.
MenuStandard.connectHandlers(self)
# Specific connections.
self.btnBack.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onBackButtonClicked")
self.btnStart.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onStartButtonClicked")
# Handler: buttonClicked
def onStartButtonClicked(self, args):
print("onStartButtonClicked")
def onBackButtonClicked(self, args):
print("onBackButtonClicked")
self.back()

View file

@ -20,7 +20,7 @@ from configuration import TheConfig
from menustandard import MenuStandard
from menucredits import MenuCredits
from menuoptions import MenuOptions
from menurace import MenuRace
from menutrackselect import MenuTrackSelect
# Main menu
class MenuMain(MenuStandard):
@ -29,7 +29,7 @@ class MenuMain(MenuStandard):
MenuStandard.__init__(self, MenuCredits, MenuOptions) #, MenuProfiles, )
self.menuRace = None
self.menuTrackSelect = None
# Initialize
def initialize(self):
@ -128,24 +128,24 @@ class MenuMain(MenuStandard):
def onPracticeButtonClicked(self, args):
print("onPracticeButtonClicked")
self.activateRaceMenu()
self.activateTrackSelectMenu()
def onQuickRaceButtonClicked(self, args):
print("onQuickRaceButtonClicked")
self.activateRaceMenu()
self.activateTrackSelectMenu()
def onSingleEventButtonClicked(self, args):
print("onSingleEventButtonClicked")
self.activateRaceMenu()
self.activateTrackSelectMenu()
def activateRaceMenu(self):
def activateTrackSelectMenu(self):
if not self.menuRace:
self.menuRace = MenuRace()
self.menuRace.initialize()
self.menuRace.setup()
if not self.menuTrackSelect:
self.menuTrackSelect = MenuTrackSelect()
self.menuTrackSelect.initialize()
self.menuTrackSelect.setup()
self.menuRace.activate(previous=self)
self.menuTrackSelect.activate(previous=self)

View file

@ -31,34 +31,26 @@ class MenuOptions(Menu):
name = "MenuOptions"
# Use layout if specified.
if TheConfig.useLayouts:
window = Menu.initialize(self, name=name, title="Options", layout="menuoptions")
else:
# If no layout specified, go on building up the menu through code.
window = Menu.initialize(self, name=name, title="Options", background="SplashOptions")
# Specific to this menu.
winMgr = PyCEGUI.WindowManager.getSingleton()
btnBack = PyCEGUI.WindowManager.getSingleton().createWindow("CEGUIDemo/Button", name + "/BtnBack")
btnBack.setText("Back")
btnBack.setTooltipText("Back to the main menu")
btnBack.setXPosition(PyCEGUI.UDim(0.43, 0.0))
btnBack.setYPosition(PyCEGUI.UDim(0.9, 0.0))
btnBack.setWidth(PyCEGUI.UDim(0.15, 0.0))
btnBack.setHeight(PyCEGUI.UDim(0.05, 0.0))
btnBack.setProperty("Font", "MenuMedium")
window.addChildWindow(btnBack)
# No code written for this menu : use mandatory layout.
window = Menu.initialize(self, name=name, title="Options", layout="menuoptions")
# Retrieve window descendants created here.
self.btnBack = window.getChild(name + "/BtnBack")
self.btnAccept = window.getChild(name + "/BtnAccept")
self.btnCancel = window.getChild(name + "/BtnCancel")
self.cbxWinSize = window.getChild(name + "/CbxWindowSize")
# Complete widget initialization.
self.cbxWinSizeItems = []
cbxItem = PyCEGUI.ListboxTextItem(" 800 x 512")
self.cbxWinSize.addItem(cbxItem)
self.cbxWinSizeItems.append(cbxItem)
cbxItem = PyCEGUI.ListboxTextItem("1280 x 800")
self.cbxWinSize.addItem(cbxItem)
self.cbxWinSizeItems.append(cbxItem)
cbxItem = PyCEGUI.ListboxTextItem("1680 x 1050")
self.cbxWinSize.addItem(cbxItem)
self.cbxWinSizeItems.append(cbxItem)
# Complete widget initialization (whatever creation mode : code or .layout).
# TODO.
return window
@ -72,10 +64,16 @@ class MenuOptions(Menu):
Menu.connectHandlers(self)
# Specific connections.
self.btnBack.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onBackButtonClicked")
self.btnCancel.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onCancelButtonClicked")
self.btnAccept.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onAcceptButtonClicked")
def onBackButtonClicked(self, args):
def onCancelButtonClicked(self, args):
print("onBackButtonClicked")
print("onCancelButtonClicked")
self.back()
def onAcceptButtonClicked(self, args):
print("onAcceptButtonClicked")
self.back()

View file

@ -1,97 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Race menu.
"""
# Import: std
import sys
# Import: PyCEGUI
import PyCEGUI
# Import: Configuration
from configuration import TheConfig
# Import: Menu
from menustandard import MenuStandard
from menucredits import MenuCredits
from menuoptions import MenuOptions
# Race menu
class MenuRace(MenuStandard):
def __init__(self):
MenuStandard.__init__(self, MenuCredits, MenuOptions) #, MenuProfiles, )
# Initialize
def initialize(self):
name = "MenuRace"
# Use layout if specified.
if TheConfig.useLayouts:
window = MenuStandard.initialize(self, name=name, title="Race", layout="menurace")
else:
# If no layout specified, go on building up the menu through code.
window = MenuStandard.initialize(self, name=name, title="Race", background="SplashRace")
# Specific to this menu.
btnStart = PyCEGUI.WindowManager.getSingleton().createWindow("CEGUIDemo/Button", name + "/BtnStart")
btnStart.setText("Start")
btnStart.setTooltipText("Start to the main menu")
btnStart.setXPosition(PyCEGUI.UDim(0.75, 0.0))
btnStart.setYPosition(PyCEGUI.UDim(0.9, 0.0))
btnStart.setWidth(PyCEGUI.UDim(0.15, 0.0))
btnStart.setHeight(PyCEGUI.UDim(0.05, 0.0))
btnStart.setProperty("Font", "MenuMedium")
window.addChildWindow(btnStart)
btnBack = PyCEGUI.WindowManager.getSingleton().createWindow("CEGUIDemo/Button", name + "/BtnBack")
btnBack.setText("Back")
btnBack.setTooltipText("Back to the main menu")
btnBack.setXPosition(PyCEGUI.UDim(0.1, 0.0))
btnBack.setYPosition(PyCEGUI.UDim(0.9, 0.0))
btnBack.setWidth(PyCEGUI.UDim(0.15, 0.0))
btnBack.setHeight(PyCEGUI.UDim(0.05, 0.0))
btnBack.setProperty("Font", "MenuMedium")
window.addChildWindow(btnBack)
# Retrieve the window descendants created here.
self.btnBack = window.getChild(name + "/BtnBack")
self.btnStart = window.getChild(name + "/BtnStart")
# Complete widget initialization (whatever creation mode : code or .layout).
return window
# connectHandlers
# - Wrapper method to define the subscription/listener relationships.
# - If there are a lot, it may behoove the coder to encapsulate them in methods, then call those methods here.
def connectHandlers(self):
# Inherited connections.
MenuStandard.connectHandlers(self)
# Specific connections.
self.btnBack.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onBackButtonClicked")
self.btnStart.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onStartButtonClicked")
# Handler: buttonClicked
def onStartButtonClicked(self, args):
print("onStartButtonClicked")
def onBackButtonClicked(self, args):
print("onBackButtonClicked")
self.back()

View file

@ -0,0 +1,87 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Track selection menu.
"""
# Import: std
import sys
# Import: PyCEGUI
import PyCEGUI
# Import: Configuration
from configuration import TheConfig
# Import: Menu
from menustandard import MenuStandard
from menucredits import MenuCredits
from menuoptions import MenuOptions
from menucarselect import MenuCarSelect
# Track selection menu
class MenuTrackSelect(MenuStandard):
def __init__(self):
MenuStandard.__init__(self, MenuCredits, MenuOptions) #, MenuProfiles, )
self.menuCarSelect = None
# Initialize
def initialize(self):
name = "MenuTrackSelect"
# No code written for this menu : use mandatory layout.
window = MenuStandard.initialize(self, name=name, title="Select a track", layout="menutrackselect")
# Retrieve the window descendants created here.
self.btnBack = window.getChild(name + "/BtnBack")
self.btnNext = window.getChild(name + "/BtnNext")
self.cbxCat = window.getChild(name + "/CbxCategory")
# Complete widget initialization.
self.cbxCatItems = []
cbxItem = PyCEGUI.ListboxTextItem("Grand Prix")
self.cbxCat.addItem(cbxItem)
self.cbxCatItems.append(cbxItem)
cbxItem = PyCEGUI.ListboxTextItem("Road")
self.cbxCat.addItem(cbxItem)
self.cbxCatItems.append(cbxItem)
cbxItem = PyCEGUI.ListboxTextItem("Dirt")
self.cbxCat.addItem(cbxItem)
self.cbxCatItems.append(cbxItem)
# TODO.
return window
# connectHandlers
# - Wrapper method to define the subscription/listener relationships.
# - If there are a lot, it may behoove the coder to encapsulate them in methods, then call those methods here.
def connectHandlers(self):
# Inherited connections.
MenuStandard.connectHandlers(self)
# Specific connections.
self.btnBack.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onBackButtonClicked")
self.btnNext.subscribeEvent(PyCEGUI.PushButton.EventClicked, self, "onNextButtonClicked")
# Handler: buttonClicked
def onNextButtonClicked(self, args):
if not self.menuCarSelect:
self.menuCarSelect = MenuCarSelect()
self.menuCarSelect.initialize()
self.menuCarSelect.setup()
self.menuCarSelect.activate(previous=self)
def onBackButtonClicked(self, args):
self.back()