def __init__(self, title=__program_name__): GObject.threads_init() # allow threads to update GUI Gtk.Window.__init__(self, title=title) logger.add_separator() # Initialise class attributes self.game_window = None self.game_window_location = None self.bot_path = None self.bot_thread = None self.args = tools.get_cmd_args() # Get settings self.settings = settings.load() # Header Bar self.create_header_bar(title) # Tabs self.create_tabs() # Window self.set_icon_from_file(tools.get_full_path('icons/logo.png')) #self.set_size_request(350, 700) self.set_default_size(350, 700) self.set_resizable(False) self.connect('key-press-event', self.on_key_press) #self.connect('configure-event', self.on_resize_or_move) #self.connect('window-state-event', self.on_minimize) self.connect('destroy', Gtk.main_quit) self.show_all() self.unbind_button.hide() if not self.settings['Debug']['Enabled']: self.debug_page.hide() if not self.settings['State']['EnablePodBar']: self.podbar_box.hide() if not self.settings['State']['EnableMiniMap']: self.minimap_box.hide()
def on_start_button_clicked(self, button): if self.game_window is None: AlertDialog(self, 'Please select a game window') elif not self.bot_path: AlertDialog(self, 'Please select a bot path') else: # get game location game_location = tools.get_widget_location(self.game_area) # start bot thread if self.bot_thread is None or not self.bot_thread.isAlive(): # get thread parameters start_from_step = self.step_spin_button.get_value_as_int() repeat_path = self.repeat_spin_button.get_value_as_int() if self.repeat_switch.get_active() else 1 if self.connect_to_account_switch.get_active(): account_id = self.accounts_combo.get_active_value() disconnect_after = self.disconnect_after_switch.get_active() else: account_id = None disconnect_after = False # run thread self.bot_thread = BotThread(self, game_location, start_from_step, repeat_path, account_id, disconnect_after) self.bot_thread.start() self.settings_button.set_sensitive(False) self.bot_widgets.set_sensitive(False) # resume bot thread if paused else: self.bot_thread.resume(game_location) # enable/disable buttons self.start_button.set_image(Gtk.Image(file=tools.get_full_path('icons/loader.gif'))) self.start_button.set_sensitive(False) self.pause_button.set_sensitive(True) self.stop_button.set_sensitive(True)
def go_to_bank(self): path_to_bank = data.BankPath self.debug(f"Go to Bank (path: {path_to_bank})") instructions = tools.read_file(tools.get_full_path(path_to_bank)) if instructions: self.interpret(instructions, ignore_start_from_step=True) else: self.pause() self.log('Error: Could not interpret to go to bank path')
def __init__(self, transient_for): Gtk.AboutDialog.__init__(self, transient_for=transient_for) self.set_program_name(shared.__program_name__) self.set_version(shared.__version__) self.set_comments(shared.__program_desc__) self.set_website(shared.__website__) self.set_website_label(shared.__website_label__) self.set_authors(shared.__authors__) logo = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/logo.png'), 64, 64) self.set_logo(logo) self.connect('response', lambda dialog, response: self.destroy())
def go_to_store(self, store_path): self.debug('Go to store (path: %s)' % store_path) if store_path in data.BankPath: instructions = data.BankPath[store_path] else: instructions = tools.read_file(tools.get_full_path(store_path)) if instructions: self.interpret(instructions, ignore_start_from_step=True) else: self.pause() self.debug('Could not interpret store path') self.log('Bot is maybe full pod', LogType.Error)
def on_load_path_button_clicked(self, button): dialog = OpenFileDialog('Load Path', self, ('Bot Path', '*.path')) dialog.set_current_folder(tools.get_full_path('paths')) response = dialog.run() if response == Gtk.ResponseType.OK: # read file path = tools.read_file(dialog.get_filename()) # append to path listbox for line in path.splitlines(): self.path_listbox.append_text(line) dialog.destroy()
def on_save_path_button_clicked(self, button): dialog = SaveFileDialog('Save as', self, ('Bot Path', '*.path')) dialog.set_current_folder(tools.get_full_path('paths')) dialog.set_current_name('path_' + tools.get_date_time() + '.path') response = dialog.run() if response == Gtk.ResponseType.OK: # get all rows text text = '' for row in self.path_listbox.get_rows(): text += self.path_listbox.get_row_text(row) + '\n' # save it to file tools.save_text_to_file(text, dialog.get_filename()) dialog.destroy()
def create_header_bar(self, title): ### Header Bar hb = Gtk.HeaderBar(title=title) logo = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/logo.png'), 24, 24) hb.pack_start(Gtk.Image(pixbuf=logo)) hb.set_show_close_button(True) self.set_titlebar(hb) ## Settings button self.settings_button = Gtk.Button() self.settings_button.set_image(Gtk.Image(icon_name='open-menu-symbolic')) self.settings_button.connect('clicked', lambda button: self.popover.show_all()) hb.pack_end(self.settings_button) self.popover = Gtk.Popover(relative_to=self.settings_button, position=Gtk.PositionType.BOTTOM) self.popover.set_border_width(2) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.popover.add(box) # Preferences button preferences_button = Gtk.ModelButton(' Preferences') preferences_button.set_alignment(0, 0.5) preferences_button.set_image(Gtk.Image(icon_name='preferences-desktop')) preferences_button.connect('clicked', self.on_preferences_button_clicked) box.add(preferences_button) # Accounts button accounts_button = Gtk.ModelButton(' Accounts') accounts_button.set_alignment(0, 0.5) accounts_button.set_image(Gtk.Image(icon_name='dialog-password')) accounts_button.connect('clicked', self.on_accounts_button_clicked) box.add(accounts_button) # Take Game Screenshot button self.take_screenshot_button = Gtk.ModelButton(' Take Game Screenshot') self.take_screenshot_button.set_alignment(0, 0.5) self.take_screenshot_button.set_image(Gtk.Image(icon_name='camera-photo')) self.take_screenshot_button.set_sensitive(False) self.take_screenshot_button.connect('clicked', self.on_take_screenshot_button_clicked) box.add(self.take_screenshot_button) # Open Log File button open_log_button = Gtk.ModelButton(' Open Log File') open_log_button.set_alignment(0, 0.5) open_log_button.set_image(Gtk.Image(icon_name='text-x-generic')) open_log_button.connect('clicked', lambda button: tools.open_file_in_editor(logger.get_filename())) box.add(open_log_button) # About button about_button = Gtk.ModelButton(' About') about_button.set_alignment(0, 0.5) about_button.set_image(Gtk.Image(icon_name='help-about')) about_button.connect('clicked', self.on_about_button_clicked) box.add(about_button)
def take_dragodinde_image(self, name, location=None): # get location if location is None: location = self.get_box_location('Dragodinde Card') # take dragodinde image if location: if self.save_dragodindes_images: # create directory(s) to store dragodindes images directory = tools.get_full_path( 'dragodindes') + '/' + tools.get_date() tools.create_directory(directory) save_to = directory + '/' + name else: save_to = None return tools.screen_game(location, save_to) else: return None
def on_start_button_clicked(self, button): if self.game_window is None: AlertDialog(self, 'Please select a game window') elif self.game_window.is_destroyed(): AlertDialog(self, 'Chosen game window was destroyed') elif not self.bot_path: AlertDialog(self, 'Please select a bot path') else: # ensure that game window is in the right place self.move_resize_game_window(self.game_window_location) # start bot thread if self.bot_thread is None or not self.bot_thread.isAlive(): # get thread parameters start_from_step = self.step_spin_button.get_value_as_int() repeat_path = self.repeat_spin_button.get_value_as_int() if self.repeat_switch.get_active() else 1 if self.connect_to_account_switch.get_active(): account_id = self.accounts_combo.get_active_value() disconnect_after = self.disconnect_after_switch.get_active() else: account_id = None disconnect_after = False # run thread self.bot_thread = BotThread(self, self.game_window_location, start_from_step, repeat_path, account_id, disconnect_after) self.bot_thread.start() self.settings_button.set_sensitive(False) self.bot_config_widgets.set_sensitive(False) # resume bot thread if paused else: self.bot_thread.resume(self.game_window_location) # show bot state & debug tabs self.log_notebook.set_current_page(1) if self.settings['Debug']['Enabled']: self.config_notebook.set_current_page(1) # enable/disable buttons self.start_button.set_image(Gtk.Image(file=tools.get_full_path('icons/loader.gif'))) self.start_button.set_sensitive(False) self.pause_button.set_sensitive(True) self.stop_button.set_sensitive(True)
def __init__(self, title=__program_name__): GObject.threads_init() # allow threads to update GUI Gtk.Window.__init__(self, title=title) logger.add_separator() # Initialise class attributes self.game_window = None self.game_area = None self.bot_path = None self.bot_thread = None self.args = tools.get_cmd_args() # Get settings self.settings = settings.load() # Header Bar self.create_header_bar(title) # Tables self.htable = Gtk.Table(1, 3, True) # horizontal table self.vtable = Gtk.Table(4, 1, True) # vertical table self.htable.attach(self.vtable, 1, 3, 0, 1) self.add(self.htable) # Tabs self.create_tabs() # Window self.set_icon_from_file(tools.get_full_path('icons/drago.png')) self.set_size_request(900, 700) self.set_resizable(False) self.connect('key-press-event', self.on_key_press) self.connect('configure-event', self.on_resize_or_move) self.connect('window-state-event', self.on_minimize) self.connect('destroy', Gtk.main_quit) self.show_all() self.unplug_button.hide() if not self.settings['Debug']['Enabled']: self.debug_page.hide() if not self.settings['Job']['EnablePodBar']: self.podbar_box.hide() if not self.settings['Job']['EnableMiniMap']: self.minimap_box.hide()
def __init__(self, parent): Gtk.Table.__init__(self, 1, 3, True) self.set_border_width(5) self.parent = parent #self.parent.connect('button-press-event', self.on_click) ## Pixel left_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) left_box.add(Gtk.Label('<b>Pixel</b>', xalign=0, use_markup=True)) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) left_box.pack_start(hbox, True, True, 0) self.attach(left_box, 0, 2, 0, 1) # TreeView model = Gtk.ListStore(GdkPixbuf.Pixbuf, int, int, int, int, str) text_renderer = Gtk.CellRendererText() columns = [ Gtk.TreeViewColumn('', Gtk.CellRendererPixbuf(), pixbuf=0), Gtk.TreeViewColumn('X', text_renderer, text=1), Gtk.TreeViewColumn('Y', text_renderer, text=2), Gtk.TreeViewColumn('Width', text_renderer, text=3), Gtk.TreeViewColumn('Height', text_renderer, text=4), Gtk.TreeViewColumn('Color', text_renderer, text=5) ] self.tree_view = CustomTreeView(model, columns) self.tree_view.connect('button-press-event', self.on_tree_view_double_clicked) self.tree_view.connect('selection-changed', self.on_tree_view_selection_changed) hbox.pack_start(self.tree_view, True, True, 0) # Select buttons_box = ButtonBox(orientation=Gtk.Orientation.VERTICAL, centered=True, linked=True) hbox.add(buttons_box) self.select_pixel_button = Gtk.Button() pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( tools.get_full_path('icons/crosshair.png'), 16, 16) #pixbuf = Gdk.Cursor(Gdk.CursorType.CROSSHAIR).get_image().scale_simple(18, 18, GdkPixbuf.InterpType.BILINEAR) self.select_pixel_button.set_image(Gtk.Image(pixbuf=pixbuf)) self.select_pixel_button.set_tooltip_text('Select') self.select_pixel_button.connect('clicked', self.on_select_pixel_button_clicked) buttons_box.add(self.select_pixel_button) # Simulate self.simulate_click_button = Gtk.Button() pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( tools.get_full_path('icons/hand.png'), 16, 16) #pixbuf = Gdk.Cursor(Gdk.CursorType.HAND1).get_image().scale_simple(18, 18, GdkPixbuf.InterpType.BILINEAR) self.simulate_click_button.set_image(Gtk.Image(pixbuf=pixbuf)) self.simulate_click_button.set_tooltip_text('Simulate Click') self.simulate_click_button.set_sensitive(False) self.simulate_click_button.connect( 'clicked', self.on_simulate_click_button_clicked) buttons_box.add(self.simulate_click_button) # Delete self.delete_pixel_button = Gtk.Button() self.delete_pixel_button.set_image( Gtk.Image(icon_name='edit-delete-symbolic')) self.delete_pixel_button.set_tooltip_text('Delete') self.delete_pixel_button.set_sensitive(False) self.delete_pixel_button.connect('clicked', self.on_delete_pixel_button_clicked) buttons_box.add(self.delete_pixel_button) # Separator right_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) right_box.add( Gtk.Separator(orientation=Gtk.Orientation.VERTICAL, margin=10)) self.attach(right_box, 2, 3, 0, 1) ## Key Press vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) right_box.pack_start(vbox, True, True, 0) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) vbox.add(hbox) hbox.add(Gtk.Label('<b>Key Press</b>', xalign=0, use_markup=True)) # Label self.keys_label = Gtk.Label() hbox.add(self.keys_label) # ComboBox hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) vbox.add(hbox) self.keys_combo = CustomComboBox(data.KeyboardShortcuts, sort=True) self.keys_combo.connect('changed', self.on_keys_combo_changed) hbox.pack_start(self.keys_combo, True, True, 0) # Simulate self.simulate_key_press_button = Gtk.Button() self.simulate_key_press_button.set_image( Gtk.Image(icon_name='input-keyboard')) self.simulate_key_press_button.set_tooltip_text('Simulate') self.simulate_key_press_button.set_sensitive(False) self.simulate_key_press_button.connect( 'clicked', self.on_simulate_key_press_button_clicked) hbox.add(self.simulate_key_press_button) ## Scroll vbox.add(Gtk.Label('<b>Scroll</b>', xalign=0, use_markup=True)) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) vbox.add(hbox) # Direction self.scroll_direction_combo = CustomComboBox(['up', 'down']) self.scroll_direction_combo.set_active(1) hbox.pack_start(self.scroll_direction_combo, True, True, 0) # Value self.scroll_menu_button = MenuButton(text='1', position=Gtk.PositionType.TOP) self.scroll_spin_button = SpinButton(min=1, max=10) self.scroll_spin_button.connect( 'value-changed', lambda button: self.scroll_menu_button.set_label( str(button.get_value_as_int()))) self.scroll_menu_button.add(self.scroll_spin_button) hbox.add(self.scroll_menu_button) # Simulate simulate_scroll_button = Gtk.Button() pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( tools.get_full_path('icons/scroll.png'), 16, 16) #pixbuf = Gdk.Cursor(Gdk.CursorType.SB_V_DOUBLE_ARROW).get_image().scale_simple(18, 18, GdkPixbuf.InterpType.BILINEAR) simulate_scroll_button.set_image(Gtk.Image(pixbuf=pixbuf)) simulate_scroll_button.set_tooltip_text('Simulate') simulate_scroll_button.connect('clicked', self.on_simulate_scroll_button_clicked) hbox.add(simulate_scroll_button)
def set_internet_state(self, state): if state: self.start_button.set_image(Gtk.Image(file=tools.get_full_path('icons/loader.gif'))) else: self.log(tools.print_internet_state(state), LogType.Error) self.start_button.set_image(Gtk.Image(icon_name='network-error'))
def create_tabs(self): log_notebook = Gtk.Notebook() log_notebook.set_border_width(2) self.vtable.attach(log_notebook, 0, 1, 3, 4) bot_notebook = Gtk.Notebook() bot_notebook.set_border_width(2) self.htable.attach(bot_notebook, 0, 1, 0, 1) # Log Tab/Page log_page = Gtk.ScrolledWindow() self.log_view = Gtk.TextView() self.log_view.set_border_width(5) self.log_view.set_editable(False) self.log_view.set_wrap_mode(Gtk.WrapMode.WORD) self.log_view.connect('size-allocate', self.log_view_auto_scroll) self.log_buf = self.log_view.get_buffer() self.red_text_tag = self.log_buf.create_tag('red', foreground='#dc3545') self.green_text_tag = self.log_buf.create_tag('green', foreground='#28a745') self.blue_text_tag = self.log_buf.create_tag('blue', foreground='#007bff') log_page.add(self.log_view) log_notebook.append_page(log_page, Gtk.Label('Log')) # Debug Tab self.debug_page = Gtk.ScrolledWindow() self.debug_view = Gtk.TextView() self.debug_view.set_border_width(5) self.debug_view.set_editable(False) self.debug_view.set_wrap_mode(Gtk.WrapMode.WORD) self.debug_view.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('black')) self.debug_view.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse('white')) self.debug_view.connect('size-allocate', self.debug_view_auto_scroll) self.debug_buf = self.debug_view.get_buffer() self.debug_page.add(self.debug_view) log_notebook.append_page(self.debug_page, Gtk.Label('Debug')) # Dev tools Tab if '--dev' in self.args: dev_tools_page = DevToolsWidget(self) log_notebook.append_page(dev_tools_page, Gtk.Label('Dev Tools')) log_notebook.show_all() log_notebook.set_current_page(2) ### Bot Tab bot_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) bot_page.set_border_width(10) bot_notebook.append_page(bot_page, Gtk.Label('Bot')) self.bot_widgets = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) bot_page.add(self.bot_widgets) ## Game Window self.bot_widgets.add(Gtk.Label('<b>Game Window</b>', xalign=0, use_markup=True)) game_window_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) self.bot_widgets.add(game_window_box) # ComboBox self.game_window_combo = Gtk.ComboBoxText() self.game_window_combo.set_margin_left(10) self.populate_game_window_combo() self.game_window_combo.connect('changed', self.on_game_window_combo_changed) game_window_box.pack_start(self.game_window_combo, True, True, 0) # Refresh self.refresh_button = Gtk.Button() self.refresh_button.set_image(Gtk.Image(icon_name='view-refresh')) self.refresh_button.set_tooltip_text('Refresh') self.refresh_button.connect('clicked', self.on_refresh_button_clicked) game_window_box.add(self.refresh_button) # Unplug self.unplug_button = Gtk.Button() self.unplug_button.set_image(Gtk.Image(icon_name='view-restore')) self.unplug_button.set_tooltip_text('Unplug') self.unplug_button.connect('clicked', self.on_unplug_button_clicked) game_window_box.add(self.unplug_button) # Plug if '--dev' in self.args: self.plug_button = Gtk.Button() self.plug_button.set_image(Gtk.Image(icon_name='window-new-symbolic')) self.plug_button.set_tooltip_text('Plug') self.plug_button.connect('clicked', self.on_plug_button_clicked) game_window_box.add(self.plug_button) ## Bot Path self.bot_widgets.add(Gtk.Label('<b>Bot Path</b>', xalign=0, use_markup=True)) bot_path_filechooserbutton = FileChooserButton(title='Choose bot path', filter=('Bot Path', '*.path')) bot_path_filechooserbutton.set_margin_left(10) bot_path_filechooserbutton.set_current_folder(tools.get_full_path('paths')) bot_path_filechooserbutton.connect('file-set', self.on_bot_path_changed) self.bot_widgets.add(bot_path_filechooserbutton) ## Start From Step hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) self.bot_widgets.add(hbox) hbox.add(Gtk.Label('Start From Step')) self.step_spin_button = SpinButton(min=1, max=1000) self.step_spin_button.set_margin_left(10) hbox.pack_end(self.step_spin_button, False, False, 0) ## Repeat Path hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) hbox.add(Gtk.Label('Repeat Path')) self.bot_widgets.add(hbox) # Switch self.repeat_switch = Gtk.Switch() self.repeat_switch.connect('notify::active', lambda switch, pspec: self.repeat_spin_button.set_sensitive(switch.get_active())) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) vbox.pack_start(self.repeat_switch, True, False, 0) hbox.add(vbox) # SpinButton self.repeat_spin_button = SpinButton(min=2, max=1000) self.repeat_spin_button.set_tooltip_text('Number of times') self.repeat_spin_button.set_sensitive(False) hbox.pack_end(self.repeat_spin_button, False, False, 0) ## Connect To Account hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Connect To Account</b>', xalign=0, use_markup=True)) self.bot_widgets.add(hbox) # Switch self.connect_to_account_switch = Gtk.Switch() self.connect_to_account_switch.connect('notify::active', lambda switch, pspec: self.connect_to_account_box.set_sensitive(switch.get_active())) hbox.pack_end(self.connect_to_account_switch, False, False, 0) # Box self.connect_to_account_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) self.connect_to_account_box.set_margin_left(10) self.connect_to_account_box.set_sensitive(False) self.bot_widgets.add(self.connect_to_account_box) # Account hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('Account')) self.connect_to_account_box.add(hbox) # Combo accounts_list = accounts.load() self.accounts_combo = TextValueComboBox(accounts_list, model=Gtk.ListStore(str, int), text_key='login', value_key='id', sort_key='position') self.accounts_combo.set_size_request(120, -1) hbox.pack_end(self.accounts_combo, False, False, 0) # Disconnect after hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('Disconnect after')) self.connect_to_account_box.add(hbox) # Switch self.disconnect_after_switch = Gtk.Switch() hbox.pack_end(self.disconnect_after_switch, False, False, 0) ## Pod self.podbar_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) bot_page.add(self.podbar_box) self.podbar_box.add(Gtk.Label('<b>Pod</b>', xalign=0, use_markup=True)) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.podbar_box.pack_start(vbox, True, True, 0) self.podbar = Gtk.ProgressBar() vbox.pack_start(self.podbar, True, False, 0) ## MiniMap self.minimap_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) bot_page.add(self.minimap_box) self.minimap_box.add(Gtk.Label('<b>MiniMap</b>', xalign=0, use_markup=True)) self.minimap = MiniMap(grid_size=(18, 18)) self.minimap.set_size_request(-1, 210) self.minimap.set_margin_left(10) self.minimap_box.add(self.minimap) ## Start button_box = ButtonBox(centered=True, linked=True) bot_page.pack_end(button_box, False, False, 0) self.start_button = Gtk.Button() self.start_button.set_tooltip_text('Start') self.start_button.set_image(Gtk.Image(icon_name='media-playback-start')) self.start_button.connect('clicked', self.on_start_button_clicked) button_box.add(self.start_button) ## Pause self.pause_button = Gtk.Button() self.pause_button.set_image(Gtk.Image(icon_name='media-playback-pause')) self.pause_button.set_tooltip_text('Pause') self.pause_button.set_sensitive(False) self.pause_button.connect('clicked', self.on_pause_button_clicked) button_box.add(self.pause_button) ## Stop self.stop_button = Gtk.Button() self.stop_button.set_image(Gtk.Image(icon_name='media-playback-stop')) self.stop_button.set_tooltip_text('Stop') self.stop_button.set_sensitive(False) self.stop_button.connect('clicked', self.on_stop_button_clicked) button_box.add(self.stop_button) ### Path Tab path_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) path_page.set_border_width(10) bot_notebook.append_page(path_page, Gtk.Label('Path')) ## Movement path_page.add(Gtk.Label('<b>Movement</b>', xalign=0, use_markup=True)) button_box = ButtonBox(orientation=Gtk.Orientation.VERTICAL, centered=True) path_page.add(button_box) # Up up_button = Gtk.Button() up_button.set_image(Gtk.Image(icon_name='go-up')) up_button.connect('clicked', lambda button: self.path_listbox.append_text('Move(UP)')) button_box.add(up_button) # Left left_button = Gtk.Button() left_button.set_image(Gtk.Image(icon_name='go-previous')) left_button.connect('clicked', lambda button: self.path_listbox.append_text('Move(LEFT)')) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=40) hbox.add(left_button) button_box.add(hbox) # Right right_button = Gtk.Button() right_button.set_image(Gtk.Image(icon_name='go-next')) right_button.connect('clicked', lambda buton: self.path_listbox.append_text('Move(RIGHT)')) hbox.add(right_button) # Down down_button = Gtk.Button() down_button.set_image(Gtk.Image(icon_name='go-down')) down_button.connect('clicked', lambda button: self.path_listbox.append_text('Move(DOWN)')) button_box.add(down_button) ## Action path_page.add(Gtk.Label('<b>Action</b>', xalign=0, use_markup=True)) stack_listbox = StackListBox() path_page.add(stack_listbox) ## Enclos pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/enclos.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Enclos') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Location widget.add(Gtk.Label('<b>Location</b>', xalign=0, use_markup=True)) self.enclos_location_combo = CustomComboBox(data.Enclos, sort=True) self.enclos_location_combo.set_margin_left(10) widget.add(self.enclos_location_combo) # Type widget.add(Gtk.Label('<b>Type</b>', xalign=0, use_markup=True)) self.enclos_type_combo = CustomComboBox(data.EnclosType, sort=True) self.enclos_type_combo.set_margin_left(10) widget.add(self.enclos_type_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Enclos(location=%s,type=%s)' % (self.enclos_location_combo.get_active_text(), self.enclos_type_combo.get_active_text()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Zaap pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/zaap.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Zaap') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # From widget.add(Gtk.Label('<b>From</b>', xalign=0, use_markup=True)) self.zaap_from_combo = CustomComboBox(data.Zaap['From'], sort=True) self.zaap_from_combo.set_margin_left(10) self.zaap_from_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaap_to_combo) ) widget.add(self.zaap_from_combo) # To widget.add(Gtk.Label('<b>To</b>', xalign=0, use_markup=True)) self.zaap_to_combo = CustomComboBox(data.Zaap['To'], sort=True) self.zaap_to_combo.set_margin_left(10) self.zaap_to_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaap_from_combo) ) widget.add(self.zaap_to_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Zaap(from=%s,to=%s)' % (self.zaap_from_combo.get_active_text(), self.zaap_to_combo.get_active_text()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Zaapi pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/destination.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Zaapi') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # From widget.add(Gtk.Label('<b>From</b>', xalign=0, use_markup=True)) self.zaapi_from_combo = CustomComboBox(data.Zaapi['From'], sort=True) self.zaapi_from_combo.set_margin_left(10) self.zaapi_from_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaapi_to_combo, use_contains=True) ) widget.add(self.zaapi_from_combo) # To widget.add(Gtk.Label('<b>To</b>', xalign=0, use_markup=True)) self.zaapi_to_combo = CustomComboBox(data.Zaapi['To'], sort=True) self.zaapi_to_combo.set_margin_left(10) self.zaapi_to_combo.connect('changed', lambda combo: combo.sync_with_combo(self.zaapi_from_combo, use_contains=True) ) widget.add(self.zaapi_to_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Zaapi(from=%s,to=%s)' % (self.zaapi_from_combo.get_active_text(), self.zaapi_to_combo.get_active_text()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Collect pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/miner.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Collect') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Map widget.add(Gtk.Label('<b>Map</b>', xalign=0, use_markup=True)) self.collect_map_combo = CustomComboBox(maps.load(), sort=True) self.collect_map_combo.set_margin_left(10) widget.add(self.collect_map_combo) # Store Path widget.add(Gtk.Label('<b>Store Path</b>', xalign=0, use_markup=True)) # Combo hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) self.collect_sp_combo_radio = Gtk.RadioButton() self.collect_sp_combo_radio.set_active(True) hbox.add(self.collect_sp_combo_radio) self.collect_sp_combo = CustomComboBox(data.BankPath, sort=True) self.collect_sp_combo.connect('changed', lambda combo: self.collect_sp_combo_radio.set_active(True)) hbox.pack_start(self.collect_sp_combo, True, True, 0) widget.add(hbox) # FileChooserButton hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.set_margin_left(10) self.collect_sp_filechooser_radio = Gtk.RadioButton(group=self.collect_sp_combo_radio) hbox.add(self.collect_sp_filechooser_radio) self.collect_sp_filechooserbutton = FileChooserButton(title='Choose store path', filter=('Store Path', '*.path')) self.collect_sp_filechooserbutton.set_current_folder(tools.get_full_path('paths')) self.collect_sp_filechooserbutton.connect('file-set', lambda filechooserbutton: self.collect_sp_filechooser_radio.set_active(True)) hbox.pack_start(self.collect_sp_filechooserbutton, True, True, 0) widget.add(hbox) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Collect(map=%s,store_path=%s)' % (self.collect_map_combo.get_active_text(), self.collect_sp_combo.get_active_text() if self.collect_sp_combo_radio.get_active() else self.collect_sp_filechooserbutton.get_filename()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Click pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/arrow.png'), 24, 24) #pixbuf = Gdk.Cursor(Gdk.CursorType.ARROW).get_image().scale_simple(24, 24, GdkPixbuf.InterpType.BILINEAR) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Click') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Twice hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Twice</b>', xalign=0, use_markup=True)) self.click_twice_switch = Gtk.Switch() hbox.pack_end(self.click_twice_switch, False, False, 0) widget.add(hbox) # Location hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Location</b>', xalign=0, use_markup=True)) cursor_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/crosshair.png'), 16, 16) #cursor_pixbuf = Gdk.Cursor(Gdk.CursorType.CROSSHAIR).get_image().scale_simple(18, 18, GdkPixbuf.InterpType.BILINEAR) self.select_button = Gtk.Button() self.select_button.set_size_request(40, -1) self.select_button.set_tooltip_text('Select') self.select_button.set_image(Gtk.Image(pixbuf=cursor_pixbuf)) self.select_button.connect('clicked', self.on_select_button_clicked) hbox.pack_end(self.select_button, False, False, 0) widget.add(hbox) ## Wait pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(tools.get_full_path('icons/hourglass.png'), 24, 24) image = Gtk.Image(pixbuf=pixbuf) label = ImageLabel(image, 'Wait') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Pause Bot hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>Pause Bot</b>', xalign=0, use_markup=True)) self.pause_bot_switch = Gtk.Switch() self.pause_bot_switch.connect('notify::active', lambda switch, pspec: self.duration_box.set_sensitive(not switch.get_active())) hbox.pack_end(self.pause_bot_switch, False, False, 0) widget.add(hbox) # Duration self.duration_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) label = Gtk.Label('<b>Duration</b>', xalign=0, use_markup=True) label.set_tooltip_text('(in seconds)') self.duration_box.add(label) self.duration_spin_button = SpinButton(min=1, max=60) self.duration_box.pack_end(self.duration_spin_button, False, False, 0) widget.add(self.duration_box) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Wait(duration=%d,pause=%s)' % (0 if self.pause_bot_switch.get_active() else self.duration_spin_button.get_value_as_int(), self.pause_bot_switch.get_active()))) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Keyboard image = Gtk.Image(icon_name='input-keyboard', icon_size=Gtk.IconSize.LARGE_TOOLBAR) label = ImageLabel(image, 'Keyboard') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Press Key hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) self.press_key_radio = Gtk.RadioButton() self.press_key_radio.add(Gtk.Label('<b>Press Key</b>', xalign=0, use_markup=True)) hbox.add(self.press_key_radio) self.key_label = Gtk.Label() hbox.add(self.key_label) widget.add(hbox) self.keys_combo = CustomComboBox(data.KeyboardShortcuts, sort=True) self.keys_combo.set_margin_left(10) self.keys_combo.connect('changed', lambda combo: ( self.key_label.set_text('(' + data.KeyboardShortcuts[combo.get_active_text()] + ')'), self.press_key_radio.set_active(True) ) ) widget.add(self.keys_combo) # Type Text self.type_text_radio = Gtk.RadioButton(group=self.press_key_radio) self.type_text_radio.add(Gtk.Label('<b>Type Text</b>', xalign=0, use_markup=True)) widget.add(self.type_text_radio) self.type_text_entry = Gtk.Entry(placeholder_text='Text') self.type_text_entry.set_margin_left(10) self.type_text_entry.set_width_chars(10) self.type_text_entry.connect('focus-in-event', lambda entry, event: self.type_text_radio.set_active(True)) widget.add(self.type_text_entry) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', self.on_keyboard_add_button_clicked) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Connect image = Gtk.Image(icon_name='network-wired', icon_size=Gtk.IconSize.LARGE_TOOLBAR) label = ImageLabel(image, 'Connect') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Account widget.add(Gtk.Label('<b>Account</b>', xalign=0, use_markup=True)) self.connect_accounts_combo = TextValueComboBox(accounts_list, model=Gtk.ListStore(str, int), text_key='login', value_key='id', sort_key='position') self.connect_accounts_combo.set_margin_left(10) widget.add(self.connect_accounts_combo) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Connect(account_id=%s)' % self.connect_accounts_combo.get_active_value())) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Disconnect image = Gtk.Image(icon_name='network-idle', icon_size=Gtk.IconSize.LARGE_TOOLBAR) label = ImageLabel(image, 'Disconnect') widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) stack_listbox.append(label, widget) # Exit Game hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) widget.add(hbox) hbox.add(Gtk.Label('<b>Exit Game</b>', xalign=0, use_markup=True)) self.exit_game_switch = Gtk.Switch() hbox.pack_end(self.exit_game_switch, False, False, 0) # Add add_button = Gtk.Button('Add') add_button.connect('clicked', lambda button: self.path_listbox.append_text('Disconnect(%s)' % self.exit_game_switch.get_active())) button_box = ButtonBox(centered=True) button_box.add(add_button) widget.add(button_box) ## Separator path_page.add(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, margin=5)) ## Listbox self.path_listbox = CustomListBox() path_page.pack_end(self.path_listbox, True, True, 0) # Load load_path_button = Gtk.Button() load_path_button.set_tooltip_text('Load') load_path_button.set_image(Gtk.Image(icon_name='document-open')) load_path_button.connect('clicked', self.on_load_path_button_clicked) self.path_listbox.add_button(load_path_button) # Save self.save_path_button = Gtk.Button() self.save_path_button.set_tooltip_text('Save') self.save_path_button.set_sensitive(False) self.save_path_button.set_image(Gtk.Image(icon_name='document-save-as')) self.save_path_button.connect('clicked', self.on_save_path_button_clicked) self.path_listbox.add_button(self.save_path_button) self.path_listbox.on_add(self.on_path_listbox_add) self.path_listbox.on_delete(self.on_path_listbox_delete) ### Map Tab map_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) map_page.set_border_width(10) bot_notebook.append_page(map_page, Gtk.Label('Map')) ## View hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) hbox.add(Gtk.Label('<b>View</b>', xalign=0, use_markup=True)) map_page.add(hbox) # Options menu_image = MenuImage() hbox.add(menu_image) options_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) menu_image.set_widget(options_box) # Use data colors use_data_colors_check = Gtk.CheckButton('Use data colors') use_data_colors_check.connect('clicked', lambda button: self.map_view.set_use_origin_colors(button.get_active())) options_box.add(use_data_colors_check) # Add borders add_borders_check = Gtk.CheckButton('Add borders') add_borders_check.connect('clicked', lambda button: self.map_view.set_add_borders(button.get_active())) options_box.add(add_borders_check) # Map View self.map_view = MiniMap() map_page.pack_start(self.map_view, True, True, 0) ## Data map_page.add(Gtk.Label('<b>Data</b>', xalign=0, use_markup=True)) self.map_data_listbox = CustomListBox(allow_moving=False) map_page.pack_start(self.map_data_listbox, True, True, 0) # Select self.select_resource_button = Gtk.Button() self.select_resource_button.set_tooltip_text('Select resource') self.select_resource_button.set_image(Gtk.Image(pixbuf=cursor_pixbuf)) self.select_resource_button.connect('clicked', self.on_select_resource_button_clicked) self.map_data_listbox.add_button(self.select_resource_button) # Edit edit_map_button = MenuButton(icon_name='document-edit-symbolic') edit_map_button.set_tooltip_text('Edit') self.map_data_listbox.add_button(edit_map_button) button_box = ButtonBox(linked=True) edit_map_button.add(button_box) # Load load_map_button = Gtk.Button() load_map_button.set_tooltip_text('Load') load_map_button.set_image(Gtk.Image(icon_name='document-open')) load_map_button.connect('clicked', self.on_load_map_button_clicked) button_box.add(load_map_button) # Delete delete_map_button = Gtk.Button() delete_map_button.set_tooltip_text('Delete') delete_map_button.set_image(Gtk.Image(icon_name='edit-delete')) delete_map_button.connect('clicked', self.on_delete_map_button_clicked) button_box.add(delete_map_button) # Save self.save_map_button = Gtk.Button() self.save_map_button.set_tooltip_text('Save') self.save_map_button.set_sensitive(False) self.save_map_button.set_image(Gtk.Image(icon_name='document-save-as')) self.save_map_button.connect('clicked', self.on_save_map_button_clicked) self.map_data_listbox.add_button(self.save_map_button) self.map_data_listbox.on_add(self.on_map_data_listbox_add) self.map_data_listbox.on_delete(self.on_map_data_listbox_delete)
def on_take_screenshot_button_clicked(self, button): if self.game_window: screenshot_name = 'screenshot_' + tools.get_date_time() screenshot_path = tools.get_full_path(screenshot_name) tools.take_window_screenshot(self.game_window, screenshot_path) self.log("Screenshot saved to '%s'" % screenshot_path, LogType.Info)