예제 #1
0
    def drawSlide(self, surf):
        mainSlideSurf = MenuFunctions.CreateBaseMenuSurf(
            (GC.WINWIDTH + 8, 6 * GC.WINHEIGHT / 10 + 8),
            'ClearMenuBackground')
        surf.blit(mainSlideSurf, (0 - 4, GC.WINHEIGHT / 5))

        if self.state.getState() == 'Config' or (
                self.state.getState() == 'TopMenu'
                and self.currentSelection == 0):
            config_font = GC.FONT['text_blue']
            controls_font = GC.FONT['text_grey']
        else:
            config_font = GC.FONT['text_grey']
            controls_font = GC.FONT['text_blue']

        configSlideSurf = MenuFunctions.CreateBaseMenuSurf(
            (GC.WINWIDTH / 2 - 8, 24), 'ClearMenuBackground')
        surf.blit(configSlideSurf, (4, 4))
        config_position = (4 + configSlideSurf.get_width() / 2 -
                           config_font.size('Config')[0] / 2,
                           16 - config_font.size('Config')[1] / 2)
        config_font.blit(cf.WORDS['Config'], surf, config_position)

        controlsSlideSurf = MenuFunctions.CreateBaseMenuSurf(
            (GC.WINWIDTH / 2 - 8, 24), 'ClearMenuBackground')
        surf.blit(controlsSlideSurf, (GC.WINWIDTH / 2 + 4, 4))
        controls_position = (GC.WINWIDTH / 2 + 4 +
                             controlsSlideSurf.get_width() / 2 -
                             controls_font.size('Controls')[0] / 2,
                             16 - controls_font.size('Controls')[1] / 2)
        controls_font.blit(cf.WORDS['Controls'], surf, controls_position)
