├── .gitattributes ├── .gitignore ├── CHANGELOG.md ├── LICENSE-INI-Parser.md ├── LICENSE-Json.NET.md ├── LICENSE-MOONSHARP.md ├── LICENSE-Octokit.NET.md ├── LICENSE-Xdelta-sharp.md ├── LICENSE-ZLIB.md ├── LICENSE.md ├── ModMyFactory ├── ModMyFactory.sln ├── ModMyFactory │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── BooleanToStringJsonConverter.cs │ ├── Colors_dark.xaml │ ├── Colors_light.xaml │ ├── CommandLine.cs │ ├── Controls │ │ ├── DefaultExpandedExpander.cs │ │ ├── DragDropReadyListBox.cs │ │ ├── DragDropReadyListBoxItem.cs │ │ ├── ExtendedTextBox.cs │ │ ├── FormattingTextBlock.cs │ │ ├── InlineList.cs │ │ ├── LayoutRoundingWindow.cs │ │ ├── NumericUpDown.xaml │ │ └── NumericUpDown.xaml.cs │ ├── DirectoryOption.cs │ ├── Export │ │ ├── ExportMode.cs │ │ ├── ExportTemplate.cs │ │ ├── ModExportTemplate.cs │ │ ├── ModpackExport.cs │ │ └── ModpackExportTemplate.cs │ ├── ExtendedVersion.cs │ ├── FactorioCollection.cs │ ├── FactorioUpdate │ │ ├── CriticalUpdaterException.cs │ │ ├── FactorioUpdater.cs │ │ ├── FileUpdateAction.cs │ │ ├── FileUpdateInfo.cs │ │ ├── UpdatePackageInfo.cs │ │ └── UpdaterErrorType.cs │ ├── GameCompatibleVersion.cs │ ├── GameVersionConverter.cs │ ├── GlobalCredentials.cs │ ├── Helpers │ │ ├── CollectionExtensions.cs │ │ ├── DirectoryInfoExtensions.cs │ │ ├── EnumarableExtensions.cs │ │ ├── FileHelper.cs │ │ ├── FileInfoExtensions.cs │ │ ├── FileSystemInfoExtensions.cs │ │ ├── GitHubClientExtensions.cs │ │ ├── INIHelper.cs │ │ ├── JsonHelper.cs │ │ ├── ModHelper.cs │ │ ├── PercievedFileType.cs │ │ ├── ProcessExtensions.cs │ │ ├── RegistryHelper.cs │ │ ├── SecureStringHelper.cs │ │ ├── ShellHelper.cs │ │ ├── SteamHelper.cs │ │ ├── StreamExtensions.cs │ │ ├── StringExtensions.cs │ │ ├── StringHelper.cs │ │ ├── TaskHelper.cs │ │ └── WindowExtensions.cs │ ├── IO │ │ ├── Junction.cs │ │ └── JunctionInfo.cs │ ├── Images │ │ ├── Add.png │ │ ├── AddDocument.png │ │ ├── AddFolder.png │ │ ├── Close.png │ │ ├── Configure.png │ │ ├── Delete.png │ │ ├── Dependency.png │ │ ├── DependencyWarning.png │ │ ├── Document.png │ │ ├── Download.png │ │ ├── Downloads.png │ │ ├── Empty_Thumbnail.png │ │ ├── Experimental.png │ │ ├── ExportPackage.png │ │ ├── Factorio.png │ │ ├── Factorio_Icon.ico │ │ ├── Factorio_Modpack_Icon.ico │ │ ├── Folder.png │ │ ├── Help.png │ │ ├── ImportPackage.png │ │ ├── Information.png │ │ ├── Installed.png │ │ ├── Inverted_small.png │ │ ├── Lang │ │ │ ├── de.png │ │ │ ├── en.png │ │ │ ├── ko.png │ │ │ ├── pt.png │ │ │ ├── ru.png │ │ │ └── zh.png │ │ ├── Link.png │ │ ├── Lock.png │ │ ├── Lock_blue.png │ │ ├── MMF_Icon.ico │ │ ├── Menu.png │ │ ├── NewPackage.png │ │ ├── OpenFolder.png │ │ ├── Optional.png │ │ ├── Optional_small.png │ │ ├── Package.png │ │ ├── Refresh.png │ │ ├── Refresh_blue.png │ │ ├── RenameActive.png │ │ ├── RenameInactive.png │ │ ├── Run.png │ │ ├── Search.png │ │ ├── Settings.png │ │ ├── Settings_blue.png │ │ ├── Settings_gray.png │ │ ├── Themes.png │ │ ├── Themes │ │ │ ├── dark.png │ │ │ └── light.png │ │ ├── Update.png │ │ ├── Warning.png │ │ ├── WebDestination.png │ │ └── modmyfactory.png │ ├── InstanceStartedEventArgs.cs │ ├── Lang │ │ ├── CultureEntry.cs │ │ ├── Strings.de.xaml │ │ ├── Strings.en.xaml │ │ ├── Strings.ko.xaml │ │ ├── Strings.pt.xaml │ │ ├── Strings.ru.xaml │ │ └── Strings.zh.xaml │ ├── MVVM │ │ ├── Converters │ │ │ ├── AdvancedVisibilityConverter.cs │ │ │ ├── FactorioVersionConverter.cs │ │ │ ├── InverseBooleanConverter.cs │ │ │ ├── LoadTimeConverter.cs │ │ │ ├── LocalizedNameConverter.cs │ │ │ ├── ModInfoSorterModeConverter.cs │ │ │ ├── MultiplyConverter.cs │ │ │ ├── RemoveFileExtensionConverter.cs │ │ │ ├── SystemIconConverter.cs │ │ │ └── ThemeNameConverter.cs │ │ ├── MenuItemProperties.cs │ │ ├── Selectors │ │ │ ├── ComboBoxTemplateSelector.cs │ │ │ ├── ModSettingTemplateSelector.cs │ │ │ └── ModUpdateTemplateSelector.cs │ │ └── Sorters │ │ │ ├── CultureEntrySorter.cs │ │ │ ├── FactorioOnlineVersionSorter.cs │ │ │ ├── FactorioVersionSorter.cs │ │ │ ├── ModDependencySorter.cs │ │ │ ├── ModInfoSorter.cs │ │ │ ├── ModInfoSorterMode.cs │ │ │ ├── ModReferenceSorter.cs │ │ │ ├── ModReleaseSorter.cs │ │ │ ├── ModSettingSorter.cs │ │ │ ├── ModSorter.cs │ │ │ ├── ModUpdateInfoSorter.cs │ │ │ ├── ModpackSorter.cs │ │ │ └── UpdateTargetSorter.cs │ ├── ManagerMode.cs │ ├── MessageType.cs │ ├── ModCollection.cs │ ├── ModManager.cs │ ├── ModMyFactory.csproj │ ├── ModSettings │ │ ├── LoadTime.cs │ │ ├── LoadTimeJsonConverter.cs │ │ ├── ModSettingInfo.cs │ │ ├── ModSettingsManager.cs │ │ ├── Serialization │ │ │ ├── BinaryFile.cs │ │ │ ├── BinaryVersion.cs │ │ │ ├── ModSettingValueTemplate.cs │ │ │ └── ModSettingsExportTemplate.cs │ │ ├── SettingType.cs │ │ ├── SettingTypeExtensions.cs │ │ ├── SettingTypeJsonConverter.cs │ │ ├── SettingValue.cs │ │ ├── SettingValueArrayJsonConverter.cs │ │ └── SettingValueJsonConverter.cs │ ├── ModTemplateList.cs │ ├── Models │ │ ├── CopyOrMoveType.cs │ │ ├── FactorioFile.cs │ │ ├── FactorioFolder.cs │ │ ├── FactorioSteamVersion.cs │ │ ├── FactorioVersion.cs │ │ ├── IHasLocale.cs │ │ ├── IHasModSettings.cs │ │ ├── ILocale.cs │ │ ├── IModReference.cs │ │ ├── InfoFile.cs │ │ ├── LatestFactorioVersion.cs │ │ ├── LocaleType.cs │ │ ├── Mod.cs │ │ ├── ModDependency.cs │ │ ├── ModDependencyInfo.cs │ │ ├── ModFile.cs │ │ ├── ModFileCollection.cs │ │ ├── ModFile_ScriptLoaders.cs │ │ ├── ModLocale.cs │ │ ├── ModReference.cs │ │ ├── ModSettings │ │ │ ├── BooleanModSetting.cs │ │ │ ├── FloatingPointListModSetting.cs │ │ │ ├── FloatingPointModSetting.cs │ │ │ ├── ILimitedModSetting.cs │ │ │ ├── IListModSetting.cs │ │ │ ├── IModSetting.cs │ │ │ ├── IModSettingProxy.cs │ │ │ ├── IStringModSetting.cs │ │ │ ├── IntegerListModSetting.cs │ │ │ ├── IntegerModSetting.cs │ │ │ ├── LimitedModSetting.cs │ │ │ ├── LimitedModSettingProxy.cs │ │ │ ├── ListModSetting.cs │ │ │ ├── ListModSettingProxy.cs │ │ │ ├── ModSetting.cs │ │ │ ├── ModSettingProxy.cs │ │ │ ├── StringListModSetting.cs │ │ │ └── StringModSetting.cs │ │ ├── ModSettingsProxy.cs │ │ ├── ModTemplate.cs │ │ ├── ModUpdateInfo.cs │ │ ├── ModVersionUpdateInfo.cs │ │ ├── Mod_Adding.cs │ │ ├── Mod_Loading.cs │ │ ├── Modpack.cs │ │ ├── ModpackReference.cs │ │ ├── ModpackTemplate.cs │ │ ├── SettingsData.cs │ │ ├── SpecialFactorioVersion.cs │ │ ├── UpdateSearchResult.cs │ │ └── UpdateTarget.cs │ ├── ModpackCollection.cs │ ├── ModpackTemplateList.cs │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Resources │ │ └── updater.exe │ ├── Settings.cs │ ├── SingleOrArrayJsonConverter.cs │ ├── Theme.cs │ ├── TwoPartVersionConverter.cs │ ├── VersionComparer.cs │ ├── ViewModels │ │ ├── AboutPageViewModel.cs │ │ ├── AboutViewModel.cs │ │ ├── ChangelogPageViewModel.cs │ │ ├── CopyOrMoveViewModel.cs │ │ ├── DependencyDownloadViewModel.cs │ │ ├── LinkPropertiesViewModel.cs │ │ ├── MainViewModel.cs │ │ ├── MainViewModel_DependencyDownload.cs │ │ ├── MainViewModel_ModUpdate.cs │ │ ├── MainViewModel_ModpackExport.cs │ │ ├── MainViewModel_ModpackImport.cs │ │ ├── ModSettingsViewModel.cs │ │ ├── ModUpdateViewModel.cs │ │ ├── ModpackExportViewModel.cs │ │ ├── OnlineModsViewModel.cs │ │ ├── ProgressViewModel.cs │ │ ├── SettingsViewModel.cs │ │ ├── UpdateListViewModel.cs │ │ ├── VersionListViewModel.cs │ │ └── VersionManagementViewModel.cs │ ├── Views │ │ ├── AboutPage.xaml │ │ ├── AboutPage.xaml.cs │ │ ├── AboutWindow.xaml │ │ ├── AboutWindow.xaml.cs │ │ ├── ChangelogPage.xaml │ │ ├── ChangelogPage.xaml.cs │ │ ├── CopyOrMoveMessageWindow.xaml │ │ ├── CopyOrMoveMessageWindow.xaml.cs │ │ ├── DependencyDownloadWindow.xaml │ │ ├── DependencyDownloadWindow.xaml.cs │ │ ├── LinkPropertiesWindow.xaml │ │ ├── LinkPropertiesWindow.xaml.cs │ │ ├── LoginWindow.xaml │ │ ├── LoginWindow.xaml.cs │ │ ├── MainWindow.xaml │ │ ├── MainWindow.xaml.cs │ │ ├── ModSettingsWindow.xaml │ │ ├── ModSettingsWindow.xaml.cs │ │ ├── ModUpdateWindow.xaml │ │ ├── ModUpdateWindow.xaml.cs │ │ ├── ModpackExportWindow.xaml │ │ ├── ModpackExportWindow.xaml.cs │ │ ├── OnlineModsWindow.xaml │ │ ├── OnlineModsWindow.xaml.cs │ │ ├── ProgressWindow.xaml │ │ ├── ProgressWindow.xaml.cs │ │ ├── SettingsWindow.xaml │ │ ├── SettingsWindow.xaml.cs │ │ ├── UpdateListWindow.xaml │ │ ├── UpdateListWindow.xaml.cs │ │ ├── UpdateNotificationWindow.xaml │ │ ├── UpdateNotificationWindow.xaml.cs │ │ ├── VersionListWindow.xaml │ │ ├── VersionListWindow.xaml.cs │ │ ├── VersionManagementWindow.xaml │ │ └── VersionManagementWindow.xaml.cs │ ├── Web │ │ ├── ApiAuthentication.cs │ │ ├── AuthenticationApi │ │ │ └── AuthenticationInfo.cs │ │ ├── FactorioOnlineVersion.cs │ │ ├── FactorioWebsite.cs │ │ ├── ModApi │ │ │ ├── ApiPage.cs │ │ │ ├── ExtendedModInfo.cs │ │ │ ├── InfoFile.cs │ │ │ ├── LicenseInfo.cs │ │ │ ├── ModInfo.cs │ │ │ ├── ModRelease.cs │ │ │ ├── PageInfo.cs │ │ │ └── PageLinks.cs │ │ ├── ModWebsite.cs │ │ ├── UpdateApi │ │ │ ├── Package.cs │ │ │ ├── UpdateInfo.cs │ │ │ ├── UpdateInfoTemplate.cs │ │ │ ├── UpdateStep.cs │ │ │ └── UpdateStepTemplate.cs │ │ ├── UpdateWebsite.cs │ │ └── WebHelper.cs │ ├── Win32 │ │ ├── AdvApi32.cs │ │ ├── ChangeNotifyEventId.cs │ │ ├── ChangeNotifyFlags.cs │ │ ├── DeviceType.cs │ │ ├── FileAccessRights.cs │ │ ├── FileFlags.cs │ │ ├── GenericAccessRights.cs │ │ ├── IOControlCode.cs │ │ ├── IOMethod.cs │ │ ├── Kernel32.cs │ │ ├── Luid.cs │ │ ├── Privilege.cs │ │ ├── PrivilegeName.cs │ │ ├── Shell32.cs │ │ ├── StandardAccessRights.cs │ │ ├── TokenPrivileges.cs │ │ ├── User32.cs │ │ ├── WindowLongIndex.cs │ │ └── WindowStyles.cs │ ├── WindowInfo.cs │ ├── Xdelta │ │ └── xdelta.dll │ ├── Zlib │ │ ├── Crc32Checksum.cs │ │ ├── Crc32ChecksumGenerator.cs │ │ ├── zlib32.dll │ │ └── zlib64.dll │ ├── app.manifest │ └── packages.config └── Updater │ ├── App.config │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Updater.csproj │ └── app.manifest └── README.md /LICENSE-INI-Parser.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2008 Ricardo Amores Hernández 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE-Json.NET.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2007 James Newton-King 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LICENSE-MOONSHARP.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2016, Marco Mastropaolo 2 | All rights reserved. 3 | 4 | Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua) 5 | Copyright (c) 2012 LoDC 6 | 7 | Visual Studio Code debugger code is based on code from Microsoft vscode-mono-debug project (https://github.com/Microsoft/vscode-mono-debug). 8 | Copyright (c) Microsoft Corporation - released under MIT license. 9 | 10 | Remote Debugger icons are from the Eclipse project (https://www.eclipse.org/). 11 | Copyright of The Eclipse Foundation 12 | 13 | The MoonSharp icon is (c) Isaac, 2014-2015 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions are met: 17 | 18 | * Redistributions of source code must retain the above copyright notice, this 19 | list of conditions and the following disclaimer. 20 | 21 | * Redistributions in binary form must reproduce the above copyright notice, 22 | this list of conditions and the following disclaimer in the documentation 23 | and/or other materials provided with the distribution. 24 | 25 | * Neither the name of the {organization} nor the names of its 26 | contributors may be used to endorse or promote products derived from 27 | this software without specific prior written permission. 28 | 29 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 30 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 33 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 36 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /LICENSE-Octokit.NET.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 GitHub, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE-ZLIB.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | Jean-loup Gailly Mark Adler 20 | jloup@gzip.org madler@alumni.caltech.edu -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2019 Mathis Rech 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.25428.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModMyFactory", "ModMyFactory\ModMyFactory.csproj", "{216F1F9C-696E-4238-AA75-0DDDED89342C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.csproj", "{B7018FDD-C8E7-41AE-B84F-CCBA7ED61620}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {216F1F9C-696E-4238-AA75-0DDDED89342C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {216F1F9C-696E-4238-AA75-0DDDED89342C}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {216F1F9C-696E-4238-AA75-0DDDED89342C}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {216F1F9C-696E-4238-AA75-0DDDED89342C}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {B7018FDD-C8E7-41AE-B84F-CCBA7ED61620}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {B7018FDD-C8E7-41AE-B84F-CCBA7ED61620}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {B7018FDD-C8E7-41AE-B84F-CCBA7ED61620}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {B7018FDD-C8E7-41AE-B84F-CCBA7ED61620}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {9723E86A-9EFF-498A-A6F8-F5D4D6BBC5B3} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/BooleanToStringJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace ModMyFactory 6 | { 7 | sealed class BooleanToStringJsonConverter : JsonConverter 8 | { 9 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 10 | { 11 | JToken token = JToken.FromObject(((bool)value).ToString().ToLower()); 12 | token.WriteTo(writer); 13 | } 14 | 15 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 16 | { 17 | JToken token = JToken.Load(reader); 18 | string value = token.Value(); 19 | return bool.Parse(value); 20 | } 21 | 22 | public override bool CanConvert(Type objectType) 23 | { 24 | return objectType == typeof(bool); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Colors_dark.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | #2d2d30 5 | #242424 6 | #505050 7 | #636363 8 | #454545 9 | #007acc 10 | #ECECEC 11 | #B0B0B0 12 | LightSkyBlue 13 | #ee4650 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Colors_light.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | White 5 | White 6 | LightGray 7 | DarkGray 8 | #5087CEFA 9 | LightSkyBlue 10 | Black 11 | DimGray 12 | #007acc 13 | Red 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Controls/DefaultExpandedExpander.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace ModMyFactory.Controls 5 | { 6 | class DefaultExpandedExpander : Expander 7 | { 8 | static DefaultExpandedExpander() 9 | { 10 | IsExpandedProperty.OverrideMetadata(typeof(DefaultExpandedExpander), new FrameworkPropertyMetadata(true)); 11 | } 12 | 13 | public DefaultExpandedExpander() 14 | { 15 | IsExpanded = true; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Controls/DragDropReadyListBox.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace ModMyFactory.Controls 5 | { 6 | public class DragDropReadyListBox : ListBox 7 | { 8 | protected override DependencyObject GetContainerForItemOverride() 9 | { 10 | return new DragDropReadyListBoxItem(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Controls/DragDropReadyListBoxItem.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using System.Windows.Input; 3 | 4 | namespace ModMyFactory.Controls 5 | { 6 | public class DragDropReadyListBoxItem : ListBoxItem 7 | { 8 | protected override void OnMouseDown(MouseButtonEventArgs e) 9 | { 10 | if (IsSelected) 11 | e.Handled = true; 12 | else 13 | base.OnMouseDown(e); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Controls/InlineList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Collections.Specialized; 4 | using System.Windows.Controls; 5 | using System.Windows.Documents; 6 | 7 | namespace ModMyFactory.Controls 8 | { 9 | class InlineList : Control 10 | { 11 | private class InlineCollectionWrapper : ObservableCollection 12 | { } 13 | 14 | 15 | private object anchor; 16 | 17 | public ICollection Inlines { get; } 18 | 19 | public InlineList() 20 | { 21 | var inlines = new InlineCollectionWrapper(); 22 | inlines.CollectionChanged += OnInlineCollectionChanged; 23 | Inlines = inlines; 24 | } 25 | 26 | void OnInlineCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) 27 | { 28 | TextBlock textBlock = anchor as TextBlock; 29 | if (textBlock != null) 30 | { 31 | switch (e.Action) 32 | { 33 | case NotifyCollectionChangedAction.Add: 34 | textBlock.Inlines.AddRange(e.NewItems); 35 | break; 36 | case NotifyCollectionChangedAction.Remove: 37 | foreach (var item in e.OldItems) 38 | textBlock.Inlines.Remove((Inline)item); 39 | break; 40 | case NotifyCollectionChangedAction.Reset: 41 | if (e.NewItems != null) 42 | { 43 | textBlock.Inlines.AddRange(e.NewItems); 44 | } 45 | if (e.OldItems != null) 46 | { 47 | foreach (var item in e.OldItems) 48 | textBlock.Inlines.Remove((Inline)item); 49 | } 50 | break; 51 | } 52 | } 53 | } 54 | 55 | public override void OnApplyTemplate() 56 | { 57 | base.OnApplyTemplate(); 58 | 59 | anchor = Template?.FindName("PART_ContentHost", this); 60 | TextBlock textBlock = anchor as TextBlock; 61 | textBlock?.Inlines.AddRange(Inlines); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Controls/NumericUpDown.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 30 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/DirectoryOption.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory 2 | { 3 | enum DirectoryOption 4 | { 5 | AppData = 0, 6 | ApplicationDirectory = 1, 7 | Custom = 2, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Export/ExportMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.Export 4 | { 5 | [Flags] 6 | enum ExportMode 7 | { 8 | /// 9 | /// Value mask. 10 | /// 11 | Mask = 0x0000FFFF, 12 | 13 | /// 14 | /// The mod is included in the pack. 15 | /// 16 | Included = 0x00010000, 17 | 18 | /// 19 | /// Download a newer version if available even if the mod is included. 20 | /// 21 | DownloadNewer = 0x00020000, 22 | 23 | //------------------------------------------------------------------------------------------------ 24 | 25 | /// 26 | /// Use format version 1 handling. Deprecated. 27 | /// 28 | Version1 = 0, 29 | 30 | /// 31 | /// Download the newest available version. 32 | /// 33 | NewestVersion = 1, 34 | 35 | /// 36 | /// Download a specific version. 37 | /// 38 | SpecificVersion = 2, 39 | 40 | /// 41 | /// Download the latest available version that is compatible with a specific version of Factorio. 42 | /// 43 | FactorioVersion = 3, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Export/ExportTemplate.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Newtonsoft.Json; 3 | 4 | namespace ModMyFactory.Export 5 | { 6 | [JsonObject(MemberSerialization.OptOut)] 7 | sealed class ExportTemplate 8 | { 9 | //---------------------------------------------------- Deprecated ------------------------------------------------------------ 10 | 11 | [DefaultValue(false)] 12 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 13 | public bool IncludesVersionInfo { get; } 14 | 15 | public ExportTemplate(bool includesVersionInfo, ModExportTemplate[] mods, ModpackExportTemplate[] modpacks) 16 | : this(includesVersionInfo, mods, modpacks, 1) 17 | { } 18 | 19 | //---------------------------------------------------------------------------------------------------------------------------- 20 | 21 | 22 | 23 | 24 | [DefaultValue(1)] 25 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 26 | public int Version { get; } 27 | 28 | public ModExportTemplate[] Mods { get; } 29 | 30 | public ModpackExportTemplate[] Modpacks { get; } 31 | 32 | [JsonConstructor] 33 | private ExportTemplate(bool includesVersionInfo, ModExportTemplate[] mods, ModpackExportTemplate[] modpacks, int version) 34 | { 35 | IncludesVersionInfo = includesVersionInfo; 36 | Mods = mods; 37 | Modpacks = modpacks; 38 | Version = version; 39 | } 40 | 41 | public ExportTemplate(ModExportTemplate[] mods, ModpackExportTemplate[] modpacks) 42 | : this(false, mods, modpacks, 2) 43 | { } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/FactorioCollection.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Helpers; 2 | using ModMyFactory.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Collections.ObjectModel; 6 | using System.Linq; 7 | 8 | namespace ModMyFactory 9 | { 10 | sealed class FactorioCollection : ObservableCollection 11 | { 12 | public static FactorioCollection Load() 13 | { 14 | FactorioVersion.ResetUniqueNames(); 15 | 16 | var installedVersions = FactorioVersion.LoadInstalledVersions(); 17 | if (App.Instance.Settings.LoadSteamVersion) 18 | { 19 | if (FactorioSteamVersion.TryLoad(out var steamVersion)) 20 | { 21 | installedVersions.Add(steamVersion); 22 | } 23 | else 24 | { 25 | App.Instance.Settings.LoadSteamVersion = false; 26 | App.Instance.Settings.Save(); 27 | } 28 | } 29 | 30 | return new FactorioCollection(installedVersions); 31 | } 32 | 33 | public FactorioCollection() 34 | : base() 35 | { 36 | this.Add(new LatestFactorioVersion(this)); 37 | } 38 | 39 | public FactorioCollection(IEnumerable collection) 40 | : base(collection) 41 | { 42 | this.Add(new LatestFactorioVersion(this)); 43 | } 44 | 45 | public FactorioCollection(List list) 46 | : base(list) 47 | { 48 | this.Add(new LatestFactorioVersion(this)); 49 | } 50 | 51 | public bool Contains(string name) 52 | { 53 | return this.Any(item => item.Name == name); 54 | } 55 | 56 | public FactorioVersion Find(string name) 57 | { 58 | return this.FirstOrDefault(item => item.Name == name); 59 | } 60 | 61 | public FactorioVersion Find(Version version, bool exact = true) 62 | { 63 | if (exact) 64 | { 65 | return this.FirstOrDefault(item => item.Version == version); 66 | } 67 | else 68 | { 69 | return this.Where(item => (item.Version.Major == version.Major) && (item.Version.Minor == version.Minor)) 70 | .MaxBy(item => item.Version, new VersionComparer()); 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/FactorioUpdate/CriticalUpdaterException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.FactorioUpdate 4 | { 5 | /// 6 | /// This exception is thrown if the Factorio updater encounters a critical error. 7 | /// 8 | class CriticalUpdaterException : Exception 9 | { 10 | /// 11 | /// The type of error the updater encountered. 12 | /// 13 | public UpdaterErrorType ErrorType { get; } 14 | 15 | public CriticalUpdaterException(UpdaterErrorType errorType, Exception innerException) 16 | : base("The updater encountered a critical error.", innerException) 17 | { 18 | ErrorType = errorType; 19 | } 20 | 21 | public CriticalUpdaterException(UpdaterErrorType errorType) 22 | : this(errorType, null) 23 | { } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/FactorioUpdate/FileUpdateAction.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory 2 | { 3 | enum FileUpdateAction 4 | { 5 | Added, 6 | Removed, 7 | Differs, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/FactorioUpdate/FileUpdateInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Converters; 3 | 4 | namespace ModMyFactory.FactorioUpdate 5 | { 6 | [JsonObject(MemberSerialization.OptOut)] 7 | sealed class FileUpdateInfo 8 | { 9 | [JsonProperty("file")] 10 | public string Path { get; } 11 | 12 | [JsonProperty("action"), JsonConverter(typeof(StringEnumConverter), true)] 13 | public FileUpdateAction Action { get; } 14 | 15 | [JsonProperty("old_crc")] 16 | public uint OldCrc { get; } 17 | 18 | [JsonProperty("crc")] 19 | public uint NewCrc { get; } 20 | 21 | [JsonConstructor] 22 | public FileUpdateInfo(string path, FileUpdateAction action, uint oldCrc, uint newCrc) 23 | { 24 | Path = path; 25 | Action = action; 26 | OldCrc = oldCrc; 27 | NewCrc = newCrc; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/FactorioUpdate/UpdatePackageInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.FactorioUpdate 4 | { 5 | [JsonObject(MemberSerialization.OptIn)] 6 | sealed class UpdatePackageInfo 7 | { 8 | [JsonProperty("type")] 9 | public string Type { get; } 10 | 11 | [JsonProperty("apiVersion")] 12 | public int ApiVersion { get; } 13 | 14 | [JsonProperty("files")] 15 | public FileUpdateInfo[] UpdatedFiles { get; } 16 | 17 | public string PackageDirectory { get; set; } 18 | 19 | [JsonConstructor] 20 | public UpdatePackageInfo(string type, int apiVersion, FileUpdateInfo[] updatedFiles) 21 | { 22 | Type = type; 23 | ApiVersion = apiVersion; 24 | UpdatedFiles = updatedFiles; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/FactorioUpdate/UpdaterErrorType.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.FactorioUpdate 2 | { 3 | /// 4 | /// Specifies the type of error the Factorio updater encounters. 5 | /// 6 | enum UpdaterErrorType 7 | { 8 | /// 9 | /// The provided archive is not a valid update package. 10 | /// 11 | PackageInvalid, 12 | 13 | /// 14 | /// The updater could not find a file specified in the update package. 15 | /// 16 | FileNotFound, 17 | 18 | /// 19 | /// A file has a different CRC32 checksum than provided by the update package. 20 | /// 21 | ChecksumMismatch, 22 | 23 | /// 24 | /// The resulting Factorio installation is corrupt. 25 | /// 26 | InstallationCorrupt, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/GameVersionConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | 5 | namespace ModMyFactory 6 | { 7 | class GameVersionConverter : JsonConverter 8 | { 9 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 10 | { 11 | JToken token = JToken.FromObject(((GameCompatibleVersion)value).ToString().ToLower()); 12 | token.WriteTo(writer); 13 | } 14 | 15 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 16 | { 17 | JToken token = JToken.Load(reader); 18 | string value = token.Value(); 19 | return GameCompatibleVersion.Parse(value); 20 | } 21 | 22 | public override bool CanConvert(Type objectType) 23 | { 24 | return objectType == typeof(GameCompatibleVersion); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace ModMyFactory.Helpers 5 | { 6 | static class CollectionExtensions 7 | { 8 | public static void ForEach(this ICollection source, Action body) 9 | { 10 | foreach (T item in source) 11 | { 12 | body.Invoke(item); 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ModMyFactory.Helpers 4 | { 5 | static class FileHelper 6 | { 7 | /// 8 | /// Determines if a given path is pointing to a directory. 9 | /// 10 | /// The path to check. 11 | /// Return true if the given path is pointing to a directory, returns false if it is pointing to a file. 12 | public static bool IsDirectory(string path) 13 | { 14 | var attributes = File.GetAttributes(path); 15 | return attributes.HasFlag(FileAttributes.Directory); 16 | } 17 | 18 | /// 19 | /// Creates a FileSystemInfo object from a given path. 20 | /// If the path is pointing to a directory a DirectoryInfo object is created, if it is pointing to a file a FileInfo object is created. 21 | /// 22 | /// The path of the file system object to create. 23 | /// Returns a FIleSystemInfo object that was created from the given path. 24 | public static FileSystemInfo CreateFileOrDirectory(string path) 25 | { 26 | if (IsDirectory(path)) 27 | return new DirectoryInfo(path); 28 | else 29 | return new FileInfo(path); 30 | } 31 | 32 | /// 33 | /// Checks if a path exists. 34 | /// 35 | public static bool PathExists(string path) 36 | { 37 | if (File.Exists(path)) return true; 38 | if (Directory.Exists(path)) return true; 39 | return false; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/FileInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Threading.Tasks; 3 | using ModMyFactory.Zlib; 4 | 5 | namespace ModMyFactory.Helpers 6 | { 7 | static class FileInfoExtensions 8 | { 9 | /// 10 | /// Gets the name of the file without the extension. 11 | /// 12 | public static string NameWithoutExtension(this FileInfo file) 13 | { 14 | return Path.GetFileNameWithoutExtension(file.Name); 15 | } 16 | 17 | /// 18 | /// Calculates the CRC checksum of the file. 19 | /// 20 | public static uint CalculateCrc(this FileInfo file) 21 | { 22 | using (var stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None)) 23 | { 24 | return Crc32Checksum.Generate(stream); 25 | } 26 | } 27 | 28 | /// 29 | /// Moves the file to a new location. 30 | /// 31 | public static async Task MoveToAsync(this FileInfo file, string destination) 32 | { 33 | await Task.Run(() => file.MoveTo(destination)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/GitHubClientExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | using Octokit; 4 | 5 | namespace ModMyFactory.Helpers 6 | { 7 | static class GitHubClientExtensions 8 | { 9 | public static async Task GetPreReleaseAsync(this GitHubClient client, string owner, string name) 10 | { 11 | var releases = await client.Repository.Release.GetAll(owner, name); 12 | return releases.Where(release => release.Prerelease).MaxBy(release => new ExtendedVersion(release.TagName)); 13 | } 14 | 15 | public static async Task GetLatestReleaseAsync(this GitHubClient client, string owner, string name, bool includePreReleases) 16 | { 17 | var latest = await client.Repository.Release.GetLatest(owner, name); 18 | if (!includePreReleases) return latest; 19 | 20 | var latestPre = await GetPreReleaseAsync(client, owner, name); 21 | return new ExtendedVersion(latestPre.TagName) > new ExtendedVersion(latest.TagName) ? latestPre : latest; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/INIHelper.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using IniParser; 3 | using IniParser.Model; 4 | 5 | namespace ModMyFactory.Helpers 6 | { 7 | static class INIHelper 8 | { 9 | public static IniData ReadINI(string content) 10 | { 11 | #pragma warning disable CS0618 12 | var parser = new StringIniParser(); 13 | #pragma warning restore CS0618 14 | return parser.ParseString(content); 15 | } 16 | 17 | public static IniData ReadINI(Stream stream) 18 | { 19 | using (var reader = new StreamReader(stream)) 20 | { 21 | var parser = new StreamIniDataParser(); 22 | return parser.ReadData(reader); 23 | } 24 | } 25 | 26 | public static IniData ReadINI(FileInfo file) 27 | { 28 | var parser = new FileIniDataParser(); 29 | return parser.ReadFile(file.FullName); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/JsonHelper.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Newtonsoft.Json; 3 | 4 | namespace ModMyFactory.Helpers 5 | { 6 | static class JsonHelper 7 | { 8 | private static readonly JsonSerializerSettings DefaultSettings; 9 | 10 | static JsonHelper() 11 | { 12 | DefaultSettings = new JsonSerializerSettings() 13 | { 14 | DefaultValueHandling = DefaultValueHandling.Include, 15 | DateFormatHandling = DateFormatHandling.IsoDateFormat, 16 | DateParseHandling = DateParseHandling.DateTime, 17 | DateTimeZoneHandling = DateTimeZoneHandling.Utc 18 | }; 19 | } 20 | 21 | public static void Serialize(T value, FileInfo file) 22 | { 23 | using (var writer = file.CreateText()) 24 | { 25 | string json = JsonConvert.SerializeObject(value, Formatting.Indented, DefaultSettings); 26 | writer.Write(json); 27 | } 28 | } 29 | 30 | public static string Serialize(T value) 31 | { 32 | return JsonConvert.SerializeObject(value, Formatting.Indented, DefaultSettings); 33 | } 34 | 35 | public static T Deserialize(FileInfo file) 36 | { 37 | using (var reader = file.OpenText()) 38 | { 39 | string json = reader.ReadToEnd(); 40 | return JsonConvert.DeserializeObject(json, DefaultSettings); 41 | } 42 | } 43 | 44 | public static T Deserialize(string json) 45 | { 46 | return JsonConvert.DeserializeObject(json, DefaultSettings); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/ModHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using System.Windows; 4 | using ModMyFactory.ViewModels; 5 | using ModMyFactory.Views; 6 | using ModMyFactory.Web; 7 | using ModMyFactory.Web.ModApi; 8 | 9 | namespace ModMyFactory.Helpers 10 | { 11 | static class ModHelper 12 | { 13 | public static async Task> FetchMods(Window progressOwner, ModCollection installedMods) 14 | { 15 | var progressWindow = new ProgressWindow() { Owner = progressOwner }; 16 | var progressViewModel = (ProgressViewModel)progressWindow.ViewModel; 17 | progressViewModel.ActionName = App.Instance.GetLocalizedResourceString("FetchingModsAction"); 18 | progressViewModel.CanCancel = false; 19 | progressViewModel.IsIndeterminate = true; 20 | 21 | Task> fetchModsTask = ModWebsite.GetModsAsync(installedMods); 22 | 23 | Task closeWindowTask = fetchModsTask.ContinueWith(t => progressWindow.Dispatcher.Invoke(progressWindow.Close)); 24 | progressWindow.ShowDialog(); 25 | 26 | List modInfos = await fetchModsTask; 27 | await closeWindowTask; 28 | 29 | return modInfos; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/PercievedFileType.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Helpers 2 | { 3 | enum PercievedFileType 4 | { 5 | None, 6 | Folder, 7 | Text, 8 | Image, 9 | Audio, 10 | Video, 11 | Compressed, 12 | Document, 13 | System, 14 | Application, 15 | Gamemedia, 16 | Contacts, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/ProcessExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading.Tasks; 4 | 5 | namespace ModMyFactory.Helpers 6 | { 7 | static class ProcessExtensions 8 | { 9 | public static Task WaitForExitAsync(this Process process) 10 | { 11 | process.EnableRaisingEvents = true; 12 | 13 | var completionSource = new TaskCompletionSource(); 14 | 15 | EventHandler handler = null; 16 | handler = (sender, e) => 17 | { 18 | process.Exited -= handler; 19 | completionSource.TrySetResult(null); 20 | }; 21 | process.Exited += handler; 22 | 23 | return completionSource.Task; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/ShellHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace ModMyFactory.Helpers 5 | { 6 | static class ShellHelper 7 | { 8 | /// 9 | /// Creates a shortcut. 10 | /// 11 | /// The path to the shortcut. 12 | /// The shortcuts target. 13 | /// The shortcuts arguments. 14 | /// The shortcuts icon. 15 | public static void CreateShortcut(string filePath, string target, string arguments, string iconLocation) 16 | { 17 | // Create the windows script host shell object. 18 | Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); 19 | dynamic shell = Activator.CreateInstance(t); 20 | 21 | try 22 | { 23 | dynamic shortcut = shell.CreateShortcut(filePath); 24 | 25 | try 26 | { 27 | shortcut.TargetPath = target; 28 | shortcut.Arguments = arguments; 29 | shortcut.IconLocation = iconLocation; 30 | shortcut.Save(); 31 | } 32 | finally 33 | { 34 | Marshal.FinalReleaseComObject(shortcut); 35 | } 36 | } 37 | finally 38 | { 39 | Marshal.FinalReleaseComObject(shell); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings.Serialization; 2 | using System.IO; 3 | 4 | namespace ModMyFactory.Helpers 5 | { 6 | static class StreamExtensions 7 | { 8 | public static BinaryVersion ReadBinaryVersion(this BinaryReader reader) 9 | { 10 | ushort main = reader.ReadUInt16(); 11 | ushort major = reader.ReadUInt16(); 12 | ushort minor = reader.ReadUInt16(); 13 | ushort revision = reader.ReadUInt16(); 14 | return new BinaryVersion(main, major, minor, revision); 15 | } 16 | 17 | public static void Write(this BinaryWriter writer, BinaryVersion version) 18 | { 19 | writer.Write(version.Main); 20 | writer.Write(version.Major); 21 | writer.Write(version.Minor); 22 | writer.Write(version.Revision); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/TaskHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace ModMyFactory.Helpers 4 | { 5 | static class TaskHelper 6 | { 7 | private static readonly Task[] emptyTaskArray = new Task[0]; 8 | 9 | /// 10 | /// Returns a task object that is immediately completed. 11 | /// 12 | // Task.CompletedTask exists in .Net 4.6 but in 4.5.2 it is an internal member. Calling WhenAll with an empty array will return the internal CompletedTask object however. 13 | public static Task CompletedTask => Task.WhenAll(emptyTaskArray); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Helpers/WindowExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Interop; 4 | 5 | namespace ModMyFactory.Helpers 6 | { 7 | static class WindowExtensions 8 | { 9 | public static IntPtr Handle(this Window window) 10 | { 11 | return new WindowInteropHelper(window).Handle; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/IO/JunctionInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace ModMyFactory.IO 5 | { 6 | sealed class JunctionInfo 7 | { 8 | public string Name { get; } 9 | 10 | public string FullName { get; } 11 | 12 | public string DestinationPath { get; private set; } 13 | 14 | public bool Exists => Junction.Exists(FullName); 15 | 16 | public JunctionInfo(string path) 17 | { 18 | if (string.IsNullOrEmpty(path)) 19 | throw new ArgumentNullException(nameof(path)); 20 | 21 | FullName = Path.GetFullPath(path); 22 | Name = Path.GetFileName(FullName.TrimEnd(Path.DirectorySeparatorChar)); 23 | 24 | if (Exists) 25 | { 26 | DestinationPath = Junction.GetDestination(FullName); 27 | } 28 | } 29 | 30 | public void Create(string destinationPath) 31 | { 32 | Junction.Create(FullName, destinationPath); 33 | DestinationPath = destinationPath; 34 | } 35 | 36 | public void SetDestination(string destinationPath) 37 | { 38 | Junction.SetDestination(FullName, destinationPath); 39 | DestinationPath = Path.GetFullPath(destinationPath); 40 | } 41 | 42 | public void Delete() 43 | { 44 | Junction.Delete(FullName); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Add.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/AddDocument.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/AddDocument.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/AddFolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/AddFolder.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Close.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Configure.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Delete.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Dependency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Dependency.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/DependencyWarning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/DependencyWarning.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Document.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Document.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Download.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Downloads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Downloads.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Empty_Thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Empty_Thumbnail.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Experimental.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Experimental.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/ExportPackage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/ExportPackage.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Factorio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Factorio.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Factorio_Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Factorio_Icon.ico -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Factorio_Modpack_Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Factorio_Modpack_Icon.ico -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Folder.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Help.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/ImportPackage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/ImportPackage.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Information.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Installed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Installed.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Inverted_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Inverted_small.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lang/de.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lang/de.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lang/en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lang/en.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lang/ko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lang/ko.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lang/pt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lang/pt.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lang/ru.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lang/ru.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lang/zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lang/zh.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Link.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lock.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Lock_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Lock_blue.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/MMF_Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/MMF_Icon.ico -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Menu.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/NewPackage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/NewPackage.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/OpenFolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/OpenFolder.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Optional.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Optional.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Optional_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Optional_small.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Package.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Refresh.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Refresh_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Refresh_blue.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/RenameActive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/RenameActive.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/RenameInactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/RenameInactive.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Run.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Search.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Settings.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Settings_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Settings_blue.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Settings_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Settings_gray.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Themes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Themes.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Themes/dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Themes/dark.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Themes/light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Themes/light.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Update.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/Warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/Warning.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/WebDestination.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/WebDestination.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Images/modmyfactory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Images/modmyfactory.png -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/InstanceStartedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory 4 | { 5 | class InstanceStartedEventArgs : EventArgs 6 | { 7 | /// 8 | /// The command line of the started instance. 9 | /// 10 | public CommandLine CommandLine { get; } 11 | 12 | public bool GameStarted { get; } 13 | 14 | public InstanceStartedEventArgs(CommandLine commandLine, bool gameStarted) 15 | { 16 | CommandLine = commandLine; 17 | GameStarted = gameStarted; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/AdvancedVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace ModMyFactory.MVVM.Converters 7 | { 8 | sealed class AdvancedVisibilityConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | bool bVal = (bool)value; 13 | 14 | if ((parameter != null) && (parameter is bool)) 15 | { 16 | bool bParam = (bool)parameter; 17 | if (bParam) bVal = !bVal; 18 | } 19 | 20 | return bVal ? Visibility.Visible : Visibility.Hidden; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/FactorioVersionConverter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ViewModels; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace ModMyFactory.MVVM.Converters 7 | { 8 | [ValueConversion(typeof(Version), typeof(string))] 9 | sealed class FactorioVersionConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var version = value as Version; 14 | if (version == null) throw new ArgumentException("Value has to be of type Version.", nameof(value)); 15 | 16 | if (version == OnlineModsViewModel.EmptyVersion) 17 | return App.Instance.GetLocalizedResourceString("EmptyVersionFormat"); 18 | 19 | return $"Factorio {version.ToString(2)}"; 20 | } 21 | 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | throw new NotSupportedException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace ModMyFactory.MVVM.Converters 6 | { 7 | [ValueConversion(typeof(bool), typeof(bool))] 8 | public class InverseBooleanConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | return !(bool)value; 13 | } 14 | 15 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | return !(bool)value; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/LoadTimeConverter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace ModMyFactory.MVVM.Converters 7 | { 8 | [ValueConversion(typeof(LoadTime), typeof(string))] 9 | class LoadTimeConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (!(value is LoadTime)) throw new ArgumentException("Value has to be of type LoadTime.", nameof(value)); 14 | var sortingMode = (LoadTime)value; 15 | 16 | return App.Instance.GetLocalizedResourceString(sortingMode.ToString() + "LoadTime"); 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotSupportedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/LocalizedNameConverter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace ModMyFactory.MVVM.Converters 7 | { 8 | class LocalizedNameConverter : IMultiValueConverter 9 | { 10 | public LocaleType LocaleType { get; set; } 11 | 12 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | var key = (string)values[0]; 15 | var localeSource = (IHasLocale)values[1]; 16 | return localeSource.GetLocale(CultureInfo.CurrentUICulture).GetValue(key, LocaleType); 17 | } 18 | 19 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 20 | { 21 | throw new NotSupportedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/ModInfoSorterModeConverter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.MVVM.Sorters; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace ModMyFactory.MVVM.Converters 7 | { 8 | [ValueConversion(typeof(ModInfoSorterMode), typeof(string))] 9 | class ModInfoSorterModeConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (!(value is ModInfoSorterMode)) throw new ArgumentException("Value has to be of type ModInfoSorterMode.", nameof(value)); 14 | var sortingMode = (ModInfoSorterMode)value; 15 | 16 | return App.Instance.GetLocalizedResourceString(sortingMode.ToString() + "SortingMode"); 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotSupportedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/MultiplyConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace ModMyFactory.MVVM.Converters 6 | { 7 | /// 8 | /// Multiplies two or more numeric values in a multi binding. 9 | /// 10 | public class MultiplyConverter : IMultiValueConverter 11 | { 12 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | double result = 1.0; 15 | foreach (var value in values) 16 | result *= (double)value; 17 | return result; 18 | } 19 | 20 | public object[] ConvertBack(object value, Type[] targetTypes,object parameter, CultureInfo culture) 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/RemoveFileExtensionConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.IO; 4 | using System.Windows.Data; 5 | 6 | namespace ModMyFactory.MVVM.Converters 7 | { 8 | [ValueConversion(typeof(string), typeof(string))] 9 | public class RemoveFileExtensionConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | string name = (string)value; 14 | return Path.GetFileNameWithoutExtension(name); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotSupportedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/SystemIconConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Globalization; 4 | using System.Reflection; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | using System.Windows.Interop; 8 | using System.Windows.Media.Imaging; 9 | 10 | namespace ModMyFactory.MVVM.Converters 11 | { 12 | [ValueConversion(typeof(string), typeof(BitmapSource))] 13 | public class SystemIconConverter : IValueConverter 14 | { 15 | public object Convert(object value, Type type, object parameter, CultureInfo culture) 16 | { 17 | Icon icon = (Icon)typeof(SystemIcons).GetProperty(parameter.ToString(), BindingFlags.Public | BindingFlags.Static).GetValue(null, null); 18 | BitmapSource bs = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); 19 | return bs; 20 | } 21 | 22 | public object ConvertBack(object value, Type type, object parameter, CultureInfo culture) 23 | { 24 | throw new NotSupportedException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Converters/ThemeNameConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace ModMyFactory.MVVM.Converters 6 | { 7 | [ValueConversion(typeof(string), typeof(string))] 8 | class ThemeNameConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | string themeName = (string)value; 13 | return App.Instance.GetLocalizedResourceString($"__theme__{themeName}"); 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | throw new NotSupportedException(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/MenuItemProperties.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace ModMyFactory.MVVM 5 | { 6 | static class MenuItemProperties 7 | { 8 | public static readonly DependencyProperty ShowCheckedProperty = 9 | DependencyProperty.RegisterAttached("ShowChecked", typeof(bool), typeof(MenuItemProperties), new PropertyMetadata(false)); 10 | 11 | public static bool GetShowChecked(MenuItem item) 12 | { 13 | return (bool)item.GetValue(ShowCheckedProperty); 14 | } 15 | 16 | public static void SetShowChecked(MenuItem item, bool value) 17 | { 18 | item.SetValue(ShowCheckedProperty, value); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Selectors/ComboBoxTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Media; 4 | 5 | namespace ModMyFactory.MVVM.Selectors 6 | { 7 | class ComboBoxTemplateSelector : DataTemplateSelector 8 | { 9 | public DataTemplate SelectedItemTemplate { get; set; } 10 | public DataTemplate ListItemTemplate { get; set; } 11 | 12 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 13 | { 14 | var parent = container; 15 | while (parent != null && !(parent is ComboBoxItem) && !(parent is ComboBox)) 16 | parent = VisualTreeHelper.GetParent(parent); 17 | 18 | var inDropDown = parent is ComboBoxItem; 19 | return inDropDown ? ListItemTemplate : SelectedItemTemplate; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Selectors/ModSettingTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models.ModSettings; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace ModMyFactory.MVVM.Selectors 6 | { 7 | sealed class ModSettingTemplateSelector : DataTemplateSelector 8 | { 9 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 10 | { 11 | var setting = item as IModSetting; 12 | if (setting != null) return setting.Template; 13 | 14 | return base.SelectTemplate(item, container); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Selectors/ModUpdateTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace ModMyFactory.MVVM.Selectors 6 | { 7 | class ModUpdateTemplateSelector : DataTemplateSelector 8 | { 9 | public DataTemplate EmptyItemTemplate { get; set; } 10 | public DataTemplate FilledItemTemplate { get; set; } 11 | 12 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 13 | { 14 | var updateTemplate = item as ModUpdateInfo; 15 | if ((updateTemplate != null) && (updateTemplate.ModVersions.Count > 0)) return FilledItemTemplate; 16 | return EmptyItemTemplate; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/CultureEntrySorter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using ModMyFactory.Lang; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class CultureEntrySorter : IComparer, IComparer 9 | { 10 | public int Compare(CultureEntry x, CultureEntry y) 11 | { 12 | return string.Compare(x.EnglishName, y.EnglishName, StringComparison.InvariantCultureIgnoreCase); 13 | } 14 | 15 | public int Compare(object x, object y) 16 | { 17 | if (!(x is CultureEntry) || !(y is CultureEntry)) 18 | throw new ArgumentException("Parameters need to be of type CultureEntry."); 19 | 20 | return Compare((CultureEntry)x, (CultureEntry)y); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/FactorioOnlineVersionSorter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using ModMyFactory.Web; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class FactorioOnlineVersionSorter : IComparer, IComparer 9 | { 10 | public int Compare(FactorioOnlineVersion x, FactorioOnlineVersion y) 11 | { 12 | return y.Version.CompareTo(x.Version); 13 | } 14 | 15 | public int Compare(object x, object y) 16 | { 17 | if (!(x is FactorioOnlineVersion) || !(y is FactorioOnlineVersion)) 18 | throw new ArgumentException("Parameters need to be of type FactorioVersion."); 19 | 20 | return Compare((FactorioOnlineVersion)x, (FactorioOnlineVersion)y); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/FactorioVersionSorter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class FactorioVersionSorter : IComparer, IComparer 9 | { 10 | public int Compare(FactorioVersion x, FactorioVersion y) 11 | { 12 | if ((x is SpecialFactorioVersion) && (y is SpecialFactorioVersion)) 13 | return 0; 14 | else if (x is SpecialFactorioVersion) 15 | return int.MinValue; 16 | else if (y is SpecialFactorioVersion) 17 | return int.MaxValue; 18 | else 19 | return y.Version.CompareTo(x.Version); 20 | } 21 | 22 | public int Compare(object x, object y) 23 | { 24 | if (!(x is FactorioVersion) || !(y is FactorioVersion)) 25 | throw new ArgumentException("Parameters need to be of type FactorioVersion."); 26 | 27 | return Compare((FactorioVersion)x, (FactorioVersion)y); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModDependencySorter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModDependencySorter : IComparer, IComparer, IComparer 9 | { 10 | public int Compare(ModDependencyInfo x, ModDependencyInfo y) 11 | { 12 | int result = x.IsOptional.CompareTo(y.IsOptional); 13 | 14 | if (result == 0) 15 | result = x.Name.CompareTo(y.Name); 16 | 17 | return result; 18 | } 19 | 20 | public int Compare(ModDependency x, ModDependency y) 21 | { 22 | if (x.IsBase && !y.IsBase) 23 | { 24 | return -1; 25 | } 26 | else if (!x.IsBase && y.IsBase) 27 | { 28 | return 1; 29 | } 30 | 31 | int result = x.IsInverted.CompareTo(y.IsInverted); 32 | if (result == 0) result = x.IsOptional.CompareTo(y.IsOptional); 33 | if (result == 0) result = x.ModName.CompareTo(y.ModName); 34 | return result; 35 | } 36 | 37 | public int Compare(object x, object y) 38 | { 39 | if ((x is ModDependencyInfo) && (y is ModDependencyInfo)) 40 | { 41 | return Compare((ModDependencyInfo)x, (ModDependencyInfo)y); 42 | } 43 | else if ((x is ModDependency) && (y is ModDependency)) 44 | { 45 | return Compare((ModDependency)x, (ModDependency)y); 46 | } 47 | else 48 | { 49 | throw new ArgumentException("Parameters need to be of type ModDependency."); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModInfoSorter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using ModMyFactory.Web.ModApi; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModInfoSorter : IComparer, IComparer 9 | { 10 | public ModInfoSorterMode Mode { get; set; } 11 | 12 | private int CompareAlphabetical(ModInfo x, ModInfo y) 13 | { 14 | return string.Compare(x.Title, y.Title, StringComparison.InvariantCultureIgnoreCase); 15 | } 16 | 17 | private int CompareDownloadCount(ModInfo x, ModInfo y) 18 | { 19 | return y.DownloadCount - x.DownloadCount; 20 | } 21 | 22 | private int CompareScore(ModInfo x, ModInfo y) 23 | { 24 | double diff = y.Score - x.Score; 25 | return Math.Sign(diff); 26 | } 27 | 28 | private int CompareLastUpdate(ModInfo x, ModInfo y) 29 | { 30 | return DateTime.Compare(y.LatestRelease.ReleaseDate, x.LatestRelease.ReleaseDate); 31 | } 32 | 33 | public int Compare(ModInfo x, ModInfo y) 34 | { 35 | int result = 0; 36 | 37 | switch (Mode) 38 | { 39 | case ModInfoSorterMode.Alphabetical: 40 | result = 0; // No special logic 41 | break; 42 | case ModInfoSorterMode.DownloadCount: 43 | result = CompareDownloadCount(x, y); 44 | break; 45 | case ModInfoSorterMode.Score: 46 | result = CompareScore(x, y); 47 | break; 48 | case ModInfoSorterMode.LastUpdate: 49 | result = CompareLastUpdate(x, y); 50 | break; 51 | } 52 | 53 | if (result == 0) return CompareAlphabetical(x, y); 54 | else return result; 55 | } 56 | 57 | public int Compare(object x, object y) 58 | { 59 | if (!(x is ModInfo) || !(y is ModInfo)) 60 | throw new ArgumentException("Parameters need to be of type ModInfo."); 61 | 62 | return Compare((ModInfo)x, (ModInfo)y); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModInfoSorterMode.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.MVVM.Sorters 2 | { 3 | enum ModInfoSorterMode 4 | { 5 | Alphabetical, 6 | DownloadCount, 7 | Score, 8 | LastUpdate, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModReferenceSorter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using ModMyFactory.Models; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModReferenceSorter : IComparer, IComparer 9 | { 10 | public int Compare(IModReference x, IModReference y) 11 | { 12 | var modReferenceX = x as ModReference; 13 | var modpackReferenceX = x as ModpackReference; 14 | var modReferenceY = y as ModReference; 15 | var modpackReferenceY = y as ModpackReference; 16 | 17 | if (modReferenceX != null && modReferenceY != null) 18 | { 19 | int result = string.Compare(x.DisplayName, y.DisplayName, StringComparison.InvariantCultureIgnoreCase); 20 | if (result == 0) result = modReferenceY.Mod.FactorioVersion.CompareTo(modReferenceX.Mod.FactorioVersion); 21 | return result; 22 | } 23 | else if (modpackReferenceX != null && modpackReferenceY != null) 24 | { 25 | return string.Compare(x.DisplayName, y.DisplayName, StringComparison.InvariantCultureIgnoreCase); 26 | } 27 | else 28 | { 29 | return modpackReferenceX != null ? -1 : 1; 30 | } 31 | } 32 | 33 | public int Compare(object x, object y) 34 | { 35 | if (!(x is IModReference) || !(y is IModReference)) 36 | throw new ArgumentException("Parameters need to be of type IModReference."); 37 | 38 | return Compare((IModReference)x, (IModReference)y); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModReleaseSorter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using ModMyFactory.Web.ModApi; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModReleaseSorter : IComparer, IComparer 9 | { 10 | public int Compare(ModRelease x, ModRelease y) 11 | { 12 | return y.Version.CompareTo(x.Version); 13 | } 14 | 15 | public int Compare(object x, object y) 16 | { 17 | if (!(x is ModRelease) || !(y is ModRelease)) 18 | throw new ArgumentException("Parameters need to be of type ModRelease."); 19 | 20 | return Compare((ModRelease)x, (ModRelease)y); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModSettingSorter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models.ModSettings; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModSettingSorter : IComparer, IComparer 9 | { 10 | public int Compare(IModSetting x, IModSetting y) 11 | { 12 | int result = x.LoadTime - y.LoadTime; 13 | if (result == 0) result = string.Compare(x.Ordering, y.Ordering, StringComparison.InvariantCulture); 14 | if (result == 0) result = x.Name.CompareTo(y.Name); 15 | return result; 16 | } 17 | 18 | public int Compare(object x, object y) 19 | { 20 | if ((x is IModSetting) && (y is IModSetting)) 21 | { 22 | return Compare((IModSetting)x, (IModSetting)y); 23 | } 24 | else 25 | { 26 | throw new ArgumentException("Parameters need to be of type ModSetting."); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModSorter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModSorter : IComparer, IComparer, IComparer, IComparer 9 | { 10 | public int Compare(Mod x, Mod y) 11 | { 12 | int result = y.FactorioVersion.CompareTo(x.FactorioVersion); 13 | if (result == 0) result = string.Compare(x.FriendlyName, y.FriendlyName, StringComparison.InvariantCultureIgnoreCase); 14 | if (result == 0) result = y.Version.CompareTo(x.Version); 15 | return result; 16 | } 17 | 18 | public int Compare(ModTemplate x, ModTemplate y) 19 | { 20 | return Compare(x.Mod, y.Mod); 21 | } 22 | 23 | public int Compare(IHasModSettings x, IHasModSettings y) 24 | { 25 | return string.Compare(x.DisplayName, y.DisplayName, StringComparison.InvariantCultureIgnoreCase); 26 | } 27 | 28 | public int Compare(object x, object y) 29 | { 30 | if ((x is Mod) && (y is Mod)) 31 | { 32 | return Compare((Mod)x, (Mod)y); 33 | } 34 | else if ((x is ModTemplate) && (y is ModTemplate)) 35 | { 36 | return Compare((ModTemplate)x, (ModTemplate)y); 37 | } 38 | if ((x is IHasModSettings) && (y is IHasModSettings)) 39 | { 40 | return Compare((IHasModSettings)x, (IHasModSettings)y); 41 | } 42 | else 43 | { 44 | throw new ArgumentException("Parameters need to be of type Mod."); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModUpdateInfoSorter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModUpdateInfoSorter : IComparer, IComparer 9 | { 10 | public int Compare(ModUpdateInfo x, ModUpdateInfo y) 11 | { 12 | int result = y.FactorioVersion.CompareTo(x.FactorioVersion); 13 | 14 | if (result == 0) 15 | result = string.Compare(x.FriendlyName, y.FriendlyName, StringComparison.InvariantCultureIgnoreCase); 16 | 17 | return result; 18 | } 19 | 20 | public int Compare(object x, object y) 21 | { 22 | if (!(x is ModUpdateInfo) || !(y is ModUpdateInfo)) 23 | throw new ArgumentException("Parameters need to be of type ModUpdateInfo."); 24 | 25 | return Compare((ModUpdateInfo)x, (ModUpdateInfo)y); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/ModpackSorter.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class ModpackSorter : IComparer, IComparer, IComparer, IComparer 9 | { 10 | public int Compare(Modpack x, Modpack y) 11 | { 12 | return string.Compare(x?.Name, y?.Name, StringComparison.InvariantCultureIgnoreCase); 13 | } 14 | 15 | public int Compare(ModpackTemplate x, ModpackTemplate y) 16 | { 17 | return string.Compare(x?.Name, y?.Name, StringComparison.InvariantCultureIgnoreCase); 18 | } 19 | 20 | public int Compare(InnerModpackTemplate x, InnerModpackTemplate y) 21 | { 22 | return string.Compare(x?.Name, y?.Name, StringComparison.InvariantCultureIgnoreCase); 23 | } 24 | 25 | public int Compare(object x, object y) 26 | { 27 | if ((x is Modpack) && (y is Modpack)) 28 | { 29 | return Compare((Modpack)x, (Modpack)y); 30 | } 31 | else if ((x is ModpackTemplate) && (y is ModpackTemplate)) 32 | { 33 | return Compare((ModpackTemplate)x, (ModpackTemplate)y); 34 | } 35 | else if ((x is InnerModpackTemplate) && (y is InnerModpackTemplate)) 36 | { 37 | return Compare((InnerModpackTemplate)x, (InnerModpackTemplate)y); 38 | } 39 | else 40 | { 41 | throw new ArgumentException("Parameters need to be of type Modpack."); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MVVM/Sorters/UpdateTargetSorter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using ModMyFactory.Models; 5 | 6 | namespace ModMyFactory.MVVM.Sorters 7 | { 8 | sealed class UpdateTargetSorter : IComparer, IComparer 9 | { 10 | public int Compare(UpdateTarget x, UpdateTarget y) 11 | { 12 | return y.TargetVersion.CompareTo(x.TargetVersion); 13 | } 14 | 15 | public int Compare(object x, object y) 16 | { 17 | if (!(x is UpdateTarget) || !(y is UpdateTarget)) 18 | throw new ArgumentException("Parameters need to be of type UpdateTarget."); 19 | 20 | return Compare((UpdateTarget)x, (UpdateTarget)y); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ManagerMode.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory 2 | { 3 | enum ManagerMode 4 | { 5 | PerFactorioVersion, 6 | Global, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/MessageType.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory 2 | { 3 | enum MessageType 4 | { 5 | Information, 6 | Question, 7 | Warning, 8 | Error, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/LoadTime.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.ModSettings 2 | { 3 | enum LoadTime 4 | { 5 | Startup, 6 | RuntimeGlobal, 7 | RuntimeUser, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/LoadTimeJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.ModSettings 7 | { 8 | sealed class LoadTimeJsonConverter : JsonConverter 9 | { 10 | private static readonly Dictionary to; 11 | private static readonly Dictionary from; 12 | 13 | static LoadTimeJsonConverter() 14 | { 15 | to = new Dictionary 16 | { 17 | { LoadTime.Startup, "startup" }, 18 | { LoadTime.RuntimeGlobal, "runtime-global" }, 19 | { LoadTime.RuntimeUser, "runtime-per-user" }, 20 | }; 21 | 22 | from = new Dictionary 23 | { 24 | { "startup", LoadTime.Startup }, 25 | { "runtime-global", LoadTime.RuntimeGlobal }, 26 | { "runtime-per-user", LoadTime.RuntimeUser }, 27 | }; 28 | } 29 | 30 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 31 | { 32 | JToken token = JToken.FromObject(to[(LoadTime)value]); 33 | token.WriteTo(writer); 34 | } 35 | 36 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 37 | { 38 | JToken token = JToken.Load(reader); 39 | string value = token.Value(); 40 | return from[value]; 41 | } 42 | 43 | public override bool CanConvert(Type objectType) 44 | { 45 | return objectType == typeof(LoadTime); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/Serialization/ModSettingValueTemplate.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace ModMyFactory.ModSettings.Serialization 5 | { 6 | class ModSettingValueTemplate 7 | { 8 | [JsonProperty("value")] 9 | public object Value { get; } 10 | 11 | [JsonConstructor] 12 | public ModSettingValueTemplate(object value) 13 | { 14 | Value = value; 15 | } 16 | 17 | public T GetValue() 18 | { 19 | if (ReferenceEquals(Value, null)) return default(T); 20 | if (Value.GetType() == typeof(T)) return (T)Value; 21 | return (T)Convert.ChangeType(Value, typeof(T)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/SettingType.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.ModSettings 2 | { 3 | enum SettingType 4 | { 5 | Boolean, 6 | Integer, 7 | FloatingPoint, 8 | String, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/SettingTypeExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.ModSettings 2 | { 3 | static class SettingTypeExtensions 4 | { 5 | public static bool CompatibleTo(this SettingType value, SettingType other) 6 | { 7 | if (value == SettingType.Integer) 8 | { 9 | return (other == SettingType.Integer) || (other == SettingType.FloatingPoint); 10 | } 11 | else 12 | { 13 | return value == other; 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/SettingTypeJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace ModMyFactory.ModSettings 7 | { 8 | sealed class SettingTypeJsonConverter : JsonConverter 9 | { 10 | private static readonly Dictionary to; 11 | private static readonly Dictionary from; 12 | 13 | static SettingTypeJsonConverter() 14 | { 15 | to = new Dictionary 16 | { 17 | { SettingType.Boolean, "bool-setting" }, 18 | { SettingType.Integer, "int-setting" }, 19 | { SettingType.FloatingPoint, "double-setting" }, 20 | { SettingType.String, "string-setting" }, 21 | }; 22 | 23 | from = new Dictionary 24 | { 25 | { "bool-setting", SettingType.Boolean }, 26 | { "int-setting", SettingType.Integer }, 27 | { "double-setting", SettingType.FloatingPoint }, 28 | { "string-setting", SettingType.String }, 29 | }; 30 | } 31 | 32 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 33 | { 34 | JToken token = JToken.FromObject(to[(SettingType)value]); 35 | token.WriteTo(writer); 36 | } 37 | 38 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 39 | { 40 | JToken token = JToken.Load(reader); 41 | string value = token.Value(); 42 | return from[value]; 43 | } 44 | 45 | public override bool CanConvert(Type objectType) 46 | { 47 | return objectType == typeof(SettingType); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/SettingValueArrayJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace ModMyFactory.ModSettings 8 | { 9 | sealed class SettingValueArrayJsonConverter : JsonConverter 10 | { 11 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 12 | { 13 | JToken token = JToken.FromObject(((SettingValue[])value).Select(v => v.Value)); 14 | token.WriteTo(writer); 15 | } 16 | 17 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 18 | { 19 | JToken token = JToken.Load(reader); 20 | if (token.Type == JTokenType.Array) 21 | { 22 | var array = (JArray)token; 23 | 24 | var result = new List(); 25 | foreach (var child in array.Children()) 26 | { 27 | switch (child.Type) 28 | { 29 | case JTokenType.Boolean: 30 | return new SettingValue(child.Value()); 31 | case JTokenType.Integer: 32 | return new SettingValue(child.Value()); 33 | case JTokenType.Float: 34 | return new SettingValue(child.Value()); 35 | case JTokenType.String: 36 | return new SettingValue(child.Value()); 37 | default: 38 | throw new JsonSerializationException("Incompatible data type."); 39 | } 40 | } 41 | return result.ToArray(); 42 | } 43 | else 44 | { 45 | throw new JsonSerializationException("Incompatible data type."); 46 | } 47 | } 48 | 49 | public override bool CanConvert(Type objectType) 50 | { 51 | return objectType == typeof(SettingValue[]); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModSettings/SettingValueJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | 5 | namespace ModMyFactory.ModSettings 6 | { 7 | sealed class SettingValueJsonConverter : JsonConverter 8 | { 9 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 10 | { 11 | JToken token = JToken.FromObject(((SettingValue)value).Value); 12 | token.WriteTo(writer); 13 | } 14 | 15 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 16 | { 17 | JToken token = JToken.Load(reader); 18 | switch (token.Type) 19 | { 20 | case JTokenType.Boolean: 21 | return new SettingValue(token.Value()); 22 | case JTokenType.Integer: 23 | return new SettingValue(token.Value()); 24 | case JTokenType.Float: 25 | return new SettingValue(token.Value()); 26 | case JTokenType.String: 27 | return new SettingValue(token.Value()); 28 | default: 29 | throw new JsonSerializationException("Incompatible data type."); 30 | } 31 | } 32 | 33 | public override bool CanConvert(Type objectType) 34 | { 35 | return objectType == typeof(SettingValue); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/CopyOrMoveType.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Models 2 | { 3 | enum CopyOrMoveType 4 | { 5 | Factorio, 6 | Mods, 7 | Mod, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/IHasLocale.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace ModMyFactory.Models 4 | { 5 | interface IHasLocale 6 | { 7 | ILocale GetLocale(CultureInfo culture); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/IHasModSettings.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Models.ModSettings; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Windows.Input; 6 | 7 | namespace ModMyFactory.Models 8 | { 9 | interface IHasModSettings : INotifyPropertyChanged, IHasLocale 10 | { 11 | string Name { get; } 12 | 13 | GameCompatibleVersion Version { get; } 14 | 15 | Version FactorioVersion { get; } 16 | 17 | string DisplayName { get; } 18 | 19 | string UniqueID { get; } 20 | 21 | bool UseBinaryFileOverride { get; } 22 | 23 | bool Override { get; set; } 24 | 25 | bool HasSettings { get; } 26 | 27 | IReadOnlyCollection Settings { get; } 28 | 29 | ICollectionView SettingsView { get; } 30 | 31 | ICommand ViewSettingsCommand { get; } 32 | 33 | void ViewSettings(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ILocale.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Models 2 | { 3 | interface ILocale 4 | { 5 | string GetValue(string key, LocaleType type); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/IModReference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using System.Windows.Media.Imaging; 4 | using WPFCore.Commands; 5 | 6 | namespace ModMyFactory.Models 7 | { 8 | interface IModReference : INotifyPropertyChanged 9 | { 10 | string DisplayName { get; } 11 | 12 | string VersionInfo { get; } 13 | 14 | string FactorioVersionInfo { get; } 15 | 16 | BitmapImage Image { get; } 17 | 18 | bool? Active { get; set; } 19 | 20 | bool HasUnsatisfiedDependencies { get; } 21 | 22 | IEnumerable ModProxies { get; } 23 | 24 | RelayCommand RemoveFromParentCommand { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/LatestFactorioVersion.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Helpers; 2 | using System.Collections.Specialized; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | 6 | namespace ModMyFactory.Models 7 | { 8 | sealed class LatestFactorioVersion : SpecialFactorioVersion 9 | { 10 | readonly FactorioCollection collection; 11 | 12 | public override string DisplayName => App.Instance.GetLocalizedResourceString("LatestFactorioName"); 13 | 14 | protected override string LoadName() 15 | { 16 | return "Latest"; 17 | } 18 | 19 | private void SetWrappedVersion() 20 | { 21 | WrappedVersion = collection.Where(item => !(item is SpecialFactorioVersion)).MaxBy(item => item.Version); 22 | } 23 | 24 | private void CollectionChangedHandler(object sender, NotifyCollectionChangedEventArgs e) 25 | { 26 | if (e.Action == NotifyCollectionChangedAction.Add) 27 | { 28 | foreach (FactorioVersion item in e.NewItems) 29 | { 30 | if (!(item is SpecialFactorioVersion)) 31 | item.PropertyChanged += ItemPropertyChangedHandler; 32 | } 33 | } 34 | 35 | if ((e.Action == NotifyCollectionChangedAction.Remove) || (e.Action == NotifyCollectionChangedAction.Reset)) 36 | { 37 | foreach (FactorioVersion item in e.OldItems) 38 | { 39 | if (!(item is SpecialFactorioVersion)) 40 | item.PropertyChanged -= ItemPropertyChangedHandler; 41 | } 42 | } 43 | 44 | SetWrappedVersion(); 45 | } 46 | 47 | private void ItemPropertyChangedHandler(object sender, PropertyChangedEventArgs e) 48 | { 49 | if (e.PropertyName == nameof(FactorioVersion.Version)) 50 | SetWrappedVersion(); 51 | } 52 | 53 | public LatestFactorioVersion(FactorioCollection collection) 54 | : base(null) 55 | { 56 | this.collection = collection; 57 | this.collection.CollectionChanged += CollectionChangedHandler; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/LocaleType.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Models 2 | { 3 | enum LocaleType 4 | { 5 | None, 6 | SettingName, 7 | SettingDescription, 8 | StringSetting, 9 | } 10 | 11 | static class LocaleTypeExtensions 12 | { 13 | public static string Key(this LocaleType type) 14 | { 15 | switch (type) 16 | { 17 | case LocaleType.SettingName: 18 | return "mod-setting-name"; 19 | case LocaleType.SettingDescription: 20 | return "mod-setting-description"; 21 | case LocaleType.StringSetting: 22 | return "string-mod-setting"; 23 | } 24 | 25 | return string.Empty; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModDependencyInfo.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Web.ModApi; 2 | using System; 3 | using System.ComponentModel; 4 | using WPFCore; 5 | 6 | namespace ModMyFactory.Models 7 | { 8 | sealed class ModDependencyInfo : NotifyPropertyChangedBase 9 | { 10 | bool isOptional; 11 | bool isSelected; 12 | 13 | public ModRelease Release { get; } 14 | 15 | public string Name { get; } 16 | 17 | public Version FactorioVersion { get; } 18 | 19 | public GameCompatibleVersion Version => Release.Version; 20 | 21 | public bool IsOptional 22 | { 23 | get => isOptional; 24 | set 25 | { 26 | if (value != isOptional) 27 | { 28 | isOptional = value; 29 | IsSelected = !isOptional; 30 | } 31 | } 32 | } 33 | 34 | public bool IsSelected 35 | { 36 | get => isSelected; 37 | set 38 | { 39 | if (value != isSelected) 40 | { 41 | isSelected = value; 42 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelected))); 43 | } 44 | } 45 | } 46 | 47 | public ModDependencyInfo(ModRelease release, string name, Version factorioVersion, bool isOptional) 48 | { 49 | Release = release; 50 | Name = name; 51 | FactorioVersion = factorioVersion; 52 | IsOptional = isOptional; 53 | IsSelected = !isOptional; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModFileCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | namespace ModMyFactory.Models 5 | { 6 | partial class Mod 7 | { 8 | private sealed class ModFileCollection : ICollection 9 | { 10 | private readonly List list; 11 | 12 | public ModFile Latest { get; private set; } 13 | 14 | public int Count => list.Count; 15 | 16 | public bool IsReadOnly => false; 17 | 18 | public ModFileCollection() 19 | { 20 | list = new List(); 21 | } 22 | 23 | public void Add(ModFile item) 24 | { 25 | list.Add(item); 26 | 27 | if ((Latest == null) || (Latest.CompareTo(item) < 0)) 28 | Latest = item; 29 | } 30 | 31 | public bool Remove(ModFile item) 32 | { 33 | if (item == Latest) 34 | Latest = null; 35 | 36 | return list.Remove(item); 37 | } 38 | 39 | public void Clear() 40 | { 41 | Latest = null; 42 | list.Clear(); 43 | } 44 | 45 | public bool Contains(ModFile item) 46 | { 47 | return list.Contains(item); 48 | } 49 | 50 | public void CopyTo(ModFile[] array, int arrayIndex) 51 | { 52 | list.CopyTo(array, arrayIndex); 53 | } 54 | 55 | public IEnumerator GetEnumerator() 56 | { 57 | return list.GetEnumerator(); 58 | } 59 | 60 | IEnumerator IEnumerable.GetEnumerator() 61 | { 62 | return list.GetEnumerator(); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/BooleanModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System.Windows; 3 | 4 | namespace ModMyFactory.Models.ModSettings 5 | { 6 | sealed class BooleanModSetting : ModSetting 7 | { 8 | sealed class BooleanModSettingProxy : ModSettingProxy 9 | { 10 | public BooleanModSettingProxy(ModSetting baseSetting) 11 | : base(baseSetting) 12 | { } 13 | 14 | public override IModSettingProxy CreateProxy() 15 | { 16 | return new BooleanModSettingProxy(this); 17 | } 18 | } 19 | 20 | public override DataTemplate Template => (DataTemplate)App.Instance.Resources["BooleanModSettingTemplate"]; 21 | 22 | public BooleanModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, bool defaultValue) 23 | : base(owner, name, loadTime, ordering, defaultValue) 24 | { } 25 | 26 | public override IModSettingProxy CreateProxy() 27 | { 28 | return new BooleanModSettingProxy(this); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/FloatingPointListModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System.Collections.Generic; 3 | using System.Windows; 4 | 5 | namespace ModMyFactory.Models.ModSettings 6 | { 7 | sealed class FloatingPointListModSetting : ListModSetting 8 | { 9 | sealed class FloatingPointListModSettingProxy : ListModSettingProxy 10 | { 11 | public FloatingPointListModSettingProxy(FloatingPointListModSetting baseSetting) 12 | : base(baseSetting) 13 | { } 14 | 15 | private FloatingPointListModSettingProxy(FloatingPointListModSettingProxy baseSetting) 16 | : base(baseSetting) 17 | { } 18 | 19 | public override IModSettingProxy CreateProxy() 20 | { 21 | return new FloatingPointListModSettingProxy(this); 22 | } 23 | } 24 | 25 | public override DataTemplate Template => (DataTemplate)App.Instance.Resources["FloatingPointListModSettingTemplate"]; 26 | 27 | public FloatingPointListModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, decimal defaultValue, IEnumerable allowedValues) 28 | : base(owner, name, loadTime, ordering, defaultValue, allowedValues) 29 | { } 30 | 31 | public override IModSettingProxy CreateProxy() 32 | { 33 | return new FloatingPointListModSettingProxy(this); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/FloatingPointModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System.Windows; 3 | 4 | namespace ModMyFactory.Models.ModSettings 5 | { 6 | sealed class FloatingPointModSetting : LimitedModSetting 7 | { 8 | sealed class FloatingPointModSettingProxy : LimitedModSettingProxy 9 | { 10 | public FloatingPointModSettingProxy(FloatingPointModSetting baseSetting) 11 | : base(baseSetting) 12 | { } 13 | 14 | private FloatingPointModSettingProxy(FloatingPointModSettingProxy baseSetting) 15 | : base(baseSetting) 16 | { } 17 | 18 | public override IModSettingProxy CreateProxy() 19 | { 20 | return new FloatingPointModSettingProxy(this); 21 | } 22 | } 23 | 24 | public override DataTemplate Template => (DataTemplate)App.Instance.Resources["FloatingPointModSettingTemplate"]; 25 | 26 | public FloatingPointModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, decimal defaultValue, decimal minValue, decimal maxValue) 27 | : base(owner, name, loadTime, ordering, defaultValue, minValue, maxValue) 28 | { } 29 | 30 | public override IModSettingProxy CreateProxy() 31 | { 32 | return new FloatingPointModSettingProxy(this); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/ILimitedModSetting.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Models.ModSettings 2 | { 3 | interface ILimitedModSetting : IModSetting 4 | { 5 | T MinValue { get; } 6 | 7 | T MaxValue { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/IListModSetting.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace ModMyFactory.Models.ModSettings 4 | { 5 | interface IListModSetting : IModSetting 6 | { 7 | IReadOnlyCollection AllowedValues { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/IModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using ModMyFactory.ModSettings.Serialization; 3 | using System.Windows; 4 | using System.Windows.Input; 5 | 6 | namespace ModMyFactory.Models.ModSettings 7 | { 8 | interface IModSetting 9 | { 10 | IHasModSettings Owner { get; } 11 | 12 | string Name { get; } 13 | 14 | LoadTime LoadTime { get; } 15 | 16 | string Ordering { get; } 17 | 18 | DataTemplate Template { get; } 19 | 20 | IModSettingProxy CreateProxy(); 21 | 22 | ModSettingValueTemplate CreateValueTemplate(); 23 | 24 | ICommand ResetCommand { get; } 25 | 26 | void Reset(); 27 | } 28 | 29 | interface IModSetting : IModSetting 30 | { 31 | T Value { get; set; } 32 | 33 | T DefaultValue { get; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/IModSettingProxy.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Models.ModSettings 2 | { 3 | interface IModSettingProxy : IModSetting 4 | { 5 | bool Override { get; set; } 6 | } 7 | 8 | interface IModSettingProxy : IModSettingProxy, IModSetting 9 | { } 10 | } 11 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/IStringModSetting.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Models.ModSettings 2 | { 3 | interface IStringModSetting : IModSetting 4 | { 5 | bool AllowEmptyValue { get; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/IntegerListModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System.Collections.Generic; 3 | using System.Windows; 4 | 5 | namespace ModMyFactory.Models.ModSettings 6 | { 7 | sealed class IntegerListModSetting : ListModSetting 8 | { 9 | sealed class IntegerListModSettingProxy : ListModSettingProxy 10 | { 11 | public IntegerListModSettingProxy(IntegerListModSetting baseSetting) 12 | : base(baseSetting) 13 | { } 14 | 15 | private IntegerListModSettingProxy(IntegerListModSettingProxy baseSetting) 16 | : base(baseSetting) 17 | { } 18 | 19 | public override IModSettingProxy CreateProxy() 20 | { 21 | return new IntegerListModSettingProxy(this); 22 | } 23 | } 24 | 25 | public override DataTemplate Template => (DataTemplate)App.Instance.Resources["IntegerListModSettingTemplate"]; 26 | 27 | public IntegerListModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, long defaultValue, IEnumerable allowedValues) 28 | : base(owner, name, loadTime, ordering, defaultValue, allowedValues) 29 | { } 30 | 31 | public override IModSettingProxy CreateProxy() 32 | { 33 | return new IntegerListModSettingProxy(this); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/IntegerModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System.Windows; 3 | 4 | namespace ModMyFactory.Models.ModSettings 5 | { 6 | sealed class IntegerModSetting : LimitedModSetting 7 | { 8 | sealed class IntegerModSettingProxy : LimitedModSettingProxy 9 | { 10 | public IntegerModSettingProxy(IntegerModSetting baseSetting) 11 | : base(baseSetting) 12 | { } 13 | 14 | private IntegerModSettingProxy(IntegerModSettingProxy baseSetting) 15 | : base(baseSetting) 16 | { } 17 | 18 | public override IModSettingProxy CreateProxy() 19 | { 20 | return new IntegerModSettingProxy(this); 21 | } 22 | } 23 | 24 | public override DataTemplate Template => (DataTemplate)App.Instance.Resources["IntegerModSettingTemplate"]; 25 | 26 | public IntegerModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, long defaultValue, long minValue, long maxValue) 27 | : base(owner, name, loadTime, ordering, defaultValue, minValue, maxValue) 28 | { } 29 | 30 | public override IModSettingProxy CreateProxy() 31 | { 32 | return new IntegerModSettingProxy(this); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/LimitedModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace ModMyFactory.Models.ModSettings 6 | { 7 | abstract class LimitedModSetting : ModSetting, ILimitedModSetting where T : IEquatable, IComparable 8 | { 9 | public override T Value 10 | { 11 | get => base.Value; 12 | set 13 | { 14 | T newValue = value; 15 | 16 | var comparer = Comparer.Default; 17 | if (comparer.Compare(newValue, MinValue) < 0) newValue = MinValue; 18 | if (comparer.Compare(newValue, MaxValue) > 0) newValue = MaxValue; 19 | 20 | base.Value = newValue; 21 | } 22 | } 23 | 24 | public T MinValue { get; } 25 | 26 | public T MaxValue { get; } 27 | 28 | protected LimitedModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, T defaultValue, T minValue, T maxValue) 29 | : base(owner, name, loadTime, ordering, defaultValue) 30 | { 31 | var comparer = Comparer.Default; 32 | if (comparer.Compare(minValue, maxValue) > 0) throw new ArgumentException("Min value cannot be larger than max value."); 33 | if (comparer.Compare(defaultValue, minValue) < 0) throw new ArgumentOutOfRangeException(nameof(defaultValue)); 34 | if (comparer.Compare(defaultValue, maxValue) > 0) throw new ArgumentOutOfRangeException(nameof(defaultValue)); 35 | 36 | MinValue = minValue; 37 | MaxValue = maxValue; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/LimitedModSettingProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace ModMyFactory.Models.ModSettings 5 | { 6 | abstract class LimitedModSettingProxy : ModSettingProxy, ILimitedModSetting where T : IEquatable, IComparable 7 | { 8 | public override T Value 9 | { 10 | get => base.Value; 11 | set 12 | { 13 | T newValue = value; 14 | 15 | var comparer = Comparer.Default; 16 | if (comparer.Compare(newValue, MinValue) < 0) newValue = MinValue; 17 | if (comparer.Compare(newValue, MaxValue) > 0) newValue = MaxValue; 18 | 19 | base.Value = newValue; 20 | } 21 | } 22 | 23 | public T MinValue { get; } 24 | 25 | public T MaxValue { get; } 26 | 27 | protected LimitedModSettingProxy(LimitedModSetting baseSetting) 28 | : base(baseSetting) 29 | { 30 | MinValue = baseSetting.MinValue; 31 | MaxValue = baseSetting.MaxValue; 32 | } 33 | 34 | protected LimitedModSettingProxy(LimitedModSettingProxy baseSetting) 35 | : base(baseSetting) 36 | { 37 | MinValue = baseSetting.MinValue; 38 | MaxValue = baseSetting.MaxValue; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/ListModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | 6 | namespace ModMyFactory.Models.ModSettings 7 | { 8 | abstract class ListModSetting : ModSetting, IListModSetting where T : IEquatable 9 | { 10 | public override T Value 11 | { 12 | get => base.Value; 13 | set 14 | { 15 | var comparer = EqualityComparer.Default; 16 | foreach (var allowedValue in AllowedValues) 17 | { 18 | if (comparer.Equals(value, allowedValue)) 19 | { 20 | base.Value = value; 21 | return; 22 | } 23 | } 24 | 25 | throw new ArgumentException("Value not allowed.", nameof(value)); 26 | } 27 | } 28 | 29 | public IReadOnlyCollection AllowedValues { get; } 30 | 31 | protected ListModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, T defaultValue, IEnumerable allowedValues) 32 | : base(owner, name, loadTime, ordering, defaultValue) 33 | { 34 | var comparer = EqualityComparer.Default; 35 | foreach (var allowedValue in allowedValues) 36 | { 37 | if (comparer.Equals(defaultValue, allowedValue)) 38 | { 39 | AllowedValues = new ReadOnlyCollection(new List(allowedValues)); 40 | return; 41 | } 42 | } 43 | 44 | throw new ArgumentException("Value not allowed.", nameof(defaultValue)); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/ListModSettingProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace ModMyFactory.Models.ModSettings 5 | { 6 | abstract class ListModSettingProxy : ModSettingProxy, IListModSetting where T : IEquatable 7 | { 8 | public override T Value 9 | { 10 | get => base.Value; 11 | set 12 | { 13 | var comparer = EqualityComparer.Default; 14 | foreach (var allowedValue in AllowedValues) 15 | { 16 | if (comparer.Equals(value, allowedValue)) 17 | { 18 | base.Value = value; 19 | return; 20 | } 21 | } 22 | 23 | throw new ArgumentException("Value not allowed.", nameof(value)); 24 | } 25 | } 26 | 27 | public IReadOnlyCollection AllowedValues { get; } 28 | 29 | protected ListModSettingProxy(ListModSetting baseSetting) 30 | : base(baseSetting) 31 | { 32 | AllowedValues = baseSetting.AllowedValues; 33 | } 34 | 35 | protected ListModSettingProxy(ListModSettingProxy baseSetting) 36 | : base(baseSetting) 37 | { 38 | AllowedValues = baseSetting.AllowedValues; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/ModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using ModMyFactory.ModSettings.Serialization; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Windows; 7 | using System.Windows.Input; 8 | using WPFCore; 9 | using WPFCore.Commands; 10 | 11 | namespace ModMyFactory.Models.ModSettings 12 | { 13 | abstract class ModSetting : NotifyPropertyChangedBase, IModSetting where T : IEquatable 14 | { 15 | T value; 16 | 17 | public IHasModSettings Owner { get; } 18 | 19 | public string Name { get; } 20 | 21 | public LoadTime LoadTime { get; } 22 | 23 | public string Ordering { get; } 24 | 25 | public ICommand ResetCommand { get; } 26 | 27 | public virtual T Value 28 | { 29 | get => value; 30 | set 31 | { 32 | var comparer = EqualityComparer.Default; 33 | if (!comparer.Equals(value, this.value)) 34 | { 35 | this.value = value; 36 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Value))); 37 | } 38 | } 39 | } 40 | 41 | public T DefaultValue { get; } 42 | 43 | public abstract DataTemplate Template { get; } 44 | 45 | private T GetStartValue() 46 | { 47 | if (ModSettingsManager.TryGetSavedValue(Owner, this, out T value)) return value; 48 | return DefaultValue; 49 | } 50 | 51 | protected ModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, T defaultValue) 52 | { 53 | Owner = owner; 54 | Name = name; 55 | LoadTime = loadTime; 56 | Ordering = ordering; 57 | ResetCommand = new RelayCommand(Reset); 58 | 59 | DefaultValue = defaultValue; 60 | value = GetStartValue(); 61 | } 62 | 63 | public virtual void Reset() 64 | { 65 | Value = DefaultValue; 66 | } 67 | 68 | public abstract IModSettingProxy CreateProxy(); 69 | 70 | public ModSettingValueTemplate CreateValueTemplate() => new ModSettingValueTemplate(value); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/ModSettingProxy.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Windows; 6 | 7 | namespace ModMyFactory.Models.ModSettings 8 | { 9 | abstract class ModSettingProxy : ModSetting, IModSettingProxy where T : IEquatable 10 | { 11 | readonly ModSetting baseSetting; 12 | bool @override; 13 | T value; 14 | 15 | public bool Override 16 | { 17 | get => @override; 18 | set 19 | { 20 | if (value != @override) 21 | { 22 | @override = value; 23 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Override))); 24 | 25 | if (@override) 26 | { 27 | if (ModSettingsManager.TryGetSavedValue(Owner, this, out T savedValue)) this.value = savedValue; 28 | else this.value = baseSetting.Value; 29 | } 30 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Value))); 31 | } 32 | } 33 | } 34 | 35 | public override T Value 36 | { 37 | get => Override ? value : baseSetting.Value; 38 | set 39 | { 40 | var comparer = EqualityComparer.Default; 41 | if (!comparer.Equals(value, this.value)) 42 | { 43 | this.value = value; 44 | if (Override) OnPropertyChanged(new PropertyChangedEventArgs(nameof(Value))); 45 | } 46 | } 47 | } 48 | 49 | public override DataTemplate Template => baseSetting.Template; 50 | 51 | protected ModSettingProxy(ModSetting baseSetting) 52 | : base(baseSetting.Owner, baseSetting.Name, baseSetting.LoadTime, baseSetting.Ordering, baseSetting.DefaultValue) 53 | { 54 | this.baseSetting = baseSetting; 55 | value = baseSetting.Value; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModSettings/StringListModSetting.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.ModSettings; 2 | using System.Collections.Generic; 3 | using System.Windows; 4 | 5 | namespace ModMyFactory.Models.ModSettings 6 | { 7 | sealed class StringListModSetting : ListModSetting 8 | { 9 | sealed class StringListModSettingProxy : ListModSettingProxy 10 | { 11 | public StringListModSettingProxy(StringListModSetting baseSetting) 12 | : base(baseSetting) 13 | { } 14 | 15 | private StringListModSettingProxy(StringListModSettingProxy baseSetting) 16 | : base(baseSetting) 17 | { } 18 | 19 | public override IModSettingProxy CreateProxy() 20 | { 21 | return new StringListModSettingProxy(this); 22 | } 23 | } 24 | 25 | public override DataTemplate Template => (DataTemplate)App.Instance.Resources["StringListModSettingTemplate"]; 26 | 27 | public StringListModSetting(IHasModSettings owner, string name, LoadTime loadTime, string ordering, string defaultValue, IEnumerable allowedValues) 28 | : base(owner, name, loadTime, ordering, defaultValue, allowedValues) 29 | { } 30 | 31 | public override IModSettingProxy CreateProxy() 32 | { 33 | return new StringListModSettingProxy(this); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModUpdateInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using ModMyFactory.Web.ModApi; 6 | using WPFCore; 7 | 8 | namespace ModMyFactory.Models 9 | { 10 | class ModUpdateInfo : NotifyPropertyChangedBase 11 | { 12 | bool isSelected; 13 | 14 | public ModRelease Update { get; } 15 | 16 | public string ModName { get; } 17 | 18 | public string FriendlyName { get; } 19 | 20 | public Version UpdateVersion => Update.Version; 21 | 22 | public Version FactorioVersion => Update.InfoFile.FactorioVersion; 23 | 24 | public List ModVersions { get; } 25 | 26 | public bool Extract => ModVersions.Any(version => version.Mod.ExtractUpdates); 27 | 28 | public bool IsSelected 29 | { 30 | get { return isSelected; } 31 | set 32 | { 33 | if (value != isSelected) 34 | { 35 | isSelected = value; 36 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelected))); 37 | 38 | if (!isSelected) 39 | { 40 | foreach (var version in ModVersions) 41 | version.IsSelected = false; 42 | } 43 | } 44 | } 45 | } 46 | 47 | public ModUpdateInfo(string modName, string friendlyName, ModRelease update) 48 | { 49 | ModName = modName; 50 | FriendlyName = friendlyName; 51 | Update = update; 52 | isSelected = true; 53 | ModVersions = new List(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/ModVersionUpdateInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Linq; 4 | using WPFCore; 5 | 6 | namespace ModMyFactory.Models 7 | { 8 | class ModVersionUpdateInfo : NotifyPropertyChangedBase 9 | { 10 | bool isSelected; 11 | 12 | public Mod Mod { get; } 13 | 14 | public Version Version => Mod.Version; 15 | 16 | public int ModpackCount { get; } 17 | 18 | public bool IsSelected 19 | { 20 | get { return isSelected; } 21 | set 22 | { 23 | if (value != isSelected) 24 | { 25 | isSelected = value; 26 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelected))); 27 | } 28 | } 29 | } 30 | 31 | public ModVersionUpdateInfo(Mod mod, ModpackCollection modpacks) 32 | { 33 | Mod = mod; 34 | isSelected = App.Instance.Settings.PreSelectModVersions; 35 | ModpackCount = modpacks.Count(pack => pack.Contains(mod)); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/SpecialFactorioVersion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.IO; 4 | 5 | namespace ModMyFactory.Models 6 | { 7 | abstract class SpecialFactorioVersion : FactorioVersion 8 | { 9 | FactorioVersion wrappedVersion; 10 | 11 | protected FactorioVersion WrappedVersion 12 | { 13 | get => wrappedVersion; 14 | set 15 | { 16 | if (value != wrappedVersion) 17 | { 18 | if (wrappedVersion != null) 19 | wrappedVersion.PropertyChanged -= WrappedVersionPropertyChangedHandler; 20 | 21 | wrappedVersion = value; 22 | 23 | if (wrappedVersion != null) 24 | wrappedVersion.PropertyChanged += WrappedVersionPropertyChangedHandler; 25 | 26 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Version))); 27 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Directory))); 28 | } 29 | } 30 | } 31 | 32 | public override Version Version => WrappedVersion?.Version; 33 | 34 | public override DirectoryInfo Directory => WrappedVersion?.Directory; 35 | 36 | protected override abstract string LoadName(); 37 | 38 | public override void Run(string args = null) 39 | { 40 | WrappedVersion?.Run(args); 41 | } 42 | 43 | protected SpecialFactorioVersion(FactorioVersion wrappedVersion) 44 | { 45 | WrappedVersion = wrappedVersion; 46 | } 47 | 48 | private void WrappedVersionPropertyChangedHandler(object sender, PropertyChangedEventArgs e) 49 | { 50 | OnPropertyChanged(e); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/UpdateSearchResult.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Models 2 | { 3 | /// 4 | /// The result of an update search. 5 | /// 6 | class UpdateSearchResult 7 | { 8 | /// 9 | /// Indicates whether an update is available. 10 | /// 11 | public bool UpdateAvailable { get; } 12 | 13 | /// 14 | /// The url of the update. 15 | /// 16 | public string UpdateUrl { get; } 17 | 18 | /// 19 | /// The asset url of the update. 20 | /// 21 | public string AssetUrl { get; } 22 | 23 | /// 24 | /// The version of the update. 25 | /// 26 | public ExtendedVersion Version { get; } 27 | 28 | /// 29 | /// Creates a new update search result. 30 | /// 31 | /// Indicates whether an update is available. 32 | /// The url of the update. 33 | /// The asset url of the update. 34 | /// The version of the update. 35 | public UpdateSearchResult(bool updateAvailable, string updateUrl, string assetUrl, ExtendedVersion version) 36 | { 37 | UpdateAvailable = updateAvailable; 38 | UpdateUrl = updateUrl; 39 | AssetUrl = assetUrl; 40 | Version = version; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Models/UpdateTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using ModMyFactory.Web.UpdateApi; 5 | 6 | namespace ModMyFactory.Models 7 | { 8 | sealed class UpdateTarget 9 | { 10 | public IReadOnlyCollection Steps { get; } 11 | 12 | public Version TargetVersion { get; } 13 | 14 | public bool IsLatestStable { get; } 15 | 16 | public UpdateTarget(IList steps, Version targetVersion, bool isLatestStable) 17 | { 18 | Steps = new ReadOnlyCollection(steps); 19 | TargetVersion = targetVersion; 20 | IsLatestStable = isLatestStable; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ModpackCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using ModMyFactory.Models; 3 | 4 | namespace ModMyFactory 5 | { 6 | class ModpackCollection : ObservableCollection 7 | { 8 | public bool Contains(string name) 9 | { 10 | foreach (var modpack in this) 11 | { 12 | if (modpack.Name == name) 13 | return true; 14 | } 15 | return false; 16 | } 17 | 18 | public Modpack Find(string name) 19 | { 20 | foreach (var modpack in this) 21 | { 22 | if (modpack.Name == name) 23 | return modpack; 24 | } 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ModMyFactory.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Resources/updater.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Resources/updater.exe -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/SingleOrArrayJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | 5 | namespace ModMyFactory 6 | { 7 | class SingleOrArrayJsonConverter : JsonConverter 8 | { 9 | public override bool CanWrite => false; 10 | 11 | public override bool CanConvert(Type objectType) 12 | { 13 | return objectType == typeof(T[]); 14 | } 15 | 16 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 17 | { 18 | JToken token = JToken.Load(reader); 19 | if (token.Type == JTokenType.Array) 20 | { 21 | return token.ToObject(); 22 | } 23 | return new T[] { token.ToObject() }; 24 | } 25 | 26 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 27 | { 28 | throw new NotSupportedException(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Theme.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.ComponentModel; 5 | using System.Windows.Input; 6 | using System.Windows.Media.Imaging; 7 | using WPFCore; 8 | using WPFCore.Commands; 9 | 10 | namespace ModMyFactory 11 | { 12 | sealed class Theme : NotifyPropertyChangedBase 13 | { 14 | static readonly List themes; 15 | 16 | public static IReadOnlyCollection AvailableThemes { get; } 17 | 18 | public static Theme Light { get; } 19 | 20 | public static Theme Dark { get; } 21 | 22 | static Theme() 23 | { 24 | themes = new List(); 25 | 26 | Light = new Theme("light"); 27 | Dark = new Theme("dark"); 28 | 29 | AvailableThemes = new ReadOnlyCollection(themes); 30 | } 31 | 32 | bool selected; 33 | 34 | public string Name { get; } 35 | 36 | public bool Selected 37 | { 38 | get => selected; 39 | set 40 | { 41 | if (value != selected) 42 | { 43 | selected = value; 44 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Selected))); 45 | 46 | if (selected) 47 | { 48 | themes.ForEach(theme => { if (theme != this) theme.Selected = false; }); 49 | App.Instance.SetTheme(Name); 50 | } 51 | } 52 | } 53 | } 54 | 55 | public BitmapImage Image { get; } 56 | 57 | public ICommand SelectCommand { get; } 58 | 59 | private Theme(string name) 60 | { 61 | Name = name; 62 | Image = new BitmapImage(new Uri($"../Images/Themes/{name}.png", UriKind.Relative)); 63 | SelectCommand = new RelayCommand(() => Selected = true); 64 | themes.Add(this); 65 | 66 | if (App.Instance.Settings.Theme == Name) 67 | { 68 | selected = true; 69 | App.Instance.SetTheme(Name); 70 | } 71 | } 72 | 73 | public void OnLocalizedNameChanged() 74 | { 75 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Name))); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/TwoPartVersionConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace ModMyFactory 6 | { 7 | class TwoPartVersionConverter : JsonConverter 8 | { 9 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 10 | { 11 | JToken token = JToken.FromObject(((Version)value).ToString(2).ToLower()); 12 | token.WriteTo(writer); 13 | } 14 | 15 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 16 | { 17 | JToken token = JToken.Load(reader); 18 | string value = token.Value(); 19 | var v = Version.Parse(value); 20 | return new Version(v.Major, v.Minor); 21 | } 22 | 23 | public override bool CanConvert(Type objectType) 24 | { 25 | return objectType == typeof(Version); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/VersionComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace ModMyFactory 6 | { 7 | sealed class VersionComparer : IComparer, IComparer, IComparer 8 | { 9 | public int Compare(Version x, Version y) 10 | { 11 | if ((x == null) && (y == null)) 12 | { 13 | return 0; 14 | } 15 | else if (x == null) 16 | { 17 | return -1; 18 | } 19 | else if (y == null) 20 | { 21 | return 1; 22 | } 23 | else 24 | { 25 | return x.CompareTo(y); 26 | } 27 | } 28 | 29 | public int Compare(GameCompatibleVersion x, GameCompatibleVersion y) 30 | { 31 | if ((x == null) && (y == null)) 32 | { 33 | return 0; 34 | } 35 | else if (x == null) 36 | { 37 | return -1; 38 | } 39 | else if (y == null) 40 | { 41 | return 1; 42 | } 43 | else 44 | { 45 | return x.CompareTo(y); 46 | } 47 | } 48 | 49 | public int Compare(object x, object y) 50 | { 51 | if ((x is Version) && (y is Version)) 52 | { 53 | return Compare((Version)x, (Version)y); 54 | } 55 | else if ((x is GameCompatibleVersion) && (y is GameCompatibleVersion)) 56 | { 57 | return Compare((GameCompatibleVersion)x, (GameCompatibleVersion)y); 58 | } 59 | else 60 | { 61 | throw new ArgumentException("Parameters need to be of type Version."); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ViewModels/AboutViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Text; 4 | using WPFCore; 5 | using WPFCore.Commands; 6 | 7 | namespace ModMyFactory.ViewModels 8 | { 9 | sealed class AboutViewModel : ViewModelBase 10 | { 11 | public string VersionString 12 | { 13 | get 14 | { 15 | var sb = new StringBuilder(); 16 | sb.Append('v'); 17 | sb.Append(App.Version); 18 | 19 | #if PORTABLE 20 | sb.Append(" portable"); 21 | #endif 22 | 23 | return sb.ToString(); 24 | } 25 | } 26 | 27 | public bool PageState { get; private set; } 28 | 29 | public Uri PageUri { get; private set; } 30 | 31 | public RelayCommand SwitchPageCommand { get; } 32 | 33 | public AboutViewModel() 34 | { 35 | PageUri = new Uri("AboutPage.xaml", UriKind.Relative); 36 | SwitchPageCommand = new RelayCommand(SwitchPage); 37 | } 38 | 39 | private void SwitchPage() 40 | { 41 | if (PageState) 42 | { 43 | PageUri = new Uri("AboutPage.xaml", UriKind.Relative); 44 | } 45 | else 46 | { 47 | PageUri = new Uri("ChangelogPage.xaml", UriKind.Relative); 48 | } 49 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(PageUri))); 50 | 51 | PageState = !PageState; 52 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(PageState))); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ViewModels/ChangelogPageViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using WPFCore; 3 | 4 | namespace ModMyFactory.ViewModels 5 | { 6 | sealed class ChangelogPageViewModel : ViewModelBase 7 | { 8 | static ChangelogPageViewModel instance; 9 | 10 | public static ChangelogPageViewModel Instance => instance ?? (instance = new ChangelogPageViewModel()); 11 | 12 | public string Changelog { get; } 13 | 14 | private ChangelogPageViewModel() 15 | { 16 | if (!App.IsInDesignMode) 17 | { 18 | string changelogPath = Path.Combine(App.Instance.ApplicationDirectoryPath, "Changelog.txt"); 19 | var changelogFile = new FileInfo(changelogPath); 20 | 21 | if (changelogFile.Exists) 22 | { 23 | using (var reader = changelogFile.OpenText()) 24 | Changelog = reader.ReadToEnd(); 25 | } 26 | else 27 | { 28 | Changelog = string.Empty; 29 | } 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ViewModels/CopyOrMoveViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using ModMyFactory.Models; 3 | using WPFCore; 4 | 5 | namespace ModMyFactory.ViewModels 6 | { 7 | class CopyOrMoveViewModel : ViewModelBase 8 | { 9 | CopyOrMoveType copyOrMoveType; 10 | 11 | public CopyOrMoveType CopyOrMoveType 12 | { 13 | get { return copyOrMoveType; } 14 | set 15 | { 16 | if (value != copyOrMoveType) 17 | { 18 | copyOrMoveType = value; 19 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(CopyOrMoveType))); 20 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(Message))); 21 | } 22 | } 23 | } 24 | 25 | public string Message 26 | { 27 | get 28 | { 29 | switch (CopyOrMoveType) 30 | { 31 | case CopyOrMoveType.Factorio: 32 | return App.Instance.GetLocalizedResourceString("CopyOrMoveFactorioMessage"); 33 | case CopyOrMoveType.Mods: 34 | return App.Instance.GetLocalizedResourceString("CopyOrMoveModsMessage"); 35 | case CopyOrMoveType.Mod: 36 | return App.Instance.GetLocalizedResourceString("CopyOrMoveModMessage"); 37 | default: 38 | return string.Empty; 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ViewModels/ModUpdateViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using System.Windows.Data; 4 | using ModMyFactory.Models; 5 | using ModMyFactory.MVVM.Sorters; 6 | using WPFCore; 7 | 8 | namespace ModMyFactory.ViewModels 9 | { 10 | class ModUpdateViewModel : ViewModelBase 11 | { 12 | ListCollectionView modsView; 13 | List modsToUpdate; 14 | 15 | public ListCollectionView ModsView 16 | { 17 | get { return modsView; } 18 | private set 19 | { 20 | if (value != modsView) 21 | { 22 | modsView = value; 23 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(ModsView))); 24 | } 25 | } 26 | } 27 | 28 | public List ModsToUpdate 29 | { 30 | get { return modsToUpdate; } 31 | set 32 | { 33 | if (value != modsToUpdate) 34 | { 35 | modsToUpdate = value; 36 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(ModsToUpdate))); 37 | 38 | ModsView = (ListCollectionView)(new CollectionViewSource() { Source = modsToUpdate }).View; 39 | ModsView.CustomSort = new ModUpdateInfoSorter(); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/ViewModels/UpdateListViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using System.Windows.Data; 4 | using ModMyFactory.Models; 5 | using ModMyFactory.MVVM.Sorters; 6 | using WPFCore; 7 | 8 | namespace ModMyFactory.ViewModels 9 | { 10 | sealed class UpdateListViewModel : ViewModelBase 11 | { 12 | ListCollectionView updateTargetsView; 13 | List updateTargets; 14 | UpdateTarget selectedTarget; 15 | bool canUpdate; 16 | 17 | public ListCollectionView UpdateTargetsView 18 | { 19 | get { return updateTargetsView; } 20 | private set 21 | { 22 | updateTargetsView = value; 23 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(UpdateTargetsView))); 24 | } 25 | } 26 | 27 | public List UpdateTargets 28 | { 29 | get { return updateTargets; } 30 | set 31 | { 32 | if (value != updateTargets) 33 | { 34 | updateTargets = value; 35 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(UpdateTargets))); 36 | 37 | UpdateTargetsView = (ListCollectionView)CollectionViewSource.GetDefaultView(UpdateTargets); 38 | UpdateTargetsView.CustomSort = new UpdateTargetSorter(); 39 | } 40 | } 41 | } 42 | 43 | public UpdateTarget SelectedTarget 44 | { 45 | get { return selectedTarget; } 46 | set 47 | { 48 | if (value != selectedTarget) 49 | { 50 | selectedTarget = value; 51 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(SelectedTarget))); 52 | CanUpdate = selectedTarget != null; 53 | } 54 | } 55 | } 56 | 57 | public bool CanUpdate 58 | { 59 | get { return canUpdate; } 60 | private set 61 | { 62 | if (value != canUpdate) 63 | { 64 | canUpdate = value; 65 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(CanUpdate))); 66 | } 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/AboutPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace ModMyFactory.Views 17 | { 18 | /// 19 | /// Interaktionslogik für AboutPage.xaml 20 | /// 21 | public partial class AboutPage : Page 22 | { 23 | public AboutPage() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/AboutWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Views 2 | { 3 | partial class AboutWindow 4 | { 5 | public AboutWindow() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/ChangelogPage.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/ChangelogPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace ModMyFactory.Views 17 | { 18 | /// 19 | /// Interaktionslogik für ChangelogPage.xaml 20 | /// 21 | public partial class ChangelogPage : Page 22 | { 23 | public ChangelogPage() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/CopyOrMoveMessageWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace ModMyFactory.Views 4 | { 5 | partial class CopyOrMoveMessageWindow 6 | { 7 | public CopyOrMoveMessageWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | public bool Move { get; private set; } 13 | 14 | private void CopyButtonClickHandler(object sender, RoutedEventArgs e) 15 | { 16 | DialogResult = true; 17 | Move = false; 18 | Close(); 19 | } 20 | 21 | private void MoveButtonClickHandler(object sender, RoutedEventArgs e) 22 | { 23 | DialogResult = true; 24 | Move = true; 25 | Close(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/DependencyDownloadWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace ModMyFactory.Views 4 | { 5 | partial class DependencyDownloadWindow 6 | { 7 | public DependencyDownloadWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void DownloadButtonClickHandler(object sender, RoutedEventArgs e) 13 | { 14 | DialogResult = true; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/LinkPropertiesWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Linq; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | using System.Windows.Media; 7 | 8 | namespace ModMyFactory.Views 9 | { 10 | internal partial class LinkPropertiesWindow 11 | { 12 | public LinkPropertiesWindow() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void CreateButtonClickHandler(object sender, RoutedEventArgs e) 18 | { 19 | DialogResult = true; 20 | } 21 | 22 | private void ModpackListBoxPreviewMouseDownHandler(object sender, MouseButtonEventArgs e) 23 | { 24 | ListBox listBox = sender as ListBox; 25 | if (listBox == null) return; 26 | 27 | if (e.ChangedButton != MouseButton.Left) 28 | return; 29 | 30 | int itemCount = ((ICollectionView)listBox.ItemsSource).Cast().Count(); 31 | ListBoxItem item = null; 32 | for (int i = 0; i < itemCount; i++) 33 | { 34 | item = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i); 35 | if (VisualTreeHelper.GetDescendantBounds(item).Contains(e.GetPosition(item))) 36 | break; 37 | item = null; 38 | } 39 | 40 | if (item == null) listBox.SelectedItem = null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/LoginWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace ModMyFactory.Views 4 | { 5 | partial class LoginWindow 6 | { 7 | public LoginWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void OKButtonClickHandler(object sender, RoutedEventArgs e) 13 | { 14 | DialogResult = true; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/ModSettingsWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Views 2 | { 3 | partial class ModSettingsWindow 4 | { 5 | public ModSettingsWindow() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/ModUpdateWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace ModMyFactory.Views 4 | { 5 | partial class ModUpdateWindow 6 | { 7 | public ModUpdateWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void UpdateButtonClickHandler(object sender, RoutedEventArgs e) 13 | { 14 | DialogResult = true; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/ModpackExportWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Linq; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | using System.Windows.Media; 7 | 8 | namespace ModMyFactory.Views 9 | { 10 | partial class ModpackExportWindow 11 | { 12 | const int DefaultWidth = 700, DefaultHeight = 800; 13 | 14 | public ModpackExportWindow() 15 | : base(App.Instance.Settings.ModpackExportWindowInfo, DefaultWidth, DefaultHeight) 16 | { 17 | InitializeComponent(); 18 | 19 | Closing += ClosingHandler; 20 | } 21 | 22 | private void ClosingHandler(object sender, CancelEventArgs e) 23 | { 24 | App.Instance.Settings.ModpackExportWindowInfo = CreateInfo(); 25 | App.Instance.Settings.Save(); 26 | } 27 | 28 | private void ExportButtonClickHandler(object sender, RoutedEventArgs e) 29 | { 30 | DialogResult = true; 31 | } 32 | 33 | private void ModpackListBoxPreviewMouseDownHandler(object sender, MouseButtonEventArgs e) 34 | { 35 | ListBox listBox = sender as ListBox; 36 | if (listBox == null) return; 37 | 38 | if (e.ChangedButton != MouseButton.Left) 39 | return; 40 | 41 | int itemCount = ((ICollectionView)listBox.ItemsSource).Cast().Count(); 42 | ListBoxItem item = null; 43 | for (int i = 0; i < itemCount; i++) 44 | { 45 | item = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i); 46 | if (VisualTreeHelper.GetDescendantBounds(item).Contains(e.GetPosition(item))) 47 | break; 48 | item = null; 49 | } 50 | 51 | if (item == null) listBox.SelectedItem = null; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/OnlineModsWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace ModMyFactory.Views 4 | { 5 | partial class OnlineModsWindow 6 | { 7 | const int DefaultWidth = 800, DefaultHeight = 600; 8 | 9 | public OnlineModsWindow() 10 | : base(App.Instance.Settings.OnlineModsWindowInfo, DefaultWidth, DefaultHeight) 11 | { 12 | InitializeComponent(); 13 | 14 | Closing += ClosingHandler; 15 | } 16 | 17 | private void ClosingHandler(object sender, CancelEventArgs e) 18 | { 19 | App.Instance.Settings.OnlineModsWindowInfo = CreateInfo(); 20 | App.Instance.Settings.Save(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/ProgressWindow.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/ProgressWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Shell; 3 | using ModMyFactory.Helpers; 4 | using ModMyFactory.ViewModels; 5 | using ModMyFactory.Win32; 6 | 7 | namespace ModMyFactory.Views 8 | { 9 | partial class ProgressWindow 10 | { 11 | public ProgressWindow() 12 | { 13 | InitializeComponent(); 14 | 15 | Loaded += LoadedHandler; 16 | Closing += ClosingHandler; 17 | } 18 | 19 | private void LoadedHandler(object sender, EventArgs e) 20 | { 21 | IntPtr handle = this.Handle(); 22 | IntPtr windowLong = User32.GetWindowLong(handle, WindowLongIndex.Style); 23 | windowLong = (IntPtr)(windowLong.ToInt64() & (long)~WindowStyles.SystemMenu); 24 | User32.SetWindowLong(handle, WindowLongIndex.Style, windowLong); 25 | 26 | var viewModel = (ProgressViewModel)ViewModel; 27 | TaskbarItemInfo = new TaskbarItemInfo 28 | { 29 | ProgressState = viewModel.IsIndeterminate ? TaskbarItemProgressState.Indeterminate : TaskbarItemProgressState.Normal, 30 | ProgressValue = viewModel.Progress, 31 | }; 32 | } 33 | 34 | private void ClosingHandler(object sender, EventArgs e) 35 | { 36 | TaskbarItemInfo.ProgressValue = 0; 37 | TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; 38 | TaskbarItemInfo = null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/SettingsWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace ModMyFactory.Views 4 | { 5 | partial class SettingsWindow 6 | { 7 | public SettingsWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | private void LoadedHandler(object sender, RoutedEventArgs e) 13 | { 14 | TabControl.SelectedIndex = 0; 15 | } 16 | 17 | private void OKButtonClickHandler(object sender, RoutedEventArgs e) 18 | { 19 | DialogResult = true; 20 | } 21 | 22 | private void SaveCredentialsBoxCheckedHandler(object sender, RoutedEventArgs e) 23 | { 24 | UsernameBox.Text = GlobalCredentials.Instance.Username; 25 | } 26 | 27 | private void SaveCredentialsBoxUncheckedHandler(object sender, RoutedEventArgs e) 28 | { 29 | UsernameBox.Text = null; 30 | PasswordBox.Password = null; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/UpdateListWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Linq; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | using System.Windows.Media; 7 | 8 | namespace ModMyFactory.Views 9 | { 10 | partial class UpdateListWindow 11 | { 12 | public UpdateListWindow() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void UpdateButtonClickHandler(object sender, RoutedEventArgs e) 18 | { 19 | DialogResult = true; 20 | } 21 | 22 | private void UpdateListBoxPreviewMouseDownHandler(object sender, MouseButtonEventArgs e) 23 | { 24 | ListBox listBox = sender as ListBox; 25 | if (listBox == null) return; 26 | 27 | if (e.ChangedButton != MouseButton.Left) 28 | return; 29 | 30 | ListBoxItem item = null; 31 | int itemCount = ((ICollectionView)listBox.ItemsSource).Cast().Count(); 32 | for (int i = 0; i < itemCount; i++) 33 | { 34 | item = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i); 35 | if (VisualTreeHelper.GetDescendantBounds(item).Contains(e.GetPosition(item))) 36 | break; 37 | item = null; 38 | } 39 | 40 | if (item == null) listBox.SelectedItem = null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/UpdateNotificationWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Web; 2 | using System.Net; 3 | using System.Threading.Tasks; 4 | using System.Windows; 5 | 6 | namespace ModMyFactory.Views 7 | { 8 | partial class UpdateNotificationWindow 9 | { 10 | public ExtendedVersion Version { get; } 11 | 12 | public bool CanAuto { get; } 13 | 14 | public bool Auto { get; private set; } 15 | 16 | public UpdateNotificationWindow() 17 | { 18 | InitializeComponent(); 19 | 20 | this.Loaded += WindowLoadedHandler; 21 | Version = new ExtendedVersion(1, 0); 22 | DataContext = this; 23 | CanAuto = false; 24 | } 25 | 26 | public UpdateNotificationWindow(ExtendedVersion version, bool canAuto) 27 | { 28 | InitializeComponent(); 29 | 30 | this.Loaded += WindowLoadedHandler; 31 | Version = version; 32 | DataContext = this; 33 | CanAuto = canAuto; 34 | } 35 | 36 | private void ManualButtonClickHandler(object sender, RoutedEventArgs e) 37 | { 38 | DialogResult = true; 39 | Auto = false; 40 | } 41 | 42 | private void AutoButtonClickHandler(object sender, RoutedEventArgs e) 43 | { 44 | DialogResult = true; 45 | Auto = true; 46 | } 47 | 48 | private static async Task DownloadChangelogAsync(ExtendedVersion version) 49 | { 50 | const string changelogUrl = "https://raw.githubusercontent.com/Artentus/ModMyFactory/master/CHANGELOG.md"; 51 | string document = string.Empty; 52 | 53 | try 54 | { 55 | document = await Task.Run(() => WebHelper.GetDocument(changelogUrl)); 56 | 57 | int i = document.IndexOf($"#### {version}"); 58 | if (i >= 0) document = document.Substring(i); 59 | } 60 | catch (WebException) 61 | { } 62 | 63 | return document; 64 | } 65 | 66 | private async void WindowLoadedHandler(object sender, RoutedEventArgs e) 67 | { 68 | ChangelogTextBlock.Text = await DownloadChangelogAsync(Version); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Views/VersionListWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Data; 5 | using System.Windows.Input; 6 | using System.Windows.Media; 7 | 8 | namespace ModMyFactory.Views 9 | { 10 | partial class VersionListWindow 11 | { 12 | public VersionListWindow() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void DownloadButtonClickHandler(object sender, RoutedEventArgs e) 18 | { 19 | DialogResult = true; 20 | } 21 | 22 | private void VersionListBoxPreviewMouseDownHandler(object sender, MouseButtonEventArgs e) 23 | { 24 | ListBox listBox = sender as ListBox; 25 | if (listBox == null) return; 26 | 27 | if (e.ChangedButton != MouseButton.Left) 28 | return; 29 | 30 | ListBoxItem item = null; 31 | int itemCount = ((ICollection)((ListCollectionView)listBox.ItemsSource).SourceCollection).Count; 32 | for (int i = 0; i < itemCount; i++) 33 | { 34 | item = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i); 35 | if (VisualTreeHelper.GetDescendantBounds(item).Contains(e.GetPosition(item))) 36 | break; 37 | item = null; 38 | } 39 | 40 | if (item == null) listBox.SelectedItem = null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ApiAuthentication.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Security; 4 | using System.Text; 5 | using System.Web; 6 | using ModMyFactory.Helpers; 7 | using ModMyFactory.Web.AuthenticationApi; 8 | 9 | namespace ModMyFactory.Web 10 | { 11 | static class ApiAuthentication 12 | { 13 | /// 14 | /// Logs in at the api. 15 | /// 16 | /// The username. 17 | /// The users password. 18 | /// Out. The login token generated by the server and the users name. 19 | /// Returns false if the login failed, otherwise true. 20 | public static bool LogIn(string username, SecureString password, out AuthenticationInfo info) 21 | { 22 | const string loginPage = "https://auth.factorio.com/api-login"; 23 | 24 | info = null; 25 | 26 | string part1 = $"api_version=2&require_game_ownership=true&username={username}&password="; 27 | int part1Length = Encoding.UTF8.GetByteCount(part1); 28 | 29 | byte[] passwordBytes = SecureStringHelper.SecureStringToBytes(password); 30 | string part2 = HttpUtility.UrlEncode(passwordBytes); 31 | 32 | byte[] content = new byte[part1Length + part2.Length]; 33 | Encoding.UTF8.GetBytes(part1, 0, part1.Length, content, 0); 34 | Encoding.UTF8.GetBytes(part2, 0, part2.Length, content, part1Length); 35 | 36 | try 37 | { 38 | string document = WebHelper.GetDocument(loginPage, content); 39 | if (string.IsNullOrWhiteSpace(document)) return false; 40 | 41 | info = JsonHelper.Deserialize(document); 42 | if ((info == null) || string.IsNullOrWhiteSpace(info.Token) || string.IsNullOrWhiteSpace(info.Username)) return false; 43 | 44 | return true; 45 | } 46 | catch (WebException ex) 47 | { 48 | if (ex.Status == WebExceptionStatus.ProtocolError) return false; 49 | else throw; 50 | } 51 | finally 52 | { 53 | SecureStringHelper.DestroySecureByteArray(content); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/AuthenticationApi/AuthenticationInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.Web.AuthenticationApi 4 | { 5 | [JsonObject(MemberSerialization.OptOut)] 6 | sealed class AuthenticationInfo 7 | { 8 | [JsonProperty("token")] 9 | public string Token { get; set; } 10 | 11 | [JsonProperty("username")] 12 | public string Username { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/FactorioOnlineVersion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using WPFCore; 3 | 4 | namespace ModMyFactory.Web 5 | { 6 | sealed class FactorioOnlineVersion : NotifyPropertyChangedBase 7 | { 8 | private static string GetBranch(Version version) 9 | { 10 | if (version.Major == 0) return "alpha"; 11 | 12 | return string.Empty; // Unknown yet, wait for 1.0 release 13 | } 14 | 15 | 16 | public Version Version { get; } 17 | 18 | public bool IsExperimental { get; } 19 | 20 | public string DownloadUrl { get; } 21 | 22 | public FactorioOnlineVersion(Version version, bool isExperimental) 23 | { 24 | Version = version; 25 | IsExperimental = isExperimental; 26 | 27 | string versionString = version.ToString(3); 28 | string branch = GetBranch(version); 29 | string platformString = Environment.Is64BitOperatingSystem ? "win64-manual" : "win32-manual"; 30 | DownloadUrl = $"https://www.factorio.com/get-download/{versionString}/{branch}/{platformString}"; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/ApiPage.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.Web.ModApi 4 | { 5 | [JsonObject(MemberSerialization.OptOut)] 6 | sealed class ApiPage 7 | { 8 | [JsonProperty("pagination")] 9 | public PageInfo Info { get; set; } 10 | 11 | [JsonProperty("results")] 12 | public ModInfo[] Mods { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/ExtendedModInfo.cs: -------------------------------------------------------------------------------- 1 | using ModMyFactory.Helpers; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Linq; 5 | 6 | namespace ModMyFactory.Web.ModApi 7 | { 8 | [JsonObject(MemberSerialization.OptIn)] 9 | sealed class ExtendedModInfo : ModInfo 10 | { 11 | private static Uri BaseDataUri { get; } 12 | 13 | static ExtendedModInfo() 14 | { 15 | const string dataUrl = "https://mods-data.factorio.com"; 16 | BaseDataUri = new Uri(dataUrl, UriKind.Absolute); 17 | } 18 | 19 | 20 | [JsonProperty("releases")] 21 | public ModRelease[] Releases { get; set; } 22 | 23 | [JsonProperty("description")] 24 | public string Description { get; set; } 25 | 26 | [JsonProperty("homepage")] 27 | public string Homepage { get; set; } 28 | 29 | [JsonProperty("github_path")] 30 | public string GitHubUrl { get; set; } 31 | 32 | [JsonProperty("license")] 33 | public LicenseInfo License { get; set; } 34 | 35 | [JsonProperty("changelog")] 36 | public string Changelog { get; set; } 37 | 38 | [JsonProperty("faq")] 39 | public string Faq { get; set; } 40 | 41 | [JsonProperty("thumbnail")] 42 | public string ThumbnailUrl { get; set; } 43 | 44 | public override ModRelease LatestRelease { get => GetLatestRelease(); set => base.LatestRelease = value; } 45 | 46 | public ModRelease GetLatestRelease(Version factorioVersion = null) 47 | { 48 | if (factorioVersion == null) 49 | return Releases.MaxBy(release => release.Version, new VersionComparer()); 50 | else 51 | return Releases.Where(release => release.InfoFile.FactorioVersion == factorioVersion).MaxBy(release => release.Version, new VersionComparer()); 52 | } 53 | 54 | public Uri GetFullThumbnailUri() 55 | { 56 | if (string.IsNullOrEmpty(ThumbnailUrl)) return null; 57 | if (ThumbnailUrl.EndsWith("/.thumb.png")) return null; 58 | return new Uri(BaseDataUri, ThumbnailUrl); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/InfoFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace ModMyFactory.Web.ModApi 5 | { 6 | sealed class InfoFile 7 | { 8 | [JsonProperty("factorio_version")] 9 | [JsonConverter(typeof(TwoPartVersionConverter))] 10 | public Version FactorioVersion { get; set; } 11 | 12 | [JsonProperty("dependencies")] 13 | [JsonConverter(typeof(SingleOrArrayJsonConverter))] 14 | public string[] Dependencies { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/LicenseInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.Web.ModApi 4 | { 5 | [JsonObject(MemberSerialization.OptOut)] 6 | sealed class LicenseInfo 7 | { 8 | [JsonProperty("name")] 9 | public string Name { get; set; } 10 | 11 | [JsonProperty("url")] 12 | public string Url { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/ModInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.Web.ModApi 4 | { 5 | [JsonObject(MemberSerialization.OptOut)] 6 | class ModInfo 7 | { 8 | [JsonProperty("title")] 9 | public string Title { get; set; } 10 | 11 | [JsonProperty("downloads_count")] 12 | public int DownloadCount { get; set; } 13 | 14 | [JsonProperty("name")] 15 | public string Name { get; set; } 16 | 17 | [JsonProperty("summary")] 18 | public string Summary { get; set; } 19 | 20 | [JsonProperty("owner")] 21 | public string Author { get; set; } 22 | 23 | [JsonProperty("score")] 24 | public double Score { get; set; } 25 | 26 | [JsonProperty("latest_release")] 27 | public virtual ModRelease LatestRelease { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/ModRelease.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using Newtonsoft.Json; 4 | using WPFCore; 5 | 6 | namespace ModMyFactory.Web.ModApi 7 | { 8 | [JsonObject(MemberSerialization.OptIn)] 9 | sealed class ModRelease : NotifyPropertyChangedBase 10 | { 11 | [JsonProperty("version")] 12 | [JsonConverter(typeof(GameVersionConverter))] 13 | public GameCompatibleVersion Version { get; set; } 14 | 15 | [JsonProperty("download_url")] 16 | public string DownloadUrl { get; set; } 17 | 18 | [JsonProperty("file_name")] 19 | public string FileName { get; set; } 20 | 21 | [JsonProperty("released_at")] 22 | public DateTime ReleaseDate { get; set; } 23 | 24 | [JsonProperty("info_json")] 25 | public InfoFile InfoFile { get; set; } 26 | 27 | 28 | bool isInstalled; 29 | 30 | public bool IsInstalled 31 | { 32 | get { return isInstalled; } 33 | set 34 | { 35 | if (value != isInstalled) 36 | { 37 | isInstalled = value; 38 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsInstalled))); 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/PageInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.Web.ModApi 4 | { 5 | [JsonObject(MemberSerialization.OptOut)] 6 | sealed class PageInfo 7 | { 8 | [JsonProperty("page_count")] 9 | public int PageCount { get; set; } 10 | 11 | [JsonProperty("page")] 12 | public int PageNumber { get; set; } 13 | 14 | [JsonProperty("count")] 15 | public int ModCount { get; set; } 16 | 17 | [JsonProperty("page_size")] 18 | public int ModsOnPage { get; set; } 19 | 20 | [JsonProperty("links")] 21 | public PageLinks Links { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/ModApi/PageLinks.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.Web.ModApi 4 | { 5 | [JsonObject(MemberSerialization.OptOut)] 6 | sealed class PageLinks 7 | { 8 | [JsonProperty("prev")] 9 | public string PreviousPage { get; set; } 10 | 11 | [JsonProperty("next")] 12 | public string NextPage { get; set; } 13 | 14 | [JsonProperty("first")] 15 | public string FirstPage { get; set; } 16 | 17 | [JsonProperty("last")] 18 | public string LastPage { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/UpdateApi/Package.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace ModMyFactory.Web.UpdateApi 7 | { 8 | sealed class Package : IReadOnlyList 9 | { 10 | readonly List updateSteps; 11 | 12 | public int Count => updateSteps.Count; 13 | 14 | public UpdateStep this[int index] => updateSteps[index]; 15 | 16 | public Package(UpdateStepTemplate[] templates) 17 | { 18 | updateSteps = new List(templates.Length); 19 | 20 | Version stableVersion = templates.FirstOrDefault(template => template.Stable != null)?.Stable; 21 | foreach (var template in templates) 22 | { 23 | if (template.Stable == null) 24 | { 25 | bool isStable = (stableVersion != null) && (template.To == stableVersion); 26 | updateSteps.Add(new UpdateStep(template.From, template.To, isStable)); 27 | } 28 | } 29 | } 30 | 31 | public IEnumerator GetEnumerator() 32 | { 33 | return updateSteps.GetEnumerator(); 34 | } 35 | 36 | IEnumerator IEnumerable.GetEnumerator() 37 | { 38 | return GetEnumerator(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/UpdateApi/UpdateInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.Web.UpdateApi 4 | { 5 | sealed class UpdateInfo 6 | { 7 | public Package Package { get; } 8 | 9 | public UpdateInfo(UpdateInfoTemplate template) 10 | { 11 | Package = Environment.Is64BitOperatingSystem 12 | ? new Package(template.Win64Package) 13 | : new Package(template.Win32Package); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/UpdateApi/UpdateInfoTemplate.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace ModMyFactory.Web.UpdateApi 4 | { 5 | [JsonObject(MemberSerialization.OptOut)] 6 | sealed class UpdateInfoTemplate 7 | { 8 | [JsonProperty("core-win32")] 9 | public UpdateStepTemplate[] Win32Package { get; set; } 10 | 11 | [JsonProperty("core-win64")] 12 | public UpdateStepTemplate[] Win64Package { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/UpdateApi/UpdateStep.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.Web.UpdateApi 4 | { 5 | sealed class UpdateStep 6 | { 7 | public Version From { get; } 8 | 9 | public Version To { get; } 10 | 11 | public bool IsStable { get; } 12 | 13 | public UpdateStep(Version from, Version to, bool isStable) 14 | { 15 | From = from; 16 | To = to; 17 | IsStable = isStable; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Web/UpdateApi/UpdateStepTemplate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Converters; 4 | 5 | namespace ModMyFactory.Web.UpdateApi 6 | { 7 | [JsonObject(MemberSerialization.OptOut)] 8 | sealed class UpdateStepTemplate 9 | { 10 | [JsonProperty("from"), JsonConverter(typeof(VersionConverter))] 11 | public Version From { get; set; } 12 | 13 | [JsonProperty("to"), JsonConverter(typeof(VersionConverter))] 14 | public Version To { get; set; } 15 | 16 | [JsonProperty("stable"), JsonConverter(typeof(VersionConverter))] 17 | public Version Stable { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/ChangeNotifyEventId.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.Win32 4 | { 5 | [Flags] 6 | enum ChangeNotifyEventId 7 | { 8 | AllEvents = 0x7FFFFFFF, 9 | AssociationChanged = 0x08000000, 10 | Attributes = 0x00000800, 11 | Create = 0x00000002, 12 | Delete = 0x00000004, 13 | DriveAdd = 0x00000100, 14 | DriveAddGui = 0x00010000, 15 | DriveRemoved = 0x00000080, 16 | ExtendedEvent = 0x04000000, 17 | FreeSpace = 0x00040000, 18 | MediaInserted = 0x00000020, 19 | MediaRemoved = 0x00000040, 20 | MakeDirectory = 0x00000008, 21 | NetShare = 0x00000200, 22 | NetUnshare = 0x00000400, 23 | RenameFolder = 0x00020000, 24 | RenameItem = 0x00000001, 25 | RemoveDirectory = 0x00000010, 26 | ServerDisconnect = 0x00004000, 27 | UpdateDirectory = 0x00001000, 28 | UpdateImage = 0x00008000, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/ChangeNotifyFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.Win32 4 | { 5 | [Flags] 6 | public enum ChangeNotifyFlags 7 | { 8 | DWord = 0x0003, 9 | IdList = 0x0000, 10 | PathA = 0x0001, 11 | PathW = 0x0005, 12 | PrinterA = 0x0002, 13 | PrinterW = 0x0006, 14 | Flush = 0x1000, 15 | FlushNoWait = 0x2000 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/DeviceType.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Win32 2 | { 3 | enum DeviceType : uint 4 | { 5 | Beep = 0x00000001, 6 | CDRom = 0x00000002, 7 | CDRomFileSytem = 0x00000003, 8 | Controller = 0x00000004, 9 | Datalink = 0x00000005, 10 | Dfs = 0x00000006, 11 | Disk = 0x00000007, 12 | DiskFileSystem = 0x00000008, 13 | FileSystem = 0x00000009, 14 | InPortPort = 0x0000000a, 15 | Keyboard = 0x0000000b, 16 | Mailslot = 0x0000000c, 17 | MidiIn = 0x0000000d, 18 | MidiOut = 0x0000000e, 19 | Mouse = 0x0000000f, 20 | MultiUncProvider = 0x00000010, 21 | NamedPipe = 0x00000011, 22 | Network = 0x00000012, 23 | NetworkBrowser = 0x00000013, 24 | NetworkFileSystem = 0x00000014, 25 | Null = 0x00000015, 26 | ParallelPort = 0x00000016, 27 | PhysicalNetcard = 0x00000017, 28 | Printer = 0x00000018, 29 | Scanner = 0x00000019, 30 | SerialMousePort = 0x0000001a, 31 | SerialPort = 0x0000001b, 32 | Screen = 0x0000001c, 33 | Sound = 0x0000001d, 34 | Streams = 0x0000001e, 35 | Tape = 0x0000001f, 36 | TapeFileSystem = 0x00000020, 37 | Transport = 0x00000021, 38 | Unknown = 0x00000022, 39 | Video = 0x00000023, 40 | VirtualDisk = 0x00000024, 41 | WaveIn = 0x00000025, 42 | WaveOut = 0x00000026, 43 | Port8042 = 0x00000027, 44 | NetworkRedirector = 0x00000028, 45 | Battery = 0x00000029, 46 | BusExtender = 0x0000002a, 47 | Modem = 0x0000002b, 48 | Vdm = 0x0000002c, 49 | MassStorage = 0x0000002d, 50 | Smb = 0x0000002e, 51 | Ks = 0x0000002f, 52 | Changer = 0x00000030, 53 | Smartcard = 0x00000031, 54 | Acpi = 0x00000032, 55 | Dvd = 0x00000033, 56 | FullscreenVideo = 0x00000034, 57 | DfsFileSystem = 0x00000035, 58 | DfsVolume = 0x00000036, 59 | Serenum = 0x00000037, 60 | Termsrv = 0x00000038, 61 | Ksec = 0x00000039, 62 | Fips = 0x0000003A, 63 | Infiniband = 0x0000003B, 64 | Vmbus = 0x0000003E, 65 | CryptProvider = 0x0000003F, 66 | Wpd = 0x00000040, 67 | Bluetooth = 0x00000041, 68 | MtComposite = 0x00000042, 69 | MtTransport = 0x00000043, 70 | Biometric = 0x00000044, 71 | Pmi = 0x00000045, 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/GenericAccessRights.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.Win32 4 | { 5 | /// 6 | /// You can use generic access rights to specify the type of access you need when you are opening a handle to an object. 7 | /// This is typically simpler than specifying all the corresponding standard and specific rights. 8 | /// 9 | [Flags] 10 | enum GenericAccessRights : uint 11 | { 12 | /// 13 | /// Read access. 14 | /// 15 | Read = 0x80000000, 16 | 17 | /// 18 | /// Write access. 19 | /// 20 | Write = 0x40000000, 21 | 22 | /// 23 | /// Execute access. 24 | /// 25 | Execute = 0x20000000, 26 | 27 | /// 28 | /// All possible access rights. 29 | /// 30 | All = 0x10000000, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/IOMethod.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Win32 2 | { 3 | enum IOMethod : uint 4 | { 5 | Buffered = 0, 6 | InDirect = 1, 7 | OutDirect = 2, 8 | Neither = 3, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/Luid.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace ModMyFactory.Win32 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | struct Luid 7 | { 8 | public uint Low; 9 | public int High; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/Privilege.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace ModMyFactory.Win32 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | struct Privilege 7 | { 8 | public const int EnabledAttribute = 2; 9 | 10 | public Luid Luid; 11 | public int Attributes; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/Shell32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace ModMyFactory.Win32 5 | { 6 | static class Shell32 7 | { 8 | [DllImport("shell32.dll", EntryPoint = "SHChangeNotify")] 9 | public static extern void ChangeNotify(ChangeNotifyEventId eventId, ChangeNotifyFlags flags, IntPtr item1, IntPtr item2); 10 | 11 | public static void ChangeNotify(ChangeNotifyEventId eventId, ChangeNotifyFlags flags) 12 | { 13 | ChangeNotify(eventId, flags, IntPtr.Zero, IntPtr.Zero); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/StandardAccessRights.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ModMyFactory.Win32 4 | { 5 | /// 6 | /// Standard rights. Contains the object's standard access rights. 7 | /// 8 | [Flags] 9 | enum StandardAccessRights : uint 10 | { 11 | /// 12 | /// Delete access. 13 | /// 14 | Delete = 0x00010000, 15 | 16 | /// 17 | /// Read access to the owner, group, and discretionary access control list (DACL) of the security descriptor. 18 | /// 19 | ReadControl = 0x00020000, 20 | 21 | /// 22 | /// Write access to the discretionary access control list (DACL). 23 | /// 24 | WriteDAC = 0x00040000, 25 | 26 | /// 27 | /// Write access to owner. 28 | /// 29 | WriteOwner = 0x00080000, 30 | 31 | /// 32 | /// Synchronize access. 33 | /// 34 | Synchronize = 0x00100000, 35 | 36 | 37 | /// 38 | /// Read access. 39 | /// 40 | Read = ReadControl, 41 | 42 | /// 43 | /// Write access. 44 | /// 45 | Write = ReadControl, 46 | 47 | /// 48 | /// Execute access. 49 | /// 50 | Execute = ReadControl, 51 | 52 | 53 | /// 54 | /// Delete, ReadControl, WriteDAC and WriteOwner. 55 | /// 56 | Required = Delete | ReadControl | WriteDAC | WriteOwner, 57 | 58 | /// 59 | /// Delete, ReadControl, WriteDAC, WriteOwner and Synchronize. 60 | /// 61 | All = Delete | ReadControl | WriteDAC | WriteOwner | Synchronize, 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/TokenPrivileges.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace ModMyFactory.Win32 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | struct TokenPrivileges 7 | { 8 | public int PrivilegeCount; 9 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] 10 | public Privilege[] Privileges; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Win32/WindowLongIndex.cs: -------------------------------------------------------------------------------- 1 | namespace ModMyFactory.Win32 2 | { 3 | enum WindowLongIndex 4 | { 5 | /// 6 | /// Retrieves the extended window styles. 7 | /// 8 | ExtendedStyle = -20, 9 | 10 | /// 11 | /// Retrieves a handle to the application instance. 12 | /// 13 | ApplicationHandle = -6, 14 | 15 | /// 16 | /// Retrieves a handle to the parent window, if any. 17 | /// 18 | ParentHandle = -8, 19 | 20 | /// 21 | /// Retrieves the identifier of the window. 22 | /// 23 | Id = -12, 24 | 25 | /// 26 | /// Retrieves the window styles. 27 | /// 28 | Style = -16, 29 | 30 | /// 31 | /// Retrieves the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero. 32 | /// 33 | Userdata = -21, 34 | 35 | /// 36 | /// Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. 37 | /// 38 | WndProc = -4, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Xdelta/xdelta.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Xdelta/xdelta.dll -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Zlib/Crc32Checksum.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace ModMyFactory.Zlib 4 | { 5 | static class Crc32Checksum 6 | { 7 | public static uint Generate(byte[] data, int offset, int count) 8 | { 9 | var generator = new Crc32ChecksumGenerator(); 10 | generator.Update(data, offset, count); 11 | return generator.CurrentChecksum; 12 | } 13 | 14 | public static uint Generate(byte[] data) 15 | { 16 | var generator = new Crc32ChecksumGenerator(); 17 | generator.Update(data); 18 | return generator.CurrentChecksum; 19 | } 20 | 21 | public static uint Generate(Stream data, long byteCount) 22 | { 23 | var generator = new Crc32ChecksumGenerator(); 24 | generator.Update(data, byteCount); 25 | return generator.CurrentChecksum; 26 | } 27 | 28 | public static uint Generate(Stream data) 29 | { 30 | var generator = new Crc32ChecksumGenerator(); 31 | generator.Update(data); 32 | return generator.CurrentChecksum; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Zlib/zlib32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Zlib/zlib32.dll -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/Zlib/zlib64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Artentus/ModMyFactory/cf92c5efc09f251e9c9f996f6cf40b234b8b0fb4/ModMyFactory/ModMyFactory/Zlib/zlib64.dll -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | PerMonitor 42 | true 43 | true 44 | 45 | 46 | 47 | 48 | 49 | 50 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /ModMyFactory/ModMyFactory/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ModMyFactory/Updater/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ModMyFactory/Updater/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // Allgemeine Informationen über eine Assembly werden über die folgenden 7 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 8 | // die einer Assembly zugeordnet sind. 9 | [assembly: AssemblyTitle("Updater")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("ModMyFactory Updater")] 14 | [assembly: AssemblyCopyright("Copyright © Mathis Rech 2019")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly 19 | // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von 20 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. 21 | [assembly: ComVisible(false)] 22 | 23 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 24 | [assembly: Guid("b7018fdd-c8e7-41ae-b84f-ccba7ed61620")] 25 | 26 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 27 | // 28 | // Hauptversion 29 | // Nebenversion 30 | // Buildnummer 31 | // Revision 32 | // 33 | // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, 34 | // übernehmen, indem Sie "*" eingeben: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.0")] 37 | [assembly: AssemblyFileVersion("1.0.0.0")] 38 | [assembly: NeutralResourcesLanguage("en")] 39 | 40 | -------------------------------------------------------------------------------- /ModMyFactory/Updater/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------