Ejemplo n.º 1
0
 def initialize(self, evt: InitializeEvent):
     try:
         data = self.zipimport.get_data(
             "assets/models/bubble/example_bubble.json")
     except AttributeError:
         with open(
                 os.path.join(
                     self.modPath,
                     "../assets/models/bubble/example_bubble.json"),
                 "r") as file:
             data = file.read()
     models = {}
     models["example_bubble"] = json.loads(data)
     bubbles = init_bubbles()
     modelLoader = ModelLoader()
     evt.canvas.itemconfig(evt.t2, text="Initialize bubbles")
     for bubble in bubbles:
         for i in range(50):
             evt.canvas.itemconfig(
                 evt.t2,
                 text=f"Initialize bubble: '{bubble.get_uname()}' {i}/50")
             evt.canvas.update()
             time.sleep(0.05)
         uname = f"{self.modID}:{bubble.get_uname()}"
         images = modelLoader.generate_bubble_images(
             bubble.minRadius, bubble.maxRadius, models[bubble.get_uname()])
         Registry.register_bubble(uname, bubble)
         Registry.register_bubresource(uname, "images", images)
     print(f"Initialized addon {self.modID}")
Ejemplo n.º 2
0
 def execute(self, command, *args, **kwargs):
     args: List[str]
     args2 = []
     command_class: BaseCommand = Registry.get_command(command)
     for index in range(0, len(command_class.args)):
         if command_class.args[index] == int:
             if args[index].isnumeric():
                 args2.append(int(args[index]))
                 continue
             return ParserError(f"Invalid type for argument {index}, it's not an integer")
         elif command_class.args[index] == float:
             if args[index].isdigit():
                 args2.append(float(args[index]))
                 continue
             return ParserError(f"Invalid type for argument {index}, it's not a float'")
         elif command_class.args[index] == SPRITE:
             if args[index] in [s.get_sname() for s in Registry.get_sprites()]:
                 args.append(Registry.get_sprite(args[index]))
                 continue
             if args[index].count(":") == 1:
                 return ParserError(f"No such sprite: {repr(args[index])}")
             return ParserError(f"Invalid type for argument {index}")
         else:
             raise ParserError(f"Invalid Command Argument type: {repr(command_class.args[index])}")
     command_class.execute(*args2, **kwargs)
Ejemplo n.º 3
0
    def __init__(self):
        super(Player, self).__init__()

        self.rotation = 0
        self.appliedEffects = []
        self.appliedEffectTypes = []

        self.score = 0
        self.health = 10
        self.maxHealth = 10
        self._exp = 0

        self.radius = 12.5
        self.speed = 0
        self.baseSpeed = 0

        self.keysPressed = ""
        self._spriteName = "qbubbles:player"
        self._spriteData = SpriteData({"objects": [{
                "Money": {
                    "diamonds": 0,
                    "coins": 0
                },
                "Abilities": {
                    **dict(((key, value) for key, value in Registry.get_abilities()))
                },
                "Effects": [],
                "Position": [],
                "speed": 10,
                "lives": 7,
                "score": 0,
                "high_score": 0,
                "teleports": 0,
                "level": 1
            }]})
        self._objectData = SpriteData(
            {
                "Money": {
                    "diamonds": 0,
                    "coins": 0
                },
                "Abilities": {
                    **dict(((key, value) for key, value in Registry.get_abilities()))
                },
                "Effects": [],
                "Position": [10, 10],
                "speed": 10,
                "lives": 7,
                "score": 0,
                "high_score": 0,
                "teleports": 0,
                "level": 1
            }
        )
        self.events_activated = False

        self.up = False
        self.down = False
        self.right = False
        self.left = False
Ejemplo n.º 4
0
    def on_savedata_readed(self, data):
        self.score = data["Player"]["score"]

        for effect in data["Player"]["Effects"]:
            effect_class: BaseEffect = Registry.get_effect(effect["id"])
            time_length: float = effect["timeRemaining"]
            strength: float = effect["strength"]
            self.start_effect(effect_class, Registry.get_scene("Game"), time_length, strength)
Ejemplo n.º 5
0
    def _update_rot_tex(self):
        """
        Updates the rotation texture

        :return:
        """
        image = Registry.get_texture("sprite", "player", rotation=int(self.rotation - (self.rotation % 1)))
        c = Registry.get_scene("Game").canvas
        c.itemconfig(self.id, image=image)
Ejemplo n.º 6
0
    def change_scene(self, name, *args, **kwargs):
        if not Registry.scene_exists(name):
            raise SceneNotFoundError(f"scene '{name}' not existent")

        # Hide old scene first
        if self.currentScene is not None:
            self.currentScene.hide_scene()

        # Get new scene and show it
        new_scene = Registry.get_scene(name)
        self.currentSceneName = name
        self.currentScene: Scene = new_scene
        self.currentScene.show_scene(*args, **kwargs)
Ejemplo n.º 7
0
    def change_mode(self, name, *args, **kwargs):
        if not Registry.mode_exists(name):
            raise ModeNotFoundError(f"mode '{name}' not existent")

        # Hide old mode first
        if self.currentMode is not None:
            self.currentMode.stop_mode()

        # Get new mode and show it
        new_mode = Registry.get_mode(name)
        self.currentModeName = name
        self.currentMode: Mode = new_mode
        self.currentMode.start_mode(*args, **kwargs)
Ejemplo n.º 8
0
 def decorator(func):
     if not isclass(func):
         raise TypeError(f"Object '{func.__name___}' is not a class")
     if qbversion == GAME_VERSION:
         # MODS.append(dict(modid=modid, name=name, version=version, func=func))
         Registry.register_modobject(modid=modid,
                                     name=name,
                                     version=version,
                                     func=func)
         func.modID = modid
         func.name = name
         func.fpath = getfile(func)
         func.modPath = os.path.split(func.fpath)[0]
         func.version = version
         func.zipimport = None
Ejemplo n.º 9
0
    def __init__(self, canvas, x, y, *, gamemap, effect):
        barimage = Registry.get_texture("qbubbles:gui",
                                        "qbubbles:effect_bar",
                                        gamemap=gamemap)
        effectimage = Registry.get_texture("qbubbles:effect",
                                           effect.get_uname(),
                                           gamemap=gamemap)

        self.cBarimage = CImage(canvas, x, y, image=barimage, anchor="nw")
        self.cEffectimage = CImage(canvas,
                                   x + 2,
                                   y + 2,
                                   image=effectimage,
                                   anchor="nw")
        self._effect = effect
