Changed up list view with some useful info.
This commit is contained in:
parent
43fed6839d
commit
e625b24851
|
|
@ -24,7 +24,7 @@
|
||||||
<Button x:Name="btnRemove" Click="btnRemove_Click">Remove</Button>
|
<Button x:Name="btnRemove" Click="btnRemove_Click">Remove</Button>
|
||||||
<!--<Button x:Name="btnLoad" Click="btnLoad_Click">Load...</Button>-->
|
<!--<Button x:Name="btnLoad" Click="btnLoad_Click">Load...</Button>-->
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ListView x:Name="lvOverlays" Grid.Row="1" SelectionChanged="lvOverlays_SelectionChanged">
|
<ListView x:Name="lvOverlays" Grid.Row="1" SelectionChanged="lvOverlays_SelectionChanged" HorizontalContentAlignment="Stretch">
|
||||||
|
|
||||||
</ListView>
|
</ListView>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -94,33 +95,39 @@ namespace VRDash
|
||||||
Thread.Sleep(10000);
|
Thread.Sleep(10000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#region Debug
|
#region Debug
|
||||||
|
#if DEBUG
|
||||||
|
//Task.Factory.StartNew(() =>
|
||||||
|
//{
|
||||||
|
// Compositor_FrameTiming previous = new Compositor_FrameTiming();
|
||||||
|
// ulong prev = 0;
|
||||||
|
// while (true)
|
||||||
|
// {
|
||||||
|
// Thread.Sleep(1000);
|
||||||
|
// Compositor_FrameTiming current = new Compositor_FrameTiming();
|
||||||
|
// current.m_nSize = (uint)Marshal.SizeOf(typeof(Compositor_FrameTiming));
|
||||||
|
// if (OpenVR.Compositor.GetFrameTiming(ref current, 0))
|
||||||
|
// {
|
||||||
|
// this.GetLogger().Debug(current.m_flTotalRenderGpuMs);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// this.GetLogger().Info("Error getting timing...");
|
||||||
|
// }
|
||||||
|
// previous = current;
|
||||||
|
|
||||||
|
// //Compositor_CumulativeStats stats = new Compositor_CumulativeStats();
|
||||||
|
// //OpenVR.Compositor.GetCumulativeStats(ref stats, (uint)Marshal.SizeOf(typeof(Compositor_CumulativeStats)));
|
||||||
|
|
||||||
//StartOverlayWindow("Discord");
|
// //this.GetLogger().Debug(stats.m_nNumFramePresents - prev);
|
||||||
|
// //prev = stats.m_nNumFramePresents;
|
||||||
|
// //stats.
|
||||||
|
|
||||||
//StartOverlayWindow("Microsoft Visual Studio");
|
// }
|
||||||
|
|
||||||
//StartOverlayWindow("Notepad++");
|
//});
|
||||||
|
#endif
|
||||||
//StartOverlayWindow("Putty");
|
#endregion
|
||||||
|
|
||||||
//StartOverlayWindow("Paint");
|
|
||||||
|
|
||||||
//Overlay.WindowOverlay obsoverlay = new Overlay.WindowOverlay("obs", "obs", new WindowSelectors.FromProcessName("obs64"), false);
|
|
||||||
//obsoverlay.Create();
|
|
||||||
//obsoverlay.DestroyOnNoWindowFound = true;
|
|
||||||
//var bringWindow = new Overlay.Actions.BringWindowToFrontAction(true);
|
|
||||||
//obsoverlay.OverlayShownActions.Add(bringWindow);
|
|
||||||
|
|
||||||
//var displays = User32.GetDisplays();
|
|
||||||
//MonitorOverlay mo0 = new MonitorOverlay("left", "Left Monitor", displays[0]);
|
|
||||||
//mo0.Create();
|
|
||||||
//MonitorOverlay mo1 = new MonitorOverlay("center", "Center Monitor", displays[1]);
|
|
||||||
//mo1.Create();
|
|
||||||
//MonitorOverlay mo2= new MonitorOverlay("right", "Right Monitor", displays[2]);
|
|
||||||
//mo2.Create();
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
|
@ -131,15 +138,18 @@ namespace VRDash
|
||||||
private void LoadProfile(Profile profile)
|
private void LoadProfile(Profile profile)
|
||||||
{
|
{
|
||||||
//Dispose of all overlays and clear list.
|
//Dispose of all overlays and clear list.
|
||||||
foreach (var overlay in OverlayManager.Overlays)
|
foreach (var overlayLVI in OverlayManager.Overlays)
|
||||||
{
|
{
|
||||||
overlay.Overlay.Dispose();
|
overlayLVI.Dispose();
|
||||||
|
overlayLVI.OverlayInfo.Overlay.Dispose();
|
||||||
}
|
}
|
||||||
OverlayManager.Overlays.Clear();
|
OverlayManager.Overlays.Clear();
|
||||||
|
|
||||||
var configs = profile.OverlayConfigs;
|
var configs = profile.OverlayConfigs;
|
||||||
|
|
||||||
foreach (var config in configs)
|
foreach (var config in configs)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
//Get type of overlay based on config type
|
//Get type of overlay based on config type
|
||||||
var attrs = OverlayInfo.GetOverlayInfos();
|
var attrs = OverlayInfo.GetOverlayInfos();
|
||||||
|
|
@ -151,7 +161,13 @@ namespace VRDash
|
||||||
|
|
||||||
UI.IOverlayEditor editor = (UI.IOverlayEditor)Activator.CreateInstance(overlayInfo.Info.EditorType, new object[] { overlay.OverlayConfig });
|
UI.IOverlayEditor editor = (UI.IOverlayEditor)Activator.CreateInstance(overlayInfo.Info.EditorType, new object[] { overlay.OverlayConfig });
|
||||||
OverlayEditorInfo overlayEditor = new OverlayEditorInfo(new UI.OverlayEditor(editor), overlay);
|
OverlayEditorInfo overlayEditor = new OverlayEditorInfo(new UI.OverlayEditor(editor), overlay);
|
||||||
OverlayManager.Overlays.Add(overlayEditor);
|
IOverlayListViewItem lvi = (IOverlayListViewItem)Activator.CreateInstance(overlayInfo.Info.ListViewType, new object[] { overlayEditor });
|
||||||
|
OverlayManager.Overlays.Add(lvi);
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
this.GetLogger().Error($"Unable to load overlay {config.Name}.", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +181,8 @@ namespace VRDash
|
||||||
var overlayInfo = attrs.Single(x => x.OverlayType == overlay.GetType());
|
var overlayInfo = attrs.Single(x => x.OverlayType == overlay.GetType());
|
||||||
UI.IOverlayEditor editor = (UI.IOverlayEditor)Activator.CreateInstance(overlayInfo.Info.EditorType, new object[] { overlay.OverlayConfig });
|
UI.IOverlayEditor editor = (UI.IOverlayEditor)Activator.CreateInstance(overlayInfo.Info.EditorType, new object[] { overlay.OverlayConfig });
|
||||||
OverlayEditorInfo overlayEditor = new OverlayEditorInfo(new UI.OverlayEditor(editor), overlay);
|
OverlayEditorInfo overlayEditor = new OverlayEditorInfo(new UI.OverlayEditor(editor), overlay);
|
||||||
OverlayManager.Overlays.Add(overlayEditor);
|
IOverlayListViewItem lvi = (IOverlayListViewItem)Activator.CreateInstance(overlayInfo.Info.ListViewType, new object[] { overlayEditor });
|
||||||
|
OverlayManager.Overlays.Add(lvi);
|
||||||
};
|
};
|
||||||
w.Content = uc;
|
w.Content = uc;
|
||||||
w.Width = 500;
|
w.Width = 500;
|
||||||
|
|
@ -177,10 +194,11 @@ namespace VRDash
|
||||||
private void btnRemove_Click(object sender, RoutedEventArgs e)
|
private void btnRemove_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if(lvOverlays.SelectedItem == null) { return; }
|
if(lvOverlays.SelectedItem == null) { return; }
|
||||||
OverlayEditorInfo overlayEditor = (OverlayEditorInfo)lvOverlays.SelectedItem;
|
IOverlayListViewItem overlayLVI = (IOverlayListViewItem)lvOverlays.SelectedItem;
|
||||||
overlayEditor.Overlay.Dispose();
|
overlayLVI.OverlayInfo.Overlay.Dispose();
|
||||||
OverlayManager.Overlays.Remove(overlayEditor);
|
overlayLVI.Dispose();
|
||||||
if (bdrContent.Child == overlayEditor.Editor)
|
OverlayManager.Overlays.Remove(overlayLVI);
|
||||||
|
if (bdrContent.Child == overlayLVI.OverlayInfo.Editor)
|
||||||
{
|
{
|
||||||
bdrContent.Child = null;
|
bdrContent.Child = null;
|
||||||
}
|
}
|
||||||
|
|
@ -189,9 +207,9 @@ namespace VRDash
|
||||||
private void lvOverlays_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void lvOverlays_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (lvOverlays.SelectedItem == null) { return; }
|
if (lvOverlays.SelectedItem == null) { return; }
|
||||||
OverlayEditorInfo overlay = (OverlayEditorInfo)lvOverlays.SelectedItem;
|
IOverlayListViewItem overlay = (IOverlayListViewItem)lvOverlays.SelectedItem;
|
||||||
|
|
||||||
bdrContent.Child = (UserControl)overlay.Editor;
|
bdrContent.Child = (UserControl)overlay.OverlayInfo.Editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnLoad_Click(object sender, RoutedEventArgs e)
|
private void btnLoad_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -27,16 +27,18 @@ namespace VRDash.Overlay
|
||||||
|
|
||||||
public class OverlayInfo : System.Attribute
|
public class OverlayInfo : System.Attribute
|
||||||
{
|
{
|
||||||
public OverlayInfo(string description, Type configType, Type editorType)
|
public OverlayInfo(string description, Type configType, Type editorType, Type listViewType)
|
||||||
{
|
{
|
||||||
Description = description;
|
Description = description;
|
||||||
ConfigType = configType;
|
ConfigType = configType;
|
||||||
EditorType = editorType;
|
EditorType = editorType;
|
||||||
|
ListViewType = listViewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Description { get; private set; }
|
public string Description { get; private set; }
|
||||||
public Type ConfigType { get; private set; }
|
public Type ConfigType { get; private set; }
|
||||||
public Type EditorType { get; private set; }
|
public Type EditorType { get; private set; }
|
||||||
|
public Type ListViewType { get; private set; }
|
||||||
|
|
||||||
public static IEnumerable<Type> GetTypesWithAttribute()
|
public static IEnumerable<Type> GetTypesWithAttribute()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,14 @@ using VRDash.UI;
|
||||||
|
|
||||||
namespace VRDash.Overlay
|
namespace VRDash.Overlay
|
||||||
{
|
{
|
||||||
[OverlayInfo("Monitor Overlay", typeof(MonitorOverlayConfig), typeof(MonitorOverlayEditor))]
|
[OverlayInfo("Monitor Overlay", typeof(MonitorOverlayConfig), typeof(MonitorOverlayEditor), typeof(MonitorListViewItem))]
|
||||||
public class MonitorOverlay : IOverlay
|
public class MonitorOverlay : IOverlay
|
||||||
{
|
{
|
||||||
|
|
||||||
public event EventHandler OverlayShown;
|
public event EventHandler OverlayShown;
|
||||||
public event EventHandler OverlayHidden;
|
public event EventHandler OverlayHidden;
|
||||||
|
|
||||||
|
//public event EventHandler Rendered;
|
||||||
|
|
||||||
public int CurrentFPS { get; private set; }
|
public int CurrentFPS { get; private set; }
|
||||||
|
|
||||||
private Task m_EventPumpTask = null;
|
private Task m_EventPumpTask = null;
|
||||||
|
|
@ -40,7 +41,7 @@ namespace VRDash.Overlay
|
||||||
|
|
||||||
public DisplayInfo DisplayInfo { get
|
public DisplayInfo DisplayInfo { get
|
||||||
{
|
{
|
||||||
return User32.GetDisplays().Single(x => x.MonitorInfo.DeviceName == Config.MonitorName);
|
return User32.GetDisplays().SingleOrDefault(x => x.MonitorInfo.DeviceName == Config.MonitorName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,17 +75,6 @@ namespace VRDash.Overlay
|
||||||
{
|
{
|
||||||
if (m_Created) { throw new Exception("This overlay has already been created."); }
|
if (m_Created) { throw new Exception("This overlay has already been created."); }
|
||||||
|
|
||||||
|
|
||||||
//Actually create the overlay
|
|
||||||
var overlay = OpenVR.Overlay;
|
|
||||||
EVROverlayError err = overlay.CreateDashboardOverlay(Config.Key, Config.Name, ref m_OverlayHandle, ref m_ThumbnailIcon);
|
|
||||||
|
|
||||||
if (err != EVROverlayError.None)
|
|
||||||
{
|
|
||||||
throw new Exception($"Error creating overlay: {err}");
|
|
||||||
}
|
|
||||||
overlay.SetOverlayInputMethod(m_OverlayHandle, VROverlayInputMethod.Mouse);
|
|
||||||
|
|
||||||
m_Running = true;
|
m_Running = true;
|
||||||
m_EventPumpTask = Task.Factory.StartNew(() => { EventPump(); });
|
m_EventPumpTask = Task.Factory.StartNew(() => { EventPump(); });
|
||||||
m_Created = true;
|
m_Created = true;
|
||||||
|
|
@ -122,7 +112,24 @@ namespace VRDash.Overlay
|
||||||
|
|
||||||
private void EventPump()
|
private void EventPump()
|
||||||
{
|
{
|
||||||
|
if (!OpenVR.IsHmdPresent())
|
||||||
|
{
|
||||||
|
this.GetLogger().Info("HMD is not present, waiting for HMD to come online.");
|
||||||
|
while (!OpenVR.IsHmdPresent())
|
||||||
|
{
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Actually create the overlay
|
||||||
var overlay = OpenVR.Overlay;
|
var overlay = OpenVR.Overlay;
|
||||||
|
EVROverlayError err = overlay.CreateDashboardOverlay(Config.Key, Config.Name, ref m_OverlayHandle, ref m_ThumbnailIcon);
|
||||||
|
|
||||||
|
if (err != EVROverlayError.None)
|
||||||
|
{
|
||||||
|
throw new Exception($"Error creating overlay: {err}");
|
||||||
|
}
|
||||||
|
overlay.SetOverlayInputMethod(m_OverlayHandle, VROverlayInputMethod.Mouse);
|
||||||
|
|
||||||
DateTime lastClick = DateTime.MinValue;
|
DateTime lastClick = DateTime.MinValue;
|
||||||
|
|
||||||
|
|
@ -171,13 +178,14 @@ namespace VRDash.Overlay
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//Skip rendering if overlay isn't visible
|
//Skip rendering if overlay isn't visible
|
||||||
#if !DEBUG
|
//#if !DEBUG
|
||||||
if ((m_OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) || overlay == null || (!overlay.IsOverlayVisible(m_OverlayHandle)))
|
if ((m_OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) || overlay == null || (!overlay.IsOverlayVisible(m_OverlayHandle)))
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
|
CurrentFPS = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -346,7 +354,8 @@ namespace VRDash.Overlay
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Acutally Render
|
#region Acutally Render
|
||||||
|
if (DisplayInfo != null)
|
||||||
|
{
|
||||||
var rect = DisplayInfo.MonitorArea;
|
var rect = DisplayInfo.MonitorArea;
|
||||||
Point pnt = new Point { X = 0, Y = 0 };
|
Point pnt = new Point { X = 0, Y = 0 };
|
||||||
pnt.X = DisplayInfo.MonitorArea.left;
|
pnt.X = DisplayInfo.MonitorArea.left;
|
||||||
|
|
@ -436,10 +445,10 @@ namespace VRDash.Overlay
|
||||||
|
|
||||||
//using ()
|
//using ()
|
||||||
{
|
{
|
||||||
var screenView = new ShaderResourceView(device, screenTexture);
|
//var screenView = new ShaderResourceView(device, screenTexture);
|
||||||
device.ImmediateContext.PixelShader.SetShaderResource(0, screenView);
|
//device.ImmediateContext.PixelShader.SetShaderResource(0, screenView);
|
||||||
|
|
||||||
var dr = new SharpDX.DataRectangle(data.Scan0, data.Stride);
|
//var dr = new SharpDX.DataRectangle(data.Scan0, data.Stride);
|
||||||
|
|
||||||
DataBox databox = device.ImmediateContext.MapSubresource(screenTexture, 0, MapMode.WriteDiscard,
|
DataBox databox = device.ImmediateContext.MapSubresource(screenTexture, 0, MapMode.WriteDiscard,
|
||||||
SharpDX.Direct3D11.MapFlags.None, out stream);
|
SharpDX.Direct3D11.MapFlags.None, out stream);
|
||||||
|
|
@ -450,35 +459,36 @@ namespace VRDash.Overlay
|
||||||
{
|
{
|
||||||
int count = 4 * data.Width * data.Height;
|
int count = 4 * data.Width * data.Height;
|
||||||
|
|
||||||
//Stride compensation. Sometimes the BMP and DX texture strides are different. This fixes it.
|
// //Stride compensation. Sometimes the BMP and DX texture strides are different. This fixes it.
|
||||||
if (databox.RowPitch == data.Stride)
|
// if (databox.RowPitch == data.Stride)
|
||||||
{
|
// {
|
||||||
|
// stream.Write(data.Scan0, 0, count);
|
||||||
|
// }
|
||||||
|
// //Truncate the extra BMP bytes.
|
||||||
|
// else if (databox.RowPitch < data.Stride)
|
||||||
|
// {
|
||||||
|
// for (int i = 0; i < data.Height; i++)
|
||||||
|
// {
|
||||||
|
// stream.Write(data.Scan0, (data.Stride * i), databox.RowPitch);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //Add some junk on empty bytes on the end to make everyone happy.
|
||||||
|
// else if (databox.RowPitch > data.Stride)
|
||||||
|
// {
|
||||||
|
// int difference = databox.RowPitch - data.Stride;
|
||||||
|
// byte[] junk = new byte[difference];
|
||||||
|
// for (int i = 0; i < data.Height; i++)
|
||||||
|
// {
|
||||||
|
// stream.Write(data.Scan0, (data.Stride * i), data.Stride);
|
||||||
|
// stream.Write(junk, 0, difference);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
stream.Write(data.Scan0, 0, count);
|
stream.Write(data.Scan0, 0, count);
|
||||||
}
|
}
|
||||||
//Truncate the extra BMP bytes.
|
|
||||||
else if (databox.RowPitch < data.Stride)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < data.Height; i++)
|
|
||||||
{
|
|
||||||
stream.Write(data.Scan0, (data.Stride * i), databox.RowPitch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Add some junk on empty bytes on the end to make everyone happy.
|
|
||||||
else if (databox.RowPitch > data.Stride)
|
|
||||||
{
|
|
||||||
int difference = databox.RowPitch - data.Stride;
|
|
||||||
byte[] junk = new byte[difference];
|
|
||||||
for (int i = 0; i < data.Height; i++)
|
|
||||||
{
|
|
||||||
stream.Write(data.Scan0, (data.Stride * i), data.Stride);
|
|
||||||
stream.Write(junk, 0, difference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VRTextureBounds_t bounds = new VRTextureBounds_t();
|
|
||||||
OpenVR.Overlay.GetOverlayTextureBounds(m_OverlayHandle, ref bounds);
|
device.ImmediateContext.UpdateSubresource(ref databox, screenTexture, 0, width, 1);
|
||||||
|
|
||||||
var texture = new Texture_t();
|
var texture = new Texture_t();
|
||||||
texture.handle = screenTexture.NativePointer;
|
texture.handle = screenTexture.NativePointer;
|
||||||
|
|
@ -503,6 +513,7 @@ namespace VRDash.Overlay
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
Thread.Sleep(20);
|
Thread.Sleep(20);
|
||||||
|
|
@ -517,7 +528,7 @@ namespace VRDash.Overlay
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clean up after we exit while loop.
|
//Clean up after we exit while loop.
|
||||||
screenTexture.Dispose();
|
screenTexture?.Dispose();
|
||||||
device.ImmediateContext.ClearState();
|
device.ImmediateContext.ClearState();
|
||||||
device.ImmediateContext.Flush();
|
device.ImmediateContext.Flush();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ using VRDash.UI;
|
||||||
|
|
||||||
namespace VRDash.Overlay
|
namespace VRDash.Overlay
|
||||||
{
|
{
|
||||||
[OverlayInfo("Window Overlay", typeof(WindowOverlayConfig), typeof(WindowOverlayEditor))]
|
[OverlayInfo("Window Overlay", typeof(WindowOverlayConfig), typeof(WindowOverlayEditor), typeof(UI.WindowOverlayListViewItem))]
|
||||||
public class WindowOverlay : IOverlay
|
public class WindowOverlay : IOverlay
|
||||||
{
|
{
|
||||||
public event EventHandler OverlayShown;
|
public event EventHandler OverlayShown;
|
||||||
|
|
@ -221,15 +221,14 @@ namespace VRDash.Overlay
|
||||||
}
|
}
|
||||||
|
|
||||||
//Skip rendering if overlay isn't visible
|
//Skip rendering if overlay isn't visible
|
||||||
#if !DEBUG
|
//#if !DEBUG
|
||||||
if ((m_OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) || overlay == null || (!overlay.IsOverlayVisible(m_OverlayHandle)))
|
if ((m_OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) || overlay == null || (!overlay.IsOverlayVisible(m_OverlayHandle)))
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
|
CurrentFPS = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region VR Events
|
#region VR Events
|
||||||
VREvent_t vrEvent = new VREvent_t();
|
VREvent_t vrEvent = new VREvent_t();
|
||||||
|
|
@ -515,10 +514,10 @@ namespace VRDash.Overlay
|
||||||
|
|
||||||
//using ()
|
//using ()
|
||||||
{
|
{
|
||||||
var screenView = new ShaderResourceView(device, screenTexture);
|
//var screenView = new ShaderResourceView(device, screenTexture);
|
||||||
device.ImmediateContext.PixelShader.SetShaderResource(0, screenView);
|
//device.ImmediateContext.PixelShader.SetShaderResource(0, screenView);
|
||||||
|
|
||||||
var dr = new SharpDX.DataRectangle(data.Scan0, data.Stride);
|
//var dr = new SharpDX.DataRectangle(data.Scan0, data.Stride);
|
||||||
|
|
||||||
DataBox databox = device.ImmediateContext.MapSubresource(screenTexture, 0, MapMode.WriteDiscard,
|
DataBox databox = device.ImmediateContext.MapSubresource(screenTexture, 0, MapMode.WriteDiscard,
|
||||||
SharpDX.Direct3D11.MapFlags.None, out stream);
|
SharpDX.Direct3D11.MapFlags.None, out stream);
|
||||||
|
|
@ -529,35 +528,36 @@ namespace VRDash.Overlay
|
||||||
{
|
{
|
||||||
int count = 4 * data.Width * data.Height;
|
int count = 4 * data.Width * data.Height;
|
||||||
|
|
||||||
//Stride compensation. Sometimes the BMP and DX texture strides are different. This fixes it.
|
// //Stride compensation. Sometimes the BMP and DX texture strides are different. This fixes it.
|
||||||
if (databox.RowPitch == data.Stride)
|
// if (databox.RowPitch == data.Stride)
|
||||||
{
|
// {
|
||||||
|
// stream.Write(data.Scan0, 0, count);
|
||||||
|
// }
|
||||||
|
// //Truncate the extra BMP bytes.
|
||||||
|
// else if (databox.RowPitch < data.Stride)
|
||||||
|
// {
|
||||||
|
// for (int i = 0; i < data.Height; i++)
|
||||||
|
// {
|
||||||
|
// stream.Write(data.Scan0, (data.Stride * i), databox.RowPitch);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //Add some junk on empty bytes on the end to make everyone happy.
|
||||||
|
// else if (databox.RowPitch > data.Stride)
|
||||||
|
// {
|
||||||
|
// int difference = databox.RowPitch - data.Stride;
|
||||||
|
// byte[] junk = new byte[difference];
|
||||||
|
// for (int i = 0; i < data.Height; i++)
|
||||||
|
// {
|
||||||
|
// stream.Write(data.Scan0, (data.Stride * i), data.Stride);
|
||||||
|
// stream.Write(junk, 0, difference);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
stream.Write(data.Scan0, 0, count);
|
stream.Write(data.Scan0, 0, count);
|
||||||
}
|
}
|
||||||
//Truncate the extra BMP bytes.
|
|
||||||
else if (databox.RowPitch < data.Stride)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < data.Height; i++)
|
|
||||||
{
|
|
||||||
stream.Write(data.Scan0, (data.Stride * i), databox.RowPitch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Add some junk on empty bytes on the end to make everyone happy.
|
|
||||||
else if (databox.RowPitch > data.Stride)
|
|
||||||
{
|
|
||||||
int difference = databox.RowPitch - data.Stride;
|
|
||||||
byte[] junk = new byte[difference];
|
|
||||||
for (int i = 0; i < data.Height; i++)
|
|
||||||
{
|
|
||||||
stream.Write(data.Scan0, (data.Stride * i), data.Stride);
|
|
||||||
stream.Write(junk, 0, difference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VRTextureBounds_t bounds = new VRTextureBounds_t();
|
|
||||||
OpenVR.Overlay.GetOverlayTextureBounds(m_OverlayHandle, ref bounds);
|
device.ImmediateContext.UpdateSubresource(ref databox, screenTexture, 0, width, 1);
|
||||||
|
|
||||||
var texture = new Texture_t();
|
var texture = new Texture_t();
|
||||||
texture.handle = screenTexture.NativePointer;
|
texture.handle = screenTexture.NativePointer;
|
||||||
|
|
@ -567,7 +567,7 @@ namespace VRDash.Overlay
|
||||||
if (result != EVROverlayError.None)
|
if (result != EVROverlayError.None)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.GetLogger().Warn($"[{Config.Name}] Error rendering: {result}");
|
this.GetLogger().Warn($"Error rendering: {result}");
|
||||||
}
|
}
|
||||||
|
|
||||||
device.ImmediateContext.UnmapSubresource(screenTexture, 0);
|
device.ImmediateContext.UnmapSubresource(screenTexture, 0);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace VRDash
|
||||||
{
|
{
|
||||||
public class OverlayManager
|
public class OverlayManager
|
||||||
{
|
{
|
||||||
public ObservableCollection<OverlayEditorInfo> Overlays { get; internal set; } = new ObservableCollection<OverlayEditorInfo>();
|
public ObservableCollection<IOverlayListViewItem> Overlays { get; internal set; } = new ObservableCollection<IOverlayListViewItem>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace VRDash
|
||||||
|
|
||||||
public string GetLoadedProfileJson()
|
public string GetLoadedProfileJson()
|
||||||
{
|
{
|
||||||
IOverlayConfig[] selection = MainWindow.OverlayManager.Overlays.Select(x => x.Overlay.OverlayConfig).ToArray();
|
IOverlayConfig[] selection = MainWindow.OverlayManager.Overlays.Select(x => x.OverlayInfo.Overlay.OverlayConfig).ToArray();
|
||||||
var profile = new Profile(selection);
|
var profile = new Profile(selection);
|
||||||
var json = JsonConvert.SerializeObject(profile, m_Settings);
|
var json = JsonConvert.SerializeObject(profile, m_Settings);
|
||||||
return json;
|
return json;
|
||||||
|
|
@ -52,6 +52,7 @@ namespace VRDash
|
||||||
|
|
||||||
public bool IsProfileSaveUpToDate()
|
public bool IsProfileSaveUpToDate()
|
||||||
{
|
{
|
||||||
|
if (!File.Exists(ConfigLocation)) { return false; }
|
||||||
return GetLoadedProfileJson() == GetDefaultProfileJson();
|
return GetLoadedProfileJson() == GetDefaultProfileJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace VRDash.UI
|
||||||
|
{
|
||||||
|
public interface IOverlayListViewItem:IDisposable
|
||||||
|
{
|
||||||
|
OverlayEditorInfo OverlayInfo { get; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<UserControl x:Class="VRDash.UI.MonitorListViewItem"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:VRDash.UI"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="50" d:DesignWidth="200">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock x:Name="tbName" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold">Name</TextBlock>
|
||||||
|
<TextBlock x:Name="tbFPS" Grid.Row="1" Grid.Column="1" Margin="0,0,10,0">Loading...</TextBlock>
|
||||||
|
<TextBlock x:Name="tbMonitor" Grid.Row="1" Grid.Column="2" FontStyle="Italic">Loading...</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
using SharpDX.DXGI;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using VRDash.Overlay;
|
||||||
|
|
||||||
|
namespace VRDash.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for WindowOverlayListViewItem.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MonitorListViewItem : UserControl,IDisposable,IOverlayListViewItem
|
||||||
|
{
|
||||||
|
public MonitorOverlay Overlay { get { return (MonitorOverlay)OverlayInfo.Overlay; } }
|
||||||
|
|
||||||
|
public OverlayEditorInfo OverlayInfo { get; private set; }
|
||||||
|
|
||||||
|
DispatcherTimer m_Timer = null;
|
||||||
|
public MonitorListViewItem(OverlayEditorInfo overlayInfo)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
OverlayInfo = overlayInfo;
|
||||||
|
|
||||||
|
m_Timer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, 300), DispatcherPriority.Normal, OnTimerTick, this.Dispatcher);
|
||||||
|
m_Timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestShit()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTimerTick(object x, object y)
|
||||||
|
{
|
||||||
|
tbName.Text = Overlay.OverlayConfig.Name;
|
||||||
|
tbFPS.Text = $"{Overlay.CurrentFPS} FPS";
|
||||||
|
tbMonitor.Text = Overlay.Config.MonitorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
m_Timer?.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<UserControl x:Class="VRDash.UI.WindowOverlayListViewItem"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:VRDash.UI"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="50" d:DesignWidth="200" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock x:Name="tbName" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold">Name</TextBlock>
|
||||||
|
<TextBlock x:Name="tbFPS" Grid.Row="1" Grid.Column="0" Margin="0,0,10,0">Loading...</TextBlock>
|
||||||
|
<TextBlock x:Name="tbWindowFound" Grid.Row="1" Grid.Column="1">Loading...</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using VRDash.Overlay;
|
||||||
|
|
||||||
|
namespace VRDash.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for WindowOverlayListViewItem.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class WindowOverlayListViewItem : UserControl, IDisposable,IOverlayListViewItem
|
||||||
|
{
|
||||||
|
public WindowOverlay Overlay { get { return (WindowOverlay)OverlayInfo.Overlay; } }
|
||||||
|
|
||||||
|
public OverlayEditorInfo OverlayInfo { get; private set; }
|
||||||
|
|
||||||
|
DispatcherTimer m_Timer = null;
|
||||||
|
public WindowOverlayListViewItem(OverlayEditorInfo overlayInfo)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
OverlayInfo = overlayInfo;
|
||||||
|
|
||||||
|
m_Timer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, 300), DispatcherPriority.Normal, OnTimerTick, this.Dispatcher);
|
||||||
|
m_Timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTimerTick(object x, object y)
|
||||||
|
{
|
||||||
|
tbName.Text = Overlay.OverlayConfig.Name;
|
||||||
|
tbFPS.Text = $"{Overlay.CurrentFPS} FPS";
|
||||||
|
|
||||||
|
if (Overlay.Config.Selector.WindowExists())
|
||||||
|
{
|
||||||
|
tbWindowFound.Text = "Window Found";
|
||||||
|
tbWindowFound.Foreground = Brushes.Green;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tbWindowFound.Text = "Window Not Found";
|
||||||
|
tbWindowFound.Foreground = Brushes.Red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
m_Timer?.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -115,6 +115,7 @@
|
||||||
<DependentUpon>CreateNewOverlay.xaml</DependentUpon>
|
<DependentUpon>CreateNewOverlay.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="UI\IOverlayEditor.cs" />
|
<Compile Include="UI\IOverlayEditor.cs" />
|
||||||
|
<Compile Include="UI\IOverlayListViewItem.cs" />
|
||||||
<Compile Include="UI\ISelectorEditor.cs" />
|
<Compile Include="UI\ISelectorEditor.cs" />
|
||||||
<Compile Include="UI\MonitorOverlayEditor.xaml.cs">
|
<Compile Include="UI\MonitorOverlayEditor.xaml.cs">
|
||||||
<DependentUpon>MonitorOverlayEditor.xaml</DependentUpon>
|
<DependentUpon>MonitorOverlayEditor.xaml</DependentUpon>
|
||||||
|
|
@ -128,6 +129,12 @@
|
||||||
<Compile Include="UI\WindowOverlayEditor.xaml.cs">
|
<Compile Include="UI\WindowOverlayEditor.xaml.cs">
|
||||||
<DependentUpon>WindowOverlayEditor.xaml</DependentUpon>
|
<DependentUpon>WindowOverlayEditor.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UI\MonitorOverlayListViewItem.xaml.cs">
|
||||||
|
<DependentUpon>MonitorOverlayListViewItem.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="UI\WindowOverlayListViewItem.xaml.cs">
|
||||||
|
<DependentUpon>WindowOverlayListViewItem.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="UI\WindowSelectorEditor.xaml.cs">
|
<Compile Include="UI\WindowSelectorEditor.xaml.cs">
|
||||||
<DependentUpon>WindowSelectorEditor.xaml</DependentUpon>
|
<DependentUpon>WindowSelectorEditor.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
@ -172,6 +179,14 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="UI\MonitorOverlayListViewItem.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="UI\WindowOverlayListViewItem.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="UI\WindowSelectorEditor.xaml">
|
<Page Include="UI\WindowSelectorEditor.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|
|
||||||
|
|
@ -54,24 +54,28 @@ namespace VRDash.WindowSelectors
|
||||||
var windows = WindowInfo.GetWindowList();
|
var windows = WindowInfo.GetWindowList();
|
||||||
if (SearchType == TitleSearchType.Contains)
|
if (SearchType == TitleSearchType.Contains)
|
||||||
{
|
{
|
||||||
var results = windows.Where(x => x.Title.ToLower().Contains(TitleFilter.ToLower()));
|
var results = windows.Where(x => x.Title.ToLower().Contains(TitleFilter.ToLower()) && x.IsVisible);
|
||||||
if(results.Count() == 0)
|
if (results.Count() == 0)
|
||||||
{
|
{
|
||||||
throw new WindowNotFoundException("No windows match the filter settings.");
|
//throw new WindowNotFoundException("No windows match the filter settings.");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return results.First();
|
return results.First();
|
||||||
|
//return windows.SingleOrDefault(x => x.Title.ToLower().Contains(TitleFilter.ToLower()));
|
||||||
}
|
}
|
||||||
if(SearchType == TitleSearchType.Regex)
|
if(SearchType == TitleSearchType.Regex)
|
||||||
{
|
{
|
||||||
var results = windows.Where(x => Regex.IsMatch(x.Title, TitleFilter));
|
var results = windows.Where(x => Regex.IsMatch(x.Title, TitleFilter) && x.IsVisible);
|
||||||
|
|
||||||
if (results.Count() == 0)
|
if (results.Count() == 0)
|
||||||
{
|
{
|
||||||
throw new WindowNotFoundException("No windows match the filter settings.");
|
//throw new WindowNotFoundException("No windows match the filter settings.");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return results.First();
|
return results.First();
|
||||||
|
//return windows.SingleOrDefault(x => Regex.IsMatch(x.Title, TitleFilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new WindowNotFoundException("Error fetching matching window.");
|
throw new WindowNotFoundException("Error fetching matching window.");
|
||||||
|
|
@ -79,6 +83,7 @@ namespace VRDash.WindowSelectors
|
||||||
|
|
||||||
public IntPtr GetWindowHandle()
|
public IntPtr GetWindowHandle()
|
||||||
{
|
{
|
||||||
|
if(Window == null) { return IntPtr.Zero; }
|
||||||
return Window.hWnd;
|
return Window.hWnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +103,10 @@ namespace VRDash.WindowSelectors
|
||||||
// return false;
|
// return false;
|
||||||
//}
|
//}
|
||||||
//return true;
|
//return true;
|
||||||
|
if(Window == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return User32.IsWindow(GetWindowHandle());
|
return User32.IsWindow(GetWindowHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue