Exemplo n.º 1
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()
Exemplo n.º 2
0
    def render(self, *args):
        imgui.columns(2, 'fileLlist')
        imgui.separator()

        pathlist = os.listdir(os.curdir)
        pathlist.insert(0, os.pardir)
        pathlist.insert(0, os.curdir)
        length = len(pathlist)
        selected = [False] * length
        for i in range(length):
            _, selected[i] = imgui.selectable(pathlist[i], selected[i])
            imgui.next_column()
            size = os.path.getsize(pathlist[i])
            imgui.text(str(size)+' byte')
            imgui.next_column()
            if(selected[i] is True):
                self.path = os.path.abspath(pathlist[i])
                print('clicked ' + pathlist[i])
                if os.path.isdir(self.path):
                    os.chdir(self.path)
                    break

        imgui.next_column()

        imgui.columns(1)
        return {'path': self.path}
Exemplo n.º 3
0
def draw_table(data, *selected_row):
    imgui.columns(len(data.columns) + 1, "##table")
    imgui.separator()
    imgui.text("")
    imgui.next_column()
    for c in data.columns:
        imgui.text(c)
        imgui.next_column()
    imgui.separator()
    # fill with data
    i = 0
    for _, row in data.iterrows():
        label = str(i)
        clicked, _ = imgui.selectable(label=label,
                                      selected=selected_row == i,
                                      flags=imgui.SELECTABLE_SPAN_ALL_COLUMNS,
                                      )
        if clicked:
            selected_row = i
        hovered = imgui.is_item_hovered()
        imgui.next_column()
        for c in data.columns:
            imgui.text(row[c])
            imgui.next_column()
        i += 1
Exemplo n.º 4
0
    def draw(self):
        imgui.begin("Example: Columns - File list")
        imgui.columns(4, 'fileList')
        imgui.separator()
        imgui.text("ID")
        imgui.next_column()
        imgui.text("File")
        imgui.next_column()
        imgui.text("Size")
        imgui.next_column()
        imgui.text("Last Modified")
        imgui.next_column()
        imgui.separator()
        imgui.set_column_offset(1, 40)

        imgui.next_column()
        imgui.text('FileA.txt')
        imgui.next_column()
        imgui.text('57 Kb')
        imgui.next_column()
        imgui.text('12th Feb, 2016 12:19:01')
        imgui.next_column()

        imgui.next_column()
        imgui.text('ImageQ.png')
        imgui.next_column()
        imgui.text('349 Kb')
        imgui.next_column()
        imgui.text('1st Mar, 2016 06:38:22')
        imgui.next_column()

        imgui.columns(1)
        imgui.end()
Exemplo n.º 5
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()
Exemplo n.º 6
0
    def draw(self):
        style = imgui.get_style()

        imgui.begin("Colors")
        imgui.columns(4)
        for color in range(0, imgui.COLOR_COUNT):
            imgui.text("Color: {}".format(color))
            imgui.color_button("color#{}".format(color), *style.colors[color])
            imgui.next_column()

        imgui.end()
Exemplo n.º 7
0
 def render(self, *args):
     if 'fileInfo' in args[0][0][0]:
         self.info = args[0][0][0]['fileInfo'][0]
     imgui.columns(2, 'info')
     imgui.separator()
     for name in self.info:
         imgui.text(name)
         imgui.next_column()
         imgui.text(self.info[name])
         imgui.next_column()
     imgui.columns(1)
     return {}
Exemplo n.º 8
0
 def light_props(self):
     expanded, visible = imgui.collapsing_header(
         'Lighting', self.GUI_STATE.lightprop.isvisible)
     style = imgui.get_style()
     if expanded:
         self.SHADER.scene_shader.attach()
         imgui.columns(2, 'GHOST')
         w = imgui.get_window_width()
         imgui.set_column_width(0, w*0.6)
         changed, self.GUI_STATE.lightprop.shininess = imgui.drag_float(
             'Shininess', self.GUI_STATE.lightprop.shininess, self.props.steps, 0.001, 30.0)
         if changed:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'shininess', self.GUI_STATE.lightprop.shininess)
         imgui.next_column()
         imgui.set_column_width(1, w*0.4)
         changed, self.props.steps = imgui.input_float(
             'Step',
             self.props.steps
         )
         imgui.columns(1)
         changed0, self.GUI_STATE.lightprop.specDamp = imgui.drag_float(
             'Specular Damp', self.GUI_STATE.lightprop.specDamp, self.props.steps, 0.001, 30.0)
         if changed0:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'specDamp',
                 self.GUI_STATE.lightprop.specDamp
             )
         changed1, self.GUI_STATE.lightprop.lightcolor = imgui.color_edit3(
             'Light Color', *self.GUI_STATE.lightprop.lightcolor
         )
         self.GUI_STATE.lightprop.lightcolor = Color3(
             *self.GUI_STATE.lightprop.lightcolor)
         if changed1:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'lightColor',
                 self.GUI_STATE.lightprop.lightcolor
             )
         if imgui.radio_button('BLINN', self.props.active):
             self.props.active = not self.props.active
         if self.props.active:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'blinn',
                 1,
                 dtype='i'
             )
         else:
             self.SHADER.scene_shader.putDataInUniformLocation(
                 'blinn',
                 0,
                 dtype='i'
             )
