Пример #1
0
def update(dt):
    # Start rendering a new frame
    imgui.new_frame()

    ### MENU BAR BEGIN ###
    if imgui.begin_main_menu_bar():
        if imgui.begin_menu("File", True):
            clicked_quit, selected_quit = imgui.menu_item(
                "Quit", "Esc", False, True)
            if clicked_quit:
                exit(1)
            imgui.end_menu()
        # End rendering the menu bar
        imgui.end_main_menu_bar()
    if quit_the_app:
        exit(1)
    ### MENU BAR END ###

    # Show a basic test window, if you want
    # show_test_window()

    # TODO: Do any imgui stuff you want here. Here's a simple example...
    # imgui.begin("My Cool Sub-Window", True) # start rendering a sub-window
    # imgui.set_window_size(window_width / 2, window_height) # take up half the screen
    # imgui.text("Here's some awesome text!") # render some text
    # if imgui.button("Click Me!"): # buttons are rendered and checked for clicks in one line!
    #     imgui.text("Button clicked!")
    # imgui.end() # end the sub-window

    # Clear the OpenGL buffer for the background color.
    gl.glClearColor(1, 1, 1, 1)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
Пример #2
0
    def update(dt):
        imgui.new_frame()
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        show_test_window()
        #imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)

        imgui.text_ansi("B\033[31marA\033[mnsi ")
        imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1., 0.)

        imgui.end()
Пример #3
0
    def render_ui(self):
        """Render the UI"""
        imgui.new_frame()
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        # Create window with the framebuffer image
        imgui.begin("Custom window with Image", True)
        # Create an image control by passing in the OpenGL texture ID (glo)
        # and pass in the image size as well.
        # The texture needs to he registered using register_texture for this to work
        imgui.image(self.fbo.color_attachments[0].glo, *self.fbo.size)
        imgui.end()

        imgui.render()
        self.imgui.render(imgui.get_draw_data())
Пример #4
0
    def draw(self, *args, **kwargs):
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        gl.glClearColor(1., 1., 1., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
Пример #5
0
 def menu_bar(self):
     if imgui.begin_main_menu_bar():
         if imgui.begin_menu("File", True):
             clicked_quit, selected_quit = imgui.menu_item(
                 "Quit", 'Cmd+Q', False, True)
             if clicked_quit:
                 self.cleanup()
                 exit(0)
             imgui.end_menu()
         changed, value = imgui.input_text("", self.input_text, 30)
         if changed:
             imgui.set_next_window_position(imgui.get_item_rect_min().x,
                                            imgui.get_item_rect_max().y)
             imgui.set_next_window_size(imgui.get_item_rect_size().x, 0)
             if imgui.begin(
                     "##popup", False, imgui.WINDOW_NO_TITLE_BAR
                     | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE):
                 for index, row in self.symbol_list.iterrows():
                     if value.upper() in row[0]:
                         _, _ = imgui.selectable(row[0] + " - " + row[2])
                         if imgui.is_item_clicked():
                             self.input_text = row[0]
                             self.load_symbol(str(row[0]).lower())
             imgui.end()
         imgui.end_main_menu_bar()
Пример #6
0
    def render_ui(self, time, rotation, translation, model):
        imgui.new_frame()
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", '', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        # imgui.show_test_window()
        imgui.begin("Custom window", True)
        value = self.slider_value
        changed, changed_value = imgui.slider_int(
            "slide ints", value,
            min_value=0, max_value=100,
            format="%d"
        ) 
        if changed:
            self.slider_value = changed_value
        imgui.text(string("time: \n", time))
        imgui.text(string("rotation: \n", rotation))
        imgui.text(string("translation: \n", translation))
        imgui.text(string("model = translation * rotation: \n", model))
        imgui.end()

        imgui.render()
        self.imgui.render(imgui.get_draw_data())
Пример #7
0
def main(recfile):
    imgui.create_context()
    window = impl_glfw_init()
    impl = GlfwRenderer(window)
    slamgui = SLAMGUI(recfile)

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):
                clicked_quit, _ = imgui.menu_item("Quit", 'Cmd+Q', False, True)
                if clicked_quit:
                    exit(0)
                imgui.end_menu()
            imgui.end_main_menu_bar()

        slamgui.render()
        gl.glClearColor(0, 0, 0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        impl.render(imgui.get_draw_data())
        glfw.swap_buffers(window)

    impl.shutdown()
    glfw.terminate()
Пример #8
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        if imgui.begin_main_menu_bar():
            # first menu dropdown
            if imgui.begin_menu('File', True):
                imgui.menu_item('New', 'Ctrl+N', False, True)
                imgui.menu_item('Open ...', 'Ctrl+O', False, True)

                # submenu
                if imgui.begin_menu('Open Recent', True):
                    imgui.menu_item('doc.txt', None, False, True)
                    imgui.end_menu()

                imgui.end_menu()

            imgui.end_main_menu_bar()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Пример #9
0
    def render(self):
        # Clear frame.
        glClearColor(0.2, 0.3, 0.3, 1.0)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Draw.
        # self.draw_grid()

        # Menu.
        self.imgui_impl.process_inputs()
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):
                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.render()
        self.imgui_impl.render(imgui.get_draw_data())
