Skip to content

Commit f3a21a0

Browse files
Test push
1 parent 7cb450e commit f3a21a0

File tree

14 files changed

+258
-76
lines changed

14 files changed

+258
-76
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
11
from ue4ss_installer_gui import main
22

3+
# import dearpygui.dearpygui as dpg
4+
5+
# dpg.create_context()
6+
7+
# with dpg.window(label="Delete Files", modal=True, show=False, tag="modal_id", no_title_bar=True):
8+
# dpg.add_text("All those beautiful files will be deleted.\nThis operation cannot be undone!")
9+
# dpg.add_separator()
10+
# dpg.add_checkbox(label="Don't ask me next time")
11+
# with dpg.group(horizontal=True):
12+
# dpg.add_button(label="OK", width=75, callback=lambda: dpg.configure_item("modal_id", show=False))
13+
# dpg.add_button(label="Cancel", width=75, callback=lambda: dpg.configure_item("modal_id", show=False))
14+
15+
# with dpg.window(label="Tutorial"):
16+
# dpg.add_button(label="Open Dialog", callback=lambda: dpg.configure_item("modal_id", show=True))
17+
18+
# dpg.create_viewport(title='Custom Title', width=800, height=600)
19+
# dpg.setup_dearpygui()
20+
# dpg.show_viewport()
21+
# dpg.start_dearpygui()
22+
# dpg.destroy_context()
23+
24+
325
main.main()

src/ue4ss_installer_gui/add_game_screen.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/ue4ss_installer_gui/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
FOOTER_HEIGHT = 28
1717
DIVIDER_HEIGHT = 15
1818
MARGIN = 40
19+
20+
UE4SS_REPO_URL = "https://github.com/UE4SS-RE/RE-UE4SS"

src/ue4ss_installer_gui/data_structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class GamePlatforms(Enum):
1212

1313
@dataclass
1414
class GameInfo:
15-
game_title: str
1615
install_dir: Path
16+
game_title: str
1717
ue4ss_version: str
1818
installed_files: List[Path] = field(default_factory=list)
1919
platform: GamePlatforms = GamePlatforms.OTHER

src/ue4ss_installer_gui/main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import os
22

3+
from ue4ss_installer_gui.screens import main as main_screen
4+
35
import dearpygui.dearpygui as dpg
46

5-
from ue4ss_installer_gui import file_io, main_screen, constants, settings
7+
from ue4ss_installer_gui import file_io, constants, settings
8+
9+
# when loading autopopulation, if a game dir exists, but game is uninstalled, do now show it unless, there is an ue4ss installation
10+
# when this happens maybe show a warning or exclamation point mark or something
611

712

813
def main():
@@ -31,7 +36,7 @@ def main():
3136
main_screen.push_main_screen()
3237
dpg.set_viewport_pos([constants.x, constants.y])
3338
dpg.setup_dearpygui()
34-
dpg.set_primary_window("MainWindow", True)
39+
dpg.set_primary_window("main_window", True)
3540
dpg.show_viewport()
3641
dpg.start_dearpygui()
3742
dpg.destroy_context()

src/ue4ss_installer_gui/screens/__init__.py

