Пример #1
0
    def show_change_name_dialog(self, instance):
        """Shows a dialog where the user can change the name of a NamedObject.
		The game gets paused while the dialog is executed."""
        self.session.speed_pause()
        events = {"okButton": callback(self.change_name, instance), "cancelButton": self._hide_change_name_dialog}
        self.main_gui.on_escape = self._hide_change_name_dialog
        changename = self.widgets["change_name"]
        newname = changename.findChild(name="new_name")
        changename.mapEvents(events)
        newname.capture(callback(self.change_name, instance))
        changename.show()
        newname.requestFocus()
Пример #2
0
 def update_settlement(self):
     """Assigns values to labels of cityinfo widget"""
     cityinfo = self.widgets["city_info"]
     cityinfo.mapEvents({"city_name": callback(self.show_change_name_dialog, self.settlement)})
     foundlabel = cityinfo.child_finder("city_name")
     foundlabel._setText(unicode(self.settlement.name))
     foundlabel.resizeToContent()
     foundlabel = cityinfo.child_finder("city_inhabitants")
     foundlabel.text = unicode(" " + str(self.settlement.inhabitants))
     foundlabel.resizeToContent()
     cityinfo.resizeToContent()
Пример #3
0
    def __init__(self, session, gui):
        super(IngameGui, self).__init__()
        self.session = session
        self.main_gui = gui
        self.widgets = {}
        self.tabwidgets = {}
        self.settlement = None
        self.resource_source = None
        self.resources_needed, self.resources_usable = {}, {}
        self._old_menu = None

        self.widgets = LazyWidgetsDict(self.styles, center_widgets=False)
        screenwidth = horizons.main.fife.engine_settings.getScreenWidth()

        cityinfo = self.widgets["city_info"]
        cityinfo.child_finder = PychanChildFinder(cityinfo)
        cityinfo.position = (screenwidth / 2 - cityinfo.size[0] / 2 - 10, 5)

        self.logbook = LogBook(session)

        # self.widgets['minimap'] is the guichan gui around the actual minimap,
        # which is saved in self.minimap
        minimap = self.widgets["minimap"]
        minimap.position = (screenwidth - minimap.size[0] - 20, 4)
        minimap.show()
        minimap.mapEvents(
            {
                "zoomIn": self.session.view.zoom_in,
                "zoomOut": self.session.view.zoom_out,
                "rotateRight": self.session.view.rotate_right,
                "rotateLeft": self.session.view.rotate_left,
                "speedUp": self.session.speed_up,
                "speedDown": self.session.speed_down,
            }
        )

        minimap_rect = Rect.init_from_topleft_and_size(minimap.position[0] + 77, 55, 120, 120)
        self.minimap = Minimap(minimap_rect, self.session, self.session.view.renderer["GenericRenderer"])
        minimap_overlay = minimap.findChild(name="minimap_overlay_image")
        self.minimap.use_overlay_icon(minimap_overlay)

        menupanel = self.widgets["menu_panel"]
        menupanel.position = (screenwidth - menupanel.size[0] + 15, 149)
        menupanel.show()
        menupanel.mapEvents(
            {
                "destroy_tool": self.session.destroy_tool,
                "build": self.show_build_menu,
                "helpLink": self.main_gui.on_help,
                "gameMenuButton": self.main_gui.show_pause,
                "logbook": self.logbook.toggle_visibility,
            }
        )

        self.widgets["tooltip"].hide()

        for w in ("status", "status_extra", "status_gold", "status_extra_gold"):
            self.widgets[w].child_finder = PychanChildFinder(self.widgets[w])
        self.widgets["status_gold"].show()

        self.message_widget = MessageWidget(self.session, cityinfo.position[0] + cityinfo.size[0], 5)

        self.resbar = ResBar(self.session, gui, self.widgets, self.resource_source)

        # map button names to build functions calls with the building id
        building_list = horizons.main.db.get_building_id_buttonname_settlerlvl()
        self.callbacks_build = {}
        for id, button_name, settler_level in building_list:
            if not settler_level in self.callbacks_build:
                self.callbacks_build[settler_level] = {}
            self.callbacks_build[settler_level][button_name] = callback(self._build, id)