Пример #1
0
    def __init__(self):
        print("Tekken Bot Starting...")

        self.tekken_config = ConfigReader("frame_data_overlay")

        self.launcher = FrameDataLauncher()

        self.overlay_visible = False

        Tk.__init__(self)

        self.wm_title("Tekken Bot: Frame Data Overlay")
        self.wm_attributes("-transparentcolor", "white")
        self.attributes("-topmost", True)
        self.attributes("-alpha", "0.75")

        self.iconbitmap('TekkenData/tekken_bot_close.ico')
        self.overrideredirect(True)
        self.configure(background='white')

        self.s = Style()
        self.s.theme_use('alt')
        self.s.configure('.', background='black')
        self.s.configure('.', foreground='black')

        Grid.columnconfigure(self, 0, weight=0)
        Grid.columnconfigure(self, 1, weight=1)
        Grid.columnconfigure(self, 2, weight=0)
        Grid.rowconfigure(self, 0, weight=1)
        Grid.rowconfigure(self, 1, weight=0)

        self.fa_p1_var = self.create_frame_advantage_label(0)
        self.fa_p2_var = self.create_frame_advantage_label(2)


        self.at_p1_var = self.create_attack_type_label(0)
        self.at_p2_var = self.create_attack_type_label(2)

        self.text = self.create_textbox()

        self.stdout = sys.stdout
        self.redirector = TextRedirector(self.stdout, self.text, self.s, self.fa_p1_var, self.fa_p2_var, self.at_p1_var, self.at_p2_var)
        self.redirect_stdout()
        print("move | type | startup | damage | block | hit | active")
        self.restore_stdout()
Пример #2
0
    def __init__(self):
        self.test = True
        Tk.__init__(self)
        self.wm_title("Tekken Bot Prime")
        self.count = 0
        self.launcher = FrameDataLauncher(False)
        self.overlay = GUI_TestOverlay(self, self.launcher)
        self.LastOutput = ""
        self.LastMove = ""
        self.overlay.update_location()
        self.CurrentStance = "Standing"
        self.NeutralStances = [
            'Universal_32769',
        ]

        self.FlamingoStances = [
            'Hw_lk00F',
            'Gpe_lk02LF',
        ]

        self.update_launcher()
Пример #3
0
    def __init__(self, master):
        print("Tekken Bot Starting...")

        is_windows_7 = 'Windows-7' in platform.platform()
        self.tekken_config = ConfigReader("frame_data_overlay")
        self.is_draggable_window = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.overlay_as_draggable_window.name, False)
        self.is_minimize_on_lost_focus = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.only_appears_when_Tekken_7_has_focus.name, True)
        self.is_transparency = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.transparent_background.name, not is_windows_7)
        self.is_overlay_on_top = not self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.overlay_on_bottom.name, False)
        self.enable_nerd_data = self.tekken_config.get_property(
            DisplaySettings.config_name(), "data_for_nerds", False)
        self.show_live_framedata = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.tiny_live_frame_data_numbers.name, True)
        self.mode = OverlayMode.FrameData

        self.launcher = FrameDataLauncher(self.enable_nerd_data)

        self.overlay_visible = False
        if master == None:
            self.toplevel = Tk()
        else:
            self.toplevel = Toplevel()

        self.toplevel.wm_title("Tekken Bot: Frame Data Overlay")

        self.toplevel.attributes("-topmost", True)

        self.background_color = CurrentColorScheme.dict[
            ColorSchemeEnum.background]

        if self.is_transparency:
            self.tranparency_color = CurrentColorScheme.dict[
                ColorSchemeEnum.transparent]
            self.toplevel.wm_attributes("-transparentcolor",
                                        self.tranparency_color)
            self.toplevel.attributes("-alpha", "0.75")
        else:
            if is_windows_7:
                print("Windows 7 detected. Disabling transparency.")
            self.tranparency_color = self.background_color
        self.toplevel.configure(background=self.tranparency_color)

        self.w = 1000
        self.h = 86

        if self.enable_nerd_data:
            self.w += 400

        self.toplevel.geometry(str(self.w) + 'x' + str(self.h))

        self.toplevel.iconbitmap('TekkenData/tekken_bot_close.ico')
        if not self.is_draggable_window:
            self.toplevel.overrideredirect(True)

        self.s = Style()
        self.s.theme_use('alt')
        self.s.configure('.', background=self.background_color)
        self.s.configure(
            '.',
            foreground=CurrentColorScheme.dict[ColorSchemeEnum.advantage_text])

        Grid.columnconfigure(self.toplevel, 0, weight=0)
        Grid.columnconfigure(self.toplevel, 1, weight=0)
        Grid.columnconfigure(self.toplevel, 2, weight=0)
        Grid.columnconfigure(self.toplevel, 3, weight=1)
        Grid.columnconfigure(self.toplevel, 4, weight=0)
        Grid.columnconfigure(self.toplevel, 5, weight=0)
        Grid.columnconfigure(self.toplevel, 6, weight=0)
        Grid.rowconfigure(self.toplevel, 0, weight=1)
        Grid.rowconfigure(self.toplevel, 1, weight=0)

        self.s.configure('TFrame', background=self.tranparency_color)
        self.fa_p1_var, fa_p1_label = self.create_frame_advantage_label(1)
        self.fa_p2_var, fa_p2_label = self.create_frame_advantage_label(5)

        self.l_margin = self.create_padding_frame(0)
        self.r_margin = self.create_padding_frame(6)
        self.l_seperator = self.create_padding_frame(2)
        self.r_seperator = self.create_padding_frame(4)

        if self.show_live_framedata:
            self.l_live_recovery = self.create_live_recovery(fa_p1_label, 0)
            self.r_live_recovery = self.create_live_recovery(fa_p2_label, 0)

        self.text = self.create_textbox(3)

        self.stdout = sys.stdout
        self.redirector = TextRedirector(self.stdout, self.text, self.s,
                                         self.fa_p1_var, self.fa_p2_var)
        self.text.configure(state="normal")
        self.text.delete("1.0", "end")
        #self.text.insert("1.0", "{:^5}|{:^8}|{:^9}|{:^7}|{:^5}|{:^5}|{:^8}|{:^5}|{:^5}|{:^7}|{:^5}|{}\n".format(" input ", "type", "startup", "block", "hit", "CH", "active", "track", "tot", "rec", "stun", "notes"))
        #self.redirector.populate_column_names(self.get_data_columns())
        self.redirector.set_columns_to_print(self.get_data_columns())

        self.text.configure(state="disabled")
