class EnemyQuitGame(Dialog): def __init__(self, master: Window): Dialog.__init__(self, master, bg_color=BLUE, outline=2, outline_color=WHITE) self.master = master self.bg = RectangleShape(self.width, self.height, (0, 0, 0, 170)) self.text = Text(font=RESOURCES.font("heavy", 50)) self.button_quit = Button(self, "Return to menu", theme=["section"], font=RESOURCES.font("heavy", 40), y_add_size=-25, callback=self.stop) self.objects.set_priority(self.bg, 0) self.master = master def on_quit(self) -> None: self.master.stop() def on_start_loop(self) -> None: self.button_quit.focus_set() def place_objects(self) -> None: self.text.center = self.frame.center self.button_quit.move(centerx=self.frame.centerx, bottom=self.frame.bottom - 10)
class LocalPlayingSection(Section): def __init__(self, master, gameplay: FourInARowGameplay): Section.__init__(self, master, "Local Multiplaying", gameplay) self.form = Form(self) self.form.add_entry("P1", Text("P1 Name:", theme="form"), Entry(self)) self.form.add_entry("P2", Text("P2 Name:", theme="form"), Entry(self)) self.button_play = Button(self, "Play", theme=["option", "section"], callback=self.play) def on_start_loop(self) -> None: super().on_start_loop() self.button_play.focus_set() def place_objects(self) -> None: Section.place_objects(self) self.form.move(left=self.frame.left + 10, top=self.title.bottom + 50) self.button_play.move(centerx=self.frame.centerx, bottom=self.frame.bottom - 10) def set_grid(self) -> None: self.button_back.set_obj_on_side(on_bottom=self.form[0], on_right=self.form[0]) self.form.set_obj_on_side(on_top=self.button_back, on_left=self.button_back, on_bottom=self.button_play) self.button_play.set_obj_on_side(on_top=self.form[-1]) def play(self) -> None: player_1_name = self.form.get("P1") or None player_2_name = self.form.get("P2") or None self.gameplay.start(LOCAL_PLAYER, player_name=player_1_name, enemy_name=player_2_name) self.stop()