コード例 #1
0
ファイル: demo.py プロジェクト: DumasDED/RoadRigCLI
def demo(screen, scene):
    frame = Frame(screen,
                  screen.height // 3,
                  screen.width // 3,
                  hover_focus=True,
                  has_border=False,
                  title="Main Menu")

    frame.palette = palette

    layout3 = Layout([100])
    frame.add_layout(layout3)

    layout3.add_widget(Label("Test"), 0)
    layout3.add_widget(Divider(draw_line=False))

    layout1 = Layout([100], fill_frame=True)
    frame.add_layout(layout1)

    layout1.add_widget(
        ListBox(Widget.FILL_FRAME, [("One", 1), ("Two", 3), ("Three", 2),
                                    ("Four", 4), ("Five", 5), ("Six", 6),
                                    ("Seven", 7), ("Eight", 8), ("Nine", 9),
                                    ("Ten", 10), ("Eleven", 11),
                                    ("Twelve", 12), ("Thirteen", 13),
                                    ("Fourteen", 14), ("Fifteen", 15),
                                    ("Sixteen", 16), ("Seventeen", 17),
                                    ("Eighteen", 18), ("Nineteen", 19),
                                    ("Twenty", 20), ("Loop", 1)],
                name="List Thing"))
    layout1.add_widget(Divider(draw_line=False))

    layout2 = Layout([1, 1, 1, 1])
    frame.add_layout(layout2)

    layout2.add_widget(Button("OK", leave), 1)
    layout2.add_widget(Button("Cancel", leave), 2)

    frame.fix()

    scenes = [Scene([frame], -1, name="Test")]

    screen.play(scenes, stop_on_resize=True, start_scene=scene)
コード例 #2
0
def MainMenu(game, screen, debug, oldpalette):
    def endgame():
        screen.close()
        quit()
        sys.exit(0)
        None

    def endmenu():
        debug[0] = False
        game = GameState.GameState()
        game.hero.inventory = []
        Mmenu.save()
        looksy = Mmenu.data
        if looksy['seedval'] != "":
            converted = 0
            if str.isnumeric(looksy['seedval']):
                game.seed = int(looksy['seedval'])
            else:
                for char in looksy['seedval']:
                    converted += ord(char)
                game.seed = int(converted)
        random.seed(game.seed)
        if looksy['nameval'] != "":
            if len(looksy["nameval"]) >= 20:
                game.name = str(looksy['nameval'])[:21]
            else:
                game.name = str(looksy['nameval'])
        debug[0] = looksy['Debug']
        #visual.blackout(screen)
        main(game, debug, looksy, screen)
        test1.deadscreen(game, screen)
        DeathMenu(game, screen, debug, oldpalette)
        return Mmenu.data

    endval = True
    Mmenu = Frame(screen,
                  screen.height * 2 // 3,
                  screen.width * 2 // 3,
                  hover_focus=True,
                  has_border=True,
                  title="Game Settings",
                  reduce_cpu=False)

    #Mmenu.palette['background'] = (0,0,1)
    Mmenu.palette = oldpalette
    mapping = Layout([100], fill_frame=True)
    Mmenu.add_layout(mapping)
    mapping.add_widget(Text("Seed:", "seedval"))
    mapping.add_widget(Text("Adventurer Name:", "nameval"))
    mapping.add_widget(CheckBox("Debug Mode:", "Debug", "Debug"))

    bottomrow = Layout([1, 1, 1, 1])
    Mmenu.add_layout(bottomrow)
    bottomrow.add_widget(Button("Exit Game", endgame), 0)
    bottomrow.add_widget(Button("Start Level", endmenu), 3)
    Mmenu.fix()

    #Mmenu._on_pic

    Scenes = [Scene([Mmenu], -1)]

    screen.play(Scenes)
    return Mmenu.data