Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions Utilities/ContentGenerator/ContentGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

from Hibiscus.FileCopyer import copy_assets, copy_config, copy_executable, copy_modules
from Hibiscus.FileLister import get_file_operation
from Platform.PlatformHandler import get_platform, PlatformHandler
from Utilities.DictHelper import load_from_file
from Utilities.Encrypter import encrypt_file, hash_file
from Utilities.File import remove_tree, iterate_path, remove_file, copy_to_file
from Utilities.Ini import set_ini, __python_read_ini
from Utilities.Platform import is_steam, set_platform
from Platform.Platform import is_steam, set_platform

init(autoreset=True)

Expand Down Expand Up @@ -48,23 +49,16 @@
if __python_read_ini(configPath, 'Path', 'Relative') == '1':
pathPrefix = projectPath

SteamCMDPath = pathPrefix + __python_read_ini(configPath, 'Path', 'SteamCMDPath')
ContentPath = pathPrefix + __python_read_ini(configPath, 'Path', 'ContentPath')

# Settings
AppName = __python_read_ini(configPath, 'Project', 'AppName')
Encrypter_Key = __python_read_ini(configPath, 'Project', 'Encrypter_Key')
ContentPath = pathPrefix + __python_read_ini(configPath, 'Path', 'ContentPath')

# user_name = input('Enter user name:')
user_name = args.userName

# https://partner.steamgames.com/doc/sdk/uploading#automating_steampipe
if args.setUpCI:
password = input('Enter user password:')
guard = input('Enter user guard:')

subprocess.call("{} +login {} {} {} +info +quit".format(SteamCMDPath,
user_name, password, guard))
PlatformHandler.set_up_ci(pathPrefix, configPath, user_name)

if not args.uploadOnly:
if args.fullBuild:
Expand Down Expand Up @@ -120,10 +114,14 @@
platform, enable, app_id, script_path = task_content
if not enable:
continue
script_path = pathPrefix + script_path

print(Fore.CYAN + 'building {}...'.format(task_name))
print(Fore.CYAN + 'init platform {}...'.format(platform))
platform_handler = get_platform(platform, pathPrefix)
platform_handler.update_user([user_name])
platform_handler.update_task([platform, enable, app_id, script_path])

script_path = pathPrefix + script_path
print(Fore.CYAN + 'building {}...'.format(task_name))
exe_path = "{}\\{}.exe".format(ContentPath, AppName)

# copy
Expand All @@ -132,10 +130,7 @@

# drm
print(Fore.BLUE + 'drm...')
if is_steam(platform):
subprocess.call("{} +login {} +drm_wrap {} \"{}\" \"{}\" drmtoolp 0 +quit".format(SteamCMDPath,
user_name, app_id, exe_path,
exe_path))
platform_handler.drm(exe_path)

# update configs
print(Fore.BLUE + 'update configs...')
Expand All @@ -150,10 +145,8 @@
encrypt_file(ContentPath + r"\settings\settings.ini", Encrypter_Key)
encrypt_file(ContentPath + r"\settings\settings_Template.ini", Encrypter_Key)

# drm
# upload
print(Fore.BLUE + 'upload...')
if is_steam(platform):
subprocess.call("{} +login {} +run_app_build \"{}\" +quit".format(SteamCMDPath,
user_name, script_path))
platform_handler.upload()

print(Fore.CYAN + 'building {} complete'.format(task_name))
18 changes: 18 additions & 0 deletions Utilities/ContentGenerator/Platform/Impl/Epic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import subprocess

from Platform.PlatformHandler import PlatformHandler


class Epic(PlatformHandler):
def __init__(self, path_prefix, config_path):
PlatformHandler.__init__(self, path_prefix, config_path)

def drm(self, exe_path):
platform, enable, app_id, script_path = PlatformHandler.task_content

def upload(self):
pass

@staticmethod
def update_ci(path_prefix, config_path, user_name):
pass
37 changes: 37 additions & 0 deletions Utilities/ContentGenerator/Platform/Impl/Steam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import subprocess

from Platform.PlatformHandler import PlatformHandler
from Utilities.Ini import __python_read_ini


class Steam(PlatformHandler):
steam_cli_path: str

def __init__(self, path_prefix, config_path):
PlatformHandler.__init__(self, path_prefix, config_path)
self.steam_cli_path = path_prefix + __python_read_ini(config_path, 'Path', 'SteamCMDPath')

def drm(self, exe_path):
platform, enable, app_id, script_path = PlatformHandler.task_content
user_name = PlatformHandler.user_info

subprocess.call("{} +login {} +drm_wrap {} \"{}\" \"{}\" drmtoolp 0 +quit".format(PlatformHandler.path_prefix,
user_name, app_id, exe_path,
exe_path))

def upload(self):
platform, enable, app_id, script_path = PlatformHandler.task_content
user_name = PlatformHandler.user_info

subprocess.call("{} +login {} +run_app_build \"{}\" +quit".format(PlatformHandler.path_prefix,
user_name, script_path))

@staticmethod
def update_ci(path_prefix, config_path, user_name):
# https://partner.steamgames.com/doc/sdk/uploading#automating_steampipe
password = input('Enter user password:')
guard = input('Enter user guard:')

steam_cli_path = path_prefix + __python_read_ini(config_path, 'Path', 'SteamCMDPath')
subprocess.call("{} +login {} {} {} +info +quit".format(steam_cli_path,
user_name, password, guard))
45 changes: 45 additions & 0 deletions Utilities/ContentGenerator/Platform/PlatformHandler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from abc import ABC, abstractmethod

from Platform.Impl.Epic import Epic
from Platform.Platform import is_steam, is_epic
from Platform.Impl.Steam import Steam


class PlatformHandler(ABC):
config_path: str
path_prefix: str
user_info: any
task_content: any

def __init__(self, path_prefix, config_path):
self.path_prefix = path_prefix
self.config_path = config_path

def update_user(self, user_info):
self.user_info = user_info

def update_task(self, task_content):
self.task_content = task_content

@abstractmethod
def drm(self, exe_path):
pass

@abstractmethod
def upload(self):
pass

@staticmethod
@abstractmethod
def set_up_ci(path_prefix, config_path, user_name):
pass


def get_platform(platform, path_prefix, config_path) -> PlatformHandler:
if is_steam(platform):
return Steam(path_prefix, config_path)

if is_epic(platform):
return Epic(path_prefix, config_path)

raise Exception("Invalid platform!")