forked from apoguita/Py4GW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript loader.py
More file actions
79 lines (63 loc) · 3 KB
/
script loader.py
File metadata and controls
79 lines (63 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from Py4GWCoreLib import ImGui, GLOBAL_CACHE, TitleID
import PyImGui, Py4GW
import os
MODULE_NAME = "Vanquisher"
TEXTURE = os.path.join(Py4GW.Console.get_projects_path(), "Bots\\Vanquish\\Vanquisher.png")
def scan_scripts(base_path: str) -> dict[str, dict[str, list[str]]]:
"""
Walk campaign -> area -> scripts.
Returns { campaign: { area: [scripts] } }
"""
campaigns: dict[str, dict[str, list[str]]] = {}
for campaign_name in os.listdir(base_path):
campaign_path = os.path.join(base_path, campaign_name)
if not os.path.isdir(campaign_path):
continue
campaigns[campaign_name] = {}
for area_name in os.listdir(campaign_path):
area_path = os.path.join(campaign_path, area_name)
if not os.path.isdir(area_path):
continue
scripts = [
f for f in os.listdir(area_path)
if f.endswith(".py")
]
campaigns[campaign_name][area_name] = scripts
return campaigns
def configure():
pass
def Draw_Window():
base_path = os.path.join(Py4GW.Console.get_projects_path(), "Bots\\Vanquish\\")
campaigns = scan_scripts(base_path)
if PyImGui.begin(MODULE_NAME, PyImGui.WindowFlags.AlwaysAutoResize):
if PyImGui.begin_table("##MainTable", 2, PyImGui.TableFlags.NoFlag):
# --- LEFT COLUMN: Texture Art ---
PyImGui.table_next_column()
if PyImGui.begin_child("##TextureChild", (280, 370), True, flags=PyImGui.WindowFlags.NoFlag):
ImGui.DrawTexture(texture_path=TEXTURE, width=275, height=350)
PyImGui.end_child()
# --- RIGHT COLUMN: Tree View ---
PyImGui.table_next_column()
if PyImGui.begin_child("##TreeChild", (300, 370), True, flags=PyImGui.WindowFlags.NoFlag):
for campaign_name, areas in campaigns.items():
total_scripts = sum(len(scripts) for scripts in areas.values())
campaign_label = f"{campaign_name} ({total_scripts})"
if PyImGui.tree_node(campaign_label):
for area_name, scripts in areas.items():
script_count = len(scripts)
area_label = f"{area_name} ({script_count})"
if PyImGui.tree_node(area_label):
for script_file in scripts:
display_name = os.path.splitext(script_file)[0]
if PyImGui.button(display_name):
full_path = os.path.join(base_path, campaign_name, area_name, script_file)
Py4GW.Console.defer_stop_load_and_run(full_path,delay_ms=500)
PyImGui.tree_pop()
PyImGui.tree_pop()
PyImGui.end_child()
PyImGui.end_table()
PyImGui.end()
def main():
Draw_Window()
if __name__ == "__main__":
main()