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 @@ - + - + + + + + + + \ 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 @@ - + - + + + + + + + \ 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 { - /// - /// user mapper. - /// - public interface IUserMapper - { - /// - /// Get the real username from an identifier - /// - /// User identifier - /// The current NancyFx context - /// Matching populated IUserIdentity object, or empty - IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context); - } - - /// - /// MUD user validator. - /// - public class MUDUserValidator : IUserValidator - { - /// - /// Validate the specified username and password. - /// - /// Username. - /// Password. - public IUserIdentity Validate(string username, string password) - { - if(username == Program.AdminUsername && password == Program.AdminPassword) - { - return null; - } - else - { - return null; - } - } - } - - /// - /// MUD user identity. - /// - public class MUDUserIdentity : IUserIdentity - { - /// - /// The claims of the authenticated user. - /// - /// The claims. - public IEnumerable Claims - { - get - { - return null; - } - } - - /// - /// The username of the authenticated user. - /// - /// The name of the user. - public string UserName - { - get - { - return uname; - } - } - - /// - /// The uname. - /// - public string uname = ""; - - /// - /// Initializes a new instance of the class. - /// - /// Username. - public MUDUserIdentity(string username) - { - uname = username; - } - } - - /// - /// Authentication bootstrapper. - /// - public class AuthenticationBootstrapper : DefaultNancyBootstrapper - { - /// - /// Initialise the bootstrapper - can be used for adding pre/post hooks and - /// any other initialisation tasks that aren't specifically container setup - /// related - /// - /// Container instance for resolving types if required. - /// The startup. - /// Pipelines. - protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) - { - base.ApplicationStartup(container, pipelines); - - pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration( - container.Resolve(), - "MUD", UserPromptBehaviour.NonAjax)); - } - } - + /// /// Program. /// @@ -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(); + }; } /// 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 @@ ..\packages\DynamicLua.1.1.2.0\lib\net40-Client\DynamicLua.dll True - - ..\packages\Nancy.1.4.1\lib\net40\Nancy.dll - True - - - ..\packages\Nancy.Authentication.Basic.1.4.1\lib\net40\Nancy.Authentication.Basic.dll - True - - - ..\packages\Nancy.Hosting.Self.1.4.1\lib\net40\Nancy.Hosting.Self.dll - True - ..\Libraries\NetSockets.dll @@ -73,7 +61,6 @@ True Resources.resx - 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 @@  - - - \ 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 @@ - + 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 @@ - + - + + + + + + + \ 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 @@ + 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; + } +}