2 # mEveMon - A character monitor for EVE Online
3 # Copyright (c) 2010 Ryan and Danny Campbell, and the mEveMon Team
5 # mEveMon is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # mEveMon is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # DIABLO UI: Heavily based on Ry's Fremantle Python code. --danny
31 about_name = 'mEveMon'
32 about_text = ('Mobile character monitor for EVE Online')
33 about_authors = [ 'Ryan Campbell','Danny Campbell' ]
34 about_website = 'http://mevemon.garage.maemo.org'
36 menu_items = ("Settings", "About", "Refresh")
38 def create_menu(self, window):
40 for command in self.menu_items:
41 button = gtk.MenuItem(command)
42 if command == "About":
43 button.connect("activate", self.about_clicked)
44 elif command == "Settings":
45 button.connect("activate", self.settings_clicked, window)
46 elif command == "Refresh":
47 button.connect("activate", self.refresh_clicked, window)
50 # Add entry to the view menu
55 def set_pix(self, filename):
56 pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
59 def settings_clicked(self, button, window):
63 #get the vbox to pack all the settings into
66 dialog.set_transient_for(window)
67 dialog.set_title("Settings")
69 uidLabel = gtk.Label("User ID:")
70 uidLabel.set_justify(gtk.JUSTIFY_LEFT)
73 uidEntry = gtk.Entry()
74 uidEntry.set_text(self.controller.get_uid())
75 uidEntry.set_property('is_focus', False)
79 apiLabel = gtk.Label("API key:")
80 apiLabel.set_justify(gtk.JUSTIFY_LEFT)
83 apiEntry = gtk.Entry()
84 apiEntry.set_text(self.controller.get_api_key())
85 apiEntry.set_property('is_focus', False)
89 ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
94 if result == gtk.RESPONSE_OK:
95 self.controller.set_api_key(apiEntry.get_text())
96 self.controller.set_uid(uidEntry.get_text())
97 self.controller.set_auth()
98 self.char_model.get_characters()
104 def about_clicked(self, button):
105 dialog = gtk.AboutDialog()
106 dialog.set_website(self.about_website)
107 dialog.set_website_label(self.about_website)
108 dialog.set_name(self.about_name)
109 dialog.set_authors(self.about_authors)
110 dialog.set_comments(self.about_text)
111 dialog.set_version(self.app_version)
115 def add_label(self, text, box, markup=True, align="left", padding=1):
116 label = gtk.Label(text)
118 label.set_use_markup(True)
120 label.set_alignment(0, 0.5)
121 box.pack_start(label, False, False, padding)
123 class mEveMonUI(BaseUI):
125 def __init__(self, controller):
126 self.controller = controller
127 gtk.set_application_name("mEveMon")
129 # create the main window
130 win = hildon.Window()
131 win.connect("destroy", self.controller.quit)
133 progress_bar = hildon.hildon_banner_show_progress(win, None, "Loading overview...")
134 progress_bar.set_fraction(0.4)
137 menu = self.create_menu(win)
139 # Attach menu to the window
142 character_win = CharacterSheetUI(self.controller)
144 # create the treeview --danny
145 self.char_model = models.CharacterListModel(self.controller)
146 treeview = gtk.TreeView(model = self.char_model)
147 treeview.connect('row-activated', character_win.build_window)
148 treeview.set_model(self.char_model)
149 self.add_columns_to_treeview(treeview)
151 # add the treeview with scrollbar --danny
152 win.add_with_scrollbar(treeview)
155 progress_bar.set_fraction(1)
156 progress_bar.destroy()
158 def add_columns_to_treeview(self, treeview):
159 #Column 0 for the treeview
160 renderer = gtk.CellRendererPixbuf()
161 column = gtk.TreeViewColumn()
162 column.pack_start(renderer, True)
163 column.add_attribute(renderer, "pixbuf", 0)
164 treeview.append_column(column)
166 #Column 1 for the treeview
167 renderer = gtk.CellRendererText()
168 column = gtk.TreeViewColumn('Character Name', renderer, text=1)
169 column.set_property("expand", True)
170 treeview.append_column(column)
172 def refresh_clicked(self, button, window):
173 progress_bar = hildon.hildon_banner_show_progress(win, None, "Loading characters...")
174 progress_bar.set_fraction(1)
175 self.char_model.get_characters()
176 progress_bar.destroy()
178 class CharacterSheetUI(BaseUI):
180 def __init__(self, controller):
181 self.controller = controller
184 self.skills_model = None
186 def build_window(self, treeview, path, view_column):
187 # TODO: this is a really long and ugly function, split it up somehow
189 win = hildon.Window()
192 progress_bar = hildon.hildon_banner_show_progress(win, None, "Loading character sheet...")
193 progress_bar.set_fraction(0.4)
196 # NOTE: we probably want a window-specific menu for this page, but the
197 # main appmenu works for now
198 menu = self.create_menu(win)
199 # Attach menu to the window
202 model = treeview.get_model()
203 miter = model.get_iter(path)
205 # column 0 is the portrait, column 1 is name
206 char_name = model.get_value(miter, 1)
207 self.char_id = self.controller.char_name2id(char_name)
208 self.sheet = self.controller.get_char_sheet(self.char_id)
210 win.set_title(char_name)
212 hbox = gtk.HBox(False, 0)
213 info_vbox = gtk.VBox(False, 1)
215 portrait = gtk.Image()
216 portrait.set_from_file(self.controller.get_portrait(char_name, 256))
219 hbox.pack_start(portrait, False, False, 10)
220 hbox.pack_start(info_vbox, False, False, 5)
222 vbox = gtk.VBox(False, 0)
224 vbox.pack_start(hbox, False, False, 0)
227 self.fill_info(info_vbox)
229 self.add_label("<big>Skill in Training:</big>", vbox, align="normal")
230 skill = self.controller.get_skill_in_training(self.char_id)
232 if skill.skillInTraining:
234 skilltree = self.controller.get_skill_tree()
236 # I'm assuming that we will always find a skill with the skill ID
237 for group in skilltree.skillGroups:
238 found_skill = group.skills.Get(skill.trainingTypeID, False)
240 skill_name = found_skill.typeName
243 self.add_label("%s <small>(Level %d)</small>" % (skill_name, skill.trainingToLevel),
244 vbox, align="normal")
245 self.add_label("<small>start time: %s\t\tend time: %s</small>" %(time.ctime(skill.trainingStartTime),
246 time.ctime(skill.trainingEndTime)), vbox, align="normal")
248 self.add_label("<small>No skills are currently being trained</small>", vbox, align="normal")
250 self.add_label("<big>Skills:</big>", vbox, align="normal")
253 skills_model = models.CharacterSkillsModel(self.controller, self.char_id)
254 skills_treeview = gtk.TreeView(model = skills_model)
255 skills_treeview.set_model(skills_model)
256 self.add_columns_to_skills_view(skills_treeview)
258 vbox.pack_start(skills_treeview, False, False, 0)
260 win.add_with_scrollbar(vbox)
263 progress_bar.set_fraction(1)
264 progress_bar.destroy()
266 def fill_info(self, box):
267 self.add_label("<big><big>%s</big></big>" % self.sheet.name, box)
268 self.add_label("<small>%s %s %s</small>" % (self.sheet.gender, self.sheet.race, self.sheet.bloodLine), box)
269 self.add_label("", box, markup=False)
270 self.add_label("<small><b>Corp:</b> %s</small>" % self.sheet.corporationName, box)
271 self.add_label("<small><b>Balance:</b> %s ISK</small>" % self.sheet.balance, box)
272 self.add_label("", box, markup=False)
273 self.add_label("", box, markup=False)
274 self.add_label("", box, markup=False)
275 self.add_label("<small><b>Intelligence: </b>%d</small>" % self.sheet.attributes.intelligence, box)
276 self.add_label("<small><b>Memory:</b>\t%d</small>" % self.sheet.attributes.memory, box)
277 self.add_label("<small><b>Charisma:</b>\t%d</small>" % self.sheet.attributes.charisma, box)
278 self.add_label("<small><b>Perception:</b>\t%d</small>" % self.sheet.attributes.perception, box)
279 self.add_label("<small><b>Willpower:</b>\t%d</small>" % self.sheet.attributes.willpower, box)
281 def add_columns_to_skills_view(self, treeview):
282 #Column 0 for the treeview
283 renderer = gtk.CellRendererText()
284 column = gtk.TreeViewColumn('Skill Name', renderer, markup=0)
285 column.set_property("expand", True)
286 treeview.append_column(column)
288 #Column 1 for the treeview
289 column = gtk.TreeViewColumn('Rank', renderer, markup=1)
290 column.set_property("expand", True)
291 treeview.append_column(column)
294 renderer = gtk.CellRendererText()
295 renderer = gtk.CellRendererText()
296 column = gtk.TreeViewColumn('Points', renderer, markup=2)
297 column.set_property("expand", True)
298 treeview.append_column(column)
301 column = gtk.TreeViewColumn('Level', renderer, markup=3)
302 column.set_property("expand", True)
303 treeview.append_column(column)
305 def refresh_clicked(self, button, window):
306 progress_bar = hildon.hildon_banner_show_progress(win, None, "Loading overview...")
307 progress_bar.set_fraction(1)
308 self.skills_model.get_skills()
309 progress_bar.destroy()
311 if __name__ == "__main__":