Create death events function.
This commit is contained in:
@@ -146,8 +146,8 @@ def edit_death(app: 'gtk_ui.GtkUi', death: 'models.Death'=None):
|
||||
return None
|
||||
|
||||
# Parse the inputs
|
||||
death.time = datetime.time(hour_spin.get_value(), min_spin.set_value)
|
||||
death.enemy = util.get_combo_value(app.ui.get_object('edit_death_enemy_combo'), 3)
|
||||
death.time = datetime.time(int(hour_spin.get_value()), int(min_spin.get_value()))
|
||||
death.enemy = util.get_combo_value(app.ui.get_object('edit_death_enemy_combo'), 4)
|
||||
death.player = util.get_combo_value(app.ui.get_object('edit_death_player_combo'), 0)
|
||||
death.info = app.ui.get_object('edit_death_comment_entry').get_text()
|
||||
store = app.ui.get_object('player_penalties_store')
|
||||
|
||||
@@ -77,6 +77,11 @@ class GtkUi:
|
||||
self.data_client.send_request('update_drink', drink)
|
||||
self.full_reload()
|
||||
|
||||
def save_death(self, death: 'models.Death'):
|
||||
with util.network_operation(self):
|
||||
self.data_client.send_request('save_death', death)
|
||||
self.full_reload()
|
||||
|
||||
def update_season(self, season: 'models.Season'):
|
||||
with util.network_operation(self):
|
||||
self.data_client.send_request('update_season', season)
|
||||
|
||||
@@ -11,10 +11,9 @@ class DeathHandlers:
|
||||
ep_id = self.app.get_selected_episode_id()
|
||||
if not ep_id:
|
||||
return
|
||||
result = dialogs.edit_death(self.app)
|
||||
if result == Gtk.ResponseType.OK:
|
||||
self.app.episodes.valid = False
|
||||
self.app.full_reload()
|
||||
death = dialogs.edit_death(self.app)
|
||||
if death:
|
||||
self.app.save_death(death)
|
||||
|
||||
def on_penalty_drink_changed(self, _, path, text):
|
||||
self.app.ui.get_object('player_penalties_store')[path][2] = text
|
||||
|
||||
@@ -81,7 +81,8 @@ def reload_episode_stats(app: 'gtk_ui.GtkUi'):
|
||||
penalties = [x.drink.name for x in death.penalties]
|
||||
penalties = ['{}x {}'.format(number, drink) for drink, number in Counter(penalties).items()]
|
||||
penalty_string = ', '.join(penalties)
|
||||
store.append([death.id, death.player.name, death.enemy.name, penalty_string])
|
||||
time_string = '{}:{}'.format(death.time.hour, death.time.minute)
|
||||
store.append([death.id, death.player.name, death.enemy.name, penalty_string, time_string])
|
||||
# Reload victory store for notebook view
|
||||
store = app.ui.get_object('episode_victories_store')
|
||||
store.clear()
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name penalty_name -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name time -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkListStore" id="episode_players_store">
|
||||
@@ -987,6 +989,17 @@
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Time</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">4</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Player</property>
|
||||
|
||||
Reference in New Issue
Block a user