Skip to content

Commit

Permalink
3.0.0: Rimworld A17 update
Browse files Browse the repository at this point in the history
- The Harmony library now comes included
- All detour-related functionality has been removed. Please use Harmony for your patching needs.
- Removed GUI injection feature (use Harmony)
- Added full Harmony patch information to the log publisher
- Dropped some junk lines from the published logs for better readability
- Added optional platform information to the log publisher (CPU, RAM, OS)
- Added automatic Harmony patching for ModBase mods
- Added MapDiscarded callback to ModBase
- ModBase.OnGUI is now called during UIRoot.UIRootOnGUI and already has UI scaling applied
- ModBase.ComponentsInitializing is now called after all components have been instantiated
- Added error and warning prefixes to the logger for better readability on text logs
- Moved controller initialization to the earliest point possible
- Integrated vanilla mod settings into the HugsLib Mod Settings dialog.
- Removed mods dialog auto-restarter (included in vanilla)
- Added automatic restart on language change
- Removed short hash collision resolver (included in vanilla)
- Added IntVec3 extension methods for designations
- Long settings handle names will now wrap around and display properly
- Removed Log window copy button
- Removed WindowReplacer (use Harmony)
- Added EntryName parameter to ModSettingsManager.GetModSettings for external mods
- Fixed exception if a map failed to load due to an error in another mod
- Converted all comments to XML docs for reading during code completion
  • Loading branch information
UnlimitedHugs committed May 9, 2017
1 parent 730e273 commit a62e362
Show file tree
Hide file tree
Showing 44 changed files with 531 additions and 394 deletions.
16 changes: 9 additions & 7 deletions HugsLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>Mods\HugsLib\Assemblies\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
Expand All @@ -56,9 +57,11 @@
<Compile Include="Source\Attrib\AttributeDetector.cs" />
<Compile Include="Source\Attrib\DetectableAttributeHandler.cs" />
<Compile Include="Source\Attrib\IDetectableAttribute.cs" />
<Compile Include="Source\Core\HugsLibMod.cs" />
<Compile Include="Source\Core\KeyBindingHandler.cs" />
<Compile Include="Source\Core\LoadOrderChecker.cs" />
<Compile Include="Source\Patches\Page_ModsConfig_Patch.cs" />
<Compile Include="Source\Core\StaticInitalizer.cs" />
<Compile Include="Source\Patches\LanguageDatabase_Patch.cs" />
<Compile Include="Source\Patches\Game_DeinitAndRemoveMap_Patch.cs" />
<Compile Include="Source\Patches\Dialog_Options_Patch.cs" />
<Compile Include="Source\Patches\EditWindow_Log_Patch.cs" />
Expand All @@ -68,16 +71,14 @@
<Compile Include="Source\Patches\PlayDataLoader_Patch.cs" />
<Compile Include="Source\Patches\Root_Patch.cs" />
<Compile Include="Source\Patches\UIRoot_Patch.cs" />
<Compile Include="Source\Restarter\Dialog_RestartGame.cs" />
<Compile Include="Source\Restarter\AutoRestarter.cs" />
<Compile Include="Source\Settings\Dialog_VanillaModSettings.cs" />
<Compile Include="Source\Shell\Shell.cs" />
<Compile Include="Source\Shell\ShellOpenDirectory.cs" />
<Compile Include="Source\Shell\ShellOpenLog.cs" />
<Compile Include="Source\Shell\ShellRestartRimWorld.cs" />
<Compile Include="Source\Core\HugsTickProxy.cs" />
<Compile Include="Source\Core\KeyBindingDefOf.cs" />
<Compile Include="Source\Core\PersistentDataManager.cs" />
<Compile Include="Source\Core\ShortHashCollisionResolver.cs" />
<Compile Include="Source\Core\UnityProxyComponent.cs" />
<Compile Include="Source\Core\VersionFile.cs" />
<Compile Include="Source\Core\VersionShort.cs" />
Expand All @@ -99,6 +100,7 @@
<Compile Include="Source\Test\AttributeTests.cs" />
<Compile Include="Source\Test\TestMod.cs" />
<Compile Include="Source\Test\TestUWO.cs" />
<Compile Include="Source\Test\VanillaMod.cs" />
<Compile Include="Source\Utils\CallbackScheduler.cs" />
<Compile Include="Source\Utils\Dialog_Confirm.cs" />
<Compile Include="Source\Utils\Dialog_Message.cs" />
Expand Down
4 changes: 2 additions & 2 deletions Mods/HugsLib/About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<ModMetaData>
<name>HugsLib</name>
<author>UnlimitedHugs</author>
<targetVersion>0.16.0</targetVersion>
<targetVersion>0.17.0</targetVersion>
<url>https://ludeon.com/forums/index.php?topic=28066.0</url>
<description>&lt;color=orange&gt;&lt;b&gt;Important: &lt;/b&gt; This mod should be loaded right after Core to work properly.&lt;/color&gt;\n
HugsLib is a library that provides shared functionality to other mods.
Version: 2.4.3
Version: 3.0.0
</description>
</ModMetaData>
2 changes: 1 addition & 1 deletion Mods/HugsLib/About/Version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<VersionData>
<overrideVersion>2.4.3</overrideVersion>
<overrideVersion>3.0.0</overrideVersion>
<gitHubRepository>UnlimitedHugs/RimworldHugsLib</gitHubRepository>
</VersionData>
Binary file modified Mods/HugsLib/Assemblies/0Harmony.dll
Binary file not shown.
Binary file modified Mods/HugsLib/Assemblies/HugsLib.dll
Binary file not shown.
15 changes: 6 additions & 9 deletions Mods/HugsLib/Languages/English/Keyed/English.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<HugsLib_setting_allNews_desc>Shows all available mod update news, including those that have already been displayed.</HugsLib_setting_allNews_desc>
<HugsLib_setting_allNews_button>Show now</HugsLib_setting_allNews_button>
<HugsLib_setting_allNews_fail>None of the active mods have any update news to display.</HugsLib_setting_allNews_fail>
<HugsLib_setting_unnamed_mod>(unnamed mod)</HugsLib_setting_unnamed_mod>
<HugsLib_setting_show_settings>Show settings</HugsLib_setting_show_settings>
<HugsLib_setting_mod_name_title>Mod settings for {0}</HugsLib_setting_mod_name_title>