Пример #4
0
class GUI_FrameDataOverlay():
    def __init__(self, master):
        print("Tekken Bot Starting...")

        is_windows_7 = 'Windows-7' in platform.platform()
        self.tekken_config = ConfigReader("frame_data_overlay")
        self.is_draggable_window = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.overlay_as_draggable_window.name, False)
        self.is_minimize_on_lost_focus = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.only_appears_when_Tekken_7_has_focus.name, True)
        self.is_transparency = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.transparent_background.name, not is_windows_7)
        self.is_overlay_on_top = not self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.overlay_on_bottom.name, False)
        self.enable_nerd_data = self.tekken_config.get_property(
            DisplaySettings.config_name(), "data_for_nerds", False)
        self.show_live_framedata = self.tekken_config.get_property(
            DisplaySettings.config_name(),
            DisplaySettings.tiny_live_frame_data_numbers.name, True)
        self.mode = OverlayMode.FrameData

        self.launcher = FrameDataLauncher(self.enable_nerd_data)

        self.overlay_visible = False
        if master == None:
            self.toplevel = Tk()
        else:
            self.toplevel = Toplevel()

        self.toplevel.wm_title("Tekken Bot: Frame Data Overlay")

        self.toplevel.attributes("-topmost", True)

        self.background_color = CurrentColorScheme.dict[
            ColorSchemeEnum.background]

        if self.is_transparency:
            self.tranparency_color = CurrentColorScheme.dict[
                ColorSchemeEnum.transparent]
            self.toplevel.wm_attributes("-transparentcolor",
                                        self.tranparency_color)
            self.toplevel.attributes("-alpha", "0.75")
        else:
            if is_windows_7:
                print("Windows 7 detected. Disabling transparency.")
            self.tranparency_color = self.background_color
        self.toplevel.configure(background=self.tranparency_color)

        self.w = 1000
        self.h = 86

        if self.enable_nerd_data:
            self.w += 400

        self.toplevel.geometry(str(self.w) + 'x' + str(self.h))

        self.toplevel.iconbitmap('TekkenData/tekken_bot_close.ico')
        if not self.is_draggable_window:
            self.toplevel.overrideredirect(True)

        self.s = Style()
        self.s.theme_use('alt')
        self.s.configure('.', background=self.background_color)
        self.s.configure(
            '.',
            foreground=CurrentColorScheme.dict[ColorSchemeEnum.advantage_text])

        Grid.columnconfigure(self.toplevel, 0, weight=0)
        Grid.columnconfigure(self.toplevel, 1, weight=0)
        Grid.columnconfigure(self.toplevel, 2, weight=0)
        Grid.columnconfigure(self.toplevel, 3, weight=1)
        Grid.columnconfigure(self.toplevel, 4, weight=0)
        Grid.columnconfigure(self.toplevel, 5, weight=0)
        Grid.columnconfigure(self.toplevel, 6, weight=0)
        Grid.rowconfigure(self.toplevel, 0, weight=1)
        Grid.rowconfigure(self.toplevel, 1, weight=0)

        self.s.configure('TFrame', background=self.tranparency_color)
        self.fa_p1_var, fa_p1_label = self.create_frame_advantage_label(1)
        self.fa_p2_var, fa_p2_label = self.create_frame_advantage_label(5)

        self.l_margin = self.create_padding_frame(0)
        self.r_margin = self.create_padding_frame(6)
        self.l_seperator = self.create_padding_frame(2)
        self.r_seperator = self.create_padding_frame(4)

        if self.show_live_framedata:
            self.l_live_recovery = self.create_live_recovery(fa_p1_label, 0)
            self.r_live_recovery = self.create_live_recovery(fa_p2_label, 0)

        self.text = self.create_textbox(3)

        self.stdout = sys.stdout
        self.redirector = TextRedirector(self.stdout, self.text, self.s,
                                         self.fa_p1_var, self.fa_p2_var)
        self.text.configure(state="normal")
        self.text.delete("1.0", "end")
        #self.text.insert("1.0", "{:^5}|{:^8}|{:^9}|{:^7}|{:^5}|{:^5}|{:^8}|{:^5}|{:^5}|{:^7}|{:^5}|{}\n".format(" input ", "type", "startup", "block", "hit", "CH", "active", "track", "tot", "rec", "stun", "notes"))
        #self.redirector.populate_column_names(self.get_data_columns())
        self.redirector.set_columns_to_print(self.get_data_columns())

        self.text.configure(state="disabled")

    def get_data_columns(self):
        booleans_for_columns = []
        for enum in DataColumns:
            bool = self.tekken_config.get_property(DataColumns.config_name(),
                                                   enum.name, True)
            booleans_for_columns.append(bool)
        return booleans_for_columns

    def redirect_stdout(self):
        sys.stdout = self.redirector

    def restore_stdout(self):
        sys.stdout = self.stdout

    def create_padding_frame(self, col):
        padding = Frame(self.toplevel, width=10)
        padding.grid(row=0, column=col, rowspan=2, sticky=N + S + W + E)
        return padding

    def create_live_recovery(self, parent, col):
        live_recovery_var = StringVar()
        live_recovery_var.set('??')
        live_recovery_label = Label(parent,
                                    textvariable=live_recovery_var,
                                    font=("Segoe UI", 12),
                                    width=5,
                                    anchor='c')
        #live_recovery_label.grid(row=0, column=col, sticky =S+W)
        live_recovery_label.place(rely=0.0, relx=0.0, x=4, y=4, anchor=NW)
        return live_recovery_var

    def create_frame_advantage_label(self, col):
        frame_advantage_var = StringVar()
        frame_advantage_var.set('?')
        frame_advantage_label = Label(self.toplevel,
                                      textvariable=frame_advantage_var,
                                      font=("Consolas", 44),
                                      width=4,
                                      anchor='c',
                                      borderwidth=4,
                                      relief='ridge')
        frame_advantage_label.grid(row=0, column=col)
        return frame_advantage_var, frame_advantage_label

    def create_attack_type_label(self, col):
        attack_type_var = StringVar()
        attack_type_var.set('?')
        attack_type_label = Label(self.toplevel,
                                  textvariable=attack_type_var,
                                  font=("Verdana", 12),
                                  width=10,
                                  anchor='c',
                                  borderwidth=4,
                                  relief='ridge')
        attack_type_label.grid(row=1, column=col)
        return attack_type_var

    def create_textbox(self, col):
        textbox = Text(self.toplevel,
                       font=("Consolas, 14"),
                       wrap=NONE,
                       highlightthickness=0,
                       pady=0,
                       relief='flat')
        # self.text.pack(side="top", fill="both", expand=True)
        textbox.grid(row=0, column=col, rowspan=2, sticky=N + S + W + E)
        #textbox.configure(background='black')
        #textbox.configure(background='white')
        textbox.configure(background=self.background_color)

        textbox.configure(
            foreground=CurrentColorScheme.dict[ColorSchemeEnum.system_text])
        #textbox.configure(foreground='dark khaki')
        #textbox.configure(foreground='#839496')
        #textbox.configure(foreground='#657B83')
        return textbox

    def update_launcher(self):
        time1 = time.time()
        self.launcher.Update()

        if self.show_live_framedata:
            if len(self.launcher.gameState.stateLog) > 1:
                l_recovery = str(
                    self.launcher.gameState.GetOppFramesTillNextMove() -
                    self.launcher.gameState.GetBotFramesTillNextMove())
                r_recovery = str(
                    self.launcher.gameState.GetBotFramesTillNextMove() -
                    self.launcher.gameState.GetOppFramesTillNextMove())
                if not '-' in l_recovery:
                    l_recovery = '+' + l_recovery
                if not '-' in r_recovery:
                    r_recovery = '+' + r_recovery
                self.l_live_recovery.set(l_recovery)
                self.r_live_recovery.set(r_recovery)

        if not self.is_draggable_window:
            tekken_rect = self.launcher.gameState.gameReader.GetWindowRect()
            if tekken_rect != None:
                x = (tekken_rect.right + tekken_rect.left) / 2 - self.w / 2
                if self.is_overlay_on_top:
                    y = tekken_rect.top
                else:
                    y = tekken_rect.bottom - self.h - 10
                self.toplevel.geometry('%dx%d+%d+%d' % (self.w, self.h, x, y))
                if not self.overlay_visible:
                    self.show()
            else:
                if self.overlay_visible:
                    self.hide()

        if self.launcher.gameState.gameReader.GetNeedReacquireState():
            self.restore_stdout()
        else:
            self.redirect_stdout()

        time2 = time.time()
        elapsed_time = 1000 * (time2 - time1)
        self.toplevel.after(max(2, 8 - int(round(elapsed_time))),
                            self.update_launcher)

    def hide(self):
        if self.is_minimize_on_lost_focus and not self.is_draggable_window:
            self.toplevel.withdraw()
            self.overlay_visible = False

    def show(self):
        self.toplevel.deiconify()
        self.overlay_visible = True

    def set_columns_to_print(self, columns_to_print):
        self.redirector.set_columns_to_print(columns_to_print)

    def update_column_to_print(self, enum, value):
        self.tekken_config.set_property(DataColumns.config_name(), enum.name,
                                        value)
        self.write_config_file()

    def write_config_file(self):
        self.tekken_config.write()
