Esempio n. 1
0
    def dynamic_popup_button(self, label, error, tag=None):
        """ Validating button.
		Behaves in the same way as a regular `concur.widgets.button` when `error` is None.
		When `error` is a string, it displays an error popup instead of emitting an event.
		"""
        while True:
            if imgui.button(label):
                if error is not None:
                    imgui.open_popup("Error Popup")
                else:
                    return tag if tag is not None else label, None

            if imgui.begin_popup("Error Popup"):
                imgui.text(error)
                if self.is_continuable:
                    if imgui.button("Continue anyway"):
                        imgui.close_current_popup()
                        imgui.end_popup()
                        return tag if tag is not None else label, None
                    imgui.same_line()
                    if imgui.button("Cancel"):
                        imgui.close_current_popup()
                    imgui.end_popup()
                else:
                    if imgui.button("OK"):
                        imgui.close_current_popup()
                    imgui.end_popup()
            yield
Esempio n. 2
0
        def table_tree(table: EntryGroup):
            for key, entry in table.items():
                if isinstance(entry, NetworkTableEntry):
                    imgui.text(entry_name(key) + ': ' + str(entry.value))

                    imgui.same_line()
                    imgui.push_id(key)
                    if imgui.button('Add'):
                        active_widgets[key] = Widget(entry)
                    imgui.pop_id()
                else:
                    t = NetworkTables.getTable(key)
                    if '.type' in t.getKeys():
                        name = t.getString('.name', '')

                        imgui.text(name)

                        imgui.same_line()
                        imgui.push_id(key)
                        if imgui.button('Add'):
                            active_widgets[key] = Widget(t, EntryType.Chooser)
                        imgui.pop_id()

                        if show_sendable_debug:
                            if imgui.tree_node('Chooser Debug (' + key + ')'):
                                table_tree(entry)
                                imgui.tree_pop()
                    elif imgui.tree_node(entry_name(key),
                                         imgui.TREE_NODE_DEFAULT_OPEN):
                        # nothing fancy, just a subtable
                        table_tree(entry)
                        imgui.tree_pop()
Esempio n. 3
0
def draw_list(id_str, label, items, select_item, delete_callback=None):

    imgui.begin_child(id_str)
    imgui.text(label)

    cur_state.hovered_item = None

    for idx, item in enumerate(items):
        cur_id_str = "##list_{}_{}".format(id_str, idx)
        sel_btn_id = "Select {} {}".format(idx, cur_id_str)
        del_btn_id = "X{}".format(cur_id_str)

        imgui.begin_group()
        if imgui.button(sel_btn_id):
            print("clicked {}".format(idx))
            select_item(idx)
        imgui.same_line()

        imgui.text(str(item))
        if delete_callback is not None:
            imgui.same_line()
            if imgui.button(del_btn_id):
                delete_callback(item)
                print("delete!!")

        imgui.end_group()

        if imgui.is_item_hovered():
            cur_state.hovered_item = item

    imgui.end_child()
Esempio n. 4
0
def render_new_drawing_popup(window):

    "Settings for creating a new drawing."

    if window._new_drawing:
        imgui.open_popup("New drawing")
        w, h = window.get_size()
        imgui.set_next_window_size(200, 120)
        imgui.set_next_window_position(w // 2 - 100, h // 2 - 60)

    if imgui.begin_popup_modal("New drawing")[0]:
        imgui.text("Creating a new drawing.")
        imgui.separator()
        changed, new_size = imgui.drag_int3("Shape",
                                            *window._new_drawing["shape"],
                                            min_value=1,
                                            max_value=2048)
        if changed:
            window._new_drawing["shape"] = new_size
        if imgui.button("OK"):
            window.really_create_drawing()
            imgui.close_current_popup()
        imgui.same_line()
        if imgui.button("Cancel"):
            window._new_drawing = None
            imgui.close_current_popup()
        imgui.end_popup()
Esempio n. 5
0
 def draw_plot_gui(self):
     if self.plot_gui:
         imgui.begin("Plot", False)
         imgui.columns(3, 'plot settings', border=True)
         imgui.text('x-axis:')
         for i in range(len(self.x_axis)):
             changed = imgui.radio_button(self.x_axis[i] + '##x', 
                                          i == self.x_axis_index)
             if changed:
                 if self.x_axis_index != i:
                     self.reset_data()
                 self.x_axis_index = i
         imgui.next_column()
         imgui.text('y-axis:')
         for i in range(len(self.y_axis)):
             changed, self.y_axis_on[i] = imgui.checkbox(self.y_axis[i] + '##y', self.y_axis_on[i])
             if changed:
                 self.reset_data()
         imgui.next_column()
         imgui.text('plot:')
         if imgui.button('add'):
             self.add_data()
         if imgui.button('reset'):
             self.reset_data()
         imgui.end()
Esempio n. 6
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)

        imgui.begin("Example: item groups")

        imgui.begin_group()
        imgui.text("First group (buttons):")
        imgui.button("Button A")
        imgui.button("Button B")
        imgui.end_group()

        imgui.same_line(spacing=50)

        imgui.begin_group()
        imgui.text("Second group (text and bullet texts):")
        imgui.bullet_text("Bullet A")
        imgui.bullet_text("Bullet B")
        imgui.end_group()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Esempio n. 7