Exemplo n.º 9
0
    def on_mod(self, im):
        '''
            进行具体的应用逻辑绘制处理:im为imgui环境对象;返回值告知程序是否继续.
            此方法应该被子类重载,完成具体的功能逻辑
        '''
        # 判断是否有ctrl+Q按下,结束app
        if im.is_key_down('ctrl+Q'):
            return False
        if not self._on_menu():
            return False

        style = imgui.get_style()
        imgui.begin("Color window")
        imgui.columns(4)
        for color in range(0, imgui.COLOR_COUNT):
            imgui.text("Color: {} {}".format(
                color, imgui.get_style_color_name(color)))
            imgui.color_button("color#{}".format(color), *style.colors[color])
            imgui.next_column()
        imgui.end()

        # 获取当前主窗口尺寸
        win_width, win_height = im.main_win.get_size()
        # 定义菜单条高度
        bar_height = 24
        # 计算横向比例分隔
        widths, hpos = split(win_width, (5, 15, 30))
        # 计算左侧竖向比例分隔
        heights, vpos = split(win_height - bar_height, (10, 30))
        # 左侧列表
        self.do_show_text('样本列表', hpos[0], bar_height, widths[0],
                          win_height - bar_height, 'list')
        # 左上窗口
        self.do_show_text('差异处', hpos[1], bar_height + vpos[0], widths[1],
                          heights[0], 'tmp_text')
        # 左下窗口
        self.do_show_text('新结果', hpos[1], bar_height + vpos[1], widths[1],
                          heights[1], '测试123456')
        # 重新计算右侧竖向比例分隔
        heights, vpos = split(win_height - bar_height, (30, 30))
        # 右上窗口
        self.do_show_text('原文本', hpos[2], bar_height + vpos[0], widths[2],
                          heights[0], '测试1234')
        # 右下窗口
        self.do_show_text('预处理', hpos[2], bar_height + vpos[1], widths[2],
                          heights[1], '测试1234')

        #imgui.show_demo_window()
        return True
Exemplo n.º 10
0
 def render(self):
     imgui.columns(2, 'alertList')
     imgui.set_column_offset(1, 45)
     imgui.text("Count")
     imgui.next_column()
     imgui.text("Alert")
     imgui.next_column()
     imgui.separator()
     # ToDo: In the future dont revert this, and simple have it lock scroll
     # to bottom like a terminal? Might be more effort than it's worth.
     list(map(render_alert, reversed(alerts.items())))
     imgui.text("Count")
     imgui.next_column()
     imgui.text("Alert")
     imgui.next_column()
     imgui.columns(1)