Пример #5
0
    def __init__(self):
        self.overlay = None

        Tk.__init__(self)
        self.wm_title("Tekken Bot Prime")
        self.iconbitmap('TekkenData/tekken_bot_close.ico')

        self.color_scheme_config = ConfigReader.ConfigReader("color_scheme")
        self.color_scheme_config.add_comment(
            "colors with names -> http://www.science.smith.edu/dftwiki/images/3/3d/TkInterColorCharts.png"
        )
        self.changed_color_scheme("Current", False)

        self.menu = Menu(self)
        self.configure(menu=self.menu)

        self.text = Text(self, wrap="word")
        self.stdout = sys.stdout
        self.var_print_frame_data_to_file = BooleanVar(value=False)
        sys.stdout = TextRedirector(self.text, sys.stdout,
                                    self.write_to_overlay,
                                    self.var_print_frame_data_to_file,
                                    "stdout")
        self.stderr = sys.stderr
        sys.stderr = TextRedirector(self.text, sys.stderr, self.write_to_error,
                                    "stderr")
        self.text.tag_configure("stderr", foreground="#b22222")

        try:
            with open("TekkenData/tekken_bot_readme.txt") as fr:
                lines = fr.readlines()
            for line in lines:
                print(line)
        except:
            print("Error reading readme file.")

        VersionChecker.check_version()

        print("Tekken Bot Starting...")
        self.launcher = FrameDataLauncher(False)

        self.overlay = fdo.GUI_FrameDataOverlay(self, self.launcher)
        #self.graph = tlo.GUI_TimelineOverlay(self, self.launcher)

        self.tekken_bot_menu = Menu(self.menu)
        self.tekken_bot_menu.add_command(label="Restart", command=self.restart)

        self.tekken_bot_menu.add_checkbutton(
            label="Print Frame Data To \"TekkenData/frame_data_output.txt\"",
            onvalue=True,
            offvalue=False,
            variable=self.var_print_frame_data_to_file)
        self.menu.add_cascade(label="Tekken Bot", menu=self.tekken_bot_menu)

        self.checkbox_dict = {}
        self.column_menu = Menu(self.menu)
        for i, enum in enumerate(fdo.DataColumns):
            bool = self.overlay.redirector.columns_to_print[i]
            self.add_checkbox(
                self.column_menu, enum, "{} ({})".format(
                    enum.name.replace('X', ' ').strip(),
                    fdo.DataColumnsToMenuNames[enum]), bool,
                self.changed_columns)
        self.menu.add_cascade(label='Columns', menu=self.column_menu)

        self.display_menu = Menu(self.menu)
        for enum in ovr.DisplaySettings:
            default = self.overlay.tekken_config.get_property(
                ovr.DisplaySettings.config_name(), enum.name, False)
            self.add_checkbox(self.display_menu, enum, enum.name, default,
                              self.changed_display)
        self.menu.add_cascade(label="Display", menu=self.display_menu)

        self.color_scheme_menu = Menu(self.menu)
        self.scheme_var = StringVar()
        for section in self.color_scheme_config.parser.sections():
            if section not in ("Comments", "Current"):
                self.color_scheme_menu.add_radiobutton(
                    label=section,
                    variable=self.scheme_var,
                    value=section,
                    command=lambda: self.changed_color_scheme(self.scheme_var.
                                                              get()))
        self.menu.add_cascade(label="Color Scheme",
                              menu=self.color_scheme_menu)

        self.overlay_mode_menu = Menu(self.menu)
        self.overlay_var = StringVar()
        for mode in OverlayMode:
            self.overlay_mode_menu.add_radiobutton(
                label=OverlayModeToDisplayName[mode],
                variable=self.overlay_var,
                value=mode.name,
                command=lambda: self.changed_mode(self.overlay_var.get()))
        self.menu.add_cascade(label="Mode", menu=self.overlay_mode_menu)
        self.mode = OverlayMode.FrameData

        self.tekken_bot_menu = Menu(self.menu)
        self.tekken_bot_menu.add_command(label=VersionChecker.CURRENT_VERSION)
        self.tekken_bot_menu.add_command(label="Check for new version",
                                         command=self.print_release_notes)
        self.tekken_bot_menu.add_command(label="Download Latest Release",
                                         command=self.download_latest_release)
        self.menu.add_cascade(label="Version", menu=self.tekken_bot_menu)

        self.text.grid(row=2, column=0, columnspan=2, sticky=N + S + E + W)
        #self.grid_rowconfigure(0, weight=1)
        self.grid_rowconfigure(2, weight=1)
        self.grid_columnconfigure(0, weight=1)
        #self.grid_columnconfigure(1, weight=1)

        self.geometry(str(920) + 'x' + str(720))

        self.update_launcher()
        self.overlay.hide()

        self.protocol("WM_DELETE_WINDOW", self.on_closing)
