Skip to content
This repository was archived by the owner on Nov 29, 2020. It is now read-only.

Commit 5f2b2f7

Browse files
committed
1.9 adjustments
1 parent 4f19222 commit 5f2b2f7

File tree

8 files changed

+50
-107
lines changed

8 files changed

+50
-107
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#### 1.9.0pre1
1+
#### 1.9.0
22
* Added proper handling for inverted mod dependencies.
33
* Added theme support (light and dark theme available now).
44
* Removed autosaves from the save selection when creating a link.
55
* Fixed crash when adding Factorio from folder.
6+
* Fixed an issue that caused some mods to not be shown in the online list.
67
* Fixed bug that caused deactivated releases in the online mods window to be selected.
78

89
#### 1.8.6

ModMyFactory/ModMyFactory/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ModMyFactory
1818
{
1919
public partial class App : Application
2020
{
21-
private const int PreReleaseVersion = 2;
21+
private const int PreReleaseVersion = -1;
2222

2323
/// <summary>
2424
/// The current application instance.

ModMyFactory/ModMyFactory/ModSettings/ModSettingsManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public static bool TryGetSavedValue<T>(IHasModSettings mod, IModSetting<T> setti
9999

100100
public static bool HasSavedDataPresent(IHasModSettings mod)
101101
{
102+
if (modSettings == null) return false;
102103
return modSettings.ContainsKey(mod.UniqueID);
103104
}
104105

ModMyFactory/ModMyFactory/Models/Mod.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ private set
103103
dependenciesView.CustomSort = new ModDependencySorter();
104104
DependenciesView = dependenciesView;
105105

106-
var settings = file.GetSettings().Select(info => info.ToSetting(this)).ToList();
107-
Settings = new ReadOnlyCollection<IModSetting>(settings);
108-
source = new CollectionViewSource() { Source = Settings };
109-
var settingsView = (ListCollectionView)source.View;
110-
settingsView.CustomSort = new ModSettingSorter();
111-
settingsView.GroupDescriptions.Add(new PropertyGroupDescription("LoadTime"));
112-
SettingsView = settingsView;
106+
//var settings = file.GetSettings().Select(info => info.ToSetting(this)).ToList();
107+
//Settings = new ReadOnlyCollection<IModSetting>(settings);
108+
//source = new CollectionViewSource() { Source = Settings };
109+
//var settingsView = (ListCollectionView)source.View;
110+
//settingsView.CustomSort = new ModSettingSorter();
111+
//settingsView.GroupDescriptions.Add(new PropertyGroupDescription("LoadTime"));
112+
//SettingsView = settingsView;
113113

114114
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Version)));
115115
OnPropertyChanged(new PropertyChangedEventArgs(nameof(FactorioVersion)));
@@ -180,7 +180,7 @@ private set
180180
/// <summary>
181181
/// Indicates whether this mod has any settings.
182182
/// </summary>
183-
public bool HasSettings => Settings.Count > 0;
183+
public bool HasSettings => (Settings == null) ? false : (Settings.Count > 0);
184184

185185
/// <summary>
186186
/// Additional information about this mod to be displayed in a tooltip.
@@ -323,7 +323,7 @@ public void ViewSettings()
323323
settingsViewModel.SetMod(this);
324324
settingsWindow.ShowDialog();
325325

326-
ModSettingsManager.SaveSettings(this);
326+
//ModSettingsManager.SaveSettings(this);
327327
}
328328

329329
private bool KeepOldFile(ModFile newFile)

ModMyFactory/ModMyFactory/Models/ModFile.cs

