def build_gui(self):
        super().build_gui()
        panel_rect = Rect(0, 0, 500, self.display.get_rect().height - (get_param('panel_padding') * 2))
        panel_rect.centerx = self.display.get_rect().centerx
        panel_rect.y = get_param('panel_padding')
        self.ui_elements['panel'] = UIPanel(panel_rect, 1, self.gui)
        # all other elements are relative
        scene_label_rect = Rect(0, 0, 400, get_param('element_height'))
        scene_label_rect.y = get_param('element_padding')
        scene_label_rect.centerx = panel_rect.w // 2  # midpoint of the panel
        self.ui_elements['scene_label'] = UILabel(scene_label_rect, "Select Existing Game Map", self.gui,
                                                  self.ui_elements['panel'])
        # buttons
        select_rect = Rect(0, 0, 400, get_param('element_height') * 3)
        select_rect.y = scene_label_rect.bottom + get_param('element_padding')
        select_rect.centerx = panel_rect.w // 2
        self.ui_elements['map_select'] = UISelectionList(select_rect, [f"Map {n}" for n in range(20)], self.gui,
                                                         container=self.ui_elements['panel'])

        preview_rect = Rect(0, 0, 256, get_param('element_height') * 8)
        preview_rect.y = select_rect.bottom + get_param('element_padding')
        preview_rect.centerx = panel_rect.w // 2
        self.ui_elements['preview'] = UILabel(preview_rect, "PREVIEW AREA", self.gui, self.ui_elements['panel'])

        button_rect = Rect(0, 0, 200, get_param('element_height'))
        button_rect.y = preview_rect.bottom + get_param('element_padding')
        button_rect.centerx = (panel_rect.w // 2) - 100
        self.ui_elements['btn_back'] = UIButton(button_rect, "Back", self.gui, self.ui_elements['panel'])
        button_rect.centerx = (panel_rect.w // 2) + 100
        self.ui_elements['btn_next'] = UIButton(button_rect, "Next", self.gui, self.ui_elements['panel'])
        self.ui_elements['btn_next'].disable()
示例#2
0
 def build_gui(self):
     super().build_gui()
     panel_rect = Rect(
         0, 0, 500,
         self.display.get_rect().height - (get_param('panel_padding') * 2))
     panel_rect.centerx = self.display.get_rect().centerx
     panel_rect.y = get_param('panel_padding')
     self.ui_elements['panel'] = UIPanel(panel_rect, 1, self.gui)
     # all other elements are relative
     scene_label_rect = Rect(0, 0, 400, get_param('element_height'))
     scene_label_rect.y = get_param('element_padding')
     scene_label_rect.centerx = panel_rect.w // 2  # midpoint of the panel
     self.ui_elements['scene_label'] = UILabel(scene_label_rect,
                                               "Map Editor Menu", self.gui,
                                               self.ui_elements['panel'])
     # buttons
     button_rect = Rect(0, 100, 400, get_param('element_height'))
     button_rect.centerx = panel_rect.w // 2
     self.ui_elements['btn_new'] = UIButton(button_rect, "New Map",
                                            self.gui,
                                            self.ui_elements['panel'])
     button_rect.y += get_param('element_height') + get_param(
         'element_padding')
     self.ui_elements['btn_load'] = UIButton(button_rect, "Load Map",
                                             self.gui,
                                             self.ui_elements['panel'])
     button_rect.y += get_param('element_height') + get_param(
         'element_padding')
     self.ui_elements['btn_back'] = UIButton(button_rect, "Back", self.gui,
                                             self.ui_elements['panel'])
示例#3
0
 def reload_display(self):
     # nuke the old display
     self.display = None
     # reload settings
     load_settings()
     # re-initialize display
     self.display = pg.display.set_mode(
         (get_param('display_width'), get_param('display_height')))
     # we need to rebuild all the scene GUI's
     for key, scene in self.scenes.items():
         scene.build_gui()
     # re-enter the current scene to reset the event system
     self.current_scene.on_enter()
示例#4
0
 def __init__(self):
     logging.debug("Configuration loaded")
     self.display = pg.display.set_mode(
         (get_param('display_width'), get_param('display_height')))
     logging.debug("Display initialized")
     self.scenes = {}  # dict of loaded scenes
     self.active_scene = ''
     self.change_scene_to = None  # if this is set, we need to change the scene
     self.running = False
     self.time_delta = 0.016
     self.clock = pg.time.Clock()
     logging.debug("GameController initialized")
     # initialize event handling
     bind_listener(self.quit_game, pg.QUIT)
     bind_listener(self.change_game_scene, EVENT_CHANGE_GAME_SCENE)
示例#5
0
 def build_gui(self):
     super().build_gui()
     panel_rect = Rect(
         0, 0, 500,
         self.display.get_rect().height - (get_param('panel_padding') * 2))
     panel_rect.centerx = self.display.get_rect().centerx
     panel_rect.y = get_param('panel_padding')
     self.ui_elements['panel'] = UIPanel(panel_rect, 1, self.gui)
     # all other elements are relative
     scene_label_rect = Rect(0, 0, 400, get_param('element_height'))
     scene_label_rect.y = get_param('element_padding')
     scene_label_rect.centerx = panel_rect.w // 2  # midpoint of the panel
     self.ui_elements['scene_label'] = UILabel(scene_label_rect,
                                               "Load Saved Game", self.gui,
                                               self.ui_elements['panel'])
     # buttons
     select_rect = Rect(0, 0, 400, get_param('element_height') * 3)
     select_rect.y = scene_label_rect.bottom + get_param('element_padding')
     select_rect.centerx = panel_rect.w // 2
     self.ui_elements['game_select'] = UISelectionList(
         select_rect, [f"Game {n}" for n in range(5)],
         self.gui,
         container=self.ui_elements['panel'])
     button_rect = Rect(0, 0, 200, get_param('element_height'))
     button_rect.y = select_rect.bottom + get_param('element_padding')
     button_rect.centerx = (panel_rect.w // 2) - 100
     self.ui_elements['btn_load'] = UIButton(button_rect, "Load Save",
                                             self.gui,
                                             self.ui_elements['panel'])
     self.ui_elements['btn_load'].disable()
     button_rect.centerx = (panel_rect.w // 2 + 100)
     self.ui_elements['btn_delete'] = UIButton(button_rect, "Delete Save",
                                               self.gui,
                                               self.ui_elements['panel'])
     self.ui_elements['btn_delete'].disable()
     button_rect.w = 400
     button_rect.centerx = panel_rect.w // 2
     button_rect.y += get_param('element_height') + get_param(
         'element_padding')
     self.ui_elements['btn_back'] = UIButton(button_rect, "Back", self.gui,
                                             self.ui_elements['panel'])
示例#6
0
 def build_gui(self):
     super().build_gui()
     panel_rect = Rect(
         0, 0, 500,
         self.display.get_rect().height - (get_param('panel_padding') * 2))
     panel_rect.centerx = self.display.get_rect().centerx
     panel_rect.y = get_param('panel_padding')
     self.ui_elements['panel'] = UIPanel(panel_rect, 1, self.gui)
     # all other elements are relative
     scene_label_rect = Rect(0, 0, 400, get_param('element_height'))
     scene_label_rect.y = get_param('element_padding')
     scene_label_rect.centerx = panel_rect.w // 2  # midpoint of the panel
     self.ui_elements['scene_label'] = UILabel(scene_label_rect,
                                               "Main Menu", self.gui,
                                               self.ui_elements['panel'])
     # buttons
     button_rect = Rect(0, 0, 400, get_param('element_height'))
     button_rect.y = scene_label_rect.bottom + get_param('element_padding')
     button_rect.centerx = panel_rect.w // 2
     self.ui_elements['btn_new'] = UIButton(button_rect, "New Game",
                                            self.gui,
                                            self.ui_elements['panel'])
     button_rect.y += get_param('element_height') + get_param(
         'element_padding')
     self.ui_elements['btn_load'] = UIButton(button_rect, "Load Game",
                                             self.gui,
                                             self.ui_elements['panel'])
     button_rect.y += get_param('element_height') + get_param(
         'element_padding')
     self.ui_elements['btn_editor'] = UIButton(button_rect, "Map Editor",
                                               self.gui,
                                               self.ui_elements['panel'])
     button_rect.y += get_param('element_height') + get_param(
         'element_padding')
     self.ui_elements['btn_settings'] = UIButton(button_rect, "Settings",
                                                 self.gui,
                                                 self.ui_elements['panel'])
     button_rect.y += get_param('element_height') + get_param(
         'element_padding')
     self.ui_elements['btn_quit'] = UIButton(button_rect, "Quit Game",
                                             self.gui,
                                             self.ui_elements['panel'])
示例#7
0
    def build_gui(self):
        super().build_gui()
        panel_rect = Rect(
            0, 0, 500,
            self.display.get_rect().height - (get_param('panel_padding') * 2))
        panel_rect.centerx = self.display.get_rect().centerx
        panel_rect.y = get_param('panel_padding')
        self.ui_elements['panel'] = UIPanel(panel_rect, 1, self.gui)
        # all other elements are relative
        scene_label_rect = Rect(0, 0, 400, get_param('element_height'))
        scene_label_rect.y = get_param('element_padding')
        scene_label_rect.centerx = panel_rect.w // 2  # midpoint of the panel
        self.ui_elements['scene_label'] = UILabel(scene_label_rect,
                                                  "Start New Game", self.gui,
                                                  self.ui_elements['panel'])

        l_side_rect = Rect(0, 0, 150, get_param('element_height'))
        l_side_rect.centerx = 125
        l_side_rect.y = scene_label_rect.bottom + get_param('element_padding')
        self.ui_elements['l_dd_label'] = UILabel(l_side_rect, "Map Type",
                                                 self.gui,
                                                 self.ui_elements['panel'])
        dd_rect = Rect(0, 0, 250, get_param('element_height'))
        dd_rect.y = l_side_rect.y
        dd_rect.centerx = 325
        self.ui_elements['l_dd_game_map'] = UIDropDownMenu(
            ['Existing', 'Random'], 'Existing', dd_rect, self.gui,
            self.ui_elements['panel'])
        btn_rect = Rect(0, 0, 200, get_param('element_height'))
        btn_rect.centerx = (panel_rect.w) // 2 - 100
        btn_rect.y = dd_rect.bottom + get_param('element_padding')
        self.ui_elements['btn_back'] = UIButton(btn_rect, "Back", self.gui,
                                                self.ui_elements['panel'])
        btn_rect = Rect(0, 0, 200, get_param('element_height'))
        btn_rect.centerx = (panel_rect.w // 2) + 100
        btn_rect.y = dd_rect.bottom + get_param('element_padding')
        self.ui_elements['btn_next'] = UIButton(btn_rect, "Next", self.gui,
                                                self.ui_elements['panel'])
    def build_gui(self):
        super().build_gui()
        panel_rect = Rect(
            0, 0, 500,
            self.display.get_rect().height - (get_param('panel_padding') * 2))
        panel_rect.centerx = self.display.get_rect().centerx
        panel_rect.y = get_param('panel_padding')
        self.ui_elements['panel'] = UIPanel(panel_rect, 1, self.gui)
        # all other elements are relative
        scene_label_rect = Rect(0, 0, 400, get_param('element_height'))
        scene_label_rect.y = get_param('element_padding')
        scene_label_rect.centerx = panel_rect.w // 2  # midpoint of the panel
        self.ui_elements['scene_label'] = UILabel(scene_label_rect,
                                                  "Generate Random Map",
                                                  self.gui,
                                                  self.ui_elements['panel'])
        # map size
        label_rect = Rect(0, 0, 150, get_param('element_height'))
        label_rect.y += scene_label_rect.bottom + get_param('element_padding')
        dd_rect = Rect(0, 0, 250, get_param('element_height'))
        dd_rect.y = label_rect.y
        label_rect.centerx = 125
        dd_rect.centerx = 325
        self.ui_elements['d_size_label'] = UILabel(label_rect, "Map Size",
                                                   self.gui,
                                                   self.ui_elements['panel'])
        self.ui_elements['dd_map_size'] = UIDropDownMenu(
            ['64', '128', '256'], '64', dd_rect, self.gui,
            self.ui_elements['panel'])
        # Seed
        label_rect.y += get_param('element_height') + get_param(
            'element_padding')
        ip_rect = Rect(0, 0, 180, get_param('element_height'))
        ip_rect.centerx = (panel_rect.w // 2) + 30
        ip_rect.y = label_rect.y
        s_btn_rect = Rect(0, 0, 60, get_param('element_height'))
        s_btn_rect.x = ip_rect.right + get_param('element_padding')
        s_btn_rect.y = ip_rect.y
        self.ui_elements['seed_label'] = UILabel(label_rect, 'Map Seed',
                                                 self.gui,
                                                 self.ui_elements['panel'])
        self.ui_elements['input_seed'] = UITextEntryLine(
            ip_rect, self.gui, self.ui_elements['panel'])
        self.ui_elements['btn_rnd_seed'] = UIButton(s_btn_rect, 'Random',
                                                    self.gui,
                                                    self.ui_elements['panel'])
        # I want to add two sliders, 1 for mountains and 1 for water, these would be used to control the upper
        # and lower limits of the height mapping.
        h_sl_ops = (0, 100)
        h_sl_sel = 50
        label_rect.y += get_param('element_height') + get_param(
            'element_padding')
        h_sl_rect = Rect(0, 0, 200, get_param('element_height'))
        h_sl_rect.centerx = (panel_rect.w //
                             2) + get_param('element_padding') + 30
        h_sl_rect.y = label_rect.y
        self.ui_elements['hsl_grass'] = UILabel(label_rect, 'Grass', self.gui,
                                                self.ui_elements['panel'])
        self.ui_elements['hs_grass'] = UIHorizontalSlider(
            h_sl_rect, h_sl_sel, h_sl_ops, self.gui, self.ui_elements['panel'])

        label_rect.y += get_param('element_height') + get_param(
            'element_padding')
        h_sl_rect.y = label_rect.y
        self.ui_elements['hsl_water'] = UILabel(label_rect, 'Water', self.gui,
                                                self.ui_elements['panel'])
        self.ui_elements['hs_water'] = UIHorizontalSlider(
            h_sl_rect, h_sl_sel, h_sl_ops, self.gui, self.ui_elements['panel'])

        label_rect.y += get_param('element_height') + get_param(
            'element_padding')
        h_sl_rect.y = label_rect.y
        self.ui_elements['hsl_mountain'] = UILabel(label_rect, 'Mountain',
                                                   self.gui,
                                                   self.ui_elements['panel'])
        self.ui_elements['hs_mountain'] = UIHorizontalSlider(
            h_sl_rect, h_sl_sel, h_sl_ops, self.gui, self.ui_elements['panel'])

        # buttons
        button_rect = Rect(0, 0, 200, get_param('element_height'))
        button_rect.centerx = panel_rect.w // 2
        button_rect.y = label_rect.bottom + get_param('element_padding')
        self.ui_elements['btn_preview'] = UIButton(button_rect,
                                                   "Generate Preview",
                                                   self.gui,
                                                   self.ui_elements['panel'])
        button_rect.w = 200
        button_rect.y += get_param('element_height') + get_param(
            'element_padding')
        button_rect.centerx = (panel_rect.w // 2) - 100
        self.ui_elements['btn_back'] = UIButton(button_rect, "Back", self.gui,
                                                self.ui_elements['panel'])
        # the apply button always starts off disabled
        button_rect.centerx = (panel_rect.w // 2) + 100
        self.ui_elements['btn_next'] = UIButton(button_rect, "Next", self.gui,
                                                self.ui_elements['panel'])
        pv_rect = Rect(0, 0, 300, 300)
        pv_rect.centerx = panel_rect.w // 2
        pv_rect.y = button_rect.bottom + get_param('element_padding')
        self.ui_elements['pv_image'] = UIImage(pv_rect, self.pv_img, self.gui,
                                               self.ui_elements['panel'])
示例#9
0
 def build_gui(self):
     super().build_gui()
     panel_rect = Rect(
         0, 0, 500,
         self.display.get_rect().height - (get_param('panel_padding') * 2))
     panel_rect.centerx = self.display.get_rect().centerx
     panel_rect.y = get_param('panel_padding')
     self.ui_elements['panel'] = UIPanel(panel_rect, 1, self.gui)
     # all other elements are relative
     scene_label_rect = Rect(0, 0, 400, get_param('element_height'))
     scene_label_rect.y = get_param('element_padding')
     scene_label_rect.centerx = panel_rect.w // 2  # midpoint of the panel
     self.ui_elements['scene_label'] = UILabel(scene_label_rect, "Settings",
                                               self.gui,
                                               self.ui_elements['panel'])
     # screen size
     label_rect = Rect(0, 0, 150, get_param('element_height'))
     label_rect.y += scene_label_rect.bottom + get_param('element_padding')
     dd_rect = Rect(0, 0, 250, get_param('element_height'))
     dd_rect.y = label_rect.y
     label_rect.centerx = 125
     dd_rect.centerx = 325
     self.ui_elements['d_size_label'] = UILabel(label_rect, "Display Size",
                                                self.gui,
                                                self.ui_elements['panel'])
     self.ui_elements['dd_d_size'] = UIDropDownMenu(
         get_param('display_sizes'), get_param('current_display_size'),
         dd_rect, self.gui, self.ui_elements['panel'])
     # full screen
     label_rect.y += get_param('element_height') + get_param(
         'element_padding')
     dd_rect.y = label_rect.y
     self.ui_elements['fs_label'] = UILabel(label_rect, "Full Screen",
                                            self.gui,
                                            self.ui_elements['panel'])
     self.ui_elements['dd_fs'] = UIDropDownMenu(
         ["On", "Off"], get_param('display_full_screen_value'), dd_rect,
         self.gui, self.ui_elements['panel'])
     # buttons
     button_rect = Rect(0, 0, 200, get_param('element_height'))
     button_rect.y = label_rect.bottom + get_param('element_padding')
     button_rect.centerx = (panel_rect.w // 2) - 100
     self.ui_elements['btn_back'] = UIButton(button_rect, "Back", self.gui,
                                             self.ui_elements['panel'])
     # the apply button always starts off disabled
     button_rect.centerx = (panel_rect.w // 2) + 100
     self.ui_elements['btn_apply'] = UIButton(button_rect, "Apply",
                                              self.gui,
                                              self.ui_elements['panel'])
     self.ui_elements['btn_apply'].disable()
     # re-assign values for our check parameters, this is to control the apply buttons state
     self._check_screen_size = get_param('current_display_size')
     self._check_full_screen = get_param('display_full_screen_value')