1
- // Project: Daggerfall Tools For Unity
1
+ // Project: Daggerfall Tools For Unity
2
2
// Copyright: Copyright (C) 2009-2021 Daggerfall Workshop
3
3
// Web Site: http://www.dfworkshop.net
4
4
// License: MIT License (http://www.opensource.org/licenses/mit-license.php)
18
18
namespace DaggerfallWorkshop . Game . UserInterface
19
19
{
20
20
/// <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 .
23
23
/// </summary>
24
24
public class HUDPlaceMarker : Panel
25
25
{
@@ -64,8 +64,12 @@ public override void Update()
64
64
enableMarkers = false ;
65
65
}
66
66
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
+
67
72
// Set marker label position and text
68
- Rect rect = Rectangle ;
69
73
Camera mainCamera = GameManager . Instance . MainCamera ;
70
74
for ( int i = 0 ; i < siteTargets . Count ; i ++ )
71
75
{
@@ -75,7 +79,24 @@ public override void Update()
75
79
if ( screenPos . z < 0 )
76
80
siteTargets [ i ] . markerLabel . Enabled = false ;
77
81
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
+
79
100
siteTargets [ i ] . markerLabel . Position = panelPos ;
80
101
siteTargets [ i ] . markerLabel . Text = string . Format ( "{0} {1}" , siteTargets [ i ] . targetName , screenPos . z . ToString ( "[0]" ) ) ;
81
102
}
0 commit comments