diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..12dde44 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.git* export-ignore +Source/ export-ignore \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..702ea6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,304 @@ + +# Created by https://www.gitignore.io/api/visualstudio,visualstudiocode + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# End of https://www.gitignore.io/api/visualstudio,visualstudiocode + +Source\TODO.md +Assemblies\0Reloader.dll diff --git a/About/About.xml b/About/About.xml new file mode 100644 index 0000000..2ee59c5 --- /dev/null +++ b/About/About.xml @@ -0,0 +1,10 @@ + + + ModSwitch + DoctorVanGogh + 0.17.1557 + COMING SOON + DEVELOPMENT VERSION: alpha1 + +Allows loading & saving sets of active mods for Rimworld.]]> + diff --git a/Assemblies/0Harmony.dll b/Assemblies/0Harmony.dll new file mode 100644 index 0000000..a95b6df Binary files /dev/null and b/Assemblies/0Harmony.dll differ diff --git a/Assemblies/ModSwitch.dll b/Assemblies/ModSwitch.dll new file mode 100644 index 0000000..be2135d Binary files /dev/null and b/Assemblies/ModSwitch.dll differ diff --git a/Assemblies/harmonycheck.dll b/Assemblies/harmonycheck.dll new file mode 100644 index 0000000..916bd98 Binary files /dev/null and b/Assemblies/harmonycheck.dll differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1852d7f --- /dev/null +++ b/LICENSE @@ -0,0 +1,382 @@ +Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International +Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-NonCommercial-ShareAlike 4.0 International Public License +("Public License"). To the extent this Public License may be +interpreted as a contract, You are granted the Licensed Rights in +consideration of Your acceptance of these terms and conditions, and the +Licensor grants You such rights in consideration of benefits the +Licensor receives from making the Licensed Material available under +these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-NC-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution, NonCommercial, and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. NonCommercial means not primarily intended for or directed towards + commercial advantage or monetary compensation. For purposes of + this Public License, the exchange of the Licensed Material for + other material subject to Copyright and Similar Rights by digital + file-sharing or similar means is NonCommercial provided there is + no payment of monetary compensation in connection with the + exchange. + + l. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + m. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + n. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part, for NonCommercial purposes only; and + + b. produce, reproduce, and Share Adapted Material for + NonCommercial purposes only. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties, including when + the Licensed Material is used other than for NonCommercial + purposes. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-NC-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database for NonCommercial purposes + only; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + including for purposes of Section 3(b); and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6b4c76 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +[![RimWorld Alpha 17](https://img.shields.io/badge/RimWorld-Alpha%2017-brightgreen.svg)](http://rimworldgame.com/) [![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc-sa/4.0/) + +# ModSwitch + +_A Rimworld mod manager *(in the making)*_ + +## Powered by ![Harmony](https://github.com/pardeike/Harmony) + +

+Powered by Harmony +