Пример #10
0
 def render_callback(self, time: float, frametime: float):
     if imgui.begin_main_menu_bar():
         if imgui.begin_menu("File", True):
             clicked_quit, selected_quit = imgui.menu_item(
                 "Quit", 'Cmd+Q', False, True
             )
             if clicked_quit:
                 exit(1)
             imgui.end_menu()
         changed, value = imgui.input_text("", self.input_text, 30)
         if changed:
             imgui.set_next_window_position(imgui.get_item_rect_min().x,
                                            imgui.get_item_rect_max().y)
             imgui.set_next_window_size(imgui.get_item_rect_size().x, 0)
             if imgui.begin("##popup", False,
                            imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE):
                 for index, row in symbol_list.iterrows():
                     if value.upper() in row[0]:
                         opened, selected = imgui.selectable(row[0] + " - " + row[2])
                         if imgui.is_item_clicked():
                             input_text = row[0]
                             selected_symbol = row[0]
             imgui.end()
         if imgui.button("download"):
             yfc.download(self.selected_symbol, symbol_data_file())
         imgui.end_main_menu_bar()
     pass
Пример #11
0
    def draw(self):
        imgui.new_frame()

        imgui.set_next_window_position(16, 32, imgui.ONCE)
        imgui.set_next_window_size(512, 512, imgui.ONCE)

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Пример #12
0
 def draw_menu(self):
     if imgui.begin_main_menu_bar():
         if imgui.begin_menu("File", True):
             clicked_quit, selected_quit = imgui.menu_item(
                     "Quit", 'Cmd+Q', False, True
                 )
             if clicked_quit:
                 exit(1)
             imgui.end_menu()
         imgui.end_main_menu_bar()
Пример #13
0
def main():
    pygame.init()
    size = 800, 600

    pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE)

    imgui.create_context()
    impl = PygameRenderer()

    io = imgui.get_io()
    io.display_size = size

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            impl.process_event(event)

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        #imgui.same_line()
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        #imgui.same_line()
        imgui.bullet_text("bullet_text")
        # 不换行
        #imgui.same_line()
        imgui.end()

        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()
        impl.render(imgui.get_draw_data())

        pygame.display.flip()