Lines changed: 3 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using ModMyFactory.Helpers;
22
using ModMyFactory.ModSettings;
3-
using Newtonsoft.Json;
43
using System;
54
using System.Collections.Generic;
65
using System.Globalization;
@@ -160,93 +159,12 @@ private ModFile(FileSystemInfo file, InfoFile infoFile, bool isFile)
160159
InfoFile = infoFile;
161160
this.isFile = isFile;
162161
}
163-
164-
private static ModSettingInfo[] ParseSettingsFile(Stream stream)
165-
{
166-
string content = string.Empty;
167-
using (var reader = new StreamReader(stream))
168-
{
169-
while (!reader.EndOfStream)
170-
{
171-
string line = reader.ReadLine();
172-
if (!line.TrimStart().StartsWith("--")) content += line;
173-
}
174-
}
175-
176-
content = content.Trim();
177-
content = content.Substring(4).TrimStart(); // Remove 'data'
178-
content = content.Substring(1).TrimStart(); // Remove ':'
179-
content = content.Substring(6).TrimStart(); // Remove 'extend'
180-
if (content[0] == '(') content = content.Substring(1).TrimStart(); // Remove '(' if present
181-
if (content[content.Length - 1] == ')') content = content.Substring(0, content.Length - 1).TrimEnd(); // Remove ')' if present
182-
content = content.Substring(1, content.Length - 2).Trim(); // Remove outer {} brackets
183-
content = content.Replace('=', ':'); // Replace assignment char
184-
content = '[' + content + ']'; // Add array brackets
185-
186-
// ToDo: add support for 'require' statements
187-
188-
try
189-
{
190-
return JsonHelper.Deserialize<ModSettingInfo[]>(content);
191-
}
192-
catch (JsonReaderException)
193-
{
194-
return new ModSettingInfo[0];
195-
}
196-
}
197-
198-
private static bool TryLoadSettingsFromFile(FileInfo archiveFile, out ModSettingInfo[] settings)
199-
{
200-
using (var archive = ZipFile.OpenRead(archiveFile.FullName))
201-
{
202-
foreach (var entry in archive.Entries)
203-
{
204-
if ((entry.Name == "settings.lua") && (entry.FullName.Count(c => c == '/') == 1))
205-
{
206-
using (var stream = entry.Open())
207-
{
208-
settings = ParseSettingsFile(stream);
209-
return true;
210-
}
211-
}
212-
}
213-
}
214-
215-
settings = null;
216-
return false;
217-
}
218-
219-
private static bool TryLoadSettingsFromDirectory(DirectoryInfo directory, out ModSettingInfo[] settings)
220-
{
221-
var settingsFile = directory.EnumerateFiles("settings.lua").FirstOrDefault();
222-
if (settingsFile == null)
223-
{
224-
settings = null;
225-
return false;
226-
}
227-
228-
using (var stream = settingsFile.OpenRead())
229-
{
230-
settings = ParseSettingsFile(stream);
231-
return true;
232-
}
233-
}
234-
235-
private bool TryLoadSettings(out ModSettingInfo[] settings)
236-
{
237-
if (isFile)
238-
return TryLoadSettingsFromFile((FileInfo)file, out settings);
239-
else
240-
return TryLoadSettingsFromDirectory((DirectoryInfo)file, out settings);
241-
}
242-
162+
243163
public ModSettingInfo[] GetSettings()
244164
{
245-
if (settings != null) return settings;
246-
247-
if (!TryLoadSettings(out settings))
248-
settings = new ModSettingInfo[0];
165+
// ToDo: read settings using Lua interpreter
249166

167+
if (settings == null) settings = new ModSettingInfo[0];
250168
return settings;
251169
}
252170

ModMyFactory/ModMyFactory/Models/ModSettingsProxy.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,21 @@ public ModSettingsProxy(IHasModSettings baseMod, Modpack parent)
7878

7979
private void CreateView()
8080
{
81-
var list = baseMod.Settings.Select(setting => setting.CreateProxy()).ToList();
82-
settings = new ReadOnlyCollection<IModSettingProxy>(list);
83-
var source = new CollectionViewSource() { Source = settings };
84-
var settingsView = (ListCollectionView)source.View;
85-
settingsView.CustomSort = new ModSettingSorter();
86-
settingsView.GroupDescriptions.Add(new PropertyGroupDescription("LoadTime"));
87-
SettingsView = settingsView;
81+
if (HasSettings)
82+
{
83+
var list = baseMod.Settings.Select(setting => setting.CreateProxy()).ToList();
84+
settings = new ReadOnlyCollection<IModSettingProxy>(list);
85+
var source = new CollectionViewSource() { Source = settings };
86+
var settingsView = (ListCollectionView)source.View;
87+
settingsView.CustomSort = new ModSettingSorter();
88+
settingsView.GroupDescriptions.Add(new PropertyGroupDescription("LoadTime"));
89+
SettingsView = settingsView;
90+
}
91+
else
92+
{
93+
settings = null;
94+
SettingsView = null;
95+
}
8896

8997
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Settings)));
9098
OnPropertyChanged(new PropertyChangedEventArgs(nameof(SettingsView)));
@@ -96,6 +104,10 @@ private void PropertyChangedHandler(object sender, PropertyChangedEventArgs e)
96104
{
97105
CreateView();
98106
}
107+
else if (e.PropertyName == nameof(IHasModSettings.HasSettings))
108+
{
109+
OnPropertyChanged(new PropertyChangedEventArgs(nameof(HasSettings)));
110+
}
99111
}
100112

101113
public void ViewSettings()

ModMyFactory/ModMyFactory/Models/Modpack.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,18 @@ private set
218218
/// <summary>
219219
/// Indicates whether any mods in this modpack have settings;
220220
/// </summary>
221-
public bool HasSettings => ModProxies.Any(proxy => proxy.HasSettings);
221+
public bool HasSettings
222+
{
223+
get
224+
{
225+
foreach (var proxy in ModProxies)
226+
{
227+
if (proxy.HasSettings)
228+
return true;
229+
}
230+
return false;
231+
}
232+
}
222233

223234
public ICommand ViewSettingsCommand { get; }
224235

@@ -231,7 +242,7 @@ public void ViewSettings()
231242
settingsViewModel.SetMods(proxyList);
232243
settingsWindow.ShowDialog();
233244

234-
ModSettingsManager.SaveSettings(proxyList);
245+
//ModSettingsManager.SaveSettings(proxyList);
235246
}
236247

237248
/// <summary>

ModMyFactory/ModMyFactory/ViewModels/MainViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,9 @@ private void Refresh()
628628
{
629629
ModManager.LoadTemplates();
630630
LoadFactorioVersions();
631-
ModSettingsManager.LoadSettings();
631+
//ModSettingsManager.LoadSettings();
632632
LoadModsAndModpacks();
633-
ModSettingsManager.SaveSettings(Mods);
633+
//ModSettingsManager.SaveSettings(Mods);
634634
}
635635

636636
private bool ModsSelected() => Mods.Any(mod => mod.IsSelected);

0 commit comments

Comments
 (0)