Пример #6
0
class GUI_TekkenBotPrime(Tk):
    def __init__(self):
        self.overlay = None

        Tk.__init__(self)
        self.wm_title("Tekken Bot Prime")
        self.iconbitmap('TekkenData/tekken_bot_close.ico')

        self.color_scheme_config = ConfigReader.ConfigReader("color_scheme")
        self.color_scheme_config.add_comment(
            "colors with names -> http://www.science.smith.edu/dftwiki/images/3/3d/TkInterColorCharts.png"
        )
        self.changed_color_scheme("Current", False)

        self.menu = Menu(self)
        self.configure(menu=self.menu)

        self.text = Text(self, wrap="word")
        self.stdout = sys.stdout
        self.var_print_frame_data_to_file = BooleanVar(value=False)
        sys.stdout = TextRedirector(self.text, sys.stdout,
                                    self.write_to_overlay,
                                    self.var_print_frame_data_to_file,
                                    "stdout")
        self.stderr = sys.stderr
        sys.stderr = TextRedirector(self.text, sys.stderr, self.write_to_error,
                                    "stderr")
        self.text.tag_configure("stderr", foreground="#b22222")

        try:
            with open("TekkenData/tekken_bot_readme.txt") as fr:
                lines = fr.readlines()
            for line in lines:
                print(line)
        except:
            print("Error reading readme file.")

        VersionChecker.check_version()

        print("Tekken Bot Starting...")
        self.launcher = FrameDataLauncher(False)

        self.overlay = fdo.GUI_FrameDataOverlay(self, self.launcher)
        #self.graph = tlo.GUI_TimelineOverlay(self, self.launcher)

        self.tekken_bot_menu = Menu(self.menu)
        self.tekken_bot_menu.add_command(label="Restart", command=self.restart)

        self.tekken_bot_menu.add_checkbutton(
            label="Print Frame Data To \"TekkenData/frame_data_output.txt\"",
            onvalue=True,
            offvalue=False,
            variable=self.var_print_frame_data_to_file)
        self.menu.add_cascade(label="Tekken Bot", menu=self.tekken_bot_menu)

        self.checkbox_dict = {}
        self.column_menu = Menu(self.menu)
        for i, enum in enumerate(fdo.DataColumns):
            bool = self.overlay.redirector.columns_to_print[i]
            self.add_checkbox(
                self.column_menu, enum, "{} ({})".format(
                    enum.name.replace('X', ' ').strip(),
                    fdo.DataColumnsToMenuNames[enum]), bool,
                self.changed_columns)
        self.menu.add_cascade(label='Columns', menu=self.column_menu)

        self.display_menu = Menu(self.menu)
        for enum in ovr.DisplaySettings:
            default = self.overlay.tekken_config.get_property(
                ovr.DisplaySettings.config_name(), enum.name, False)
            self.add_checkbox(self.display_menu, enum, enum.name, default,
                              self.changed_display)
        self.menu.add_cascade(label="Display", menu=self.display_menu)

        self.color_scheme_menu = Menu(self.menu)
        self.scheme_var = StringVar()
        for section in self.color_scheme_config.parser.sections():
            if section not in ("Comments", "Current"):
                self.color_scheme_menu.add_radiobutton(
                    label=section,
                    variable=self.scheme_var,
                    value=section,
                    command=lambda: self.changed_color_scheme(self.scheme_var.
                                                              get()))
        self.menu.add_cascade(label="Color Scheme",
                              menu=self.color_scheme_menu)

        self.overlay_mode_menu = Menu(self.menu)
        self.overlay_var = StringVar()
        for mode in OverlayMode:
            self.overlay_mode_menu.add_radiobutton(
                label=OverlayModeToDisplayName[mode],
                variable=self.overlay_var,
                value=mode.name,
                command=lambda: self.changed_mode(self.overlay_var.get()))
        self.menu.add_cascade(label="Mode", menu=self.overlay_mode_menu)
        self.mode = OverlayMode.FrameData

        self.tekken_bot_menu = Menu(self.menu)
        self.tekken_bot_menu.add_command(label=VersionChecker.CURRENT_VERSION)
        self.tekken_bot_menu.add_command(label="Check for new version",
                                         command=self.print_release_notes)
        self.tekken_bot_menu.add_command(label="Download Latest Release",
                                         command=self.download_latest_release)
        self.menu.add_cascade(label="Version", menu=self.tekken_bot_menu)

        self.text.grid(row=2, column=0, columnspan=2, sticky=N + S + E + W)
        #self.grid_rowconfigure(0, weight=1)
        self.grid_rowconfigure(2, weight=1)
        self.grid_columnconfigure(0, weight=1)
        #self.grid_columnconfigure(1, weight=1)

        self.geometry(str(920) + 'x' + str(720))

        self.update_launcher()
        self.overlay.hide()

        self.protocol("WM_DELETE_WINDOW", self.on_closing)

    def print_release_notes(self):
        VersionChecker.check_version(force_print=True)

    def download_latest_release(self):
        webbrowser.open('https://github.com/roguelike2d/TekkenBot/releases/')

    def restart(self):
        self.launcher = FrameDataLauncher(False)
        self.stop_overlay()
        self.start_overlay()

    def write_to_overlay(self, string):
        if self.var_print_frame_data_to_file.get() and 'NOW:' in string:
            with open("TekkenData/frame_data_output.txt", 'a') as fa:
                fa.write(string + '\n')
        if self.overlay != None:
            self.overlay.redirector.write(string)
        #if 'HIT' in string:
        #self.graph.redirector.write(string)

    def write_to_error(self, string):
        self.stderr.write(string)

    def add_checkbox(self, menu, lookup_key, display_string, default_value,
                     button_command):
        var = BooleanVar()
        var.set(default_value)
        self.checkbox_dict[lookup_key] = var
        menu.add_checkbutton(label=display_string,
                             onvalue=True,
                             offvalue=False,
                             variable=var,
                             command=button_command)

    def changed_color_scheme(self, section, do_reboot=True):
        for enum in fdo.ColorSchemeEnum:
            fdo.CurrentColorScheme.dict[
                enum] = self.color_scheme_config.get_property(
                    section, enum.name, fdo.CurrentColorScheme.dict[enum])
            self.color_scheme_config.set_property(
                "Current", enum.name, fdo.CurrentColorScheme.dict[enum])
        self.color_scheme_config.write()
        if do_reboot:
            self.reboot_overlay()

    def changed_mode(self, mode):

        self.stop_overlay()

        self.mode = OverlayMode[mode]

        if self.mode != OverlayMode.Off:
            self.start_overlay()

    def changed_columns(self):
        generated_columns = []
        for enum in fdo.DataColumns:
            var = self.checkbox_dict[enum]
            generated_columns.append(var.get())
            if self.mode == OverlayMode.FrameData:
                self.overlay.update_column_to_print(enum, var.get())
        if self.mode == OverlayMode.FrameData:
            self.overlay.set_columns_to_print(generated_columns)

    def changed_display(self):
        for enum in ovr.DisplaySettings:
            var = self.checkbox_dict[enum]
            if self.overlay != None:
                self.overlay.tekken_config.set_property(
                    ovr.DisplaySettings.config_name(), enum.name, var.get())
        if self.overlay != None:
            self.overlay.tekken_config.write()
        self.reboot_overlay()

    def stop_overlay(self):
        if self.overlay != None:
            self.overlay.toplevel.destroy()
        self.overlay = None

    def start_overlay(self):
        if self.mode == OverlayMode.FrameData:
            self.overlay = fdo.GUI_FrameDataOverlay(self, self.launcher)
            self.overlay.hide()
        #if self.mode == OverlayMode.Timeline:
        #    self.overlay = tlo.GUI_TimelineOverlay(self, self.launcher)
        #    self.overlay.hide()
        if self.mode == OverlayMode.CommandInput:
            self.overlay = cio.GUI_CommandInputOverlay(self, self.launcher)
            self.overlay.hide()
        if self.mode == OverlayMode.PunishCoach:
            self.overlay = pco.GUI_PunishCoachOverlay(self, self.launcher)
            self.overlay.hide()
        if self.mode == OverlayMode.MatchupRecord:
            self.overlay = mso.GUI_MatchStatOverlay(self, self.launcher)
            self.overlay.hide()
        if self.mode == OverlayMode.DebugInfo:
            self.overlay = dio.GUI_DebugInfoOverlay(self, self.launcher)
            self.overlay.hide()

    def reboot_overlay(self):
        self.stop_overlay()
        self.start_overlay()

    def update_launcher(self):
        time1 = time.time()
        successful_update = self.launcher.Update()

        if self.overlay != None:
            self.overlay.update_location()
            if successful_update:
                self.overlay.update_state()
        #self.graph.update_state()
        time2 = time.time()
        elapsed_time = 1000 * (time2 - time1)
        if self.launcher.gameState.game_reader.is_pid_valid():
            self.after(max(2, 8 - int(round(elapsed_time))),
                       self.update_launcher)
        else:
            self.after(1000, self.update_launcher)

    def on_closing(self):
        sys.stdout = self.stdout
        sys.stderr = self.stderr
        self.destroy()