Whitespace-only changes.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
import os
2+
import pathlib
3+
4+
from ue4ss_installer_gui.screens import main
5+
6+
import dearpygui.dearpygui as dpg
7+
8+
from ue4ss_installer_gui import data_structures, settings, constants, ue4ss, file_io
9+
10+
11+
# make sure it allows multiple game installs of the same game, show some _1 _2 or something
12+
# have it check the game dir not the game title for if it already exists later
13+
# if it's not an unreal game make it show a different popup, right now it says it's already in the list
14+
15+
16+
def game_dir_actually_has_unreal_game_check(game_dir_path: pathlib.Path):
17+
acceptable_dirs = [
18+
f"{file_io.SCRIPT_DIR}/Engine/Binaries",
19+
f"{file_io.SCRIPT_DIR}/Engine/Shared",
20+
f"{file_io.SCRIPT_DIR}/Engine/Shared",
21+
]
22+
acceptable_files = [f"{file_io.SCRIPT_DIR}/Manifest_NonUFSFiles_Win64.txt"]
23+
for acceptable_dir in acceptable_dirs:
24+
if os.path.isdir(os.path.normpath(acceptable_dir)):
25+
return True
26+
for acceptable_file in acceptable_files:
27+
if os.path.isfile(os.path.normpath(acceptable_file)):
28+
return True
29+
init_not_an_unreal_game_popup(game_dir_path)
30+
from time import sleep
31+
32+
sleep(0.1)
33+
dpg.configure_item("not_an_unreal_game_pop_up", show=True)
34+
return False
35+
36+
37+
def call_dismiss_pop_up_game_already_in_list():
38+
dpg.delete_item("game_already_exists_popup")
39+
40+
41+
def call_dismiss_pop_up_not_unreal_game():
42+
dpg.delete_item("not_an_unreal_game_pop_up")
43+
44+
45+
def init_not_an_unreal_game_popup(game_directory: pathlib.Path):
46+
if dpg.does_item_exist("not_an_unreal_game_pop_up"):
47+
dpg.delete_item("not_an_unreal_game_pop_up")
48+
dpg.add_window(
49+
modal=True,
50+
tag="not_an_unreal_game_pop_up",
51+
no_title_bar=True,
52+
min_size=[100, 140],
53+
)
54+
message = " The following game directory does not contain an unreal game:"
55+
message_two = os.path.normpath(str(game_directory))
56+
dpg.add_text(message, parent="not_an_unreal_game_pop_up", wrap=384)
57+
dpg.add_text(message_two, parent="not_an_unreal_game_pop_up", wrap=384)
58+
dpg.add_separator(parent="not_an_unreal_game_pop_up")
59+
dpg.add_button(
60+
label="Close",
61+
parent="not_an_unreal_game_pop_up",
62+
width=-1,
63+
height=-1,
64+
callback=call_dismiss_pop_up_not_unreal_game,
65+
)
66+
67+
68+
def init_game_already_in_list_pop_up(game_directory: pathlib.Path):
69+
dpg.add_window(
70+
modal=True, # this is randomly breaking it right now
71+
tag="game_already_exists_popup",
72+
no_title_bar=True,
73+
width=constants.window_width - 200,
74+
height=constants.window_height - 700,
75+
pos=(100, constants.y + 100),
76+
)
77+
message = " The following game already exists in the games list:"
78+
message_two = os.path.normpath(str(game_directory))
79+
dpg.add_text(message, parent="game_already_exists_popup", wrap=384)
80+
dpg.add_text(message_two, parent="game_already_exists_popup", wrap=384)
81+
dpg.add_separator(parent="game_already_exists_popup")
82+
dpg.add_button(
83+
label="Close",
84+
parent="game_already_exists_popup",
85+
width=-1,
86+
height=-1,
87+
callback=call_dismiss_pop_up_game_already_in_list,
88+
)
89+
90+
91+
def game_already_in_list_check(game_directory: pathlib.Path) -> bool:
92+
# this checks currently only the games in settings, it needs to also check the autopopulated list
93+
game_entries = settings.get_settings().get("games", {})
94+
is_game_already_in_list = False
95+
for game_entry in game_entries:
96+
if os.path.normpath(game_entry["install_dir"]) == os.path.normpath(
97+
str(game_directory)
98+
):
99+
is_game_already_in_list = True
100+
break
101+
if is_game_already_in_list:
102+
init_game_already_in_list_pop_up(game_directory)
103+
from time import sleep
104+
105+
sleep(0.1)
106+
dpg.configure_item("game_already_exists_popup", show=True)
107+
return True
108+
return False
109+
110+
111+
def add_manual_game_to_settings_file(game_dir_path: pathlib.Path) -> bool:
112+
was_valid = True
113+
if game_already_in_list_check(game_dir_path) == True:
114+
was_valid = False
115+
if game_dir_actually_has_unreal_game_check(game_dir_path) == False:
116+
was_valid = False
117+
if was_valid == False:
118+
return was_valid
119+
loaded_settings = settings.get_settings()
120+
game_entry = data_structures.GameInfo(
121+
install_dir=game_dir_path,
122+
game_title=os.path.basename(str(game_dir_path)),
123+
ue4ss_version=ue4ss.get_default_ue4ss_version_tag(),
124+
installed_files=[],
125+
platform=data_structures.GamePlatforms.OTHER,
126+
)
127+
128+
new_installed_files = []
129+
for file in game_entry.installed_files:
130+
new_installed_files.append(file)
131+
132+
game_entry_dict = {
133+
"game_title": game_entry.game_title,
134+
"install_dir": str(game_entry.install_dir),
135+
"ue4ss_version": game_entry.ue4ss_version,
136+
"installed_files": new_installed_files,
137+
"platform": game_entry.platform.name,
138+
}
139+
140+
games_list = loaded_settings.get("games", [])
141+
games_list.append(game_entry_dict)
142+
loaded_settings["games"] = games_list
143+
144+
settings.save_settings(loaded_settings)
145+
return was_valid
146+
147+
148+
def callback_directory_selected(sender, app_data):
149+
if add_manual_game_to_settings_file(pathlib.Path(app_data["file_path_name"])):
150+
dpg.delete_item("directory_picker")
151+
main.add_new_game_to_games_list(os.path.basename(app_data["file_path_name"]))
152+
153+
154+
def choose_directory():
155+
if dpg.does_item_exist("directory_picker"):
156+
dpg.delete_item("directory_picker")
157+
158+
dpg.add_file_dialog(
159+
directory_selector=True,
160+
show=True,
161+
callback=callback_directory_selected,
162+
tag="directory_picker",
163+
width=constants.window_width - 80,
164+
height=constants.window_height - 80,
165+
modal=True,
166+
)