Ejemplo n.º 10
0
 def create(self, x, y):
     image = Registry.get_texture("sprite", "player", rotation=0)
     self.id = self._c_create_image(x, y, image, anchor="center")
     # self.id = Registry.get_scene("Game").canvas.create_image(x, y, image=Registry.get_texture("sprite", "player",
     #                                                                                           rotation=0))
     self.baseSpeed = 80
     self.speed = self.baseSpeed
Ejemplo n.º 11
0
 def create(self, x, y, radius=5, speed=5, health=5):
     if self.baseClass is None:
         raise UnlocalizedNameError(f"BubbleObject is used for Sprite information, use the base_class argument with "
                                    f"a Bubble-instance instead of NoneType to fix this problem")
     if self.id is not None:
         raise OverflowError(f"BubbleObject is already created")
     canvas: Canvas = Registry.get_scene("Game").canvas
     self.defenceMultiplier = self.baseClass.defenceMultiplier
     self.attackMultiplier = self.baseClass.attackMultiplier
     self.baseSpeed = speed
     self.health = health
     self.radius = radius / 2
     self.id = canvas.create_image(
         x, y, image=Registry.get_texture("qbubbles:bubble", self.baseClass.get_uname(), radius=radius))
     self._objectData["radius"] = radius
     self._objectData["speed"] = speed
     self._objectData["health"] = health
     self._objectData["Position"] = (x, y)
     UpdateEvent.bind(self.on_update)
     CleanUpEvent.bind(self.on_cleanup)
     CollisionEvent.bind(self.on_collision)
Ejemplo n.º 12
0
    def __init__(self):
        """
        Main-class constructor for Q-Bubbles
        """
        os.chdir(os.path.split(__file__)[0])  # ...\qbubbles

        self.fakeRoot = FakeWindow()

        self.debug = False
        self.pre_run()
        super(Main, self).__init__(self.fakeRoot)
        self.fakeRoot.bind_events(self)
        # self.protocol("WM_DELETE_WINDOW", self.fakeRoot.destroy)

        self.dpiX: float
        self.dpiY: float
        self.dpiScaling: float
        self.tkScale: Callable
        self.tkGeometryScale: Callable

        make_tk_dpiaware(self)

        Registry.register_window("fake", self.fakeRoot)
        Registry.register_window("default", self)
        Registry.gameData["startTime"] = time.time()

        width = self.winfo_screenwidth()
        height = self.winfo_screenheight()
        self.wm_attributes("-alpha", 0)
        self.geometry(self.tkGeometryScale(f"{width}x{height}+0+0"))
        self.wm_protocol("WM_DELETE_WINDOW", lambda: os.kill(os.getpid(), 0))
        self.update()
        self.deiconify()
        self.overrideredirect(1)
        self.wm_attributes("-alpha", 1)

        if "launcherConfig" not in Registry.gameData.keys():
            game_dir: Optional[str] = None
            for argv in sys.argv[1:]:
                if argv.startswith("gameDir="):
                    game_dir = argv[8:]
            if game_dir is None:
                raise RuntimeError(
                    "Argument 'gameDir' is not defined, Q-Bubbles cannot continue"
                )
            if not game_dir.endswith("/"):
                game_dir += "/"
            Registry.gameData["launcherConfig"] = {"gameDir": game_dir}

        # os.chdir(game_dir)

        Registry.register_scene("LoadScreen",
                                Load(Registry.get_window("default")))

        Load.scenemanager.change_scene("LoadScreen")
Ejemplo n.º 13
0
    def mainloop(self):
        import time
        # Titlemenu mainloop
        self.background.canvas.update()
        end_time = time.time() + 10
        while self.loop_active:
            try:
                # Update background
                self.background.create_bubble()
                self.background.move_bubbles()
                self.background.cleanup_bubs()

                # Update window
                self.frame.update()
                self.frame.update_idletasks()

                if "--travis" in sys.argv:
                    if time.time() > end_time:
                        Registry.get_window("default").destroy()
                        break
            except TclError:
                break
Ejemplo n.º 14
0
    def __init__(self):
        os.chdir(os.path.split(__file__)[0])

        self.fakeRoot = FakeWindow()

        self.pre_run()
        super(Main, self).__init__(self.fakeRoot)
        self.fakeRoot.bind_events(self)

        self.dpiX: float
        self.dpiY: float
        self.dpiScaling: float
        self.tkScale: Callable
        self.tkGeometryScale: Callable

        make_tk_dpiaware(self)

        Registry.register_window("fake", self.fakeRoot)
        Registry.register_window("default", self)
        Registry.gameData["startTime"] = time.time()

        # self.wm_attributes("-topmost", True)
        self.overrideredirect(1)
        # width = self.winfo_screenwidth()
        # height = self.winfo_screenheight()
        width = 1920
        height = 1080
        self.geometry(self.tkGeometryScale(f"{width}x{height}+0+0"))
        self.after(30000, lambda: os.kill(os.getpid(), 0))
        # self.wm_protocol("WM_DELETE_WINDOW", ...)

        if "launcherConfig" not in Registry.gameData.keys():
            game_dir: Optional[str] = None
            for argv in sys.argv[1:]:
                if argv.startswith("gameDir="):
                    game_dir = argv[8:]
            if game_dir is None:
                raise RuntimeError(
                    "Argument 'gameDir' is not defined, Q-Bubbles cannot continue"
                )
            Registry.gameData["launcherConfig"] = {"gameDir": game_dir}

        Registry.register_scene("LoadScreen",
                                Load(Registry.get_window("default")))

        Load.scenemanager.change_scene("LoadScreen")
Ejemplo n.º 15
0
 def distance(self, to):
     canvas = Registry.get_scene("Game").canvas
     try:
         # try:
         x1, y1 = self.get_coords()
         # except ValueError:
         #     self.instant_death()
         # try:
         x2, y2 = to.get_coords()
         # except ValueError:
         #     to.instant_death()
         # print(f"POINT_1: {x1, y1}")
         # print(f"POINT_2: {x2, y2}")
         # noinspection PyUnboundLocalVariable
         return sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
     except ValueError:
         return math.inf
     except UnboundLocalError:
         return math.inf
