Example #1
0
    def __init__(self, screen, data):
        self.data = data       
        self.gun_data = self.data["gun_data"]
        self.screen = screen
        self.change_gun = 0             # 現在選択している装備場所
        self.screen_info = pygame.font.Font("freesansbold.ttf" ,70).render("Shop", True, (255,255,255))
        self.back_info = pygame.font.Font("freesansbold.ttf" ,50).render("'Q' : Back", True, (255,255,255))

        self.gun_value = [1000, 1000, 1000, 1000, 1000, 1000]

        texts = [data["name"] for data in self.gun_data.values()]
        del texts[0]
        
        self.listbox = ListBox(self.screen, 80, 150, 300, 250, texts, font_size=40, target=True)
        self.listbox.set_selectable([data["own"]==1 for data in self.gun_data.values()])

        self.clock = pygame.time.Clock()
Example #2
0
    def __init__(self, screen, data):
        # データを保持
        self.gun_data = data["gun_data"]
        self.equipment = data["equip"]
        self.chip_data = data["chip_data"]
        self.chip = data["chip"]
        # スクリーンの保持
        self.screen = screen
        # 選択の初期値
        self.change_gun = 0  # 現在選択している装備場所
        self.change_chip = 0
        self.change_id = 0
        self.back = False  # 一つ前の画面にもどるか
        # 操作の表記
        self.screen_info = pygame.font.Font("font/freesansbold.ttf",
                                            70).render("Equip", True,
                                                       (255, 255, 255))
        self.back_info = pygame.font.Font(
            "font/ShipporiMincho-TTF-Regular.ttf",
            50).render("'Q' : 戻る", True, (255, 255, 255))
        self.change_info = pygame.font.Font(
            "font/ShipporiMincho-TTF-Regular.ttf",
            50).render("'C' : 切り替え", True, (255, 255, 255))
        # リストボックスの作成
        # Gun
        texts = [data["name"] for data in self.gun_data.values()]
        equip_listbox = ListBox(self.screen, 80, 200, 300, 250, texts, font_size=40, target=True,\
                                     title="Gun", title_size=60)
        equip_listbox.set_selectable(
            [data["own"] == 1 for data in self.gun_data.values()])
        # Chip
        texts = [data['name'] for data in self.chip_data.values()]
        chip_listbox = ListBox(self.screen, 80, 200, 300, 250, texts, font_size=40, target=True,\
                                     title="Chip", title_size=60)
        chip_listbox += ['remove', 'remove ALL']
        # 両方をリストに格納し、選択された方を描画
        self.listboxes = [equip_listbox, chip_listbox]
        self.listbox = self.listboxes[self.change_id]
        # 現在の装備状況を描画するイメージボックスの作成
        self.gun_image_box = ImageBox(screen, 700, 450, 90, 90, 3)
        self.chip_image_box = ImageBox(screen, 500, 450, 90, 90, 6)

        self.text_box = TextBox(screen, 550, 200, 550, 200, font_size=30)
        # 時間管理
        self.clock = pygame.time.Clock()
Example #3
0
    def __init__(self, screen, data):
        self.screen = screen
        self.data = data

        self.stage_num = 1
        self.select_num = 0
        self.option_num = 0
        self.path = glob('stage/*/')
        self.new_path = []

        for i in range(len(self.path)):
            self.new_path.append(self.path[i].strip('stage\/'))

        StageSelect_font = pygame.font.Font("font/freesansbold.ttf", 55)
        Arrow_font = pygame.font.Font("font/freesansbold.ttf", 100)
        self.Stage_font = pygame.font.Font("font/freesansbold.ttf", 45)

        self.StageSelect_text = StageSelect_font.render("Stage Select", True, (255,255,255)) 
        self.RightArrow_text = Arrow_font.render(">", True, (255,255,255))
        self.LeftArrow_text = Arrow_font.render("<", True, (255,255,255))
        self.RightArrow_text = pygame.transform.rotate(self.RightArrow_text, 90)
        self.LeftArrow_text = pygame.transform.rotate(self.LeftArrow_text, 90)
        # ステージのテキスト情報をリストにする
        self.stage_text = [None]
        '''for i in range(3):
            text = "Stage" + str(i+1)
            self.stage_text.append(Stage_font.render(text, True, (255,255,255)))
'''
        # リストボックスの設定
        self.option_listbox = ListBox(self.screen, 50, 80, 250, 200, ['Back', 'Shop', 'Equip'], font_size=55, title="Menu")
        self.option_listbox.set_selectable([True, True, True])
        self.file_listbox = ListBox(self.screen, 940, 80, 120, 400, self.new_path, title="File")
    
        self.file_listbox.set_selectable([True, True])
        self.file_listbox()
        self.file_id = None

        # メッセージボックスの設定
        self.messagebox = MessageBox(self.screen, 130, 540, 900,  outline_color=(180,180,180), select='random')
        with open('data/message.txt', 'r', encoding='utf-8') as fp:
            self.messagebox += fp.readlines()

        self.clock = pygame.time.Clock()
