def __init__(self, item, **kwargs):
        super().__init__(**kwargs)
        self.world = self.parent.parent.world
        self.item = item
        self.options = []
        self.visible = True
        if self.world.has_component(item, c.UseEffect):
            self.options.append("use")
        if self.world.has_component(item, c.Explosive):
            self.options.append("prime")
        self.options.append("throw")
        self.options.append("drop")
        self.size = len(self.options)

        inv_slot_size = constants.TILE_SIZE*constants.MENU_SCALE
        self.pos = (40 + inv_slot_size*2 + 12*constants.MENU_SCALE, self.game.height/2 - inv_slot_size*3)
        image_bottom = self.pos[1]+inv_slot_size*1.5
        self.options_pos = [DynamicPos((self.pos[0], image_bottom + (10 + i*12)*constants.MENU_SCALE), speed=20) for i in range(self.size)]
        self.cursorpos = 0

        audio.play("snap2", replace=True)

        self.widgets = []
        if self.world.has_component(self.item, c.Describable):
            text_x = constants.TILE_SIZE * constants.MENU_SCALE * 1.6
            describe = self.world.entity_component(self.item, c.Describable)
            self.widgets.extend((
                wgt.Text(renderer=self.game.renderer, size=10*constants.MENU_SCALE, text=describe.name, offset=(text_x, 0)),
                wgt.Text(renderer=self.game.renderer, size=5*constants.MENU_SCALE, text=describe.desc, offset=(text_x, 15*constants.MENU_SCALE)),
            ))
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.cursor_pos = 0
        self.desc_widget = wgt.Text(
            renderer=self.game.renderer,
            size=constants.MENU_SCALE * 10,
            offset=(self.game.width/4, self.game.height/2 + constants.MENU_SCALE * 45)
        )
        self.detail_widget = wgt.TextLines(
            renderer=self.game.renderer,
            size=constants.MENU_SCALE * 5,
            offset=(self.game.width/4, self.game.height/2 + constants.MENU_SCALE * 60)
        )

        self.widgets = [
            wgt.Text(
                renderer=self.game.renderer,
                text="Choose your character",
                size=constants.MENU_SCALE * 15,
                offset=(self.game.width / 2, constants.MENU_SCALE * 100),
                centered=True
            ),
            self.desc_widget,
            self.detail_widget
        ]