Exemplo n.º 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)

        imgui.begin("Example: Columns - File list")
        imgui.columns(4, 'fileLlist')
        imgui.separator()
        imgui.text("ID")
        imgui.next_column()
        imgui.text("File")
        imgui.next_column()
        imgui.text("Size")
        imgui.next_column()
        imgui.text("Last Modified")
        imgui.next_column()
        imgui.separator()
        imgui.set_column_offset(1, 40)

        imgui.next_column()
        imgui.text('FileA.txt')
        imgui.next_column()
        imgui.text('57 Kb')
        imgui.next_column()
        imgui.text('12th Feb, 2016 12:19:01')
        imgui.next_column()

        imgui.next_column()
        imgui.text('ImageQ.png')
        imgui.next_column()
        imgui.text('349 Kb')
        imgui.next_column()
        imgui.text('1st Mar, 2016 06:38:22')
        imgui.next_column()

        imgui.columns(1)
        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Exemplo n.º 12
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)

        style = imgui.get_style()
        imgui.begin("Colors")
        imgui.columns(4)
        for color in range(0, imgui.COLOR_COUNT):
            imgui.text("Color: {}".format(color))
            imgui.color_button("color#{}".format(color), *style.colors[color])
            imgui.next_column()

        imgui.end()

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Exemplo n.º 13
0
    def onDrawGuiCallback(self, args):
        if self.visible:
            if imgui.begin("Grinder - Profile Editor##grinder_profileeditor",
                           (400, 400)):
                textChanged, self.bot.currentProfile["name"] = imgui.inputText(
                    "##profilesavename", self.bot.currentProfile["name"])
                imgui.sameLine()
                if imgui.button("Save##profileeditor_save_profile"):
                    self.saveProfile()
                selectedChanged, self.profilesSelectedIndex = imgui.combo(
                    "##qfsdsfs", self.profilesSelectedIndex,
                    self.availableProfiles)
                imgui.sameLine()
                if imgui.button("Load##profileeditor_load_profile"):
                    profileName = self.availableProfiles[
                        self.profilesSelectedIndex]
                    self.loadProfile(profileName)
                if imgui.button("Clear profile##profileeditor_clear_profile",
                                (imgui.getContentRegionAvail()[0], 25)):
                    self.bot.currentProfile = profile.defaultProfile()
                imgui.separator()
                if imgui.collapsingHeader("Hotspots##profileeditor_hotspots",
                                          0x20):
                    if imgui.button("Add hotspot"):
                        player = BigWorld.player()
                        if player:
                            position = player.position
                            self.bot.currentProfile["hotspots"].append(
                                (position.x, position.y, position.z,
                                 player.mapID))
                    imgui.sameLine()
                    if imgui.checkbox(
                            "Randomize hotspots",
                            self.bot.currentProfile["randomizeHotspots"]):
                        self.bot.currentProfile[
                            "randomizeHotspots"] = not self.bot.currentProfile[
                                "randomizeHotspots"]

                    if len(self.bot.currentProfile["hotspots"]) > 0:
                        imgui.columns(3)
                        imgui.text("MapID")
                        imgui.nextColumn()
                        imgui.text("Position")
                        imgui.nextColumn()
                        imgui.text("Action")
                        imgui.nextColumn()
                        hotspotToRemove = None
                        for index, hotspot in enumerate(
                                self.bot.currentProfile["hotspots"]):
                            imgui.text(str(hotspot[3]))
                            imgui.nextColumn()
                            imgui.text(
                                str(math.trunc(hotspot[0])) + ", " +
                                str(math.trunc(hotspot[1])) + ", " +
                                str(math.trunc(hotspot[2])))
                            imgui.nextColumn()
                            if imgui.button("Remove##rem_hotspot" +
                                            str(index)):
                                hotspotToRemove = hotspot
                            imgui.nextColumn()
                        if hotspotToRemove:
                            self.bot.currentProfile["hotspots"].remove(
                                hotspotToRemove)
                        imgui.columns(1)
            imgui.end()
Exemplo n.º 14
0
def begin_button_tab_bar ( count : int ):
    imgui.columns( count, border = False )
