Skip to content

Commit dfc1a94

Browse files
committed
Added randomizer.
Added randomizer. Fixed bug with loading some levels with negative wall light levels. Added code to return Streams for files from GOBs/LFDs, in addition to directly loading into DfFile objects. Fixed rounding errors with palette loading. Minor bug fixes to Databound library. Fix selecting files inside GOBs in FileBrowser. Added ICloneable support to many of the file and randomizer classes. Small loading/saving fixes to some of the DF file classes. Rewrote parts of DfFont to be easier to use. Fix reading of Steam libraryfolders.vdf for most recent Steam Deck updates.
1 parent fa5d37c commit dfc1a94

File tree

127 files changed

+119635
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+119635
-384
lines changed

Assets/Dark Forces Showcase/LevelExplorer/LevelNameList.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ private void Start() {
1414
public void Refresh() {
1515
this.Clear();
1616
this.AddRange(Enumerable.Range(0, LevelLoader.Instance.LevelList.Levels.Count));
17-
this.SelectedValue = LevelLoader.Instance.CurrentLevelIndex;
17+
if (this.ToggleGroup != null) {
18+
this.SelectedValue = LevelLoader.Instance.CurrentLevelIndex;
19+
}
1820
}
1921
}
2022
}

Assets/Dark Forces Showcase/Loader.prefab

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ RectTransform:
228228
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
229229
m_AnchorMin: {x: 0, y: 1}
230230
m_AnchorMax: {x: 0, y: 1}
231-
m_AnchoredPosition: {x: 1386.9952, y: -33.11}
231+
m_AnchoredPosition: {x: 2747.5466, y: -33.11}
232232
m_SizeDelta: {x: 46.01, y: 46.01}
233233
m_Pivot: {x: 0.5, y: 0.5}
234234
--- !u!222 &78064304
@@ -388,8 +388,8 @@ RectTransform:
388388
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
389389
m_AnchorMin: {x: 0, y: 1}
390390
m_AnchorMax: {x: 0, y: 1}
391-
m_AnchoredPosition: {x: 749.12006, y: -33.109768}
392-
m_SizeDelta: {x: 1321.7733, y: 46.219543}
391+
m_AnchoredPosition: {x: 1429.3959, y: -33.109768}
392+
m_SizeDelta: {x: 2682.3386, y: 46.219543}
393393
m_Pivot: {x: 0.5, y: 0.5}
394394
--- !u!222 &97872367
395395
CanvasRenderer:
@@ -717,8 +717,8 @@ RectTransform:
717717
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
718718
m_AnchorMin: {x: 0, y: 1}
719719
m_AnchorMax: {x: 0, y: 1}
720-
m_AnchoredPosition: {x: 965, y: -408.56024}
721-
m_SizeDelta: {x: 910, y: 797.1205}
720+
m_AnchoredPosition: {x: 1645.2759, y: -408.56024}
721+
m_SizeDelta: {x: 2270.5518, y: 797.1205}
722722
m_Pivot: {x: 0.5, y: 0.5}
723723
--- !u!222 &251415155
724724
CanvasRenderer:
@@ -845,8 +845,8 @@ RectTransform:
845845
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
846846
m_AnchorMin: {x: 0, y: 1}
847847
m_AnchorMax: {x: 0, y: 1}
848-
m_AnchoredPosition: {x: 279.3567, y: -25.11}
849-
m_SizeDelta: {x: 558.7134, y: 50.22}
848+
m_AnchoredPosition: {x: 732.8739, y: -25.11}
849+
m_SizeDelta: {x: 1465.7478, y: 50.22}
850850
m_Pivot: {x: 0.5, y: 0.5}
851851
--- !u!222 &297960939
852852
CanvasRenderer:
@@ -969,8 +969,8 @@ RectTransform:
969969
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
970970
m_AnchorMin: {x: 0, y: 1}
971971
m_AnchorMax: {x: 0, y: 1}
972-
m_AnchoredPosition: {x: 720, y: -976.6703}
973-
m_SizeDelta: {x: 1420, y: 66.21954}
972+
m_AnchoredPosition: {x: 1400.2759, y: -976.6703}
973+
m_SizeDelta: {x: 2780.5518, y: 66.21954}
974974
m_Pivot: {x: 0.5, y: 0.5}
975975
--- !u!114 &304237836
976976
MonoBehaviour:
@@ -1297,7 +1297,7 @@ RectTransform:
12971297
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
12981298
m_AnchorMin: {x: 0, y: 1}
12991299
m_AnchorMax: {x: 0, y: 1}
1300-
m_AnchoredPosition: {x: 894.50006, y: -25.11}
1300+
m_AnchoredPosition: {x: 2255.0518, y: -25.11}
13011301
m_SizeDelta: {x: 31, y: 50.22}
13021302
m_Pivot: {x: 0.5, y: 0.5}
13031303
--- !u!222 &462446775
@@ -1883,7 +1883,7 @@ RectTransform:
18831883
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
18841884
m_AnchorMin: {x: 0, y: 1}
18851885
m_AnchorMax: {x: 0, y: 1}
1886-
m_AnchoredPosition: {x: 265.5417, y: -25.11}
1886+
m_AnchoredPosition: {x: 719.0589, y: -25.11}
18871887
m_SizeDelta: {x: 69.49, y: 40.22}
18881888
m_Pivot: {x: 0.5, y: 0.5}
18891889
--- !u!222 &690603146
@@ -2575,7 +2575,7 @@ RectTransform:
25752575
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
25762576
m_AnchorMin: {x: 0, y: 1}
25772577
m_AnchorMax: {x: 0, y: 1}
2578-
m_AnchoredPosition: {x: 1223.855, y: -35.11}
2578+
m_AnchoredPosition: {x: 2584.4067, y: -35.11}
25792579
m_SizeDelta: {x: 132.19, y: 50.22}
25802580
m_Pivot: {x: 0.5, y: 0.5}
25812581
--- !u!222 &857775272
@@ -2869,8 +2869,8 @@ RectTransform:
28692869
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
28702870
m_AnchorMin: {x: 0, y: 1}
28712871
m_AnchorMax: {x: 0, y: 1}
2872-
m_AnchoredPosition: {x: 766.0096, y: -33.11}
2873-
m_SizeDelta: {x: 1175.9604, y: 46.22}
2872+
m_AnchoredPosition: {x: 1446.2859, y: -33.11}
2873+
m_SizeDelta: {x: 2536.5117, y: 46.22}
28742874
m_Pivot: {x: 0.5, y: 0.5}
28752875
--- !u!222 &981356851
28762876
CanvasRenderer:
@@ -3068,8 +3068,8 @@ RectTransform:
30683068
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
30693069
m_AnchorMin: {x: 0, y: 1}
30703070
m_AnchorMax: {x: 0, y: 1}
3071-
m_AnchoredPosition: {x: 720, y: -93.33}
3072-
m_SizeDelta: {x: 1420, y: 66.22}
3071+
m_AnchoredPosition: {x: 1400.2759, y: -93.33}
3072+
m_SizeDelta: {x: 2780.5518, y: 66.22}
30733073
m_Pivot: {x: 0.5, y: 0.5}
30743074
--- !u!114 &1041850585
30753075
MonoBehaviour:
@@ -3386,10 +3386,10 @@ RectTransform:
33863386
m_Father: {fileID: 1513315606}
33873387
m_RootOrder: 0
33883388
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
3389-
m_AnchorMin: {x: 0.5, y: 0.5}
3390-
m_AnchorMax: {x: 0.5, y: 0.5}
3389+
m_AnchorMin: {x: 0, y: 0}
3390+
m_AnchorMax: {x: 1, y: 1}
33913391
m_AnchoredPosition: {x: 0, y: 0}
3392-
m_SizeDelta: {x: 1440, y: 1080}
3392+
m_SizeDelta: {x: 0, y: 0}
33933393
m_Pivot: {x: 0.5, y: 0.5}
33943394
--- !u!222 &1160257300
33953395
CanvasRenderer:
@@ -3521,7 +3521,7 @@ RectTransform:
35213521
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35223522
m_AnchorMin: {x: 0, y: 1}
35233523
m_AnchorMax: {x: 0, y: 1}
3524-
m_AnchoredPosition: {x: 1359.975, y: -35.11}
3524+
m_AnchoredPosition: {x: 2720.5266, y: -35.11}
35253525
m_SizeDelta: {x: 120.05, y: 50.22}
35263526
m_Pivot: {x: 0.5, y: 0.5}
35273527
--- !u!222 &1312019593
@@ -4391,8 +4391,8 @@ RectTransform:
43914391
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
43924392
m_AnchorMin: {x: 0, y: 1}
43934393
m_AnchorMax: {x: 0, y: 1}
4394-
m_AnchoredPosition: {x: 718.8567, y: -25.11}
4395-
m_SizeDelta: {x: 310.28668, y: 50.22}
4394+
m_AnchoredPosition: {x: 1852.6498, y: -25.11}
4395+
m_SizeDelta: {x: 763.8039, y: 50.22}
43964396
m_Pivot: {x: 0.5, y: 0.5}
43974397
--- !u!222 &1517053113
43984398
CanvasRenderer:
@@ -4648,8 +4648,8 @@ RectTransform:
46484648
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
46494649
m_AnchorMin: {x: 0, y: 1}
46504650
m_AnchorMax: {x: 0, y: 1}
4651-
m_AnchoredPosition: {x: 720, y: -535.00024}
4652-
m_SizeDelta: {x: 1420, y: 817.1205}
4651+
m_AnchoredPosition: {x: 1400.2759, y: -535.00024}
4652+
m_SizeDelta: {x: 2780.5518, y: 817.1205}
46534653
m_Pivot: {x: 0.5, y: 0.5}
46544654
--- !u!114 &1561274080
46554655
MonoBehaviour:
@@ -5868,8 +5868,8 @@ RectTransform:
58685868
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
58695869
m_AnchorMin: {x: 0, y: 1}
58705870
m_AnchorMax: {x: 0, y: 1}
5871-
m_AnchoredPosition: {x: 720, y: -35.11}
5872-
m_SizeDelta: {x: 1420, y: 50.22}
5871+
m_AnchoredPosition: {x: 1400.2759, y: -35.11}
5872+
m_SizeDelta: {x: 2780.5518, y: 50.22}
58735873
m_Pivot: {x: 0.5, y: 0.5}
58745874
--- !u!114 &2051305892
58755875
MonoBehaviour:
@@ -5986,8 +5986,8 @@ RectTransform:
59865986
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
59875987
m_AnchorMin: {x: 0, y: 1}
59885988
m_AnchorMax: {x: 0, y: 1}
5989-
m_AnchoredPosition: {x: 720, y: -1039.89}
5990-
m_SizeDelta: {x: 1420, y: 60.22}
5989+
m_AnchoredPosition: {x: 1400.2759, y: -1039.89}
5990+
m_SizeDelta: {x: 2780.5518, y: 60.22}
59915991
m_Pivot: {x: 0.5, y: 0.5}
59925992
--- !u!222 &2119520865
59935993
CanvasRenderer:
@@ -9671,7 +9671,7 @@ Canvas:
96719671
m_OverrideSorting: 0
96729672
m_OverridePixelPerfect: 0
96739673
m_SortingBucketNormalizedSize: 0
9674-
m_AdditionalShaderChannelsFlag: 0
9674+
m_AdditionalShaderChannelsFlag: 25
96759675
m_SortingLayerID: 0
96769676
m_SortingOrder: 100
96779677
m_TargetDisplay: 0
@@ -11129,6 +11129,7 @@ MonoBehaviour:
1112911129
collapsed: {fileID: 0}
1113011130
expanded: {fileID: 0}
1113111131
node: {fileID: 1450317669}
11132+
size: {fileID: 0}
1113211133
--- !u!1 &7758479752323762614
1113311134
GameObject:
1113411135
m_ObjectHideFlags: 0