0
    def _show_custom_context(self):
        if imgui.button("paste url"):
            shader_id = clipboard.paste().strip()
            if shader_id.startswith("http://glslsandbox.com/e#"):
                shader_id = shader_id.replace("http://glslsandbox.com/e#", "")
            self.get_input("id").value = shader_id

        imgui.same_line()
        if imgui.button("copy url"):
            shader_id = self.get("id")
            url = "http://glslsandbox.com/e#%s" % shader_id
            clipboard.copy(url)

        imgui.same_line()
        if imgui.button("save fragment"):
            imgui.open_popup("save_fragment")
        base_path = os.path.join(assets.SHADER_PATH, "generate")
        save_path = node_widget.imgui_pick_file("save_fragment", base_path)
        if save_path is not None:
            self._export_fragment(save_path)

        imgui.same_line()
        if imgui.button("reference as file"):
            imgui.open_popup("reference_fragment")
        reference_path = node_widget.imgui_pick_file("reference_fragment",
                                                     base_path)
        if reference_path is not None:
            self._export_fragment(reference_path)
            self._reference_file_watcher = assets.FileWatcher(reference_path)
Esempio n. 8
0
def render_unsaved_close_drawing(window):

    "Popup to prevent accidentally closing a drawing with unsaved work."

    drawing = window.close_unsaved_drawing

    if drawing and drawing.unsaved:
        imgui.open_popup("Really close?")

    if imgui.begin_popup_modal("Really close?",
                               flags=imgui.WINDOW_NO_RESIZE)[0]:
        imgui.text("The drawing contains unsaved work.")
        if imgui.button("Yes, close anyway"):
            window.drawings.remove(drawing)
            window.close_unsaved_drawing = None
            imgui.close_current_popup()
        imgui.same_line()
        if imgui.button("Yes, but save first"):
            window.save_drawing(drawing)
            window.drawings.remove(drawing)
            window.close_unsaved_drawing = None
            imgui.close_current_popup()
        imgui.same_line()
        if imgui.button("No, cancel"):
            window.close_unsaved_drawing = None
            imgui.close_current_popup()
        imgui.end_popup()
Esempio n. 9
0
def render_unsaved_exit(window):

    "Popup to prevent exiting the application with unsaved work."

    if window.exit_unsaved_drawings:
        imgui.open_popup("Really exit?")

    imgui.set_next_window_size(500, 200)
    if imgui.begin_popup_modal("Really exit?")[0]:
        imgui.text("You have unsaved work in these drawing(s):")

        imgui.begin_child("unsaved",
                          border=True,
                          height=imgui.get_content_region_available()[1] - 26)
        for drawing in window.exit_unsaved_drawings:
            imgui.text(drawing.filename)
            if imgui.is_item_hovered():
                pass  # TODO popup thumbnail of the picture?
        imgui.end_child()

        if imgui.button("Yes, exit anyway"):
            imgui.close_current_popup()
            pyglet.app.exit()
        imgui.same_line()
        if imgui.button("Yes, but save first"):
            for drawing in window.exit_unsaved_drawings:
                window.save_drawing(drawing)
            pyglet.app.exit()
        imgui.same_line()
        if imgui.button("No, cancel"):
            window.exit_unsaved_drawings = None
            imgui.close_current_popup()
        imgui.end_popup()
