This commit is contained in:
CGFighter
2022-06-15 21:31:35 +03:00
parent e89eb45ccc
commit 7febeef817
9 changed files with 108 additions and 12 deletions

View File

Binary file not shown.

View File

@@ -5,4 +5,8 @@
<CommandResearchWhateverToggleDescInactive>Inactive - colonists will not choose something to research on their own.</CommandResearchWhateverToggleDescInactive>
<ResearchWhateverNothingLeftToResearch>{0} has nothing left to research</ResearchWhateverNothingLeftToResearch>
<ResearchWhateverNewResearch>{0} has started a new research: {1}</ResearchWhateverNewResearch>
<CommandResearchWhateverToggleMute>Mute</CommandResearchWhateverToggleMute>
<CommandResearchWhateverToggleDefault>Default</CommandResearchWhateverToggleDefault>
<CommandResearchWhateverToggleLetter>Letter</CommandResearchWhateverToggleLetter>
<CommandResearchWhateverToggleNotice>Notice</CommandResearchWhateverToggleNotice>
</LanguageData>

View File

@@ -0,0 +1,37 @@
using System.Linq;
using System.Collections.Generic;
using HarmonyLib;
using RimWorld;
using Verse;
using Verse.Sound;
namespace ResearchWhatever.Patches
{
[HarmonyPatch(typeof(ResearchManager), "FinishProject")]
public static class ResearchManager_FinishProject_ResearchWhateverPatch
{
public static void Prefix(ResearchManager __instance, ref bool doCompletionDialog)
{
if (doCompletionDialog)
{
var comp = Current.Game.GetComponent<ResearchWhateverGameComp>();
if (comp.NotifyMode == ResearchWhateverNotifyMode.rwnDefault)
return;
doCompletionDialog = false;
switch (comp.NotifyMode)
{
case ResearchWhateverNotifyMode.rwnLetter:
Find.LetterStack.ReceiveLetter("ResearchFinished".Translate(__instance.currentProj.LabelCap), __instance.currentProj.description, LetterDefOf.PositiveEvent, null, null, null, null, null);
break;
case ResearchWhateverNotifyMode.rwnNotice:
Messages.Message("ResearchFinished".Translate(__instance.currentProj.LabelCap).CapitalizeFirst(), MessageTypeDefOf.SilentInput);
break;
default:
break;
}
}
}
}
}

View File

