117 lines
3.5 KiB
Python
117 lines
3.5 KiB
Python
import os
|
|
import tkinter as tk
|
|
from tkinter import filedialog, Text
|
|
|
|
focus_path, _ = os.path.split(os.getcwd())
|
|
focus_path += r"\common\national_focus"
|
|
focus_list = []
|
|
|
|
class App(tk.Frame):
|
|
def __init__(self, master=None):
|
|
super().__init__(master)
|
|
self.file_name = ""
|
|
self.master = master
|
|
self.pack()
|
|
self.create_widgets()
|
|
|
|
def create_widgets(self):
|
|
self.file_select_focus = tk.Button(self)
|
|
self.file_select_focus["text"] = "\nSelect a focus file"
|
|
self.file_select_focus["command"] = self.select_file_path
|
|
self.file_select_focus.pack(side="top")
|
|
|
|
self.run_script = tk.Button(self)
|
|
self.run_script["text"] = "Run Program"
|
|
self.run_script["command"] = self.run_app
|
|
self.run_script.pack(side="top")
|
|
|
|
self.output_label = tk.Label(self)
|
|
self.output_label["text"] = f"\nCurrent Focus File:\n{self.file_name}\n\n"
|
|
self.output_label["wraplength"] = 250
|
|
self.output_label.pack(side="top")
|
|
|
|
self.entry1text = tk.Label(self)
|
|
self.entry1text["text"] = "Starting Focus ID to Loc:"
|
|
self.entry1text["wraplength"] = 170
|
|
self.entry1text.pack(side="top")
|
|
|
|
self.entry1 = tk.Entry(self)
|
|
self.entry1.pack(side="top")
|
|
|
|
self.entry2text = tk.Label(self)
|
|
self.entry2text["text"] = "Final Focus ID to Loc:"
|
|
self.entry2text["wraplength"] = 170
|
|
self.entry2text.pack(side="top")
|
|
|
|
self.entry2 = tk.Entry(self)
|
|
self.entry2.pack(side="top")
|
|
|
|
def select_file_path(self):
|
|
self.file_name = filedialog.askopenfilename(initialdir=focus_path)
|
|
self.output_label["text"] = f"\nCurrent Loc File:\n{self.file_name}\n\n"
|
|
|
|
def run_app(self):
|
|
starting_focus = self.entry1.get()
|
|
end_focus = self.entry2.get()
|
|
starting_focus_found = False
|
|
for line in open(self.file_name, "r").readlines():
|
|
if starting_focus_found == False:
|
|
if starting_focus in line:
|
|
starting_focus_found = True
|
|
else:
|
|
continue
|
|
if " id = " in line and not " " in line:
|
|
focus_list.append(line[6:-1])
|
|
if end_focus in line:
|
|
break
|
|
|
|
for focus in focus_list:
|
|
if "blankfocus" not in focus:
|
|
print(focus)
|
|
focus_name = focus.replace("_", " ")[4:].title()
|
|
focus2 = focus[4:].title()
|
|
with open(r"Burgundy_redacted_scripted_loc.txt", "a+") as scripted_loc:
|
|
|
|
scripted_loc.write("\ndefined_text = {")
|
|
scripted_loc.write("\n name = GetBRGFocus"+focus2)
|
|
scripted_loc.write("\n text = {")
|
|
scripted_loc.write("\n trigger = {")
|
|
scripted_loc.write("\n BRG = {")
|
|
scripted_loc.write("\n is_ai = no")
|
|
scripted_loc.write("\n }")
|
|
scripted_loc.write("\n }")
|
|
scripted_loc.write("\n localization_key = "+focus+"_text")
|
|
scripted_loc.write("\n }")
|
|
scripted_loc.write("\n text = {")
|
|
scripted_loc.write("\n trigger = {")
|
|
scripted_loc.write("\n BRG = {")
|
|
scripted_loc.write("\n is_ai = yes")
|
|
scripted_loc.write("\n }")
|
|
scripted_loc.write("\n }")
|
|
scripted_loc.write("\n localization_key = BRG_redacted")
|
|
scripted_loc.write("\n }")
|
|
scripted_loc.write("\n}\n")
|
|
|
|
|
|
with open("Burgundy_redacted_focuses_l_english.yml", "a+") as loc:
|
|
for focus in focus_list:
|
|
focus2 = focus[4:].title()
|
|
loc.write(f"\n{focus}:0 \"[Root.GetBRGFocus{focus2}]\"")
|
|
loc.write("\n")
|
|
for focus in focus_list:
|
|
focus_name = focus.replace("_", " ")[4:].title()
|
|
loc.write(f"\n{focus}_text:0 \"{focus_name}\"")
|
|
loc.write("\n")
|
|
for focus in focus_list:
|
|
loc.write(f"\n{focus}_desc:0 \"\"")
|
|
loc.write("\n")
|
|
|
|
|
|
|
|
|
|
root = tk.Tk()
|
|
root.geometry("260x300")
|
|
root.title("Burgundy Scripted Loc Generator")
|
|
app = App(master=root)
|
|
app.mainloop()
|