Ejemplo n.º 16
0
    def __init__(self):
        super(TitleMenu, self).__init__(Registry.get_window("default"))

        self.lang = Registry.gameData["language"]
        self.config = Registry.gameData["config"]
        self.btnFont: Font = Registry.gameData["fonts"]["titleButtonFont"]

        # Items
        self.items = list()

        # Create background
        self.background = Background(self.frame)

        # Create buttons
        self.start_btn = Button(
            self.frame, bg="#007f7f", fg="#7fffff", bd=15, command=lambda: self.play_event(),
            text=self.lang["home.start"], relief="flat", font=self.btnFont.get_tuple())
        self.quit_btn = Button(
            self.frame, bg="#007f7f", fg="#7fffff", bd=15, command=lambda: os.kill(os.getpid(), 0),
            text=self.lang["home.quit"], relief="flat", font=self.btnFont.get_tuple())
        self.options_btn = Button(
            self.frame, bg="#007f7f", fg="#7fffff", bd=15, text=self.lang["home.options"], relief="flat",
            font=self.btnFont.get_tuple())

        # Place buttons on screen
        self.start_btn.place(
            x=Registry.gameData["WindowWidth"] / 2, y=Registry.gameData["WindowHeight"] / 2 - 40, width=310,
            anchor="center")
        self.quit_btn.place(
            x=Registry.gameData["WindowWidth"] / 2 + 80, y=Registry.gameData["WindowHeight"] / 2 + 40, width=150,
            anchor=CENTER)
        self.options_btn.place(
            x=Registry.gameData["WindowWidth"] / 2 - 80, y=Registry.gameData["WindowHeight"] / 2 + 40, width=150,
            anchor="center")

        # Refresh game.
        self.frame.update()

        self.loop_active = True
Ejemplo n.º 17
0
    def __init__(self):
        super(TeleportMode, self).__init__("teleport")

        self.scene = Registry.get_scene("Game")
Ejemplo n.º 18
0
 def move_joy(self, x=0, y=0):
     Registry.get_scene("Game").canvas.move(self.id, x, y)
Ejemplo n.º 19
0
    def create_savedata(self, path, seed):
        game_data = {
            "GameInfo": {
                "seed": seed
            },
            "GameMap": {
                "id": self.get_uname(),
                "seed": seed,
                "initialized": False,
                "Randoms": []
            }
        }

        def dict_exclude_key(key, d: dict):
            d2 = d.copy()
            del d2[key]
            return d2

        spriteinfo_data = {
            "qbubbles:bubble": {
                "speedMultiplier": 5,
                "maxAmount": 100
            },
            "Sprites":
            [sprite.get_sname() for sprite in Registry.get_sprites()],
            "SpriteData":
            dict(((s.get_sname(),
                   dict_exclude_key("objects", dict(s.get_spritedata())))
                  for s in Registry.get_sprites()))
        }

        spriteData = dict()
        for sprite in Registry.get_sprites():
            spriteData[sprite.get_sname()] = sprite.get_spritedata().default

        Registry.saveData = {
            "GameData": game_data,
            "SpriteInfo": spriteinfo_data,
            "SpriteData": spriteData
        }

        bubble_data = {
            "bub-id": [],
            "bub-special": [],
            "bub-action": [],
            "bub-radius": [],
            "bub-speed": [],
            "bub-position": [],
            "bub-index": [],
            "key-active": False
        }

        game_data_file = NZTFile(f"{path}/game.nzt", "w")
        game_data_file.data = game_data
        game_data_file.save()
        game_data_file.close()

        sprite_info_file = NZTFile(f"{path}/spriteinfo.nzt", "w")
        sprite_info_file.data = spriteinfo_data
        sprite_info_file.save()
        sprite_info_file.close()

        os.makedirs(f"{path}/sprites/", exist_ok=True)

        for sprite in spriteData.keys():
            sprite_path = '/'.join(sprite.split(":")[:-1])
            if not os.path.exists(f"{path}/sprites/{sprite_path}"):
                os.makedirs(f"{path}/sprites/{sprite_path}", exist_ok=True)
            sprite_data_file = NZTFile(
                f"{path}/sprites/"
                f"{sprite.replace(':', '/')}.nzt", "w")
            sprite_data_file.data = spriteData[sprite]
            sprite_data_file.save()
            sprite_data_file.close()

        game_data_file = NZTFile(f"{path}/bubble.nzt", "w")
        game_data_file.data = bubble_data
        game_data_file.save()
        game_data_file.close()