<HugsLib_features_title>New Mod Features</HugsLib_features_title>
<HugsLib_features_description>The following mod updates were installed, and these are the new features and improvements that came with them.\nYou can disable this dialog in Options &gt; Mod Settings</HugsLib_features_description>
Expand All @@ -23,7 +26,7 @@
<HugsLib_features_linkDesc>Opens your browser on a page where you can learn more about this update.\nAddress: {0}</HugsLib_features_linkDesc>

<HugsLib_copiedToClipboard>Copied to clipboard.</HugsLib_copiedToClipboard>

<HugsLib_logs_copy>Copy</HugsLib_logs_copy>
<HugsLib_logs_shareBtn>Share logs</HugsLib_logs_shareBtn>
<HugsLib_logs_shareConfirmTitle>Confirm</HugsLib_logs_shareConfirmTitle>
Expand All @@ -37,18 +40,12 @@
<HugsLib_logs_retryBtn>Retry</HugsLib_logs_retryBtn>
<HugsLib_logs_browseBtn>Open in browser</HugsLib_logs_browseBtn>

<HugsLib_logs_filesBtn>Files</HugsLib_logs_filesBtn>
<HugsLib_logs_filesBtn>+</HugsLib_logs_filesBtn>
<HugsLib_logs_openLogFile>Open log file</HugsLib_logs_openLogFile>
<HugsLib_logs_openSaveDir>Open save folder</HugsLib_logs_openSaveDir>
<HugsLib_logs_openModsDir>Open mods folder</HugsLib_logs_openModsDir>

<HugsLib_restart_title>Restart game</HugsLib_restart_title>
<HugsLib_restart_text>Changes have been saved.\n\nTo activate the new mod configuration it is recommended to restart the game.</HugsLib_restart_text>
<HugsLib_restart_restartNowBtn>Restart now</HugsLib_restart_restartNowBtn>
<HugsLib_restart_autoToggle>Restart automatically</HugsLib_restart_autoToggle>
<HugsLib_restart_restarting>Restarting</HugsLib_restart_restarting>
<HugsLib_setting_autoRestart_label>Restart after Mods menu changes</HugsLib_setting_autoRestart_label>
<HugsLib_setting_autoRestart_desc>Automatically restarts the game after changes to the Mods menu have been made.</HugsLib_setting_autoRestart_desc>
<HugsLib_restart_language_text>The game language has changed. The game will now restart automatically.</HugsLib_restart_language_text>

<HugsLib_loadOrderWarning_title>Improper mod load order</HugsLib_loadOrderWarning_title>
<HugsLib_loadOrderWarning_text>&lt;b&gt;The HugsLib mod&lt;/b&gt; should always be loaded after &lt;b&gt;Core&lt;/b&gt; to avoid issues.\nPlease adjust your mod order in the Mods menu and restart the game.</HugsLib_loadOrderWarning_text>
Expand Down
16 changes: 8 additions & 8 deletions Mods/HugsLib/Languages/Russian/Keyed/Russian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<HugsLib_setting_allNews_desc>Показывает все доступные новости обновлений, включая те, что уже были показаны.</HugsLib_setting_allNews_desc>
<HugsLib_setting_allNews_button>Показать сейчас</HugsLib_setting_allNews_button>
<HugsLib_setting_allNews_fail>Ни один из загруженных модов не содержит новостей.</HugsLib_setting_allNews_fail>
<HugsLib_setting_unnamed_mod>(мод без названия)</HugsLib_setting_unnamed_mod>
<HugsLib_setting_show_settings>Показать настройки</HugsLib_setting_show_settings>
<HugsLib_setting_mod_name_title>Настройки мода {0}</HugsLib_setting_mod_name_title>

