Adjust UI to be compact
parent
453bd3cd49
commit
5f3bd45d11
27
UI.py
27
UI.py
|
@ -34,8 +34,9 @@ class GenericUI:
|
||||||
if event.type == pygame.MOUSEBUTTONDOWN:
|
if event.type == pygame.MOUSEBUTTONDOWN:
|
||||||
mouse_pos = pygame.mouse.get_pos()
|
mouse_pos = pygame.mouse.get_pos()
|
||||||
if self.hold_function and self.collide_at(mouse_pos):
|
if self.hold_function and self.collide_at(mouse_pos):
|
||||||
self.hold_function(mouse_pos)
|
if event.button == 1:
|
||||||
draw_update = True
|
self.hold_function(mouse_pos)
|
||||||
|
draw_update = True
|
||||||
|
|
||||||
if event.type == pygame.MOUSEBUTTONUP:
|
if event.type == pygame.MOUSEBUTTONUP:
|
||||||
mouse_pos = pygame.mouse.get_pos()
|
mouse_pos = pygame.mouse.get_pos()
|
||||||
|
@ -273,7 +274,7 @@ class ScrollList(GenericUI):
|
||||||
text_rect.width = self.width
|
text_rect.width = self.width
|
||||||
self.text_rects.append(text_rect)
|
self.text_rects.append(text_rect)
|
||||||
current_y += text_rect.height
|
current_y += text_rect.height
|
||||||
self.max_offset = max(0, current_y - self.height - self.outline_thickness)
|
self.max_offset = max(0, current_y - self.height)
|
||||||
self.redraw()
|
self.redraw()
|
||||||
self.draw_update.emit()
|
self.draw_update.emit()
|
||||||
|
|
||||||
|
@ -290,33 +291,29 @@ class CallPanel(GenericUI):
|
||||||
|
|
||||||
self.text_size = 20
|
self.text_size = 20
|
||||||
margins = 5
|
margins = 5
|
||||||
ui_width = 75
|
ui_width = 80
|
||||||
ui_height = 25
|
ui_height = 25
|
||||||
width_spacings = (width - 3 * ui_width - 2 * margins) / 4
|
width_spacings = (width - 2.5 * ui_width - 2 * margins) / 4
|
||||||
height_spacings = (height - 2 * margins - 3 * ui_height) / 4
|
height_spacings = (height - 2 * margins - 3 * ui_height) / 4
|
||||||
self.output_text = ['', '']
|
self.output_text = ['', '']
|
||||||
|
|
||||||
#self.label1 = TextBox(margins+width_spacings, margins,
|
|
||||||
# ui_width, ui_height, text='List1', text_size=self.text_size)
|
|
||||||
self.list1 = ScrollList(margins+width_spacings, margins,
|
self.list1 = ScrollList(margins+width_spacings, margins,
|
||||||
ui_width, height - 2*margins,
|
ui_width/2, height - 2*margins,
|
||||||
texts=[str(i) for i in range(4)], text_size=self.text_size)
|
texts=[str(i) for i in range(20)], text_size=self.text_size)
|
||||||
self.list1.list_selected.connect(lambda text, **z: self.print_list_selection(text, 0))
|
self.list1.list_selected.connect(lambda text, **z: self.print_list_selection(text, 0))
|
||||||
|
|
||||||
#self.label2 = TextBox(margins+width_spacings*2+ui_width, margins,
|
self.list2 = ScrollList(margins+width_spacings*2+ui_width/2, margins,
|
||||||
# ui_width, ui_height, text='List2', text_size=self.text_size)
|
|
||||||
self.list2 = ScrollList(margins+width_spacings*2+ui_width, margins,
|
|
||||||
ui_width, height - 2*margins,
|
ui_width, height - 2*margins,
|
||||||
texts=['a', 'b', 'c', 'd'], text_size=self.text_size)
|
texts=['a', 'b', 'c', 'd'], text_size=self.text_size)
|
||||||
self.list2.list_selected.connect(lambda text, **z: self.print_list_selection(text, 1))
|
self.list2.list_selected.connect(lambda text, **z: self.print_list_selection(text, 1))
|
||||||
|
|
||||||
self.output_box = TextBox(margins+width_spacings*3+ui_width*2, margins+height_spacings,
|
self.output_box = TextBox(margins+width_spacings*3+ui_width*1.5, margins+height_spacings,
|
||||||
ui_width, ui_height, text='-', text_size=self.text_size)
|
ui_width, ui_height, text='-', text_size=self.text_size)
|
||||||
|
|
||||||
self.confirm_button = Button(margins+width_spacings*3+ui_width*2, margins+height_spacings*2+ui_height,
|
self.confirm_button = Button(margins+width_spacings*3+ui_width*1.5, margins+height_spacings*2+ui_height,
|
||||||
ui_width, ui_height, text='Call', text_size=self.text_size)
|
ui_width, ui_height, text='Call', text_size=self.text_size)
|
||||||
self.confirm_button.clicked.connect(self.emit_output)
|
self.confirm_button.clicked.connect(self.emit_output)
|
||||||
self.cancel_button = Button(margins + width_spacings * 3 + ui_width * 2,
|
self.cancel_button = Button(margins + width_spacings * 3 + ui_width * 1.5,
|
||||||
margins + height_spacings * 3 + ui_height * 2,
|
margins + height_spacings * 3 + ui_height * 2,
|
||||||
ui_width, ui_height, text='Pass', text_size=self.text_size)
|
ui_width, ui_height, text='Pass', text_size=self.text_size)
|
||||||
|
|
||||||
|
|
2
main.py
2
main.py
|
@ -105,7 +105,7 @@ if __name__ == '__main__':
|
||||||
# rng_state = pickle.load(f)
|
# rng_state = pickle.load(f)
|
||||||
#random.setstate(rng_state)
|
#random.setstate(rng_state)
|
||||||
|
|
||||||
main_view = GameScreen(900, 600, clear_colour=(255, 0, 0),
|
main_view = GameScreen(800, 600, clear_colour=(255, 0, 0),
|
||||||
autoplay=AUTOPLAY, view_all_cards=VIEW_ALL_CARDS)
|
autoplay=AUTOPLAY, view_all_cards=VIEW_ALL_CARDS)
|
||||||
|
|
||||||
main_view.run()
|
main_view.run()
|
10
table.py
10
table.py
|
@ -85,8 +85,8 @@ class Table:
|
||||||
# Prepare the card with dimensions
|
# Prepare the card with dimensions
|
||||||
w_deck = min(self.height, self.width) * 0.18
|
w_deck = min(self.height, self.width) * 0.18
|
||||||
l_deck = min(self.width, self.height) * 0.7
|
l_deck = min(self.width, self.height) * 0.7
|
||||||
# This is not a deck as it will never be drawn
|
# This is not a deck as it will never be draw
|
||||||
self.discard_deck = cards.prepare_playing_cards(int(w_deck*0.7), int(w_deck*0.8))
|
self.discard_deck = cards.prepare_playing_cards(int(w_deck*0.6), int(w_deck*0.6 *97/71))
|
||||||
game_margins = 5
|
game_margins = 5
|
||||||
|
|
||||||
# Players' deck positioning
|
# Players' deck positioning
|
||||||
|
@ -194,7 +194,7 @@ class Table:
|
||||||
self.require_player_input = False
|
self.require_player_input = False
|
||||||
|
|
||||||
self.calling_panel = UI.CallPanel(playdeckx[0]+w_deck+5,playdecky[0]+w_deck-100,
|
self.calling_panel = UI.CallPanel(playdeckx[0]+w_deck+5,playdecky[0]+w_deck-100,
|
||||||
250, 100)
|
220, 100)
|
||||||
self.calling_panel.parent = self
|
self.calling_panel.parent = self
|
||||||
self.calling_panel.visible = False
|
self.calling_panel.visible = False
|
||||||
self.parent = None
|
self.parent = None
|
||||||
|
@ -502,10 +502,14 @@ class Table:
|
||||||
self.write_message(msg, line=1, update_now=False)
|
self.write_message(msg, line=1, update_now=False)
|
||||||
msg = 'Bid Leader: Player {0:d}'.format(self.current_player)
|
msg = 'Bid Leader: Player {0:d}'.format(self.current_player)
|
||||||
self.write_message(msg, line=2, update_now=True)
|
self.write_message(msg, line=2, update_now=True)
|
||||||
|
|
||||||
if self.first_player:
|
if self.first_player:
|
||||||
self.first_player = False
|
self.first_player = False
|
||||||
|
if player_bid:
|
||||||
|
self.update_player_bid(self.current_player, player_bid, update_now=False)
|
||||||
else:
|
else:
|
||||||
self.update_player_bid(self.current_player, player_bid, update_now=False)
|
self.update_player_bid(self.current_player, player_bid, update_now=False)
|
||||||
|
|
||||||
if self.table_status["bid"] < 75:
|
if self.table_status["bid"] < 75:
|
||||||
self.current_player += 1
|
self.current_player += 1
|
||||||
self.current_player %= NUM_OF_PLAYERS
|
self.current_player %= NUM_OF_PLAYERS
|
||||||
|
|
Loading…
Reference in New Issue