Skip to content

Commit 3f15f7a

Browse files
committed
Add a couple more options to snapshot profile
- These need to be in the snapshot profile, rather than game profile, because they may vary depending on what is being snapshot from a particular game (vs game profile stuff which is global for the game) - Also log current snap profile values on startup
1 parent c6054b0 commit 3f15f7a

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,6 @@ Native/mod_stats/__test_mod_stats.txt
7676
Native/mod_stats/__test_process_messages_1.txt
7777
Native/mod_stats/__test_process_messages_2.txt
7878
Native/mod_stats/__test_process_messages_3.txt
79-
g2005g1_pre.sh
79+
g2025g1_pre.sh
80+
G2025g1
81+
SnapshotProfiles/TestProfile1.yaml

MMManaged/SnapshotProfile.fs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ open System.IO
1212
/// in the correct space for the game.
1313
/// SnapshotProfiles are loaded from yaml files in the "SnapshotProfiles" subdirectory of the modelmod installation folder.
1414
module SnapshotProfile =
15-
type Profile(name,posX,uvX) =
15+
type Profile(name,posX,uvX,flipTangent,vecEncoding) =
1616
member x.Name() = name
1717
member x.PosXForm() = posX
1818
member x.UVXForm() = uvX
19+
member x.FlipTang() = flipTangent
20+
member x.VecEncoding() = vecEncoding
1921

2022
override x.ToString() =
21-
sprintf "[SnapshotProfile: %s; pos: %A; uv: %A]" name posX uvX
23+
sprintf "[SnapshotProfile: %s; pos: %A; uv: %A, fliptangent: %A, vecencoding: %A]" name posX uvX flipTangent vecEncoding
2224

23-
let EmptyProfile = Profile("",[],[])
25+
let EmptyProfile = Profile("",[],[],false,"")
2426

2527
/// This profile should always exist in SnapshotProfiles.yaml.
2628
/// If it does not, new game profiles will be created with an empty snapshot profile (not an error, but not desirable either)
@@ -52,10 +54,29 @@ module SnapshotProfile =
5254
| None -> def
5355
| Some s -> s |> Seq.map Yaml.toString |> List.ofSeq
5456

57+
let getBool def key =
58+
pvals
59+
|> Yaml.getOptionalValue key
60+
|> Yaml.toOptionalBool
61+
|> function
62+
| None -> def
63+
| Some b -> b
64+
65+
let getString def key =
66+
pvals
67+
|> Yaml.getOptionalValue key
68+
|> Yaml.toOptionalString
69+
|> function
70+
| None -> def
71+
| Some s -> s
72+
73+
5574
let posX = getStrList [] "pos"
5675
let uvX = getStrList [] "uv"
76+
let flipTang = getBool false "flipTangent"
77+
let vecEncoding = getString "" "vecEncoding"
5778

58-
profiles.Add(pname,Profile(pname,posX,uvX))
79+
profiles.Add(pname,Profile(pname,posX,uvX,flipTang,vecEncoding))
5980
)
6081
profiles.ToArray() |> Map.ofArray
6182

MMManaged/State.fs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,15 @@ module State =
119119

120120
_rootDir <- rootDir
121121

122+
let mutable snapProfileVal = None;
123+
122124
let snapProfile =
123125
try
124126
let sprofiles = SnapshotProfile.GetAll(_rootDir)
125127
_snapProfiles <- sprofiles
126-
if not (sprofiles |> Map.containsKey conf.SnapshotProfile) then
128+
snapProfileVal <- sprofiles |> Map.tryFind conf.SnapshotProfile
129+
130+
if snapProfileVal.IsNone then
127131
log().Error "Unrecognized snapshot profile: %A; no snapshot transforms will be applied" conf.SnapshotProfile
128132
log().Info "The following snapshot profiles are available: %A" _snapProfiles
129133
""
@@ -140,6 +144,7 @@ module State =
140144
}
141145
log().Info "Root dir: %A" (Path.GetFullPath(_rootDir))
142146
log().Info "Conf: %A" conf
147+
log().Info "SnapProfile: %A" snapProfileVal
143148

144149
_conf <- conf
145150
_locator <- DirLocator(_rootDir,_conf)

0 commit comments

Comments
 (0)