Skip to content

Commit

Permalink
Added randomizer.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
The-MAZZTer committed Sep 26, 2021
1 parent fa5d37c commit dfc1a94
Show file tree
Hide file tree
Showing 127 changed files with 119,635 additions and 384 deletions.
4 changes: 3 additions & 1 deletion Assets/Dark Forces Showcase/LevelExplorer/LevelNameList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ private void Start() {
public void Refresh() {
this.Clear();
this.AddRange(Enumerable.Range(0, LevelLoader.Instance.LevelList.Levels.Count));
this.SelectedValue = LevelLoader.Instance.CurrentLevelIndex;
if (this.ToggleGroup != null) {
this.SelectedValue = LevelLoader.Instance.CurrentLevelIndex;
}
}
}
}
59 changes: 30 additions & 29 deletions Assets/Dark Forces Showcase/Loader.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1386.9952, y: -33.11}
m_AnchoredPosition: {x: 2747.5466, y: -33.11}
m_SizeDelta: {x: 46.01, y: 46.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &78064304
Expand Down Expand Up @@ -388,8 +388,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 749.12006, y: -33.109768}
m_SizeDelta: {x: 1321.7733, y: 46.219543}
m_AnchoredPosition: {x: 1429.3959, y: -33.109768}
m_SizeDelta: {x: 2682.3386, y: 46.219543}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &97872367
CanvasRenderer:
Expand Down Expand Up @@ -717,8 +717,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 965, y: -408.56024}
m_SizeDelta: {x: 910, y: 797.1205}
m_AnchoredPosition: {x: 1645.2759, y: -408.56024}
m_SizeDelta: {x: 2270.5518, y: 797.1205}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &251415155
CanvasRenderer:
Expand Down Expand Up @@ -845,8 +845,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 279.3567, y: -25.11}
m_SizeDelta: {x: 558.7134, y: 50.22}
m_AnchoredPosition: {x: 732.8739, y: -25.11}
m_SizeDelta: {x: 1465.7478, y: 50.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &297960939
CanvasRenderer:
Expand Down Expand Up @@ -969,8 +969,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 720, y: -976.6703}
m_SizeDelta: {x: 1420, y: 66.21954}
m_AnchoredPosition: {x: 1400.2759, y: -976.6703}
m_SizeDelta: {x: 2780.5518, y: 66.21954}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &304237836
MonoBehaviour:
Expand Down Expand Up @@ -1297,7 +1297,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 894.50006, y: -25.11}
m_AnchoredPosition: {x: 2255.0518, y: -25.11}
m_SizeDelta: {x: 31, y: 50.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &462446775
Expand Down Expand Up @@ -1883,7 +1883,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 265.5417, y: -25.11}
m_AnchoredPosition: {x: 719.0589, y: -25.11}
m_SizeDelta: {x: 69.49, y: 40.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &690603146
Expand Down Expand Up @@ -2575,7 +2575,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1223.855, y: -35.11}
m_AnchoredPosition: {x: 2584.4067, y: -35.11}
m_SizeDelta: {x: 132.19, y: 50.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &857775272
Expand Down Expand Up @@ -2869,8 +2869,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 766.0096, y: -33.11}
m_SizeDelta: {x: 1175.9604, y: 46.22}
m_AnchoredPosition: {x: 1446.2859, y: -33.11}
m_SizeDelta: {x: 2536.5117, y: 46.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &981356851
CanvasRenderer:
Expand Down Expand Up @@ -3068,8 +3068,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 720, y: -93.33}
m_SizeDelta: {x: 1420, y: 66.22}
m_AnchoredPosition: {x: 1400.2759, y: -93.33}
m_SizeDelta: {x: 2780.5518, y: 66.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1041850585
MonoBehaviour:
Expand Down Expand Up @@ -3386,10 +3386,10 @@ RectTransform:
m_Father: {fileID: 1513315606}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1440, y: 1080}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1160257300
CanvasRenderer:
Expand Down Expand Up @@ -3521,7 +3521,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1359.975, y: -35.11}
m_AnchoredPosition: {x: 2720.5266, y: -35.11}
m_SizeDelta: {x: 120.05, y: 50.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1312019593
Expand Down Expand Up @@ -4391,8 +4391,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 718.8567, y: -25.11}
m_SizeDelta: {x: 310.28668, y: 50.22}
m_AnchoredPosition: {x: 1852.6498, y: -25.11}
m_SizeDelta: {x: 763.8039, y: 50.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1517053113
CanvasRenderer:
Expand Down Expand Up @@ -4648,8 +4648,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 720, y: -535.00024}
m_SizeDelta: {x: 1420, y: 817.1205}
m_AnchoredPosition: {x: 1400.2759, y: -535.00024}
m_SizeDelta: {x: 2780.5518, y: 817.1205}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1561274080
MonoBehaviour:
Expand Down Expand Up @@ -5868,8 +5868,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 720, y: -35.11}
m_SizeDelta: {x: 1420, y: 50.22}
m_AnchoredPosition: {x: 1400.2759, y: -35.11}
m_SizeDelta: {x: 2780.5518, y: 50.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2051305892
MonoBehaviour:
Expand Down Expand Up @@ -5986,8 +5986,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 720, y: -1039.89}
m_SizeDelta: {x: 1420, y: 60.22}
m_AnchoredPosition: {x: 1400.2759, y: -1039.89}
m_SizeDelta: {x: 2780.5518, y: 60.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2119520865
CanvasRenderer:
Expand Down Expand Up @@ -9671,7 +9671,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 100
m_TargetDisplay: 0
Expand Down Expand Up @@ -11129,6 +11129,7 @@ MonoBehaviour:
collapsed: {fileID: 0}
expanded: {fileID: 0}
node: {fileID: 1450317669}
size: {fileID: 0}
--- !u!1 &7758479752323762614
GameObject:
m_ObjectHideFlags: 0
Expand Down
37 changes: 0 additions & 37 deletions Assets/Dark Forces Showcase/Map Generator/MapGenerator.unity
Original file line number Diff line number Diff line change
Expand Up @@ -7161,8 +7161,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 658956221}
- component: {fileID: 658956220}
- component: {fileID: 658956219}
- component: {fileID: 658956222}
- component: {fileID: 658956224}
- component: {fileID: 658956223}
Expand All @@ -7173,41 +7171,6 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &658956219
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 658956218}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e11d70c114204334694ef2f77f8c190e, type: 3}
m_Name:
m_EditorClassIdentifier:
duplicateAction: 2
persistAcrossScenes: 0
fullBright: 0
bypassCmpDithering: 1
simpleShader: {fileID: 4800000, guid: f3f7d7cc68ab0f1428144ca71de16cb9, type: 3}
transparentShader: {fileID: 0}
colorShader: {fileID: 4800000, guid: 43716613a537e694180e59ec894830f4, type: 3}
planeShader: {fileID: 4800000, guid: 1a45cdc7378c0514493891ded350127d, type: 3}
--- !u!114 &658956220
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 658956218}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9895b0db1478fc44da3c59dfca56da9d, type: 3}
m_Name:
m_EditorClassIdentifier:
duplicateAction: 2
persistAcrossScenes: 0
darkForcesFolder:
--- !u!4 &658956221
Transform:
m_ObjectHideFlags: 0
Expand Down
7 changes: 6 additions & 1 deletion Assets/Dark Forces Showcase/Menu/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void ParseCommandLine() {
HelpOrder = 100,
ValueName = "TOOLNAME",
PrependedGroupName = "Tools:",
HelpDescription = "Jump to a specific tool on startup. Values: LevelExplorer, MapGenerator"
HelpDescription = "Jump to a specific tool on startup. Values: LevelExplorer, MapGenerator, Randomizer"
)]
public string CommandLineTool { get; set; }

