def _load_background(self):
     background = Sprite(self.gallery.content["display"]["city_" +
                                                         self.market])
     self.optimal_scale = (self.config.window_width *
                           self.display_pos_size["display_city_commerce"]
                           ["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_city_commerce"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_city_commerce"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     self.add(background)
     if self.market == "commerce":
         overlay = Sprite(self.gallery.content["display"]["city_commerce_" +
                                                          self.supply])
         overlay.image_anchor = 0, 0
         overlay.x = self.left_margin
         overlay.y = self.bottom_margin
         overlay.scale = self.optimal_scale
         self.add(overlay)
示例#2
0
 def _load_background(self):
     background = Sprite(
         self.gallery.content["display"]["worldmap_minitrain"])
     self.optimal_scale = (self.config.window_width * self.display_pos_size[
         "display_worldmap_minitrain"]["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_worldmap_minitrain"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_worldmap_minitrain"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     #self.add(background)
     white_base = ColorLayer(255,
                             255,
                             255,
                             255,
                             width=background.width * 6,
                             height=background.height + 10)
     white_base.x = background.x - (background.width * 3)
     white_base.y = background.y + self.bottom_margin
     self.add(white_base)
示例#3
0
 def __init__(self):
     Layer.__init__(self)
     self.config = Config()
     self.gallery = Gallery()
     self.schedule_interval(self.music_start, interval=7)
     self.intro_sound = load("music/sound_start.wav", streaming=False)
     self.intro_sound.play()
     self.is_event_handler = True
     background = Sprite(self.gallery.content["display"]["title"])
     self.optimal_scale = (
         self.config.window_width *
         self.display_pos_size["display_title"]["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_title"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_title"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     self.add(background)
     place_holder_image = Sprite(self.gallery.content["screen"]["title"])
     place_holder_image.position = director.window.width / 2, director.window.height / 2
     place_holder_image.scale = self.optimal_scale
     place_holder_image.do(ScaleBy(5.2, duration=25))
     self.add(place_holder_image)
    def _load_background(self):
        background = Sprite(
            self.gallery.content["display"]["worldmap_quarters"])
        self.optimal_scale = (self.config.window_width * self.display_pos_size[
            "display_worldmap_quarters"]["W"]) / background.width
        background.image_anchor = 0, 0
        background.scale = self.optimal_scale
        background.x = self.config.window_width * self.display_pos_size[
            "display_worldmap_quarters"]["X"]
        background.y = self.config.window_height * self.display_pos_size[
            "display_worldmap_quarters"]["Y"]
        self.left_margin = background.x
        self.bottom_margin = background.y
        self.optimal_width = background.width
        self.optimal_height = background.height
        self.add(background)

        self.ps_alarm = Sun()
        self.ps_alarm.total_particles = 20
        self.ps_alarm.speed = 0.0
        self.ps_alarm.speed_var = 0.0
        self.ps_alarm.life_var = 0.0
        self.ps_alarm.blend_additive = True
        self.ps_alarm.position = (
            self.optimal_width * self.button_positions["ps_alarm"]["X"] +
            self.left_margin), (
                self.optimal_height * self.button_positions["ps_alarm"]["Y"] +
                self.bottom_margin)
        self.ps_alarm.start_color = Color(1, 0.40, 0.40, 0.40)
        self.ps_alarm.size = 50.0
示例#5
0
 def _load_trade_boxes(self):
     self.remove_trade_boxes()
     if self.trade_display:
         self._load_button_gen("button", "drop", events.emit_commerce_switch_trade_dump, "button_switch", 0, 1, 0.95)
         for wagon in self.wagons_for_trade:
             self._load_button_gen("wagon", self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].display_image+"_t", events.emit_wagon_select, "trade_bracket"+str(wagon), wagon, 1, 0.99 )
             label_wagon_name = Label(self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].wagon_name + " ("+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].storage+")", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.152)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=16*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_name"+str(wagon))
             label_wagon_name = Label(" ", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.026)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=14*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_hold"+str(wagon))
             self._load_button_gen("button", "plus", events.emit_item_buy, "button_buy"+str(wagon), wagon, 0.72, 0.95 )
             self._load_button_gen("button", "minus", events.emit_item_sell, "button_sell"+str(wagon), wagon, 0.72, 0.95 )
     else:
         self._load_button_gen("button", "trade", events.emit_commerce_switch_trade_dump, "button_switch", 0, 1, 0.95)
         for wagon in self.wagons_for_dump:
             trade_bracket = Sprite(self.gallery.content["wagon"][self.config.conf_wagons[self.wagons_for_dump[wagon]["wagon_id"]].display_image+"_t"])
             trade_bracket.image_anchor = 0, 0
             trade_bracket.scale = self.optimal_scale
             trade_bracket.x = self.optimal_width * self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]
             trade_bracket.y = self.optimal_height * self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]
             self.add(trade_bracket, name="trade_bracket"+str(wagon))
             label_wagon_name = Label(self.config.conf_wagons[self.wagons_for_dump[wagon]["wagon_id"]].wagon_name + " ("+self.config.conf_wagons[self.wagons_for_dump[wagon]["wagon_id"]].storage+")", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.152)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=16*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_name"+str(wagon))
             label_wagon_name = Label(" ", (self.optimal_width * (self.button_positions["sprite_trade_bracket"+str(wagon)]["X"]+0.112), self.optimal_height*(self.button_positions["sprite_trade_bracket"+str(wagon)]["Y"]+0.026)), color=(0,0,0,255), font_name="Arial", bold=True, font_size=14*self.optimal_scale, anchor_x="center", anchor_y="center")
             self.add(label_wagon_name, name="trade_bracket_wagon_hold"+str(wagon))
             self._load_button_gen("button", "minus", events.emit_item_sell, "button_sell"+str(wagon), wagon, 0.72, 0.95 )
     self.update_desc()
示例#6
0
 def __init__(self, window_size, pic):
     super().__init__()
     map = Sprite(pic)
     w, h = window_size
     # map.scale_x, map.scale_y = w/map.width, h/map.height
     map.image_anchor = (0, 0)
     # map.position = map.width//2, map.height//2
     self.add(map)
 def _load_background(self, bubble_type, px, py, pscale):
     background = Sprite(self.gallery.content["text"]["bubble_" +
                                                      bubble_type])
     background.scale = pscale
     background.image_anchor = 0, 0
     background.x = px
     background.y = py
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
 def _load_background(self):
     background = Sprite(self.gallery.content["display"]["city_hud"])
     self.optimal_scale=(self.config.window_width * self.display_pos_size["display_city_hud"]["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size["display_city_hud"]["X"]
     background.y = self.config.window_height * self.display_pos_size["display_city_hud"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     self.add(background)
示例#9
0
 def display_wagon_info(self, wagon):
     try:
         self.remove("sprite_wagon_selected")
     except:
         A=1
     wagon_selected = Sprite(self.gallery.content["wagon"][self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].display_image+"_c"])
     wagon_selected.image_anchor = 0, 0
     wagon_selected.scale = self.optimal_scale*1.66
     wagon_selected.x = self.optimal_width * self.button_positions["sprite_wagon_selected"]["X"]
     wagon_selected.y = self.optimal_height * self.button_positions["sprite_wagon_selected"]["Y"]
     self.add(wagon_selected, name="sprite_wagon_selected")
     self.get("label_stores_1").element.text=self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].screen_name
     self.get("label_stores_2").element.text="Net weight: "+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].net_weight+", Capacity: "+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].capacity+str(self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].units)+self.config.conf_wagons[self.wagons_for_trade[wagon]["wagon_id"]].storage
     self.update_desc()
