This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw_menu_start.py
69 lines (58 loc) · 2.3 KB
/
w_menu_start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import webbrowser
from direct.gui.OnscreenText import OnscreenText, TextNode
from direct.gui.DirectGui import (
DirectFrame,
DirectLabel,
DirectRadioButton)
from w_i_menu import IMenu
class StartMenu(IMenu):
def __init__(self):
frame = DirectFrame(frameSize=(base.a2dLeft, base.a2dRight,
base.a2dBottom, base.a2dTop),
frameColor=(0, 0, 0, 1.0))
IMenu.__init__(self, frame=frame)
self.menuVerticalChoicesList = [
{"event": "Menu-Start", "text": "New game"},
{"event": "Menu-Load", "text": "Load game"},
{"event": "Menu-Website", "text": "Visit Wholetone Games"},
{"event": "Menu-Quit", "text": "Quit"}
]
self.isFetchingSite = False
self.addTitle()
self.createVerticalButtons()
def createButton(self, text, index, eventArgs):
btn = DirectRadioButton(text=text,
text_align=TextNode.ACenter,
scale=0.07,
frameColor=(0, 0, 0, 0.0),
pos=(0, 0,
(-.10 - (index * .15))),
variable=self.menuVerticalChoice,
value=[index],
text_fg=(1, 1, 1, 1),
command=self.menuVerticalEvent)
self.menuVerticalButtons.append(btn)
btn.reparentTo(self.frameMain)
def websiteTask(self):
if not self.isFetchingSite:
self.isFetchingSite = True
taskMgr.add(self.openSite, 'openSite')
def openSite(self, task):
webbrowser.open('http://wholetonegames.blogspot.com', new=2)
taskMgr.doMethodLater(0.1, self.afterSiteLoads, 'site Loaded')
return task.done
def afterSiteLoads(self, task):
self.isFetchingSite = False
return task.done
def addTitle(self):
self.title = OnscreenText(
base.appName, 1,
fg=(1, 0, 0, 1),
pos=(0, 0.3),
font=base.font_title,
align=TextNode.ACenter,
scale=.5,
mayChange=1)
self.title.reparentTo(self.frameMain)
def cancelCommand(self):
pass