aboutsummaryrefslogtreecommitdiff
path: root/Histacom2/TitleScreen.cs
blob: 93d3a6720397e87c118ed5b9d8cbce5db30501e5 (plain) (blame)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
using Histacom2.Properties;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Histacom2.OS.Win95;
using Histacom2.OS.Win98;
using Histacom2.Engine;
using static Histacom2.Engine.SaveSystem;
using Histacom2.SaveDialogs;
using System.Runtime.InteropServices;
using System.Reflection;
using System.ComponentModel;
using Histacom2.OS.WinXPBad;

namespace Histacom2
{
    public partial class TitleScreen : Form
    {
        public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();

        public static Windows95 frm95;
        public static Windows98 frm98;
        public static WindowsXPBad frmBadXP;
        public static string gameVersion = "Version 2.0.3-dev";
        public static string username;
        public static string progress = "95";
        
        public static NewGameDialog newGameBox;
        public static LoadGameDialog loadGameBox;

        // Border stuff

        public bool max = false;

        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HT_CAPTION = 0x2;

        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd,
                         int Msg, int wParam, int lParam);
        [DllImport("user32.dll")]
        public static extern bool ReleaseCapture();


        public TitleScreen()
        {
            InitializeComponent();
            this.startmenu.Paint += (sender, args) => Paintbrush.PaintClassicBorders(sender, args, 2);
            if (!File.Exists(Path.Combine(DataDirectory, "o.k")))
            {
                SeizureWarning sw = new SeizureWarning();
                sw.Size = programContent.Size;
                programContent.Controls.Add(sw);
                sw.BringToFront();
            }
        }

        public void StartGame()
        {
            // Time to decide which OS to start up!

			switch (CurrentSave.CurrentOS)
			{
				case "95":
					frm95 = new Windows95();
					frm95.TopMost = true;
					frm95.FormBorderStyle = FormBorderStyle.None;
					frm95.WindowState = FormWindowState.Maximized;
					//if (vm_mode.Checked)
					//{
					//    frm95.Size = new Size(Convert.ToInt32(VM_Width.Text), Convert.ToInt32(VM_Height.Text));
					//    frm95.FormBorderStyle = FormBorderStyle.Fixed3D;
					//}
					frm95.Show();
					Hide();

					break;
				case "98":
					frm98 = new Windows98();
					frm98.TopMost = true;
					frm98.FormBorderStyle = FormBorderStyle.None;
					frm98.WindowState = FormWindowState.Maximized;
					//if (vm_mode.Checked)
					//{
					//    frm98.Size = new Size(Convert.ToInt32(VM_Width.Text), Convert.ToInt32(VM_Height.Text));
					//    frm98.FormBorderStyle = FormBorderStyle.Fixed3D;
					//}
					frm98.Show();
					Hide();

					break;
				case "xpbad":
					frmBadXP = new WindowsXPBad();
					frmBadXP.TopMost = true;
					frmBadXP.FormBorderStyle = FormBorderStyle.None;
					frmBadXP.WindowState = FormWindowState.Maximized;
					//if (vm_mode.Checked)
					//{
					//    frm98.Size = new Size(Convert.ToInt32(VM_Width.Text), Convert.ToInt32(VM_Height.Text));
					//    frm98.FormBorderStyle = FormBorderStyle.Fixed3D;
					//}
					frmBadXP.Show();
					Hide();

					break;
				default:
					MessageBox.Show("WARNING! It looks like this save is corrupt!");
					MessageBox.Show("We will now open the Save troubleshooter");

					SaveFileTroubleShooter troubleshooter = new SaveFileTroubleShooter();

					troubleshooter.ShowDialog();
					break;
			}
        }

        private void VM_WidthHeight_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.')) e.Handled = true;

            // only allow one decimal point
            if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1)) e.Handled = true;
        }

        // When the TitleScreen Loads
        private void TitleScreen_Load(object sender, EventArgs e)
        {
            Directory.CreateDirectory(GameDirectory);
            Directory.CreateDirectory(DataDirectory);
            Directory.CreateDirectory(AllProfilesDirectory);

            Resources.google.Save(Path.Combine(DataDirectory, "google.jpg"));

            // Set GameVersion
            gameversion.Text = gameVersion;

            // Initialize Font
            File.WriteAllBytes(DataDirectory + "\\LeviWindows.ttf", Resources.LeviWindows);
            File.WriteAllBytes(DataDirectory + "\\windows_command_prompt.ttf", Resources.windows_command_prompt);
            File.WriteAllBytes(DataDirectory + "\\lemon-lcd.ttf", Resources.Lemon_s_LCD);
            pfc.AddFontFile(DataDirectory + "\\LeviWindows.ttf");
            pfc.AddFontFile(DataDirectory + "\\windows_command_prompt.ttf");
            pfc.AddFontFile(DataDirectory + "\\lemon-lcd.ttf");
            gameversion.Font = new Font(pfc.Families[0], 16F, FontStyle.Bold, GraphicsUnit.Point, (0));
            ProgramsToolStripMenuItem.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            DocumentsToolStripMenuItem.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            achievementsToolStripMenuItem.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            SettingsToolStripMenuItem.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            HelpToolStripMenuItem.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            ShutdownToolStripMenuItem.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
        }
        #region Menu Buttons

        #region NewGame

        // When NewGame is Clicked
        private void NewGame_Click(object sender, EventArgs e)
        {
            newGameBox = new NewGameDialog();
            newGameBox.ShowDialog();

            if (newGameBox.Successful)
            {
                NewGame();
                StartGame();
            }
        }

        public void BSODRewind(object sender, EventArgs e)
        {
            if (progress == "95")
            {
                frm95.Close();
                frm95 = null;

                try
                {
                    // Time to close all the game applications
                    foreach (Form frm in Application.OpenForms) if (frm.Tag.ToString() != "ignoreFormOnTaskbar") frm.Close();
                } catch {

                }

                // Generate fullscreen desktop
                frm95 = new Windows95();
                frm95.TopMost = true;
                frm95.FormBorderStyle = FormBorderStyle.None;
                frm95.WindowState = FormWindowState.Maximized;
                frm95.Show();
                Hide();
            }
        }
        #endregion

        #region LoadGame
        private void LoadGame_Click(object sender, EventArgs e)
        {
            loadGameBox = new LoadGameDialog();
            loadGameBox.ShowDialog();

            if (loadGameBox.successful)
            {
                LoadSave();
                SetTheme();
                StartGame();
            }            
        }
        #endregion

        #region ExitButton
        private void Exit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        #endregion

        #endregion

        private void gameversion_MouseHover(object sender, EventArgs e)
        {
            gameversion.Text = "There are no easter eggs here!";
        }

        private void gameversion_MouseLeave(object sender, EventArgs e)
        {
            gameversion.Text = gameVersion;
        }

        private void startbutton_Click(object sender, EventArgs e)
        {
            if (DevMode)
            {
                DevMode = false;
                gameversion.Text = "Developer Mode Deactivated";
            } else {
                DevMode = true;
                gameversion.Text = "Developer Mode Activated";
            }
            
        }

        private void closebutton_Click_1(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void updateText_Tick(object sender, EventArgs e)
        {
            if (gameversion.Text != gameVersion)
            {
                gameversion.Text = gameVersion;
                updateText.Stop();
            }
        }

        private void achievementsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AchievementScreen achievelist = new AchievementScreen();
            achievelist.ShowDialog();
        }
    }
}