Skip to content

Commit

Permalink
v2.0.1.9: Add option to not show labels near mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Mar 26, 2020
1 parent fa3c94c commit 00db67c
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.cameraplus</identifier>
<version>2.0.1.8</version>
<version>2.0.1.9</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
2 changes: 1 addition & 1 deletion About/ModSync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ModSyncNinjaData>
<ID>d47b5c8c-3f08-4ab6-8d0a-bc67e509d15c</ID>
<ModName>Camera+</ModName>
<Version>2.0.1.8</Version>
<Version>2.0.1.9</Version>
<SaveBreaking>False</SaveBreaking>
<Host name="Github">
<Owner>pardeike</Owner>
Expand Down
1 change: 1 addition & 0 deletions Languages/English/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<AnimalsDifferent>Animals have a different marker</AnimalsDifferent>
<HideAnimals>Animals have no marker</HideAnimals>
<ZoomToMouse>Zoom to mouse</ZoomToMouse>
<MouseRevealsLabels>Mouse reveals labels</MouseRevealsLabels>
<KeyLeftShift>Left Shift</KeyLeftShift>
<KeyLeftAlt>Left Alt</KeyLeftAlt>
<KeyLeftControl>Left Ctrl</KeyLeftControl>
Expand Down
1 change: 1 addition & 0 deletions Languages/German/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<AnimalsDifferent>Tiere haben einen anderen Marker</AnimalsDifferent>
<HideAnimals>Tiere haben keinen Marker</HideAnimals>
<ZoomToMouse>Zoom an die Maus</ZoomToMouse>
<MouseRevealsLabels>Maus zeigt Labels</MouseRevealsLabels>
<KeyLeftShift>Left Shift</KeyLeftShift>
<KeyLeftAlt>Left Alt</KeyLeftAlt>
<KeyLeftControl>Left Ctrl</KeyLeftControl>
Expand Down
1 change: 1 addition & 0 deletions Languages/Japanese/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<AnimalsDifferent>動物は別のマーカーを持っています</AnimalsDifferent>
<HideAnimals>動物にはマーカーがありません</HideAnimals>
<ZoomToMouse>マウスポインタにズーム</ZoomToMouse>
<MouseRevealsLabels>マウスでラベルが表示される</MouseRevealsLabels>
<KeyLeftShift>左Shift</KeyLeftShift>
<KeyLeftAlt>左Alt</KeyLeftAlt>
<KeyLeftControl>左Ctrl</KeyLeftControl>
Expand Down
1 change: 1 addition & 0 deletions Languages/Spanish/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<AnimalsDifferent>Los animales tienen un marcador diferente</AnimalsDifferent>
<HideAnimals>Los animales no tienen marcador</HideAnimals>
<ZoomToMouse>Acercar al mouse</ZoomToMouse>
<MouseRevealsLabels>El mouse revela etiquetas</MouseRevealsLabels>
<KeyLeftShift>Left Shift</KeyLeftShift>
<KeyLeftAlt>Left Alt</KeyLeftAlt>
<KeyLeftControl>Left Ctrl</KeyLeftControl>
Expand Down
1 change: 1 addition & 0 deletions Languages/SpanishLatin/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<AnimalsDifferent>Los animales tienen un marcador diferente</AnimalsDifferent>
<HideAnimals>Los animales no tienen marcador</HideAnimals>
<ZoomToMouse>Acercar al mouse</ZoomToMouse>
<MouseRevealsLabels>El mouse revela etiquetas</MouseRevealsLabels>
<KeyLeftShift>Left Shift</KeyLeftShift>
<KeyLeftAlt>Left Alt</KeyLeftAlt>
<KeyLeftControl>Left Ctrl</KeyLeftControl>
Expand Down
20 changes: 18 additions & 2 deletions Source/CrossPromotion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ internal static string ModPreviewPath(ulong modID)
return dir + modID + "-preview.jpg";
}

internal static byte[] SafeRead(string path)
{
for (var i = 1; i <= 5; i++)
{
try
{
return File.ReadAllBytes(path);
}
catch (Exception)
{
Thread.Sleep(250);
}
}
return null;
}

