def __init__(self, session, building, ship=None, build_related=None): super(BuildingTool, self).__init__(session) assert not (ship and build_related) self.renderer = self.session.view.renderer['InstanceRenderer'] self.ship = ship self._class = building self.__init_selectable_component() self.buildings = [] # list of PossibleBuild objs self.buildings_action_set_ids = [] # list action set ids of list above self.buildings_fife_instances = {} # fife instances of possible builds self.buildings_missing_resources = {} # missing resources for possible builds self.rotation = 45 + random.randint(0, 3)*90 self.start_point, self.end_point = None, None self.last_change_listener = None self._transparencified_instances = set() # fife instances modified for transparency self._buildable_tiles = set() # tiles marked as buildable self._related_buildings = set() # buildings highlighted as related self._highlighted_buildings = set() # related buildings highlighted when preview is near it self._build_logic = None self._related_buildings_selected_tiles = frozenset() # highlights w.r.t. related buildings if self.ship is not None: self._build_logic = ShipBuildingToolLogic(ship) elif build_related is not None: self._build_logic = BuildRelatedBuildingToolLogic(self, weakref.ref(build_related) ) else: self._build_logic = SettlementBuildingToolLogic(self) self.load_gui() self.__class__.gui.show() self.session.ingame_gui.minimap_to_front() self.session.gui.on_escape = self.on_escape self.highlight_buildable() WorldObjectDeleted.subscribe(self._on_worldobject_deleted)
def __init__(self, session): self.session = session # {instance: [list of icons]} self.icons = {} # Renderer used to render the icons self.renderer = self.session.view.renderer['GenericRenderer'] AddStatusIcon.subscribe(self.on_add_icon_message) RemoveStatusIcon.subscribe(self.on_remove_icon_message) WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
def __init__(self, session): super(TearingTool, self).__init__(session) self.coords = None self.selected = WeakList() self.oldedges = None self.tear_tool_active = True self.session.ingame_gui.hide_menu() self.session.selected_instances.clear() horizons.globals.fife.set_cursor_image("tearing") self._hovering_over = WeakList() WorldObjectDeleted.subscribe(self._on_object_deleted)
def end(self): self.tooltip_instance = None self.tooltip_icon.hide_tooltip() self.tooltip_icon = None self.renderer = None self.icons = None AddStatusIcon.unsubscribe(self.on_add_icon_message) HoverInstancesChanged.unsubscribe(self.on_hover_instances_changed) RemoveStatusIcon.unsubscribe(self.on_remove_icon_message) WorldObjectDeleted.unsubscribe(self.on_worldobject_deleted_message)
def __init__(self, session): super(TearingTool, self).__init__(session) self._transparent_instances = set() # fife instances modified for transparency self.coords = None self.selected = WeakList() self.oldedges = None self.tear_tool_active = True self.session.ingame_gui.hide_menu() self.session.selected_instances.clear() horizons.globals.fife.set_cursor_image("tearing") self._hovering_over = WeakList() WorldObjectDeleted.subscribe(self._on_object_deleted)
def __init__(self, session): self.session = session # {instance: [list of icons]} self.icons = {} # Renderer used to render the icons self.renderer = self.session.view.renderer['GenericRenderer'] self.tooltip_instance = None # no weakref: # we need to remove the tooltip always anyway, and along with it the entry here self.tooltip_icon = Icon(position=(1,1)) # 0, 0 is currently not supported by tooltips AddStatusIcon.subscribe(self.on_add_icon_message) HoverInstancesChanged.subscribe(self.on_hover_instances_changed) RemoveStatusIcon.subscribe(self.on_remove_icon_message) WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
def remove(self): WorldObjectDeleted.unsubscribe(self._on_worldobject_deleted) self._remove_listeners() self._remove_building_instances() self._remove_coloring() self._build_logic.remove(self.session) self._buildable_tiles = None self._transparencified_instances = None self._related_buildings_selected_tiles = None self._related_buildings = None self._highlighted_buildings = None self._build_logic = None self.buildings = None if self.gui is not None: self.session.view.remove_change_listener(self.draw_gui) self.gui.hide() ExtScheduler().rem_all_classinst_calls(self) super(BuildingTool, self).remove()
def __init__(self, renderer, layer): """ @param renderer: Renderer used to render the icons @param layer: map layer, needed to place icon """ self.layer = layer self.renderer = renderer # {instance: [list of icons]} self.icons = {} self.tooltip_instance = None # no weakref: # we need to remove the tooltip always anyway, and along with it the entry here self.tooltip_icon = Icon(position=(1, 1)) # 0, 0 is currently not supported by tooltips AddStatusIcon.subscribe(self.on_add_icon_message) HoverInstancesChanged.subscribe(self.on_hover_instances_changed) RemoveStatusIcon.subscribe(self.on_remove_icon_message) WorldObjectDeleted.subscribe(self.on_worldobject_deleted_message)
def __init__(self, session, building, ship=None, build_related=None): super(BuildingTool, self).__init__(session) assert not (ship and build_related) self.renderer = self.session.view.renderer['InstanceRenderer'] self.ship = ship self._class = building self.__init_selectable_component() self.buildings = [] # list of PossibleBuild objs self.buildings_action_set_ids = [] # list action set ids of list above self.buildings_fife_instances = {} # fife instances of possible builds self.buildings_missing_resources = { } # missing resources for possible builds self.rotation = 45 + random.randint(0, 3) * 90 self.start_point, self.end_point = None, None self.last_change_listener = None self._transparencified_instances = set( ) # fife instances modified for transparency self._buildable_tiles = set() # tiles marked as buildable self._related_buildings = set() # buildings highlighted as related self._highlighted_buildings = set( ) # related buildings highlighted when preview is near it self._build_logic = None self._related_buildings_selected_tiles = frozenset( ) # highlights w.r.t. related buildings if self.ship is not None: self._build_logic = ShipBuildingToolLogic(ship) elif build_related is not None: self._build_logic = BuildRelatedBuildingToolLogic( self, weakref.ref(build_related)) else: self._build_logic = SettlementBuildingToolLogic(self) self.load_gui() self.__class__.gui.show() self.session.ingame_gui.minimap_to_front() self.session.gui.on_escape = self.on_escape self.highlight_buildable() WorldObjectDeleted.subscribe(self._on_worldobject_deleted) SettlementInventoryUpdated.subscribe(self.update_preview) PlayerInventoryUpdated.subscribe(self.update_preview)
def remove(self): self.session.ingame_gui.resource_overview.close_construction_mode() WorldObjectDeleted.unsubscribe(self._on_worldobject_deleted) self._remove_listeners() self._remove_building_instances() self._remove_coloring() self._build_logic.remove(self.session) self._buildable_tiles = None self._transparencified_instances = None self._related_buildings_selected_tiles = None self._related_buildings = None self._highlighted_buildings = None self._build_logic = None self.buildings = None if self.__class__.gui is not None: self.__class__.gui.hide() ExtScheduler().rem_all_classinst_calls(self) SettlementInventoryUpdated.discard(self.update_preview) PlayerInventoryUpdated.discard(self.update_preview) super(BuildingTool, self).remove()
def remove(self): WorldObjectDeleted.broadcast(self, self, self.worldid) super(WorldObject, self).remove() self.log.debug("Removing WorldObject %s %s", self.worldid, self) del WorldObject.__objects[self.worldid]
def remove(self): self._mark() self.tear_tool_active = False horizons.globals.fife.set_cursor_image("default") WorldObjectDeleted.unsubscribe(self._on_object_deleted) super(TearingTool, self).remove()