diff options
| author | lempamo <[email protected]> | 2017-07-01 11:33:34 -0400 |
|---|---|---|
| committer | lempamo <[email protected]> | 2017-07-01 11:33:34 -0400 |
| commit | 1e15555a88864a6398b3bc811cc22f62be203f7b (patch) | |
| tree | 2f5bace7a231b22ba7a74279ead0d4107df31175 /TimeHACK.Main/TitleScreen.cs | |
| parent | fc728100a39bff88215b0b21602afbda9ff6b00b (diff) | |
| parent | 6357242767ded19a6f30fc1c0ecd82c0bdc62ac4 (diff) | |
| download | histacom2-1e15555a88864a6398b3bc811cc22f62be203f7b.tar.gz histacom2-1e15555a88864a6398b3bc811cc22f62be203f7b.tar.bz2 histacom2-1e15555a88864a6398b3bc811cc22f62be203f7b.zip | |
Merge remote-tracking branch 'refs/remotes/TimeHACKDevs/master'
Diffstat (limited to 'TimeHACK.Main/TitleScreen.cs')
| -rw-r--r-- | TimeHACK.Main/TitleScreen.cs | 91 |
1 files changed, 83 insertions, 8 deletions
diff --git a/TimeHACK.Main/TitleScreen.cs b/TimeHACK.Main/TitleScreen.cs index 0d7ee36..0e01d4c 100644 --- a/TimeHACK.Main/TitleScreen.cs +++ b/TimeHACK.Main/TitleScreen.cs @@ -8,12 +8,18 @@ using TimeHACK.OS.Win98; using TimeHACK.Engine; using static TimeHACK.Engine.SaveSystem; using TimeHACK.SaveDialogs; +using System.Runtime.InteropServices; +using System.Reflection; +using System.ComponentModel; namespace TimeHACK { public partial class TitleScreen : Form { public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection(); + + TimeHACK.Engine.Template.WinClassic borders = new TimeHACK.Engine.Template.WinClassic(); + public static Windows95 frm95; public static Windows98 frm98; public static string username; @@ -25,14 +31,56 @@ namespace TimeHACK public static NewGameDialog newGameBox; public static LoadGameDialog loadGameBox; + // Border stuff + + public Boolean max = false; + + public const int WM_NCLBUTTONDOWN = 0xA1; + public const int HT_CAPTION = 0x2; + + [DllImportAttribute("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, + int Msg, int wParam, int lParam); + [DllImportAttribute("user32.dll")] + public static extern bool ReleaseCapture(); + + + public TitleScreen() + { + InitializeComponent(); + + // Add the WINDOWS BORDERS from the Window Manager + + FieldInfo f1 = typeof(Control).GetField("EventMouseDown", + BindingFlags.Static | BindingFlags.NonPublic); + object obj = f1.GetValue(borders.programtopbar); + PropertyInfo pi = borders.programtopbar.GetType().GetProperty("Events", + BindingFlags.NonPublic | BindingFlags.Instance); + EventHandlerList list = (EventHandlerList)pi.GetValue(borders.programtopbar, null); + list.RemoveHandler(obj, list[obj]); + + borders.programtopbar.MouseDown += new MouseEventHandler(TitleBarDrag); + borders.programtopbar.Controls.Find("closebutton", false)[0].MouseClick += new MouseEventHandler(closeButton); + borders.programtopbar.Controls.Find("maximizebutton", false)[0].MouseClick += new MouseEventHandler(MaximiseButton); + + this.Controls.Add(borders.programtopbar); + this.Controls.Add(borders.top); + this.Controls.Add(borders.right); + this.Controls.Add(borders.left); + this.Controls.Add(borders.bottom); + + + } + public void StartGame() - { + { //TODO: You may want to handle story stuff to decide what OS to boot here. if (Convert.ToInt32(VM_Width.Text) == 1337 && Convert.ToInt32(VM_Height.Text) == 1337) { leet(); } - else { + else + { // Time to decide which OS to start up! switch (CurrentSave.CurrentOS) @@ -74,14 +122,32 @@ namespace TimeHACK troubleshooter.ShowDialog(); break; } - - } + + } } + void TitleBarDrag(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left && max == false) + { + ReleaseCapture(); + SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); + } + } - public TitleScreen() + void MaximiseButton(object sender, MouseEventArgs e) { - InitializeComponent(); + if (this.WindowState == FormWindowState.Normal) + { + this.WindowState = FormWindowState.Maximized; + } else { + this.WindowState = FormWindowState.Normal; + } + } + + void closeButton(object sender, MouseEventArgs e) + { + Close(); } private void closebutton_Click(object sender, EventArgs e) @@ -125,7 +191,7 @@ namespace TimeHACK // Set GameVersion - gameversion.Text = "TimeHACK " + Program.gameID; + gameversion.Text = Program.gameID; // Initialize Font File.WriteAllBytes(Data + "\\LeviWindows.ttf", Resources.LeviWindows); @@ -269,7 +335,7 @@ namespace TimeHACK private void gameversion_MouseLeave(object sender, EventArgs e) { - gameversion.Text = "TimeHACK " + Program.gameID; + gameversion.Text = Program.gameID; } private void startbutton_Click(object sender, EventArgs e) @@ -289,5 +355,14 @@ namespace TimeHACK { Application.Exit(); } + + private void updateText_Tick(object sender, EventArgs e) + { + if (gameversion.Text != Program.gameID) + { + gameversion.Text = Program.gameID; + updateText.Stop(); + } + } } } |
