-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instanced Projects, AssetLocator, ParamBank, FMGBank #895
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
03ae5ea
Create project replacing assetlocator, rework functions to use common…
Philiquaz 4ea5fd6
Move statics usages
Philiquaz 2950aca
Remove passing of AssetLocator - Make it (temporarily) static
Philiquaz 6c42a46
Turn Assetlocator into a static dummy
Philiquaz 68afcf0
Move static hack to AssetLocator
Philiquaz 9218d1a
Rename project to projectassetlocator, introduce owning project object
Philiquaz b09337d
Clean some imports
Philiquaz 522aded
END SUPPORT of ER PartialParams, ParamBank to use new assetlocator.
Philiquaz cfc43f9
Stop reusing parambank instances, make them part of Project. Also kee…
Philiquaz eec8a6a
Change comparison menus to select project/mod folder
Philiquaz e08fe37
Allow to still select json from compare, including loading settings f…
Philiquaz dccb513
Defs loaded on a per-project/bank basis
Philiquaz 28567cf
Merge remote-tracking branch 'Soulsmods/master' into feat/Projects
Philiquaz 563ccf1
Repair from merge
Philiquaz 509024a
Merge branch 'feat/Projects' into feat/ProjectsPt2
Philiquaz 59d44a9
Move parammeta to be part of parambank
Philiquaz c0cb605
deduplicate project gametype (again)
Philiquaz f6d09c8
undo privacy because we are setting it outside and I don't want to fi…
Philiquaz e3dccc2
Scuffed start on instanced FMGBank
Philiquaz a58e6fd
Use own assetlocator in fmgbank, fix writemode
Philiquaz 24abf0e
fmg loading with fromOptions
Philiquaz 4f25dae
Move FMG enums to their own class
Philiquaz 64d97b6
Move big switches
Philiquaz 6980550
move post-load fmginfo edits
Philiquaz fccf0c2
Renamed UICategories to FileCategories so that we're not putting UI s…
Philiquaz aa21aef
Move data into dictionary rather than list
Philiquaz bdd38db
rename fmginfo uicategory, filecategory.text
Philiquaz 014853d
Move the game-based hacks to generateInfo
Philiquaz ab250b9
naming and insertion consistency
Philiquaz d0ad25c
Loaded categories is now backed by the fmgbank itself
Philiquaz a6c2056
Patching is on lookup instead of modifying data
Philiquaz 88476fc
Move sorting logic to lookup stuff
Philiquaz f049647
Split up Exporter, EntryGroup and FMGInfo
Philiquaz d5fc007
no more partial class
Philiquaz f5e32c0
Move reloading of FMGs to bank and outside of screen.
Philiquaz 830fe86
Move most of FMGBank into FMGLang
Philiquaz efec21f
Introduce FMGFileSet, finally some semblence of functioning again.
Philiquaz b9f0c7e
Merge remote-tracking branch 'Soulsmods/master' into feat/ProjectsFMG…
Philiquaz 93e77c9
Fix Errors when no project loaded, assetbrowser ordering
Philiquaz 4b0ae66
Merge remote-tracking branch 'Soulsmods/master' into feat/ProjectsFMG…
Philiquaz e9b45a0
GetProjectFileAllPaths util
Philiquaz df5d439
Merge remote-tracking branch 'Soulsmods/master' into feat/ProjectsFMG…
Philiquaz 263fb66
merge compile fixes
Philiquaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
using SoulsFormats; | ||
using StudioCore.Editor; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace StudioCore; | ||
|
||
/// <summary> | ||
/// Helper functions and statics for Project/Assetlocator | ||
/// </summary> | ||
public class AssetUtils | ||
{ | ||
public static readonly string GameExecutableFilter; | ||
public static readonly string ProjectJsonFilter; | ||
public static readonly string RegulationBinFilter; | ||
public static readonly string Data0Filter; | ||
public static readonly string ParamBndDcxFilter; | ||
public static readonly string ParamBndFilter; | ||
public static readonly string EncRegulationFilter; | ||
public static readonly string ParamLooseFilter; | ||
public static readonly string CsvFilter; | ||
public static readonly string TxtFilter; | ||
public static readonly string FmgJsonFilter; | ||
|
||
static AssetUtils() | ||
{ | ||
// These patterns are meant to be passed directly into PlatformUtils. | ||
// Everything about their handling should be done there. | ||
|
||
// Game Executable (.EXE, EBOOT.BIN)|*.EXE*;*EBOOT.BIN* | ||
// Windows executable (*.EXE)|*.EXE* | ||
// Playstation executable (*.BIN)|*.BIN* | ||
GameExecutableFilter = "exe,bin"; | ||
// Project file (project.json)|PROJECT.JSON | ||
ProjectJsonFilter = "json"; | ||
// Regulation file (regulation.bin)|REGULATION.BIN | ||
RegulationBinFilter = "bin"; | ||
// Data file (Data0.bdt)|DATA0.BDT | ||
Data0Filter = "bdt"; | ||
// ParamBndDcx (gameparam.parambnd.dcx)|GAMEPARAM.PARAMBND.DCX | ||
ParamBndDcxFilter = "parambnd.dcx"; | ||
// ParamBnd (gameparam.parambnd)|GAMEPARAM.PARAMBND | ||
ParamBndFilter = "parambnd"; | ||
// Enc_RegBndDcx (enc_regulation.bnd.dcx)|ENC_REGULATION.BND.DCX | ||
EncRegulationFilter = "bnd.dcx"; | ||
// Loose Param file (*.Param)|*.Param | ||
ParamLooseFilter = "param"; | ||
// CSV file (*.csv)|*.csv | ||
CsvFilter = "csv"; | ||
// Text file (*.txt)|*.txt | ||
TxtFilter = "txt"; | ||
// Exported FMGs (*.fmg.json)|*.fmg.json | ||
FmgJsonFilter = "fmg.json"; | ||
// All file filter is implicitly added by NFD. Ideally this is used explicitly. | ||
// All files|*.* | ||
} | ||
public static GameType GetGameTypeForExePath(string exePath) | ||
{ | ||
var type = GameType.Undefined; | ||
if (exePath.ToLower().Contains("darksouls.exe")) | ||
{ | ||
type = GameType.DarkSoulsPTDE; | ||
} | ||
else if (exePath.ToLower().Contains("darksoulsremastered.exe")) | ||
{ | ||
type = GameType.DarkSoulsRemastered; | ||
} | ||
else if (exePath.ToLower().Contains("darksoulsii.exe")) | ||
{ | ||
type = GameType.DarkSoulsIISOTFS; | ||
} | ||
else if (exePath.ToLower().Contains("darksoulsiii.exe")) | ||
{ | ||
type = GameType.DarkSoulsIII; | ||
} | ||
else if (exePath.ToLower().Contains("eboot.bin")) | ||
{ | ||
var path = Path.GetDirectoryName(exePath); | ||
if (Directory.Exists($@"{path}\dvdroot_ps4")) | ||
{ | ||
type = GameType.Bloodborne; | ||
} | ||
else | ||
{ | ||
type = GameType.DemonsSouls; | ||
} | ||
} | ||
else if (exePath.ToLower().Contains("sekiro.exe")) | ||
{ | ||
type = GameType.Sekiro; | ||
} | ||
else if (exePath.ToLower().Contains("eldenring.exe")) | ||
{ | ||
type = GameType.EldenRing; | ||
} | ||
else if (exePath.ToLower().Contains("armoredcore6.exe")) | ||
{ | ||
type = GameType.ArmoredCoreVI; | ||
} | ||
|
||
return type; | ||
} | ||
|
||
public static bool CheckFilesExpanded(string gamepath, GameType game) | ||
{ | ||
if (game == GameType.EldenRing) | ||
{ | ||
if (!Directory.Exists($@"{gamepath}\map")) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!Directory.Exists($@"{gamepath}\asset")) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
if (game is GameType.DarkSoulsPTDE or GameType.DarkSoulsIII or GameType.Sekiro) | ||
{ | ||
if (!Directory.Exists($@"{gamepath}\map")) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!Directory.Exists($@"{gamepath}\obj")) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
if (game == GameType.DarkSoulsIISOTFS) | ||
{ | ||
if (!Directory.Exists($@"{gamepath}\map")) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!Directory.Exists($@"{gamepath}\model\obj")) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
if (game == GameType.ArmoredCoreVI) | ||
{ | ||
if (!Directory.Exists($@"{gamepath}\map")) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!Directory.Exists($@"{gamepath}\asset")) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public static string GetGameIDForDir(GameType Type) | ||
{ | ||
switch (Type) | ||
{ | ||
case GameType.DemonsSouls: | ||
return "DES"; | ||
case GameType.DarkSoulsPTDE: | ||
return "DS1"; | ||
case GameType.DarkSoulsRemastered: | ||
return "DS1R"; | ||
case GameType.DarkSoulsIISOTFS: | ||
return "DS2S"; | ||
case GameType.Bloodborne: | ||
return "BB"; | ||
case GameType.DarkSoulsIII: | ||
return "DS3"; | ||
case GameType.Sekiro: | ||
return "SDT"; | ||
case GameType.EldenRing: | ||
return "ER"; | ||
case GameType.ArmoredCoreVI: | ||
return "AC6"; | ||
default: | ||
throw new Exception("Game type not set"); | ||
} | ||
} | ||
|
||
public static AssetDescription GetNullAsset() | ||
{ | ||
AssetDescription ret = new(); | ||
ret.AssetPath = "null"; | ||
ret.AssetName = "null"; | ||
ret.AssetArchiveVirtualPath = "null"; | ||
ret.AssetVirtualPath = "null"; | ||
return ret; | ||
} | ||
|
||
public static string GetBinderVirtualPath(string virtualPathToBinder, string binderFilePath) | ||
{ | ||
var filename = Path.GetFileNameWithoutExtension($@"{binderFilePath}.blah"); | ||
if (filename.Length > 0) | ||
{ | ||
filename = $@"{virtualPathToBinder}/{filename}"; | ||
} | ||
else | ||
{ | ||
filename = virtualPathToBinder; | ||
} | ||
|
||
return filename; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a static dictionary for a fast lookup? (for all the switches here, might add up if summed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might, but then there's the nuanced cases like des vs bb, or in other such methods the shared cases.
For the whole file, I think ideally we'd define an object/jumptable and do some scummy OOP to handle per-game behaviours (and reuse this "game implementation" class for different databanks eg param loading code, fmg loading code etc.)
But moving to that sort of system might be a step beyond what this PR is focusing on, which is more to instantiate projects and databanks separately, as well as just clean up some asset lookup code.
That is, if I'm understanding your point.
In terms of performance, this particular function is negligibly used.