Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1fbe5ea

Browse files
committed
Quest debugger place markers handle retro mode
Minor fix for quest debugger place markers to handle retro mode on/off and retro mode aspect ratios.
1 parent bff417a commit 1fbe5ea

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

Assets/Scripts/Game/UserInterface/HUDPlaceMarker.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Project: Daggerfall Tools For Unity
1+
// Project: Daggerfall Tools For Unity
22
// Copyright: Copyright (C) 2009-2021 Daggerfall Workshop
33
// Web Site: http://www.dfworkshop.net
44
// License: MIT License (http://www.opensource.org/licenses/mit-license.php)
@@ -18,8 +18,8 @@
1818
namespace DaggerfallWorkshop.Game.UserInterface
1919
{
2020
/// <summary>
21-
/// A debugging class to hack a local quest site marker onto HUD.
22-
/// Not intended for gameplay - only used for bootstrapping site location in quest system.
21+
/// A debugging class to draw local quest site marker onto HUD.
22+
/// Not intended for gameplay - only used to help find site locations during quest development.
2323
/// </summary>
2424
public class HUDPlaceMarker : Panel
2525
{
@@ -64,8 +64,12 @@ public override void Update()
6464
enableMarkers = false;
6565
}
6666

67+
// Get docked HUD height
68+
float largeHUDHeight = 0;
69+
if (DaggerfallUI.Instance.DaggerfallHUD != null && DaggerfallUI.Instance.DaggerfallHUD.LargeHUD.Enabled && DaggerfallUnity.Settings.LargeHUDDocked)
70+
largeHUDHeight = DaggerfallUI.Instance.DaggerfallHUD.LargeHUD.ScreenHeight;
71+
6772
// Set marker label position and text
68-
Rect rect = Rectangle;
6973
Camera mainCamera = GameManager.Instance.MainCamera;
7074
for (int i = 0; i < siteTargets.Count; i++)
7175
{
@@ -75,7 +79,24 @@ public override void Update()
7579
if (screenPos.z < 0)
7680
siteTargets[i].markerLabel.Enabled = false;
7781

78-
Vector2 panelPos = ScreenToLocal(new Vector2(screenPos.x, rect.height - screenPos.y));
82+
// Convert label screen position into panel position based on retro mode setting
83+
// Panel is always 640x400 and scaled to fit "screen" which varies based on retro mode setting
84+
// Need to adjust for docked large HUD
85+
// Also Unity screen position is bottom-left whereas Panel position is top-left
86+
Vector2 panelPos = Vector2.zero;
87+
switch (DaggerfallUnity.Settings.RetroRenderingMode)
88+
{
89+
case 0: // Off
90+
panelPos = new Vector2(screenPos.x / LocalScale.x, (Screen.height - screenPos.y) / LocalScale.y);
91+
break;
92+
case 1: // 320x200
93+
panelPos = new Vector2(screenPos.x * 2, Screen.height / LocalScale.y - screenPos.y * 2 - largeHUDHeight / LocalScale.y);
94+
break;
95+
case 2: // 640x400
96+
panelPos = new Vector2(screenPos.x, Screen.height / LocalScale.y - screenPos.y - largeHUDHeight / LocalScale.y);
97+
break;
98+
}
99+
79100
siteTargets[i].markerLabel.Position = panelPos;
80101
siteTargets[i].markerLabel.Text = string.Format("{0} {1}", siteTargets[i].targetName, screenPos.z.ToString("[0]"));
81102
}

Assets/Scripts/Game/UserInterfaceWindows/DaggerfallHUD.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected override void Setup()
152152
NativePanel.Components.Add(midScreenTextLabel);
153153

154154
placeMarker.Size = new Vector2(640, 400);
155-
placeMarker.AutoSize = AutoSizeModes.ScaleToFit;
155+
placeMarker.AutoSize = AutoSizeModes.ScaleFreely;
156156
ParentPanel.Components.Add(placeMarker);
157157

158158
escortingFaces.Size = NativePanel.Size;

0 commit comments

Comments
 (0)