+ +Harmony is lisenced under a [MIT license](https://raw.githubusercontent.com/pardeike/Harmony/master/LICENSE). \ No newline at end of file diff --git a/Source/DEVELOPMENT-SETUP.md b/Source/DEVELOPMENT-SETUP.md new file mode 100644 index 0000000..732652c --- /dev/null +++ b/Source/DEVELOPMENT-SETUP.md @@ -0,0 +1,16 @@ +# How to setup local developement + +Your local path to the Rimworld game & assemblies is probably not what anybody else is using. + +To keep multiple developers from playing ping-pong with the project file(s) and the respective assembly HintPath entries that setting has been externalized. + +After cloning the repository just edit `Source\RimworldInstall.props` (it's a plain XML file) and make sure the `RimworldManagedDir`entry resolves to the correct directory for _your_ local Rimworld assemblies. If you're developing on a running Rimworld install, then you can simply edit the `RimworldInstallDir` entry (other variables derive from there by default). +If you're keeping just a copy of the managed assemblies simply make sure the `RimworldManagedDir` resolves correctly to those assemblies. For relative paths starting with `$(SolutionDir)` is a good idea, as well as making sure you end in a `\`. + +If you want to be a particularly conscientious developer, run + +```bash +git update-index --skip-worktree Source\Rimworldinstall.props +``` + +after setting up your local version of the file. Then git will never upload your modified version. diff --git a/Source/ModSwitch.sln b/Source/ModSwitch.sln new file mode 100644 index 0000000..68b40be --- /dev/null +++ b/Source/ModSwitch.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModSwitch", "ModSwitch\ModSwitch.csproj", "{AB2E8E89-3D1D-4E36-A0AE-489B6EBC84A6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AB2E8E89-3D1D-4E36-A0AE-489B6EBC84A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AB2E8E89-3D1D-4E36-A0AE-489B6EBC84A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AB2E8E89-3D1D-4E36-A0AE-489B6EBC84A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AB2E8E89-3D1D-4E36-A0AE-489B6EBC84A6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Source/ModSwitch/ModSwitch.cs b/Source/ModSwitch/ModSwitch.cs new file mode 100644 index 0000000..bd17ea5 --- /dev/null +++ b/Source/ModSwitch/ModSwitch.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Harmony; +using UnityEngine; +using Verse; + +namespace DoctorVanGogh.ModSwitch { + class ModSwitch : Mod { + private Settings _settings; + + public ModSwitch(ModContentPack content) : base(content) { + var harmony = HarmonyInstance.Create("DoctorVanGogh.ModSwitch"); + harmony.PatchAll(typeof(ModSwitch).Assembly); + + Log.Message("Initialized ModSwitch patches..."); + + _settings = GetSettings(); + } + + public override string SettingsCategory() { + return "ModSwitch"; + } + + public override void DoSettingsWindowContents(Rect inRect) { + _settings.DoWindowContents(inRect); + } + + public void DoModsConfigWindowContents(Rect bottom) { + _settings.DoModsConfigWindowContents(bottom); + } + } +} diff --git a/Source/ModSwitch/ModSwitch.csproj b/Source/ModSwitch/ModSwitch.csproj new file mode 100644 index 0000000..8f2a507 --- /dev/null +++ b/Source/ModSwitch/ModSwitch.csproj @@ -0,0 +1,69 @@ + + + + + + Debug + AnyCPU + {AB2E8E89-3D1D-4E36-A0AE-489B6EBC84A6} + Library + Properties + DoctorVanGogh.ModSwitch + ModSwitch + v3.5 + 512 + + + + false + none + false + ..\..\Assemblies\ + DEBUG;TRACE + prompt + 4 + + + none + true + ..\..\Assemblies\ + + + prompt + 4 + + + + False + ..\..\Assemblies\0Harmony.dll + False + + + $(RimworldManagedDir)\Assembly-CSharp.dll + False + + + + + + $(RimworldManagedDir)\UnityEngine.dll + False + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/ModSwitch/ModSwitch.csproj.DotSettings b/Source/ModSwitch/ModSwitch.csproj.DotSettings new file mode 100644 index 0000000..d425c61 --- /dev/null +++ b/Source/ModSwitch/ModSwitch.csproj.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/Source/ModSwitch/Model/ModSet.cs b/Source/ModSwitch/Model/ModSet.cs new file mode 100644 index 0000000..cfd6fed --- /dev/null +++ b/Source/ModSwitch/Model/ModSet.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using Harmony; +using RimWorld; +using UnityEngine; +using Verse; + +namespace DoctorVanGogh.ModSwitch { + class ModSet : IExposable { + + private static readonly FieldInfo fiModsConfig_data; + private static readonly FieldInfo fiModsConfigData_activeMods; + + static ModSet() { + var tModsConfig = typeof(ModsConfig); + var tModsConfigData = AccessTools.Inner(tModsConfig, "ModsConfigData"); + fiModsConfigData_activeMods = AccessTools.Field(tModsConfigData, "activeMods"); + fiModsConfig_data = AccessTools.Field(tModsConfig, "data"); + } + + public List Mods = new List(); + + public string Name = String.Empty; + private TipSignal? _tip; + + public void ExposeData() { + Scribe_Collections.Look(ref Mods, false, "mods"); + Scribe_Values.Look(ref Name, "name"); + } + + private TipSignal Tip { + get { return (_tip ?? (_tip = new TipSignal(ToString()))).Value; } + } + + public override string ToString() { + return Mods.Aggregate(new StringBuilder(), (sb, m) => sb.Length == 0 ? sb.Append(m) : sb.AppendFormat(", {0}", m), sb => sb.ToString()); + } + + public void DoWindowContents(Rect rect) { + GUI.Label(rect, Name); + TooltipHandler.TipRegion(rect, Tip); + } + + public void Apply() { + // TODO: improve performance, dont do multiple joins over same data... + + // join set with installed mods while perserving order from set + List installedMods = Mods + .Select((m, idx) => new {id = m, Index = idx}) + .Join(ModLister.AllInstalledMods, t => t.id, md => md.Identifier, (t, md) => new {Id = t.id, Index = t.Index}) + .OrderBy(t => t.Index) + .Select(t => t.Id) + .ToList(); + + fiModsConfigData_activeMods.SetValue(fiModsConfig_data.GetValue(null), new List(installedMods)); + + if (installedMods.Count != Mods.Count) { + var missingMods = Mods.Where(m => !installedMods.Contains(m)); + StringBuilder sb = new StringBuilder($"Some mods from {Name} are not currently installed:"); + sb.AppendLine(); + sb.AppendLine(); + foreach (var item in missingMods) { + sb.AppendLine($" - {item}"); + } + + Find.WindowStack.Add(new Dialog_MessageBox(sb.ToString(), title: "Missing mods")); + } + } + } +} diff --git a/Source/ModSwitch/Properties/AssemblyInfo.cs b/Source/ModSwitch/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..cb00015 --- /dev/null +++ b/Source/ModSwitch/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ModSwitch")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ModSwitch")] +[assembly: AssemblyCopyright("Copyright © DoctorVanGogh 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ab2e8e89-3d1d-4e36-a0ae-489b6ebc84a6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.0.1.0")] +[assembly: AssemblyFileVersion("0.0.1.0")] diff --git a/Source/ModSwitch/Settings.cs b/Source/ModSwitch/Settings.cs new file mode 100644 index 0000000..fad2254 --- /dev/null +++ b/Source/ModSwitch/Settings.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; +using UnityEngine; +using Verse; + +namespace DoctorVanGogh.ModSwitch { + class Settings : ModSettings{ + private List Sets = new List(); + + private Vector2 _scrollPosition = new Vector2(); + + + public override void ExposeData() { + Scribe_Collections.Look(ref Sets, false, "sets"); + } + + public void DoWindowContents(Rect rect) { + Listing_Standard list = new Listing_Standard(GameFont.Small) { + ColumnWidth = rect.width + }; + list.Begin(rect); + + if (list.ButtonTextLabeled("Import", "ModListBackup")) { + Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("Importing from ModListBackup will overwrite all existing sets.", ImportModListBackupo, true, "Confirm import")); + } + +#if DEBUG + if (list.ButtonTextLabeled("Debug", "ListExisting")) { + foreach (var modSet in Sets) { + Log.Message($"ModSet '{modSet.Name}': {modSet}"); + } + } +#endif + + const float scrollbarSize = 16f; + const float sliderHeight = 30f; + const float gapSize = 4f; + + var r = list.GetRect(rect.height - list.CurHeight); + + int count = Sets.Count; + + Widgets.BeginScrollView(r, ref _scrollPosition, new Rect(0, 0, r.width - scrollbarSize, count * (sliderHeight + gapSize))); + Vector2 position = new Vector2(); + + // render each row + foreach (var entry in Sets) { + position.y = position.y + gapSize; + + Rect line = new Rect(0, position.y, r.width - scrollbarSize, sliderHeight); + + entry.DoWindowContents(line); + position.y += sliderHeight; + } + + Widgets.EndScrollView(); + + list.End(); + } + + private void ImportModListBackupo() { + Sets.Clear(); + + string parent = Path.Combine(GenFilePaths.SaveDataFolderPath, "ModListBackup"); + Util.Trace($"Looking at {parent}"); + if (Directory.Exists(parent)) { + var existing = Directory.GetFiles(parent, "*.rws"); + + foreach (var mlbSet in existing) { + Util.Trace($"Reading {mlbSet}"); + + XmlDocument doc = new XmlDocument(); + doc.Load(mlbSet); + + var set = new ModSet { + Name = $"MLB '{Path.GetFileNameWithoutExtension(mlbSet)}'", + Mods = doc.DocumentElement.SelectNodes(@"//activeMods/li/text()").Cast().Select(n => n.Value).ToList() + }; + Util.Trace($"Imported {set.Name}: {set}"); + Sets.Add(set); + } + } + + LoadedModManager.GetMod().WriteSettings(); + } + + + + public void DoModsConfigWindowContents(Rect target) { + if (Widgets.ButtonText(new Rect(target.x, target.y, 120f, 30f), "[MS] Load set")) { + Find.WindowStack.Add(new FloatMenu(Sets.Select(ms => new FloatMenuOption(ms.Name, ms.Apply)).ToList())); + } + } + } +} diff --git a/Source/ModSwitch/Util.cs b/Source/ModSwitch/Util.cs new file mode 100644 index 0000000..fb4634c --- /dev/null +++ b/Source/ModSwitch/Util.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using Verse; + +namespace DoctorVanGogh.ModSwitch { + class Util { + [Conditional("TRACE")] + public static void Trace(string s) { + Log.Message($"[ModSwitch]: {s}"); + } + + public static void Warning(string s) { + Log.Warning($"[ModSwitch]: {s}"); + } + } +} diff --git a/Source/ModSwitch/[Patches]/Patches.cs b/Source/ModSwitch/[Patches]/Patches.cs new file mode 100644 index 0000000..0450738 --- /dev/null +++ b/Source/ModSwitch/[Patches]/Patches.cs @@ -0,0 +1,18 @@ +using Harmony; +using RimWorld; +using UnityEngine; +using Verse; + +namespace DoctorVanGogh.ModSwitch { + class Patches { + + [HarmonyPatch(typeof(Page_ModsConfig), nameof(Page_ModsConfig.DoWindowContents))] + public class ModsConfig_DoWindowContents { + + public static void Postfix(Rect rect) { + const float bottomHeight = 52f; + LoadedModManager.GetMod()?.DoModsConfigWindowContents(new Rect(0, rect.height - bottomHeight + 8f, 350f, bottomHeight - 8f)); + } + } + } +} diff --git a/Source/RimworldInstall.props b/Source/RimworldInstall.props new file mode 100644 index 0000000..11af416 --- /dev/null +++ b/Source/RimworldInstall.props @@ -0,0 +1,26 @@ + + + + C:\Program Files (x86)\Steam\steamapps\common\RimWorld\ + + + $(RimworldInstallDir)\RimWorldWin_Data\ + + + $(RimworldDataDir)\Managed\ + + + + \ No newline at end of file diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..b7ba722 --- /dev/null +++ b/TODO.md @@ -0,0 +1,9 @@ +# Things to do + +- Implement saving current mod set +- Subscribing to items that are 'new' +- Renaming sets +- Deleting sets +- Auto-creating/picking sets at mod load +- 'copy local' for Steam mods ??? +- fancy UI (colors etc)