예제 #2
0
    def draw(self, surf, gameStateObj):
        self.write_index = 6
        if not self.surf:
            bg_surf = MenuFunctions.CreateBaseMenuSurf(
                self.size, 'BaseMenuBackgroundOpaque')
            self.surf = Engine.create_surface(
                (self.size[0] + 2, self.size[1] + 4),
                convert=True,
                transparent=True)
            self.surf.blit(bg_surf, (2, 4))
            self.surf.blit(GC.IMAGESDICT['SmallGem'], (0, 0))
            Image_Modification.flickerImageTranslucent(self.surf, 10)
        BGSurf = self.surf.copy()

        # Center it
        pos = surf.get_width() // 2 - self.size[0] // 2 - 2, surf.get_height(
        ) // 2 - self.size[1] // 2 - 4
        # Blit words
        for index, word in enumerate(self.banner):
            word_width = GC.FONT[self.banner_font[index]].size(word)[0]
            GC.FONT[self.banner_font[index]].blit(
                word, BGSurf, (self.write_index,
                               self.size[1] // 2 - self.font_height // 2 + 4))
            self.write_index += word_width
        # Blit item icon
        if self.item:
            self.item.draw(BGSurf, (self.size[0] - 6 - 16 - 2, 4 + 4),
                           cooldown=False)
        surf.blit(BGSurf, pos)
예제 #3
0
    def draw(self, gameStateObj):
        text_lines = self.split_string(self.eval_string(self.display_name_string, gameStateObj))

        longest_surf_width = self.get_size(text_lines)

        if longest_surf_width != self.surf_width or len(text_lines) != self.num_lines:
            self.num_lines = len(text_lines)
            self.surf_width = longest_surf_width
            surf_height = 16 * self.num_lines + 8

            # Blit background
            BGSurf = MenuFunctions.CreateBaseMenuSurf((self.surf_width + 16, surf_height), 'BaseMenuBackgroundOpaque')
            if self.num_lines == 1:
                BGSurf.blit(GC.IMAGESDICT['Shimmer1'], (BGSurf.get_width() - 1 - GC.IMAGESDICT['Shimmer1'].get_width(), 4))
            elif self.num_lines == 2:
                BGSurf.blit(GC.IMAGESDICT['Shimmer2'], (BGSurf.get_width() - 1 - GC.IMAGESDICT['Shimmer2'].get_width(), 4))
            self.BGSurf = Engine.create_surface((BGSurf.get_width(), BGSurf.get_height() + 3), transparent=True, convert=True)
            self.BGSurf.blit(BGSurf, (0, 3))
            gem = GC.IMAGESDICT['BlueCombatGem']
            self.BGSurf.blit(gem, (BGSurf.get_width()//2 - gem.get_width()//2, 0))
            # Now make translucent
            self.BGSurf = Image_Modification.flickerImageTranslucent(self.BGSurf, 20)

        temp_surf = self.BGSurf.copy()
        for index, line in enumerate(text_lines):
            position = temp_surf.get_width()//2 - GC.FONT['text_white'].size(line)[0]//2, 16 * index + 6
            GC.FONT['text_white'].blit(line, temp_surf, position)

        return temp_surf
예제 #4
0
    def create_help_box(self):
        if self.weapon or self.spell:
            font1 = GC.FONT['text_blue']
            font2 = GC.FONT['text_yellow']

            if self.weapon:
                first_line_text = [' ', self.weapon.LVL, ' Mt ', str(self.weapon.MT), ' Hit ', str(self.weapon.HIT)]
                if cf.CONSTANTS['crit']:
                    first_line_text += [' Crit ', str(self.crit) if self.crit is not None else '--']
                if self.weight:
                    first_line_text += [' Wt ', str(self.weight)]
                first_line_text += [' Rng ', self.strRNG]
                first_line_font = [font1, font1, font2, font1, font2, font1]
                if cf.CONSTANTS['crit']:
                    first_line_font += [font2, font1]
                if self.weight:
                    first_line_font += [font2, font1]
                first_line_font += [font2, font1]

            elif self.spell:
                first_line_text = [' ', self.spell.LVL]
                first_line_font = [font1, font1]
                if self.damage is not None:
                    first_line_text += [' Mt ', str(self.damage)]
                    first_line_font += [font2, font1]
                if self.hit is not None:
                    first_line_text += [' Hit ', str(self.hit)]
                    first_line_font += [font2, font1]
                if cf.CONSTANTS['crit'] and self.crit is not None:
                    first_line_text += [' Crit ', str(self.crit)]
                    first_line_font += [font2, font1]
                first_line_text += [' Rng ', self.strRNG]
                first_line_font += [font2, font1]

            first_line_length = max(font1.size(''.join(first_line_text))[0] + (16 if self.icon else 0) + 4, 112) # 112 was 96
            if self.desc:
                output_desc_lines = TextChunk.line_wrap(TextChunk.line_chunk(self.desc), first_line_length, GC.FONT['convo_black']) 
            else:
                output_desc_lines = ''
            size_x = first_line_length + 16
            size_y = 24 + len(output_desc_lines)*16
            help_surf = MenuFunctions.CreateBaseMenuSurf((size_x, size_y), 'MessageWindowBackground')  
            self.drawType(help_surf, 4, 4)
            
            # Actually blit first line
            word_index = 20 if self.icon else 4
            for index, word in enumerate(first_line_text):
                first_line_font[index].blit(word, help_surf, (word_index, 4))
                word_index += first_line_font[index].size(word)[0]
            
            for index, line in enumerate(output_desc_lines):
                GC.FONT['convo_black'].blit(''.join(line), help_surf, (4, GC.FONT['convo_black'].height*index + 4 + 16))  

            return help_surf

        else:
            return InfoMenu.create_help_box(self.desc)
예제 #5
0
 def drawInvalid(self, surf):
     size_of_text = GC.FONT['text_white'].size("Invalid Choice!")
     width = size_of_text[0]
     height = size_of_text[1]
     pop_up_surf = MenuFunctions.CreateBaseMenuSurf((width + 16 - width%8, height + 16 - height%8))
     surf.blit(Image_Modification.flickerImageTranslucent(GC.IMAGESDICT['BlackBackground'].copy(), 60), (0, 0))
     topleft = (GC.WINWIDTH//2 - pop_up_surf.get_width()//2, GC.WINHEIGHT//2 - pop_up_surf.get_height()//2)
     surf.blit(pop_up_surf, topleft)
     position = (GC.WINWIDTH//2 - width//2, GC.WINHEIGHT//2 - height//2)
     GC.FONT['text_white'].blit(cf.WORDS["Invalid Choice"], surf, position)
예제 #6
0
    def begin(self, gameStateObj, metaDataObj):
        if not self.started:
            # Get units to display
            self.units = [unit for unit in gameStateObj.allunits if unit.position and unit.team == 'player']

            self.bg_surf = Image_Modification.flickerImageTranslucent(GC.IMAGESDICT['UnitMenuBackground'], 10)
            self.title_bg = Image_Modification.flickerImageTranslucent(GC.IMAGESDICT['TitleBar'], 10)
            self.background = MenuFunctions.MovingBackground(GC.IMAGESDICT['RuneBackground'])
            self.states = [('Character', ['Class', 'Lv', 'Exp', 'HP', 'Max'], [4, 66, 89, 113, 133]),
                           ('Fighting Skill', ['STR', 'MAG', 'SKL', 'SPD', 'LCK', 'DEF', 'RES'], [4, 26, 48, 71, 94, 119, 142]),
                           ('Equipment', ['Equip', 'Atk', 'Hit', 'Avoid'], [16, 72, 103, 136]),
                           ('Personal Data', ['MOV', 'CON', 'Aid', 'Rat', 'Trv'], [4, 33, 60, 82, 106]),
                           ('Weapon Level', Weapons.TRIANGLE.types, [9 + idx*16 for idx in range(len(Weapons.TRIANGLE.types))])]
            if cf.CONSTANTS['support']:
                self.states.append(('Support Chance', ['Ally'], [0]))
            self.state_index = 0
            self.prev_state_index = 0
            self.unit_index = 1 # 0 means on banner
            self.scroll_index = 1
            self.banner_index = 0
            self.num_per_page = 6

            self.state_scroll = 0
            self.scroll_direction = 0

            self.weapon_icons = [Weapons.Icon(weapon) for weapon in Weapons.TRIANGLE.types]
            self.help_boxes = []
            self.info = False

            self.scroll_bar = GUIObjects.ScrollBar((233, 59))
            self.left_arrow = GUIObjects.ScrollArrow('left', (7, 41))
            self.right_arrow = GUIObjects.ScrollArrow('right', (GC.WINWIDTH - 7 - 8, 41), 0.5)

            # For sort
            self.current_sort = 'Name'
            self.descending = False
            self.sort_surf = MenuFunctions.CreateBaseMenuSurf((64, 24))
            self.sort_surf = Image_Modification.flickerImageTranslucent(self.sort_surf, 10)
            self.sort_arrow_counter = Counters.ArrowCounter()
            self.sort_arrow_counter.arrow_anim = [0, 1, 2]
            self.sort()

            # Transition in:
            gameStateObj.stateMachine.changeState("transition_in")
            return 'repeat'
        else:
            chosen_unit = gameStateObj.info_menu_struct['chosen_unit']
            if chosen_unit and chosen_unit in self.units:
                self.move_to_unit(chosen_unit)
            gameStateObj.info_menu_struct['chosen_unit'] = None
    def __init__(self, item):
        self.last_time = self.start_time = 0
        self.transition_in = self.transition_out = False
        self.item = item
        font1 = GC.FONT['text_blue']
        font2 = GC.FONT['text_yellow']

        if self.item.weapon:
            self.first_line_text = [' ', self.item.weapon.LVL, ' Mt ', str(self.item.weapon.MT), ' Hit ', str(self.item.weapon.HIT)]
            if cf.CONSTANTS['crit']:
                self.first_line_text += [' Crit ', str(self.item.crit) if self.item.crit is not None else '--']
            if self.item.weight:
                self.first_line_text += [' Wt ', str(self.item.weight)]
            self.first_line_text += [' Rng ', self.item.strRNG]
            self.first_line_font = [font1, font1, font2, font1, font2, font1]
            if cf.CONSTANTS['crit']:
                self.first_line_font += [font2, font1]
            if self.item.weight:
                self.first_line_font += [font2, font1]
            self.first_line_font += [font2, font1]

        elif self.item.spell:
            self.first_line_text = [' ', self.item.spell.LVL]
            self.first_line_font = [font1, font1]
            if self.item.damage is not None:
                self.first_line_text += [' Mt ', str(self.item.damage)]
                self.first_line_font += [font2, font1]
            if self.item.hit is not None:
                self.first_line_text += [' Hit ', str(self.item.hit)]
                self.first_line_font += [font2, font1]
            if cf.CONSTANTS['crit'] and self.item.crit is not None:
                self.first_line_text += [' Crit ', str(self.item.crit)]
                self.first_line_font += [font2, font1]
            self.first_line_text += [' Rng ', self.item.strRNG]
            self.first_line_font += [font2, font1]

        first_line_length = max(font1.size(''.join(self.first_line_text))[0] + (16 if self.item.icon else 0) + 4, 112) # 112 was 96
        if self.item.desc:
            self.output_desc_lines = TextChunk.line_wrap(TextChunk.line_chunk(self.item.desc), first_line_length, GC.FONT['convo_black']) 
            self.output_desc_lines = [''.join(line) for line in self.output_desc_lines]
        else:
            self.output_desc_lines = []
        size_x = first_line_length + 24
        size_y = 32 + len(self.output_desc_lines)*16
        self.help_surf = MenuFunctions.CreateBaseMenuSurf((size_x, size_y), 'MessageWindowBackground')  
        self.h_surf = Engine.create_surface((size_x, size_y + 3), transparent=True)
예제 #8
0
    def drawInfo(self, surf):
        mainInfoSurf = MenuFunctions.CreateBaseMenuSurf((GC.WINWIDTH - 32, 24), 'BaseMenuBackground')
        surf.blit(mainInfoSurf, (16, GC.WINHEIGHT - 24))

        if self.state.getState() == "Config":
            info_text = self.config[self.currentSelection][2]
        elif self.state.getState() == "Controls":
            info_text = cf.WORDS['Controls_desc']
        elif self.state.getState() == "Get_Input":
            info_text = cf.WORDS['Get_Input_desc']
        elif self.state.getState() == "TopMenu":
            if self.currentSelection == 0:
                info_text = cf.WORDS['Config_desc']
            else:
                info_text = cf.WORDS['Controls_desc']
        else:
            return
        GC.FONT['text_white'].blit(info_text, surf, (32, GC.WINHEIGHT - 20))