Exemplo n.º 1
0
 def addMenus(self):
     # character menu options are added dynamically by CharacterDetector, so we pass this into that
     self.characterMenu = tk.Menubutton(text="Character...", background="black", fg="white", borderwidth="1",
                                   highlightbackground="black", highlightthickness="1",
                                   activebackground="gray25", activeforeground="white")
     self.characterMenu.grid(row="5", column="2")
     self.characterMenu.menu = tk.Menu(self.characterMenu, tearoff=False)
     self.characterMenu["menu"] = self.characterMenu.menu
     self.characterDetector = logreader.CharacterDetector(self, self.characterMenu)
     
     # Set up file menu options
     self.mainMenu = tk.Menubutton(text="File...", background="black", fg="white", borderwidth="1",
                                   highlightbackground="black", highlightthickness="1",
                                   activebackground="gray25", activeforeground="white")
     self.mainMenu.grid(row="5", column="1")
     self.mainMenu.menu = tk.Menu(self.mainMenu, tearoff=False)
     self.mainMenu["menu"] = self.mainMenu.menu
     self.mainMenu.menu.add_command(label="Edit Profile Settings", command=lambda: settingsWindow.SettingsWindow(self))
     
     # add all the profiles from settings into the menu
     self.profileMenu = tk.Menu(self.mainMenu, tearoff=False)
     settings.initializeMenu(self)
     
     self.mainMenu.menu.add_cascade(label="Profile", menu=self.profileMenu)
     self.mainMenu.menu.add_separator()
     self.mainMenu.menu.add_command(label="Fleet Mode", command=lambda: fleetConnectionWindow.FleetWindow(self))
     self.mainMenu.menu.add_separator()
     self.mainMenu.menu.add_command(label="Simulate Input", command=lambda: simulationWindow.SimulationWindow(self))
     getLogFilePath = lambda: tk.filedialog.askopenfilename(initialdir=self.characterDetector.path, title="Select log file")
     self.mainMenu.menu.add_command(label="Playback Log", command=lambda: self.characterDetector.playbackLog(getLogFilePath()))
     self.mainMenu.menu.add_separator()
     self.mainMenu.menu.add_command(label="Quit", command=self.quitEvent)
Exemplo n.º 2
0
    def addMenus(self):
        # character menu options are added dynamically by CharacterDetector, so we pass this into that
        self.characterMenu = tk.Menubutton(text="人物",
                                           background="black",
                                           fg="white",
                                           borderwidth="1",
                                           highlightbackground="black",
                                           highlightthickness="1",
                                           activebackground="gray25",
                                           activeforeground="white")
        self.characterMenu.grid(row="5", column="2")
        self.characterMenu.menu = tk.Menu(self.characterMenu, tearoff=False)
        self.characterMenu["menu"] = self.characterMenu.menu
        self.characterDetector = logreader.CharacterDetector(
            self, self.characterMenu)

        # Set up file menu options
        self.mainMenu = tk.Menubutton(text="文件",
                                      background="black",
                                      fg="white",
                                      borderwidth="1",
                                      highlightbackground="black",
                                      highlightthickness="1",
                                      activebackground="gray25",
                                      activeforeground="white")
        self.mainMenu.grid(row="5", column="1")
        self.mainMenu.menu = tk.Menu(self.mainMenu, tearoff=False)
        self.mainMenu["menu"] = self.mainMenu.menu
        self.mainMenu.menu.add_command(
            label="个人配置设置...",
            command=lambda: settingsWindow.SettingsWindow(self))

        # add all the profiles from settings into the menu
        self.profileMenu = tk.Menu(self.mainMenu, tearoff=False)
        settings.initializeMenu(self)

        self.mainMenu.menu.add_cascade(label="配置", menu=self.profileMenu)
        self.mainMenu.menu.add_separator()
        self.mainMenu.menu.add_command(label="清除总量/峰值", state=tk.DISABLED)
        self.mainMenu.menu.add_separator()
        self.mainMenu.menu.add_command(
            label="舰队模式",
            command=lambda: fleetConnectionWindow.FleetWindow(self))
        self.mainMenu.menu.add_separator()
        self.mainMenu.menu.add_command(
            label="开始模拟",
            command=lambda: simulationWindow.SimulationWindow(self))
        getLogFilePath = lambda: tk.filedialog.askopenfilename(
            initialdir=self.characterDetector.path, title="选择战斗记录文件")
        self.mainMenu.menu.add_command(label="回放战斗记录",
                                       command=lambda: self.characterDetector.
                                       playbackLog(getLogFilePath()))
        self.mainMenu.menu.add_separator()
        self.mainMenu.menu.add_command(label="退出", command=self.quitEvent)