Esempio n. 10
0
 def testWindow(self):
     imgui.begin("Custom window", False)  # start new window: Custom Window
     imgui.text("Bar")  # text label
     imgui.text_colored("Eggs", 0.2, 1.,
                        0.)  # colored text label (text, r, g , b)
     imgui.button("Test Button", 100, 20)
     imgui.end()  # End window def: Custom Window
Esempio n. 11
0
    def render_timeline(self):
        imgui.begin("timeline")
        tstamp = self.frame['tstamp']
        if imgui.button("<"):
            self.playing = False
            if self.i > 0:
                self.loadframe(self.i - 1)
        imgui.same_line()
        if self.playing:
            if (self.i == len(self.ts) - 1) or imgui.button("stop"):
                self.playing = False
            elif time.time() >= self.ts[self.i + 1] - self.t0:
                self.nextframe()
        elif imgui.button("play"):
            self.playing = True
            self.t0 = tstamp - time.time()
        imgui.same_line()
        if imgui.button(">"):
            self.playing = False
            self.nextframe()
        tsfrac = tstamp - int(tstamp)
        tstring = time.strftime(
            "%H:%M:%S.", time.localtime(tstamp)) + "%02d" % (tsfrac * 100)
        imgui.same_line()
        imgui.text(tstring)

        w = imgui.get_window_width()
        imgui.image(self.frametexid, w, 480 * w / 640)

        changed, i = imgui.slider_int("frame", self.i, 0,
                                      self.scanner.num_frames() - 1)
        if changed:
            self.playing = False
            self.loadframe(i)
        imgui.end()
Esempio n. 12
0
def show_main_menu():
    global text, ip_text
    style: GuiStyle = imgui.get_style()
    style.window_border_size = 0
    style.colors[imgui.COLOR_BUTTON] = Vec4(0.26, 0.59, 0.5, 0.4)
    style.colors[imgui.COLOR_BUTTON_ACTIVE] = Vec4(0.06, 0.53, 0.4, 1.0)
    style.colors[imgui.COLOR_BUTTON_HOVERED] = Vec4(0.26, 0.59, 0.5, 1.0)
    imgui.set_next_window_bg_alpha(0)
    imgui.set_next_window_position(300, 220)
    imgui.set_next_window_size(180, 200)
    imgui.begin("tremor0", False, imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_TITLE_BAR |
                imgui.WINDOW_ALWAYS_USE_WINDOW_PADDING)
    _, username = imgui.input_text("Name", text, 16)
    _, ip = imgui.input_text("Host", ip_text, 32)
    ip_text = ip
    text = username
    imgui.end()
    imgui.set_next_window_bg_alpha(0)
    imgui.set_next_window_size(100, 100)
    imgui.set_next_window_position(200, 200)
    imgui.begin("tremor1", False, imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_TITLE_BAR |
                imgui.WINDOW_ALWAYS_USE_WINDOW_PADDING)
    imgui.text_colored("Tremor", 0.9, 0.6, 1.0)
    play_clicked = imgui.button("Play", 82, 25)
    exit_clicked = imgui.button("Exit", 82, 25)
    if exit_clicked:
        graphics_subsystem.request_close()
    if play_clicked:
        print(username)
        client_net.connect_to_server((ip, 27070), username)
    imgui.end()
    def render_ui(self):
        global samples, observation_samples
        imgui.new_frame()

        imgui.begin("Options", True)

        if imgui.button("Random Scene"):
            random_scene()

        if imgui.button("Randomize Observations"):
            random_observations()

        _, samples = imgui.drag_int("Query SPP",
                                    samples,
                                    min_value=1,
                                    max_value=1024)
        _, observation_samples = imgui.drag_int("Observation SPP",
                                                observation_samples,
                                                min_value=1,
                                                max_value=1024)

        imgui.end()

        imgui.render()
        self.imgui.render(imgui.get_draw_data())