Пример #7
0
 def restart(self):
     self.launcher = FrameDataLauncher(False)
     self.stop_overlay()
     self.start_overlay()
Пример #8
0
    def __init__(self):
        print("Tekken Bot Starting...")

        is_windows_7 = 'Windows-7' in platform.platform()
        self.tekken_config = ConfigReader("frame_data_overlay")
        self.is_draggable_window = self.tekken_config.get_property("independent_window_mode", True, lambda x: not "0" in str(x))
        self.is_minimize_on_lost_focus = self.tekken_config.get_property("minimize_on_lost_focus", True, lambda x: not "0" in str(x))
        self.is_transparency = self.tekken_config.get_property("transparency", not is_windows_7, lambda x: not "0" in str(x))
        self.enable_nerd_data = self.tekken_config.get_property("data_for_nerds", False, lambda x: not "0" in str(x))

        self.launcher = FrameDataLauncher(self.enable_nerd_data)

        self.overlay_visible = False

        Tk.__init__(self)

        self.wm_title("Tekken Bot: Frame Data Overlay")

        self.attributes("-topmost", True)

        #self.background_color = '#002B36'
        self.background_color = 'gray10'

        if self.is_transparency:
            self.wm_attributes("-transparentcolor", "white")
            self.attributes("-alpha", "0.75")
            self.tranparency_color = 'white'
        else:
            if is_windows_7:
                print("Windows 7 detected. Disabling transparency.")
            self.tranparency_color = self.background_color
        self.configure(background=self.tranparency_color)



        self.w = 820
        self.h = 96

        if self.enable_nerd_data:
            self.w += 400

        self.geometry( str(self.w) + 'x' + str(self.h))

        self.iconbitmap('TekkenData/tekken_bot_close.ico')
        if not self.is_draggable_window:
            self.overrideredirect(True)


        self.s = Style()
        self.s.theme_use('alt')
        self.s.configure('.', background=self.background_color)
        self.s.configure('.', foreground='black')

        Grid.columnconfigure(self, 0, weight=0)
        Grid.columnconfigure(self, 1, weight=0)
        Grid.columnconfigure(self, 2, weight=0)
        Grid.columnconfigure(self, 3, weight=1)
        Grid.columnconfigure(self, 4, weight=0)
        Grid.columnconfigure(self, 5, weight=0)
        Grid.columnconfigure(self, 6, weight=0)
        Grid.rowconfigure(self, 0, weight=1)
        Grid.rowconfigure(self, 1, weight=0)

        self.s.configure('TFrame', background=self.tranparency_color)
        self.fa_p1_var = self.create_frame_advantage_label(1)
        self.fa_p2_var = self.create_frame_advantage_label(5)

        self.l_margin = self.create_padding_frame(0)
        self.r_margin = self.create_padding_frame(2)
        self.l_seperator = self.create_padding_frame(4)
        self.r_seperator = self.create_padding_frame(6)


        self.text = self.create_textbox(3)

        self.stdout = sys.stdout
        self.redirector = TextRedirector(self.stdout, self.text, self.s, self.fa_p1_var, self.fa_p2_var)
        self.text.configure(state="normal")
        self.text.delete("1.0", "end")
        self.text.insert("1.0", "{:^5}|{:^8}|{:^9}|{:^8}|{:^5}|{:^5}|{:^5}|{}\n".format(" input ", "type", "startup", "block", "hit", "CH", "active", "notes"))

        self.text.configure(state="disabled")
