Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 6528812

Browse files
committedMay 22, 2020
resize map according to window size
1 parent fed045d commit 6528812

9 files changed

+118
-42
lines changed
 

‎Elite/Elite.csproj

+6-3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@
239239
<ItemGroup>
240240
<Content Include="FodyWeavers.xml" />
241241
<Resource Include="Hourglass.ico" />
242+
<Content Include="Templates\images\galaxyL.png">
243+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
244+
</Content>
245+
<Content Include="Templates\images\galaxyP.png">
246+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
247+
</Content>
242248
<Content Include="Templates\images\powers\Aisling Duval.png">
243249
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
244250
</Content>
@@ -353,9 +359,6 @@
353359
<Content Include="Templates\images\init.png">
354360
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
355361
</Content>
356-
<Content Include="Templates\images\galaxy.png">
357-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
358-
</Content>
359362
<Content Include="Templates\images\ships\Keelback.png">
360363
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
361364
</Content>

‎Elite/FipPanel.cs

+70-22
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ internal class FipPanel
135135
private int[] _currentZoomLevel = new int[100];
136136

137137

138-
private int _currentLcdyOffset;
138+
private int _currentLcdYOffset;
139139
private int _currentLcdHeight;
140140

141141
public IntPtr FipDevicePointer;
@@ -167,6 +167,32 @@ internal class FipPanel
167167

168168
private double ScrollBarHeight => _htmlWindowHeight -7.0;
169169

170+
private int GalaxyImageDisplayWidth => _htmlWindowWidth - 10;
171+
172+
private int GalaxyImageDisplayHeight
173+
{
174+
get
175+
{
176+
double aspectRatio;
177+
178+
if (_htmlWindowWidth >= _htmlWindowHeight)
179+
{
180+
aspectRatio = History.GalaxyImageLHeight / History.GalaxyImageLWidth;
181+
}
182+
else
183+
{
184+
aspectRatio = History.GalaxyImagePHeight / History.GalaxyImagePWidth;
185+
}
186+
187+
return (int)(GalaxyImageDisplayWidth * aspectRatio);
188+
189+
}
190+
}
191+
192+
private string GalaxyImageFileName => _htmlWindowWidth >= _htmlWindowHeight ? "galaxyl.png" : "galaxyp.png";
193+
194+
private int GalaxyImageMarginTop => (int)((_htmlWindowHeight - GalaxyImageDisplayHeight) / 2.0);
195+
170196
private DirectOutputClass.PageCallback _pageCallbackDelegate;
171197
private DirectOutputClass.SoftButtonCallback _softButtonCallbackDelegate;
172198

@@ -307,7 +333,7 @@ private bool SetTab(LcdTab tab)
307333

308334
_currentTabCursor = LcdTab.None;
309335

310-
_currentLcdyOffset = 0;
336+
_currentLcdYOffset = 0;
311337

312338
File.WriteAllText(_settingsPath, ((int)_currentTab).ToString());
313339
}
@@ -618,7 +644,7 @@ private void SoftButtonCallback(IntPtr device, IntPtr buttons, IntPtr context)
618644

619645
_currentCard[(int) _currentTab]++;
620646
_currentZoomLevel[(int) _currentTab]++;
621-
_currentLcdyOffset = 0;
647+
_currentLcdYOffset = 0;
622648

623649
mustRefresh = true;
624650
}
@@ -632,16 +658,16 @@ private void SoftButtonCallback(IntPtr device, IntPtr buttons, IntPtr context)
632658
{
633659
_currentCard[(int) _currentTab]--;
634660
_currentZoomLevel[(int) _currentTab]--;
635-
_currentLcdyOffset = 0;
661+
_currentLcdYOffset = 0;
636662

637663
mustRefresh = true;
638664
}
639665