Esempio n. 14
0
def main():
    renderer = NXRenderer()
    currentDir = os.getcwd()

    while True:
        renderer.handleinputs()

        imgui.new_frame()

        width, height = renderer.io.display_size
        imgui.set_next_window_size(width, height)
        imgui.set_next_window_position(0, 0)
        imgui.begin("",
                    flags=imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE
                    | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_SAVED_SETTINGS)
        imgui.text("Welcome to PyNX!")
        imgui.text("Touch is supported")
        imgui.text("Current dir: " + os.getcwd())

        if os.getcwd() != "sdmc:/":
            imgui.push_style_color(imgui.COLOR_BUTTON, *FOLDER_COLOR)
            if imgui.button("../", width=200, height=60):
                os.chdir("..")
            imgui.pop_style_color(1)

        dirs = []
        files = []
        for e in os.listdir():
            if os.path.isdir(e):
                dirs.append(e)
            else:
                files.append(e)

        dirs = sorted(dirs)
        files = sorted(files)

        for e in dirs:
            imgui.push_style_color(imgui.COLOR_BUTTON, *FOLDER_COLOR)
            if imgui.button(e + "/", width=200, height=60):
                os.chdir(e)
            imgui.pop_style_color(1)

        for e in files:
            if e.endswith(".py"):
                imgui.push_style_color(imgui.COLOR_BUTTON, *PYFILE_COLOR)
            else:
                imgui.push_style_color(imgui.COLOR_BUTTON, *FILE_COLOR)

            if imgui.button(e, width=200, height=60) and e.endswith(".py"):
                run_python_module(e)

            imgui.pop_style_color(1)

        imgui.end()

        imgui.render()
        renderer.render()

    renderer.shutdown()
Esempio n. 15
0
    def onDrawGuiCallback(self, args):
        if self.visible:
            if imgui.begin("Grinder##grinder_mainwindow", (300,350)):
                player = BigWorld.player()
                imgui.columns(2)
                imgui.separator()
                imgui.text("State")
                imgui.nextColumn()
                if self.bot.running and self.bot.engine.currentState:
                    imgui.text(self.bot.engine.currentState.name)
                else:
                    imgui.text("N/A")
                imgui.nextColumn()
                imgui.text("Name")
                imgui.nextColumn()
                if player:
                    imgui.text(player.playerName)
                else:
                    imgui.text("Not ingame")
                imgui.nextColumn()
                imgui.text("Experience")
                imgui.nextColumn()
                if player:
                    exp_label = '{0} / {1}'.format(player.exp, data.avatar_lv_data.data.get(player.realLv, {}).get('upExp', '?'))
                    imgui.text(exp_label)
                else:
                    imgui.text("Not ingame")
                imgui.columns(1)
                imgui.separator()
                if not self.bot.running:
                    if imgui.button("Start##grinder_start_bot", (imgui.getContentRegionAvail()[0] / 2, 25)):
                        try:
                            combat_inst = combats.LOADED_COMBATS[combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]]
                            self.bot.start(combat_inst)
                            self.profileEditor.hide()
                        except IndexError:
                            roplus.log("Please select a combat script first !")
                    imgui.sameLine()
                    if imgui.button("Profile editor##grinder_profile_editor", (imgui.getContentRegionAvail()[0], 25)):
                        self.profileEditor.show()
                else:
                    if imgui.button("Stop##grinder_stop_bot", (imgui.getContentRegionAvail()[0], 25)):
                        self.bot.stop()

                imgui.separator()
                if imgui.button("Save settings##grinder_save_settings", (imgui.getContentRegionAvail()[0], 25)):
                    settings.saveSettings(self.bot.settings, "grinder")
                if imgui.collapsingHeader("Combats##grinder_combats_settings", 0x20):
                    selectedChanged, self.combatSelectedIndex = imgui.combo("##grinder_combatcombo", self.combatSelectedIndex, combats.LOADED_COMBATS.keys())
                    if selectedChanged:
                        self.bot.settings["lastUsedCombat"] = combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]
                        self.bot.saveSettings()
                    imgui.sameLine()
                    if imgui.button("Reload##grinder_reload_scripts", (imgui.getContentRegionAvail()[0], 24)):
                        combats.reloadCombatModules()
                        
        
            imgui.end()
Esempio n. 16
0
 def tests(self):
     imgui.begin("Test Window")
     imgui.text("Lorem ipsum")
     changed, self.checkbox = imgui.checkbox("Checkbox", self.checkbox)  # imgui.core.checkbox
     if imgui.button("Test Circle", 100, 20):
         self.canvas.add_object(self.testCircle)
     if imgui.button("Test Ellipse", 100, 20):
         self.canvas.add_object(self.testEllipse)
     imgui.end()