Пример #9
0
class GUI_FrameDataOverlay(Tk):
    def __init__(self):
        print("Tekken Bot Starting...")

        is_windows_7 = 'Windows-7' in platform.platform()
        self.tekken_config = ConfigReader("frame_data_overlay")
        self.is_draggable_window = self.tekken_config.get_property("independent_window_mode", True, lambda x: not "0" in str(x))
        self.is_minimize_on_lost_focus = self.tekken_config.get_property("minimize_on_lost_focus", True, lambda x: not "0" in str(x))
        self.is_transparency = self.tekken_config.get_property("transparency", not is_windows_7, lambda x: not "0" in str(x))
        self.enable_nerd_data = self.tekken_config.get_property("data_for_nerds", False, lambda x: not "0" in str(x))

        self.launcher = FrameDataLauncher(self.enable_nerd_data)

        self.overlay_visible = False

        Tk.__init__(self)

        self.wm_title("Tekken Bot: Frame Data Overlay")

        self.attributes("-topmost", True)

        #self.background_color = '#002B36'
        self.background_color = 'gray10'

        if self.is_transparency:
            self.wm_attributes("-transparentcolor", "white")
            self.attributes("-alpha", "0.75")
            self.tranparency_color = 'white'
        else:
            if is_windows_7:
                print("Windows 7 detected. Disabling transparency.")
            self.tranparency_color = self.background_color
        self.configure(background=self.tranparency_color)



        self.w = 820
        self.h = 96

        if self.enable_nerd_data:
            self.w += 400

        self.geometry( str(self.w) + 'x' + str(self.h))

        self.iconbitmap('TekkenData/tekken_bot_close.ico')
        if not self.is_draggable_window:
            self.overrideredirect(True)


        self.s = Style()
        self.s.theme_use('alt')
        self.s.configure('.', background=self.background_color)
        self.s.configure('.', foreground='black')

        Grid.columnconfigure(self, 0, weight=0)
        Grid.columnconfigure(self, 1, weight=0)
        Grid.columnconfigure(self, 2, weight=0)
        Grid.columnconfigure(self, 3, weight=1)
        Grid.columnconfigure(self, 4, weight=0)
        Grid.columnconfigure(self, 5, weight=0)
        Grid.columnconfigure(self, 6, weight=0)
        Grid.rowconfigure(self, 0, weight=1)
        Grid.rowconfigure(self, 1, weight=0)

        self.s.configure('TFrame', background=self.tranparency_color)
        self.fa_p1_var = self.create_frame_advantage_label(1)
        self.fa_p2_var = self.create_frame_advantage_label(5)

        self.l_margin = self.create_padding_frame(0)
        self.r_margin = self.create_padding_frame(2)
        self.l_seperator = self.create_padding_frame(4)
        self.r_seperator = self.create_padding_frame(6)


        self.text = self.create_textbox(3)

        self.stdout = sys.stdout
        self.redirector = TextRedirector(self.stdout, self.text, self.s, self.fa_p1_var, self.fa_p2_var)
        self.text.configure(state="normal")
        self.text.delete("1.0", "end")
        self.text.insert("1.0", "{:^5}|{:^8}|{:^9}|{:^8}|{:^5}|{:^5}|{:^5}|{}\n".format(" input ", "type", "startup", "block", "hit", "CH", "active", "notes"))

        self.text.configure(state="disabled")

    def redirect_stdout(self):
        sys.stdout = self.redirector

    def restore_stdout(self):
        sys.stdout = self.stdout

    def create_padding_frame(self, col):
        padding = Frame(width=10)
        padding.grid(row=0, column=col, rowspan=2, sticky=N + S + W + E)
        return padding

    def create_frame_advantage_label(self, col):
        frame_advantage_var = StringVar()
        frame_advantage_var.set('??')
        frame_advantage_label = Label(self, textvariable=frame_advantage_var, font=("Consolas", 44), width=4, anchor='c',
                                        borderwidth=4, relief='ridge')
        frame_advantage_label.grid(row=0, column=col)
        return frame_advantage_var

    def create_attack_type_label(self, col):
        attack_type_var = StringVar()
        attack_type_var.set('??')
        attack_type_label = Label(self, textvariable=attack_type_var, font=("Verdana", 12), width=10, anchor='c',
                                    borderwidth=4, relief='ridge')
        attack_type_label.grid(row=1, column=col)
        return attack_type_var

    def create_textbox(self, col):
        textbox = Text(self, font=("Consolas, 14"), wrap=NONE, highlightthickness=0, relief='flat')
        # self.text.pack(side="top", fill="both", expand=True)
        textbox.grid(row=0, column=col, rowspan=2, sticky=N + S + W + E)
        #textbox.configure(background='black')
        #textbox.configure(background='white')
        textbox.configure(background=self.background_color)

        textbox.configure(foreground='lawn green')
        #textbox.configure(foreground='dark khaki')
        #textbox.configure(foreground='#839496')
        #textbox.configure(foreground='#657B83')
        return textbox


    def update_launcher(self):
        time1 = time.time()
        self.launcher.Update()
        time2 = time.time()
        elapsed_time = 1000 * (time2 - time1)

        if not self.is_draggable_window:
            tekken_rect = self.launcher.gameState.gameReader.GetWindowRect()
            if tekken_rect != None:
                x = (tekken_rect.right + tekken_rect.left)/2 - self.w/2
                y = tekken_rect.top
                self.geometry('%dx%d+%d+%d' % (self.w, self.h, x, y))
                if not self.overlay_visible:
                    self.show()
            else:
                if self.overlay_visible:
                    self.hide()

        if self.launcher.gameState.gameReader.GetNeedReacquireState():
            self.restore_stdout()
        else:
            self.redirect_stdout()
        #print(10 - int(round(elapsed_time)))
        self.after(max(2, 8 - int(round(elapsed_time))), self.update_launcher)

    def hide(self):
        if self.is_minimize_on_lost_focus and not self.is_draggable_window:
            self.withdraw()
            self.overlay_visible = False

    def show(self):
        self.deiconify()
        self.overlay_visible = True
