Mercurial > rinkhals
annotate gamelib/mainmenu.py @ 4:e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 12:48:02 +0000 |
parents | |
children | 67b79658b047 |
rev | line source |
---|---|
4
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
1 import pygame |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
2 from pgu import gui |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
3 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
4 class MainMenu(gui.Table): |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
5 def __init__(self,**params): |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
6 gui.Table.__init__(self,**params) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
7 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
8 def fullscreen_changed(btn): |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
9 #pygame.display.toggle_fullscreen() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
10 print "TOGGLE FULLSCREEN" |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
11 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
12 def stars_changed(slider): |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
13 n = slider.value - len(stars) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
14 if n < 0: |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
15 for i in range(n,0): |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
16 stars.pop() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
17 else: |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
18 for i in range(0,n): |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
19 stars.append([random.randrange(-W*span,W*span), |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
20 random.randrange(-H*span,H*span), |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
21 random.randrange(1,dist)]) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
22 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
23 fg = (255,255,255) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
24 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
25 self.tr() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
26 self.td(gui.Label("Phil's Pygame GUI",color=fg),colspan=2) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
27 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
28 self.tr() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
29 self.td(gui.Label("Speed: ",color=fg),align=1) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
30 e = gui.HSlider(100,-500,500,size=20,width=100,height=16,name='speed') |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
31 self.td(e) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
32 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
33 self.tr() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
34 self.td(gui.Label("Size: ",color=fg),align=1) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
35 e = gui.HSlider(2,1,5,size=20,width=100,height=16,name='size') |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
36 self.td(e) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
37 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
38 self.tr() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
39 self.td(gui.Label("Quantity: ",color=fg),align=1) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
40 e = gui.HSlider(100,1,1000,size=20,width=100,height=16,name='quantity') |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
41 e.connect(gui.CHANGE, stars_changed, e) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
42 self.td(e) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
43 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
44 self.tr() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
45 self.td(gui.Label("Color: ",color=fg),align=1) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
46 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
47 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
48 default = "#ffffff" |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
49 color = gui.Color(default,width=64,height=10,name='color') |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
50 # color_d = ColorDialog(default) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
51 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
52 # color.connect(gui.CLICK,color_d.open,None) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
53 # color_d.connect(gui.CHANGE,gui.action_setvalue,(color_d,color)) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
54 self.td(color) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
55 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
56 btn = gui.Switch(value=False,name='fullscreen') |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
57 btn.connect(gui.CHANGE, fullscreen_changed, btn) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
58 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
59 self.tr() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
60 self.td(gui.Label("Full Screen: ",color=fg),align=1) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
61 self.td(btn) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
62 |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
63 self.tr() |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
64 self.td(gui.Label("Warp Speed: ",color=fg),align=1) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
65 self.td(gui.Switch(value=False,name='warp')) |
e8ddbc95cbf3
Silly (and broken) first stab at menu thing.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff
changeset
|
66 |