Example #1
0
 def set_configurations(cls):
     cfgs = dict()
     if not os.path.exists(ConfigManager.CONFIG_PATH):
         ConfigManager.LOGGER.error("Configuration file not found...")
         ConfigManager.LOGGER.info(
             "Generating default configuration file...")
         ConfigManager.generate_default_configuration()
     with open(ConfigManager.CONFIG_PATH, 'r') as json_cfg:
         cfg = json.load(json_cfg)
         # LOADING CONFIGURATIONS
         # TRY to find custom settings
         try:
             ConfigManager.LOGGER.info(
                 "Loading custom configuration settings...")
             cfgs["screen"] = [
                 cfg["CUSTOM"]["SIZE"]["WIDTH"],
                 cfg["CUSTOM"]["SIZE"]["HEIGHT"]
             ]
             cfgs["lang"] = cfg["CUSTOM"]["LANGUAGE"]
             cfgs["theme"] = cfg["CUSTOM"]["THEME"]
         except KeyError as ex:
             ConfigManager.LOGGER.error("Custom configurations not found")
             ConfigManager.LOGGER.info("Loading default configurations...")
             cfgs["screen"] = [
                 cfg["DEFAULT"]["SIZE"]["WIDTH"],
                 cfg["DEFAULT"]["SIZE"]["HEIGHT"]
             ]
             cfgs["lang"] = cfg["DEFAULT"]["LANGUAGE"]
             cfgs["theme"] = cfg["DEFAULT"]["THEME"]
     DisplaySettings.set_size_by_key(
         DisplaySettings.get_size_name(cfgs.get("screen")))
     StringUtils.set_language(cfgs.get("lang"))  # LANGUAGE
     Themes.set_theme(cfgs.get("theme"))  # THEME
Example #2
0
 def check_form_events(self, event):
     super().check_form_events(event)
     if event.type == MOUSEBUTTONUP:
         if event.button != 4 and event.button != 5:
             pos = pg.mouse.get_pos()
             self.check_menu_pressed(pos)
             if self.btn_drop_down.collidepoint(pos) == 1:
                 if self.__is_drop_down_pressed:
                     self.__is_drop_down_pressed = False
                 else:
                     self.__is_drop_down_pressed = True
                     self.__size_counter = 0
             elif self.btn_apply.get_rect().collidepoint(pos) == 1:
                 for i in range(0, len(DisplaySettings.SCREEN_SIZES), 1):
                     if self.__size == DisplaySettings.get_size_name(
                             DisplaySettings.get_size_by_id(i)):
                         DisplaySettings.set_size_by_key(
                             DisplaySettings.get_size_name(
                                 DisplaySettings.get_size_by_id(i)))
                         self.display = pg.display.set_mode(
                             DisplaySettings.DEFAULT_SCREEN_SIZE)
             else:
                 self.__is_drop_down_pressed = False
     elif event.type == MOUSEBUTTONDOWN:
         if self.__is_drop_down_pressed:
             if event.button == 4:
                 self.__size_counter -= 1
             elif event.button == 5 and len(
                     DisplaySettings.SCREEN_SIZES) > 3:
                 self.__size_counter += 1
             if self.__size_counter < 0:
                 self.__size_counter = 0
             elif (len(DisplaySettings.SCREEN_SIZES) >
                   3) and (self.__size_counter >
                           len(DisplaySettings.SCREEN_SIZES) - 3):
                 self.__size_counter = (len(DisplaySettings.SCREEN_SIZES) -
                                        3)