Ejemplo n.º 1
0
    def setup(self):
        MenuView.setup(self)
        width, height = self.controller.window.width, self.controller.window.height

        self.layout = VerticalLayout(0, 0)

        self.text_input = TextWidget(self.controller.window, G.IP_ADDRESS, 0, 0, width=160, height=20, font_name='Arial', batch=self.batch)
        self.controller.window.push_handlers(self.text_input)
        self.text_input.focus()
        def text_input_callback(symbol, modifier):
            G.IP_ADDRESS = self.text_input.text
        self.text_input.push_handlers(key_released=text_input_callback)

        button = self.Button(caption=G._("Connect to server"), on_click=self.controller.start_multiplayer_game)
        self.layout.add(button)
        self.buttons.append(button)
        button= self.Button(caption=G._("Launch server"), on_click=self.launch_server)
        self.layout.add(button)
        self.buttons.append(button)
        button= self.Button(caption=G._("Done"), on_click=self.controller.main_menu)
        self.layout.add(button)
        self.buttons.append(button)

        self.label = Label('Play Multiplayer', font_name='ChunkFive Roman', font_size=25, x=width/2, y=self.frame.y + self.frame.height,
            anchor_x='center', anchor_y='top', color=(255, 255, 255, 255), batch=self.batch,
            group=self.labels_group)

        self.on_resize(width, height)
Ejemplo n.º 2
0
    def setup(self):
        MenuView.setup(self)
        width, height = self.controller.window.width, self.controller.window.height

        self.layout = VerticalLayout(0, 0)

        self.text_input = TextWidget(self.controller.window, G.IP_ADDRESS, 0, 0, width=160, height=20, font_name='Arial', batch=self.batch)
        self.controller.window.push_handlers(self.text_input)
        self.text_input.focus()
        def text_input_callback(symbol, modifier):
            G.IP_ADDRESS = self.text_input.text
        self.text_input.push_handlers(key_released=text_input_callback)

        button = self.Button(caption=G._("Connect to server"), on_click=self.controller.start_multiplayer_game)
        self.layout.add(button)
        self.buttons.append(button)
        button= self.Button(caption=G._("Launch server"), on_click=self.launch_server)
        self.layout.add(button)
        self.buttons.append(button)
        button= self.Button(caption=G._("Done"), on_click=self.controller.main_menu)
        self.layout.add(button)
        self.buttons.append(button)

        self.label = Label('Play Multiplayer', font_name='ChunkFive Roman', font_size=25, x=width/2, y=self.frame.y + self.frame.height,
            anchor_x='center', anchor_y='top', color=(255, 255, 255, 255), batch=self.batch,
            group=self.labels_group)

        self.on_resize(width, height)