示例#10
0
    def menu_xo(self):
        if not self.interact:
            background = Sprite(
                self.gallery.content["display"]["worldmap_hud_interact2"])
            background.image_anchor = 0, 0
            background.scale = self.optimal_scale
            background.x = 0
            background.y = 0
            self.add(background, name="display_worldmap_hud_interact")
            self.interact = True
            opt = {
                "0": {
                    "text": "Prospect for coal",
                    "param": "prospect"
                },
                "1": {
                    "text": "Deploy explosives",
                    "param": "mine"
                },
                "2": {
                    "text": "Discuss",
                    "param": "discuss_xo"
                },
                "3": {
                    "text": "That is all",
                    "param": "end"
                }
            }

            display_interact_box_self = DisplayInteractBox(
                opt, "1", self.optimal_width *
                self.button_positions["display_interact_box_self"]["X"],
                self.optimal_width *
                self.button_positions["display_interact_box_self"]["Y"],
                self.optimal_scale)
            self.add(display_interact_box_self,
                     name="display_interact_box_self")
            label_line_1 = self._load_label_gen("label_line_1")
            self.add(label_line_1, name="label_line_1")
            label_line_2 = self._load_label_gen("label_line_2")
            self.add(label_line_2, name="label_line_2")
            label_line_3 = self._load_label_gen("label_line_3")
            self.add(label_line_3, name="label_line_3")
            label_line_4 = self._load_label_gen("label_line_4")
            self.add(label_line_4, name="label_line_4")
            label_line_5 = self._load_label_gen("label_line_5")
            self.add(label_line_5, name="label_line_5")
            self.clear_text()
            self.get("label_line_1"
                     ).element.text = "Yes Conductor, how can I assist? "