Esempio n. 17
0
    def draw(self):
        imgui.begin("Scope")
        self.begin_input(self.input)
        imgui.button('input')
        self.end_input()
        imgui.same_line(spacing=16)
        imgui.plot_lines("Sin(t)", np.array(self.values).astype(np.float32), graph_size=imgui.get_content_region_available())

        imgui.end()
Esempio n. 18
0
    def draw(self):
        imgui.begin("Example: buttons")

        if imgui.button("Button 1"):
            self.message = "You pressed 1!"
        if imgui.button("Button 2"):
            self.message = "You pressed 2!"
        imgui.text(self.message)
        imgui.end()
Esempio n. 19
0
 def show_toggle_window_button(self, show_at_startup=False):
     if show_at_startup and self.never_shown:
         self.opened = True
     self.never_shown = False
     if self.opened:
         if imgui.button("Hide image lister"):
             self.opened = False
     else:
         if imgui.button("Show image lister"):
             self.opened = True
Esempio n. 20
0
    def render_timeline(self):
        imgui.begin("timeline")
        tstamp = self.frame['tstamp']
        if imgui.button("<"):
            self.playing = False
            if self.i > 0:
                self.loadframe(self.i - 1)
        imgui.same_line()
        if self.playing:
            if (self.i
                    == self.scanner.num_frames() - 1) or imgui.button("stop"):
                self.playing = False
            elif time.time() >= self.ts[self.i + 1] - self.t0:
                self.nextframe()
        elif imgui.button("play"):
            self.playing = True
            self.t0 = tstamp - time.time()
        imgui.same_line()
        if imgui.button(">"):
            self.playing = False
            self.nextframe()
        tsfrac = tstamp - int(tstamp)
        tstring = time.strftime(
            "%H:%M:%S.", time.localtime(tstamp)) + "%02d" % (tsfrac * 100)
        imgui.same_line()
        imgui.text(tstring)

        w = imgui.get_window_width()
        if self.show_frontview:
            imgui.image(self.fronttexid, w, w / 2)  # 2:1 aspect for front view
        else:  # 4:3 aspect
            imgui.image(self.frametexid, w, 3 * w / 4)

        if self.acts is not None:
            imgui.plot_lines("activations", self.acts)

        nCtrlAngles = (len(self.controlstate[self.i]) - 14) // 3
        cc = self.controlstate[self.i][-nCtrlAngles:]
        imgui.plot_lines("control costs", np.clip(cc, 0, 100))

        # make a histogram of expected cone locations
        if self.acts is not None:
            hist = np.zeros(len(self.acts) * 2, np.float32)
            np.add.at(hist, self.frame['c0'], 1)
            np.add.at(hist, self.frame['c1'], -1)
            hist = np.cumsum(hist)
            hist = hist[:len(self.acts)] + hist[-len(self.acts):]
            imgui.plot_lines("expected cone locations", hist)

        changed, i = imgui.slider_int("frame", self.i, 0,
                                      self.scanner.num_frames() - 1)
        if changed:
            self.playing = False
            self.loadframe(i)
        imgui.end()
    def render ( self ):
        super().render()

        if imgui.begin( "Music Editor" ):
            ( width, height ) = imgui.get_content_region_available();

            ( changed, value ) = imgui.input_text_multiline( "###Code", self.code, 1000, width = width, height = height / 2 )
            if changed: self.code = value
            
            to_parse = False
            to_play = False

            if imgui.button( "Parse" ):
                to_parse = True

            imgui.same_line()
            
            if imgui.button( "Play" ):
                to_play = True

            try:
                if to_parse or to_play:
                    self.player = Player()

                    self.player.sequencers.append( FluidSynthSequencer() )

                    parser = Parser();

                    self.parsedTree = parser.parse( self.code )
                    
                    self.context = self.create_context( self.player )

                    value = self.parsedTree.eval( self.context )
                    
                    self.player.events = events = list( value ) if isinstance( value, Music ) else []

                    self.parsedException = None
                if to_play:
                    self.player.play()
            except Exception as ex:
                self.parsedException = ex
                print(ex)
                traceback.print_tb(ex.__traceback__)

            if self.parsedException != None:
                imgui.text_colored( str( self.parsedException ), 1, 0, 0 )

            
            self.expressionTab = self.imgui_tabbar( self.expressionTab, [
                ( EXPRESSION_TAB_AST, "AST", self.render_inspector_ast ),
                ( EXPRESSION_TAB_EVENTS, "Events", self.render_inspector_events ),
                ( EXPRESSION_TAB_KEYBOARD, "Keyboard", self.render_inspector_keyboard )
            ] )

            imgui.end()