<HugsLib_features_title>Новости Обновлений Модов</HugsLib_features_title>
<HugsLib_features_description>Здесь показаны недавно установленные версии модов и новый функционал, который они добавили в игру.\nЭто окно можно отключить в меню Настройки &gt; Настройки Модов</HugsLib_features_description>
Expand All @@ -37,16 +40,13 @@
<HugsLib_logs_retryBtn>Повторить попытку</HugsLib_logs_retryBtn>
<HugsLib_logs_browseBtn>Открыть в браузере</HugsLib_logs_browseBtn>

<HugsLib_logs_filesBtn>Файлы</HugsLib_logs_filesBtn>
<HugsLib_logs_filesBtn>+</HugsLib_logs_filesBtn>
<HugsLib_logs_openLogFile>Открыть журнал событий</HugsLib_logs_openLogFile>
<HugsLib_logs_openSaveDir>Открыть папку с сохраненными играми</HugsLib_logs_openSaveDir>
<HugsLib_logs_openModsDir>Открыть папку с модами</HugsLib_logs_openModsDir>

<HugsLib_restart_title>Требуется перезапуск</HugsLib_restart_title>
<HugsLib_restart_text>Изменения сохранены.\n\nЧтобы изменения вступили в силу, необходимо перезапустить игру.</HugsLib_restart_text>
<HugsLib_restart_restartNowBtn>Перезапустить сейчас</HugsLib_restart_restartNowBtn>
<HugsLib_restart_autoToggle>Перезапускать автоматически</HugsLib_restart_autoToggle>
<HugsLib_restart_restarting>Перезапуск</HugsLib_restart_restarting>
<HugsLib_setting_autoRestart_label>Перезапускать при перенастройке модов</HugsLib_setting_autoRestart_label>
<HugsLib_setting_autoRestart_desc>Автоматически перезапускает игру если состав или порядок загрузки модов был изменен.</HugsLib_setting_autoRestart_desc>
<HugsLib_restart_language_text>Язык игры был изменен. Игра будет автоматически перезапущена.</HugsLib_restart_language_text>

