def main(): arkman = ArkSteamManager() loader = arkman.getLoader() config = get_global_config() assetname = sys.argv[1] if len(sys.argv) > 1 else None if not assetname: print('Usage: python ueexport.py <assetname>') sys.exit(1) assetname = find_asset(assetname, loader) if not assetname: print("Not found") sys.exit(1) asset = loader[assetname] assert asset.default_export if not asset.default_export: print("Asset has no default export") sys.exit(2) export = asset.default_export data = sanitise_output(export.properties) pprint(data) save_as_json(data, f'output/{asset.name}.{export.name}.json', pretty=True)
def _gather_relations(arkman: ArkSteamManager, basepath: Path): relations: List[Tuple[str, str]] # list of (name, parent) inclusions = arkman.config.optimisation.SearchInclude exclusions = arkman.config.optimisation.SearchIgnore basepath.mkdir(parents=True, exist_ok=True) # Scan core (or read cache) cachefile = basepath / 'core' version_key = dict(format=FORMAT_VERSION, game_buildid=arkman.getGameBuildId(), inclusions=inclusions, exclusions=exclusions) relations = cache_data(version_key, cachefile, lambda _: _scan_core(arkman)) # Scan /Game/Mods/<modid> for each installed mod (or read cache) for modid in get_managed_mods(): cachefile = basepath / f'mod-{modid}' mod_version = arkman.getModData(modid)['version'] # type:ignore version_key = dict(format=FORMAT_VERSION, mod_version=mod_version, inclusions=inclusions, exclusions=exclusions) mod_relations = cache_data(version_key, cachefile, lambda _: _scan_mod(modid, arkman)) relations.extend(mod_relations) return relations
def _gather_version_data(arkman: ArkSteamManager, config: ConfigFile): # Gather identities and versions of all involved components key = dict(format=4, core=dict(version=arkman.getGameVersion(), buildid=arkman.getGameBuildId()), mods=dict((modid, arkman.getModData(modid)['version']) for modid in config.mods)) # type: ignore return key
def _gather_version_data(arkman: ArkSteamManager, config: ConfigFile): # Gather identities and versions of all involved components if not arkman.mod_data_cache or not arkman.getGameBuildId(): raise AssertionError("ArkManager must be fully initialised") key = dict(format=5, core=dict(buildid=arkman.getGameBuildId()), mods=dict((modid, arkman.getModData(modid)['version']) for modid in config.mods)) # type: ignore return key
def collect_asset(assetname: str) -> UAsset: arkman = ArkSteamManager() loader = arkman.getLoader() # config = get_global_config() assetname = find_asset(args.assetname, loader) if not assetname: print("Asset not found") sys.exit(1) return loader[assetname]
def __init__(self, arkman: ArkSteamManager, modids: Set[str], config: ConfigFile): self.config = config self.arkman = arkman self.modids = modids self.loader = arkman.createLoader() self.discoverer = ark.discovery.SpeciesDiscoverer(self.loader) self.game_version = self.arkman.getGameVersion()
def __init__(self, arkman: ArkSteamManager, git: GitManager, config=get_global_config()): self.config: ConfigFile = config self.arkman: ArkSteamManager = arkman self.loader: AssetLoader = arkman.getLoader() self.git = git self.roots: List[ExportRoot] = []
def __init__(self, arkman: ArkSteamManager, modids: Set[str], config: ConfigFile): self.config = config self.arkman = arkman self.modids = modids self.loader = arkman.getLoader() self.game_version = self.arkman.getGameVersion() self.discoverer = Discoverer(self.loader, remove_assets_from_cache=True) self.discoverer.register_asset_tester(CompositionSublevelTester())
def _explore_path( path: str, is_mod: bool, arkman: ArkSteamManager, verbose: bool = False) -> Generator[Tuple[str, str], None, None]: n = 0 includes = set(arkman.config.optimisation.SearchInclude) mod_excludes = set(arkman.config.optimisation.SearchIgnore) core_excludes = set( ['/Game/Mods/.*', *arkman.config.optimisation.SearchIgnore]) excludes = mod_excludes if is_mod else core_excludes loader = arkman.getLoader() with ue_parsing_context(properties=False, bulk_data=False): asset_iterator = loader.find_assetnames( path, include=includes, exclude=excludes, extension=ue.hierarchy.asset_extensions, return_extension=True) for (assetname, ext) in asset_iterator: n += 1 if verbose and n % 200 == 0: logger.info(assetname) try: asset = loader.load_asset(assetname, quiet=not verbose) except AssetLoadException: logger.warning("Failed to load asset: %s", assetname) continue try: export: ExportTableItem for export in ue.hierarchy._find_exports_to_store(asset, ext): parent = ue.hierarchy._get_parent_cls(export) fullname = export.fullname if not parent: raise ValueError( f"Unexpected missing parent for export: {fullname}" ) if not fullname: raise ValueError( f"Unexpected empty export name: {export.asset.assetname}.{export.name}" ) yield (fullname, parent) except AssetLoadException: logger.warning("Failed to check parentage of %s", assetname) # Remove maps from the cache immediately as they are large and cannot be inherited from if ext == '.umap': loader.cache.remove(assetname)
def initialise_hierarchy(arkman: ArkSteamManager, config: ConfigFile = get_global_config()): version_key = _gather_version_data(arkman, config) loader = arkman.getLoader() gen_fn = lambda _: _generate_hierarchy(loader) output_path = f'{config.settings.DataDir}/asset_hierarchy' data = cache_data(version_key, output_path, gen_fn, force_regenerate=config.dev.ClearHierarchyCache) ue.hierarchy.tree = data
def run(): config = get_global_config() config.settings.SkipInstall = True arkman = ArkSteamManager(config=config) arkman.ensureSteamCmd() arkman.ensureGameUpdated() arkman.ensureModsUpdated(config.mods) initialise_hierarchy(arkman, config) for result in find_matches(): output_result(result)
def collect_asset(assetname: str) -> UAsset: config = get_global_config() config.settings.SkipInstall = True arkman = ArkSteamManager(config=config) if args.ovi: # Hierarchy is needed for proxies in the Oviraptor target. arkman.ensureSteamCmd() arkman.ensureGameUpdated() arkman.ensureModsUpdated(config.mods) initialise_hierarchy(arkman) loader = arkman.getLoader() # config = get_global_config() assetname = find_asset(args.assetname, loader) if not assetname: print("Asset not found") sys.exit(1) return loader[assetname]
from typing import * from deepdiff import DeepDiff import ark.mod import ark.properties from ark.export_asb_values import values_for_species from automate.ark import ArkSteamManager, readModData from ue.asset import UAsset from ue.base import UEBase from ue.loader import AssetLoader from ue.properties import * from ue.stream import MemoryStream from ue.utils import * arkman = ArkSteamManager() loader = arkman.getLoader() version_string = None #%% Helpers replace_name = lambda match: f'{species_names[int(match.group(1))]}' # replace_stat = lambda match: f'stat.{stat_names[int(match.group(1))]}.{stat_fields[int(match.group(2))]}' SPECIES_REGEX = re.compile(r"root\['species'\]\[(\d+)\]") STAT_REGEX = re.compile(r"statsRaw\[(\d+)\]\[(\d+)\]") JOIN_LINES_REGEX = re.compile(r"(?:\n\t+)?(?<=\t)([\d.-]+,?)(?:\n\t+)?") def clean_diff_output(diff): diff = SPECIES_REGEX.sub(replace_name, diff)
odd = False for propname, propvalues in sorted(propertyvalues.items(), key=lambda p: p[0]): for index, values in sorted(propvalues.items(), key=lambda p: p[0]): assetvalues = [values[assetname] or '' for assetname in assetlist] tree.insert('', 'end', text=propname, values=[propname, index] + assetvalues, tags=('odd' if odd else 'even', )) odd = not odd if __name__ == '__main__': global arkman, loader arkman = ArkSteamManager() loader = arkman.createLoader() mainasset = sys.argv[1] if len(sys.argv) > 1 else None create_ui() assert root if not mainasset: from tkinter import filedialog from pathlib import Path assetname = filedialog.askopenfilename( title='Select asset file...', filetypes=(('uasset files', '*.uasset'), ("All files", "*.*")), initialdir=loader.asset_path) assert assetname path = Path(assetname).relative_to(loader.asset_path).with_suffix('')
from config import ConfigFile, get_global_config from ue.asset import ExportTableItem, ImportTableItem, UAsset from ue.gathering import gather_properties from ue.hierarchy import inherits_from from ue.loader import AssetLoader, AssetNotFound basicConfig(level=INFO) logger = getLogger(__name__) logger.addHandler(NullHandler()) config = get_global_config() config.settings.SkipInstall = True # config.mods = tuple('111111111,895711211,839162288'.split(',')) arkman = ArkSteamManager(config=config) arkman.ensureSteamCmd() arkman.ensureGameUpdated() arkman.ensureModsUpdated(config.mods) loader = arkman.getLoader() print() print('Interactive session ready:') print(' arkman : ArkSteamManager initialised in dry-run mode') print(' loader : Asset loader') print(' config : A safe default config') print() print('Restrict managed mods for this session:') print('>>> config.mods = tuple(\'111111111\',\'895711211\',\'839162288\')') print() print('To get access to the fully cached asset hierarchy:')
#%% Setup from interactive_utils import * # pylint: disable=wrong-import-order import logging from automate.ark import ArkSteamManager logging.basicConfig(level=logging.INFO) arkman = ArkSteamManager() #%% Init arkman.ensureSteamCmd() #%% Update game gamever = arkman.ensureGameUpdated() print(f'\nGame:\n') print(f'Version: {gamever}') print(f'Content path: {arkman.getContentPath()}') print() #%% Update mods arkman.ensureModsUpdated([ # 829467257, # SurvivalPlus 839162288, # Primal_Fear # 893735676, # Ark Eternal 895711211, # ClassicFlyers # 919470289, # SSFlyer # 1083349027, # SpeedyFlyers # 1090809604, # Pyria
def fixture_loader(config: ConfigFile) -> AssetLoader: arkman = ArkSteamManager(config=config) loader = arkman.getLoader() return loader
def fixture_loader() -> AssetLoader: arkman = ArkSteamManager() loader = arkman.getLoader() return loader
def fixture_loader(arkman: ArkSteamManager) -> AssetLoader: loader = arkman.getLoader() return loader
def fixture_arkman(config: ConfigFile) -> ArkSteamManager: arkman = ArkSteamManager(config=config) return arkman