示例#11
0
 def _load_background(self):
     background = Sprite(self.gallery.content["display"]["worldmap_hud"])
     self.optimal_scale = (self.config.window_width *
                           self.display_pos_size["display_worldmap_hud"]
                           ["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_worldmap_hud"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_worldmap_hud"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     black_base = ColorLayer(0,
                             0,
                             0,
                             255,
                             width=background.width,
                             height=background.height)
     black_base.x = background.x
     black_base.y = background.y
     self.add(black_base)
     self._load_button_gen("button", "engine", events.emit_show_engine,
                           "button_engine", 0, 1, 0.9)
     self._load_button_gen("button", "quarters", events.emit_show_quarters,
                           "button_quarters", 0, 1, 0.9)
     self._load_button_gen("button", "cnc", events.emit_show_cnc,
                           "button_cnc", 0, 1, 0.9)
     self._load_button_gen("button", "minimap", events.emit_show_minimap,
                           "button_minimap", 0, 1, 0.9)
     self._load_button_gen("button", "find_engine", events.emit_find_engine,
                           "button_find_engine", 0, 1, 0.9)
     self._load_button_gen("button", "arrow_left",
                           events.emit_scroll_minitrain,
                           "button_arrow_left", 0, 0.4, 0.95)
     self._load_button_gen("button", "arrow_right",
                           events.emit_scroll_minitrain,
                           "button_arrow_right", 0, 0.4, 0.95)
     #self._load_button_direction()
     self._load_button_gen("button", "break_on", events.emit_switch_break,
                           "button_break", 0, 1, 0.95)
     self._load_button_gen("button", "direction_for",
                           events.emit_switch_direction, "button_direction",
                           0, 1, 0.95)
     self.add(background)
示例#12
0
    def _load_interface(self):
        hud = Sprite(self.gallery.content["display"]["mainmenu_hud"])
        hud.image_anchor = 0, 0
        hud.scale = self.optimal_scale
        hud.x = 0
        hud.y = 0
        self.add(hud)

        self._load_button_gen("button", "startgame", events.emit_start_game,
                              "button_startgame", 0, 0.4, 0.95)
        self._load_button_gen("button", "loadgame", events.emit_load_game,
                              "button_loadgame", 0, 0.4, 0.95)
        self._load_button_gen("button", "sound_" + self.sound_on_off,
                              events.emit_sound_switch, "button_sound_switch",
                              0, 0.4, 0.95)
        self._load_button_gen("button", "startgame", events.emit_quick_battle,
                              "button_quickbattle", 0, 0.4, 0.95)
示例#13
0
文件: thumb.py 项目: LLNT/3X-Project
    def __init__(self, minimap, w, h, size=10):
        super().__init__(0, 0, 0, 100, w * size, h * size)
        self.batch = BatchNode()
        for (i, j) in minimap:
            tmp = minimap[(i, j)]
            if tmp is not -1:
                img = 'grid/' + str(tmp) + '.png'
                pos = i * size, j * size
                spr = Sprite(image=img, position=pos)
                spr.scale_x, spr.scale_y = size / spr.width, size / spr.height
                spr.image_anchor = (0, 0)
                self.batch.add(spr)

        self.add(self.batch)
        self.frame = ColorLayer(0, 0, 100, 100, min(w * 10, 160),
                                min(h * 10, 90))
        self.add(self.frame)
示例#14
0
 def refresh_labels(self):
     if self.transarctica.update_minitrain:
         xx = self.optimal_width * 0.985
         for sp in self.get_children():
             self.remove(sp)
         white_base = ColorLayer(235,
                                 200,
                                 130,
                                 255,
                                 width=self.optimal_width * 6,
                                 height=self.optimal_height + 15)
         white_base.x = self.left_margin - (self.optimal_width * 3)
         white_base.y = self.bottom_margin
         self.add(white_base)
         for wg in self.transarctica.train_layout:
             train = Sprite(
                 self.gallery.content["wagon"][self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].display_image +
                                               "_tr"])
             train.image_anchor = 0, 0
             train.scale = self.optimal_scale * 0.40
             xx = xx - train.width
             train.x = xx
             train.y = self.bottom_margin + 10
             #damage_base = ColorLayer( 85*int(self.config.conf_wagons[self.transarctica.train_layout[wg]].damage),45,45,45*int(self.config.conf_wagons[self.transarctica.train_layout[wg]].damage), width=train.width, height=train.height)
             self.add(train)
             if int(self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].damage) > 0:
                 damage_base = ColorLayer(
                     255,
                     0,
                     0,
                     255,
                     width=trunc(
                         (train.width / 4) *
                         (4 - int(self.config.conf_wagons[
                             self.transarctica.train_layout[wg]].damage))),
                     height=train.height // 10)
                 damage_base.x = train.x
                 damage_base.y = train.y + damage_base.height * 9
                 self.add(damage_base)
         self.transarctica.update_minitrain = False
 def _load_trade_boxes(self):
     self.remove_trade_boxes()
     if self.trade_display:
         self._load_button_gen("button", "drop",
                               events.emit_commerce_switch_trade_dump,
                               "button_switch", 0, 1, 0.95)
         for item in self.items_for_trade:
             trade_bracket = Sprite(
                 self.gallery.content["item"][self.config.conf_items[
                     self.items_for_trade[item]["item_id"]].display_image +
                                              "_t"])
             trade_bracket.image_anchor = 0, 0
             trade_bracket.scale = self.optimal_scale
             trade_bracket.x = self.optimal_width * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["X"]
             trade_bracket.y = self.optimal_height * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["Y"]
             self.add(trade_bracket, name="trade_bracket" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_trade[item]
                                        ["item_id"]].item_name,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.138),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.152)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=16 * self.optimal_scale,
                 anchor_x="center",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_name" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_trade[item]
                                        ["item_id"]].storage,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.088),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.130)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_storage" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.104)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_supply" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.078)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_demand" + str(item))
             label_item_name = Label(
                 "Price: " + str(self.items_for_trade[item]["price"]),
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.088),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.052)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_price" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.026)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_hold" + str(item))
             #if (self.items_for_trade[item]["sell_units"] > 0):
             self._load_button_gen("button", "plus", events.emit_item_buy,
                                   "button_buy" + str(item), item, 0.72,
                                   0.95)
             #if (self.items_for_trade[item]["buy_units"] > 0):
             self._load_button_gen("button", "minus", events.emit_item_sell,
                                   "button_sell" + str(item), item, 0.72,
                                   0.95)
     else:
         self._load_button_gen("button", "trade",
                               events.emit_commerce_switch_trade_dump,
                               "button_switch", 0, 1, 0.95)
         for item in self.items_for_dump:
             trade_bracket = Sprite(
                 self.gallery.content["item"][self.config.conf_items[
                     self.items_for_dump[item]["item_id"]].display_image +
                                              "_t"])
             trade_bracket.image_anchor = 0, 0
             trade_bracket.scale = self.optimal_scale
             trade_bracket.x = self.optimal_width * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["X"]
             trade_bracket.y = self.optimal_height * self.button_positions[
                 "sprite_trade_bracket" + str(item)]["Y"]
             self.add(trade_bracket, name="trade_bracket" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_dump[item]
                                        ["item_id"]].item_name,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.138),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.152)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=16 * self.optimal_scale,
                 anchor_x="center",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_name" + str(item))
             label_item_name = Label(
                 self.config.conf_items[self.items_for_dump[item]
                                        ["item_id"]].storage,
                 (self.optimal_width *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["X"] + 0.088),
                  self.optimal_height *
                  (self.button_positions["sprite_trade_bracket" +
                                         str(item)]["Y"] + 0.130)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_storage" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.104)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(
                 label_item_name, name="button_buy" +
                 str(item))  #just to have an object with the name to remove
             self.add(label_item_name,
                      name="trade_bracket_item_hold" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.078)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_demand" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.052)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_price" + str(item))
             label_item_name = Label(
                 " ", (self.optimal_width *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["X"] + 0.088),
                       self.optimal_height *
                       (self.button_positions["sprite_trade_bracket" +
                                              str(item)]["Y"] + 0.026)),
                 color=(0, 0, 0, 255),
                 font_name="Arial",
                 bold=True,
                 font_size=14 * self.optimal_scale,
                 anchor_x="left",
                 anchor_y="center")
             self.add(label_item_name,
                      name="trade_bracket_item_supply" + str(item))
             self._load_button_gen("button", "minus", events.emit_item_sell,
                                   "button_sell" + str(item), item, 0.72,
                                   0.95)
     self.update_desc()
 def __init__(self):
     super().__init__()
     s = Sprite("bg.png")
     s.image_anchor = (0,0)
     self.add(s)
 def __init__(self):
     super(RulersLayer, self).__init__()
     
     self._kCCBRulerWidth = 15
     
     self._stageOrigin = [0,0]
     self._winSize = [0,0]
     self._zoom = 1.0
     
     # TODO:@twenty0ne
     # CCScale9Sprite
     bgVertical = Sprite('images/ruler-bg-vertical.png')
     # TODO:@twenty0ne
     # notice image_anchor, anchor, transform_anchor difference
     bgVertical.image_anchor = 0,0
     self.add(bgVertical)
     self._bgVertical = bgVertical
     
     bgHorizontal = Sprite('images/ruler-bg-horizontal.png')
     bgHorizontal.image_anchor = 0,0
     self.add(bgHorizontal, z=2)
     self._bgHorizontal = bgHorizontal
     
     marksVertical = CocosNode()
     self.add(marksVertical, z=1)
     self._marksVertical = marksVertical
     
     marksHorizontal = CocosNode()
     self.add(marksHorizontal, z=3)
     self._marksHorizontal = marksHorizontal
     
     mouseMarkVertical = Sprite('images/ruler-guide.png')
     mouseMarkVertical.image_anchor = 0,0.5
     mouseMarkVertical.visible = False
     self.add(mouseMarkVertical, z=4)
     self._mouseMarkVertical = mouseMarkVertical
     
     mouseMarkHorizontal = Sprite('images/ruler-guide.png')
     mouseMarkHorizontal.rotation = -90
     mouseMarkHorizontal.image_anchor = 0,0.5
     mouseMarkHorizontal.visible = False
     self.add(mouseMarkHorizontal, z=4)
     self._mouseMarkHorizontal = mouseMarkHorizontal
     
     xyBg = Sprite('images/ruler-xy.png')
     xyBg.image_anchor = 0,0
     xyBg.position = 0,0
     self.add(xyBg, z=5)
     
     lblX = Label("0", position=(40,3), color=(0,0,0,255), font_size=8, anchor_x="right")
     #lblX.anchor = 1,0
     #lblX.position = 47,3
     lblX.visible = False
     self.add(lblX, z=6)
     self._lblX = lblX
     
     lblY = Label("0", position=(90,3), color=(0,0,0,255), font_size=8, anchor_x="right")
     #lblY.anchor = 1,0
     #lblY.position = 97,3
     lblY.visible = False
     self.add(lblY, z=6)
     self._lblY = lblY
 def updateWithSize(self, ws, so, zm):
     self._stageOrigin[0] = int(self._stageOrigin[0])
     self._stageOrigin[1] = int(self._stageOrigin[1])
     
     if self._winSize == ws and self._stageOrigin == so and self._zoom == zm:
         return
     
     self._winSize = ws
     self._stageOrigin = so
     self._zoom = zm
     
     # TODO:@twenty0ne
     # CCScale9Sprite.preferedSize
     # Resize backrounds
     self._bgHorizontal.scale_x = self._winSize[0]/self._bgHorizontal.width
     self._bgHorizontal.scale_y = self._kCCBRulerWidth/self._bgHorizontal.height
     
     self._bgVertical.scale_x = self._kCCBRulerWidth/self._bgVertical.width
     self._bgVertical.scale_y = self._winSize[1]/self._bgVertical.height
     
     # Add marks and numbers
     for obj in self._marksVertical.get_children():
         self._marksVertical.remove(obj)
     for obj in self._marksHorizontal.get_children():
         self._marksHorizontal.remove(obj)
         
     # Vertical marks
     y = int(so[1]) - (int(so[1])/10)*10
     while y < ws[1]:
         yDist = abs(y - int(self._stageOrigin[1]))
         
         mark = None
         addLabel = False
         if yDist == 0:
             mark = Sprite("images/ruler-mark-origin.png")
             addLabel = True
         elif yDist%50 == 0:
             mark = Sprite("images/ruler-mark-major.png")
             addLabel = True
         else:
             mark = Sprite("images/ruler-mark-minor.png")
         mark.image_anchor = 0,0.5
         mark.position = 0,y
         self._marksVertical.add(mark)
         
         if addLabel:
             displayDist = yDist / self._zoom
             strDist = str(displayDist)
             strLen = len(strDist)
             for i in range(0, strLen):
                 lbl = Label(strDist[i], color=(0,0,0,255), font_size=8)
                 lbl.anchor = 0,0
                 lbl.position = 2,(y+1+10*(strLen-i-1))
                 self._marksVertical.add(lbl)
         
         y = y + 10
         
     # Horizontal marks
     x = int(so[0]) - (int(so[0])/10)*10
     while x < ws[0]:
         xDist = abs(x - int(self._stageOrigin[0]))
         
         mark = None
         addLabel = False
         if xDist == 0:
             mark = Sprite("images/ruler-mark-origin.png")
             addLabel = True
         elif xDist%50 == 0:
             mark = Sprite("images/ruler-mark-major.png")
             addLabel = True
         else:
             mark = Sprite("images/ruler-mark-minor.png")
         mark.image_anchor = 0,0.5
         mark.position = x,0
         mark.rotation = -90
         self._marksHorizontal.add(mark)
         
         if addLabel:
             displayDist = xDist / self._zoom
             lbl = Label(str(displayDist), color=(0,0,0,255), font_size=8)
             lbl.anchor = 0,0
             lbl.position = x+1,1
             self._marksHorizontal.add(lbl)
         
         x = x + 10