Пример #14
0
def _imgui_pick_file_menu(base_path, wildcard="*"):
    MAX_FILE_DISPLAY_LENGTH = 60

    try:
        entries = []
        for name in os.listdir(base_path):
            entries.append(
                (not os.path.isdir(os.path.join(base_path, name)), name))

        imgui.text("New:")
        imgui.same_line()
        imgui.push_item_width(-1)
        changed, value = imgui.input_text("", "", 255,
                                          imgui.INPUT_TEXT_ENTER_RETURNS_TRUE)
        if changed:
            return os.path.join(base_path, value)
        imgui.separator()
        for w in WILDCARDS:
            if imgui.button(w):
                return os.path.join(base_path, w)
            imgui.same_line()
        imgui.dummy(0, 0)
        imgui.separator()

        if len(entries) == 0:
            imgui.dummy(200, 0)

        for not_is_dir, name in sorted(entries):
            display_name = name
            if len(display_name) > MAX_FILE_DISPLAY_LENGTH:
                display_name = display_name[:MAX_FILE_DISPLAY_LENGTH //
                                            2] + "..." + display_name[
                                                -MAX_FILE_DISPLAY_LENGTH // 2:]

            if not not_is_dir:
                if imgui.begin_menu(display_name):
                    selected_path = _imgui_pick_file_menu(
                        os.path.join(base_path, name), wildcard)
                    imgui.end_menu()
                    if selected_path is not None:
                        return os.path.join(base_path, selected_path)
            else:
                if not fnmatch.fnmatch(name, wildcard):
                    continue
                clicked, state = imgui.menu_item(display_name, None, False)
                if clicked:
                    return os.path.join(base_path, name)

        imgui.separator()
        imgui.text("Pick: %s" % wildcard)
    except:
        imgui.text("Unable to open dir")
Пример #15
0
    def draw(self):
        flags = imgui.WINDOW_MENU_BAR

        imgui.begin("Child Window - File Browser", flags=flags)

        if imgui.begin_menu_bar():
            if imgui.begin_menu('File'):
                imgui.menu_item('Close')
                imgui.end_menu()

            imgui.end_menu_bar()

        imgui.end()
Пример #16
0
def main():
    pygame.init()
    clock = pygame.time.Clock()
    size = 640, 480

    pygame.display.set_mode(size, pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.OPENGL)

    io = imgui.get_io()
    io.fonts.add_font_default()
    io.display_size = size

    renderer = PygameRenderer()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            renderer.process_event(event)

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    pygame.quit()
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()

        pygame.display.flip()
        clock.tick(60)
Пример #17
0
def draw_imgui(scene: Scene):
    if Settings.GuiEnabled:
        # Menu Bar
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File"):
                imgui.menu_item("Open")

                if imgui.menu_item("Exit")[0]:
                    glfw.terminate()

                imgui.end_menu()

            if imgui.begin_menu("View"):

                if imgui.menu_item("Grid",
                                   shortcut='G',
                                   selected=Settings.GridEnabled)[0]:
                    Settings.GridEnabled = not Settings.GridEnabled

                if imgui.menu_item("GUI",
                                   shortcut='TAB',
                                   selected=Settings.GuiEnabled)[0]:
                    Settings.GuiEnabled = not Settings.GuiEnabled

                if imgui.menu_item("Stats",
                                   shortcut='P',
                                   selected=Settings.StatsEnabled)[0]:
                    Settings.StatsEnabled = not Settings.StatsEnabled

                imgui.end_menu()
            if Settings.StatsEnabled:
                imgui.same_line(imgui.get_window_width() - 150)
                imgui.text("FPS: " + "%.2f" % Global.fps + "  " +
                           "%.2f" % Global.frametime + "ms")
        imgui.end_main_menu_bar()

        # imgui.show_demo_window()

        # Scene
        imgui.begin("Scene")
        draw_node_item(scene.nodelist[0], scene)
        imgui.end()

        imgui.begin("Properties")
        imgui.text("Model")

        imgui.end()

    else:
        pass
Пример #18
0
def on_frame():
    if imgui.begin_main_menu_bar():
        if imgui.begin_menu("File", True):
            clicked_quit, selected_quit = imgui.menu_item(
                "Quit", 'Cmd+Q', False, True)
            if clicked_quit:
                exit(1)
            imgui.end_menu()
        imgui.end_main_menu_bar()
    imgui.show_test_window()
    imgui.begin("Custom window", True)
    imgui.text("Bar")
    imgui.text_colored("Eggs", 0.2, 1., 0.)
    imgui.end()
Пример #19
0
def main():
    window, gl_context = impl_pysdl2_init()
    impl = SDL2Impl(window)

    opened = True

    running = True
    event = SDL_Event()
    while running:
        while SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == SDL_QUIT:
                running = False
                break
            impl.process_event(event)
        impl.process_inputs()

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):
                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)
                if clicked_quit:
                    exit(1)
                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_user_guide()
        imgui.show_test_window()

        if opened:
            expanded, opened = imgui.begin("fooo", True)
            imgui.text("Bar")
            imgui.text_colored("Eggs", 0.2, 1., 0.)
            imgui.end()

        with imgui.styled(imgui.STYLE_ALPHA, 1):
            imgui.show_metrics_window()

        gl.glClearColor(114 / 255., 144 / 255., 154 / 255., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()

        SDL_GL_SwapWindow(window)

    impl.shutdown()
    SDL_GL_DeleteContext(gl_context)
    SDL_DestroyWindow(window)
    SDL_Quit()
Пример #20
0
def main():
    window = impl_glfw_init()
    impl = GlfwRenderer(window)

    box1 = box2 = box3 = True

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.begin("Scope Test")

        box1 = imgui.checkbox("Checkbox", box1)[1]

        with imgui.scope(2):
            imgui.new_line()
            imgui.text("Same name, different scope:")
            box2 = imgui.checkbox("Checkbox", box2)[1]

        imgui.new_line()
        imgui.text("Same name, same scope:")
        imgui.text("(This will not work right)")
        box3 = imgui.checkbox("Checkbox", box3)[1]

        imgui.end()

        gl.glClearColor(1., 1., 1., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        glfw.swap_buffers(window)

    impl.shutdown()
    imgui.shutdown()
    glfw.terminate()
Пример #21
0
    def render_ui(self, t, dt):
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("Test Menu"):
                imgui.end_menu()

            imgui.end_main_menu_bar()

        imgui.begin("Control")
        imgui.text(f"FPS {1.0 / (dt):.2f}")
        imgui.end()
        imgui.render()

        self.imgui.render(imgui.get_draw_data())
Пример #22
0
def main():
    window, gl_context = impl_pysdl2_init()
    imgui.create_context()
    impl = SDL2Renderer(window)

    running = True
    event = SDL_Event()
    while running:
        while SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == SDL_QUIT:
                running = False
                break
            impl.process_event(event)
        impl.process_inputs()

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        show_test_window()
        #imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        gl.glClearColor(1., 1., 1., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        impl.render(imgui.get_draw_data())
        SDL_GL_SwapWindow(window)

    impl.shutdown()
    SDL_GL_DeleteContext(gl_context)
    SDL_DestroyWindow(window)
    SDL_Quit()
Пример #23
0
 def _on_menu(self):
     # 绘制并处理主菜单条
     running = True
     if imgui.begin_main_menu_bar():
         # 在主菜单条上增加File菜单
         if imgui.begin_menu("File", True):
             # 在File菜单被点击后显示需要的菜单项
             clicked_quit, selected_quit = imgui.menu_item("Quit", 'CTRL+Q')
             # 如果Quit菜单项被点击,结束App
             if clicked_quit:
                 running = False
             # 结束File菜单的处理
             imgui.end_menu()
         # 结束主菜单条的处理
         imgui.end_main_menu_bar()
     return running
Пример #24
0
def menu(label, widget, enabled=True):
    """ Create an expandable menu in the `main_menu_bar`.

    Widgets commonly used in menus are `menu_item`, and `separator`.
    """
    while True:
        expanded = imgui.begin_menu(label, enabled)
        try:
            if expanded:
                next(widget)
        except StopIteration as e:
            return e.value
        finally:
            if expanded:
                imgui.end_menu()
        yield
Пример #25
0
def main():
    ctx = imgui.create_context()
    implot.create_context()
    implot.set_imgui_context(ctx)

    window = impl_glfw_init()
    impl = GlfwRenderer(window)

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_ansi("B\033[31marA\033[mnsi ")
        imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1., 0.)
        imgui.extra.text_ansi_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        # show_test_window()
        imgui.show_test_window()
        implot.show_demo_window()

        gl.glClearColor(1., 1., 1., 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        impl.render(imgui.get_draw_data())
        glfw.swap_buffers(window)

    impl.shutdown()
    glfw.terminate()
Пример #26
0
 def draw_menu(self):
     if imgui.begin_main_menu_bar():
         if imgui.begin_menu("File", True):
             clicked_quit, selected_quit = imgui.menu_item(
                     "Quit", 'Cmd+Q', False, True
                 )
             if clicked_quit:
                 exit(1)
             imgui.end_menu()
         if imgui.begin_menu("Controls", True):
             clicked_scene, selected_scene = imgui.menu_item(
                 "Scene", "Cmd+S", False, True
             )
             if clicked_scene:
                 self.scene_controls = True
             imgui.end_menu()
         imgui.end_main_menu_bar()
Пример #27
0
    def update(self):
        # Start a new imgui frame, so Game and GameObject updates can add to it.
        imgui.new_frame()

        # Add in a menu bar.
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):
                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", '', False, True)
                if clicked_quit:
                    self.running = False
                imgui.end_menu()
            imgui.end_main_menu_bar()

        # Add a game selector debug menu.
        imgui.begin("Game Selector", True)
        if imgui.button("Simple"):
            self.game = GameSimple.GameSimple()
        if imgui.button("Sokoban"):
            self.game = GameSokoban.GameSokoban()
        if imgui.button("Water Test"):
            self.game = GameWaterTest.GameWaterTest()
        if imgui.button("Effect - Dissolve"):
            self.game = GameDissolve.GameDissolve()
        imgui.end()

        # Uncomment this to see what imgui can do.
        # imgui.show_test_window()

        # Calculate deltaTime and update all game objects by that much time.
        currentTime = pygame.time.get_ticks()
        deltaTime = (currentTime - self.timeAtStartOfLastFrame) / 1000.0
        self.timeAtStartOfLastFrame = currentTime
        self.game.update(deltaTime)

        # Calculate and display FPS.
        self.frameCount += 1
        if currentTime - self.frameResetTime > 1000:
            self.lastFPS = self.frameCount
            self.frameCount = 0
            self.frameResetTime = currentTime

        imgui.begin("FPS Counter")
        imgui.text("FPS: " + str(self.lastFPS))
        imgui.end()
Пример #28
0
def mainMenuBar():
    if imgui.begin_menu_bar():
        # Create a menu bar button for locations
        if imgui.begin_menu('Locations'):
            # Loop through all the locations to then be sorted
            for location in flights.getFlightLocations():
                # create the menu item so we can check if clicked
                click, state = imgui.menu_item(
                    location, selected=currentSelectedLocations[location])

                if click:
                    # if the button was clicked just toggle the boolean in the currentselected locations as this handles showing or hiding
                    # in the loop below in the main GUi panel
                    currentSelectedLocations[
                        location] = not currentSelectedLocations[location]
            imgui.end_menu()

        imgui.end_menu_bar()
Пример #29
0
    def moduleMenuBar(self, modules):
        if (imgui.begin_menu(self.name)):

            main_c, _ = imgui.menu_item("Main Interface")
            if main_c:
                for _, moduleToDisable in modules.items():
                    moduleToDisable.interfaceActive = False
                self.interfaceActive = not self.interfaceActive
                self.activeInterface = "main"

            banList_c, _ = imgui.menu_item("Ban List")
            if banList_c:
                for _, moduleToDisable in modules.items():
                    moduleToDisable.interfaceActive = False
                self.interfaceActive = not self.interfaceActive
                self.activeInterface = "ban"

            imgui.end_menu()
Пример #30
0
    def draw_mainmenu(self):
        if imgui.begin_main_menu_bar():
            # File
            if imgui.begin_menu('File', True):
                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            # View
            if imgui.begin_menu('View', True):
                clicked_metrics, self.window.view_metrics = imgui.menu_item(
                    "Metrics", 'Cmd+M', self.window.view_metrics, True)

                imgui.end_menu()

            imgui.end_main_menu_bar()
Пример #31
0
def main():
    pygame.init()

    size = 800, 600

    pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL)
    pygame.display.set_caption("GBDev tool window")
    io = imgui.get_io()
    io.fonts.add_font_default()
    io.display_size = size

    renderer = PygameRenderer()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            renderer.process_event(event)

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("Menu", True):
                open_gbtd, selected_none = imgui.menu_item("Open GBTD", None, False, True)
                open_gbtk, selected_none = imgui.menu_item("Open GBTK", None, False, True)
                
                export_json, selected_none = imgui.menu_item("Export Default Json", None, False, True)

                clicked_quit, selected_quit = imgui.menu_item("Quit", 'Cmd+Q', False, True)

                if clicked_quit:
                    exit(1)
                if open_gbtd:
                    os.system("wine tools/GBTD/GBTD.EXE &")
                if open_gbtk:
                    os.system("wine tools/GBTK.exe &")
                if export_json:
                    tools.json2c.default_use()
                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.begin("Data", True)

        img_path = "data/img"
        onlyfiles = [f for f in listdir(img_path) if isfile(join(img_path, f))]
        #print(onlyfiles)
        for file in onlyfiles:
            imgui_image_menu(img_path+"/"+file)

        imgui.end()

        imgui.begin("Images", True)

        imgs_id = []
        for img_filename in onlyfiles:
            if img_filename.split(".")[-1] == "png":
                imgs_id.append((img_path+"/"+img_filename, img_manager.load_image(img_path+"/"+img_filename)))

        for img in imgs_id:
            img_size = img_manager.get_image_size(img[0])
            if img[1] is not 0 and img_size is not ():
                imgui.image(img[1], img_size[0]*2, img_size[1]*2, (0,1), (1,0))
                imgui.same_line()


        imgui.end()
        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()

        pygame.display.flip()