blob: 71514cbf03cdc80e1fac5d84d21d3a72c00ad41b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
using System;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
namespace WarframeClock
{
class Program
{
public static bool UseWorldStatePhp = true;
public static string VersionString = "Warframe Clock Overlay 2019-01-16";
private static Clock clock;
private static System.Threading.Timer worldStateFetchTimer;
[STAThread]
static void Main(string[] args)
{
clock = new Clock();
StartNotifyIcon();
if (UseWorldStatePhp)
StartWorldStateFetch();
StartOverlay();
}
private static void StartNotifyIcon()
{
var thread = new Thread(delegate ()
{
var iconMenu = new ContextMenu();
var icon = new NotifyIcon()
{
Text = "Warframe Clock",
ContextMenu = iconMenu,
Icon = Properties.Resources.TrayIcon
};
iconMenu.MenuItems.Add(new MenuItem(VersionString) { Enabled = false });
iconMenu.MenuItems.Add(new MenuItem("Quit", (_, __) =>
{
icon.Dispose();
Environment.Exit(0);
}));
icon.Visible = true;
Application.Run();
});
thread.Start();
}
private static void StartWorldStateFetch()
{
worldStateFetchTimer = new System.Threading.Timer(state =>
{
lock (state)
{
try
{
var worldState = WorldState.Fetch();
var cetusSyndicate = worldState.SyndicateMissions.FirstOrDefault(mi => mi.Tag == "CetusSyndicate");
if (cetusSyndicate == null)
{
Console.WriteLine("WorldState: CetusSyndicate missions not found");
return;
}
var cetusExpiry = cetusSyndicate.Expiry.Date.NumberLong;
Console.WriteLine($"WorldState: CetusSyndicate missions expire at {cetusExpiry}");
clock.CetusExpiry = cetusExpiry;
}
catch (Exception ex)
{
Console.WriteLine($"WorldState: Failed to fetch or parse worldState.php: {ex.ToString()}");
Console.WriteLine(ex.StackTrace);
}
}
}, new object(), 0, 10 * 60 * 1000 /* 10 minutes */);
}
private static void StartOverlay()
{
new ClockOverlay(clock, "Warframe.x64").Start();
}
}
}
|