internal static Texture2D PreviewForMod(ulong modID)
{
if (previewTextures.TryGetValue(modID, out var texture))
Expand All @@ -134,7 +150,7 @@ internal static Texture2D PreviewForMod(ulong modID)
if (File.Exists(path) == false)
return null;
texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
if (texture.LoadImage(File.ReadAllBytes(path)))
if (texture.LoadImage(SafeRead(path)))
previewTextures[modID] = texture;
return texture;
}
Expand Down Expand Up @@ -403,7 +419,7 @@ void actionButtonAction()
{
var orderedMods = (IEnumerable<ModMetaData>)AccessTools.Method(typeof(Page_ModsConfig), "ModsInListOrder").Invoke(page, Array.Empty<object>());
page.selectedMod = orderedMods.FirstOrDefault(meta => meta.GetPublishedFileId().m_PublishedFileId == myModID);
var modsBefore = orderedMods.FirstIndexOf(m => m == page.selectedMod);
var modsBefore = orderedMods.ToList().FindIndex(m => m == page.selectedMod);
if (modsBefore >= 0)
_ = Traverse.Create(page).Field("modListScrollPosition").SetValue(new Vector2(0f, modsBefore * 26f + 4f));
}
Expand Down
5 changes: 4 additions & 1 deletion Source/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ static bool Prefix(Vector3 loc)
return true;

// show if mouse is nearby
return Tools.MouseDistanceSquared(loc, true) <= 2.25f;
if (CameraPlusMain.Settings.mouseOverShowsLabels)
return Tools.MouseDistanceSquared(loc, true) <= 2.25f;

return false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

[assembly: Guid("b0d46bb5-08ff-4e04-9efd-3e32e38a9cc2")]

[assembly: AssemblyVersion("2.0.1.8")]
[assembly: AssemblyFileVersion("2.0.1.8")]
[assembly: AssemblyVersion("2.0.1.9")]
[assembly: AssemblyFileVersion("2.0.1.9")]
4 changes: 4 additions & 0 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class CameraPlusSettings : ModSettings
public int dotSize = 9;
public int hidePawnLabelBelow = 9;
public int hideThingLabelBelow = 32;
public bool mouseOverShowsLabels = true;
public LabelStyle customNameStyle = LabelStyle.AnimalsDifferent;

public KeyCode[] cameraSettingsMod = new[] { KeyCode.LeftShift, KeyCode.None };
Expand Down Expand Up @@ -79,6 +80,7 @@ public override void ExposeData()
Scribe_Values.Look(ref dotSize, "dotSize", 9);
Scribe_Values.Look(ref hidePawnLabelBelow, "hidePawnLabelBelow", 0);
Scribe_Values.Look(ref hideThingLabelBelow, "hideThingLabelBelow", 32);
Scribe_Values.Look(ref mouseOverShowsLabels, "mouseOverShowsLabels", true);
Scribe_Values.Look(ref customNameStyle, "customNameStyle", LabelStyle.AnimalsDifferent);
Scribe_Values.Look(ref cameraSettingsMod[0], "cameraSettingsMod1", KeyCode.LeftShift);
Scribe_Values.Look(ref cameraSettingsMod[1], "cameraSettingsMod2", KeyCode.None);
Expand Down Expand Up @@ -145,6 +147,7 @@ public void DoWindowContents(Rect inRect)
list.Gap(6f);

list.CheckboxLabeled("ZoomToMouse".Translate(), ref zoomToMouse);
list.CheckboxLabeled("MouseRevealsLabels".Translate(), ref mouseOverShowsLabels);

list.Gap(24f);

Expand Down Expand Up @@ -245,6 +248,7 @@ public void DoWindowContents(Rect inRect)
dotSize = 9;
hidePawnLabelBelow = 9;
hideThingLabelBelow = 32;
mouseOverShowsLabels = true;
customNameStyle = LabelStyle.AnimalsDifferent;
cameraSettingsMod[0] = KeyCode.LeftShift;
cameraSettingsMod[1] = KeyCode.None;
Expand Down
5 changes: 4 additions & 1 deletion Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ public static void ShouldShowLabel(Vector3 location, bool isPawn, out bool showL
showLabel = true;
showDot = false;

if (CameraPlusMain.Settings.hideNamesWhenZoomedOut == false || MouseDistanceSquared(location, isPawn) <= 2.25f)
if (CameraPlusMain.Settings.hideNamesWhenZoomedOut == false)
return;

if (MouseDistanceSquared(location, isPawn) <= 2.25f && CameraPlusMain.Settings.mouseOverShowsLabels)
return;

var len = CurrentCellLength();
Expand Down
Binary file modified v1.1/Assemblies/CameraPlus.dll
Binary file not shown.

0 comments on commit 00db67c

Please sign in to comment.