Skip to content
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
Binary file not shown.
17 changes: 17 additions & 0 deletions addons/compass/UI/Textures/Map/ACE_DeclinationIcon.edds.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MetaFileClass {
Name "{694C2E8773F36418}UI/Textures/Map/ACE_DeclinationIcon.edds"
Configurations {
PNGResourceClass PC : "{DC555BD399D92412}Configs/System/ResourceTypes/PC/TextureUnspecified.conf" {
}
PNGResourceClass XBOX_ONE : "{8F13AE697AE60784}Configs/System/ResourceTypes/XBOX_ONE/TextureUnspecified.conf" {
}
PNGResourceClass XBOX_SERIES : "{D28E01700D90F52C}Configs/System/ResourceTypes/XBOX_SERIES/TextureUnspecified.conf" {
}
PNGResourceClass PS4 : "{C6CD3D8752652D2A}Configs/System/ResourceTypes/PS4/TextureUnspecified.conf" {
}
PNGResourceClass PS5 : "{6248F71B9D7C1E93}Configs/System/ResourceTypes/PS5/TextureUnspecified.conf" {
}
PNGResourceClass HEADLESS : "{699C82A6807668A7}Configs/System/ResourceTypes/HEADLESS/TextureUnspecified.conf" {
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 123 additions & 0 deletions addons/compass/UI/layouts/Map/ACE_MapDeclinationInfo.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
FrameWidgetClass {
Name "rootFrame"
Slot FrameWidgetSlot "{69A426371F908E74}" {
Anchor 0 0 1 1
PositionX 0
OffsetLeft 0
PositionY 0
OffsetTop 0
SizeX 0
OffsetRight 0
SizeY 0
OffsetBottom 0
}
"Z Order" 1
Clipping False
components {
ACE_MapDeclinationUIComponent "{69A357EF102EFDB6}" {
}
}
{
VerticalLayoutWidgetClass "{69A4441EA7DBB33C}" {
Name "VerticalLayout0"
Slot FrameWidgetSlot "{69A4441EFDA9A908}" {
Anchor 1 1 1 1
OffsetLeft 0
OffsetTop 0
OffsetRight -100
OffsetBottom -30
Alignment 1 1
SizeToContent 1
}
{
SizeLayoutWidgetClass "{69A357EBEF45C8B4}" {
Name "Layout"
Slot LayoutSlot "{69A4441D9715310F}" {
HorizontalAlign 1
VerticalAlign 1
}
AllowWidthOverride 1
WidthOverride 512
AllowHeightOverride 1
HeightOverride 256
{
OverlayWidgetClass "{69A357EB2B908260}" {
Name "Overlay0"
Slot AlignableSlot "{69A4441EF38766EB}" {
HorizontalAlign 3
VerticalAlign 3
}
{
CanvasWidgetClass "{69A357EBEF45C8BB}" {
Name "Canvas"
Slot OverlayWidgetSlot "{69A357EF1CE4E178}" {
HorizontalAlign 3
VerticalAlign 3
}
ZoomLevel 0.5
}
FrameWidgetClass "{69A37C1C722DB2DD}" {
Name "Frame0"
Slot OverlayWidgetSlot "{69A37C1C722D90FB}" {
HorizontalAlign 3
VerticalAlign 3
}
{
ImageWidgetClass "{69A357EB52AAE00D}" {
Name "Star"
Slot FrameWidgetSlot "{69A411507EB895B1}" {
OffsetLeft 0
OffsetTop 0
OffsetRight -100
OffsetBottom -30
Alignment 0.5 0.5
SizeToContent 1
}
Color 0 0 0 1
Texture "{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset"
Image "favourite"
Size 32 32
}
TextWidgetClass "{69A37C1DB55A3AE2}" {
Name "MN"
Slot FrameWidgetSlot "{69A37C1C718096D9}" {
OffsetLeft 0
PositionY 0
OffsetTop 0
OffsetRight -100
OffsetBottom -30
Alignment 0.5 0.5
SizeToContent 1
}
Color 0 0 0 1
Text "MN"
}
TextWidgetClass "{69A37C1DC63472D1}" {
Name "Declination"
Slot FrameWidgetSlot "{69A37C1FDF07DC12}" {
Alignment 0.5 0.5
SizeToContent 1
}
Color 0 0 0 1
Text "0°"
}
}
}
}
}
}
}
RichTextWidgetClass "{69A4441F7D5B3F37}" {
Name "Description"
Slot LayoutSlot "{69A4441D97153040}" {
Padding 0 0 0 80
}
Color 0 0 0 1
Text "2025 MAGNETIC NORTH"\
"DECLINATION AT CENTER OF SHEET"
"Horizontal Alignment" Center
}
}
}
}
}
17 changes: 17 additions & 0 deletions addons/compass/UI/layouts/Map/ACE_MapDeclinationInfo.layout.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MetaFileClass {
Name "{584E24A7094D7F1A}UI/layouts/Map/ACE_MapDeclinationInfo.layout"
Configurations {
LayoutResourceClass PC {
}
LayoutResourceClass XBOX_ONE : PC {
}
LayoutResourceClass XBOX_SERIES : PC {
}
LayoutResourceClass PS4 : PC {
}
LayoutResourceClass PS5 : PC {
}
LayoutResourceClass HEADLESS : PC {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//------------------------------------------------------------------------------------------------
class ACE_MapDeclinationUIComponent : ScriptedWidgetComponent
{
[Attribute("-16777216", UIWidgets.ColorPicker)]
protected int m_iColor;

protected SizeLayoutWidget m_wLayout;
protected CanvasWidget m_wCanvas;
protected vector m_vCenter;
protected ImageWidget m_wStarIcon;
protected TextWidget m_wMagneticNorthLabel;
protected TextWidget m_wDeclinationText;
protected float m_fDPIScale;
protected vector m_vUnscaledMagneticVec;
protected vector m_vUnscaledPerpVec;
protected ref array<ref CanvasWidgetCommand> m_aDrawCommands;

protected const float TN_LINE_LENGTH = 2 * 104;
protected const float TN_LINE_WIDTH = 2;
protected const float MN_LINE_LENGTH = TN_LINE_LENGTH - 30;
protected const float MN_LINE_WIDTH = 4;
protected const float MN_LABEL_OFFSET = 15;
protected const float TEXT_OFFSET = 6;
protected const float ARROW_HEAD_LENGTH = 18;
protected const float ARROW_HEAD_WIDTH = 6;

//------------------------------------------------------------------------------------------------
override void HandlerAttached(Widget w)
{
m_wLayout = SizeLayoutWidget.Cast(w.FindAnyWidget("Layout"));
m_wCanvas = CanvasWidget.Cast(m_wLayout.FindAnyWidget("Canvas"));
m_wStarIcon = ImageWidget.Cast(m_wLayout.FindAnyWidget("Star"));
m_wMagneticNorthLabel = TextWidget.Cast(m_wLayout.FindAnyWidget("MN"));
m_wDeclinationText = TextWidget.Cast(m_wLayout.FindAnyWidget("Declination"));

ChimeraWorld world = GetGame().GetWorld();
if (!world)
return;

TimeAndWeatherManagerEntity manager = world.GetTimeAndWeatherManager();
if (!manager)
return;

float declination = manager.ACE_GetMagneticDeclination();
float rotation = Math.DEG2RAD * declination;
m_vUnscaledMagneticVec = Vector(Math.Sin(rotation), -Math.Cos(rotation), 0);
m_vUnscaledPerpVec = (float)declination.Sign() * Vector(-m_vUnscaledMagneticVec[1], m_vUnscaledMagneticVec[0], 0);

m_wMagneticNorthLabel.SetRotation(declination);
m_wMagneticNorthLabel.SetColorInt(m_iColor);
FrameSlot.SetAlignment(m_wMagneticNorthLabel, declination < 0, 0.5);

m_wDeclinationText.SetTextFormat("%1°", declination.ToString(lenDec: 1));
m_wDeclinationText.SetColorInt(m_iColor);
FrameSlot.SetAlignment(m_wDeclinationText, declination < 0, 0.5);
}

//------------------------------------------------------------------------------------------------
override bool OnUpdate(Widget w)
{
float dpiScale = GetGame().GetWorkspace().DPIScale(1);
if (dpiScale == m_fDPIScale)
return true;

m_fDPIScale = dpiScale;
m_vCenter = m_fDPIScale * Vector(0.5 * m_wLayout.GetWidthOverride(), m_wLayout.GetHeightOverride(), 0);
vector magneticVec = m_fDPIScale * m_vUnscaledMagneticVec;
vector perpVec = m_fDPIScale * m_vUnscaledPerpVec;

vector endPos = m_vCenter - m_fDPIScale * TN_LINE_LENGTH * vector.Up;
LineDrawCommand trueNorthLine = CreateLines({m_vCenter, endPos}, TN_LINE_WIDTH);
SetWidgetPos(m_wStarIcon, endPos);

endPos = m_vCenter + MN_LINE_LENGTH * magneticVec;
vector arrowPos = m_vCenter + (MN_LINE_LENGTH - ARROW_HEAD_LENGTH) * magneticVec + ARROW_HEAD_WIDTH * perpVec;
LineDrawCommand magneticNorthLine = CreateLines({m_vCenter, endPos, arrowPos}, MN_LINE_WIDTH);
m_aDrawCommands = {trueNorthLine, magneticNorthLine};
m_wCanvas.SetDrawCommands(m_aDrawCommands);

SetWidgetPos(m_wMagneticNorthLabel, m_vCenter + (MN_LINE_LENGTH + MN_LABEL_OFFSET) * magneticVec + TEXT_OFFSET * perpVec);
SetWidgetPos(m_wDeclinationText, m_vCenter + (MN_LINE_LENGTH / 2) * magneticVec + TEXT_OFFSET * perpVec);
return true;
}

//------------------------------------------------------------------------------------------------
protected void SetWidgetPos(Widget w, vector pos)
{
pos /= m_fDPIScale;
FrameSlot.SetPos(w, pos[0], pos[1]);
}

//------------------------------------------------------------------------------------------------
protected LineDrawCommand CreateLines(array<vector> points, float lineWidth)
{
LineDrawCommand command = new LineDrawCommand();
command.m_iColor = m_iColor;
command.m_fWidth = m_fDPIScale * lineWidth;
command.m_Vertices = {};

foreach (vector point : points)
{
command.m_Vertices.Insert(point[0]);
command.m_Vertices.Insert(point[1]);
}

return command;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//------------------------------------------------------------------------------------------------
modded class SCR_MapCompassUI : SCR_MapRTWBaseUI
{
protected SCR_MapToolEntry m_ACE_DeclinationEntry;
protected Widget m_wACE_DeclinationInfo;
protected bool m_bACE_Declination_Visible;
protected bool m_bACE_Declination_WantedVisible;

protected static const string ACE_DECLINATION_INFO_LAYOUT_NAME = "{584E24A7094D7F1A}UI/layouts/Map/ACE_MapDeclinationInfo.layout";
protected const ResourceName ACE_DECLINATION_ICON = "{694C2E8773F36418}UI/Textures/Map/ACE_DeclinationIcon.edds";

//------------------------------------------------------------------------------------------------
override void Init()
{
super.Init();

SCR_MapToolMenuUI toolMenu = SCR_MapToolMenuUI.Cast(m_MapEntity.GetMapUIComponent(SCR_MapToolMenuUI));
if (!toolMenu)
return;

m_ACE_DeclinationEntry = toolMenu.RegisterToolMenuEntry(ACE_DECLINATION_ICON, "", 11, m_bIsExclusive);
m_ACE_DeclinationEntry.m_OnClick.Insert(ACE_Declination_ToggleVisible);
}

//------------------------------------------------------------------------------------------------
protected void ACE_Declination_ToggleVisible(SCR_ButtonBaseComponent button = null)
{
ACE_Declination_SetVisible(!m_bACE_Declination_Visible);
}

//------------------------------------------------------------------------------------------------
void ACE_Declination_SetVisible(bool visible)
{
if (m_bACE_Declination_Visible == visible)
return;

if (visible)
m_wACE_DeclinationInfo = GetGame().GetWorkspace().CreateWidgets(ACE_DECLINATION_INFO_LAYOUT_NAME, m_MapEntity.GetMapWidget().GetParent());
else if (m_wACE_DeclinationInfo)
m_wACE_DeclinationInfo.RemoveFromHierarchy();

m_ACE_DeclinationEntry.SetActive(visible);
m_bACE_Declination_Visible = visible;
}

//------------------------------------------------------------------------------------------------
override void OnMapOpen(MapConfiguration config)
{
super.OnMapOpen(config);
ACE_Declination_SetVisible(m_bACE_Declination_WantedVisible);
}

//------------------------------------------------------------------------------------------------
override void OnMapClose(MapConfiguration config)
{
super.OnMapClose(config);
m_bACE_Declination_WantedVisible = m_bACE_Declination_Visible;
ACE_Declination_SetVisible(false);
}
}