Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Config/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using BepInEx.Configuration;
using DynamicMaps.UI.Controls;
using UnityEngine;

// THIS IS HEAVILY BASED ON DRAKIAXYZ'S SPT-QuickMoveToContainer
Expand Down Expand Up @@ -66,6 +67,17 @@ internal class Settings
public static ConfigEntry<KeyboardShortcut> PeekShortcut;
public static ConfigEntry<bool> HoldForPeek;

public const string MiniMapTitle = "4. Mini-Map";
public static ConfigEntry<KeyboardShortcut> MiniMapKey;
public static ConfigEntry<KeyboardShortcut> MiniMapZoomIn;
public static ConfigEntry<KeyboardShortcut> MiniMapZoomOut;
public static ConfigEntry<float> MiniMapZoom;
public static ConfigEntry<Vector2> MiniMapAnchoredPosition;
public static ConfigEntry<Vector2> MiniMapSizeDelta;
public static ConfigEntry<Vector2> MiniMapAnchorMin;
public static ConfigEntry<Vector2> MiniMapAnchorMax;
public static ConfigEntry<Vector2> MiniMapPivot;

// public static ConfigEntry<KeyboardShortcut> KeyboardShortcut;

public static void Init(ConfigFile Config)
Expand Down Expand Up @@ -396,6 +408,89 @@ public static void Init(ConfigFile Config)
null,
new ConfigurationManagerAttributes { })));

//4. Mini-Map START
ConfigEntries.Add(MiniMapSizeDelta = Config.Bind(
MiniMapTitle,
"Zoom Map size",
new Vector2(275f, 275f),
new ConfigDescription(
"The size of the mini map",
null,
new ConfigurationManagerAttributes { })));

ConfigEntries.Add(MiniMapAnchoredPosition = Config.Bind(
MiniMapTitle,
"Mini Map position",
new Vector2(-10f, -10f),
new ConfigDescription(
"The position of the mini map",
null,
new ConfigurationManagerAttributes { })));

ConfigEntries.Add(MiniMapAnchorMin = Config.Bind(
MiniMapTitle,
"Mini Map anchor min",
new Vector2(1f, 1f),
new ConfigDescription(
"The min anchor of the mini map",
null,
new ConfigurationManagerAttributes { })));

ConfigEntries.Add(MiniMapAnchorMax = Config.Bind(
MiniMapTitle,
"Mini Map anchor max",
new Vector2(1f, 1f),
new ConfigDescription(
"The max anchor of the mini map",
null,
new ConfigurationManagerAttributes { })));

ConfigEntries.Add(MiniMapPivot = Config.Bind(
MiniMapTitle,
"Mini Map Pivot",
new Vector2(1f, 1f),
new ConfigDescription(
"The pivot of the mini map",
null,
new ConfigurationManagerAttributes { })));


ConfigEntries.Add(MiniMapZoom = Config.Bind(
MiniMapTitle,
"Mini Map Zoom",
10f,
new ConfigDescription(
"The zoom of the mini map",
new AcceptableValueRange<float>(.9f, 15f),
new ConfigurationManagerAttributes { })));

ConfigEntries.Add(MiniMapKey = Config.Bind(
MiniMapTitle,
"Mini Map Hotkey",
new KeyboardShortcut(KeyCode.End),
new ConfigDescription(
"Active/disable the mini-map.",
null,
new ConfigurationManagerAttributes { })));

ConfigEntries.Add(MiniMapZoomIn = Config.Bind(
MiniMapTitle,
"Mini Map Zoom In Hotkey",
new KeyboardShortcut(KeyCode.Keypad8),
new ConfigDescription(
"Zoom in the mini-map.",
null,
new ConfigurationManagerAttributes { })));

ConfigEntries.Add(MiniMapZoomOut = Config.Bind(
MiniMapTitle,
"Mini Map Zoom Out Hotkey",
new KeyboardShortcut(KeyCode.Keypad5),
new ConfigDescription(
"Zoom out the mini-map.",
null,
new ConfigurationManagerAttributes { })));
//4.Mini-Map END
RecalcOrder();
}

Expand Down
1 change: 1 addition & 0 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ internal void TryAttachToBattleUIScreen(EftBattleUIScreen battleUI)
}

