diff --git a/CUE4Parse b/CUE4Parse index 5dd002d2..3a243aa9 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 5dd002d23f61f8104eca549ede03c2d9f112072f +Subproject commit 3a243aa9452658bbc6a74d538d1cf4d73da758f4 diff --git a/FModel/Extensions/AvalonExtensions.cs b/FModel/Extensions/AvalonExtensions.cs index b356e106..3021e178 100644 --- a/FModel/Extensions/AvalonExtensions.cs +++ b/FModel/Extensions/AvalonExtensions.cs @@ -14,6 +14,7 @@ public static class AvalonExtensions private static readonly IHighlightingDefinition _cppHighlighter = LoadHighlighter("Cpp.xshd"); private static readonly IHighlightingDefinition _changelogHighlighter = LoadHighlighter("Changelog.xshd"); private static readonly IHighlightingDefinition _verseHighlighter = LoadHighlighter("Verse.xshd"); + private static readonly IHighlightingDefinition _luaHighlighter = LoadHighlighter("Lua.xshd"); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static IHighlightingDefinition LoadHighlighter(string resourceName) @@ -29,6 +30,9 @@ public static class AvalonExtensions { switch (ext) { + case "lua": + case "luac": + return _luaHighlighter; case "ini": case "csv": return _iniHighlighter; diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 4ca717cf..90c2d391 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -81,6 +81,7 @@ + @@ -129,6 +130,7 @@ + diff --git a/FModel/Resources/Lua.xshd b/FModel/Resources/Lua.xshd new file mode 100644 index 00000000..148f5b97 --- /dev/null +++ b/FModel/Resources/Lua.xshd @@ -0,0 +1,230 @@ + + + + + + + + + + + + + --.*$ + + "([^"\\]|\\.)*" + '([^'\\]|\\.)*' + + \b\d+\.\d+([eE][+-]?\d+)?\b + \b\d+[eE][+-]?\d+\b + \b\d+\b + + + return + function + goto + end + if + else + elseif + then + for + in + until + while + break + or + and + repeat + do + + + + local + nil + not + true + false + + + + + assert + collectgarbage + error + ipairs + next + pairs + pcall + print + rawequal + rawget + rawlen + rawset + select + setmetatable + tonumber + tostring + type + xpcall + getmetatable + require + module + + + math + string + table + coroutine + os + io + utf8 + bit32 + package + debug + + + arshift + band + bnot + bor + bxor + btest + extract + lrotate + lshift + replace + rrotate + rshift + + + create + resume + running + status + wrap + yield + isyieldable + + + getuservalue + gethook + getinfo + getlocal + getregistry + getupvalue + upvaluejoin + upvalueid + setuservalue + sethook + setlocal + setupvalue + traceback + + + close + flush + input + lines + open + output + popen + read + tmpfile + seek + setvbuf + write + + + byte + char + dump + find + format + gmatch + gsub + len + lower + match + rep + reverse + sub + upper + pack + packsize + unpack + concat + maxn + insert + move + offset + codepoint + codes + charpattern + + + clock + date + difftime + execute + exit + getenv + remove + rename + setlocale + time + loadlib + searchpath + seeall + preload + cpath + path + searchers + loaded + + + abs + acos + asin + atan + atan2 + ceil + cos + cosh + deg + exp + floor + fmod + ult + log + log10 + max + min + modf + pi + rad + random + randomseed + sin + sqrt + tan + sinh + tanh + pow + frexp + ldexp + huge + maxinteger + mininteger + + + (\|)|(<<)|(>>)|(\/\/)|(==)|(~=)|(<=)|(>=)|(<)|(>)|(=)|(\()|(\))|(\{)|(\})|(\[)|(\])|(::)|(:)|(;)|(,)|(\.\.\.)|(\.\.)|(\.)|[+\-*%\^#&~] + + (?<=function\s)[A-Za-z0-9_]+(?=\.) + + (?<=\.)[A-Za-z0-9_]+(?=\() + (?<=function\s)[A-Za-z0-9_]+(?=\s*\() + + \b[A-Z_][A-Z0-9_]*\b + + diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index ee0fd647..197db7c2 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -24,6 +24,7 @@ using CUE4Parse.GameTypes.Borderlands3.Assets.Exports; using CUE4Parse.GameTypes.Borderlands4.Assets.Exports; using CUE4Parse.GameTypes.Borderlands4.Wwise; using CUE4Parse.GameTypes.DFHO.Assets.Objects; +using CUE4Parse.GameTypes.HonorOfKings.FileProvider; using CUE4Parse.GameTypes.KRD.Assets.Exports; using CUE4Parse.GameTypes.RocoKingdomWorld.Assets.Objects; using CUE4Parse.GameTypes.SMG.UE4.Assets.Exports.Wwise; @@ -195,6 +196,7 @@ public class CUE4ParseViewModel : ViewModel ], SearchOption.AllDirectories, versionContainer, pathComparer), _ when versionContainer.Game is EGame.GAME_AshEchoes => new AEDefaultFileProvider(gameDirectory, SearchOption.AllDirectories, versionContainer, pathComparer), _ when versionContainer.Game is EGame.GAME_BlackStigma => new DefaultFileProvider(gameDirectory, SearchOption.AllDirectories, versionContainer, StringComparer.Ordinal), + _ when versionContainer.Game is EGame.GAME_HonorofKingsWorld => new HoKWDefaultFileProvider(gameDirectory, SearchOption.AllDirectories, versionContainer, pathComparer), _ => new DefaultFileProvider(gameDirectory, SearchOption.AllDirectories, versionContainer, pathComparer) }; @@ -718,7 +720,6 @@ public class CUE4ParseViewModel : ViewModel case "verse": case "html": case "json5": - case "json": case "uref": case "cube": case "usda": @@ -773,6 +774,17 @@ public class CUE4ParseViewModel : ViewModel break; } + case "json": + { + var data = Provider.SaveAsset(entry); + using var stream = new MemoryStream(data) { Position = 0 }; + using var reader = new StreamReader(stream); + + var parsedJson = JsonConvert.DeserializeObject(reader.ReadToEnd()); + TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(parsedJson, Formatting.Indented), saveProperties, updateUi); + + break; + } case "locmeta": { var archive = entry.CreateReader();