Exemplo n.º 15
0
def render_plugins_ui(drawing):
    "Draw UI windows for all plugins active for the current drawing."

    # TODO there's an imgui related crash here somewhere preventing (at least) the
    # voxel plugin from being used in more than one drawing. For now: avoid that.

    if not drawing:
        return

    deactivated = set()

    for name, (plugin, sig, args) in drawing.plugins.items():
        _, opened = imgui.begin(f"{name} {id(drawing)}", True)
        if not opened:
            deactivated.add(name)
            imgui.end()
            continue
        imgui.columns(2)
        for param_name, param_sig in islice(sig.items(), 2, None):
            imgui.text(param_name)
            imgui.next_column()
            default_value = args.get(param_name)
            if default_value is not None:
                value = default_value
            else:
                value = param_sig.default
            label = f"##{param_name}_val"
            if param_sig.annotation == int:
                changed, args[param_name] = imgui.drag_int(label, value)
            elif param_sig.annotation == float:
                changed, args[param_name] = imgui.drag_float(label, value)
            elif param_sig.annotation == str:
                changed, args[param_name] = imgui.input_text(label, value, 20)
            elif param_sig.annotation == bool:
                changed, args[param_name] = imgui.checkbox(label, value)
            imgui.next_column()
        imgui.columns(1)

        texture_and_size = getattr(plugin, "texture", None)
        if texture_and_size:
            texture, size = texture_and_size
            w, h = size
            ww, wh = imgui.get_window_size()
            scale = max(1, (ww - 10) // w)
            imgui.image(texture.name,
                        w * scale,
                        h * scale,
                        border_color=(1, 1, 1, 1))

        last_run = getattr(plugin, "last_run", 0)
        period = getattr(plugin, "period", None)
        t = time()
        if period and t > last_run + period or imgui.button("Execute"):
            plugin.last_run = last_run
            try:
                result = plugin(voxpaint, drawing, **args)
                if result:
                    args.update(result)
            except Exception:
                print_exc()

        imgui.button("Help")
        if imgui.begin_popup_context_item("Help", mouse_button=0):
            if plugin.__doc__:
                imgui.text(inspect.cleandoc(plugin.__doc__))
            else:
                imgui.text("No documentation available.")
            imgui.end_popup()
        imgui.end()

    for name in deactivated:
        drawing.plugins.pop(name, None)
Exemplo n.º 16
0
    def displayInterface(self):

        imgui.begin_child("left_bottom", width=606, height=370)

        if (self.activeInterface == "main"):

            imgui.text("Main Interface (SSH)")
            imgui.begin_child("left_bottom",
                              width=606,
                              height=290,
                              border=True)

            imgui.begin_child("connections", width=606)

            imgui.columns(4, 'ssh_connections')
            imgui.text("ID")
            imgui.next_column()
            imgui.text("USER")
            imgui.next_column()
            imgui.text("IP")
            imgui.next_column()
            imgui.text("Time Connected")
            imgui.separator()

            imgui.set_column_width(0, 70)

            for conn in list(self.activeConnections.keys()):
                now = datetime.now()
                elapsed = now - self.activeConnections[conn]["connected_time"]
                imgui.next_column()
                imgui.text(self.activeConnections[conn]["ssh_proc"])
                imgui.next_column()
                imgui.text(self.activeConnections[conn]["user"])
                imgui.next_column()
                imgui.text(self.activeConnections[conn]["ip"])
                imgui.next_column()
                imgui.text(str(elapsed))

            imgui.columns(1)

            imgui.end_child()
            imgui.end_child()

            imgui.text("Select a SSH Session")

            clicked, current = imgui.combo("##Path input", self.sshSelected,
                                           self.sshSelectionOptions)

            if (clicked):
                self.sshSelected = current

            if (imgui.button("Kick")):
                ssh_proc = self.sshSelectionOptions[
                    self.sshSelected].split()[0][1:-1]
                log.logNorm("Kicked SSH Session (" + ssh_proc + ") " +
                            self.activeConnections[ssh_proc]["user"])
                self.disconnectSSHConnection(ssh_proc)

            imgui.same_line()
            if (imgui.button("Ban Both")):
                self.handleBanningUser()
                self.handleBanningIPAddr()
                self.handleDisconnectingCurrentSelection()

            imgui.same_line()
            if (imgui.button("Ban User")):
                self.handleBanningUser()
                self.handleDisconnectingCurrentSelection()

            imgui.same_line()
            if (imgui.button("Ban IP")):
                self.handleBanningIPAddr()
                self.handleDisconnectingCurrentSelection()

        elif (self.activeInterface == "ban"):
            imgui.text("Ban List (SSH)")
            imgui.begin_child("left_bottom",
                              width=299,
                              height=310,
                              border=True)

            imgui.columns(2, 'ssh_connections')
            imgui.text("USERNAME")
            imgui.next_column()
            imgui.next_column()
            imgui.separator()

            for user in self.banList["users"]:
                imgui.text(user)
                imgui.next_column()

            imgui.columns(1)
            imgui.end_child()

            imgui.same_line()

            imgui.begin_child("right_bottom",
                              width=299,
                              height=310,
                              border=True)
            imgui.text("IP Address")
            imgui.next_column()
            imgui.next_column()
            imgui.separator()

            for user in self.banList["ip_addresses"]:
                imgui.text(user)
                imgui.next_column()

            imgui.columns(1)
            imgui.end_child()

            imgui.begin_child("left_selection", width=299)

            clicked, current = imgui.combo("##Path input",
                                           self.banUserSelected,
                                           self.banList["users"])

            imgui.same_line()

            if (imgui.button("Unban")):
                self.alert("Unbanning User (" +
                           self.banList["users"][self.banUserSelected] + ")")
                del self.banList["users"][self.banUserSelected]
                self.saveBanList()

            imgui.end_child()

            imgui.same_line()

            imgui.begin_child("right_selection", width=299)

            clicked, current = imgui.combo("##Path input", self.banIPSelected,
                                           self.banList["ip_addresses"])

            imgui.same_line()

            if (imgui.button("Unban")):
                self.alert("Unbanning IP (" +
                           self.banList["ip_addresses"][self.banIPSelected] +
                           ")")
                del self.banList["ip_addresses"][self.banIPSelected]
                self.saveBanList()

            imgui.end_child()

        imgui.end_child()

        imgui.same_line()

        imgui.begin_child("ssh_alerts")
        imgui.text("SSH Connections Alerts")

        imgui.begin_child("ssh_alerts_logger", border=True)

        for message in self.alerts:
            imgui.text_wrapped(message)

        imgui.end_child()
        imgui.end_child()
Exemplo n.º 17
0
 def render(self):
     imgui.columns(len(self.attrs), 'alertList')
     list(map(self.render_header,self.attrs))
     imgui.separator()
     list(map(self.render_row,self.processList))
     imgui.columns(1)
    def run(self):
        # Loop until the user closes the window
        while not glfw.window_should_close(self.window):
            # Poll for and process events
            glfw.poll_events()

            # build gui.
            self.impl.process_inputs()

            w, h = glfw.get_window_size(self.window)
            glViewport(0, 0, w, h)

            imgui.new_frame()

            timeline_height = 35
            imgui.push_style_var(imgui.STYLE_WINDOW_ROUNDING, 0)
            imgui.push_style_var(imgui.STYLE_FRAME_ROUNDING, 0)

            imgui.set_next_window_position(0, h - timeline_height - 10)
            imgui.set_next_window_size(w, timeline_height)

            imgui.begin(
                "Timeline", False, imgui.WINDOW_NO_TITLE_BAR
                | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_SCROLLBAR)
            imgui.columns(1)
            imgui.same_line(0, 0)
            imgui.push_item_width(-50)
            changed, value = imgui.slider_int("", self.sliderValue, 0,
                                              self.num_scans - 1)
            if changed: self.sliderValue = value
            if self.sliderValue != self.currentTimestep:
                self.currentTimestep = self.sliderValue

            imgui.push_style_var(imgui.STYLE_FRAME_ROUNDING, 3)

            play_delay = 1
            refresh_rate = 0.05

            current_time = time.time()

            imgui.same_line(spacing=5)
            changed = imgui.button("<", 20)
            if self.currentTimestep > 0:
                # just a click
                if changed:
                    self.currentTimestep = self.sliderValue = self.currentTimestep - 1
                    self.lastUpdate = current_time

                # button pressed.
                if imgui.is_item_active() and not self.button_backward_hold:
                    self.hold_start = current_time
                    self.button_backward_hold = True

                if not imgui.is_item_active() and self.button_backward_hold:
                    self.button_backward_hold = False

                # start playback when button pressed long enough
                if self.button_backward_hold and (
                    (current_time - self.hold_start) > play_delay):
                    if (current_time - self.lastUpdate) > refresh_rate:
                        self.currentTimestep = self.sliderValue = self.currentTimestep - 1
                        self.lastUpdate = current_time

            imgui.same_line(spacing=2)
            changed = imgui.button(">", 20)

            if self.currentTimestep < self.num_scans - 1:
                # just a click
                if changed:
                    self.currentTimestep = self.sliderValue = self.currentTimestep + 1
                    self.lastUpdate = current_time

                # button pressed.
                if imgui.is_item_active() and not self.button_forward_hold:
                    self.hold_start = current_time
                    self.button_forward_hold = True

                if not imgui.is_item_active() and self.button_forward_hold:
                    self.button_forward_hold = False

                # start playback when button pressed long enough
                if self.button_forward_hold and (
                    (current_time - self.hold_start) > play_delay):
                    if (current_time - self.lastUpdate) > refresh_rate:
                        self.currentTimestep = self.sliderValue = self.currentTimestep + 1
                        self.lastUpdate = current_time

            imgui.pop_style_var(3)
            imgui.end()

            imgui.set_next_window_position(20, 20, imgui.FIRST_USE_EVER)
            imgui.set_next_window_size(200, 150, imgui.FIRST_USE_EVER)
            imgui.begin("Show Data")

            if len(self.subdirs) > 1:
                for i, subdir in enumerate(self.subdirs):
                    changed, value = imgui.checkbox(subdir,
                                                    self.current_subdir == i)
                    if i < len(self.subdirs) - 1: imgui.same_line()
                    if changed and value: self.current_subdir = i

            subdir = self.subdirs[self.current_subdir]

            data_available = "input" in self.availableData[subdir]
            if data_available:
                imgui.push_style_var(imgui.STYLE_ALPHA, 1.0)
            else:
                imgui.push_style_var(imgui.STYLE_ALPHA, 0.3)

            changed, value = imgui.checkbox("input", self.showInput)
            if changed and value and data_available:
                self.showInput = True
                self.showLabels = False

            imgui.pop_style_var()

            data_available = "labels" in self.availableData[subdir]
            if data_available:
                imgui.push_style_var(imgui.STYLE_ALPHA, 1.0)
            else:
                imgui.push_style_var(imgui.STYLE_ALPHA, 0.3)

            changed, value = imgui.checkbox("labels", self.showLabels)
            if changed and value and data_available:
                self.showInput = False
                self.showLabels = True

            imgui.pop_style_var()

            data_available = "invalid" in self.availableData[subdir]
            if data_available:
                imgui.push_style_var(imgui.STYLE_ALPHA, 1.0)
            else:
                imgui.push_style_var(imgui.STYLE_ALPHA, 0.3)

            changed, value = imgui.checkbox("invalid", self.showInvalid)
            if changed and data_available: self.showInvalid = value

            imgui.pop_style_var()

            data_available = "occluded" in self.availableData[subdir]
            if data_available:
                imgui.push_style_var(imgui.STYLE_ALPHA, 1.0)
            else:
                imgui.push_style_var(imgui.STYLE_ALPHA, 0.3)

            changed, value = imgui.checkbox("occluded", self.showOccluded)
            if changed and data_available: self.showOccluded = value

            imgui.pop_style_var()

            imgui.end()

            # imgui.show_demo_window()

            showData = []
            if self.showInput: showData.append("input")
            if self.showOccluded: showData.append("occluded")
            if self.showInvalid: showData.append("invalid")

            mvp = self.projection_ @ self.cam.matrix @ self.conversion_

            glClearColor(1.0, 1.0, 1.0, 1.0)

            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
            glBindVertexArray(self.vao)

            self.program.bind()
            self.program["mvp"] = mvp.transpose()
            self.program["view_mat"] = (
                self.cam.matrix @ self.conversion_).transpose()
            self.program["lightPos"] = glow.vec3(10, 10, 10)
            self.program["voxel_scale"] = 0.8
            self.program["voxel_alpha"] = 1.0
            self.program["use_label_colors"] = True

            self.label_colors.bind(0)

            if self.showLabels:
                self.setCurrentBufferData("labels", self.currentTimestep)
                glDrawArraysInstanced(GL_TRIANGLES, 0, 36, self.num_instances)

            self.program["use_label_colors"] = False
            self.program["voxel_color"] = glow.vec3(0.3, 0.3, 0.3)

            self.program["voxel_alpha"] = 0.5

            for data_name in showData:
                self.program["voxel_scale"] = 0.5
                if data_name == "input": self.program["voxel_scale"] = 0.8

                self.setCurrentBufferData(data_name, self.currentTimestep)
                glDrawArraysInstanced(GL_TRIANGLES, 0, 36, self.num_instances)

            self.program.release()
            self.label_colors.release(0)

            glBindVertexArray(self.vao_no_points)

            self.prgDrawPose.bind()
            self.prgDrawPose["mvp"] = mvp.transpose()
            self.prgDrawPose["pose"] = np.identity(4, dtype=np.float32)
            self.prgDrawPose["size"] = 1.0

            glDrawArrays(GL_POINTS, 0, 1)
            self.prgDrawPose.release()

            glBindVertexArray(0)

            # draw gui ontop.
            imgui.render()
            self.impl.render(imgui.get_draw_data())

            # Swap front and back buffers
            glfw.swap_buffers(self.window)
Exemplo n.º 19
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
Exemplo n.º 20
0
    def onDrawGuiCallback(self, args):
        p = BigWorld.player()
        if self.visible:
            if imgui.begin("Quester##Quester_mainwindow", (300,350)):
                imgui.columns(2)
                imgui.separator()
                imgui.text("Name")
                imgui.nextColumn()
                if p:
                    imgui.text(p.playerName)
                else:
                    imgui.text("Not ingame")
                imgui.nextColumn()
                imgui.text("Map ID")
                imgui.nextColumn()
                if p:
                    imgui.text(str(p.mapID))
                else:
                    imgui.text("Not ingame")
                imgui.nextColumn()
                imgui.text("Experience")
                imgui.nextColumn()
                if p:
                    exp_label = '{0} / {1}'.format(p.exp, data.avatar_lv_data.data.get(p.realLv, {}).get('upExp', '?'))
                    imgui.text(exp_label)
                    imgui.nextColumn()
                else:
                    imgui.text("Not ingame")
                    imgui.nextColumn()
                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("Active quest")
                imgui.nextColumn()
                if self.bot.running and self.bot.currentQuestCompletor:
                    imgui.text(str(self.bot.currentQuestCompletor.questId))
                else:
                    imgui.text("N/A")
                imgui.nextColumn()
                imgui.text("Quest state")
                imgui.nextColumn()
                if self.bot.running and self.bot.currentQuestCompletor:
                    imgui.text(self.bot.currentQuestCompletor.state)
                else:
                    imgui.text("N/A")
                imgui.nextColumn()
                imgui.columns(1)
                imgui.separator()

                if not self.bot.running:
                    if imgui.button("Start##Quester_start_bot", (imgui.getContentRegionAvail()[0], 25)):
                        try:
                            combat_inst = combats.LOADED_COMBATS[combats.LOADED_COMBATS.keys()[self.combatSelectedIndex]]
                            self.bot.start(combat_inst)
                        except IndexError:
                            roplus.log("Please select a combat script first !")
                else:
                    if imgui.button("Stop##Quester_stop_bot", (imgui.getContentRegionAvail()[0], 25)):
                        self.bot.stop()

                imgui.separator()
                if imgui.button("Save settings##Quester_save_settings", (imgui.getContentRegionAvail()[0], 25)):
                    settings.saveSettings(self.bot.settings, "Quester")

                #
                # Combats
                #
                if imgui.collapsingHeader("Combats##Quester_combats_settings", 0x20):
                    selectedChanged, self.combatSelectedIndex = imgui.combo("##Quester_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##Quester_reload_scripts", (imgui.getContentRegionAvail()[0], 24)):
                        combats.reloadCombatModules()

                #
                # Quest Logs
                #
                if imgui.collapsingHeader("[Debug] Quests Info##Quester_questslog"):
                    if p and p.questInfoCache:
                        for category, questIds in p.questInfoCache.items():
                            if imgui.treeNode("[{}] {}".format(str(len(questIds)), category)):
                                for questId in questIds:
                                    questDetails = p.genQuestDetail(questId, -1)
                                    questData = QuestData.data.get(questId, {})
                                    if questData and imgui.treeNode("[{}] {}".format(str(questId), questData.get("name", ""))):
                                        if questDetails and questDetails.get("taskGoal", {}) and imgui.treeNode("Quest goals ({})##questid_{}".format(str(len(questDetails["taskGoal"])), str(questId))):
                                            for i, taskGoal in enumerate(questDetails["taskGoal"]):
                                                questGoal = QuestGoal(taskGoal)
                                                if imgui.treeNode("[{0}] {1}##quest_goal_{2}_{0}".format(str(i+1), questGoal.description, str(questId))):
                                                    imgui.text("State : {}".format(str(questGoal.state)))
                                                    imgui.text("Type : {}".format(str(questGoal.type)))
                                                    imgui.text("Track Seek ID : {}".format(str(questGoal.trackSeekId)))
                                                    imgui.text("Track Task Type : {}".format(str(questGoal.trackTaskType)))
                                                    imgui.text("Order : {}".format(str(questGoal.order)))
                                                    if questGoal.trackSeekData and imgui.treeNode("Track Task data##questid_{}_{}".format(str(questId), str(i))):
                                                        for k,v in questGoal.trackSeekData.items():
                                                            imgui.text("{} -> {}".format(str(k), str(v)))
                                                        imgui.treePop()
                                                    imgui.treePop()
                                            imgui.treePop()
                                        if questData and imgui.treeNode("Quest data##questid_{}".format(str(questId))):
                                            for k,v in questData.items():
                                                imgui.text("{} -> {}".format(str(k), str(v)))
                                            imgui.treePop()
                                        if questDetails and imgui.treeNode("Quest details##questid_{}".format(str(questId))):
                                            for k,v in questDetails.items():
                                                imgui.text("{} -> {}".format(str(k), str(v)))
                                            imgui.treePop()
                                        imgui.treePop()
                                imgui.treePop()
                            #for questInfo in roplus.helpers.questing.getQuestInfosFromCache(questCategory):
                            #    if imgui.treeNode("["+questCategory+"] "+questInfo.getName()+"##" + str(questInfo.questId)):
                            #        if imgui.treeNode("-> Quest Data##" + str(questInfo.questId)):
                            #            for k,v in questInfo.questData.items():
                            #                imgui.text(str(k) + " -> " + str(v))
                            #            imgui.treePop()
                            #        if imgui.treeNode("-> Quest Details##" + str(questInfo.questId)):
                            #            for k,v in player.genQuestDetail(questInfo.questId, -1).items():
                            #                imgui.text(str(k) + " -> " + str(v))
                            #            imgui.treePop()
                            #        imgui.treePop()
        
            imgui.end()
Exemplo n.º 21
0
def render_plugins_ui(window):
    "Draw UI windows for all plugins active for the current drawing."
    if not window.drawing:
        return

    drawing = window.drawing

    deactivated = set()
    for name, args in window.drawing.active_plugins.items():
        plugin, sig = window.plugins[name]
        _, opened = imgui.begin(f"{ name } ##{ drawing.path or drawing.uuid }",
                                True)
        if not opened:
            deactivated.add(name)
        imgui.columns(2)
        for param_name, param_sig in islice(sig.items(), 4, None):
            if param_sig.annotation == inspect._empty:
                continue
            imgui.text(param_name)
            imgui.next_column()
            default_value = args.get(param_name)
            if default_value is not None:
                value = default_value
            else:
                value = param_sig.default
            label = f"##{param_name}_val"
            if param_sig.annotation == int:
                changed, args[param_name] = imgui.drag_int(label, value)
            elif param_sig.annotation == float:
                changed, args[param_name] = imgui.drag_float(label, value)
            elif param_sig.annotation == str:
                changed, args[param_name] = imgui.input_text(label, value, 20)
            elif param_sig.annotation == bool:
                changed, args[param_name] = imgui.checkbox(label, value)
            imgui.next_column()
        imgui.columns(1)

        texture_and_size = getattr(plugin, "texture", None)
        if texture_and_size:
            texture, size = texture_and_size
            w, h = size
            ww, wh = imgui.get_window_size()
            scale = max(1, (ww - 10) // w)
            imgui.image(texture.name,
                        w * scale,
                        h * scale,
                        border_color=(1, 1, 1, 1))

        if hasattr(plugin, "ui"):
            result = plugin.ui(oldpaint, imgui, window.drawing, window.brush,
                               **args)
            if result:
                args.update(result)

        last_run = getattr(plugin, "last_run", 0)
        period = getattr(plugin, "period", None)
        t = time()
        # TODO I've seen more readable if-statements in my days...
        if callable(plugin) and ((period and t > last_run + period) or
                                 (not period and imgui.button("Execute"))):
            plugin.last_run = t
            try:
                result = plugin(oldpaint, imgui, window.drawing, window.brush,
                                **args)
                if result:
                    args.update(result)
            except Exception:
                # We don't want crappy plugins to ruin everything
                # Still probably probably possible to crash opengl though...
                logger.error(f"Plugin {name}: {format_exc()}")

        imgui.button("Help")
        if imgui.begin_popup_context_item("Help", mouse_button=0):
            if plugin.__doc__:
                imgui.text(inspect.cleandoc(plugin.__doc__))
            else:
                imgui.text("No documentation available.")
            imgui.end_popup()

        imgui.end()
    for name in deactivated:
        window.drawing.active_plugins.pop(name, None)
Exemplo n.º 22
0
def interface():
    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()
        if imgui.begin_menu('Windows', True):
            clicked_fixtureC, selected_fixtureC = imgui.menu_item(
                'Fixture Controls', shortcut=None)
            if clicked_fixtureC:
                if values.showFixtureControl:
                    values.showFixtureControl = False
                else:
                    values.showFixtureControl = True

            imgui.end_menu()
        imgui.end_main_menu_bar()

    if values.showFixtureControl:
        imgui.begin("Fixture Control", True)
        for r in patch.rooms.values():
            expanded, visible = imgui.collapsing_header(r.name)
            if expanded:
                imgui.indent()
                for f in r.fixtureList:
                    expanded, visible = imgui.collapsing_header(f.name)
                    rgb = values.values[f.name]
                    if expanded:
                        imgui.columns(2, f.name)
                        imgui.indent()
                        imgui.text('Red')
                        changed, value = imgui.slider_int(
                            '##int%sred' % f.name, rgb[0], 0, 255)
                        if changed:
                            rgb[0] = value
                            ui.cache(f.setColor, [rgb, 0.2])
                            ui.update()
                        imgui.text('Green')
                        changed, value = imgui.slider_int(
                            '##int%sgreen' % f.name, rgb[1], 0, 255)
                        if changed:
                            rgb[1] = value
                            ui.cache(f.setColor, [rgb, 0.2])
                            ui.update()
                        imgui.text('Blue')
                        changed, value = imgui.slider_int(
                            '##int%sblue' % f.name, rgb[2], 0, 255)
                        if changed:
                            rgb[2] = value
                            ui.cache(f.setColor, [rgb, 0.2])
                            ui.update()
                        imgui.next_column()
                        imgui.color_button('Color Sample',
                                           rgb[0] / 255,
                                           rgb[1] / 255,
                                           rgb[2] / 255,
                                           width=100,
                                           height=100)
                        imgui.columns(1)
                        imgui.unindent()
                imgui.unindent()
        imgui.same_line(spacing=50)
        imgui.end()