Пример #10
0
class GUI_FrameDataOverlay(Tk):
    def __init__(self):
        print("Tekken Bot Starting...")

        self.tekken_config = ConfigReader("frame_data_overlay")

        self.launcher = FrameDataLauncher()

        self.overlay_visible = False

        Tk.__init__(self)

        self.wm_title("Tekken Bot: Frame Data Overlay")
        self.wm_attributes("-transparentcolor", "white")
        self.attributes("-topmost", True)
        self.attributes("-alpha", "0.75")

        self.iconbitmap('TekkenData/tekken_bot_close.ico')
        self.overrideredirect(True)
        self.configure(background='white')

        self.s = Style()
        self.s.theme_use('alt')
        self.s.configure('.', background='black')
        self.s.configure('.', foreground='black')

        Grid.columnconfigure(self, 0, weight=0)
        Grid.columnconfigure(self, 1, weight=1)
        Grid.columnconfigure(self, 2, weight=0)
        Grid.rowconfigure(self, 0, weight=1)
        Grid.rowconfigure(self, 1, weight=0)

        self.fa_p1_var = self.create_frame_advantage_label(0)
        self.fa_p2_var = self.create_frame_advantage_label(2)


        self.at_p1_var = self.create_attack_type_label(0)
        self.at_p2_var = self.create_attack_type_label(2)

        self.text = self.create_textbox()

        self.stdout = sys.stdout
        self.redirector = TextRedirector(self.stdout, self.text, self.s, self.fa_p1_var, self.fa_p2_var, self.at_p1_var, self.at_p2_var)
        self.redirect_stdout()
        print("move | type | startup | damage | block | hit | active")
        self.restore_stdout()

    def redirect_stdout(self):
        sys.stdout = self.redirector

    def restore_stdout(self):
        sys.stdout = self.stdout

    def create_frame_advantage_label(self, col):
        frame_advantage_var = StringVar()
        frame_advantage_var.set('??')
        frame_advantage_label = Label(self, textvariable=frame_advantage_var, font=("Consolas", 44), width=4, anchor='c',
                                        borderwidth=4, relief='ridge')
        frame_advantage_label.grid(row=0, column=col, sticky=E + W + N)
        return frame_advantage_var

    def create_attack_type_label(self, col):
        attack_type_var = StringVar()
        attack_type_var.set('??')
        attack_type_label = Label(self, textvariable=attack_type_var, font=("Verdana", 14), width=9, anchor='c',
                                    borderwidth=4, relief='ridge')
        attack_type_label.grid(row=1, column=col)
        return attack_type_var

    def create_textbox(self):
        textbox = Text(self, font=("Consolas, 13"), wrap="word", highlightthickness=2, relief='ridge')
        # self.text.pack(side="top", fill="both", expand=True)
        textbox.grid(row=0, column=1, rowspan=2, sticky=N + S + W + E)
        textbox.configure(background='black')
        textbox.configure(foreground='green')
        return textbox


    def update_launcher(self):
        self.launcher.Update()

        tekken_rect = self.launcher.gameState.gameReader.GetWindowRect()
        if tekken_rect != None:
            w = 720
            h = 120
            x = (tekken_rect.right + tekken_rect.left)/2 - w/2
            y = tekken_rect.top
            self.geometry('%dx%d+%d+%d' % (w, h, x, y))
            if not self.overlay_visible:
                self.show()
        else:
            if self.overlay_visible:
                self.hide()

        if self.launcher.gameState.gameReader.GetNeedReacquireState():
            self.restore_stdout()
        else:
            self.redirect_stdout()

        self.after(7, self.update_launcher)

    def hide(self):
        if self.tekken_config.get_property("minimize_on_lost_focus", True, lambda x: not "0" in str(x) ):
            self.withdraw()
            self.overlay_visible = False

    def show(self):
        self.deiconify()
        self.overlay_visible = True
