Skip to content

Commit

Permalink
Add a bunch of tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
VinaLx committed Sep 1, 2021
1 parent 685cf38 commit 07fa688
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 17 deletions.
Binary file modified Assemblies/ResearchTree.dll
Binary file not shown.
17 changes: 12 additions & 5 deletions Languages/English/Keyed/KeyedTranslations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@
<ResearchPal.AllowGeneralX>Unlock {0}</ResearchPal.AllowGeneralX>
<ResearchPal.OtherPrerequisites>Other prerequisites: {0}</ResearchPal.OtherPrerequisites>

<ResearchPal.LClickReplaceQueue>Left-Click to replace queue</ResearchPal.LClickReplaceQueue>
<ResearchPal.LClickRemoveFromQueue>Left-Click to remove from queue</ResearchPal.LClickRemoveFromQueue>
<ResearchPal.SLClickAddToQueue>Shift-Left-Click to append to queue</ResearchPal.SLClickAddToQueue>
<ResearchPal.ALClickAddToQueue>Alt-Left-Click to prepend to queue</ResearchPal.ALClickAddToQueue>
<ResearchPal.CLClickDebugInstant>(DEBUG) Ctrl-Left-Click to instantly complete</ResearchPal.CLClickDebugInstant>
<ResearchPal.LClickReplaceQueue>Left-click to replace queue.</ResearchPal.LClickReplaceQueue>
<ResearchPal.LClickRemoveFromQueue>Left-click to remove from queue.</ResearchPal.LClickRemoveFromQueue>
<ResearchPal.SLClickAddToQueue>Shift + Left-click to append to queue.</ResearchPal.SLClickAddToQueue>
<ResearchPal.ALClickAddToQueue>Alt + Left-click to prepend to queue.</ResearchPal.ALClickAddToQueue>
<ResearchPal.CLClickDebugInstant>(DEBUG) Ctrl + Left-click to instantly complete.</ResearchPal.CLClickDebugInstant>
<ResearchPal.RightClickNode>Right-click for continuous highlight.</ResearchPal.RightClickNode>
<ResearchPal.RightClickIcon>Right-click item icon (or dots icon) to show detail information.</ResearchPal.RightClickIcon>
<ResearchPal.Drag>Drag to interact with research queue.</ResearchPal.Drag>
<ResearchPal.ShortcutManual>Press shift to display shortcut manual.</ResearchPal.ShortcutManual>

<ResearchPal.TechLevel>Tech Level: </ResearchPal.TechLevel>
<ResearchPal.Requires>Requires</ResearchPal.Requires>
<ResearchPal.LeadsTo>Leads to</ResearchPal.LeadsTo>
<ResearchPal.None>none</ResearchPal.None>
<ResearchPal.TechLevelTooLow>Because your faction tech level is too low ({0}), research cost is multiplied by {1} (from {2}).</ResearchPal.TechLevelTooLow>

<ResearchPal.QueuedNode>Already queued node</ResearchPal.QueuedNode>
<ResearchPal.MissingFacilities>Missing {0}</ResearchPal.MissingFacilities>
Expand Down Expand Up @@ -64,6 +70,7 @@
<ResearchPal.DontIgnoreHiddenPrerequisitesTip>Fix an old bug of the original ResearchPal that ignores hidden prereqisites.
You should always turn this option on for a more balanced gameplay. Being able to turning off this option is for existing save game strategy compatibility. (restart the game to apply)</ResearchPal.DontIgnoreHiddenPrerequisitesTip>
<ResearchPal.NeedsRestart>Research settings changed, restart RimWorld to apply the change.</ResearchPal.NeedsRestart>
<ResearchPal.DisableShortcutManual>Disable Shortcut Manual</ResearchPal.DisableShortcutManual>

<ResearchPal.ScrollSpeedMultiplier>Scrolling Speed Multiplier</ResearchPal.ScrollSpeedMultiplier>
<ResearchPal.ScrollSpeedMultiplierTip>Control horizontal and vertical scrolling speed of the main research tree</ResearchPal.ScrollSpeedMultiplierTip>
Expand Down
58 changes: 48 additions & 10 deletions Source/Graph/ResearchNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,16 @@ private void HandleTooltips() {
return;
}
Text.WordWrap = true;


if (!Settings.disableShortcutManual) {
TooltipHandler.TipRegion(Rect, ShortcutManualTooltip, Research.GetHashCode() + 2);
}
// attach description and further info to a tooltip
if (!TechprintAvailable()) {
TooltipHandler.TipRegion(Rect,
ResourceBank.String.MissingTechprints(Research.TechprintsApplied, Research.techprintCount));
"InsufficientTechprintsApplied".Translate(Research.TechprintsApplied, Research.TechprintCount));
// ResourceBank.String.MissingTechprints(Research.TechprintsApplied, Research.techprintCount));
}
if ( !BuildingPresent() ) {
TooltipHandler.TipRegion( Rect,
Expand All @@ -355,13 +361,50 @@ private void HandleTooltips() {
TooltipHandler.TipRegion(Rect, prompt);
}
}
TooltipHandler.TipRegion(Rect, GetResearchTooltipString, Research.GetHashCode());
if (Research.techLevel > Faction.OfPlayer.def.techLevel) {
TooltipHandler.TipRegion(
Rect, TechLevelTooLowTooltip, Research.GetHashCode() + 3);
}
TooltipHandler.TipRegion(
Rect, GetResearchTooltipString, Research.GetHashCode());

if (Settings.progressTooltip && ProgressWorthDisplaying() && !Research.IsFinished) {
TooltipHandler.TipRegion(Rect, string.Format("Progress: {0}", ProgressString()));
}
}

private string ShortcutManualTooltip() {
if (Event.current.shift) {
StringBuilder builder = new StringBuilder();
if (PainterIs(Painter.Queue)) {
builder.AppendLine(ResourceBank.String.LClickRemoveFromQueue);
} else {
if (Available()) {
builder.AppendLine(ResourceBank.String.LClickReplaceQueue);
builder.AppendLine(ResourceBank.String.SLClickAddToQueue);
builder.AppendLine(ResourceBank.String.ALClickAddToQueue);
}
if (DebugSettings.godMode) {
builder.AppendLine(ResourceBank.String.CLClickDebugInstant);
}
}
if (Available()) {
builder.AppendLine(ResourceBank.String.Drag);
}
builder.AppendLine(ResourceBank.String.RClickHighlight);
builder.AppendLine(ResourceBank.String.RClickIcon);
return builder.ToString();
} else {
return ResourceBank.String.ShiftForShortcutManual;
}
}

private string TechLevelTooLowTooltip() {
var techlevel = Faction.OfPlayer.def.techLevel;
return ResourceBank.String.TechLevelTooLow(
techlevel, Research.CostFactor(techlevel), (int) Research.baseCost);
}

private IEnumerable<ResearchProjectDef> OtherLockedPrerequisites(
IEnumerable<ResearchProjectDef> ps) {
if (ps == null) {
Expand All @@ -375,7 +418,7 @@ private string OtherPrereqTooltip(List<ResearchProjectDef> ps) {
return "";
}
return ResourceBank.String.OtherPrerequisites(
String.Join(", ", ps.Distinct().Select (p => p.LabelCap)));
String.Join(", ", ps.Distinct().Select(p => p.LabelCap)));
}

private string UnlockItemTooltip(Def def) {
Expand Down Expand Up @@ -799,13 +842,8 @@ private string GetResearchTooltipString()
var text = new StringBuilder();
text.AppendLine(Research.description);
text.AppendLine();

text.AppendLine(ResourceBank.String.SLClickAddToQueue);
text.AppendLine(ResourceBank.String.ALClickAddToQueue);

if (DebugSettings.godMode) {
text.AppendLine(ResourceBank.String.CLClickDebugInstant);
}
text.Append(ResourceBank.String.TechLevelOfResearch
+ Research.techLevel.ToStringHuman().CapitalizeFirst());

return text.ToString();
}
Expand Down
20 changes: 18 additions & 2 deletions Source/ResourceBank.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Verse;
using RimWorld;