Assets/Dark Forces Showcase/Map Generator/MapGenerator.unity

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7161,8 +7161,6 @@ GameObject:
71617161
serializedVersion: 6
71627162
m_Component:
71637163
- component: {fileID: 658956221}
7164-
- component: {fileID: 658956220}
7165-
- component: {fileID: 658956219}
71667164
- component: {fileID: 658956222}
71677165
- component: {fileID: 658956224}
71687166
- component: {fileID: 658956223}
@@ -7173,41 +7171,6 @@ GameObject:
71737171
m_NavMeshLayer: 0
71747172
m_StaticEditorFlags: 0
71757173
m_IsActive: 1
7176-
--- !u!114 &658956219
7177-
MonoBehaviour:
7178-
m_ObjectHideFlags: 0
7179-
m_CorrespondingSourceObject: {fileID: 0}
7180-
m_PrefabInstance: {fileID: 0}
7181-
m_PrefabAsset: {fileID: 0}
7182-
m_GameObject: {fileID: 658956218}
7183-
m_Enabled: 1
7184-
m_EditorHideFlags: 0
7185-
m_Script: {fileID: 11500000, guid: e11d70c114204334694ef2f77f8c190e, type: 3}
7186-
m_Name:
7187-
m_EditorClassIdentifier:
7188-
duplicateAction: 2
7189-
persistAcrossScenes: 0
7190-
fullBright: 0
7191-
bypassCmpDithering: 1
7192-
simpleShader: {fileID: 4800000, guid: f3f7d7cc68ab0f1428144ca71de16cb9, type: 3}
7193-
transparentShader: {fileID: 0}
7194-
colorShader: {fileID: 4800000, guid: 43716613a537e694180e59ec894830f4, type: 3}
7195-
planeShader: {fileID: 4800000, guid: 1a45cdc7378c0514493891ded350127d, type: 3}
7196-
--- !u!114 &658956220
7197-
MonoBehaviour:
7198-
m_ObjectHideFlags: 0
7199-
m_CorrespondingSourceObject: {fileID: 0}
7200-
m_PrefabInstance: {fileID: 0}
7201-
m_PrefabAsset: {fileID: 0}
7202-
m_GameObject: {fileID: 658956218}
7203-
m_Enabled: 1
7204-
m_EditorHideFlags: 0
7205-
m_Script: {fileID: 11500000, guid: 9895b0db1478fc44da3c59dfca56da9d, type: 3}
7206-
m_Name:
7207-
m_EditorClassIdentifier:
7208-
duplicateAction: 2
7209-
persistAcrossScenes: 0
7210-
darkForcesFolder:
72117174
--- !u!4 &658956221
72127175
Transform:
72137176
m_ObjectHideFlags: 0

