Skip to content

Commit

Permalink
tidy up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inorton committed Jul 12, 2020
1 parent bfe8a55 commit e1d5ef1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion EDMCOverlay/EDMCOverlay/OverlayJsonServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void Start()
Logger.LogMessage("JSON server thread startup");
var banner = new Graphic
{
TTL = 5,
TTL = 15,
Id = "_",
Color = "yellow",
Size = GraphicType.FONT_LARGE,
Expand Down
21 changes: 10 additions & 11 deletions EDMCOverlay/EDMCOverlay/OverlayRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,17 @@ public void Start(OverlayJsonServer service)
{
this.StartUpdate();
});
}

[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
}

[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);

private static string GetActiveWindowTitle()
{
const int nChars = 256;
StringBuilder Buff = new StringBuilder(nChars);
IntPtr handle = GetForegroundWindow();
IntPtr handle = WindowUtils.GetForegroundWindow();

if (GetWindowText(handle, Buff, nChars) > 0)
if (WindowUtils.GetWindowText(handle, Buff, nChars) > 0)
{
return Buff.ToString();
}
Expand Down Expand Up @@ -186,7 +182,6 @@ private void Draw(Graphics draw)
}

// this causes flickering
//Glass.TopMost = true;
Clear(draw);
foreach (var id in Graphics.Keys.ToArray())
{
Expand Down Expand Up @@ -305,12 +300,16 @@ private void StartUpdate()
Thread.Sleep(500);
continue;
}
IntPtr activeWindow = GetForegroundWindow();
IntPtr activeWindow = WindowUtils.GetForegroundWindow();

bool foreground = (activeWindow == Glass.Follow.MainWindowHandle);

if (!foreground)
Debug.WriteLine("window obscured");
if (foreground)
{
Debug.WriteLine(DateTime.Now + " window foreground");
} else {
Debug.WriteLine(DateTime.Now + " window obscured");
}

bool render = (foreground && (Graphics.Values.Count > 0)) || this.ForceRender;

Expand Down
4 changes: 2 additions & 2 deletions EDMCOverlay/EDMCOverlay/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Patch Number
// Revision
//
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EDMC Overlay (c) 2017 Ian Norton
# EDMC Overlay (c) 2020 Ian Norton
## About

EDMC Overlay is a helper program for Elite:Dangerous, It provides a means for
Expand Down
12 changes: 6 additions & 6 deletions test_selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ def test_raw_messages():

overlay = edmcoverlay.Overlay()
overlay.connect()
for i in range(1, 200):
for i in range(1, 100):
print("test {}".format(i))
time.sleep(0.1)
overlay.send_raw({
"id": "foo{}".format(i),
"x": random.randint(10, 1024),
"y": (6 * i) % 960,
"color": "#ff0000",
"x": random.randint(10, 1140),
"y": (8 * i) % 960,
"color": "#ff{:02x}00".format(random.randint(32, 240)),
"text": "msg{}".format(i),
"ttl": 60,
})

time.sleep(2)
for i in range(1, 200):
overlay.send_raw({
"id": "foo{}".format(i),
Expand Down

0 comments on commit e1d5ef1

Please sign in to comment.