Even more menu work.
This commit is contained in:
parent
920e33a2fd
commit
c3deaa23ff
7 changed files with 342 additions and 100 deletions
|
@ -40,85 +40,9 @@ namespace ShiftOS.Objects
|
|||
[Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")]
|
||||
public string Username { get; set; }
|
||||
|
||||
private List<Action> _setCpCallbacks = new List<Action>(); // everything in this list is called by Codepoints.set() and syncCp().
|
||||
private ulong _cp = 0; // locally cached codepoints counter
|
||||
private Object _cpLock = new Object(); // locked when modifying or reading the codepoints counter
|
||||
private Object _webLock = new Object(); // locked when communicating with the server
|
||||
private Timer _updTimer; // timer to start a new sync thread every 5 minutes
|
||||
|
||||
// Sync local Codepoints count with the server.
|
||||
public void syncCp()
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
lock (_cpLock)
|
||||
{
|
||||
lock (_webLock)
|
||||
{
|
||||
var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken);
|
||||
_cp = uc.GetCodepoints();
|
||||
}
|
||||
}
|
||||
foreach (Action a in _setCpCallbacks)
|
||||
a();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
// we have to write these wrapper functions so we can keep _setCpCallbacks private,
|
||||
// so that it doesn't get serialised
|
||||
public void addSetCpCallback(Action callback)
|
||||
{
|
||||
_setCpCallbacks.Add(callback);
|
||||
}
|
||||
|
||||
public void removeSetCpCallback(Action callback)
|
||||
{
|
||||
_setCpCallbacks.Remove(callback);
|
||||
}
|
||||
|
||||
public bool IsSandbox = false;
|
||||
|
||||
public ulong Codepoints
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsSandbox == true)
|
||||
return 0;
|
||||
if (_updTimer == null)
|
||||
_updTimer = new Timer((o) => syncCp(), null, 0, 300000);
|
||||
lock (_cpLock)
|
||||
{
|
||||
return _cp;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (IsSandbox == true)
|
||||
return;
|
||||
lock (_cpLock)
|
||||
{
|
||||
_cp = value;
|
||||
new Thread(() =>
|
||||
{
|
||||
lock (_webLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken);
|
||||
uc.SetCodepoints(value);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
})
|
||||
{
|
||||
IsBackground = false
|
||||
}.Start();
|
||||
}
|
||||
foreach (Action a in _setCpCallbacks)
|
||||
a();
|
||||
}
|
||||
}
|
||||
public ulong Codepoints { get; set; }
|
||||
|
||||
public Dictionary<string, bool> Upgrades { get; set; }
|
||||
public int StoryPosition { get; set; }
|
||||
|
|
|
@ -59,7 +59,6 @@ namespace ShiftOS.WinForms.Applications
|
|||
public ShiftoriumFrontend()
|
||||
{
|
||||
InitializeComponent();
|
||||
SaveSystem.CurrentSave.addSetCpCallback(updatecounter);
|
||||
updatecounter();
|
||||
Populate();
|
||||
SetList();
|
||||
|
@ -238,7 +237,6 @@ namespace ShiftOS.WinForms.Applications
|
|||
|
||||
public bool OnUnload()
|
||||
{
|
||||
SaveSystem.CurrentSave.removeSetCpCallback(updatecounter);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
188
ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs
generated
188
ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs
generated
|
@ -35,7 +35,24 @@
|
|||
this.button4 = new System.Windows.Forms.Button();
|
||||
this.button5 = new System.Windows.Forms.Button();
|
||||
this.lbticker = new System.Windows.Forms.Label();
|
||||
this.pnloptions = new System.Windows.Forms.Panel();
|
||||
this.txtubase = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtdsport = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtdsaddress = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.opt_btncancel = new System.Windows.Forms.Button();
|
||||
this.btnsave = new System.Windows.Forms.Button();
|
||||
this.flcampaign = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.btnnewgame = new System.Windows.Forms.Button();
|
||||
this.btncontinue = new System.Windows.Forms.Button();
|
||||
this.button10 = new System.Windows.Forms.Button();
|
||||
this.flmenu.SuspendLayout();
|
||||
this.pnloptions.SuspendLayout();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
this.flcampaign.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// flmenu
|
||||
|
@ -48,7 +65,7 @@
|
|||
this.flmenu.Controls.Add(this.button4);
|
||||
this.flmenu.Controls.Add(this.button5);
|
||||
this.flmenu.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||
this.flmenu.Location = new System.Drawing.Point(46, 218);
|
||||
this.flmenu.Location = new System.Drawing.Point(49, 367);
|
||||
this.flmenu.Name = "flmenu";
|
||||
this.flmenu.Size = new System.Drawing.Size(187, 145);
|
||||
this.flmenu.TabIndex = 0;
|
||||
|
@ -84,6 +101,7 @@
|
|||
this.button3.TabIndex = 2;
|
||||
this.button3.Text = "Settings";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||
//
|
||||
// button4
|
||||
//
|
||||
|
@ -116,12 +134,161 @@
|
|||
this.lbticker.Tag = "header3";
|
||||
this.lbticker.Text = "This is a tickerbar.";
|
||||
//
|
||||
// pnloptions
|
||||
//
|
||||
this.pnloptions.Controls.Add(this.txtubase);
|
||||
this.pnloptions.Controls.Add(this.label3);
|
||||
this.pnloptions.Controls.Add(this.txtdsport);
|
||||
this.pnloptions.Controls.Add(this.label2);
|
||||
this.pnloptions.Controls.Add(this.txtdsaddress);
|
||||
this.pnloptions.Controls.Add(this.label1);
|
||||
this.pnloptions.Controls.Add(this.flowLayoutPanel1);
|
||||
this.pnloptions.Location = new System.Drawing.Point(49, 26);
|
||||
this.pnloptions.Name = "pnloptions";
|
||||
this.pnloptions.Size = new System.Drawing.Size(432, 290);
|
||||
this.pnloptions.TabIndex = 2;
|
||||
//
|
||||
// txtubase
|
||||
//
|
||||
this.txtubase.Location = new System.Drawing.Point(146, 133);
|
||||
this.txtubase.Name = "txtubase";
|
||||
this.txtubase.Size = new System.Drawing.Size(225, 20);
|
||||
this.txtubase.TabIndex = 6;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(22, 136);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(106, 13);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Unite API base URL:";
|
||||
//
|
||||
// txtdsport
|
||||
//
|
||||
this.txtdsport.Location = new System.Drawing.Point(146, 85);
|
||||
this.txtdsport.Name = "txtdsport";
|
||||
this.txtdsport.Size = new System.Drawing.Size(225, 20);
|
||||
this.txtdsport.TabIndex = 4;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(22, 88);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(99, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Digital Society Port:";
|
||||
//
|
||||
// txtdsaddress
|
||||
//
|
||||
this.txtdsaddress.Location = new System.Drawing.Point(146, 54);
|
||||
this.txtdsaddress.Name = "txtdsaddress";
|
||||
this.txtdsaddress.Size = new System.Drawing.Size(225, 20);
|
||||
this.txtdsaddress.TabIndex = 2;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(22, 57);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(118, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Digital Society Address:";
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.AutoSize = true;
|
||||
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flowLayoutPanel1.Controls.Add(this.opt_btncancel);
|
||||
this.flowLayoutPanel1.Controls.Add(this.btnsave);
|
||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 259);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(432, 31);
|
||||
this.flowLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// opt_btncancel
|
||||
//
|
||||
this.opt_btncancel.AutoSize = true;
|
||||
this.opt_btncancel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.opt_btncancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.opt_btncancel.Location = new System.Drawing.Point(377, 3);
|
||||
this.opt_btncancel.Name = "opt_btncancel";
|
||||
this.opt_btncancel.Size = new System.Drawing.Size(52, 25);
|
||||
this.opt_btncancel.TabIndex = 0;
|
||||
this.opt_btncancel.Text = "Cancel";
|
||||
this.opt_btncancel.UseVisualStyleBackColor = true;
|
||||
this.opt_btncancel.Click += new System.EventHandler(this.opt_btncancel_Click);
|
||||
//
|
||||
// btnsave
|
||||
//
|
||||
this.btnsave.AutoSize = true;
|
||||
this.btnsave.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.btnsave.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnsave.Location = new System.Drawing.Point(327, 3);
|
||||
this.btnsave.Name = "btnsave";
|
||||
this.btnsave.Size = new System.Drawing.Size(44, 25);
|
||||
this.btnsave.TabIndex = 1;
|
||||
this.btnsave.Text = "Save";
|
||||
this.btnsave.UseVisualStyleBackColor = true;
|
||||
this.btnsave.Click += new System.EventHandler(this.btnsave_Click);
|
||||
//
|
||||
// flcampaign
|
||||
//
|
||||
this.flcampaign.AutoSize = true;
|
||||
this.flcampaign.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flcampaign.Controls.Add(this.btnnewgame);
|
||||
this.flcampaign.Controls.Add(this.btncontinue);
|
||||
this.flcampaign.Controls.Add(this.button10);
|
||||
this.flcampaign.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||
this.flcampaign.Location = new System.Drawing.Point(242, 364);
|
||||
this.flcampaign.Name = "flcampaign";
|
||||
this.flcampaign.Size = new System.Drawing.Size(187, 87);
|
||||
this.flcampaign.TabIndex = 3;
|
||||
//
|
||||
// btnnewgame
|
||||
//
|
||||
this.btnnewgame.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnnewgame.Location = new System.Drawing.Point(3, 3);
|
||||
this.btnnewgame.Name = "btnnewgame";
|
||||
this.btnnewgame.Size = new System.Drawing.Size(181, 23);
|
||||
this.btnnewgame.TabIndex = 0;
|
||||
this.btnnewgame.Text = "New Game";
|
||||
this.btnnewgame.UseVisualStyleBackColor = true;
|
||||
this.btnnewgame.Click += new System.EventHandler(this.btnnewgame_Click);
|
||||
//
|
||||
// btncontinue
|
||||
//
|
||||
this.btncontinue.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btncontinue.Location = new System.Drawing.Point(3, 32);
|
||||
this.btncontinue.Name = "btncontinue";
|
||||
this.btncontinue.Size = new System.Drawing.Size(181, 23);
|
||||
this.btncontinue.TabIndex = 1;
|
||||
this.btncontinue.Text = "Continue";
|
||||
this.btncontinue.UseVisualStyleBackColor = true;
|
||||
this.btncontinue.Click += new System.EventHandler(this.btncontinue_Click);
|
||||
//
|
||||
// button10
|
||||
//
|
||||
this.button10.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.button10.Location = new System.Drawing.Point(3, 61);
|
||||
this.button10.Name = "button10";
|
||||
this.button10.Size = new System.Drawing.Size(181, 23);
|
||||
this.button10.TabIndex = 4;
|
||||
this.button10.Text = "Back";
|
||||
this.button10.UseVisualStyleBackColor = true;
|
||||
this.button10.Click += new System.EventHandler(this.button10_Click);
|
||||
//
|
||||
// MainMenu
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.ClientSize = new System.Drawing.Size(1161, 566);
|
||||
this.Controls.Add(this.flcampaign);
|
||||
this.Controls.Add(this.pnloptions);
|
||||
this.Controls.Add(this.lbticker);
|
||||
this.Controls.Add(this.flmenu);
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
|
@ -129,6 +296,11 @@
|
|||
this.Text = "MainMenu";
|
||||
this.Load += new System.EventHandler(this.MainMenu_Load);
|
||||
this.flmenu.ResumeLayout(false);
|
||||
this.pnloptions.ResumeLayout(false);
|
||||
this.pnloptions.PerformLayout();
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
this.flowLayoutPanel1.PerformLayout();
|
||||
this.flcampaign.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -143,5 +315,19 @@
|
|||
private System.Windows.Forms.Button button4;
|
||||
private System.Windows.Forms.Button button5;
|
||||
private System.Windows.Forms.Label lbticker;
|
||||
private System.Windows.Forms.Panel pnloptions;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.Button opt_btncancel;
|
||||
private System.Windows.Forms.Button btnsave;
|
||||
private System.Windows.Forms.TextBox txtubase;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox txtdsport;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox txtdsaddress;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.FlowLayoutPanel flcampaign;
|
||||
private System.Windows.Forms.Button btnnewgame;
|
||||
private System.Windows.Forms.Button btncontinue;
|
||||
private System.Windows.Forms.Button button10;
|
||||
}
|
||||
}
|
|
@ -47,11 +47,20 @@ namespace ShiftOS.WinForms.MainMenu
|
|||
tickermove.Interval = 1;
|
||||
tickerreset.Interval = 1000;
|
||||
|
||||
pnloptions.Hide();
|
||||
flcampaign.Hide();
|
||||
flmenu.CenterParent();
|
||||
|
||||
tickerreset.Start();
|
||||
}
|
||||
|
||||
public void HideOptions()
|
||||
{
|
||||
pnloptions.Hide();
|
||||
flmenu.BringToFront();
|
||||
flmenu.CenterParent();
|
||||
}
|
||||
|
||||
private void MainMenu_Load(object sender, EventArgs e)
|
||||
{
|
||||
Tools.ControlManager.SetupControls(this);
|
||||
|
@ -76,6 +85,12 @@ namespace ShiftOS.WinForms.MainMenu
|
|||
return "Terminal too weird for ya? You can use the Format Editor to generate your own Terminal command parser. No coding knowledge needed!";
|
||||
case 5:
|
||||
return "Contests are a good way to earn heaps of Codepoints. Head on over to http://getshiftos.ml/Contests for info on current community contests.";
|
||||
case 6:
|
||||
return "There's no bugs in this game... But if you find some, please submit them to http://getshiftos.ml/Bugs.";
|
||||
case 7:
|
||||
return "SHIFTOS - PROPERTY OF MICHAEL VANOVERBEEK. FOR INTERNAL USE ONLY. Build number = sos_tr_133764 [Just kidding. ShiftOS is open-source. Find the code at http://github.com/shiftos-game/ShiftOS!]";
|
||||
case 8:
|
||||
return "Hold your Codepoints against the wall... when they take everything away. Hold your Codepoints against the wall...";
|
||||
default:
|
||||
return "Good God. We don't know what to put here.";
|
||||
}
|
||||
|
@ -83,7 +98,18 @@ namespace ShiftOS.WinForms.MainMenu
|
|||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Desktop.CurrentDesktop.Show();
|
||||
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();
|
||||
}
|
||||
|
||||
private void button5_Click(object sender, EventArgs e)
|
||||
|
@ -96,5 +122,97 @@ namespace ShiftOS.WinForms.MainMenu
|
|||
(Desktop.CurrentDesktop as WinformsDesktop).IsSandbox = true;
|
||||
Desktop.CurrentDesktop.Show();
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
var conf = ShiftOS.Objects.UserConfig.Get();
|
||||
|
||||
txtubase.Text = conf.UniteUrl;
|
||||
txtdsaddress.Text = conf.DigitalSocietyAddress;
|
||||
txtdsport.Text = conf.DigitalSocietyPort.ToString();
|
||||
|
||||
|
||||
pnloptions.Show();
|
||||
pnloptions.BringToFront();
|
||||
pnloptions.CenterParent();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Infobox.Show("Invalid port number", "The Digital Society Port must be a valid whole number between 0 and 65535.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p < 0 || p > 65535)
|
||||
{
|
||||
Infobox.Show("Invalid port number", "The Digital Society Port must be a valid whole number between 0 and 65535.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
conf.DigitalSocietyPort = p;
|
||||
|
||||
string unite = txtubase.Text;
|
||||
if (unite.EndsWith("/"))
|
||||
{
|
||||
int len = unite.Length;
|
||||
int index = len - 1;
|
||||
int end = 1;
|
||||
unite = unite.Remove(index, end);
|
||||
}
|
||||
conf.UniteUrl = unite;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private void btncontinue_Click(object sender, EventArgs e)
|
||||
{
|
||||
Desktop.CurrentDesktop.Show();
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
Desktop.CurrentDesktop.Show();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Desktop.CurrentDesktop.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,10 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
if (play)
|
||||
{
|
||||
while(_out.PlaybackState == PlaybackState.Playing)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
ShiftOS.Engine.AudioManager.Stop();
|
||||
_out = new WaveOut();
|
||||
var mp3 = new WaveFileReader(str);
|
||||
|
|
|
@ -94,6 +94,15 @@ namespace ShiftOS.Engine
|
|||
|
||||
}
|
||||
|
||||
public static string SaveDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
return System.IO.Path.Combine(appdata, "ShiftOS", "saves");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all full paths without their keynames.
|
||||
/// </summary>
|
||||
|
|
|
@ -575,14 +575,14 @@ namespace ShiftOS.Engine
|
|||
public static void ReadSave()
|
||||
{
|
||||
//Migrate old saves.
|
||||
if(System.IO.Directory.Exists("C:\\ShiftOS2"))
|
||||
if (System.IO.Directory.Exists("C:\\ShiftOS2"))
|
||||
{
|
||||
Console.WriteLine("Old save detected. Migrating filesystem to MFS...");
|
||||
foreach (string file in System.IO.Directory.EnumerateDirectories("C:\\ShiftOS2")
|
||||
.Select(d => new DirectoryInfo(d).FullName))
|
||||
{
|
||||
if(!Utils.DirectoryExists(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/")))
|
||||
Utils.CreateDirectory(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"));
|
||||
if (!Utils.DirectoryExists(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/")))
|
||||
Utils.CreateDirectory(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"));
|
||||
}
|
||||
foreach (string file in System.IO.Directory.EnumerateFiles("C:\\ShiftOS2"))
|
||||
{
|
||||
|
@ -594,25 +594,18 @@ namespace ShiftOS.Engine
|
|||
|
||||
}
|
||||
|
||||
string path = Path.Combine(Paths.SaveDirectory, "autosave.save");
|
||||
|
||||
if (Utils.FileExists(Paths.SaveFileInner))
|
||||
if (System.IO.File.Exists(Path.Combine(Paths.SaveDirectory, "autosave.save")))
|
||||
{
|
||||
oobe.ShowSaveTransfer(JsonConvert.DeserializeObject<Save>(Utils.ReadAllText(Paths.SaveFileInner)));
|
||||
CurrentSave = JsonConvert.DeserializeObject<Save>(System.IO.File.ReadAllText(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Utils.FileExists(Paths.GetPath("user.dat")))
|
||||
{
|
||||
string token = Utils.ReadAllText(Paths.GetPath("user.dat"));
|
||||
|
||||
ServerManager.SendMessage("mud_token_login", token);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewSave();
|
||||
}
|
||||
NewSave();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -644,15 +637,25 @@ namespace ShiftOS.Engine
|
|||
Console.Write("{SE_SAVING}... ");
|
||||
if (SaveSystem.CurrentSave != null)
|
||||
{
|
||||
Utils.WriteAllText(Paths.GetPath("user.dat"), CurrentSave.UniteAuthToken);
|
||||
var serialisedSaveFile = JsonConvert.SerializeObject(CurrentSave, Formatting.Indented);
|
||||
new Thread(() =>
|
||||
{
|
||||
// please don't do networking on the main thread if you're just going to
|
||||
// discard the response, it's extremely slow
|
||||
ServerManager.SendMessage("mud_save", serialisedSaveFile);
|
||||
try
|
||||
{
|
||||
// please don't do networking on the main thread if you're just going to
|
||||
// discard the response, it's extremely slow
|
||||
ServerManager.SendMessage("mud_save", serialisedSaveFile);
|
||||
}
|
||||
catch { }
|
||||
})
|
||||
{ IsBackground = false }.Start();
|
||||
if (!System.IO.Directory.Exists(Paths.SaveDirectory))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(Paths.SaveDirectory);
|
||||
|
||||
}
|
||||
|
||||
System.IO.File.WriteAllText(Path.Combine(Paths.SaveDirectory, "autosave.save"), serialisedSaveFile);
|
||||
}
|
||||
if (!Shiftorium.Silent)
|
||||
Console.WriteLine(" ...{DONE}.");
|
||||
|
|
Reference in a new issue