Ejemplo n.º 3
0
    def setup(self):
        self.group = pyglet.graphics.OrderedGroup(3)
        self.labels_group = pyglet.graphics.OrderedGroup(4)

        image = frame_image
        self.layout = VerticalLayout(0, 0)
        # Custom background
        self.background = None
        self.frame_rect = Rectangle(0, 0, self.controller.window.get_size()[0], image.height)
        self.frame = Rectangle(0, 0, self.controller.window.get_size()[0], image.height)

        width, height = self.controller.window.width, self.controller.window.height

        self.label = Label(G.APP_NAME, font_name='ChunkFive Roman', font_size=50, x=width//2, y=self.frame.y + self.frame.height,
            anchor_x='center', anchor_y='top', color=(255, 255, 255, 255), batch=self.batch,
            group=self.labels_group)
        self.label.width = self.label.content_width
        self.label.height = self.label.content_height
        self.layout.add(self.label)

        button = self.Button(caption=G._("Singleplayer"),on_click=self.controller.start_singleplayer_game)
        self.layout.add(button)
        self.buttons.append(button)
        button = self.Button(caption=G._("Multiplayer"),on_click=self.controller.multiplayer)
        self.layout.add(button)
        self.buttons.append(button)
        button = self.Button(caption=G._("Options..."),on_click=self.controller.game_options)
        self.layout.add(button)
        self.buttons.append(button)
        button = self.Button(caption=G._("Exit game"),on_click=self.controller.exit_game)
        self.layout.add(button)
        self.buttons.append(button)

        # Splash text
        self.splash_text = 'Hello!'

        now = datetime.datetime.now()
        if now.month == 1 and now.day == 1:
            self.splash_text = 'Happy new year!'

        self.splash_text_label = Label(self.splash_text, font_name='Arial', font_size=30, x=self.label.x, y=self.label.y,
            anchor_x='center', anchor_y='top', color=(255, 255, 0, 255),
            group=self.labels_group)

        self.on_resize(width, height)

        # Panorama
        self.panorama = [G.texture_pack_list.selected_texture_pack.load_texture(['title', 'bg', 'panorama' + str(x) + '.png']) for x in range(6)]
        self.panorama_timer = 0

        pyglet.clock.schedule_interval(self.update_panorama_timer, .05)
        self.blur_texture = pyglet.image.Texture.create(256, 256)

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
Ejemplo n.º 4
0
    def setup(self):
        self.group = pyglet.graphics.OrderedGroup(3)
        self.labels_group = pyglet.graphics.OrderedGroup(4)

        image = frame_image
        self.layout = VerticalLayout(0, 0)
        # Custom background
        self.background = None
        self.frame_rect = Rectangle(0, 0, self.controller.window.get_size()[0], image.height)
        self.frame = Rectangle(0, 0, self.controller.window.get_size()[0], image.height)

        width, height = self.controller.window.width, self.controller.window.height

        self.label = Label(G.APP_NAME, font_name='ChunkFive Roman', font_size=50, x=width/2, y=self.frame.y + self.frame.height,
            anchor_x='center', anchor_y='top', color=(255, 255, 255, 255), batch=self.batch,
            group=self.labels_group, width=width, height=height)
        self.label.height = self.label.content_height
        self.layout.add(self.label)

        button = self.Button(caption=G._("Singleplayer"),on_click=self.controller.start_singleplayer_game)
        self.layout.add(button)
        self.buttons.append(button)
        button = self.Button(caption=G._("Multiplayer"),on_click=self.controller.multiplayer)
        self.layout.add(button)
        self.buttons.append(button)
        button = self.Button(caption=G._("Options..."),on_click=self.controller.game_options)
        self.layout.add(button)
        self.buttons.append(button)
        button = self.Button(caption=G._("Exit game"),on_click=self.controller.exit_game)
        self.layout.add(button)
        self.buttons.append(button)

        # Splash text
        self.splash_text = 'Hello!'

        now = datetime.datetime.now()
        if now.month == 1 and now.day == 1:
            self.splash_text = 'Happy new year!'

        self.splash_text_label = Label(self.splash_text, font_name='Arial', font_size=30, x=self.label.x, y=self.label.y,
            anchor_x='center', anchor_y='top', color=(255, 255, 0, 255),
            group=self.labels_group)

        self.on_resize(width, height)

        # Panorama
        self.panorama = [G.texture_pack_list.selected_texture_pack.load_texture(['title', 'bg', 'panorama' + str(x) + '.png']) for x in range(6)]
        self.panorama_timer = 0

        pyglet.clock.schedule_interval(self.update_panorama_timer, .05)
        self.blur_texture = pyglet.image.Texture.create(256, 256)

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
Ejemplo n.º 5
0
    def setup(self):
        MenuView.setup(self)
        width, height = self.controller.window.width, self.controller.window.height

        self.layout = VerticalLayout(0, 0)

        textures_enabled = len(G.texture_pack_list.available_texture_packs) > 1

        self.text_input = TextWidget(self.controller.window, G.USERNAME, 0, 0, width=160, height=20, font_name='Arial', batch=self.batch)
        self.controller.window.push_handlers(self.text_input)
        self.text_input.focus()
        self.text_input.caret.mark = len(self.text_input.document.text)  # Don't select the whole text
        def text_input_callback(symbol, modifier):
            G.USERNAME = self.text_input.text
        self.text_input.push_handlers(key_released=text_input_callback)

        hl = HorizontalLayout(0, 0)
        sb = self.Scrollbar(x=0, y=0, width=300, height=40, sb_width=20, sb_height=40, caption="Music")
        hl.add(sb)

        def change_sound_volume(pos):
            print(G.EFFECT_VOLUME)
            G.EFFECT_VOLUME = float(float(pos) / 100)
        sb = self.Scrollbar(x=0, y=0, width=300, height=40, sb_width=20, sb_height=40, caption="Sound", pos=int(G.EFFECT_VOLUME * 100), on_pos_change=change_sound_volume)
        hl.add(sb)
        self.layout.add(hl)

        hl = HorizontalLayout(0, 0)
        button = self.Button(width=300, caption=G._("Controls..."), on_click=self.controller.controls)
        hl.add(button)
        self.buttons.append(button)
        button = self.Button(width=300, caption=G._("Textures"), on_click=self.controller.textures, enabled=textures_enabled)
        hl.add(button)
        self.buttons.append(button)
        self.layout.add(hl)

        button = self.Button(width=610, caption=G._("Done"), on_click=self.controller.main_menu)
        self.layout.add(button)
        self.buttons.append(button)

        self.label = Label('Options', font_name='ChunkFive Roman', font_size=25, x=width/2, y=self.frame.y + self.frame.height,
            anchor_x='center', anchor_y='top', color=(255, 255, 255, 255), batch=self.batch,
            group=self.labels_group)

        self.on_resize(width, height)
