import apicache
import os.path
import traceback
+import time
#conic is used for connection handling
import conic
self.gconf = gnome.gconf.client_get_default()
#NOTE: remove this after a few releases
self.update_settings()
- self.connect()
+ self.connect_to_network()
self.cached_api = eveapi.EVEAPIConnection( cacheHandler = \
apicache.cache_handler(debug=False))
self.gui = gui.mEveMonUI(self)
pass
- def connect(self):
+ def connect_to_network(self):
connection = conic.Connection()
#why 0xAA55?
connection.connect("connection-event", self.connection_cb, 0xAA55)
assert(connection.request_connection(conic.CONNECT_FLAG_NONE))
+ def get_sp(self, uid, char_id):
+ sheet = self.get_char_sheet(uid, char_id)
+
+ # TODO: we also have to calculate how much we earned from a
+ # currently training skill
+
+ actual_sp = 0
+
+ for skill in sheet.skills:
+ actual_sp += skill.skillpoints
+
+ live_sp = actual_sp + self.get_training_sp(uid, char_id)
+
+ return live_sp
+
+ def get_spps(self, uid, char_id):
+ """
+ Calculate and returns the skill points per hour for the given character.
+ """
+ skill = self.get_skill_in_training(uid, char_id)
+
+ if not skill.skillInTraining:
+ return (0, 0)
+
+ total_sp = skill.trainingDestinationSP - skill.trainingStartSP
+ total_time = skill.trainingEndTime - skill.trainingStartTime
+
+ spps = float(total_sp) / total_time
+
+ return (spps, skill.trainingStartTime)
+
+ def get_training_sp(self, uid, char_id):
+ """
+ returns the additional SP that the in-training skill has acquired
+ """
+
+ spps_tuple = self.get_spps(uid, char_id)
+
+ print spps_tuple
+
+ if not spps_tuple:
+ return 0
+
+ spps, start_time = spps_tuple
+
+ eve_time = time.time() #evetime is utc, right?
+
+ time_diff = eve_time - start_time
+
+ return (spps * time_diff)
+
+
if __name__ == "__main__":
app = mEveMon()
app.run()
import hildon
import gobject
+import glib
+
from ui import models
class BaseUI():
box.pack_start(label, False, False, padding)
+ return label
+
class mEveMonUI(BaseUI):
class CharacterSheetUI(BaseUI):
-
+ UPDATE_INTERVAL = 1
+
def __init__(self, controller):
self.controller = controller
self.sheet = None
# column 0 is the portrait, column 1 is name
char_name = model.get_value(miter, 1)
- uid = model.get_value(miter, 2)
+ self.uid = model.get_value(miter, 2)
self.char_id = self.controller.char_name2id(char_name)
- self.sheet = self.controller.get_char_sheet(uid, self.char_id)
+ self.sheet = self.controller.get_char_sheet(self.uid, self.char_id)
win.set_title(char_name)
vbox.pack_start(separator, False, False, 5)
self.add_label("<big>Skill in Training:</big>", vbox, align="normal")
- skill = self.controller.get_skill_in_training(uid, self.char_id)
+
+ self.display_skill_in_training(vbox)
+
+ separator = gtk.HSeparator()
+ vbox.pack_start(separator, False, False, 0)
+
+ self.add_label("<big>Skills:</big>", vbox, align="normal")
+
+ skills_treeview = hildon.GtkTreeView(gtk.HILDON_UI_MODE_NORMAL)
+ self.skills_model = models.CharacterSkillsModel(self.controller, self.char_id)
+ skills_treeview.set_model(self.skills_model)
+ self.add_columns_to_skills_view(skills_treeview)
+ vbox.pack_start(skills_treeview, False, False, 1)
+
+ win.add(pannable_area)
+ win.show_all()
+
+ hildon.hildon_gtk_window_set_progress_indicator(win, 0)
+
+ def display_skill_in_training(self, vbox):
+ skill = self.controller.get_skill_in_training(self.uid, self.char_id)
if skill.skillInTraining:
self.add_label("<small>No skills are currently being trained</small>",
vbox, align="normal")
- separator = gtk.HSeparator()
- vbox.pack_start(separator, False, False, 0)
-
- self.add_label("<big>Skills:</big>", vbox, align="normal")
-
- skills_treeview = hildon.GtkTreeView(gtk.HILDON_UI_MODE_NORMAL)
- self.skills_model = models.CharacterSkillsModel(self.controller, self.char_id)
- skills_treeview.set_model(self.skills_model)
- self.add_columns_to_skills_view(skills_treeview)
- vbox.pack_start(skills_treeview, False, False, 1)
-
- win.add(pannable_area)
- win.show_all()
- hildon.hildon_gtk_window_set_progress_indicator(win, 0)
def fill_info(self, box):
self.add_label("<big><big>%s</big></big>" % self.sheet.name, box)
self.add_label("", box, markup=False)
self.add_label("<small><b>Corp:</b> %s</small>" % self.sheet.corporationName, box)
self.add_label("<small><b>Balance:</b> %s ISK</small>" % self.sheet.balance, box)
+ self.live_sp_val = self.controller.get_sp(self.uid, self.char_id)
+ print self.live_sp_val
+ self.live_sp = self.add_label("<small><b>Total SP:</b> %s</small>" %
+ self.live_sp_val, box)
+
+ self.spps = self.controller.get_spps(self.uid, self.char_id)[0]
+ glib.timeout_add_seconds(self.UPDATE_INTERVAL, self.update_live_sp)
def fill_stats(self, box):
self.skills_model.get_skills()
hildon.hildon_gtk_window_set_progress_indicator(window, 0)
+
+ def update_live_sp(self):
+ self.live_sp_val = self.live_sp_val + self.spps * self.UPDATE_INTERVAL
+ self.live_sp.set_label("<small><b>Total SP:</b> %d</small>" %
+ self.live_sp_val)
+
+ return True
+
+
if __name__ == "__main__":
main()