<HugsLib_loadOrderWarning_title>Неверный порядок модов</HugsLib_loadOrderWarning_title>
<HugsLib_loadOrderWarning_text>&lt;b&gt;Мод HugsLib&lt;/b&gt; должен всегда загружаться после &lt;b&gt;Core&lt;/b&gt; во избежание проблем.\nПожалуйста исправьте порядок в меню модов.</HugsLib_loadOrderWarning_text>
</LanguageData>
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 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.16.0")]
[assembly: AssemblyFileVersion("0.16.0")]
[assembly: AssemblyVersion("0.17.0")]
[assembly: AssemblyFileVersion("0.17.0")]
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
![HugsLib logo](http://i.imgur.com/1d35OiC.png)

![Version](https://img.shields.io/badge/Rimworld-A17-brightgreen.svg)

A lightweight shared mod library for Rimworld. Provides a foundation for mods and delivers shared functionality.

**Notice:** HugsLib has changed and must now be installed as a separate mod by the players. The library itself is no longer to be included with your mods. You can, however, include the checker assembly to ensure that the player will be notified if they are missing the necessary version of the library ([RimworldHugsLibChecker](https://github.com/UnlimitedHugs/RimworldHugsLibChecker)).
**Notice:** HugsLib must be installed as a separate mod by the players. The library itself is no longer to be included with your mods. You can, however, include the checker assembly to ensure that the player will be notified if they are missing the necessary version of the library ([RimworldHugsLibChecker](https://github.com/UnlimitedHugs/RimworldHugsLibChecker)).

## Current features
- Mod foundation: Base class to build mods on. Extending classes have access to custom logging, settings, and receive the following events from the library controller: Initialize, Tick, Update, FixedUpdate, OnGUI, WorldLoaded, MapComponentsInitializing, MapLoaded, SceneLoaded, SettingsChanged, DefsLoaded.
- Mod foundation: Base class to build mods on. Extending classes have access to custom logging, settings, and receive the following events from the library controller: Initialize, DefsLoaded, Tick, Update, FixedUpdate, OnGUI, WorldLoaded, MapComponentsInitializing, MapLoaded, MapDiscarded, SceneLoaded, SettingsChanged.
- Persistent in-game settings: Implementing mods can create custom settings of various types that can be changed by the player in the new Mod Settings menu. Settings are stored in a file in the user folder.
- Mod update news: Mods can provide a message for each version they release, highlighting new features. These messages will be shown once to the player the next time he starts the game. This is a good way to ensure that new mod features do not go unnoticed by the majority of players. This is especially true on Steam, where the player may not have even read the description before subscribing. Messages include support for images and basic formatting.
- Log publisher: Adds a keyboard shortcut (**Ctrl+F12**) to publish the logs from within the game. Returns a URL that you can share with others or send to a mod author. The published logs also include the list of running mods and their versions. This is a great way for a mod author to get the logs from a player who is experiencing an issue with his mod.
- Log publisher: Adds a keyboard shortcut (**Ctrl+F12**) to publish the logs from within the game. Returns a URL that you can share with others or send to a mod author. The published logs also include the list of running mods and their versions, as well as the full list of active Harmony patches. This is a great way for a mod author to get the logs from a player who is experiencing an issue with his mod.
- Checker assembly: A small dll designed to be included with your mod, that ensures the player is running at least the version of the library you specify. A dialog is displayed if a problem is detected, helping the player to resolve the issue. This is how the library stays up to date. See [RimworldHugsLibChecker](https://github.com/UnlimitedHugs/RimworldHugsLibChecker) for more info.
- UtilityWorldObjects: A convenient way to store your data in a save file. Since A16 MapComponents are no longer a reliable way to store your data, and UWO's are designed to be a drop-in replacement.
- Custom tick scheduling: Includes tools for executing callbacks with a specified tick delay, and registering recurring ticks with non-standard intervals. Recurring ticks are distributed uniformly across the time spectrum, to minimize the performance impact of the ticking entity.
- Detouring: provides special attributes for more convenient detouring. Detours are safety-checked to prevent improper use. Repeated detours of the same method are not allowed and will generate an error. Mods can implement special methods to handle detouring errors, which allows for graceful failure and easier pinpointing of player issues.
- GUI injection: provides a special attribute that allows a method to be executed whenever a given window type is drawn. This allows to inject drawing code for any window in the game.
- Auto-restarter: adds a prompt to the Mods dialog to restart the game when changes to the mod configuration have been made. Mod load order changes are also detected.
- Log window additions: adds buttons to copy the selected log message and activate the log publisher. Also adds a menu to find common files: open the log file and browse the user data and mods folders.
- Auto-restarter: Automatically restarts the game when the language is changed.
- Log window additions: Adds a menu to find common files: open the log file and browse the user data and mods folders.
- Harmony library: HugsLib includes the [Harmony library](https://github.com/pardeike/Harmony) by Andreas Pardeike.

## Compatibility
The only detour by the library itself is the `Window.WindowOnGUI` method, used to power the GUI injection system.
There are no known compatibility issues at this time. Please use the [Harmony library](https://github.com/pardeike/Harmony) for your detouring needs and everything should work well together.

## Usage
This is a public library similar to CCL, designed to be easily updateable between Rimworld versions. Feel free to use it for your own projects.
13 changes: 13 additions & 0 deletions Source/Core/HugsLibMod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Verse;

namespace HugsLib.Core {
/// <summary>
/// Entry point for the library.
/// Instantiated by the game at the start of DoPlayLoad().
/// </summary>
public class HugsLibMod : Mod {
public HugsLibMod(ModContentPack content) : base(content) {
HugsLibController.EarlyInitialize();
}
}
}
6 changes: 3 additions & 3 deletions Source/Core/KeyBindingHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HugsLib.Restarter;
using HugsLib.Shell;
using HugsLib.Shell;
using HugsLib.Utils;
using UnityEngine;
using Verse;

namespace HugsLib.Core {
/// <summary>
Expand All @@ -17,7 +17,7 @@ public static void OnGUI() {
ShellOpenLog.Execute();
}
if (HugsLibKeyBingings.RestartRimworld.JustPressed) {
AutoRestarter.PerformRestart();
LongEventHandler.ExecuteWhenFinished(GenCommandLine.Restart);
}
}
}
Expand Down
45 changes: 0 additions & 45 deletions Source/Core/ShortHashCollisionResolver.cs

This file was deleted.

13 changes: 13 additions & 0 deletions Source/Core/StaticInitalizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Verse;

namespace HugsLib.Core {
/// <summary>
/// Provides an entry point for late controller setup during static constructor initialization.
/// </summary>
[StaticConstructorOnStartup]
internal static class StaticInitalizer {
static StaticInitalizer() {
HugsLibController.Instance.LateInitalize();
}
}
}
Loading

0 comments on commit a62e362

Please sign in to comment.