Beispiel #3
0
    def _start_main_menu(self):
        """Add everything to the main menu. Called after the title drops.

        The main menu animation and proper main menu could be two seperate scenes.
        """
        audio.play_music(constants.MUSIC_DUNGEON)
        options = ["New game", "Settings", "Exit"]
        if self.game.has_save():
            options.insert(0, "Continue game")
        pos = (self.game.width // 2, self.game.height // 2)
        option_select = self.add_child_scene(OptionSelect, options, pos)
        self.game.set_focus(option_select)
        option_select.connect_signal("selected", self.selected_option)

        # Help text
        self.widgets = (wgt.Text(renderer=self.game.renderer,
                                 offset=(5 * constants.MENU_SCALE,
                                         5 * constants.MENU_SCALE),
                                 size=5 * constants.MENU_SCALE,
                                 color=constants.LIGHT_GRAY,
                                 text="CONTROLS"),
                        wgt.TextLines(
                            renderer=self.game.renderer,
                            offset=(5 * constants.MENU_SCALE,
                                    16 * constants.MENU_SCALE),
                            size=5 * constants.MENU_SCALE,
                            color=constants.GRAY,
                            text=[
                                "WASD, ARROWS       MOVE",
                                "Z, SPACE, ENTER    SELECT/OPEN INVENTORY",
                                "X, ESCAPE          BACK/EXIT",
                                "TAB                OPEN/CLOSE INVENTORY"
                            ]))
Beispiel #4
0
    def __init__(self, item, **kwargs):
        super().__init__(**kwargs)
        self.camera = self.parent.parent.camera
        self.world = self.parent.parent.world
        self.item = item
        self.dir = (0, 0)
        self.targettile = None
        self.droptile = None

        self.help_pos = DynamicPos(
            (self.game.width // 2,
             self.game.height + constants.MENU_SCALE * 2.5),
            speed=10)
        self.help_pos.move((self.help_pos.x, self.game.height / 2 +
                            constants.TILE_SIZE * constants.MENU_SCALE))

        text_args = {
            "renderer": self.game.renderer,
            "size": 5 * constants.MENU_SCALE,
            "centered": True
        }

        self.help_text = (wgt.Text(**text_args,
                                   text="Pick a direction",
                                   offset=(0, 0),
                                   color=constants.LIGHT_GRAY),
                          wgt.TextLines(**text_args,
                                        text=["Z to throw", "X to cancel"],
                                        offset=(0, 7 * constants.MENU_SCALE)))
Beispiel #5
0
    def __init__(self, disp, settings, args):
        self.disp = disp
        # draw layout only once
        self.bg = gd.Pixmap(disp, "layout-music.png", [0, 0])
        # text slots
        font = "DroidSans.ttf"
        self.title  = gd.Text(disp, [0,0], font, 18, "PpJjÄäPpJjÄä Title")
        self.artist = gd.Text(disp, [0,24], font, 16, "PpJjÄä Artist")
        self.time   = gd.Text(disp, [0,51], font, 18, "00:00", halign = "right")

        self.dataProviders = [
            ShairportDataProvider(settings),
            PlexDataProvider(settings)
        ]

        self.devMode = False
Beispiel #6
0
 def __init__(self, disp, settings, args):
     self.disp = disp
     self.settings = settings
     self.args = args
     self.poller = ICalPoller(self.settings.countdown["ical"])
     self.bg = gd.Pixmap(disp, "layout-idle.png", [0, 0])
     self.time = gd.Text(disp, [0, 6],
                         "DroidSans.ttf",
                         50,
                         "00:00",
                         halign="center",
                         valign="top")
     self.days = gd.Text(disp, [0, 3],
                         "DroidSans.ttf",
                         12,
                         "000 Tage",
                         halign="center",
                         valign="bottom")
Beispiel #7
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        health_bar_pos = constants.MENU_SCALE * 8 * 4, self.game.height - constants.MENU_SCALE * 8 * 5
        health_bar_size = constants.MENU_SCALE * 8 * 14, constants.MENU_SCALE * 8
        self.health_bar = pygame.Rect(health_bar_pos, health_bar_size)

        self.max_health_text = wgt.Text(renderer=self.game.renderer,
                                        size=15 * constants.MENU_SCALE)

        self.health_text = wgt.Text(
            renderer=self.game.renderer,
            size=15 * constants.MENU_SCALE,
            offset=(self.health_bar.left + 5 * constants.MENU_SCALE,
                    self.health_bar.top - 15 * constants.MENU_SCALE))

        self.level_text = wgt.Text(
            renderer=self.game.renderer,
            size=10 * constants.MENU_SCALE,
            offset=(self.health_bar.x,
                    self.health_bar.bottom + 5 * constants.MENU_SCALE),
            color=constants.LIGHT_GRAY)

        self.kills_text = wgt.Text(
            renderer=self.game.renderer,
            size=10 * constants.MENU_SCALE,
            offset=(self.health_bar.x,
                    self.health_bar.bottom + 17.5 * constants.MENU_SCALE),
            color=constants.LIGHT_GRAY)

        self.time_text = wgt.Text(
            renderer=self.game.renderer,
            size=10 * constants.MENU_SCALE,
            offset=(self.health_bar.x + 80 * constants.MENU_SCALE,
                    self.health_bar.bottom + 17.5 * constants.MENU_SCALE),
            color=constants.LIGHT_GRAY)

        self.widgets = [
            self.max_health_text, self.health_text, self.level_text,
            self.kills_text, self.time_text
        ]
Beispiel #8
0
    def __init__(self,
                 parent=None,
                 message=None,
                 input_text='Enter text here.',
                 *a,
                 **k):
        super(InputDialog, self).__init__(parent, center=True, *a, **k)

        self.margin_bottom = 400
        self.message = widget.Text(self, unicode(message))
        self.message.set_size(50)

        widget.get_keyboard_input(input_text,
                                  lambda text: self.on_dialog_exit(text))
Beispiel #9
0
 def __init__(self, text, pos, state, **kwargs):
     super().__init__(**kwargs)
     self.text = text
     width = constants.MENU_SCALE * (110 + len(text) * 0)
     height = constants.MENU_SCALE * 15
     self.box_rect = pygame.Rect(pos[0] + 10 * constants.MENU_SCALE, pos[1],
                                 width, height)
     self.state = state
     self.text_widget = wgt.Text(
         renderer=self.game.renderer,
         text=text,
         size=constants.MENU_SCALE * 5,
         offset=(self.box_rect.left,
                 self.box_rect.top + 5 * constants.MENU_SCALE),
         color=constants.GRAY)
Beispiel #10
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.config = config.Config()
        x = self.game.width // 2 - constants.MENU_SCALE * 200
        y = self.game.height // 2 - constants.MENU_SCALE * 120
        width = constants.MENU_SCALE * 400
        height = constants.MENU_SCALE * 240
        self.box_rect = pygame.Rect(x, y, width, height)
        self.border_size = constants.MENU_SCALE * 4

        self.widgets = [
            wgt.Text(renderer=self.game.renderer,
                     text="Settings",
                     offset=(self.box_rect.centerx,
                             self.box_rect.top + constants.MENU_SCALE * 15),
                     size=constants.MENU_SCALE * 10,
                     color=constants.DARK_GREEN,
                     centered=True),
            wgt.TextLines(
                renderer=self.game.renderer,
                text=[
                    "This menu is a work in progress.",
                    "Graphics settings will take effect on a game restart."
                ],
                offset=(self.box_rect.centerx,
                        self.box_rect.bottom + constants.MENU_SCALE * 15),
                size=constants.MENU_SCALE * 5,
                color=constants.LIGHT_GRAY,
                centered=True)
        ]
        self.options = []
        self.option_index = None

        toggle_pos = (self.box_rect.left + 10 * constants.MENU_SCALE,
                      self.box_rect.top + 40 * constants.MENU_SCALE)
        toggle = self.add_child_scene(Toggle,
                                      "Fullscreen",
                                      toggle_pos,
                                      state=self.config.fullscreen_mode)
        toggle.connect_signal("changed_state",
                              lambda x: self.set_setting("fullscreen_mode", x))
        self.options.append(toggle)
Beispiel #11
0
    def __init__(self, parent=None, message=None, *a, **k):
        super(YesNoDialog, self).__init__(parent, center=True, *a, **k)

        self.separation = 30
        self.message = widget.Text(self, unicode(message))
        self.message.set_size(50)

        self._but_box = widget.HBox(self)
        self._but_box.separation = 20

        self.yes_button = widget.Button(self._but_box,
                                        'Yes',
                                        'data/icon/accept.png',
                                        vertical=False)
        self.no_button = widget.Button(self._but_box,
                                       'No',
                                       'data/icon/no.png',
                                       vertical=False)

        self.yes_button.on_click += lambda _: self.on_dialog_exit(ret='yes')
        self.no_button.on_click += lambda _: self.on_dialog_exit(ret='no')