/
display.py
95 lines (75 loc) · 2.63 KB
/
display.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from kivy.app import App
from kivy.uix.image import Image
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.scrollview import ScrollView
from kivy.properties import NumericProperty, ReferenceListProperty,\
ObjectProperty, StringProperty
from kivy.vector import Vector
from kivy.clock import Clock
from kivy.lang import Builder
import buttons
import newgame
from dispatcher import dispatcher, recievelayout, recievebtnlayout
import time
import os
import pickle
state = 0
def makemap(num):
imglst = []
for x in range(0, num):
imglst.append(Image(source="/home/vega/Documents/GitHub/local/lyras-game/documents/mapbase_X.png"))
return imglst
class Map(GridLayout):
def __init__(self, **kwargs):
super(Map, self).__init__(**kwargs)
self.cols = 7
self.rows = 5
mapsize = self.cols * self.rows
self.padding = (5, 7)
imglst = makemap(mapsize)
for x in range(0, mapsize):
self.add_widget(imglst[x])
imglst[x].height = 200
imglst[x].width = 200
class BtnLayout(GridLayout):
def __init__(self, **kwargs):
super(BtnLayout, self).__init__(**kwargs)
btnlst = buttons.makebtns(15)
for x in range(0, 15):
btnlst[x].bind(on_press=self.clk)
self.add_widget(btnlst[x])
def clk(self, obj):
print(str(obj.text) + ": Button Pressed")
global state
state = dispatcher(obj, state)
def update(self):
for x in self.children:
if x.text == "blank" or x.text == "":
buttons.setbgrs_blank(x)
elif x.text == "inactive" or x.text == " ":
buttons.setbgrs_inactive(x)
else:
buttons.setbgrs_active(x)
class FinalLayout(Widget):
text = StringProperty("testtest")
def __init__(self, **kwargs):
super(FinalLayout, self).__init__(**kwargs)
self.text = "If you are seeing this something has gone very, very wrong. May the debugging gods take pitty on you."
def update(self, dt):
global state
obj = "invalid"
state = dispatcher(obj, state)
BtnLayout.update(self.children[0].children[0])
class LyraApp(App):
def build(self):
display = FinalLayout()
recievelayout(display)
recievebtnlayout(display.children[0].children[0])
Clock.schedule_interval(display.update, 1.0 / 60.0)
return display
LyraApp().run()