diff options
| -rw-r--r-- | ShiftOS.MFSProfiler/App.config | 10 | ||||
| -rw-r--r-- | ShiftOS.Server/App.config | 10 | ||||
| -rw-r--r-- | ShiftOS.Server/Program.cs | 121 | ||||
| -rw-r--r-- | ShiftOS.Server/ShiftOS.Server.csproj | 13 | ||||
| -rw-r--r-- | ShiftOS.Server/WebAdmin.cs | 115 | ||||
| -rw-r--r-- | ShiftOS.Server/packages.config | 3 | ||||
| -rw-r--r-- | ShiftOS.WinForms/App.config | 2 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Oobe.cs | 1 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/App.config | 10 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/SaveSystem.cs | 15 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/TutorialManager.cs | 33 |
12 files changed, 77 insertions, 257 deletions
diff --git a/ShiftOS.MFSProfiler/App.config b/ShiftOS.MFSProfiler/App.config index cf88e98..efb416e 100644 --- a/ShiftOS.MFSProfiler/App.config +++ b/ShiftOS.MFSProfiler/App.config @@ -1,9 +1,15 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <runtime> - <loadFromRemoteSources enabled="true"/> + <loadFromRemoteSources enabled="true" /> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + </assemblyBinding> </runtime> </configuration>
\ No newline at end of file diff --git a/ShiftOS.Server/App.config b/ShiftOS.Server/App.config index cf88e98..efb416e 100644 --- a/ShiftOS.Server/App.config +++ b/ShiftOS.Server/App.config @@ -1,9 +1,15 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <runtime> - <loadFromRemoteSources enabled="true"/> + <loadFromRemoteSources enabled="true" /> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + </assemblyBinding> </runtime> </configuration>
\ No newline at end of file diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 3ef78ee..099df86 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -33,119 +33,10 @@ using System.IO; using Newtonsoft.Json; using System.Net; using System.Net.Sockets; -using Nancy.Hosting.Self; -using Nancy; -using Nancy.Authentication.Basic; -using Nancy.Security; -using Nancy.TinyIoc; -using Nancy.Bootstrapper; namespace ShiftOS.Server { - /// <summary> - /// user mapper. - /// </summary> - public interface IUserMapper - { - /// <summary> - /// Get the real username from an identifier - /// </summary> - /// <param name="identifier">User identifier</param> - /// <param name="context">The current NancyFx context</param> - /// <returns>Matching populated IUserIdentity object, or empty</returns> - IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context); - } - - /// <summary> - /// MUD user validator. - /// </summary> - public class MUDUserValidator : IUserValidator - { - /// <summary> - /// Validate the specified username and password. - /// </summary> - /// <param name="username">Username.</param> - /// <param name="password">Password.</param> - public IUserIdentity Validate(string username, string password) - { - if(username == Program.AdminUsername && password == Program.AdminPassword) - { - return null; - } - else - { - return null; - } - } - } - - /// <summary> - /// MUD user identity. - /// </summary> - public class MUDUserIdentity : IUserIdentity - { - /// <summary> - /// The claims of the authenticated user. - /// </summary> - /// <value>The claims.</value> - public IEnumerable<string> Claims - { - get - { - return null; - } - } - - /// <summary> - /// The username of the authenticated user. - /// </summary> - /// <value>The name of the user.</value> - public string UserName - { - get - { - return uname; - } - } - - /// <summary> - /// The uname. - /// </summary> - public string uname = ""; - - /// <summary> - /// Initializes a new instance of the <see cref="ShiftOS.Server.MUDUserIdentity"/> class. - /// </summary> - /// <param name="username">Username.</param> - public MUDUserIdentity(string username) - { - uname = username; - } - } - - /// <summary> - /// Authentication bootstrapper. - /// </summary> - public class AuthenticationBootstrapper : DefaultNancyBootstrapper - { - /// <summary> - /// Initialise the bootstrapper - can be used for adding pre/post hooks and - /// any other initialisation tasks that aren't specifically container setup - /// related - /// </summary> - /// <param name="container">Container instance for resolving types if required.</param> - /// <returns>The startup.</returns> - /// <param name="pipelines">Pipelines.</param> - protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) - { - base.ApplicationStartup(container, pipelines); - - pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration( - container.Resolve<MUDUserValidator>(), - "MUD", UserPromptBehaviour.NonAjax)); - } - } - + /// <summary> /// Program. /// </summary> @@ -294,17 +185,11 @@ namespace ShiftOS.Server } - var hConf = new HostConfiguration(); - hConf.UrlReservations.CreateAutomatically = true; - - var nancy = new NancyHost(hConf, new Uri("http://localhost:13371/")); - server.OnStopped += (o, a) => { - nancy.Stop(); - }; + Console.WriteLine("Server stopping."); - nancy.Start(); + }; } /// <summary> diff --git a/ShiftOS.Server/ShiftOS.Server.csproj b/ShiftOS.Server/ShiftOS.Server.csproj index 8db678e..ae6248c 100644 --- a/ShiftOS.Server/ShiftOS.Server.csproj +++ b/ShiftOS.Server/ShiftOS.Server.csproj @@ -37,18 +37,6 @@ <HintPath>..\packages\DynamicLua.1.1.2.0\lib\net40-Client\DynamicLua.dll</HintPath> <Private>True</Private> </Reference> - <Reference Include="Nancy, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\packages\Nancy.1.4.1\lib\net40\Nancy.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Nancy.Authentication.Basic, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\packages\Nancy.Authentication.Basic.1.4.1\lib\net40\Nancy.Authentication.Basic.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Nancy.Hosting.Self, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\packages\Nancy.Hosting.Self.1.4.1\lib\net40\Nancy.Hosting.Self.dll</HintPath> - <Private>True</Private> - </Reference> <Reference Include="NetSockets"> <HintPath>..\Libraries\NetSockets.dll</HintPath> </Reference> @@ -73,7 +61,6 @@ <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> - <Compile Include="WebAdmin.cs" /> </ItemGroup> <ItemGroup> <None Include="App.config" /> diff --git a/ShiftOS.Server/WebAdmin.cs b/ShiftOS.Server/WebAdmin.cs deleted file mode 100644 index c9ff94b..0000000 --- a/ShiftOS.Server/WebAdmin.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using Nancy; -using Nancy.Security; -using NetSockets; -using Newtonsoft.Json; -using ShiftOS.Objects; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Server -{ - public class WebAdmin : NancyModule - { - private Guid thisGuid { get; set; } - - public WebAdmin() - { - this.RequiresAuthentication(); - - - client = new NetObjectClient(); - - client.OnReceived += (o, a) => - { - var msg = a.Data.Object as ServerMessage; - if (msg.Name == "Welcome") - { - thisGuid = new Guid(msg.Contents); - } - }; - - client.Connect(Program.server.Address.MapToIPv4().ToString(), 13370); - - string template = Properties.Resources.Home; - - Get["/"] = _ => { return GetPage(template, "index.html"); }; - Get["/{page}"] = parameters => - { - return GetPage(template, parameters.page); - }; - } - - public NetObjectClient client = new NetObjectClient(); - - public string GetPage(string template, string page) - { - string pageContents = File.ReadAllText("adm/" + page); - - string page_text = template.Replace("{BODY}", pageContents); - - page_text = page_text.Replace("{IP_ADDR}", client.RemoteHost.ToString()); - page_text = page_text.Replace("{PORT}", client.RemotePort.ToString()); - - return page_text; - } - - public string GrabResource(string page) - { - var type = this.GetType(); - foreach(var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) - { - foreach(var attr in property.GetCustomAttributes(false)) - { - if(attr is PageAttribute) - { - if(page == (attr as PageAttribute).Name) - { - return property.GetGetMethod().Invoke(this, null) as string; - } - } - } - } - - return Properties.Resources.NotFound; - } - } - - public class PageAttribute :Attribute - { - public PageAttribute(string name) - { - Name = name; - } - - public string Name { get; set; } - } -} diff --git a/ShiftOS.Server/packages.config b/ShiftOS.Server/packages.config index 3e07118..5fb0f8f 100644 --- a/ShiftOS.Server/packages.config +++ b/ShiftOS.Server/packages.config @@ -1,8 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="DynamicLua" version="1.1.2.0" targetFramework="net452" /> - <package id="Nancy" version="1.4.1" targetFramework="net452" /> - <package id="Nancy.Authentication.Basic" version="1.4.1" targetFramework="net452" /> - <package id="Nancy.Hosting.Self" version="1.4.1" targetFramework="net452" /> <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" /> </packages>
\ No newline at end of file diff --git a/ShiftOS.WinForms/App.config b/ShiftOS.WinForms/App.config index a5749ef..efb416e 100644 --- a/ShiftOS.WinForms/App.config +++ b/ShiftOS.WinForms/App.config @@ -4,7 +4,7 @@ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <runtime> - <loadFromRemoteSources enabled="true"/> + <loadFromRemoteSources enabled="true" /> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 20d8ab5..b7bc3d8 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -173,6 +173,7 @@ namespace ShiftOS.WinForms Thread.Sleep(500); TextType("I will reboot your system in Tutorial Mode now. Complete the tutorial, and you shall be on your way."); SaveSystem.CurrentSave = MySave; + SaveSystem.CurrentSave.StoryPosition = 1; SaveSystem.SaveGame(); this.Invoke(new Action(() => { diff --git a/ShiftOS_TheReturn/App.config b/ShiftOS_TheReturn/App.config index cf88e98..efb416e 100644 --- a/ShiftOS_TheReturn/App.config +++ b/ShiftOS_TheReturn/App.config @@ -1,9 +1,15 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <runtime> - <loadFromRemoteSources enabled="true"/> + <loadFromRemoteSources enabled="true" /> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + </assemblyBinding> </runtime> </configuration>
\ No newline at end of file diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 537b14e..4b5312a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -149,11 +149,24 @@ namespace ShiftOS.Engine Shiftorium.Init(); - while (CurrentSave.StoryPosition < 5) + while (CurrentSave.StoryPosition < 1) { } + if(CurrentSave.StoryPosition == 1) + { + Desktop.InvokeOnWorkerThread(new Action(() => + { + TutorialManager.StartTutorial(); + })); + + while(CurrentSave.StoryPosition < 2) + { + + } + } + Thread.Sleep(75); diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index a88b3d9..30bd703 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -163,6 +163,7 @@ <Compile Include="Story.cs" /> <Compile Include="TerminalBackend.cs" /> <Compile Include="TerminalTextWriter.cs" /> + <Compile Include="TutorialManager.cs" /> <Compile Include="VirusEngine.cs" /> <Compile Include="WinOpenAttribute.cs" /> <EmbeddedResource Include="AltTabWindow.resx"> diff --git a/ShiftOS_TheReturn/TutorialManager.cs b/ShiftOS_TheReturn/TutorialManager.cs new file mode 100644 index 0000000..1d8943e --- /dev/null +++ b/ShiftOS_TheReturn/TutorialManager.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public static class TutorialManager + { + private static ITutorial _tut = null; + + public static void RegisterTutorial(ITutorial tut) + { + _tut = tut; + _tut.OnComplete += (o, a) => + { + SaveSystem.CurrentSave.StoryPosition = 2; + }; + } + + public static void StartTutorial() + { + _tut.Start(); + } + } + + public interface ITutorial + { + void Start(); + event EventHandler OnComplete; + } +} |
