Skip to content

Commit

Permalink
Resource legend; fix mouse over info; hide unused resources
Browse files Browse the repository at this point in the history
  • Loading branch information
DMagic1 committed Aug 15, 2020
1 parent 2543f75 commit cc22ef8
Show file tree
Hide file tree
Showing 3 changed files with 308 additions and 9 deletions.
10 changes: 10 additions & 0 deletions SCANsat.Unity/Interfaces/ISCAN_BigMap.cs
Expand Up @@ -105,6 +105,10 @@ public interface ISCAN_BigMap

Texture2D LegendImage { get; }

Texture2D ResourceLegendImage { get; }

Vector2 ResourceLegendLabels { get; }

IList<string> Projections { get; }

IList<string> MapTypes { get; }
Expand Down Expand Up @@ -139,6 +143,12 @@ public interface ISCAN_BigMap

void OpenSettings();

void IncreaseResourceCutoff();

void DecreaseResourceCutoff();

void OpenResourceSettings();

void OpenOverlay();

void ExportMap();
Expand Down
83 changes: 80 additions & 3 deletions SCANsat.Unity/Unity/SCAN_BigMap.cs
Expand Up @@ -104,6 +104,14 @@ public class SCAN_BigMap : CanvasFader, IDragHandler, IBeginDragHandler, IEndDra
[SerializeField]
private GameObject m_TooltipPrefab = null;
[SerializeField]
private GameObject m_ResourceBar = null;
[SerializeField]
private RawImage m_ResourceLegendImage = null;
[SerializeField]
private TextHandler m_ResourceLegendLabelOne = null;
[SerializeField]
private TextHandler m_ResourceLegendLabelTwo = null;
[SerializeField]
private Slider m_LoSlider = null;
[SerializeField]
private Slider m_HiSlider = null;
Expand Down Expand Up @@ -176,6 +184,8 @@ public class SCAN_BigMap : CanvasFader, IDragHandler, IBeginDragHandler, IEndDra
private byte statusTooltipType;
private SCAN_Tooltip _statusTooltip;

private const float MAXMAPWIDTH = 8200;

protected override void Awake()
{
base.Awake();
Expand Down Expand Up @@ -450,6 +460,9 @@ public void setMap(ISCAN_BigMap map)
if (m_ResourcesToggle != null)
m_ResourcesToggle.isOn = map.ResourceToggle;

if (m_ResourceBar != null)
m_ResourceBar.SetActive(map.ResourceToggle);

if (!map.OrbitAvailable && m_OrbitObject != null)
m_OrbitObject.SetActive(false);

Expand All @@ -461,6 +474,9 @@ public void setMap(ISCAN_BigMap map)

SetLegend(map.LegendToggle);

if (map.ResourceToggle)
SetResourceLegend();

SetButtons(map.CurrentScene);

SetScale(map.Scale);
Expand Down Expand Up @@ -604,7 +620,15 @@ public void SetSize(Vector2 size)
m_MapLayout.preferredHeight = m_MapLayout.preferredWidth / 2 + 8;
}

public void SetLegend(bool isOn)
public void SetLegends(bool isOn)
{
SetLegend(isOn);

if (bigInterface.ResourceToggle)
SetResourceLegend();
}

private void SetLegend(bool isOn)
{
if (m_LegendObject == null)
return;
Expand Down Expand Up @@ -661,6 +685,20 @@ public void SetLegend(bool isOn)
}
}

public void SetResourceLegend()
{
if (m_ResourceLegendImage != null)
m_ResourceLegendImage.texture = bigInterface.ResourceLegendImage;

Vector2 res = bigInterface.ResourceLegendLabels;

if (m_ResourceLegendLabelOne != null)
m_ResourceLegendLabelOne.OnTextUpdate.Invoke(res.x.ToString(res.x < 0.1 ? "P1" : "P0"));

if (m_ResourceLegendLabelTwo != null)
m_ResourceLegendLabelTwo.OnTextUpdate.Invoke(res.y.ToString(res.y < 0.1 ? "P1" : "P0"));
}

private void SetFlagIcons(IList<MapLabelInfo> flags)
{
if (flags == null)
Expand Down Expand Up @@ -1195,8 +1233,8 @@ public void OnResize(BaseEventData eventData)

if (m_MapLayout.preferredWidth < m_MapLayout.minWidth)
m_MapLayout.preferredWidth = m_MapLayout.minWidth;
else if (m_MapLayout.preferredWidth > 8200)
m_MapLayout.preferredWidth = 8200;
else if (m_MapLayout.preferredWidth > MAXMAPWIDTH)
m_MapLayout.preferredWidth = MAXMAPWIDTH;

if (m_MapLayout.preferredWidth % 2 != 0)
m_MapLayout.preferredWidth += 1;
Expand Down Expand Up @@ -1434,6 +1472,8 @@ private void SetResource(string selection)

bigInterface.ResourceToggle = true;

SetResourceLegend();

dropDown.FadeOut();
dropDown = null;

Expand Down Expand Up @@ -1476,6 +1516,9 @@ private void SetCelestialBody(string selection)

SetLegend(bigInterface.LegendToggle);

if (bigInterface.ResourceToggle)
SetResourceLegend();

dropDown.FadeOut();
dropDown = null;

Expand Down Expand Up @@ -1621,7 +1664,41 @@ public void ToggleResource(bool isOn)

bigInterface.ResourceToggle = isOn;

if (m_ResourceBar != null)
m_ResourceBar.SetActive(isOn);

RefreshIcons();

if (isOn)
SetResourceLegend();
}

public void ResourceCutoffMinus()
{
if (bigInterface == null)
return;

bigInterface.DecreaseResourceCutoff();

SetResourceLegend();
}

public void ResourceCutoffPlus()
{
if (bigInterface == null)
return;

bigInterface.IncreaseResourceCutoff();

SetResourceLegend();
}

public void OpenResourceSettings()
{
if (bigInterface == null)
return;

bigInterface.OpenResourceSettings();
}

public void OpenSmallMap()
Expand Down

0 comments on commit cc22ef8

Please sign in to comment.