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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.MainMenu
{
public partial class MainMenu : Form
{
private void StartGame()
{
new Loading().Show();
}
public MainMenu(IDesktop desk)
{
InitializeComponent();
(desk as WinformsDesktop).ParentMenu = this;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
#if DEBUG
var asm = Assembly.GetExecutingAssembly();
string asmName = asm.GetName().Name;
string vstring = "";
var version = asm.GetCustomAttributes(true).FirstOrDefault(x => x is AssemblyVersionAttribute) as AssemblyVersionAttribute;
if (version != null)
vstring = version.Version;
lbbuilddetails.Text = $"{asmName} - version number: {vstring} - THIS IS AN UNSTABLE RELEASE.";
#else
lbbuilddetails.Hide();
#endif
}
public void HideOptions()
{
pnloptions.Hide();
flmenu.BringToFront();
flmenu.CenterParent();
currentMenu = flmenu;
CategoryText = Localization.Parse("{MAINMENU_TITLE}");
}
public string CategoryText
{
get
{
return lbcurrentui.Text;
}
set
{
lbcurrentui.Text = value;
lbcurrentui.CenterParent();
lbcurrentui.Top = currentMenu.Top - (lbcurrentui.Height * 2);
}
}
private Control currentMenu = null;
private void MainMenu_Load(object sender, EventArgs e)
{
Tools.ControlManager.SetupControls(this);
shiftos.CenterParent();
shiftos.Top = 35;
var tickermove = new Timer();
var tickerreset = new Timer();
tickermove.Tick += (o, a) =>
{
if (lbticker.Left <= (0 - lbticker.Width))
{
tickermove.Stop();
tickerreset.Start();
}
else
{
lbticker.Top = (this.ClientSize.Height - (lbticker.Height * 2));
lbticker.Left -= 2;
}
};
tickerreset.Tick += (o, a) =>
{
lbticker.Visible = false;
lbticker.Text = GetTickerMessage();
lbticker.Left = this.Width;
lbticker.Visible = true;
tickerreset.Stop();
tickermove.Start();
};
tickermove.Interval = 1;
tickerreset.Interval = 1000;
pnloptions.Hide();
flcampaign.Hide();
flmenu.CenterParent();
tickerreset.Start();
currentMenu = flmenu;
CategoryText = Localization.Parse("{MAINMENU_TITLE}");
//ShiftOeS easter egg
Random rnd = new Random();
int RandomNum = rnd.Next(1,100);
if (RandomNum == 42) //if we find the answer to life, universe and everything than set the logo to shiftoes
{
shiftos.Image = Properties.Resources.shiftoes;
}
}
private Random rnd = new Random();
private string GetTickerMessage()
{
return Localization.Parse("{MAINMENU_TIPTEXT_" + rnd.Next(10) + "}");
}
private void button1_Click(object sender, EventArgs e)
{
if(System.IO.File.Exists(System.IO.Path.Combine(Paths.SaveDirectory, "autosave.save")))
{
btncontinue.Show();
}
else
{
btncontinue.Hide();
}
flmenu.Hide();
flcampaign.Show();
flcampaign.BringToFront();
flcampaign.CenterParent();
currentMenu = flcampaign;
CategoryText = Localization.Parse("{MAINMENU_CAMPAIGN}");
}
private void button5_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
(Desktop.CurrentDesktop as WinformsDesktop).IsSandbox = true;
StartGame();
}
private void button3_Click(object sender, EventArgs e)
{
var conf = ShiftOS.Objects.UserConfig.Get();
txtdsaddress.Text = conf.DigitalSocietyAddress;
txtdsport.Text = conf.DigitalSocietyPort.ToString();
pnloptions.Show();
pnloptions.BringToFront();
pnloptions.CenterParent();
currentMenu = pnloptions;
CategoryText = Localization.Parse("{GEN_SETTINGS}");
}
private void opt_btncancel_Click(object sender, EventArgs e)
{
HideOptions();
}
private void btnsave_Click(object sender, EventArgs e)
{
var conf = ShiftOS.Objects.UserConfig.Get();
conf.DigitalSocietyAddress = txtdsaddress.Text;
int p = 0;
if(int.TryParse(txtdsport.Text, out p) == false || p < 0 || p > 65535)
{
Infobox.Show("{TITLE_INVALIDPORT}", "{PROMPT_INVALIDPORT}");
return;
}
conf.DigitalSocietyPort = p;
System.IO.File.WriteAllText("servers.json", Newtonsoft.Json.JsonConvert.SerializeObject(conf, Newtonsoft.Json.Formatting.Indented));
HideOptions();
}
private void button10_Click(object sender, EventArgs e)
{
flcampaign.Hide();
flmenu.Show();
flmenu.BringToFront();
flmenu.CenterParent();
currentMenu = flmenu;
CategoryText = Localization.Parse("{MAINMENU_TITLE}");
}
private void btncontinue_Click(object sender, EventArgs e)
{
StartGame();
}
private void btnnewgame_Click(object sender, EventArgs e)
{
string path = System.IO.Path.Combine(Paths.SaveDirectory, "autosave.save");
if (System.IO.File.Exists(path))
{
Infobox.PromptYesNo("Campaign", "You are about to start a new game, which will erase any previous progress. Are you sure you want to do this?", (result) =>
{
if (result == true)
{
System.IO.File.Delete(path);
StartGame();
}
});
}
else
{
StartGame();
}
}
}
}
|