Exemplo n.º 3
0
    def changeSettings(self):
        """This function is called when a user changes settings after the settings are verified"""
        if self.is_alive():
            self.paused = True
            self.mainWindow.after_cancel(self.animate)
            self.graph.subplot.clear()
        if self.simulationEnabled:
            self.simulationSettings(enable=False)
            self.mainWindow.mainMenu.menu.delete(7)
            self.mainWindow.mainMenu.menu.insert_command(
                7,
                label="Simulate Input",
                command=lambda: simulationWindow.SimulationWindow(self.
                                                                  mainWindow))
            self.mainWindow.topLabel.grid_remove()
            self.mainWindow.mainMenu.menu.entryconfig(5, state="normal")

        self.slowDown = False
        self.seconds = settings.getSeconds()
        self.interval = settings.getInterval()
        self.categories["dpsOut"]["settings"] = settings.getDpsOutSettings()
        self.categories["dpsIn"]["settings"] = settings.getDpsInSettings()
        self.categories["logiOut"]["settings"] = settings.getLogiOutSettings()
        self.categories["logiIn"]["settings"] = settings.getLogiInSettings()
        self.categories["capTransfered"][
            "settings"] = settings.getCapTransferedSettings()
        self.categories["capRecieved"][
            "settings"] = settings.getCapRecievedSettings()
        self.categories["capDamageOut"][
            "settings"] = settings.getCapDamageOutSettings()
        self.categories["capDamageIn"][
            "settings"] = settings.getCapDamageInSettings()
        self.categories["mining"]["settings"] = settings.getMiningSettings()
        self.graphDisabled = settings.getGraphDisabled()

        if self.graphDisabled:
            self.graph.grid_remove()
        else:
            self.graph.grid()

        self.labelHandler.redoLabels()
        self.mainWindow.makeAllChildrenDraggable(self.labelHandler)

        if settings.detailsWindowShow:
            self.mainWindow.detailsWindow.deiconify()
        else:
            self.mainWindow.detailsWindow.withdraw()

        if self.fleetMode and settings.fleetWindowShow:
            self.mainWindow.fleetWindow.deiconify()
        else:
            self.mainWindow.fleetWindow.withdraw()

        self.arrayLength = int((self.seconds * 1000) / self.interval)
        historicalTemplate = [0] * self.arrayLength
        yValuesTemplate = np.array([0] * self.arrayLength)
        ySmooth = self.graph.smoothListGaussian(yValuesTemplate, 5)
        # resets all the arrays to contain no values
        showAnyPeakOrTotal = False
        for category, items in self.categories.items():
            if items["settings"]:
                self.labelHandler.enableLabel(category, True)
                showPeak = items["settings"][0].get("showPeak", False)
                self.labelHandler.enablePeak(category, showPeak)
                showTotal = items["settings"][0].get("showTotal", False)
                findColor = lambda x, category=category: self.findColor(
                    category, x)
                showAnyPeakOrTotal = showAnyPeakOrTotal or showPeak or showTotal
                self.labelHandler.enableTotal(category, findColor, showTotal)
                self.detailsHandler.enableLabel(category, True)
                items["historical"] = historicalTemplate.copy()
                items["historicalDetails"] = [[]] * self.arrayLength
                items["yValues"] = yValuesTemplate.copy()
                items["labelOnly"] = items["settings"][0].get(
                    "labelOnly", False)
                if not items["labelOnly"]:
                    plotLine, = self.graph.subplot.plot(ySmooth,
                                                        zorder=items["zorder"])
                    items["lines"] = [plotLine]
            else:
                self.labelHandler.enableLabel(category, False)
                self.labelHandler.enablePeak(category, False)
                self.detailsHandler.enableLabel(category, False)

        self.mainWindow.showClearMenuOption(
            showAnyPeakOrTotal,
            lambda: self.labelHandler.clearValues(self.findColor))

        if not self.graphDisabled:
            self.graph.subplot.margins(0, 0)
            self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100)
            self.graph.graphFigure.canvas.draw()

        # reset fleet data
        characterName = self.mainWindow.fleetWindow.characterName
        if self.dataQueue:
            self.fleetData = {
                'aggregate': {
                    'dpsOut': {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    },
                    'dpsIn': {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    },
                    'logiOut': {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                },
                'dpsOut': {
                    characterName: {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                },
                'dpsIn': {
                    characterName: {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                },
                'logiOut': {
                    characterName: {
                        'historical': historicalTemplate.copy(),
                        'yValues': yValuesTemplate.copy()
                    }
                }
            }
        self.mainWindow.fleetWindow.resetGraphs(ySmooth)
        self.mainWindow.fleetWindow.changeSettings()

        self.paused = False
Exemplo n.º 4
0
 def changeSettings(self):
     """This function is called when a user changes settings after the settings are verified"""
     if self.is_alive():
         self.paused = True
         self.mainWindow.after_cancel(self.animate)
         self.graph.subplot.clear()
     if self.simulationEnabled:
         self.simulationSettings(enable=False)
         self.mainWindow.mainMenu.menu.delete(5)
         self.mainWindow.mainMenu.menu.insert_command(5, label="Simulate Input", command=lambda: simulationWindow.SimulationWindow(self.mainWindow))
         self.mainWindow.topLabel.grid_remove()
         self.mainWindow.mainMenu.menu.entryconfig(3, state="normal")
     
     self.slowDown = False
     self.seconds = settings.getSeconds()
     self.interval = settings.getInterval()
     self.categories["dpsOut"]["settings"] = settings.getDpsOutSettings()
     self.categories["dpsIn"]["settings"] = settings.getDpsInSettings()
     self.categories["logiOut"]["settings"] = settings.getLogiOutSettings()
     self.categories["logiIn"]["settings"] = settings.getLogiInSettings()
     self.categories["capTransfered"]["settings"] = settings.getCapTransferedSettings()
     self.categories["capRecieved"]["settings"] = settings.getCapRecievedSettings()
     self.categories["capDamageOut"]["settings"] = settings.getCapDamageOutSettings()
     self.categories["capDamageIn"]["settings"] = settings.getCapDamageInSettings()
     self.categories["mining"]["settings"] = settings.getMiningSettings()
     self.graphDisabled = settings.getGraphDisabled()
     
     if self.graphDisabled:
         self.graph.grid_remove()
     else:
         self.graph.grid()
     
     self.labelHandler.redoLabels()
     
     if settings.detailsWindowShow:
         self.mainWindow.detailsWindow.deiconify()
     else:
         self.mainWindow.detailsWindow.withdraw()
     
     # resets all the arrays to contain no values
     for category, items in self.categories.items():
         if items["settings"]:
             self.labelHandler.enableLabel(category, True)
             self.detailsHandler.enableLabel(category, True)
             items["historical"] = [0] * int((self.seconds*1000)/self.interval)
             items["historicalDetails"] = [[]] * int((self.seconds*1000)/self.interval)
             items["yValues"] = np.array([0] * int((self.seconds*1000)/self.interval))
             try:
                 items["labelOnly"] = items["settings"][0]["labelOnly"]
             except KeyError:
                 items["settings"][0]["labelOnly"] = False
                 items["labelOnly"] = items["settings"][0]["labelOnly"]
             if not items["labelOnly"]:
                 ySmooth = self.graph.smoothListGaussian(items["yValues"], 5)
                 plotLine, = self.graph.subplot.plot(ySmooth, zorder=items["zorder"])
                 items["lines"] = [plotLine]
         else:
             self.labelHandler.enableLabel(category, False)
             self.detailsHandler.enableLabel(category, False)
     
     if not self.graphDisabled:
         self.graph.subplot.margins(0,0)
         self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100)
         self.graph.graphFigure.canvas.draw()
     
     self.paused = False