Ejemplo n.º 20
0
    def on_mapinit(self, evt: MapInitializeEvent):
        w = Registry.gameData["WindowWidth"]
        h = Registry.gameData["WindowHeight"]

        self.seedRandom = Registry.saveData["Game"]["GameMap"]["seed"]
        self.init_defaults()

        canvas: Canvas = evt.canvas

        t1 = evt.t1
        t2 = evt.t2

        # noinspection PyUnusedLocal
        self.panelTop = CPanel(canvas,
                               0,
                               0,
                               width="extend",
                               height=69,
                               fill="darkcyan",
                               outline="darkcyan")
        # print(f"Panel Top created: {self.panelTop}")
        panelTopFont = Font("Helvetica", 12)

        # # Initializing the panels for the game.
        # self.panels["game/top"] = canvas.create_rectangle(
        #     -1, -1, Registry.gameData["WindowWidth"], 69, fill="darkcyan"
        # )

        # Create seperating lines.
        canvas.create_line(0,
                           70,
                           Registry.gameData["WindowWidth"],
                           70,
                           fill="lightblue")
        canvas.create_line(0,
                           69,
                           Registry.gameData["WindowWidth"],
                           69,
                           fill="lightblue")

        canvas.create_text(55,
                           30,
                           text=Registry.get_lname("info", "score"),
                           fill=self.tSpecialColor,
                           font=panelTopFont.get_tuple())
        canvas.itemconfig(t2, text="Score")
        canvas.create_text(110,
                           30,
                           text=Registry.get_lname("info", "level"),
                           fill=self.tSpecialColor,
                           font=panelTopFont.get_tuple())
        canvas.itemconfig(t2, text="Level")
        canvas.create_text(165,
                           30,
                           text=Registry.get_lname("info", "speed"),
                           fill=self.tSpecialColor,
                           font=panelTopFont.get_tuple())
        canvas.itemconfig(t2, text="Speed")
        canvas.create_text(220,
                           30,
                           text=Registry.get_lname("info", "lives"),
                           fill=self.tSpecialColor,
                           font=panelTopFont.get_tuple())
        canvas.itemconfig(t2, text="Lives")

        CEffectBarArea(canvas, gamemap=self)

        canvas.create_text(1120,
                           30,
                           text=Registry.gameData["language"]["info.tps"],
                           fill=self.tNormalColor,
                           font=panelTopFont.get_tuple())
        canvas.itemconfig(t2, text="Teleports")

        # Coin / Diamond icons
        canvas.create_image(1185, 30, image=Registry.get_icon("StoreDiamond"))
        canvas.itemconfig(t2, text="Diamonds")
        canvas.create_image(1185, 50, image=Registry.get_icon("StoreCoin"))
        canvas.itemconfig(t2, text="Coins")

        canvas.itemconfig(t1, text="Creating Stats Data")
        canvas.itemconfig(t2, text="")

        # Game information values.
        self.texts["score"] = canvas.create_text(55, 50, fill="cyan")
        canvas.itemconfig(t2, text="Score")
        self.texts["level"] = canvas.create_text(110, 50, fill="cyan")
        canvas.itemconfig(t2, text="Level")
        self.texts["speed"] = canvas.create_text(165, 50, fill="cyan")
        canvas.itemconfig(t2, text="Speed")
        self.texts["lives"] = canvas.create_text(220, 50, fill="cyan")
        canvas.itemconfig(t2, text="Lives")

        self.texts["shiptp"] = canvas.create_text(w - 20, 10, fill="cyan")
        canvas.itemconfig(t2, text="Teleports")
        self.texts["diamond"] = canvas.create_text(w - 20, 30, fill="cyan")
        canvas.itemconfig(t2, text="Diamonds")
        self.texts["coin"] = canvas.create_text(w - 20, 50, fill="cyan")
        canvas.itemconfig(t2, text="Coins")
        self.texts["level-view"] = canvas.create_text(
            Registry.gameData["MiddleX"],
            Registry.gameData["MiddleY"],
            fill='Orange',
            font=Font("Helvetica", 46).get_tuple())
        canvas.itemconfig(t2, text="Level View")

        self.background = CPanel(canvas,
                                 0,
                                 71,
                                 "extend",
                                 "expand",
                                 fill="#00a7a7",
                                 outline="#00a7a7")

        LoadCompleteEvent.bind(self.on_loadcomplete)

        bubbles = Registry.saveData["Sprites"]["qbubbles:bubble"][
            "objects"].copy()
        Registry.saveData["Sprites"]["qbubbles:bubble"]["objects"] = []
        for bubble in bubbles:
            bub = Registry.get_bubble(bubble["id"])
            pos = bubble["pos"]
            x = pos[0]
            y = pos[1]
            rad = bubble["radius"]
            spd = bubble["speed"]
            hlt = bubble["health"]
            self.create_bubble(x, y, bub, rad, spd, hlt)

        self.player = Player()
        if Registry.saveData["Sprites"]["qbubbles:player"]["objects"][0][
                "Position"]:
            self.player.create(*Registry.saveData["Sprites"]["qbubbles:player"]
                               ["objects"][0]["Position"])
        else:
            self.player.create(Registry.gameData["MiddleX"],
                               Registry.gameData["MiddleY"])
        self._gameobjects.append(self.player)
        self.canvas = canvas
Ejemplo n.º 21
0
 def get_coords(self):
     return Registry.get_scene("Game").canvas.coords(self.id)
Ejemplo n.º 22
0
 def delete(self) -> NoReturn:
     canvas: Canvas = Registry.get_scene("Game").canvas
     canvas.delete(self.id)
Ejemplo n.º 23
0
 def create(self, x, y):
     Registry.get_scene("Game").gameObjects.append(self)
Ejemplo n.º 24
0
 def damage(self, value: float):
     scene = Registry.get_scene("Game")
     if not SpriteDamageEvent(scene, self).cancel:
         self.health -= value / self.defenceValue
         if self.health <= 0:
             self.dead = True
Ejemplo n.º 25
0
 def get_uname_registry(self) -> List[str]:
     return Registry.get_id_bubble(self)
Ejemplo n.º 26
0
 def get_tuple(self):
     return self.family, Registry.get_window("default").tkScale(
         self.size), self.style
Ejemplo n.º 27
0
 def teleport(self, x, y):
     Registry.get_scene("Game").canvas.coords(self.id, x, y)
     self._objectData["Position"] = self.get_coords()
Ejemplo n.º 28
0
 def on_key_release(self, evt: KeyReleaseEvent):
     if evt.keySym.lower() == "return":
         Registry.get_mode("teleport").execute("done", x=self.get_coords()[0], y=self.get_coords()[1])