示例#19
0
    def _load_background(self):
        background = Sprite(self.gallery.content["display"]["worldmap_engine"])
        self.optimal_scale = (self.config.window_width *
                              self.display_pos_size["display_worldmap_engine"]
                              ["W"]) / background.width
        background.image_anchor = 0, 0
        background.scale = self.optimal_scale
        background.x = self.config.window_width * self.display_pos_size[
            "display_worldmap_engine"]["X"]
        background.y = self.config.window_height * self.display_pos_size[
            "display_worldmap_engine"]["Y"]
        self.left_margin = background.x
        self.bottom_margin = background.y
        self.optimal_width = background.width
        self.optimal_height = background.height

        pic_fire = Sprite(
            self.gallery.content["display"]["worldmap_engine_fire"])
        pic_fire.image_anchor = 0, 0
        pic_fire.scale = self.optimal_scale
        pic_fire.x = self.optimal_width * self.button_positions["pic_fire"][
            "X"] + self.left_margin
        pic_fire.y = self.optimal_height * self.button_positions["pic_fire"][
            "Y"] + self.bottom_margin
        self.add(pic_fire, name="pic_fire")

        self.ps_fire = Fire()
        self.ps_fire.size = 120
        self.ps_fire.position = (
            self.optimal_width * self.button_positions["ps_fire"]["X"] +
            self.left_margin,
            self.optimal_height * self.button_positions["ps_fire"]["Y"] +
            self.bottom_margin)
        self.add(self.ps_fire, name="ps_fire")

        self.add(background)

        pic_anthracite = Sprite(
            self.gallery.content["display"]["worldmap_engine_anthracite"])
        pic_anthracite.image_anchor = 0, 0
        pic_anthracite.scale = self.optimal_scale
        pic_anthracite.x = self.optimal_width * self.button_positions[
            "pic_anthracite"]["X"] + self.left_margin
        pic_anthracite.y = self.optimal_height * self.button_positions[
            "pic_anthracite"]["Y"] + self.bottom_margin
        self.add(pic_anthracite, name="pic_anthracite")

        pic_lignite = Sprite(
            self.gallery.content["display"]["worldmap_engine_lignite"])
        pic_lignite.image_anchor = 0, 0
        pic_lignite.scale = self.optimal_scale
        pic_lignite.x = self.optimal_width * self.button_positions[
            "pic_lignite"]["X"] + self.left_margin
        pic_lignite.y = self.optimal_height * self.button_positions[
            "pic_lignite"]["Y"] + self.bottom_margin
        self.add(pic_lignite, name="pic_lignite")

        self.ps_alarm = Sun()
        self.ps_alarm.total_particles = 20
        self.ps_alarm.speed = 0.0
        self.ps_alarm.speed_var = 0.0
        self.ps_alarm.life_var = 0.0
        self.ps_alarm.blend_additive = True
        self.ps_alarm.position = (
            self.optimal_width * self.button_positions["ps_alarm"]["X"] +
            self.left_margin), (
                self.optimal_height * self.button_positions["ps_alarm"]["Y"] +
                self.bottom_margin)
        self.ps_alarm.start_color = Color(1, 0.40, 0.40, 0.40)
        self.ps_alarm.size = 50.0