Esempio n. 22
0
 def draw(self):
     imgui.begin("Example: tooltip")
     imgui.button("Click me!")
     if imgui.is_item_hovered():
         imgui.begin_tooltip()
         imgui.text("This button is clickable.")
         imgui.text("This button has full window tooltip.")
         texture_id = imgui.get_io().fonts.texture_id
         imgui.image(texture_id, 512, 64, border_color=(1, 0, 0, 1))
         imgui.end_tooltip()
     imgui.end()
Esempio n. 23
0
    def draw(self):
        imgui.begin("Spark")

        self.begin_input(self.input)
        imgui.button('input')
        self.end_input()

        if imgui.button("Run"):
            self.reset()

        imgui.end()

        self.emitter.draw()
Esempio n. 24
0
    def configurationInterface(self):
        imgui.text_wrapped(self.description)

        imgui.spacing()

        if not self.started:
            if imgui.button("Start"):
                self.start()
        else:
            if imgui.button("Stop"):
                self.stop()

        imgui.spacing()
        imgui.separator()
        imgui.spacing()
Esempio n. 25
0
def imgui_image_menu(path):
    filename = path.split("/")[-1]
    if filename.split(".")[-1] == "bin":
        imgui.text(filename)
        if imgui.begin_popup_context_item("Convert "+filename, 2):
            if imgui.button("Convert to 8x8 images"):
                tools.bin2png.bin2png(path,8)
                img_manager.reload_img(path.replace(".bin", ".png"))
            if imgui.button("Convert to 16x16 images"):
                tools.bin2png.bin2png(path, 16)
                img_manager.reload_img(path.replace(".bin", ".png"))
            if imgui.button("Convert to 32x32 images"):
                tools.bin2png.bin2png(path, 32)
                img_manager.reload_img(path.replace(".bin", ".png"))
            imgui.end_popup()
Esempio n. 26
0
    def _draw_component(self, entity, component_name, component_name_display):
        if not entity.has_component(component_name):
            return
        treeNodeFlags = imgui.TREE_NODE_DEFAULT_OPEN | imgui.TREE_NODE_FRAMED | imgui.TREE_NODE_ALLOW_ITEM_OVERLAP | imgui.TREE_NODE_FRAME_PADDING
        component = entity.get_component(component_name)
        # contentRegionAvailable = imgui.get_content_region_available()
        # lineHeight =
        imgui.push_style_var(imgui.STYLE_FRAME_PADDING, (4, 4))
        imgui.separator()
        open = imgui.tree_node(component_name_display, treeNodeFlags)
        imgui.pop_style_var()
        # TODO imgui.same_line(contentRegionAvailable.x - lin)
        imgui.same_line()
        if imgui.button("+"):
            imgui.open_popup("ComponentSettings")
        removeComponent = False
        if imgui.begin_popup("ComponentSettings"):
            if menu_item_clicked("Remove component"):
                removeComponent = True
            imgui.end_popup()
        if open:
            getattr(self, "_draw_component_%s" % component_name)(component)
            imgui.tree_pop()

        if removeComponent:
            entity.remove_component(component_name)
Esempio n. 27
0
 def gui(self):
     if imgui.begin_popup(self.name):
         imgui.label_text(self.name, self.name)
         if imgui.button('Ok'):
             self.callback()
             imgui.close_current_popup()
             imgui.end_popup()
    def imgui_tabbar ( self, open_tab, tabs ):
        width = imgui.get_content_region_available_width()

        tab_width = ( width - imgui.get_style().item_spacing.x * ( len( tabs ) - 1 ) ) / len( tabs )

        first = True

        open_panel = None

        for key, label, panel in tabs:
            if not first: 
                imgui.same_line()

            if imgui.button( label, width = tab_width ):
                open_tab = key

            if open_tab == key:
                open_panel = panel

            first = False

        if open_panel != None:
            open_panel()

        return open_tab
