mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 09:52:15 +00:00
unite stuffs
This commit is contained in:
parent
9a911c660f
commit
cdfba45faa
12 changed files with 650 additions and 49 deletions
36
ShiftOS.Unite/Properties/AssemblyInfo.cs
Normal file
36
ShiftOS.Unite/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ShiftOS.Unite")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ShiftOS.Unite")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e57ff1e6-3780-4510-b7ef-64731ec81bb8")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
54
ShiftOS.Unite/ShiftOS.Unite.csproj
Normal file
54
ShiftOS.Unite/ShiftOS.Unite.csproj
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E57FF1E6-3780-4510-B7EF-64731EC81BB8}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ShiftOS.Unite</RootNamespace>
|
||||
<AssemblyName>ShiftOS.Unite</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="UniteClient.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -69,7 +69,7 @@ namespace ShiftOS.WinForms.Applications
|
|||
{
|
||||
}
|
||||
|
||||
internal void OpenInternal(string title, string msg)
|
||||
internal void OpenInternal(string title, string msg, Action c)
|
||||
{
|
||||
Title = title;
|
||||
AppearanceManager.SetupDialog(this);
|
||||
|
@ -80,7 +80,7 @@ namespace ShiftOS.WinForms.Applications
|
|||
btnok.Click += (o, a) =>
|
||||
{
|
||||
AppearanceManager.Close(this);
|
||||
OpenCallback?.Invoke();
|
||||
c?.Invoke();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -89,8 +89,7 @@ namespace ShiftOS.WinForms.Applications
|
|||
|
||||
public void Open(string title, string msg, Action c = null)
|
||||
{
|
||||
OpenCallback = c;
|
||||
new Dialog().OpenInternal(title, msg);
|
||||
new Dialog().OpenInternal(title, msg, c);
|
||||
}
|
||||
|
||||
public void PromptTextInternal(string title, string message, Action<string> callback, bool isPassword)
|
||||
|
|
|
@ -36,6 +36,7 @@ using Newtonsoft.Json;
|
|||
using ShiftOS.Engine;
|
||||
using ShiftOS.Objects;
|
||||
using ShiftOS.Objects.ShiftFS;
|
||||
using ShiftOS.Unite;
|
||||
using ShiftOS.WinForms.Tools;
|
||||
|
||||
namespace ShiftOS.WinForms
|
||||
|
@ -219,55 +220,93 @@ You must join the digital society, rise up the ranks, and save us.
|
|||
t.Start();
|
||||
}
|
||||
|
||||
public void PerformUniteLogin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void PromptForLogin()
|
||||
{
|
||||
ServerMessageReceived MessageReceived = null;
|
||||
MessageReceived = (msg) =>
|
||||
Infobox.Show("Login", "Since the last time you've played ShiftOS, some changes have been made to the login system. You must now login using your website credentials.", () =>
|
||||
{
|
||||
if(msg.Name == "mud_savefile")
|
||||
Infobox.PromptYesNo("Website account", "Do you have an account at http://getshiftos.ml?", (hasAccount) =>
|
||||
{
|
||||
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
|
||||
SaveSystem.SaveGame();
|
||||
Application.Restart();
|
||||
}
|
||||
else if(msg.Name == "mud_notfound")
|
||||
{
|
||||
ServerManager.MessageReceived -= MessageReceived;
|
||||
|
||||
PromptForLogin();
|
||||
}
|
||||
};
|
||||
ServerManager.MessageReceived += MessageReceived;
|
||||
Infobox.PromptYesNo("Login", "You are missing a digital society authentication link. Would you like to generate a new link with an existing account? Choosing \"No\" will restart the session in the out-of-box experience.", (result)=>
|
||||
{
|
||||
if (result == true)
|
||||
{
|
||||
Infobox.PromptText("Login", "Please enter your digital society username.", (uname) =>
|
||||
if(hasAccount == true)
|
||||
{
|
||||
Infobox.PromptText("Login", "Please enter your password.", (pword) =>
|
||||
var loginDialog = new UniteLoginDialog((success)=>
|
||||
{
|
||||
ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new
|
||||
string token = success;
|
||||
var uClient = new UniteClient("http://getshiftos.ml", token);
|
||||
Infobox.Show("Welcome to ShiftOS.", $"Hello, {uClient.GetDisplayName()}! We've signed you into your account. We'll now try to link your ShiftOS account with your save file.", () =>
|
||||
{
|
||||
username = uname,
|
||||
password = pword
|
||||
}));
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
//restart in OOBE
|
||||
if (Objects.ShiftFS.Utils.FileExists(Paths.GetPath("user.dat")))
|
||||
{
|
||||
Utils.Delete(Paths.GetPath("user.dat"));
|
||||
ServerMessageReceived smr = null;
|
||||
smr = (msg) =>
|
||||
{
|
||||
ServerManager.MessageReceived -= smr;
|
||||
if (msg.Name == "mud_savefile")
|
||||
{
|
||||
SaveSystem.CurrentSave = JsonConvert.DeserializeObject<Save>(msg.Contents);
|
||||
SaveSystem.SaveGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkSaveFile(token);
|
||||
}
|
||||
};
|
||||
ServerManager.MessageReceived += smr;
|
||||
ServerManager.SendMessage("mud_token_login", token);
|
||||
});
|
||||
});
|
||||
AppearanceManager.SetupDialog(loginDialog);
|
||||
}
|
||||
string json = Utils.ExportMount(0);
|
||||
System.IO.File.WriteAllText(Paths.SaveFile, json);
|
||||
System.Diagnostics.Process.Start(Application.ExecutablePath);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void LinkSaveFile(string token)
|
||||
{
|
||||
Infobox.PromptText("Enter username", "Please enter the username you used for your save file before these changes.", (cuname) =>
|
||||
{
|
||||
Infobox.PromptText("Enter password", "Now, please enter the corresponding password.", (cpass) =>
|
||||
{
|
||||
ServerMessageReceived nsmr = null;
|
||||
nsmr = (nmsg) =>
|
||||
{
|
||||
ServerManager.MessageReceived -= nsmr;
|
||||
if (nmsg.Name == "mud_savefile")
|
||||
{
|
||||
var save = JsonConvert.DeserializeObject<Save>(nmsg.Contents);
|
||||
save.UniteAuthToken = token;
|
||||
Infobox.Show("That'll do it.", "Your save has been linked up! Next time you log into the ShiftOS site, your Codepoints should show on your profile. There's just a few more things we have to do.", () =>
|
||||
{
|
||||
SaveSystem.CurrentSave = save;
|
||||
SaveSystem.SaveGame();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Infobox.Show("Uh oh.", "We couldn't find a save file with those values. Please try again", () =>
|
||||
{
|
||||
LinkSaveFile(token);
|
||||
});
|
||||
}
|
||||
};
|
||||
ServerManager.MessageReceived += nsmr;
|
||||
ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new
|
||||
{
|
||||
username = cuname,
|
||||
password = cpass
|
||||
}));
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
public void ForceReboot()
|
||||
{
|
||||
string json = Utils.ExportMount(0);
|
||||
System.IO.File.WriteAllText(Paths.SaveFile, json);
|
||||
System.Diagnostics.Process.Start(Application.ExecutablePath);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
public void StartTrailer()
|
||||
|
|
|
@ -367,6 +367,12 @@
|
|||
<Compile Include="Tools\DitheringEngine.cs" />
|
||||
<Compile Include="Tools\ShiftOSMenuRenderer.cs" />
|
||||
<Compile Include="TrailerCommands.cs" />
|
||||
<Compile Include="UniteLoginDialog.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UniteLoginDialog.Designer.cs">
|
||||
<DependentUpon>UniteLoginDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="VisualBasicStuff.cs" />
|
||||
<Compile Include="WFLanguageProvider.cs" />
|
||||
<Compile Include="WidgetManager.cs" />
|
||||
|
@ -525,6 +531,9 @@
|
|||
<EmbeddedResource Include="ShiftnetSites\MainHomepage.resx">
|
||||
<DependentUpon>MainHomepage.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UniteLoginDialog.resx">
|
||||
<DependentUpon>UniteLoginDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="WindowBorder.resx">
|
||||
<DependentUpon>WindowBorder.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
123
ShiftOS.WinForms/UniteLoginDialog.Designer.cs
generated
Normal file
123
ShiftOS.WinForms/UniteLoginDialog.Designer.cs
generated
Normal file
|
@ -0,0 +1,123 @@
|
|||
namespace ShiftOS.WinForms
|
||||
{
|
||||
partial class UniteLoginDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtusername = new System.Windows.Forms.TextBox();
|
||||
this.txtpassword = new System.Windows.Forms.TextBox();
|
||||
this.btnlogin = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(16, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(84, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Tag = "header2";
|
||||
this.label1.Text = "Login to ShiftOS";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(16, 82);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(58, 13);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Username:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(16, 115);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(56, 13);
|
||||
this.label3.TabIndex = 2;
|
||||
this.label3.Text = "Password:";
|
||||
//
|
||||
// txtusername
|
||||
//
|
||||
this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtusername.Location = new System.Drawing.Point(112, 79);
|
||||
this.txtusername.Name = "txtusername";
|
||||
this.txtusername.Size = new System.Drawing.Size(424, 20);
|
||||
this.txtusername.TabIndex = 3;
|
||||
//
|
||||
// txtpassword
|
||||
//
|
||||
this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtpassword.Location = new System.Drawing.Point(112, 112);
|
||||
this.txtpassword.Name = "txtpassword";
|
||||
this.txtpassword.Size = new System.Drawing.Size(424, 20);
|
||||
this.txtpassword.TabIndex = 4;
|
||||
this.txtpassword.UseSystemPasswordChar = true;
|
||||
//
|
||||
// btnlogin
|
||||
//
|
||||
this.btnlogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnlogin.Location = new System.Drawing.Point(460, 148);
|
||||
this.btnlogin.Name = "btnlogin";
|
||||
this.btnlogin.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnlogin.TabIndex = 5;
|
||||
this.btnlogin.Text = "Login";
|
||||
this.btnlogin.UseVisualStyleBackColor = true;
|
||||
this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click);
|
||||
//
|
||||
// UniteLoginDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.btnlogin);
|
||||
this.Controls.Add(this.txtpassword);
|
||||
this.Controls.Add(this.txtusername);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "UniteLoginDialog";
|
||||
this.Size = new System.Drawing.Size(573, 192);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox txtusername;
|
||||
private System.Windows.Forms.TextBox txtpassword;
|
||||
private System.Windows.Forms.Button btnlogin;
|
||||
}
|
||||
}
|
90
ShiftOS.WinForms/UniteLoginDialog.cs
Normal file
90
ShiftOS.WinForms/UniteLoginDialog.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ShiftOS.Engine;
|
||||
using System.Net;
|
||||
|
||||
namespace ShiftOS.WinForms
|
||||
{
|
||||
public partial class UniteLoginDialog : UserControl, IShiftOSWindow
|
||||
{
|
||||
public UniteLoginDialog(Action<string> callback)
|
||||
{
|
||||
InitializeComponent();
|
||||
Callback = callback;
|
||||
}
|
||||
|
||||
private Action<string> Callback { get; set; }
|
||||
|
||||
public void OnLoad()
|
||||
{
|
||||
this.ParentForm.AcceptButton = btnlogin;
|
||||
}
|
||||
|
||||
public void OnSkinLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public bool OnUnload()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnUpgrade()
|
||||
{
|
||||
}
|
||||
|
||||
private void btnlogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
string u = txtusername.Text;
|
||||
string p = txtpassword.Text;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(u))
|
||||
{
|
||||
Infobox.Show("Please enter a username.", "You must enter a proper email address.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(p))
|
||||
{
|
||||
Infobox.Show("Please enter a password.", "You must enter a valid password.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4");
|
||||
string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}"));
|
||||
webrequest.Headers.Add("Authentication: Basic " + base64);
|
||||
var response = webrequest.GetResponse();
|
||||
var str = response.GetResponseStream();
|
||||
var reader = new System.IO.StreamReader(str);
|
||||
string result = reader.ReadToEnd();
|
||||
reader.Close();
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
response.Dispose();
|
||||
Callback?.Invoke(result);
|
||||
AppearanceManager.Close(this);
|
||||
}
|
||||
#if DEBUG
|
||||
catch(Exception ex)
|
||||
{
|
||||
Infobox.Show("Error", ex.ToString());
|
||||
}
|
||||
#else
|
||||
catch
|
||||
{
|
||||
Infobox.Show("Login failed.", "The login attempt failed due to an incorrect username and password pair.");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
ShiftOS.WinForms/UniteLoginDialog.resx
Normal file
120
ShiftOS.WinForms/UniteLoginDialog.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -266,12 +266,9 @@ namespace ShiftOS.Engine
|
|||
{
|
||||
if (Utils.FileExists(Paths.GetPath("user.dat")))
|
||||
{
|
||||
var userdat = JsonConvert.DeserializeObject<ClientSave>(Utils.ReadAllText(Paths.GetPath("user.dat")));
|
||||
string token = Utils.ReadAllText(Paths.GetPath("user.dat"));
|
||||
|
||||
ServerManager.SendMessage("mud_login", $@"{{
|
||||
username: ""{userdat.Username}"",
|
||||
password: ""{userdat.Password}""
|
||||
}}");
|
||||
ServerManager.SendMessage("mud_token_login", token);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -131,6 +131,8 @@
|
|||
<Compile Include="TerminalBackend.cs" />
|
||||
<Compile Include="TerminalTextWriter.cs" />
|
||||
<Compile Include="TutorialManager.cs" />
|
||||
<Compile Include="UniteClient.cs" />
|
||||
<Compile Include="UniteTestCommands.cs" />
|
||||
<Compile Include="VirusEngine.cs" />
|
||||
<Compile Include="WinOpenAttribute.cs" />
|
||||
<EmbeddedResource Include="Infobox.resx">
|
||||
|
|
68
ShiftOS_TheReturn/UniteClient.cs
Normal file
68
ShiftOS_TheReturn/UniteClient.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShiftOS.Unite
|
||||
{
|
||||
public class UniteClient
|
||||
{
|
||||
public string Token { get; private set; }
|
||||
public string BaseURL { get; private set; }
|
||||
|
||||
public UniteClient(string baseurl, string usertoken)
|
||||
{
|
||||
BaseURL = baseurl;
|
||||
Token = Token;
|
||||
}
|
||||
|
||||
internal string MakeCall(string url)
|
||||
{
|
||||
var webrequest = WebRequest.Create(BaseURL + url);
|
||||
webrequest.Headers.Add("Authentication: Token " + Token);
|
||||
using (var response = webrequest.GetResponse())
|
||||
{
|
||||
using (var stream = response.GetResponseStream())
|
||||
{
|
||||
using (var reader = new System.IO.StreamReader(stream))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDisplayName()
|
||||
{
|
||||
return MakeCall("/API/GetDisplayName");
|
||||
}
|
||||
|
||||
public void SetDisplayName(string value)
|
||||
{
|
||||
MakeCall("/API/SetDisplayName/" + value.ToString());
|
||||
}
|
||||
|
||||
public string GetFullName()
|
||||
{
|
||||
return MakeCall("/API/GetFullName");
|
||||
}
|
||||
|
||||
public void SetFullName(string value)
|
||||
{
|
||||
MakeCall("/API/SetFullName/" + value.ToString());
|
||||
}
|
||||
|
||||
|
||||
public long GetCodepoints()
|
||||
{
|
||||
return Convert.ToInt64(MakeCall("/API/GetCodepoints"));
|
||||
}
|
||||
|
||||
public void SetCodepoints(long value)
|
||||
{
|
||||
MakeCall("/API/SetCodepoints/" + value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
64
ShiftOS_TheReturn/UniteTestCommands.cs
Normal file
64
ShiftOS_TheReturn/UniteTestCommands.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShiftOS.Engine
|
||||
{
|
||||
[Namespace("unite")]
|
||||
public static class UniteTestCommands
|
||||
{
|
||||
[Command("login")]
|
||||
[RequiresArgument("username")]
|
||||
[RequiresArgument("password")]
|
||||
public static bool LoginTest(Dictionary<string, object> args)
|
||||
{
|
||||
string u = args["username"].ToString();
|
||||
string p = args["password"].ToString();
|
||||
var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4");
|
||||
string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}"));
|
||||
webrequest.Headers.Add("Authentication: Basic " + base64);
|
||||
var response = webrequest.GetResponse();
|
||||
var str = response.GetResponseStream();
|
||||
var reader = new System.IO.StreamReader(str);
|
||||
string result = reader.ReadToEnd();
|
||||
Console.WriteLine("Server returned: " + result);
|
||||
reader.Close();
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
response.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("linklogin")]
|
||||
[RequiresArgument("username")]
|
||||
[RequiresArgument("password")]
|
||||
public static bool LinkLogin(Dictionary<string, object> args)
|
||||
{
|
||||
string u = args["username"].ToString();
|
||||
string p = args["password"].ToString();
|
||||
var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4");
|
||||
string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}"));
|
||||
webrequest.Headers.Add("Authentication: Basic " + base64);
|
||||
var response = webrequest.GetResponse();
|
||||
var str = response.GetResponseStream();
|
||||
var reader = new System.IO.StreamReader(str);
|
||||
string result = reader.ReadToEnd();
|
||||
//If we get this far, the token is OURS. :D
|
||||
SaveSystem.CurrentSave.UniteAuthToken = result;
|
||||
Console.WriteLine("Unite says \"Access Granted!\"");
|
||||
SaveSystem.SaveGame();
|
||||
reader.Close();
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
response.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue