def interdict_yn(root, title="NOT_SET", text="NOT_SET", button_y="NOT_SET", button_n="NOT_SET", callback_y=lambda s: 0, callback_n=lambda s: 0, wrap=48, key="sgcui_modalyn"): debug("Calling UI_STATES::INTERDICT_YN...") debug("title=" + title) debug("text=" + text) debug("button_y=" + button_y) debug("button_n=" + button_n) debug("wrap=" + str(wrap)) debug("style=" + key) text_ = textwrap.wrap(text, wrap) text = "" for l in text_: text += "\n" + l.replace("%n", "\n") state = root.state_manager.start_interdicting("generic_ui", root.gamedb(key)) state.widgets["replace_title"].config(text=_t(title)) state.widgets["replace_body"].config(text=_t(text)) state.widgets["replace_button_yes"].config(label=_t(button_y)) state.widgets["replace_button_no"].config(label=_t(button_n)) state.callback_y = callback_y state.callback_n = callback_n return state
def create_widget(self, config, add_dict=1, add_screen=1, _is_internal=0): config_ = self.default_config.copy() config_.update(config) def process_inserts(node, db): for i in node.keys(): if isinstance(node[i], basestring): if node[i].startswith("$"): node[i] = db(node[i].replace("$", "")) elif node[i].startswith("&"): node[i] = self.data_inserts[node[i].replace("&", "")] if isinstance(node[i], dict): node[i] = process_inserts(node[i], db) return node config_ = process_inserts(config, self.root.gamedb) config_["__interdictor"] = self if "text" in config_: config_["text"] = _t(config_["text"]) if "label" in config_: config_["label"] = _t(config_["label"]) if config_["type"] in self.root.widget_constructors.keys(): # debug("Creating a '"+config_["type"]+"'") widget = self.root.widget_constructors[config_["type"]](**config_) widget._is_internal = _is_internal widget._json_config = config_ widget.wai = WidgetAbstractionInterface(widget, self, self.root) for controller_cfg in config_.get("controllers", []): if controller_cfg[ "controller"] in self.root.widget_controllers.keys(): # debug("--Binding '"+controller_cfg["controller"]+"' to it") controller_obj = self.root.widget_controllers[ controller_cfg["controller"]](controller_cfg) widget.wai.add_controller(controller_obj) else: if issubclass(controller_cfg["controller"], WidgetController ): #Let Mixin states just provide a class widget.wai.add_controller( controller_cfg["controller"](controller_cfg)) else: error("--CONTROLLER " + controller_cfg["controller"] + " NOT FOUND!") if add_dict: key = config_.get("id", hash(widget)) self.widgets[key] = widget widget._ui_id = key # if add_screen: # widget.add(order=config_.get("order",None)) return widget else: error("WIDGET '" + config_["type"] + "' NOT FOUND")
def interdict_ok(root, title="NOT_SET", text="NOT_SET", button="NOT_SET", callback=lambda s:0, wrap=48, key="sgcui_modalok"): debug("Calling UI_STATES::INTERDICT_OK...") debug("title="+title) debug("text="+text) debug("button="+button) debug("wrap="+str(wrap)) debug("style="+key) text=text.replace("%n", "\n") state=root.state_manager.start_interdicting("generic_ui", root.gamedb(key)) #print state.widgets.keys() state.widgets["replace_title"].config(text=_t(title)) state.widgets["replace_body"].config(text=_t(text)) state.widgets["replace_button"].config(label=_t(button)) state.callback=callback
def create_widget(self, config, add_dict=1, add_screen=1, _is_internal=0): config_=self.default_config.copy() config_.update(config) def process_inserts(node, db): for i in node.keys(): if isinstance(node[i], basestring): if node[i].startswith("$"): node[i]=db(node[i].replace("$","")) elif node[i].startswith("&"): node[i]=self.data_inserts[node[i].replace("&", "")] if isinstance(node[i], dict): node[i]=process_inserts(node[i], db) return node config_=process_inserts(config, self.root.gamedb) config_["__interdictor"]=self if "text" in config_: config_["text"]=_t(config_["text"]) if "label" in config_: config_["label"]=_t(config_["label"]) if config_["type"] in self.root.widget_constructors.keys(): # debug("Creating a '"+config_["type"]+"'") widget=self.root.widget_constructors[config_["type"]](**config_) widget._is_internal=_is_internal widget._json_config=config_ widget.wai=WidgetAbstractionInterface(widget, self, self.root) for controller_cfg in config_.get("controllers",[]): if controller_cfg["controller"] in self.root.widget_controllers.keys(): # debug("--Binding '"+controller_cfg["controller"]+"' to it") controller_obj=self.root.widget_controllers[controller_cfg["controller"]](controller_cfg) widget.wai.add_controller(controller_obj) else: if issubclass(controller_cfg["controller"], WidgetController): #Let Mixin states just provide a class widget.wai.add_controller(controller_cfg["controller"](controller_cfg)) else: error("--CONTROLLER "+controller_cfg["controller"]+" NOT FOUND!") if add_dict: key=config_.get("id", hash(widget)) self.widgets[key]=widget widget._ui_id=key # if add_screen: # widget.add(order=config_.get("order",None)) return widget else: error("WIDGET '"+config_["type"]+"' NOT FOUND")
def interdict_yn(root, title="NOT_SET", text="NOT_SET", button_y="NOT_SET", button_n="NOT_SET",callback_y=lambda s:0, callback_n=lambda s:0, wrap=48, key="sgcui_modalyn"): debug("Calling UI_STATES::INTERDICT_YN...") debug("title="+title) debug("text="+text) debug("button_y="+button_y) debug("button_n="+button_n) debug("wrap="+str(wrap)) debug("style="+key) text_=textwrap.wrap(text, wrap) text="" for l in text_: text+="\n"+l.replace("%n", "\n") state=root.state_manager.start_interdicting("generic_ui", root.gamedb(key)) state.widgets["replace_title"].config(text=_t(title)) state.widgets["replace_body"].config(text=_t(text)) state.widgets["replace_button_yes"].config(label=_t(button_y)) state.widgets["replace_button_no"].config(label=_t(button_n)) state.callback_y=callback_y state.callback_n=callback_n return state
def interdict_ok(root, title="NOT_SET", text="NOT_SET", button="NOT_SET", callback=lambda s: 0, wrap=48, key="sgcui_modalok"): debug("Calling UI_STATES::INTERDICT_OK...") debug("title=" + title) debug("text=" + text) debug("button=" + button) debug("wrap=" + str(wrap)) debug("style=" + key) text = text.replace("%n", "\n") state = root.state_manager.start_interdicting("generic_ui", root.gamedb(key)) #print state.widgets.keys() state.widgets["replace_title"].config(text=_t(title)) state.widgets["replace_body"].config(text=_t(text)) state.widgets["replace_button"].config(label=_t(button)) state.callback = callback
def internal_update(self): screen=self.root.screen.screen screen.fill((0,0,0)) screen.blit(self.ship_image, self.ship_image_pos) # pygame.draw.line(screen, (255,0,255), (0,0), self.ship_image_pos, 5) screen.blit(absroot.gamedb("font_standard_large").render(_t("Select A Slot"), 1, (255,255,255)), (0,0)) for i in self.scaled_hardpoints: pygame.draw.rect(screen, i[2], i[0], 2) # pygame.draw.line(screen, (0,0,255), self.ship_image_pos, i[0].topleft, 5) if i[2] == (255,0,0): self.params["item"].parent.get_item_in_hardpoint(i[1]).tt_delay_update(i[0])
def internal_update(self): screen = self.root.screen.screen screen.fill((0, 0, 0)) screen.blit(self.ship_image, self.ship_image_pos) # pygame.draw.line(screen, (255,0,255), (0,0), self.ship_image_pos, 5) screen.blit( absroot.gamedb("font_standard_large").render( _t("Select A Slot"), 1, (255, 255, 255)), (0, 0)) for i in self.scaled_hardpoints: pygame.draw.rect(screen, i[2], i[0], 2) # pygame.draw.line(screen, (0,0,255), self.ship_image_pos, i[0].topleft, 5) if i[2] == (255, 0, 0): self.params["item"].parent.get_item_in_hardpoint( i[1]).tt_delay_update(i[0])
def internal_update(self): screen = self.root.screen.screen screen.fill((200, 200, 200)) screen.blit( absroot.gamedb( self.ship.get_faction_attr("inventory_image", "img_cargobay_default")), (0, 0)) for x in xrange(self.INVENTORY_WIDTH + 2): pygame.draw.line(screen, (40, 40, 40), (x * 64, 50), (x * 64, 690), 2) for y in xrange(30): pygame.draw.line(screen, (40, 40, 40), (0, 50 + (y * 64)), (960, 50 + (y * 64)), 2) for l in self.tiles: screen.blit(l[2], l[1]) if l[0] == self.selected_item: pygame.draw.rect(screen, (0, 255, 0), pygame.Rect(l[1].left, l[1].top, 64, 64), 2) l[0].tt_delay_update(l[1]) screen.blit( absroot.gamedb( self.ship.get_faction_attr("inventory_image", "img_cargobay_default")).subsurface( (0, 0, 1300, 50)), (0, 0)) screen.blit(absroot.gamedb("img_playermenu_inv_sel"), (0, 0)) pygame.draw.rect(screen, (0, 0, 0), pygame.Rect(962, 50, 400, 700)) text = _t("INVENTORY MANAGEMENT SYSTEM") text += _t("\nGrey --> Equipped") text += _t("\nWhite --> Not Owned") text += _t("\nGreen --> Selected") text += _t("\n[=======================================]") text += _t("\nShip : ") + str(self.ship.name) text += _t("\nAccel : ") + str( int(self.ship.speed / self.ship.get_mass())) text += _t("\nMass : ") + str(self.ship.get_mass()) + "t" text += _t("\nCargo : ") + str(self.ship.get_inventory_mass()) + "t" text += _t("\nItems : ") + str( sum([x.count for x in self.ship.inventory])) if self.is_shop: text += _t( "\n[=======================================]\nTRADE MANAGEMENT SYSTEM\nSelect an item and press T to trade" ) text += _t("\nShop : ") + self.shop_other.name #text+=_t("\nAccel : "+str(int(self.shop_other.speed/self.shop_other.get_mass())) #Probably don't need this... text += _t("\nMass : ") + str(self.shop_other.get_mass()) + "t" text += _t("\nCargo : ") + str( self.shop_other.get_inventory_mass()) + "t" text += _t("\nItems : ") + str( sum([x.count for x in self.shop_other.inventory])) screen.blit( tooltips.render_wrapped_text(text, 300, absroot.gamedb("font_item_desc"), (200, 200, 200)), (962, 50))
def internal_update(self): screen=self.root.screen.screen screen.fill((200,200,200)) screen.blit(absroot.gamedb(self.ship.get_faction_attr("inventory_image", "img_cargobay_default")), (0,0)) for x in xrange(self.INVENTORY_WIDTH+2): pygame.draw.line(screen, (40,40,40), (x*64, 50), (x*64, 690), 2) for y in xrange(30): pygame.draw.line(screen, (40,40,40), (0, 50+(y*64)), (960, 50+(y*64)), 2) for l in self.tiles: screen.blit(l[2], l[1]) if l[0]==self.selected_item: pygame.draw.rect(screen, (0,255,0), pygame.Rect(l[1].left, l[1].top, 64, 64), 2) l[0].tt_delay_update(l[1]) screen.blit(absroot.gamedb(self.ship.get_faction_attr("inventory_image", "img_cargobay_default")).subsurface((0,0,1300,50)), (0,0)) screen.blit(absroot.gamedb("img_playermenu_inv_sel"), (0,0)) pygame.draw.rect(screen, (0,0,0), pygame.Rect(962, 50, 400, 700)) text=_t("INVENTORY MANAGEMENT SYSTEM") text+=_t("\nGrey --> Equipped") text+=_t("\nWhite --> Not Owned") text+=_t("\nGreen --> Selected") text+=_t("\n[=======================================]") text+=_t("\nShip : ")+str(self.ship.name) text+=_t("\nAccel : ")+str(int(self.ship.speed/self.ship.get_mass())) text+=_t("\nMass : ")+str(self.ship.get_mass())+"t" text+=_t("\nCargo : ")+str(self.ship.get_inventory_mass())+"t" text+=_t("\nItems : ")+str(sum([x.count for x in self.ship.inventory])) if self.is_shop: text+=_t("\n[=======================================]\nTRADE MANAGEMENT SYSTEM\nSelect an item and press T to trade") text+=_t("\nShop : ")+self.shop_other.name #text+=_t("\nAccel : "+str(int(self.shop_other.speed/self.shop_other.get_mass())) #Probably don't need this... text+=_t("\nMass : ")+str(self.shop_other.get_mass())+"t" text+=_t("\nCargo : ")+str(self.shop_other.get_inventory_mass())+"t" text+=_t("\nItems : ")+str(sum([x.count for x in self.shop_other.inventory])) screen.blit( tooltips.render_wrapped_text(text, 300, absroot.gamedb("font_item_desc"), (200,200,200)) ,(962,50) )