namespace ResearchPal
{
Expand All @@ -9,7 +10,7 @@ public static class String
const string PREFIX = "ResearchPal.";

static string TL(string s) => (PREFIX + s).Translate();
static string TL(string s, params object[] args) => (PREFIX + s).Translate(args);
static string TL(string s, params NamedArgument[] args) => (PREFIX + s).Translate(args);

#region Settings
public static readonly string ShowNotificationPopup = TL("ShowNotificationPopup");
Expand Down Expand Up @@ -54,6 +55,8 @@ public static class String
public static readonly string ShowIndexOnQueue = TL("ShowQueueIndexOnQueue");
public static readonly string ShowIndexOnQueueTip = TL("ShowQueueIndexOnQueueTip");

public static readonly string DisableShortcutManual = TL("DisableShortcutManual");

public static readonly string DontIgnoreHiddenPrerequisites = TL("DontIgnoreHiddenPrerequisites");
public static readonly string DontIgnoreHiddenPrerequisitesTip = TL("DontIgnoreHiddenPrerequisitesTip");
public static readonly string DebugResearch = TL("DebugResearch");
Expand Down Expand Up @@ -81,9 +84,22 @@ public static class String
public static readonly string ALClickAddToQueue = TL("ALClickAddToQueue");
public static readonly string CLClickDebugInstant = TL("CLClickDebugInstant");

public static readonly string RClickHighlight = TL("RightClickNode");
public static readonly string RClickIcon = TL("RightClickIcon");
public static readonly string Drag = TL("Drag");

public static readonly string ShiftForShortcutManual = TL("ShortcutManual");

public static string MissingFacilities(string list) => TL("MissingFacilities", list);
public static string MissingTechprints(int techprintsApplied, int techprintCount) => TL("MissingTechprints", techprintsApplied, techprintCount);
// public static string MissingTechprints(int techprintsApplied, int techprintCount) => TL("MissingTechprints", techprintsApplied, techprintCount);
public static string FinishedResearch(string label) => TL("ResearchFinished", label);

public static readonly string TechLevelOfResearch = TL("TechLevel");

public static string TechLevelTooLow(
TechLevel techlevel, float multiplier, int baseCost) {
return TL("TechLevelTooLow", techlevel.ToStringHuman(), multiplier, baseCost);
}
#endregion

#region MainTabWindow_ResearchTree
Expand Down
4 changes: 4 additions & 0 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class Settings : ModSettings

public static bool showIndexOnQueue = false;

public static bool disableShortcutManual = false;

public static float scrollingSpeedMultiplier = 1f;
public static float zoomingSpeedMultiplier = 1f;
public static float draggingDisplayDelay = 0.25f;
Expand Down Expand Up @@ -112,6 +114,7 @@ public static void DoSettingsWindowContents(Rect windowRect)
listLeft.CheckboxLabeled(ProgressTooltip, ref progressTooltip, ProgressTooltipTip);
listLeft.CheckboxLabeled(AlwaysDisplayProgress, ref alwaysDisplayProgress, AlwaysDisplayProgressTip);
listLeft.CheckboxLabeled(ShowIndexOnQueue, ref showIndexOnQueue, ShowIndexOnQueueTip);
listLeft.CheckboxLabeled(DisableShortcutManual, ref disableShortcutManual);

listLeft.Gap();

Expand Down Expand Up @@ -167,6 +170,7 @@ public override void ExposeData()
Scribe_Values.Look(ref progressTooltip, "ProgressTooltip", false);
Scribe_Values.Look(ref alwaysDisplayProgress, "AlwaysDisplayProgress", false);
Scribe_Values.Look(ref showIndexOnQueue, "ShowQueuePositionOnQueue", false);
Scribe_Values.Look(ref disableShortcutManual, "DisableShortcutManual", false);
Scribe_Values.Look(ref dontIgnoreHiddenPrerequisites, "dontIgnoreHiddenPrerequisites", true);
Scribe_Values.Look(ref scrollingSpeedMultiplier, "ScrollingSpeedMultiplier", 1);
Scribe_Values.Look(ref zoomingSpeedMultiplier, "zoomingSpeedMultiplier", 1);
Expand Down

0 comments on commit 07fa688

Please sign in to comment.