Map.TryAddPeekComponent(battleUI);
Map.TryAddMiniMapComponent(battleUI);
}
}
}
65 changes: 65 additions & 0 deletions UI/Components/MapMiniComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using BepInEx.Configuration;
using DynamicMaps.Utils;
using UnityEngine;

namespace DynamicMaps.UI.Components
{
internal class MapMiniComponent : MonoBehaviour
{
public ModdedMapScreen MapScreen { get; set; }
public RectTransform MapScreenTrueParent { get; set; }
public RectTransform RectTransform { get; private set; }
public KeyboardShortcut ActivateMiniMap { get; set; }
public bool IsActive { get; private set; }

internal static MapMiniComponent Create(GameObject parent)
{
var go = UIUtils.CreateUIGameObject(parent, "MiniMap");
go.GetRectTransform().sizeDelta = parent.GetRectTransform().sizeDelta;
var component = go.AddComponent<MapMiniComponent>();
return component;
}

private void Awake()
{
RectTransform = gameObject.GetRectTransform();
}

private void Start()
{
BeginMiniMap();
}

private void Update()
{
if (ActivateMiniMap.BetterIsDown())
{
if (!IsActive)
{
BeginMiniMap();
}
else
{
EndMiniMap();
}
}
}

internal void BeginMiniMap()
{
IsActive = true;

MapScreen.transform.SetParent(RectTransform);
MapScreen.Show();
}

internal void EndMiniMap()
{
MapScreen.WasMinimapActive = MapScreen.IsMinimapActive;

IsActive = false;
MapScreen.Hide();
MapScreen.transform.SetParent(MapScreenTrueParent);
}
}
}
15 changes: 15 additions & 0 deletions UI/Components/MapPeekComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BepInEx.Configuration;
using DynamicMaps.Utils;
using EFT.UI.Map;
using UnityEngine;

namespace DynamicMaps.UI.Components
Expand Down Expand Up @@ -27,6 +28,7 @@ internal static MapPeekComponent Create(GameObject parent)
private void Awake()
{
RectTransform = gameObject.GetRectTransform();
IsPeeking = false;
}

private void Update()
Expand Down Expand Up @@ -63,6 +65,12 @@ internal void BeginPeek()
{
return;
}
MapScreen.WasMinimapActive = MapScreen.IsMinimapActive;

if (MapScreen.IsMinimapActive && MapScreen.MiniMapComponent != null)
{
MapScreen.MiniMapComponent.EndMiniMap();
}

// just in case something else is attached and tries to be in front
transform.SetAsLastSibling();
Expand All @@ -86,6 +94,13 @@ internal void EndPeek()
// un-attach map screen and re-attach to true parent
MapScreen.Hide();
MapScreen.transform.SetParent(MapScreenTrueParent);

if (MapScreen.WasMinimapActive && MapScreen.MiniMapComponent != null)
{
MapScreen.MiniMapComponent.BeginMiniMap();
}

MapScreen.WasMinimapActive = MapScreen.IsMinimapActive;
}
}
}
8 changes: 5 additions & 3 deletions UI/Components/MapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MapView : MonoBehaviour
{
private static Vector2 _markerSize = new Vector2(30, 30);
private static float _zoomMaxScaler = 10f; // multiplier against zoomMin
private static float _zoomMinScaler = 1.1f; // divider against ratio of a provided rect
private static float _zoomMinScaler = .9f; // divider against ratio of a provided rect

public event Action<int> OnLevelSelected;

Expand Down Expand Up @@ -286,8 +286,10 @@ public void SetMinMaxZoom(RectTransform parentTransform)
{
// set zoom min and max based on size of map and size of mask
var mapSize = RectTransform.sizeDelta;
ZoomMin = Mathf.Min(parentTransform.sizeDelta.x / mapSize.x, parentTransform.sizeDelta.y / mapSize.y) / _zoomMinScaler;
ZoomMax = _zoomMaxScaler * ZoomMin;
var parentSize = parentTransform.sizeDelta;

ZoomMin = Mathf.Min(parentSize.x / mapSize.x, parentSize.y / mapSize.y) / _zoomMinScaler;
ZoomMax = Mathf.Max(_zoomMaxScaler * ZoomMin, 1.0f);

// this will set everything up for initial zoom
SetMapZoom(ZoomMin, 0);
Expand Down
Loading