snake-biscuits / bsp_tool

Python library for analysing .bsp files
GNU General Public License v3.0
102 stars 8 forks source link

Load bulk bsps #139

Open snake-biscuits opened 1 year ago

snake-biscuits commented 1 year ago

Most times when I test things, I grab multiple maps at once This involves typing the same block of code at the start of every session:

>>> import bsp_tool, fnmatch, os
>>> md = "E:/Mod/Titanfall"
>>> maps = {m[:-4]: bsp_tool.load_bsp(os.path.join(md, m)) for m in fnmatch.filter(os.listdir(md), "*.bsp")}

tests.utils.get_test_maps does a similar job, but doesn't overlap well w/ current needs I would also like to feed the archive to gets w/ get_test_maps, as a pytest flag

tests.test_load_bsp.test_load_bsp

I'd like to break The MegaTest up into more functions (seeing the name all typed out, it's so ugly; real MuffinMail.MuffinHash.MuffinHash energy) Being able to target a specific chunk of the MegaTest would be nice Also means the MegaTest is just for redundancy, new branches can be tested solo

The Apex Archive will require more robust tools

We need to be able to compare iterations of maps (extensions.diff needs more work too) e.g. Titanfall: Beta -> Titanfall 2: Tech Test (PS4) -> Titanfall 2 And because of how manual the process is rn, Titanfall Engine depots/ are rarely looked at.

snake-biscuits commented 1 year ago

spending all day on tools for The Apex Archive made me realise how bad it is

snake-biscuits commented 1 year ago

Would be nice to have bulk tools for the following branches:

Vindictus has over 400 maps, and we have 2 branches to manage w/ 3 StaticProp formats Also ties into:

snake-biscuits commented 12 months ago

Loading all Titanfall 2 depots:

>>> import bsp_tool, os, fnmatch
>>> dd = "E:/Mod/Titanfall2/depot"
>>> depots = os.listdir(dd)
>>> sd = "game/r2/maps"
>>> maps = {f"{d}/{m[:-4]}": bsp_tool.load_bsp(os.path.join(dd, d, sd, m))
...         for d in depots
...         for m in fnmatch.filter(os.listdir(os.path.join(dd, d, sd)), "*.bsp")}

Inspecting workshop map listings is equally absurd (1 folder per "mod") Could probably say the same for .pk3 (Quake III Dreamcast is hell)

snake-biscuits commented 4 weeks ago

195 is kinda revisiting this idea

But coming in from the angle of tests

Since we broke out autodetect into it's own script, bsp_tool/__init__.py is much less cluttered I can see some proper functions for this

def bulk_load_bsp(special_dict: BulkDict, BspClass=None, branch=None):
    if BspClass is None or branch is None:
        use_autodetect = True
    ...
snake-biscuits commented 4 weeks ago

We need some kind of standard object to return Not just a {"map_name": bsp} dict Where a .bsp comes from is important (which Apex season, .pak etc.)

snake-biscuits commented 3 weeks ago

I've mostly finished a refactor of tests.files that could work for this

>>> from tests import files
>>> search_area = {"Steam": {"Half-Life 2 (Ep1)": ["half-life 2/episodic/maps/"]}}
>>> from bsp_tool.valve import ValveBsp
>>> from bsp_tool.branches.valve import orange_box
>>> files.library_bsps(ValveBsp, {orange_box: search_area})
{"Steam | Half-Life 2 (Ep1) | credits.bsp": <ValveBsp 'credits.bsp' valve.orange_box (VBSP version 19)>,
 "Steam | Half-Life 2 (Ep1) | ep1_c17_00.bsp": <ValveBsp 'ep1_c17_00.bsp' valve.orange_box (VBSP version 20)>,
 ...}

NOTE: no autodetect, since it's for testing branch scripts & BspClasses

Related