Assets/Dark Forces Showcase/Menu/Menu.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void ParseCommandLine() {
7979
HelpOrder = 100,
8080
ValueName = "TOOLNAME",
8181
PrependedGroupName = "Tools:",
82-
HelpDescription = "Jump to a specific tool on startup. Values: LevelExplorer, MapGenerator"
82+
HelpDescription = "Jump to a specific tool on startup. Values: LevelExplorer, MapGenerator, Randomizer"
8383
)]
8484
public string CommandLineTool { get; set; }
8585

@@ -196,6 +196,11 @@ private async void Start() {
196196
SceneName = "MapGenerator",
197197
Description = "Attempts to emulate the DF automap and various level editors to draw a top-down map view.\n\nClick and drag with the mouse to pan around the map. Use right click and move the mouse left and right to rotate. Use the scroll wheel to zoom. A menu bar on top can be used to adjust options or export a PNG of the map.\n\nThis tool could be used as the basis for an automap or level editor map component."
198198
},
199+
new Showcase() {
200+
Name = "Randomizer",
201+
SceneName = "Randomizer",
202+
Description = "Randomizers items and enemies within Dark Forces levels or mod levels. Also allows adjustment of other aspects such as colors, light levels, automap functionality, keys/code drops, and more."
203+
},
199204
new Showcase(),
200205
new Showcase() {
201206
Name = "Command Line Help",

Assets/Dark Forces Showcase/Mod Dialog/Mod File.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ MonoBehaviour:
762762
m_Options:
763763
- m_Text: DFBRIEF.LFD
764764
m_Image: {fileID: 0}
765-
- m_Text: FTEXTCRA.LDS
765+
- m_Text: FTEXTCRA.LFD
766766
m_Image: {fileID: 0}
767767
m_OnValueChanged:
768768
m_PersistentCalls:

Assets/Dark Forces Showcase/Mod Dialog/Mod.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace MZZT.DarkForces.Showcase {
77
public class Mod : Singleton<Mod> {
8+
// TODO Folder adding, help
9+
810
[SerializeField, Header("References")]
911
private GameObject background = null;
1012
[SerializeField]
@@ -34,7 +36,7 @@ public async void OnAddModClickedAsync() {
3436
SelectButtonText = "Add",
3537
SelectedFileMustExist = true,
3638
SelectedPathMustExist = true,
37-
StartPath = lastFolder != null ? lastFolder : FileLoader.Instance.DarkForcesFolder,
39+
StartPath = lastFolder ?? FileLoader.Instance.DarkForcesFolder,
3840
Title = "Select Mod File",
3941
ValidateFileName = true
4042
});

Assets/Dark Forces Showcase/PauseMenu.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ protected virtual void Start() {
2626
protected int loadingCount;
2727
public async Task BeginLoadingAsync() {
2828
if (this.loadingCount == 0) {
29-
this.MenuOpen = false;
29+
if (this.background != null) {
30+
this.MenuOpen = false;
31+
}
3032
this.IsInUI = true;
3133

3234
if (this.loading.sprite == null) {

Assets/Dark Forces Showcase/Randomizer.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using MZZT.DataBinding;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Reflection;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using UnityEngine;
9+
10+
namespace MZZT.DarkForces.Showcase {
11+
public class DataboundRandomRange : Databound<RandomRange> {
12+
[SerializeField]
13+
private string memberName;
14+
15+
private void Start() {
16+
IDataboundObject databound = this.GetComponentsInParent<IDataboundObject>(true).First(x => (object)x != this);
17+
databound.ValueChanged += this.Databound_ValueChanged;
18+
this.OnValueChanged();
19+
}
20+
21+
private void Databound_ValueChanged(object sender, EventArgs e) {
22+
this.OnValueChanged();
23+
}
24+
25+
private void OnValueChanged() {
26+
IDataboundObject databound = this.GetComponentsInParent<IDataboundObject>(true).First(x => (object)x != this);
27+
object value = databound.Value;
28+
if (value == null) {
29+
return;
30+
}
31+
32+
MemberInfo member = value.GetType().GetMember(this.memberName).First();
33+
34+
this.Value = (RandomRange)(member switch {
35+
FieldInfo field => field.GetValue(value),
36+
PropertyInfo property => property.GetValue(value),
37+
MethodInfo method => method.Invoke(value, Array.Empty<object>()),
38+
_ => throw new NotImplementedException()
39+
});
40+
}
41+
}
42+
}

Assets/Dark Forces Showcase/Randomizer/DataboundRandomRange.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)