Source code for cgl.plugins.unreal.utils.uproject
import os
from pathlib import Path
from cgl.plugins.perforce.utils.workspace import get_workspace_path
[docs]
def get_uproject_path(company, project, world):
workspace_path = Path(get_workspace_path(company, project, world))
if not os.listdir(workspace_path):
from cgl.ui.widgets.dialog import InputDialog
dialog = InputDialog(
title="Start New Project?",
message="Workspace is empty, start new UE project?",
)
dialog.exec()
if dialog.button == "Ok":
print("Creating UE project from template")
return
else:
return
file = list(workspace_path.glob("*.uproject"))[0]
if file:
return file
return None
[docs]
def set_default_map(path_object):
"""
Sets a default map to open whenever world is opened in unreal
Args:
path_object (cfg): Path object for the current unreal uproject
"""
project_folder = os.path.dirname(path_object.perforce_workspace)
config_path = os.path.join(project_folder, "Config")
settings_file_path = os.path.join(config_path, "DefaultEngine.ini")
settings_string = "[/Script/EngineSettings.GameMapsSettings]\nGameDefaultMap=/Game/Levels/DefaultLevel.DefaultLevel\nEditorStartupMap=/Game/Levels/DefaultLevel.DefaultLevel\n\n"
with open(settings_file_path, "a+") as f:
f.write(settings_string)
f.close()
if __name__ == "__main__":
print(get_uproject_path("JHCS", "ttas", "test"))