Example #4
0
class Shop:
    def __init__(self, screen, data):
        self.data = data       
        self.gun_data = self.data["gun_data"]
        self.screen = screen
        self.change_gun = 0             # 現在選択している装備場所
        self.screen_info = pygame.font.Font("freesansbold.ttf" ,70).render("Shop", True, (255,255,255))
        self.back_info = pygame.font.Font("freesansbold.ttf" ,50).render("'Q' : Back", True, (255,255,255))

        self.gun_value = [1000, 1000, 1000, 1000, 1000, 1000]

        texts = [data["name"] for data in self.gun_data.values()]
        del texts[0]
        
        self.listbox = ListBox(self.screen, 80, 150, 300, 250, texts, font_size=40, target=True)
        self.listbox.set_selectable([data["own"]==1 for data in self.gun_data.values()])

        self.clock = pygame.time.Clock()

    def do(self):
        while True:
            self.clock.tick(30)
            request = self.process()
            self.draw()
            if request != CONTINUE:
                return request

    def process(self):
        # 内部処理
        self.listbox()
        for event in pygame.event.get():
            select = self.listbox.process(event)
            if event.type == QUIT:
                return EXIT
            if event.type == KEYDOWN:    
                if event.key == K_q:
                    return BACK
                self.change_gun = (self.change_gun + 3) % 3
                
        return CONTINUE

    def draw(self):
        # 画面描画
        self.screen.fill((0,0,0))
        self.screen.blit(self.screen_info, [150, 20])
        self.screen.blit(self.back_info, [WIDTH-self.back_info.get_rect().right-20, 20])
        
        self.listbox.color_reset()
        self.listbox.draw()
        pygame.display.update()

    def Buy(self):
        data = self.data['gun_data']
        if data[self.gun_num]['own'] == 0:
            if self.data['money'] >= self.gun_value[self.gun_num - 1]:
                self.data['money'] -= self.gun_value[self.gun_num - 1]
                data[self.gun_num]['own'] = 1
Example #5
0
class SelectMapPanel(SpriteContainer):
    def __init__(self, select, back):
        super(SelectMapPanel,self).__init__()
        self.background = ImageSprite(images["selectmap"])
        self.add(self.background)
        
        self.buttons = pygame.sprite.Group()
        self.selectButton = RA2Button("Select")
        self.selectButton.setpos(menubuttonx,menubuttony)
        self.selectButton.setMouseListener(select)
        self.buttons.add(self.selectButton)
        
        self.backButton = RA2Button("Back")
        self.backButton.setpos(menubuttonx,self.selectButton.bottom())
        self.backButton.setMouseListener(back)
        self.buttons.add(self.backButton)
        
        self.listBox = ListBox()
        self.listBox.addItem("map0.txt")
        self.listBox.addItem("map1.txt")
        self.listBox.addItem("map2.txt")
        self.listBox.addItem("map3.txt")
        self.listBox.setpos(listboxx,listboxy)
    
    def onMouseDown(self,x,y,button):
        self.listBox.onMouseDown(x,y-self.listBox.y-boxpad)
        self.selectButton.onMouseDown(x,y,button)
        self.backButton.onMouseDown(x,y,button)
        
    def onMouseUp(self,x,y,button):
        self.selectButton.onMouseUp(x,y,button)
        self.backButton.onMouseUp(x,y,button)
        
    def onMouseMove(self,x,y,button1=None,button2=None,button3=None):
        self.selectButton.onMouseMove(x,y)
        self.backButton.onMouseMove(x,y)
    
    def draw(self,screen):
        super(SelectMapPanel,self).draw(screen)
        self.listBox.draw(screen)
        self.buttons.draw(screen)
def get_listbox(Items=None,
                ItemIndex=0,
                ItemHeight=15,
                widget_name='MyChoice',
                Left=0,
                Height=100,
                Top=0,
                Width=200,
                TopMargin=10,
                RightMargin=10,
                BottomMargin=10,
                LeftMargin=10,
                has_OnClick=False,
                has_OnSelectionChange=True):

    return ListBox(**key_word_args(LISTBOX_PARAML, locals()))
Example #7
0
 def __init__(self, select, back):
     super(SelectMapPanel,self).__init__()
     self.background = ImageSprite(images["selectmap"])
     self.add(self.background)
     
     self.buttons = pygame.sprite.Group()
     self.selectButton = RA2Button("Select")
     self.selectButton.setpos(menubuttonx,menubuttony)
     self.selectButton.setMouseListener(select)
     self.buttons.add(self.selectButton)
     
     self.backButton = RA2Button("Back")
     self.backButton.setpos(menubuttonx,self.selectButton.bottom())
     self.backButton.setMouseListener(back)
     self.buttons.add(self.backButton)
     
     self.listBox = ListBox()
     self.listBox.addItem("map0.txt")
     self.listBox.addItem("map1.txt")
     self.listBox.addItem("map2.txt")
     self.listBox.addItem("map3.txt")
     self.listBox.setpos(listboxx,listboxy)
