Add build script.

This commit is contained in:
luxick
2018-02-24 14:06:59 +01:00
parent af57942ad8
commit f1160ddb55
12 changed files with 868 additions and 347 deletions

View File

@@ -9,14 +9,18 @@ from dsst_gtk3 import util
from dsst_sql import sql, sql_func
class DSSTGtkUi:
class GtkUi:
""" The main UI class """
def __init__(self):
# Load Glade UI files
self.ui = Gtk.Builder()
self.ui.add_from_file(os.path.join(os.path.dirname(__file__), 'resources', 'glade', 'window.glade'))
self.ui.add_from_file(os.path.join(os.path.dirname(__file__), 'resources', 'glade', 'dialogs.glade'))
glade_resources = [
['dsst_gtk3', 'resources', 'glade', 'window.glade'],
['dsst_gtk3', 'resources', 'glade', 'dialogs.glade']
]
for path in glade_resources:
self.ui.add_from_string(util.Util.load_ui_resource_string(path))
# Connect signal handlers to UI
self.handlers = handlers.Handlers(self)
self.ui.connect_signals(self.handlers)
@@ -45,14 +49,20 @@ class DSSTGtkUi:
for season in sql.Season.select().order_by(sql.Season.number):
store.append([season.id, season.game_name])
def reload_for_season(self, season_id):
# Reload after season was changed ##################################################################################
def reload_for_season(self):
season_id = self.get_selected_season_id()
if season_id is None or season_id == -1:
return
# Rebuild episodes store
ep_id = self.get_selected_episode_id()
selection = self.ui.get_object('episodes_tree_view').get_selection()
# selection.handler_block_by_func(self.handlers.on_selected_episode_changed)
store = self.ui.get_object('episodes_store')
store.clear()
for episode in sql_func.get_episodes_for_season(season_id):
store.append([episode.id, episode.number, str(episode.date)])
# Load player stats for season
player_stats = {}
for episode in sql_func.get_episodes_for_season(season_id):
@@ -64,20 +74,31 @@ class DSSTGtkUi:
for name, stats in player_stats.items():
store.append([name, stats[0], stats[1]])
# Load enemy stats for season
enemy_stats = {enemy.name: [0, 0] for enemy in sql.Season.get(sql.Season.id == season_id).enemies}
enemy_stats = {enemy.name: [0, 0, enemy.id] for enemy in sql.Season.get(sql.Season.id == season_id).enemies}
store = self.ui.get_object('enemy_season_store')
store.clear()
for name, stats in enemy_stats.items():
store.append([name, stats[0], stats[1]])
store.append([name, stats[0], stats[1], stats[2]])
def reload_for_episode(self, episode_id):
pass
# Reload after episode was changed #################################################################################
def reload_for_episode(self):
episode_id = self.get_selected_episode_id()
if not episode_id:
return
store = self.ui.get_object('episode_players_store')
store.clear()
for player in sql.Episode.get(sql.Episode.id == self.get_selected_episode_id()).players:
store.append([player.id, player.name, player.hex_id])
def get_selected_season_id(self):
season_id = util.Util.get_combo_value(self.ui.get_object('season_combo_box'), 0)
return season_id if season_id != -1 else None
def get_selected_episode_id(self):
(model, tree_iter) = self.ui.get_object('episodes_tree_view').get_selection().get_selected()
return model.get_value(tree_iter, 0) if tree_iter else None
if __name__ == '__main__':
DSSTGtkUi()
def main():
GtkUi()
Gtk.main()