Expand Down Expand Up @@ -196,6 +196,11 @@ private async void Start() {
SceneName = "MapGenerator",
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."
},
new Showcase() {
Name = "Randomizer",
SceneName = "Randomizer",
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."
},
new Showcase(),
new Showcase() {
Name = "Command Line Help",
Expand Down
2 changes: 1 addition & 1 deletion Assets/Dark Forces Showcase/Mod Dialog/Mod File.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ MonoBehaviour:
m_Options:
- m_Text: DFBRIEF.LFD
m_Image: {fileID: 0}
- m_Text: FTEXTCRA.LDS
- m_Text: FTEXTCRA.LFD
m_Image: {fileID: 0}
m_OnValueChanged:
m_PersistentCalls:
Expand Down
4 changes: 3 additions & 1 deletion Assets/Dark Forces Showcase/Mod Dialog/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace MZZT.DarkForces.Showcase {
public class Mod : Singleton<Mod> {
// TODO Folder adding, help

[SerializeField, Header("References")]
private GameObject background = null;
[SerializeField]
Expand Down Expand Up @@ -34,7 +36,7 @@ public async void OnAddModClickedAsync() {
SelectButtonText = "Add",
SelectedFileMustExist = true,
SelectedPathMustExist = true,
StartPath = lastFolder != null ? lastFolder : FileLoader.Instance.DarkForcesFolder,
StartPath = lastFolder ?? FileLoader.Instance.DarkForcesFolder,
Title = "Select Mod File",
ValidateFileName = true
});
Expand Down
4 changes: 3 additions & 1 deletion Assets/Dark Forces Showcase/PauseMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ protected virtual void Start() {
protected int loadingCount;
public async Task BeginLoadingAsync() {
if (this.loadingCount == 0) {
this.MenuOpen = false;
if (this.background != null) {
this.MenuOpen = false;
}
this.IsInUI = true;

if (this.loading.sprite == null) {
Expand Down
8 changes: 8 additions & 0 deletions Assets/Dark Forces Showcase/Randomizer.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Assets/Dark Forces Showcase/Randomizer/DataboundRandomRange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using MZZT.DataBinding;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace MZZT.DarkForces.Showcase {
public class DataboundRandomRange : Databound<RandomRange> {
[SerializeField]
private string memberName;

private void Start() {
IDataboundObject databound = this.GetComponentsInParent<IDataboundObject>(true).First(x => (object)x != this);
databound.ValueChanged += this.Databound_ValueChanged;
this.OnValueChanged();
}

private void Databound_ValueChanged(object sender, EventArgs e) {
this.OnValueChanged();
}

private void OnValueChanged() {
IDataboundObject databound = this.GetComponentsInParent<IDataboundObject>(true).First(x => (object)x != this);
object value = databound.Value;
if (value == null) {
return;
}

MemberInfo member = value.GetType().GetMember(this.memberName).First();

this.Value = (RandomRange)(member switch {
FieldInfo field => field.GetValue(value),
PropertyInfo property => property.GetValue(value),
MethodInfo method => method.Invoke(value, Array.Empty<object>()),
_ => throw new NotImplementedException()
});
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MZZT.DataBinding;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MZZT.DarkForces.Showcase {
public class DataboundRandomizerColormapSettings : Databound<RandomizerColormapSettings> {
private void OnEnable() {
this.Value = Randomizer.Instance.Settings.Colormap;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dfc1a94

Please sign in to comment.