@@ -13,7 +13,7 @@ namespace ResearchWhatever
{
//[HarmonyPatch(typeof(StaticConstructorOnStartupUtility), "CallAll")]
[HarmonyPatch]
static class StaticConstructorOnStartupUtility_CallAll_ResearchWhateverPatch
public static class StaticConstructorOnStartupUtility_CallAll_ResearchWhateverPatch
{
internal static MethodBase TargetMethod()
{
@@ -29,7 +29,7 @@ namespace ResearchWhatever
return LCallAll;
}
//
static void Postfix()
public static void Postfix()
{
List<ThingDef> list = new List<ThingDef>(
from x in DefDatabase<ThingDef>.AllDefsListForReading

View File

@@ -8,9 +8,9 @@ using Verse.Sound;
namespace ResearchWhatever.Patches
{
[HarmonyPatch(typeof(WorkGiver_Researcher), "ShouldSkip")]
static class WorkGiver_Researcher_ShouldSkip_ResearchWhateverPatch
public static class WorkGiver_Researcher_ShouldSkip_ResearchWhateverPatch
{
static bool Prefix(ref bool __result)
public static bool Prefix(ref bool __result)
{
__result = false;
return false;
@@ -18,9 +18,9 @@ namespace ResearchWhatever.Patches
}
[HarmonyPatch(typeof(WorkGiver_Researcher), "PotentialWorkThingRequest", MethodType.Getter)]
static class WorkGiver_PotentialWorkThingRequest_ResearchWhateverPatch
public static class WorkGiver_PotentialWorkThingRequest_ResearchWhateverPatch
{
static bool Prefix(ref ThingRequest __result)
public static bool Prefix(ref ThingRequest __result)
{
__result = ThingRequest.ForGroup(ThingRequestGroup.ResearchBench);
return false;
@@ -28,7 +28,7 @@ namespace ResearchWhatever.Patches
}
[HarmonyPatch(typeof(WorkGiver_Researcher), "HasJobOnThing")]
static class WorkGiver_Researcher_HasJobOnThing_ResearchWhateverPatch
public static class WorkGiver_Researcher_HasJobOnThing_ResearchWhateverPatch
{
private static bool hasFacilities(this Building_ResearchBench bench, List<ThingDef> requiredFacilities)
{
@@ -43,7 +43,7 @@ namespace ResearchWhatever.Patches
return true;
}
static void Prefix(Pawn pawn, Thing t, bool forced)
public static void Prefix(Pawn pawn, Thing t, bool forced)
{
ResearchProjectDef currentProj = Find.ResearchManager.currentProj;
if (currentProj != null) return;

View File

@@ -68,6 +68,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResearchWhateverComp.cs" />
<Compile Include="ResearchWhateverExtansion.cs" />
<Compile Include="ResearchWhateverGameComp.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Verse;
using RimWorld;
using UnityEngine;
namespace ResearchWhatever
{
@@ -29,7 +30,33 @@ namespace ResearchWhatever
command_Toggle.isActive = (() => active);
command_Toggle.toggleAction = delegate ()
{
Active = !active;
if (Event.current.button == 0)
Active = !Active;
else if (Event.current.button == 1)
{
var comp = Current.Game.GetComponent<ResearchWhateverGameComp>();
//var lable = Mute ? "CommandResearchWhateverToggleMute".Translate().CapitalizeFirst() : "CommandResearchWhateverToggleUnmute".Translate().CapitalizeFirst();
List<FloatMenuOption> list = new List<FloatMenuOption>();
list.Add(new FloatMenuOption("CommandResearchWhateverToggleDefault".Translate().CapitalizeFirst(), delegate ()
{
comp.NotifyMode = ResearchWhateverNotifyMode.rwnDefault;
}));
list.Add(new FloatMenuOption("CommandResearchWhateverToggleLetter".Translate().CapitalizeFirst(), delegate ()
{
comp.NotifyMode = ResearchWhateverNotifyMode.rwnLetter;
}));
list.Add(new FloatMenuOption("CommandResearchWhateverToggleNotice".Translate().CapitalizeFirst(), delegate ()
{
comp.NotifyMode = ResearchWhateverNotifyMode.rwnNotice;
}));
list.Add(new FloatMenuOption("CommandResearchWhateverToggleMute".Translate().CapitalizeFirst(), delegate ()
{
comp.NotifyMode = ResearchWhateverNotifyMode.rwnMute;
}));
FloatMenu floatMenu = new FloatMenu(list);
floatMenu.vanishIfMouseDistant = true;
Find.WindowStack.Add(floatMenu);
}
};
if (Active)
{

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Linq;
using Verse;
using RimWorld;
namespace ResearchWhatever
{
public enum ResearchWhateverNotifyMode { rwnDefault, rwnLetter, rwnNotice, rwnMute }
public class ResearchWhateverGameComp : GameComponent
{
public ResearchWhateverGameComp()
{
}
public ResearchWhateverGameComp(Game game)
{
}
public override void ExposeData()
{
Scribe_Values.Look(ref notifyMode, "NotifyMode");
}
private ResearchWhateverNotifyMode notifyMode = ResearchWhateverNotifyMode.rwnDefault;
public ResearchWhateverNotifyMode NotifyMode { get { return notifyMode; } set { notifyMode = value; } }
}
}

View File

@@ -1,6 +1,9 @@
1.0.3
1.0.4
- now you can r-click on the toggle to mute completion notifications;
1.0.3
- added an extension to make it possible to ignore some research or prioritize last;
- made so repeatable research from firefoxpdm.ResearchableStatUpgrades us always bottom priority;
- made so repeatable research from firefoxpdm.ResearchableStatUpgrades is always bottom priority;
1.0.2
- option gets disabled if building is not of player faction;