Skip to content

Commit

Permalink
Started "new game" popup implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
exomo committed Dec 12, 2017
1 parent 1de2627 commit 0d8080a
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 23 deletions.
107 changes: 87 additions & 20 deletions GUI/KickerUi.kv
Original file line number Diff line number Diff line change
Expand Up @@ -242,30 +242,41 @@
#padding_x: dp(15)

<NewGamePopup>:
title: 'Neuer Spieler'
title: 'Neues Spiel'
auto_dismiss: False
enable_ok: True
size_hint: None, None
size: 600, 400
player_name: player_name
token_id: 'Hallo'
size: 700, 450
#team1: team1
#team2: team2
BoxLayout:
orientation: 'vertical'
Label:
text: "Neues Spiel"
Label:
text: 'Name:'
size_hint: 1, .1
TextInput:
id: player_name
multiline: False
size_hint: 1, .15
focus: True
text_validate_unfocus: False
hint_text: 'Spielername eingeben'
#on_text: root.validate_input()
#on_text_validate: if root.enable_ok: root.on_ok()
# on_focus: root.on_focus(*args)
BoxLayout:
canvas.before:
Color:
rgba: 0,1,0,1
Rectangle:
size: self.size
pos: self.pos
orientation: 'horizontal'
size_hint_y: 1
TeamDisplay:
id: team1
team: 'Team 1'
size_hint: 1, 0.25
Image:
canvas.before:
Color:
rgba: 0,0,1,1
Rectangle:
size: self.size
pos: self.pos
source: 'GUI/Kicker_top.jpg'
size_hint_x: 0.5
TeamDisplay:
id: team2
team: 'Team 2'
size_hint: 1, 0.25
BoxLayout:
size_hint_y: 0.1
orientation: 'horizontal'
Expand All @@ -275,8 +286,64 @@
Button:
text: 'OK'
disabled: not root.enable_ok
#on_release: root.on_ok()
on_release: root.on_ok()

<TeamDisplay@BoxLayout>:
canvas.before:
Color:
rgba: 1,0,0,1
Rectangle:
size: self.size
pos: self.pos
team: ''
player1: ''
player2: ''
score: 0
orientation: 'vertical'
Label:
text: '[b]' + root.team + '[/b]'
markup: True
size_hint_y: 0.1
halign: 'center'
valign: 'top'
canvas.before:
Color:
rgba: 0,1,1,1
Rectangle:
size: self.size
pos: self.pos
Label:
text: root.player1
markup: True
size_hint_y: 0.5
halign: 'center'
valign: 'middle'
Label:
text: '&'
markup: True
size_hint_y: 0.1
halign: 'center'
valign: 'middle'
Label:
text: root.player2
markup: True
size_hint_y: 0.5
halign: 'center'
valign: 'middle'
BoxLayout:
orientation: 'horizontal'
padding: 0.1
size_hint_y: 0.2
Button:
text: '-'
on_release: root.score -= 1
TextInput:
id: team1_score
text: str(root.score)
Button:
text: '+'
on_release: root.score += 1

<AdminPage@BoxLayout>:
BoxLayout:
orientation: 'vertical'
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion GUI/gui_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def __init__(self, parent, controller):
labelPlayer2 = tk.Label(self, textvariable=self.player2Name)
labelPlayer2.grid(row=4, column=0, columnspan=3)

image = Image.open("Kicker_top.jpg")
image = Image.open("GUI/Kicker_top.jpg")
photo = ImageTk.PhotoImage(image)

topview = tk.Label(self, image=photo)
Expand Down
39 changes: 37 additions & 2 deletions GUI/kivy_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class GamePage(BoxLayout):

def new_game(self, text):
"""show popup to add new game"""
popup = NewGamePopup()
popup = NewGamePopup(self.game_list)
popup.open()
print("Show the 'New Game' popup")
self.game_list.refresh()
Expand All @@ -162,7 +162,42 @@ def refresh(self):
for i, game in enumerate(games)]

class NewGamePopup(Popup):
pass
"""Popup to enter a new game"""
team1 = ObjectProperty()
team2 = ObjectProperty()

def __init__(self, game_list, **kwargs):
super(NewGamePopup, self).__init__(**kwargs)
self.game_list = game_list
self.players = []
#self.timer = Clock.schedule_interval(self.on_interval, 0.1)
#self.team1.player1 = 'Spieler 1\n[b]Bitte Token einlesen[/b]'

def on_interval(self, time_elapsed):
token = rfidReader.TryGetToken()
if token is not None:
player = db.get_player(token)
if player is not None and not player.tokenID in [p.tokenID for p in self.players]:
self.players.append(player)
player_number = len(self.players)
if player_number == 1:
self.team1.player1 = player.name
self.team1.player2 = 'Spieler 2\n[b]Bitte Token einlesen[/b]'
elif player_number == 2:
self.team1.player2 = player.name
self.team2.player1 = 'Spieler 3\n[b]Bitte Token einlesen[/b]'
elif player_number == 3:
self.team2.player1 = player.name
self.team2.player2 = 'Spieler 4\n[b]Bitte Token einlesen[/b]'
elif player_number == 4:
self.team2.player2 = player.name
self.timer.cancel()

def on_ok(self):
print('{:d} : {:d}'.format(self.team1.score, self.team2.score))

def on_dismiss(self):
self.timer.cancel()

class KickerApp(App):
"""
Expand Down

0 comments on commit 0d8080a

Please sign in to comment.