Пример #11
0
class OverlayApp(Tk):
    def __init__(self):
        self.test = True
        Tk.__init__(self)
        self.wm_title("Tekken Bot Prime")
        self.count = 0
        self.launcher = FrameDataLauncher(False)
        self.overlay = GUI_TestOverlay(self, self.launcher)
        self.LastOutput = ""
        self.LastMove = ""
        self.overlay.update_location()
        self.CurrentStance = "Standing"
        self.NeutralStances = [
            'Universal_32769',
        ]

        self.FlamingoStances = [
            'Hw_lk00F',
            'Gpe_lk02LF',
        ]

        self.update_launcher()

    def on_closing(self):
        self.destroy()

    def update_stance(self):
        try:
            movename = self.launcher.gameState.GetCurrentBotMoveName()
        except:
            movename = ""
        if self.CurrentStance == "Standing":
            if movename in self.FlamingoStances:
                self.CurrentStance = "Flamingo"
                return True
        else:
            if movename in self.NeutralStances:
                self.CurrentStance = "Standing"
                return True
        return False

    def update_launcher(self):
        time1 = time.time()
        successful_update = self.launcher.Update()
        output = "Do 1,1,3,3\n"
        #output = self.launcher.gameState.GetCurrentBotMoveName()
        if (output != self.LastOutput):
            self.overlay.WriteToOverlay(output + "\n")
            self.LastOutput = output

        try:
            movename = self.launcher.gameState.GetCurrentBotMoveName()
        except:
            movename = ""

        if self.update_stance():
            self.overlay.WriteToOverlay('Stance: ' + self.CurrentStance + '\n')


#        if movename != self.LastMove:
#            self.overlay.WriteToOverlay("Movename: " + movename + "\n")
#            self.LastMove = movename

#        if movename == "Hw_llkhlk":
#            self.overlay.WriteToOverlay("Congrats!!\n")

#        if len(output) > 0:
#            self.overlay.WriteToOverlay(output)

        if self.overlay != None:
            #self.overlay.update_location()
            if successful_update:
                self.overlay.update_state()
        #self.graph.update_state()
        time2 = time.time()
        elapsed_time = 1000 * (time2 - time1)
        if self.launcher.gameState.gameReader.HasWorkingPID():
            self.after(max(2, 8 - int(round(elapsed_time))),
                       self.update_launcher)
        else:
            self.after(1000, self.update_launcher)