Skip to content

Commit e3a3575

Browse files
Added an option to draw cross-layer pings
Requires adding translations
1 parent d5e9bd1 commit e3a3575

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

Source/Client/Settings/MpSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class MpSettings : ModSettings
2323
public bool showModCompatibility = true;
2424
public bool hideTranslationMods = true;
2525
public bool enablePings = true;
26+
public bool enableCrossPlanetLayerPings = true;
2627
public KeyCode? sendPingButton = KeyCode.Mouse4;
2728
public KeyCode? jumpToPingButton = KeyCode.Mouse3;
2829
public Rect chatRect;
@@ -66,6 +67,7 @@ public override void ExposeData()
6667
Scribe_Values.Look(ref showModCompatibility, "showModCompatibility", true);
6768
Scribe_Values.Look(ref hideTranslationMods, "hideTranslationMods", true);
6869
Scribe_Values.Look(ref enablePings, "enablePings", true);
70+
Scribe_Values.Look(ref enableCrossPlanetLayerPings, "enableCrossPlanetLayerPings", true);
6971
Scribe_Values.Look(ref sendPingButton, "sendPingButton", KeyCode.Mouse4);
7072
Scribe_Values.Look(ref jumpToPingButton, "jumpToPingButton", KeyCode.Mouse3);
7173
Scribe_Custom.LookRect(ref chatRect, "chatRect");

Source/Client/Settings/MpSettingsUI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public static void DoGeneralSettings(MpSettings settings, Rect inRect, Rect page
7373
listing.CheckboxLabeled("MpShowModCompat".Translate(), ref settings.showModCompatibility,
7474
"MpShowModCompatDesc".Translate());
7575
listing.CheckboxLabeled("MpEnablePingsSetting".Translate(), ref settings.enablePings);
76+
listing.CheckboxLabeled("MpEnableCrossPlanetLayerPings".Translate(), ref settings.enableCrossPlanetLayerPings,
77+
"MpEnableCrossPlanetLayerPingsDesc".Translate());
7678
listing.CheckboxLabeled("MpShowMainMenuAnimation".Translate(), ref settings.showMainMenuAnim);
7779

7880
const string buttonOff = "Off";

Source/Client/UI/DrawPingPlanet.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,26 @@ static void Postfix()
1616
{
1717
if (ping.mapId != -1) continue;
1818
if (ping.PlayerInfo is not { } player) continue;
19-
// Only display pings on the current layer
20-
if (ping.planetTile.Layer != Find.WorldSelector.SelectedLayer) continue;
19+
20+
var layer = Find.WorldSelector.SelectedLayer;
21+
// Only display pings on the current layer or (if enabled) on layers we can zoom to.
22+
if (Multiplayer.settings.enableCrossPlanetLayerPings)
23+
{
24+
// We can either start with the ping layer, and keep zooming out,
25+
// or start with the current player layer, and keep zooming in.
26+
// Or both. This implementation tries to zoom in from the current player's layer.
27+
28+
// Infinite loop prevention.
29+
for (var i = 0; i < 25; i++)
30+
{
31+
// Either can't zoom in more, or we found our target
32+
if (layer == null || layer == ping.planetTile.Layer)
33+
break;
34+
35+
layer = layer.zoomInToLayer;
36+
}
37+
}
38+
if (ping.planetTile.Layer != layer) continue;
2139

2240
var tileCenter = GenWorldUI.WorldToUIPosition(Find.WorldGrid.GetTileCenter(ping.planetTile));
2341
const float size = 30f;

0 commit comments

Comments
 (0)