640666
break;
641667
case 2: // scroll clockwise
642-
if (state)
668+
if (state && _currentTab != LcdTab.Map)
643669
{
644-
_currentLcdyOffset += 50;
670+
_currentLcdYOffset += 50;
645671

646672
mustRender = false;
647673

@@ -651,14 +677,14 @@ private void SoftButtonCallback(IntPtr device, IntPtr buttons, IntPtr context)
651677
break;
652678
case 4: // scroll anti-clockwise
653679

654-
if (_currentLcdyOffset == 0) return;
680+
if (_currentLcdYOffset == 0) return;
655681

656-
if (state)
682+
if (state && _currentTab != LcdTab.Map)
657683
{
658-
_currentLcdyOffset -= 50;
659-
if (_currentLcdyOffset < 0)
684+
_currentLcdYOffset -= 50;
685+
if (_currentLcdYOffset < 0)
660686
{
661-
_currentLcdyOffset = 0;
687+
_currentLcdYOffset = 0;
662688
}
663689

664690
mustRender = false;
@@ -825,15 +851,15 @@ private void CheckLcdOffset()
825851
{
826852
if (_currentLcdHeight <= _htmlWindowHeight)
827853
{
828-
_currentLcdyOffset = 0;
854+
_currentLcdYOffset = 0;
829855
}
830856

831-
if (_currentLcdyOffset + _htmlWindowHeight > _currentLcdHeight )
857+
if (_currentLcdYOffset + _htmlWindowHeight > _currentLcdHeight )
832858
{
833-
_currentLcdyOffset = _currentLcdHeight - _htmlWindowHeight + 4;
859+
_currentLcdYOffset = _currentLcdHeight - _htmlWindowHeight + 4;
834860
}
835861

836-
if (_currentLcdyOffset < 0) _currentLcdyOffset = 0;
862+
if (_currentLcdYOffset < 0) _currentLcdYOffset = 0;
837863
}
838864

839865
private ReturnValues AddPage(uint pageNumber, bool setActive)
@@ -909,9 +935,16 @@ private void OnImageLoad(object sender, HtmlImageLoadEventArgs e)
909935

910936
using (var graphics = Graphics.FromImage(image))
911937
{
912-
if (e.Src.ToLower() == "galaxy.png" && _currentTab == LcdTab.Map)
938+
if (e.Src.ToLower().StartsWith("galaxy") && _currentTab == LcdTab.Map)
913939
{
914-
graphics.DrawPolygon(_whitePen, History.TravelHistoryPoints.ToArray());
940+
if (e.Src.ToLower().StartsWith("galaxyl"))
941+
{
942+
graphics.DrawPolygon(_whitePen, History.TravelHistoryPointsL.ToArray());
943+
}
944+
else
945+
{
946+
graphics.DrawPolygon(_whitePen, History.TravelHistoryPointsP.ToArray());
947+
}
915948

916949
var zoomLevel = _currentZoomLevel[(int)_currentTab] / 2.0 + 1;
917950

@@ -929,8 +962,19 @@ private void OnImageLoad(object sender, HtmlImageLoadEventArgs e)
929962
var spaceX = Data.LocationData.StarPos[0];
930963
var spaceZ = Data.LocationData.StarPos[2];
931964

932-
var imgX = (spaceX - History.SpaceMinX) / (History.SpaceMaxX - History.SpaceMinX) * image.Width;
933-
var imgY = (History.SpaceMaxZ - spaceZ) / (History.SpaceMaxZ - History.SpaceMinZ) * image.Height;
965+
var imgX = 0.0;
966+
var imgY = 0.0;
967+
968+
if (e.Src.ToLower().StartsWith("galaxyl"))
969+
{
970+
imgX = (spaceX - History.SpaceMinXL) / (History.SpaceMaxXL - History.SpaceMinXL) * image.Width;
971+
imgY = (History.SpaceMaxZL - spaceZ) / (History.SpaceMaxZL - History.SpaceMinZL) * image.Height;
972+
}
973+
else
974+
{
975+
imgX = (spaceX - History.SpaceMinXP) / (History.SpaceMaxXP - History.SpaceMinXP) * image.Width;
976+
imgY = (History.SpaceMaxZP - spaceZ) / (History.SpaceMaxZP - History.SpaceMinZP) * image.Height;
977+
}
934978

935979
imgX -= markerWidth / 2.0;
936980
imgY -= markerHeight / 2.0;
@@ -1388,6 +1432,10 @@ public void RefreshDevicePage(bool mustRender = true)
13881432
{
13891433
CurrentTab = _currentTab,
13901434
CurrentPage = _currentPage,
1435+
GalaxyImageDisplayHeight = GalaxyImageDisplayHeight,
1436+
GalaxyImageDisplayWidth = GalaxyImageDisplayWidth,
1437+
GalaxyImageMarginTop = GalaxyImageMarginTop + "px",
1438+
GalaxyImageFileName = GalaxyImageFileName,
13911439

13921440
_currentZoomLevel = _currentZoomLevel[(int) _currentTab]
13931441

@@ -1562,16 +1610,16 @@ public void RefreshDevicePage(bool mustRender = true)
15621610
{
15631611
graphics.DrawImage(_htmlImage, new Rectangle(new Point(HtmlWindowXOffset, 0),
15641612
new Size(HtmlWindowUsableWidth, _htmlWindowHeight + 20)),
1565-
new Rectangle(new Point(0, _currentLcdyOffset),
1613+
new Rectangle(new Point(0, _currentLcdYOffset),
15661614
new Size(HtmlWindowUsableWidth, _htmlWindowHeight + 20)),
15671615
GraphicsUnit.Pixel);
15681616
}
15691617
}
15701618

1571-
if (_currentLcdHeight > _htmlWindowHeight)
1619+
if (_currentLcdHeight > _htmlWindowHeight && _currentTab != LcdTab.Map)
15721620
{
15731621
var scrollThumbHeight = _htmlWindowHeight / (double)_currentLcdHeight * ScrollBarHeight;
1574-
var scrollThumbYOffset = _currentLcdyOffset / (double)_currentLcdHeight * ScrollBarHeight;
1622+
var scrollThumbYOffset = _currentLcdYOffset / (double)_currentLcdHeight * ScrollBarHeight;
15751623

15761624
graphics.DrawRectangle(_scrollPen, new Rectangle(new Point(_htmlWindowWidth - 9, 2),
15771625
new Size(5, (int)ScrollBarHeight)));

‎Elite/History.cs

+38-13
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,28 @@ namespace Elite
1111
{
1212
public static class History
1313
{
14-
public const double SpaceMinX = -41715.0;
15-
public const double SpaceMaxX = 41205.0;
16-
public const double SpaceMinZ = -19737.0;
17-
public const double SpaceMaxZ = 68073.0;
14+
// 1478 x 1125
15+
16+
public const double SpaceMinXL = -41715.0;
17+
public const double SpaceMaxXL = 41205.0;
18+
public const double SpaceMinZL = -19737.0;
19+
public const double SpaceMaxZL = 68073.0;
20+
21+
// 1125 x 1478
22+
23+
public const double SpaceMinXP = -31812.8;
24+
public const double SpaceMaxXP = 31302.85;
25+
public const double SpaceMinZP = -33513.4;
26+
public const double SpaceMaxZP = 81849.41;
1827

1928
public class FSDJumpInfo
2029
{
2130
public string StarSystem { get; set; }
2231
public List<double> StarPos { get; set; }
2332
}
2433

25-
public static List<PointF> TravelHistoryPoints = new List<PointF>();
34+
public static List<PointF> TravelHistoryPointsL = new List<PointF>();
35+
public static List<PointF> TravelHistoryPointsP = new List<PointF>();
2636

2737
public class LocationInfo
2838

@@ -47,8 +57,10 @@ public class DockedInfo
4757

4858
public static Dictionary<string, List<double>> VisitedSystemList = new Dictionary<string, List<double>>();
4959

50-
private static double ImageWidth { get; set; }
51-
private static double ImageHeight { get; set; }
60+
public static double GalaxyImageLWidth { get; set; }
61+
public static double GalaxyImageLHeight { get; set; }
62+
public static double GalaxyImagePWidth { get; set; }
63+
public static double GalaxyImagePHeight { get; set; }
5264

5365
private class UnsafeNativeMethods
5466
{
@@ -94,14 +106,23 @@ public static void AddTravelPos(List<double> starPos)
94106
var y = starPos[1];
95107
var z = starPos[2];
96108

97-
var imgX = (x - SpaceMinX) / (SpaceMaxX - SpaceMinX) * ImageWidth;
98-
var imgY = (SpaceMaxZ - z) / (SpaceMaxZ - SpaceMinZ) * ImageHeight;
109+
var imgX = (x - SpaceMinXL) / (SpaceMaxXL - SpaceMinXL) * GalaxyImageLWidth;
110+
var imgY = (SpaceMaxZL - z) / (SpaceMaxZL - SpaceMinZL) * GalaxyImageLHeight;
99111

100-
TravelHistoryPoints.Add(new PointF
112+
TravelHistoryPointsL.Add(new PointF
101113
{
102114
X = (float) imgX,
103115
Y = (float) imgY
104116
});
117+
118+
imgX = (x - SpaceMinXP) / (SpaceMaxXP - SpaceMinXP) * GalaxyImagePWidth;
119+
imgY = (SpaceMaxZP - z) / (SpaceMaxZP - SpaceMinZP) * GalaxyImagePHeight;
120+
121+
TravelHistoryPointsP.Add(new PointF
122+
{
123+
X = (float)imgX,
124+
Y = (float)imgY
125+
});
105126
}
106127
}
107128

@@ -118,9 +139,13 @@ public static string GetEliteHistory()
118139

119140
try
120141
{
121-
var image = Image.FromFile(Path.Combine(App.ExePath, "Templates\\images\\galaxy.png"));
122-
ImageWidth = image.Width;
123-
ImageHeight = image.Height;
142+
var imageL = Image.FromFile(Path.Combine(App.ExePath, "Templates\\images\\galaxyL.png"));
143+
GalaxyImageLWidth = imageL.Width;
144+
GalaxyImageLHeight = imageL.Height;
145+
146+
var imageP = Image.FromFile(Path.Combine(App.ExePath, "Templates\\images\\galaxyP.png"));
147+
GalaxyImagePWidth = imageP.Width;
148+
GalaxyImagePHeight = imageP.Height;
124149

125150
var journalFiles = journalDirectory.GetFiles("Journal.*").OrderBy(x => x.LastWriteTime);
126151

‎Elite/NotifyIconResources.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
reuse the same context menu (which is a resource) again (which will have its DataContext set to the old TaskbarIcon)
1010
-->
1111
<ContextMenu x:Shared="false" x:Key="SysTrayMenu">
12-
<MenuItem Name="ToggleWindowMenuItem" Header="Toggle Mirror Window" Command="{Binding ToggleWindowCommand}" />
12+
<MenuItem Name="ToggleWindowMenuItem" Header="Toggle Window" Command="{Binding ToggleWindowCommand}" />
1313
<Separator />
1414
<MenuItem Header="Exit" Command="{Binding ExitApplicationCommand}" />
1515
</ContextMenu>

‎Elite/Templates/images/galaxy.png

-2.21 MB
Binary file not shown.

‎Elite/Templates/images/galaxyL.png

1010 KB
Loading

‎Elite/Templates/images/galaxyP.png

989 KB
Loading

‎Elite/Templates/map.cshtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
Layout = "layout.cshtml";
33
}
44

5-
<div class="main">
6-
<div class="imgcenter"><img src="galaxy.png" width="310" height="236" /></div>
5+
<div class="main" style="margin-top:@Model.GalaxyImageMarginTop">
6+
<div class="imgcenter"><img src="@Model.GalaxyImageFileName" width="@Model.GalaxyImageDisplayWidth" height="@Model.GalaxyImageDisplayHeight" /></div>
77
</div>

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The joystick is configured via joysticksettings.config
3535
</joystickSettings>
3636
```
3737

38-
There is a Toggle Mirror Window menu option in the tray icon context menu.
38+
There is a Toggle Window menu option in the tray icon context menu.
3939
This option mirrors the FIP display, that is being controlled by the HOTAS hat switch, to a window for use in VR.
4040

4141
If FipSerialNumber in joysticksettings.config has the special value "window", then a separate window is created,

0 commit comments

Comments
 (0)
This repository has been archived.