示例#20
0
 def __init__(self):
     super().__init__()
     s = Sprite("bg.png")
     s.image_anchor = (0, 0)
     self.add(s)
 def draw_wagons_buttons(self):
     if self.service_mode == "R":
         self.get(
             "label_line_4"
         ).element.text = "Select wagon to Repair." + "You have " + str(
             self.transarctica.cargo_manifest[
                 self.transarctica.get_item_id_from_name(
                     "Lignite")]["hold"]) + " baks lignite"
     elif self.service_mode == "S":
         self.get(
             "label_line_4"
         ).element.text = "Select wagons to Switch." + "You have " + str(
             self.transarctica.cargo_manifest[
                 self.transarctica.get_item_id_from_name(
                     "Lignite")]["hold"]) + " baks lignite"
     wagon_scale = 0.30
     right_pad = self.config.window_width * 0.85
     curr_x = right_pad
     curr_y = self.optimal_height * 0.15
     train = Sprite(self.gallery.content["wagon"]["blank"])
     train.scale = self.optimal_scale * wagon_scale
     divider = train.width
     if self.service_mode == "S":
         self._load_button_gen("wagon", "blank", events.emit_wagon_service,
                               "button_wagon_b" + str(0), 100, wagon_scale,
                               0.95, curr_x, curr_y)
         self.elements_to_remove.append("button_wagon_b" + str(0))
         for wg in self.transarctica.train_layout:
             train = Sprite(
                 self.gallery.content["wagon"][self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].display_image])
             train.image_anchor = 0, 0
             train.scale = self.optimal_scale * wagon_scale
             curr_x = curr_x - train.width
             if curr_x <= 50:
                 right_pad -= self.config.window_width * 0.05
                 curr_x = right_pad - train.width
                 curr_y -= self.optimal_height * 0.05
             train.x = curr_x
             train.y = curr_y
             self._load_button_gen(
                 "wagon", self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].display_image,
                 events.emit_wagon_service, "button_wagon_" + str(wg), wg,
                 wagon_scale, 0.95, curr_x, curr_y)
             self.elements_to_remove.append("button_wagon_" + str(wg))
             if int(self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].damage) > 0:
                 damage_base = ColorLayer(
                     255,
                     0,
                     0,
                     255,
                     width=trunc(
                         (train.width / 4) *
                         (4 - int(self.config.conf_wagons[
                             self.transarctica.train_layout[wg]].damage))),
                     height=train.height // 10)
                 damage_base.x = train.x
                 damage_base.y = train.y + damage_base.height * 9
                 self.add(damage_base, name="healthbar_wagon_" + str(wg))
                 self.elements_to_remove.append("healthbar_wagon_" +
                                                str(wg))
             curr_x = curr_x - divider
             self._load_button_gen("wagon", "blank",
                                   events.emit_wagon_service,
                                   "button_wagon_b" + str(wg + 1), 101 + wg,
                                   wagon_scale, 0.95, curr_x, curr_y)
             self.elements_to_remove.append("button_wagon_b" + str(wg + 1))
     if self.service_mode == "R":
         for wg in self.transarctica.train_layout:
             if self.config.conf_wagons[
                     self.transarctica.train_layout[wg]].damage > 0:
                 train = Sprite(
                     self.gallery.content["wagon"][self.config.conf_wagons[
                         self.transarctica.train_layout[wg]].display_image])
                 train.image_anchor = 0, 0
                 train.scale = self.optimal_scale * wagon_scale
                 curr_x = curr_x - train.width
                 if curr_x <= 50:
                     right_pad -= self.config.window_width * 0.05
                     curr_x = right_pad - train.width
                     curr_y -= self.optimal_height * 0.05
                 train.x = curr_x
                 train.y = curr_y
                 self._load_button_gen(
                     "wagon", self.config.conf_wagons[
                         self.transarctica.train_layout[wg]].display_image,
                     events.emit_wagon_service, "button_wagon_" + str(wg),
                     wg, wagon_scale, 0.95, curr_x, curr_y)
                 self.elements_to_remove.append("button_wagon_" + str(wg))
                 if int(self.config.conf_wagons[
                         self.transarctica.train_layout[wg]].damage) > 0:
                     damage_base = ColorLayer(
                         255,
                         0,
                         0,
                         255,
                         width=trunc(
                             (train.width / 4) *
                             (4 - int(self.config.conf_wagons[
                                 self.transarctica.train_layout[wg]].damage)
                              )),
                         height=train.height // 10)
                     damage_base.x = train.x
                     damage_base.y = train.y + damage_base.height * 9
                     self.add(damage_base,
                              name="healthbar_wagon_" + str(wg))
                     self.elements_to_remove.append("healthbar_wagon_" +
                                                    str(wg))