Ejemplo n.º 29
0
    def initialize(self):
        config_ = config.Reader("config/startup.nzt").get_decoded()

        with open("lang/" + config_["Game"]["language"] + ".yaml",
                  "r") as file:
            lang_ = yaml.safe_load(file.read())

        Registry.gameData["config"] = config_
        Registry.gameData["language"] = lang_

        # Config resolution / positions
        root = Registry.get_window("default")
        # root = root
        Registry.gameData["WindowWidth"] = root.tkScale(
            root.winfo_screenwidth())
        Registry.gameData["WindowHeight"] = root.tkScale(
            root.winfo_screenheight())
        if "--travis" in sys.argv:
            Registry.gameData["WindowWidth"] = 1920
            Registry.gameData["WindowHeight"] = 1080
        Registry.gameData["MiddleX"] = Registry.gameData["WindowWidth"] / 2
        Registry.gameData["MiddleY"] = Registry.gameData["WindowHeight"] / 2

        # # Register Xbox-Bindings
        # Registry.register_xboxbinding("A", game.close_present)
        # print("[Game]:", "Starting XboxController")
        # self.xbox = xbox.XboxController()
        # print("[Game]:", "Started XboxController")
        #
        # self.xControl = dict()
        #
        # a = [int(self.xbox.LeftJoystickX * 7), int(self.xbox.LeftJoystickY * 7)]
        # b = [int(self.xbox.RightJoystickX * 7), int(self.xbox.RightJoystickY * 7)]
        # self.xControl["LeftJoystick"] = a
        # self.xControl["RightJoystick"] = b
        # self.xControl["A"] = bool(self.xbox.A)
        # self.xControl["B"] = bool(self.xbox.B)
        # self.xControl["x"] = bool(self.xbox."x")
        # self.xControl[""y""] = bool(self.xbox."y")
        # self.xControl["Start"] = bool(self.xbox.Start)
        # self.xControl["Back"] = bool(self.xbox.Back)
        # self.xControl["LeftBumper"] = bool(self.xbox.LeftBumper)
        # self.xControl["RightBumper"] = bool(self.xbox.RightBumper)
        # self.xControl["LeftTrigger"] = int((self.xbox.LeftBumper + 1) / 2 * 7)
        # self.xControl["RightTrigger"] = int((self.xbox.RightBumper + 1) / 2 * 7)

        title_font = Font("Helvetica", 50, "bold")
        descr_font = Font("Helvetica", 15)

        Registry.register_scene("qbubbles:ErrorScene", ErrorScene())
        Registry.register_scene("qbubbles:CrashScene", CrashScene())

        sys.excepthook = custom_excepthook
        root.report_callback_exception = report_callback_exception
        Registry.get_window(
            "fake").report_callback_exception = report_callback_exception

        t0 = self.canvas.create_rectangle(0,
                                          0,
                                          Registry.gameData["WindowWidth"],
                                          Registry.gameData["WindowHeight"],
                                          fill="#3f3f3f",
                                          outline="#3f3f3f")
        t1 = self.canvas.create_text(Registry.gameData["MiddleX"],
                                     Registry.gameData["MiddleY"] - 2,
                                     text="Loading Mods",
                                     anchor="s",
                                     font=title_font.get_tuple(),
                                     fill="#afafaf")
        t2 = self.canvas.create_text(Registry.gameData["MiddleX"],
                                     Registry.gameData["MiddleY"] + 2,
                                     text="",
                                     anchor="n",
                                     font=descr_font.get_tuple(),
                                     fill="#afafaf")
        self.canvas.update()

        from qbubbles.globals import GAME_VERSION

        mods_dir = f"{Registry.gameData['launcherConfig']['gameDir']}addons/{GAME_VERSION}"

        if not os.path.exists(mods_dir):
            os.makedirs(mods_dir)

        # mods_path = os.path.abspath(f"{mods_dir}").replace("\\", "/")
        # sys.path.insert(0, mods_path)
        modules = {}
        mainPackageNames = []

        try:
            for file in os.listdir(mods_dir):
                # print(file, os.path.isfile(f"{mods_dir}/{file}"), f"{mods_dir}/{file}")
                # print(file)
                if os.path.isfile(f"{mods_dir}/{file}"):
                    if file.endswith(".pyz"):
                        a = zipimport.zipimporter(
                            f"{mods_dir}/{file}"
                        )  # f"{file}.main", globals(), locals(), [])
                        # print(dir(a))
                        try:
                            mainPackage = json.loads(
                                a.get_data(
                                    "qbubble-addoninfo.json"))["mainPackage"]
                        except OSError:
                            print(f"Found non-addon file: {file}")
                            continue
                        if mainPackage in mainPackageNames:
                            raise RuntimeError(
                                f"Illegal package name '{mainPackage}'. "
                                f"Package name is already in use")

                        if '.' in mainPackage:
                            printerr(f"Illegal package name: '{mainPackage}'. "
                                     f"Package name contains a dot")
                            continue
                        error = False
                        for char in mainPackage[1:]:
                            if char not in string.ascii_letters + string.digits:
                                printerr(
                                    f"Illegal package name: '{mainPackage}'. "
                                    f"Package name contains invalid character '{char}'"
                                )
                                error = True
                        if error:
                            continue

                        mainPackageNames.append(mainPackage)

                        module = a.load_module(mainPackage)
                        # _locals = {firstname: module}
                        # _globals = {}
                        # module = eval(f"{mainPackage}", _globals, _locals)
                        # module = module.qplaysoftware.exampleaddon
                        if a.find_module("qbubbles") is not None:
                            raise RuntimeError(
                                "Illegal module name: 'qbubbles'")
                        modules[module.ADDONID] = a
                        # print(a)
                    else:
                        if file.endswith(".disabled"):
                            continue
                        print(f"Found non-addon file: {file}")
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Addon loading failed",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

            # self.canvas.itemconfig(t0, fill="#ff0000")
            # self.canvas.itemconfig(t1, text="Addon loading failed!", fill="#ffa7a7")
            # self.canvas.itemconfig(t2, text=,
            #                        fill="#ffa7a7")
            # self.canvas.create_text(Registry.gameData["WindowWidth"]-16, Registry.gameData["WindowHeight"]-16,
            #                         text="Press any key or mouse button to continue", anchor="se",
            #                         font=("Helvetica", Registry.get_window("default").tkScale(16), 'bold'), fill="#ffa7a7")
            # Registry.get_window("default").focus_set()
            # self.canvas.bind_all("<Key>", lambda evt: os.kill(os.getpid(), 1))
            # self.canvas.bind_all("<Button>", lambda evt: os.kill(os.getpid(), 1))
            # Registry.get_window("default").protocol("WM_DELETE_WINDOW", lambda: None)
            # self.canvas.mainloop()
        # sys.path.remove(mods_path)

        addon_ids = Registry.get_all_addons()

        print(
            f"Attempting to load the following addons: {', '.join(list(addon_ids).copy())}"
        )

        # print(list(addon_ids))

        addons = []
        for addon_id in list(addon_ids):
            # print(repr(addon_id), type(addon_id))
            if Registry.mod_exists(addon_id):
                addon = Registry.get_module(addon_id)["addon"]
                addon: Type[AddonSkeleton]
                self.canvas.itemconfig(t2, text=addon.name)
                addon.zipimport = None
                if addon.modID in modules.keys():
                    addon.zipimport = modules[addon.modID]
                addons.append(addon())

        # print(addons)

        PreInitializeEvent(self, self.canvas, t1, t2)

        # # Pre-Initialize
        # self.mod_loader.pre_initialize(self)

        # =----- GAME MAPS -----= #
        self.canvas.itemconfig(t1, text="Loading Gamemaps")
        self.canvas.itemconfig(t2, text="Initialize gamemaps")
        self.canvas.update()

        try:
            gameMaps = init_gamemaps()
            i = 1
            for gamemap in gameMaps:
                self.canvas.itemconfig(
                    t2, text=f"Register gamemap {i}/{len(gameMaps)}")
                self.canvas.update()

                Registry.register_gamemap(gamemap.get_uname(), gamemap)
                i += 1
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Initialize Game Maps failed",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        # =----- SPRITES -----= #
        self.canvas.itemconfig(t1, text="Loading Sprites")
        self.canvas.itemconfig(t2, text="Initialize sprites")
        self.canvas.update()

        try:
            sprites = init_sprites()
            i = 1
            for sprite in sprites:
                self.canvas.itemconfig(
                    t2, text=f"Register sprite {i}/{len(gameMaps)}")
                self.canvas.update()

                Registry.register_sprite(sprite.get_sname(), sprite)
                i += 1
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Initialize Sprites failed"
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        self.canvas.itemconfig(t1, text="Loading Bubbles")
        self.canvas.itemconfig(t2, text="Initialize bubbles")
        self.canvas.update()

        try:
            bubbleObjects = bubblesInit.init_bubbles()
            for bubbleObject in bubbleObjects:
                self.canvas.itemconfig(
                    t2, text=f"Register bubble {bubbleObject.get_uname()}")
                Registry.register_bubble(bubbleObject.get_uname(),
                                         bubbleObject)
            BubbleSystem.init()
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Initialize Bubbles failed!",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        self.canvas.itemconfig(t2, text="Loading bubble models")
        self.canvas.update()

        try:
            modelLoader = ModelLoader()
            modelsBubble = modelLoader.load_models("bubble")

            for bubbleObject in bubbleObjects:
                if bubbleObject.get_uname().count(":") > 1:
                    printerr(
                        f"Illegal uname: {bubbleObject.get_uname()} has multiple ':' characters"
                    )
                    self.scenemanager.change_scene(
                        "qbubbles:ErrorScene", "Loading Bubble Models failed",
                        f"Illegal uname: {bubbleObject.get_uname()} has multiple ':' characters"
                    )
                uname = bubbleObject.get_uname().split(":")[-1]
                modid = bubbleObject.get_uname().split(":")[0]
                self.canvas.itemconfig(
                    t2, text=f"Generating bubble image: qbubbles:{uname}")
                self.canvas.update()
                if bubbleObject.get_uname().split(
                        ":")[-1] not in modelsBubble.keys():
                    printwrn(
                        f"Bubble object with uname '{bubbleObject.get_uname().split(':')[-1]}' have no bubble model"
                    )
                    continue

                images = {}
                images = modelLoader.generate_bubble_images(
                    bubbleObject.minRadius, bubbleObject.maxRadius,
                    modelsBubble[uname])
                # for radius in range(bubbleObject.minRadius, bubbleObject.maxRadius):
                #     colors = modelsBubble[uname]["Colors"]
                #     images[radius] = utils.createbubble_image((radius, radius), None, *colors)
                for radius, texture in images.items():
                    Registry.register_texture("qbubbles:bubble",
                                              bubbleObject.get_uname(),
                                              texture,
                                              radius=radius)
                Registry.register_bubble(bubbleObject.get_uname(),
                                         bubbleObject)
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Loading Bubble Models failed!",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        self.canvas.itemconfig(t1, text="Loading Sprites")
        self.canvas.itemconfig(t2, text="Load sprite models")
        self.canvas.update()

        try:
            modelsSprite = modelLoader.load_models("sprite")
            self.playerModel = modelsSprite["player"]

            for spriteName, spriteData in modelsSprite.items():
                if spriteData["Rotation"]:
                    degrees = spriteData['RotationDegrees']
                    self.canvas.itemconfig(
                        t2,
                        text=
                        f"Load images for {spriteName} 0 / {int(360 / degrees)}"
                    )
                    self.canvas.update()
                    image = Image.open(
                        f"assets/textures/sprites/{spriteData['Image']['Name']}.png"
                    )
                    for degree in range(0, 360, spriteData["RotationDegrees"]):
                        self.canvas.itemconfig(
                            t2,
                            text=
                            f"Load images for {spriteName} {int(degree / degrees)} / {int(360 / degrees)}"
                        )
                        self.canvas.update()
                        image_c: Image.Image = image.copy()
                        image_c = image_c.rotate(degree,
                                                 resample=Image.BICUBIC)
                        Registry.register_texture("sprite",
                                                  spriteName,
                                                  ImageTk.PhotoImage(image_c),
                                                  rotation=degree)
                    # print(Registry._registryTextures)
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Loading Sprite Models failed!",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        # # TODO: Remove this and use Registry.get_bubresource(...) as above (with .yml files for bubble-models)
        # self.canvas.itemconfig(t2, text="Creating Dicts")
        # self.canvas.update()
        #
        # # Adding the dictionaries for the bubbles. With different res.
        # Registry.gameData["BubbleImage"] = dict()
        # Registry.gameData["BubbleImage"]["Normal"] = dict()
        # Registry.gameData["BubbleImage"]["Triple"] = dict()
        # Registry.gameData["BubbleImage"]["Double"] = dict()
        # Registry.gameData["BubbleImage"]["Kill"] = dict()
        # Registry.gameData["BubbleImage"]["SpeedUp"] = dict()
        # Registry.gameData["BubbleImage"]["SpeedDown"] = dict()
        # Registry.gameData["BubbleImage"]["Ultimate"] = dict()
        # Registry.gameData["BubbleImage"]["Up"] = dict()
        # Registry.gameData["BubbleImage"]["Teleporter"] = dict()
        # Registry.gameData["BubbleImage"]["SlowMotion"] = dict()
        # Registry.gameData["BubbleImage"]["DoubleState"] = dict()
        # Registry.gameData["BubbleImage"]["Protect"] = dict()
        # Registry.gameData["BubbleImage"]["ShotSpdStat"] = dict()
        # Registry.gameData["BubbleImage"]["HyperMode"] = dict()
        # Registry.gameData["BubbleImage"]["TimeBreak"] = dict()
        # Registry.gameData["BubbleImage"]["Confusion"] = dict()
        # Registry.gameData["BubbleImage"]["Paralyse"] = dict()
        # Registry.gameData["BubbleImage"]["StoneBub"] = dict()
        # Registry.gameData["BubbleImage"]["NoTouch"] = dict()
        # Registry.gameData["BubbleImage"]["Key"] = dict()
        # Registry.gameData["BubbleImage"]["Diamond"] = dict()
        # Registry.gameData["BubbleImage"]["Present"] = dict()
        # Registry.gameData["BubbleImage"]["SpecialKey"] = dict()
        #
        # _min = 21
        # _max = 80
        #
        # # Adding the different resolutions to the bubbles.
        # for i in range(_min, _max + 1):
        #     Registry.gameData["BubbleImage"]["Normal"][i] = utils.createbubble_image((i, i), None, "white")
        #     Registry.gameData["BubbleImage"]["Double"][i] = utils.createbubble_image((i, i), None, "gold")
        #     Registry.gameData["BubbleImage"]["Triple"][i] = utils.createbubble_image((i, i), None, "blue", "#007fff", "#00ffff", "white")
        #     Registry.gameData["BubbleImage"]["SpeedDown"][i] = utils.createbubble_image((i, i), None, "#ffffff", "#a7a7a7", "#7f7f7f", "#373737")
        #     Registry.gameData["BubbleImage"]["SpeedUp"][i] = utils.createbubble_image((i, i), None, "#ffffff", "#7fff7f", "#00ff00", "#007f00")
        #     Registry.gameData["BubbleImage"]["Up"][i] = utils.createbubble_image((i, i), None, "#00ff00", "#00ff00", "#00000000", "#00ff00")
        #     Registry.gameData["BubbleImage"]["Ultimate"][i] = utils.createbubble_image((i, i), None, "gold", "gold", "orange", "gold")
        #     Registry.gameData["BubbleImage"]["Kill"][i] = utils.createbubble_image((i, i), None, "#7f0000", "#7f007f", "#7f0000",)
        #     Registry.gameData["BubbleImage"]["Teleporter"][i] = utils.createbubble_image((i, i), None, "#7f7f7f", "#7f7f7f", "#ff1020", "#373737")
        #     Registry.gameData["BubbleImage"]["SlowMotion"][i] = utils.createbubble_image((i, i), None, "#ffffffff", "#00000000", "#000000ff")
        #     Registry.gameData["BubbleImage"]["DoubleState"][i] = utils.createbubble_image((i, i), None, "gold", "#00000000", "gold", "gold")
        #     Registry.gameData["BubbleImage"]["Protect"][i] = utils.createbubble_image((i, i), None, "#00ff00", "#3fff3f", "#7fff7f", "#9fff9f")
        #     Registry.gameData["BubbleImage"]["ShotSpdStat"][i] = utils.createbubble_image((i, i), None, "#ff7f00", "#ff7f00", "gold")
        #     Registry.gameData["BubbleImage"]["HyperMode"][i] = utils.createbubble_image((i, i), None, "black", "black", "white", "black")
        #     Registry.gameData["BubbleImage"]["TimeBreak"][i] = utils.createbubble_image((i, i), None, "red", "orange", "yellow", "white")
        #     Registry.gameData["BubbleImage"]["Confusion"][i] = utils.createbubble_image((i, i), None, "black", "purple", "magenta", "white")
        #     Registry.gameData["BubbleImage"]["Paralyse"][i] = utils.createbubble_image((i, i), None, "#ffff00", "#ffff00", "#ffff7f", "#ffffff")
        #     Registry.gameData["BubbleImage"]["StoneBub"][i] = utils.createbubble_image((i, i), None, "black", "orange", "yellow")
        #     Registry.gameData["BubbleImage"]["NoTouch"][i] = utils.createbubble_image((i, i), None, "#7f7f7f", "#7f7f7f", "#7f7f7f", "#373737")
        #
        #     self.canvas.itemconfig(t1, text="Loading Bubbles Sizes")
        #     self.canvas.itemconfig(t2, text="Loading %s of %s" % (i - _min, _max - 1 - _min))
        #     self.canvas.update()
        #
        # # Adding the static-resolution-bubbles.
        # Registry.gameData["BubbleImage"]["Key"][60] = PhotoImage(file="assets/bubbles/Key.png")
        # Registry.gameData["BubbleImage"]["Diamond"][36] = PhotoImage(
        #     file="assets/bubbles/Diamond.png")
        # Registry.gameData["BubbleImage"]["Present"][40] = PhotoImage(
        #     file="assets/bubbles/Present.png")
        # # noinspection PyTypeChecker
        # Registry.gameData["BubbleImage"]["Coin"] = PhotoImage(file="assets/CoinBub.png")
        # Registry.gameData["BubbleImage"]["SpecialKey"][48] = PhotoImage(
        #     file="assets/bubbles/SpecialMode.png")

        # # TODO: Remove this.
        # for i in Registry.gameData["BubbleImage"].keys():
        #     print("%s: %s" % (i, repr(Registry.gameData["BubbleImage"][i])))

        # Adding ship image.
        Registry.register_image("ShipImage",
                                PhotoImage(file="assets/Ship.png"))

        self.canvas.itemconfig(t1, text="Loading Other Images")
        self.canvas.itemconfig(t2, text="Loading Icons")
        self.canvas.update()

        try:
            # Getting the store-icons.
            Registry.register_storeitem(
                "Key", PhotoImage(file="assets/Images/StoreItems/Key.png"))
            self.canvas.itemconfig(t2, text="Loading Icons - Store Item: Key")
            self.canvas.update()
            Registry.register_storeitem(
                "Teleport",
                PhotoImage(file="assets/Images/StoreItems/Teleport.png"))
            self.canvas.itemconfig(t2,
                                   text="Loading Icons - Store Item: Teleport")
            self.canvas.update()
            Registry.register_storeitem(
                "Shield",
                PhotoImage(file="assets/Images/StoreItems/Shield.png"))
            self.canvas.itemconfig(t2,
                                   text="Loading Icons - Store Item: Shield")
            self.canvas.update()
            Registry.register_storeitem(
                "Diamond",
                PhotoImage(file="assets/Images/StoreItems/DiamondBuy.png"))
            self.canvas.itemconfig(t2,
                                   text="Loading Icons - Store Item: Diamond")
            self.canvas.update()
            Registry.register_storeitem(
                "BuyACake",
                PhotoImage(file="assets/Images/StoreItems/BuyACake.png"))
            self.canvas.itemconfig(
                t2, text="Loading Icons - Store Item: Buy A Cake")
            self.canvas.update()
            Registry.register_storeitem(
                "Pop3Bubbles",
                PhotoImage(file="assets/Images/StoreItems/Pop_3_bubs.png"))
            self.canvas.itemconfig(
                t2, text="Loading Icons - Store Item: Pop 3 Bubbles")
            self.canvas.update()
            Registry.register_storeitem(
                "PlusLife",
                PhotoImage(file="assets/Images/StoreItems/PlusLife.png"))
            self.canvas.itemconfig(t2,
                                   text="Loading Icons - Store Item: PlusLife")
            self.canvas.update()
            Registry.register_storeitem(
                "Speedboost",
                PhotoImage(file="assets/Images/StoreItems/SpeedBoost.png"))
            self.canvas.itemconfig(
                t2, text="Loading Icons - Store Item: Speedboost")
            self.canvas.update()
            Registry.register_storeitem(
                "SpecialMode",
                PhotoImage(file="assets/Images/StoreItems/SpecialMode.png"))
            self.canvas.itemconfig(
                t2, text="Loading Icons - Store Item: Special Mode")
            self.canvas.update()
            Registry.register_storeitem(
                "DoubleScore",
                PhotoImage(file="assets/Images/StoreItems/DoubleScore.png"))
            self.canvas.itemconfig(t2, text="Loading Icons - Double Score")
            self.canvas.update()
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Loading Icons Stage 1 failed!",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        try:
            # Loading backgrounds
            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2, text="Loading Background - Line")
            self.canvas.update()
            Registry.register_background(
                "Line", PhotoImage(file="assets/LineIcon.png"))

            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2, text="Loading Background - Normal")
            self.canvas.update()
            Registry.register_background(
                "Normal",
                PhotoImage(file="assets/Images/Backgrounds/GameBG2.png"))

            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2,
                                   text="Loading Background - Special Mode")
            self.canvas.update()
            Registry.register_background(
                "Special",
                PhotoImage(
                    file="assets/Images/Backgrounds/GameBG Special2.png"))
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Loading Background failed",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        try:
            # Loading foregrounds
            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2,
                                   text="Loading Foreground - For Bubble Gift")
            self.canvas.update()
            Registry.register_foreground(
                "BubbleGift", PhotoImage(file="assets/EventBackground.png"))

            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2, text="Loading Foreground - Store FG")
            self.canvas.update()
            Registry.register_foreground("StoreFG",
                                         PhotoImage(file="assets/FG2.png"))
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Loading Foregounds failed",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        try:
            # Loading Icons
            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2, text="Loading Icons - Present Circle")
            self.canvas.update()
            Registry.register_icon("PresentCircle",
                                   PhotoImage(file="assets/Circle.png"))

            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2, text="Loading Icons - Present Chest")
            self.canvas.update()
            Registry.register_icon("PresentChest",
                                   PhotoImage(file="assets/Present.png"))

            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(
                t2, text="Loading Icons - Store: Diamond & Coin")
            self.canvas.update()
            Registry.register_icon("StoreDiamond",
                                   PhotoImage(file="assets/Diamond.png"))
            Registry.register_icon("StoreCoin",
                                   PhotoImage(file="assets/Coin.png"))

            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2, text="Loading Icons - Pause")
            self.canvas.update()
            Registry.register_icon("Pause",
                                   PhotoImage(file="assets/Pause.png"))

            self.canvas.itemconfig(t1, text="Loading Other Images")
            self.canvas.itemconfig(t2, text="Loading Icons - SlowMotion")
            self.canvas.update()
            Registry.register_icon(
                "EffectSlowmotion",
                PhotoImage(file="assets/SlowMotionIcon.png"))
        except Exception as e:
            import traceback
            printerr("".join(
                list(traceback.format_exception_only(e.__class__, e))))
            self.scenemanager.change_scene(
                "qbubbles:ErrorScene", "Loading Icons Stage 2 failed",
                "".join(list(traceback.format_exception_only(e.__class__, e))))

        # Loading fonts
        Registry.gameData["fonts"] = {}

        self.canvas.itemconfig(t1, text="Loading Fonts")
        self.canvas.itemconfig(t2, text="Title Fonts")
        self.canvas.update()
        Registry.gameData["fonts"]["titleButtonFont"] = Font("Helvetica", 15)

        self.canvas.itemconfig(t1, text="Loading Fonts")
        self.canvas.itemconfig(t2, text="Slots Menu Fonts")
        self.canvas.update()
        Registry.gameData["fonts"]["slotsButtonFont"] = Font("Helvetica", 12)

        InitializeEvent(self, self.canvas, t1, t2)

        for bubble in Registry.get_bubbles():
            if Registry.bubresource_exists(bubble.get_uname()):
                continue

        # Register Scenes
        self.canvas.itemconfig(t1, text="Loading Scenes")
        self.canvas.itemconfig(t2, text="Title Screen")
        Registry.register_scene("TitleScreen", TitleMenu())
        self.canvas.itemconfig(t2, text="Saves Menu")
        Registry.register_scene("SaveMenu", SavesMenu())
        self.canvas.itemconfig(t2, text="Store")
        Registry.register_scene("Store", Store())
        self.canvas.itemconfig(t2, text="Game")
        Registry.register_scene("Game", Game())

        # Registry.register_mode("teleport", TeleportMode())

        PostInitializeEvent(self, self.canvas, t1, t2)

        self.canvas.itemconfig(t1, text="DONE!")
        self.canvas.itemconfig(t2, text="")

        self.scenemanager.change_scene("TitleScreen")
        return
Ejemplo n.º 30
0
 def _c_create_image(x, y, image, anchor="nw"):
     return Registry.get_scene("Game").canvas.create_image(x, y, image=image, anchor=anchor)