src/ue4ss_installer_gui/configure_game_screen.py renamed to src/ue4ss_installer_gui/screens/configure_game.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
# keep mods and settings checkbox, ticked on by default
1212
# horizontal
1313
# switches between
14-
# reinstall/uninstall/install/verify/progress bar for downloading
14+
# reinstall/uninstall/
15+
# install/a list of horizontals
16+
# for each horizontal
17+
# check box
18+
# text label of the release file name/extensionn
19+
# progress bar for downloading
1520

16-
# filter releases download files by
17-
# "zMapGenBP.zip"
18-
# "zCustomGameConfigs.zip"
21+
# filter default things to install ticked releases download files by
1922
# "Dev" and "UE4SS"
2023
# not "Dev" and "UE4SS"
2124
# if not "Dev" in any "XInput"
Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
import os
22
import webbrowser
3+
import pathlib
34

45
import dearpygui.dearpygui as dpg
56

6-
from ue4ss_installer_gui import add_game_screen, steam, epic, unreal_engine, constants
7+
from ue4ss_installer_gui.screens import add_game
8+
9+
from ue4ss_installer_gui import (
10+
steam,
11+
epic,
12+
unreal_engine,
13+
constants,
14+
settings,
15+
unreal,
16+
ue4ss,
17+
)
18+
19+
# have to handle when people uninstall games, and leave eu4ss, and when people fully nuke
720

821

922
scroll_area_height = (
@@ -40,6 +53,17 @@ def init_main_screen_sub_header():
4053
dpg.add_text(subheader_text, wrap=constants.window_width - 40)
4154

4255

56+
def get_game_dirs_in_settings() -> list[pathlib.Path]:
57+
settings_game_dirs = []
58+
loaded_settings = settings.get_settings()
59+
games_list = loaded_settings.get("games", {})
60+
for entry in games_list:
61+
settings_game_dirs.append(entry.get("install_dir"))
62+
for settings_game_dir in settings_game_dirs:
63+
print(settings_game_dir)
64+
return settings_game_dirs
65+
66+
4367
def init_main_screen_game_list_scroll_box():
4468
with dpg.child_window(
4569
width=-1, height=scroll_area_height, tag="GameListScroll", autosize_x=True
@@ -56,9 +80,17 @@ def init_main_screen_game_list_scroll_box():
5680
str(base_dir)
5781
)
5882
]
59-
83+
str_game_settings_list = []
84+
for game_dir in get_game_dirs_in_settings():
85+
print(f"game_dir: {game_dir}")
86+
str_game_settings_list.append(game_dir)
87+
all_game_dirs.extend(str_game_settings_list)
6088
for game_dir in all_game_dirs:
61-
add_new_game_to_games_list(os.path.basename(game_dir))
89+
if (
90+
unreal.does_directory_contain_unreal_game(pathlib.Path(game_dir))
91+
or ue4ss.is_ue4ss_installed()
92+
):
93+
add_new_game_to_games_list(os.path.basename(game_dir))
6294

6395

6496
def init_main_screen_footer_section():
@@ -91,13 +123,13 @@ def init_main_screen_footer_section():
91123
dpg.add_spacer(width=constants.window_width - (4 * 50 + 20 + 160) - 24)
92124

93125
dpg.add_button(label="Add Game Manually", width=160, height=30, tag="ag")
94-
dpg.set_item_callback("ag", callback=add_game_screen.choose_directory)
126+
dpg.set_item_callback("ag", callback=add_game.choose_directory)
95127

96128

97129
def push_main_screen():
98130
with dpg.window(
99131
label="UE4SS Installer",
100-
tag="MainWindow",
132+
tag="main_window",
101133
no_title_bar=True,
102134
width=constants.window_width,
103135
height=constants.window_height,

src/ue4ss_installer_gui/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def init_settings():
2121
logger.log_message(f"Settings initialized from {SETTINGS_FILE}")
2222

2323

24-
def load_settings() -> tomlkit.TOMLDocument:
24+
def get_settings() -> tomlkit.TOMLDocument:
2525
if not os.path.isfile(SETTINGS_FILE):
2626
logger.log_message(f"Settings file {SETTINGS_FILE} does not exist!")
2727
raise FileNotFoundError("Missing settings file.")

0 commit comments

Comments
 (0)