def __init__(self, parent=None): self.gui = TrainerPeoplemonEditorGUI(parent) self.peoplemon = TrainerPeoplemon() self.main_saveable = self.peoplemon int_entry_map = { self.gui.id: self.peoplemon.id, self.gui.level: self.peoplemon.level, self.gui.xp: self.peoplemon.cur_xp, self.gui.next_xp: self.peoplemon.next_level_up_xp, self.gui.cur_hp: self.peoplemon.cur_hp, self.gui.cur_ail: self.peoplemon.cur_ail, self.gui.hold: self.peoplemon.hold_item } for widget, saveable in int_entry_map.items(): widget.entry.config(textvariable=make_int_var(saveable)) moves = (self.peoplemon.move1.id, self.peoplemon.move1.pp, self.peoplemon.move2.id, self.peoplemon.move2.pp, self.peoplemon.move3.id, self.peoplemon.move3.pp, self.peoplemon.move4.id, self.peoplemon.move4.pp) for entry, saveable in zip(self.gui.moves_widgets, moves): entry.config(textvariable=make_int_var(saveable)) for widget, saveable in zip(self.gui.iv_widgets, [x for x in self.peoplemon.ivs]): widget.entry.config(textvariable=make_int_var(saveable)) for widget, saveable in zip(self.gui.ev_widgets, [x for x in self.peoplemon.evs]): widget.entry.config(textvariable=make_int_var(saveable)) self.gui.nick.entry.config( textvariable=make_str_var(self.peoplemon.nickname))
def select_override(self, ind): if ind is not None: current = self.array_connector.cur_selection self.gui.string.entry.config( textvariable=make_str_var(current.code)) self.gui.code.entry.config( textvariable=make_int_var(current.override))
def on_select(self, id): move = self.item_connector.cur_selection gui = self.gui for widget, saveable in ( (gui.id, move.id), (gui.attack, move.attack), (gui.accuracy, move.accuracy), (gui.effect, move.effect), (gui.priority, move.priority), (gui.pp, move.pp), (gui.type, move.type), (gui.chance, move.effect_chance), (gui.intensity, move.effect_intensity), (gui.score, move.effect_score)): widget.entry.config(textvariable=make_int_var(saveable)) for widget, saveable in ( (gui.name.entry, move.name), (gui.attacker_anim.entry, move.attacker_anim), (gui.defender_anim.entry, move.defender_anim), (gui.description, move.description)): widget.config(textvariable=make_str_var(saveable)) for widget, saveable in ( (gui.is_special, move.is_special), (gui.targets_self, move.effect_targets_self)): widget.config(variable=make_check_var(saveable)) gui.classification.combo.config(textvariable=make_combo_var(move.classification, CLASSIFICATIONS))
def on_learn_move_select(self, ind): if ind is None: return learn_move = self.item_connector.cur_selection.learn_moves[ind] for widget, saveable in ((self.gui.learn_move_id, learn_move.move_id), (self.gui.learn_level, learn_move.learn_level)): widget.entry.config(textvariable=make_int_var(saveable))
def on_select(self, id): peoplemon = self.item_connector.cur_selection gui = self.gui int_map = { gui.id: peoplemon.id, gui.base_xp: peoplemon.base_xp_yield, gui.special_id: peoplemon.special_ability_id, gui.type: peoplemon.type, gui.evolve_level: peoplemon.evolve_level, gui.evolve_id: peoplemon.evolve_id } for widget, saveable in int_map.items(): widget.entry.config(textvariable=make_int_var(saveable)) for widget, saveable in ((gui.description, peoplemon.description), (gui.name.entry, peoplemon.name)): widget.config(textvariable=make_str_var(saveable)) gui.xp_group.combo.config( textvariable=make_combo_var(peoplemon.xp_group, XP_MAP)) for stats_gui, stats, in ((self.gui.base_stats, peoplemon.base_stats), (self.gui.ev_stats, peoplemon.ev_stats)): for widget, saveable in ((stats_gui.attack, stats.attack), (stats_gui.defense, stats.defense), (stats_gui.special_attack, stats.special_attack), (stats_gui.special_defense, stats.special_defense), (stats_gui.hp, stats.hp), (stats_gui.speed, stats.speed), (stats_gui.accuracy, stats.accuracy), (stats_gui.evade, stats.evade), (stats_gui.critical, stats.critical)): widget.entry.config(textvariable=make_int_var(saveable)) self.learn_move_connector = ArrayConnector(peoplemon.learn_moves, gui.learn_list, gui.add_learn_move, gui.learn_move_id, gui.learn_level) self.available_move_connector = ArrayConnector( peoplemon.valid_moves, gui.available_list, gui.add_available_button, gui.available_move_id) self.gui.learn_list.signal_select.connect(self.on_learn_move_select) self.gui.available_list.signal_select.connect( self.on_available_move_select)
def select_node(self, ind): if ind is not None: node_widget = self.gui.current_motion_widget current = self.node_connector.cur_selection combo_map = {D_UP: 0, D_RIGHT: 1, D_DOWN: 2, D_LEFT: 3} node_widget.steps.entry.config( textvariable=make_int_var(current.num_steps)) node_widget.direction.config( textvariable=make_combo_var(current.direction, combo_map))
def credit_changed(self, ind): current = self.array_connector.cur_selection self.gui.multi_widget.change_widget(self.TYPE_MAP[current.type.get()]) widget = self.gui.multi_widget.current_widget if current.type.get() == ImageType: widget.path.entry.configure( textvariable=make_str_var(current.type.image)) elif current.type.get() == TextType: text_credit = current.type.text widget.text.entry.configure( textvariable=make_str_var(text_credit.text)) widget.size.entry.configure( textvariable=make_int_var(text_credit.size)) widget.signal_color_selected.connect(self.on_color_selected) for saveable in (text_credit.blue, ): saveable.signal_changed.connect(self.on_color_changed) self.on_color_changed(None) self.gui.x_pos.entry.config(textvariable=make_int_var(current.x)) self.gui.y_buf.entry.config(textvariable=make_int_var(current.y_buf))
def __init__(self, parent=None): self.gui = TrainerEditorGUI(parent) self.trainer = Trainer() self.main_saveable = self.trainer str_entry_map = { self.gui.name: self.trainer.name, self.gui.anim_name: self.trainer.animation, self.gui.before_convo: self.trainer.before_convo, self.gui.after_convo: self.trainer.after_convo, self.gui.lost_text: self.trainer.lose_message, self.gui.playlist: self.trainer.playlist, self.gui.background: self.trainer.background_image } self.gui.item_list.set_key(lambda item: item.get()) for widget, saveable in str_entry_map.items(): widget.entry.config(textvariable=make_str_var(saveable)) self.gui.sight_range.entry.config( textvariable=make_int_var(self.trainer.sight_range)) self.node_connector = None self.peoplemon_connector = ArrayConnector(self.trainer.peoplemon, self.gui.peoplemon_list, self.gui.add_peoplemon, self.gui.file_name) self.peoplemon_connector.bind_move() self.item_connector = ArrayConnector(self.trainer.items, self.gui.item_list, self.gui.add_item, self.gui.item_id) self.gui.peoplemon_list.signal_select.connect(self.select_peoplemon) self.gui.item_list.signal_select.connect(self.select_item) ai_map = { AI_RANDOM: 0, AI_DUMB: 1, AI_SMART: 2, AI_SUICIDAL: 3, AI_AGGRESSIVE: 4, AI_DEFENSIVE: 5, AI_AVERAGE: 6, AI_ADAPTIVE: 7 } behavior_map = { B_STILL: StandStillBehavior, B_SPIN: SpinInPlaceBehavior, B_FOLLOW: FollowPathBehavior, B_WANDER: WanderBehavior } self.gui.ai_type.config( textvariable=make_combo_var(self.trainer.ai_type, ai_map)) self.gui.motion_type.config( textvariable=make_combo_var(self.trainer.behavior, behavior_map)) self.behavior_connect = BehaviorWidgetConnector( self.gui.behavior_widget, self.trainer.behavior) self.behavior_connect.signal_repack.connect(self.on_repack)
def __init__(self, parent=None): self.gui = WildEditorGUI(parent) self.peoplemon = WildPeoplemon() self.main_saveable = self.peoplemon for entry, int_type in ((self.gui.entry_id, self.peoplemon.id), (self.gui.entry_min, self.peoplemon.min_lvl), (self.gui.entry_max, self.peoplemon.max_lvl), (self.gui.entry_rarity, self.peoplemon.rarity)): entry.entry.config(textvariable=make_int_var(int_type)) self.array_connector = ArrayConnector(self.peoplemon.overrides, self.gui.choices, self.gui.add, self.gui.code, self.gui.string) self.gui.choices.signal_select.connect(self.select_override) self.gui.choices.set_key(lambda override: override.code.get())
def select_override(self, ind): if ind is not None: current = self.array_connector.cur_selection int_map = { self.gui.entry_x: current.x, self.gui.entry_y: current.y, self.gui.entry_spawn: current.spawn_id } str_map = { self.gui.entry_display: current.display_name, self.gui.entry_ref: current.reference_name, self.gui.entry_map: current.map_name } for entry, saveable in int_map.items(): entry.entry.config(textvariable=make_int_var(saveable)) for entry, saveable in str_map.items(): entry.entry.config(textvariable=make_str_var(saveable))
def behavior_changed(self, Type, *args): widget_map = { StandStillBehavior: Still, SpinInPlaceBehavior: SpinInPlace, FollowPathBehavior: FollowPath, WanderBehavior: WanderFreely } if Type not in widget_map: return self.gui.change_widget(widget_map[Type]) current = self.gui.current_motion_widget if Type == StandStillBehavior: self.signal_repack(False) elif Type == WanderBehavior: current.radius.entry.config( textvariable=make_int_var(self.behavior.wander.radius)) self.signal_repack(False) elif Type == SpinInPlaceBehavior: dir_map = {D_CLOCK: 0, D_COUNTER: 1, D_RANDOM: 2} current.combo.config(textvariable=make_combo_var( self.behavior.spin.motion, dir_map)) self.signal_repack(False) elif Type == FollowPathBehavior: for node in self.behavior.follow.nodes: current.node_list.clear() current.node_list.append(str(node), node) current.pack(padx=10, fill=tk.BOTH) current.check.config( variable=make_check_var(self.behavior.follow.reverse_loop)) self.node_connector = ArrayConnector(self.behavior.follow.nodes, current.node_list, current.add_button, current.direction, current.steps) self.node_connector.bind_move() current.node_list.signal_select.connect(self.select_node) self.signal_repack(True)
def on_available_move_select(self, ind): if ind is None: return move = self.item_connector.cur_selection.valid_moves[ind] self.gui.available_move_id.entry.config( textvariable=make_int_var(move))
def select_item(self, ind): if ind is not None: current = self.item_connector.cur_selection self.gui.item_id.entry.config(textvariable=make_int_var(current))