Example #8
0
class Menu:
    
    def __init__(self, screen, data):
        self.screen = screen
        self.data = data

        self.stage_num = 1
        self.select_num = 0
        self.option_num = 0
        self.path = glob('stage/*/')
        self.new_path = []

        for i in range(len(self.path)):
            self.new_path.append(self.path[i].strip('stage\/'))

        StageSelect_font = pygame.font.Font("font/freesansbold.ttf", 55)
        Arrow_font = pygame.font.Font("font/freesansbold.ttf", 100)
        self.Stage_font = pygame.font.Font("font/freesansbold.ttf", 45)

        self.StageSelect_text = StageSelect_font.render("Stage Select", True, (255,255,255)) 
        self.RightArrow_text = Arrow_font.render(">", True, (255,255,255))
        self.LeftArrow_text = Arrow_font.render("<", True, (255,255,255))
        self.RightArrow_text = pygame.transform.rotate(self.RightArrow_text, 90)
        self.LeftArrow_text = pygame.transform.rotate(self.LeftArrow_text, 90)
        # ステージのテキスト情報をリストにする
        self.stage_text = [None]
        '''for i in range(3):
            text = "Stage" + str(i+1)
            self.stage_text.append(Stage_font.render(text, True, (255,255,255)))
'''
        # リストボックスの設定
        self.option_listbox = ListBox(self.screen, 50, 80, 250, 200, ['Back', 'Shop', 'Equip'], font_size=55, title="Menu")
        self.option_listbox.set_selectable([True, True, True])
        self.file_listbox = ListBox(self.screen, 940, 80, 120, 400, self.new_path, title="File")
    
        self.file_listbox.set_selectable([True, True])
        self.file_listbox()
        self.file_id = None

        # メッセージボックスの設定
        self.messagebox = MessageBox(self.screen, 130, 540, 900,  outline_color=(180,180,180), select='random')
        with open('data/message.txt', 'r', encoding='utf-8') as fp:
            self.messagebox += fp.readlines()

        self.clock = pygame.time.Clock()

    def draw(self):
        while True:
            self.clock.tick(30)
            # リストボックスの描画
            self.option_listbox.draw(False)
            self.file_listbox.draw()
            self.Select_Stage(self.file_id)     #ステージ選択処理
            self.messagebox.draw()
            pygame.display.update()
            for event in pygame.event.get():
                # リストボックスに入力
                file_id = self.file_listbox.process(event)
                option_num = self.option_listbox.process(event)
                if event.type == KEYDOWN:
                    self.Key_Event(event)       #押されたキーによって異なる処理
                    if event.key == K_RETURN and self.select_num == 1 and self.file_id != None:
                        return self.Return_Stage(self.stage_path[self.stage_num])
                if event.type == QUIT:
                    return EXIT, None

                if file_id != None:
                    # ファイルが選択されたとき
                    self.file_id = file_id
                    self.stage_path = glob(self.path[self.file_id] + '/*')
                    
                    self.stage_text = self.stage_path
                    self.stage_said_text = []

                    for i, _ in enumerate(self.stage_text):
                        self.stage_said_text.append("Stage" + str(i+1))

                    self.select_num += 1
                    # file_listboxからターゲットを外す
                    self.file_listbox.process(event)
                    self.stage_num = 0

                if option_num != None:
                    # オプションが選択されたとき
                    if option_num == 0:
                        return None, '0'
                    elif option_num == 1:
                        Shop(self.screen, self.data).do()
                        break
                    elif option_num == 2:
                        if Equipment(self.screen, self.data).do() == EXIT:
                            return EXIT, None
                        break
                
            self.screen.fill((0,0,0))
            
    
    def Select_Stage(self, file_id):
        #選択しているステージを描画
        color = (self.select_num==1)*(255,100,100) or (100,100,100)
        pygame.draw.rect(self.screen,color,Rect(350,80,550,450))
        self.screen.blit(self.StageSelect_text, [350, 20])     #テキストStageSelectを描画
        # ステージファイルが選択されていないとき、ステージを表示しない
        if file_id != None:
            color = [(0,0,255),(0,255,0), (255,0,0)]
            text = self.Stage_font.render(self.stage_said_text[self.stage_num], True, (255,)*3)
            self.screen.blit(text, [410, 190])
            pygame.draw.rect(self.screen,color[self.stage_num-1],Rect(400,180,450,250),5)
            self.screen.blit(self.RightArrow_text, [575, 120])  #テキスト > を描画
            self.screen.blit(self.LeftArrow_text, [575, 430])     #テキスト > を描画
    
    def Key_Event(self,event):
        # 左右キーで大枠の選択
        if event.key == K_RIGHT:
            self.select_num -= 1
        elif event.key == K_LEFT:
            self.select_num += 1
        self.select_num = (self.select_num+3) % 3
        # リストボックスが選択されているとき、ターゲットする
        if self.select_num == 0:
            self.file_listbox()
        elif self.select_num == 2:
            self.option_listbox()
        # ステージ選択のとき、上下キーでステージ選択の移動
        if event.key == K_UP:
            self.stage_num -= (self.select_num==1)
        elif event.key == K_DOWN:
            self.stage_num += (self.select_num==1)
        stage_size = len(self.stage_text)
        self.stage_num = (self.stage_num+stage_size) % stage_size
    
    def Return_Stage(self, path):
        return self.stage_num, path