Ejemplo n.º 6
0
    def setup(self):
        MenuView.setup(self)
        width, height = self.controller.window.width, self.controller.window.height

        self.layout = VerticalLayout(0, 0)

        textures_enabled = len(G.texture_pack_list.available_texture_packs) > 1

        self.text_input = TextWidget(self.controller.window, G.USERNAME, 0, 0, width=160, height=20, font_name='Arial', batch=self.batch)
        self.controller.window.push_handlers(self.text_input)
        self.text_input.focus()
        self.text_input.caret.mark = len(self.text_input.document.text)  # Don't select the whole text
        def text_input_callback(symbol, modifier):
            G.USERNAME = self.text_input.text
        self.text_input.push_handlers(key_released=text_input_callback)

        hl = HorizontalLayout(0, 0)
        sb = self.Scrollbar(x=0, y=0, width=300, height=40, sb_width=20, sb_height=40, caption="Music")
        hl.add(sb)

        def change_sound_volume(pos):
            print G.EFFECT_VOLUME
            G.EFFECT_VOLUME = float(float(pos) / 100)
        sb = self.Scrollbar(x=0, y=0, width=300, height=40, sb_width=20, sb_height=40, caption="Sound", pos=int(G.EFFECT_VOLUME * 100), on_pos_change=change_sound_volume)
        hl.add(sb)
        self.layout.add(hl)

        hl = HorizontalLayout(0, 0)
        button = self.Button(width=300, caption=G._("Controls..."), on_click=self.controller.controls)
        hl.add(button)
        self.buttons.append(button)
        button = self.Button(width=300, caption=G._("Textures"), on_click=self.controller.textures, enabled=textures_enabled)
        hl.add(button)
        self.buttons.append(button)
        self.layout.add(hl)

        button = self.Button(width=610, caption=G._("Done"), on_click=self.controller.main_menu)
        self.layout.add(button)
        self.buttons.append(button)

        self.label = Label('Options', font_name='ChunkFive Roman', font_size=25, x=width/2, y=self.frame.y + self.frame.height,
            anchor_x='center', anchor_y='top', color=(255, 255, 255, 255), batch=self.batch,
            group=self.labels_group)

        self.on_resize(width, height)
Ejemplo n.º 7
0
    def setup(self):
        MenuView.setup(self)
        width, height = self.controller.window.width, self.controller.window.height

        self.layout = VerticalLayout(0, 0)

        self.key_buttons = []
        for identifier in ('move_backward', 'move_forward', 'move_left', 'move_right'):
            button = self.ToggleButton(width=200, caption=pyglet.window.key.symbol_string(getattr(G, identifier.upper() + '_KEY')))
            button.id = identifier
            self.buttons.append(button)
            self.key_buttons.append(button)
        self.button_return = self.Button(caption=G._("Done"),on_click=self.controller.game_options)
        self.buttons.append(self.button_return)

        self.on_resize(width, height)
Ejemplo n.º 8
0
    def setup(self):
        MenuView.setup(self)
        width, height = self.controller.window.width, self.controller.window.height

        self.layout = VerticalLayout(0, 0)

        self.key_buttons = []
        for identifier in ('move_backward', 'move_forward', 'move_left', 'move_right'):
            button = self.ToggleButton(width=200, caption=pyglet.window.key.symbol_string(getattr(G, identifier.upper() + '_KEY')))
            button.id = identifier
            self.buttons.append(button)
            self.key_buttons.append(button)
        self.button_return = self.Button(caption=G._("Done"),on_click=self.controller.game_options)
        self.buttons.append(self.button_return)

        self.on_resize(width, height)