Esempio n. 29
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)

        imgui.begin("Example: button")
        imgui.button("Button 1")
        imgui.button("Button 2")
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Esempio n. 30
0
def show_togglable_window(window_param, window_function_code):
    global _ALL_TOGGLABLE_STATUS
    if window_param.window_title not in _ALL_TOGGLABLE_STATUS:
        _ALL_TOGGLABLE_STATUS[
            window_param.window_title] = window_param.initialShow

    this_window_open_status = _ALL_TOGGLABLE_STATUS[window_param.window_title]

    if this_window_open_status:
        toggle_button_legend = "Hide " + window_param.window_title
    else:
        toggle_button_legend = "Show " + window_param.window_title

    if imgui.button(make_unique_label(toggle_button_legend)):
        this_window_open_status = not this_window_open_status

    if this_window_open_status:
        imgui.set_next_window_size(window_param.size[0], window_param.size[1])
        if window_param.include_begin_code:
            imgui.begin(window_param.window_title)

        window_function_code()

        if window_param.include_begin_code:
            imgui.end()
Esempio n. 31
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)

        imgui.begin("Example: simple popup modal")

        if imgui.button("Open Modal popup"):
            imgui.open_popup("select-popup")

        imgui.same_line()

        if imgui.begin_popup_modal("select-popup")[0]:
            imgui.text("Select an option:")
            imgui.separator()
            imgui.selectable("One")
            imgui.selectable("Two")
            imgui.selectable("Three")
            imgui.end_popup()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Esempio n. 32
0
    def onDrawGuiCallback(self, *args, **kw):
        if self.window_visable:
            try:
                if imgui.begin('AutoLoot {0} - {1}##Entity_mainwindow'.format(autoloot.__version__, autoloot.__author__), (600,350)):
                    # button bar
                    if imgui.checkbox('Enable Auto-Loot', self.enabled_auto_loot):
                        self.enabled_auto_loot = not self.enabled_auto_loot
                    
                    if imgui.collapsingHeader('Available Loot ({0} items)'.format(len(self.bot.items))):
                        imgui.columns(4)
                        for item in self.bot.items:
                            if not item:
                                continue

                            imgui.text(item.roleName)
                            imgui.nextColumn()

                            if item.__module__ == 'DroppedItem':
                                try:
                                    imgui.text('Lootable' if item._checkPickItem(self.bot.p) else 'Not Lootable')
                                except AttributeError:
                                    imgui.text('Not _checkPickItem')
                            else:
                                imgui.text('Openable?')
                            imgui.nextColumn()

                            imgui.text('{0}'.format(self.bot.p.position.distTo(item.position)))
                            imgui.nextColumn()

                            if imgui.button('Go To {0}##NavToEntity'.format(item.__module__)):
                                nav.moveToEntityPathFind(item)
                            imgui.nextColumn()
                            imgui.separator()
                        imgui.columns(1)

                    if imgui.collapsingHeader('Debug All Entities'):
                        for entity_name, entities in sorted(self.bot.entities.iteritems()):
                            for entity in entities:
                                imgui.columns(5)
                                imgui.separator()
                                imgui.text('{0}'.format(entity_name))
                                imgui.nextColumn()
                                imgui.text('{0}'.format(entity.id))
                                imgui.nextColumn()
                                if entity_name == 'DroppedItem' and hasattr(entity, '_checkPickItem') and entity._checkPickItem(self.bot.p):
                                    imgui.text('{0}'.format('Lootable'))
                                elif not entity_name == 'DroppedItem':
                                    imgui.text('No Data Available')
                                else:
                                    imgui.text('Not your Loot!')
                                imgui.nextColumn()
                                if entity and hasattr(entity, 'position') and self.bot.p and hasattr(self.bot.p, 'position'):
                                    imgui.text('{0}'.format(self.bot.p.position.distTo(entity.position)))
                                else:
                                    imgui.text('No Position Information')
                                imgui.nextColumn()
                                if imgui.button('NavToEntity##NavToEntity'):
                                    nav.moveToEntityPathFind(entity)
                                imgui.nextColumn()
                        imgui.columns(1)
                imgui.end()
            except Exception:
                import traceback
                for line in traceback.format_exc().splitlines():
                    roplus.log(line)
                self.window_visable = False