Lock certain apps away when system offline.

This commit is contained in:
Michael 2017-03-10 12:29:28 -05:00
parent a9b08eb216
commit a9754b7df2
19 changed files with 100 additions and 7 deletions

View file

@ -41,6 +41,7 @@ using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("Artpad", true, "al_artpad", "Graphics")]
[RequiresUpgrade("artpad")]
[WinOpen("artpad")]

View file

@ -36,6 +36,7 @@ using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
public partial class Chat : UserControl, IShiftOSWindow
{
public Chat(string chatId)

View file

@ -41,6 +41,7 @@ using System.IO.Compression;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("Downloader", false, null, "Networking")]
[DefaultIcon("iconDownloader")]
public partial class Downloader : UserControl, IShiftOSWindow

View file

@ -34,6 +34,7 @@ using System.Windows.Forms;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications {
[MultiplayerOnly]
[Launcher("FormatEditor", true, "al_format_editor", "Games")]
[RequiresUpgrade("format_editor")]
[WinOpen("formateditor")]

View file

@ -37,6 +37,7 @@ using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[DefaultTitle("Choose graphic")] [DefaultIcon("icongraphicpicker")]
public partial class GraphicPicker : UserControl, IShiftOSWindow
{

View file

@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[RequiresUpgrade("mud_fundamentals")]
[Launcher("MUD Control Centre", true, "al_mud_control_centre", "Networking")]
[WinOpen("mud_control_centre")]

View file

@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications {
[MultiplayerOnly]
[Launcher("Name Changer", true, "al_name_changer", "Customization")]
[RequiresUpgrade("name_changer")]
[WinOpen("name_changer")]

View file

@ -37,6 +37,7 @@ using ShiftOS.Objects;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("Pong", true, "al_pong", "Games")]
[WinOpen("pong")]
[DefaultIcon("iconPong")]

View file

@ -36,6 +36,7 @@ using System.Windows.Forms;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("ShiftLetters", false, null, "Games")]
[RequiresUpgrade("shiftletters")]
[WinOpen("shiftletters")]

View file

@ -35,6 +35,7 @@ using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
{
[Launcher("ShiftLotto", true, "al_shiftlotto", "Games")]
[MultiplayerOnly]
[DefaultIcon("iconShiftLotto")]
[RequiresUpgrade("shiftlotto")]
[WinOpen("shiftlotto")]

View file

@ -36,6 +36,7 @@ using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications {
[Launcher("ShiftSweeper", true, "al_shiftsweeper", "Games")]
[RequiresUpgrade("shiftsweeper")]
[MultiplayerOnly]
[WinOpen("shiftsweeper")]
[DefaultIcon("iconShiftSweeper")]
public partial class ShiftSweeper : UserControl, IShiftOSWindow {

View file

@ -40,6 +40,7 @@ using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("Shifter", true, "al_shifter", "Customization")]
[RequiresUpgrade("shifter")]
[WinOpen("shifter")]

View file

@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications {
[Launcher("Shiftnet", false, null, "Networking")]
[MultiplayerOnly]
[DefaultIcon("iconShiftnet")]
public partial class Shiftnet : UserControl, IShiftOSWindow {
public Shiftnet() {

View file

@ -39,6 +39,7 @@ namespace ShiftOS.WinForms.Applications
{
[Launcher("Shiftorium", true, "al_shiftorium", "Utilities")]
[RequiresUpgrade("shiftorium_gui")]
[MultiplayerOnly]
[WinOpen("shiftorium")]
[DefaultTitle("Shiftorium")]
[DefaultIcon("iconShiftorium")]

View file

@ -668,5 +668,15 @@ namespace ShiftOS.WinForms
return true;
}
[Command("experience", description = "Marks a story plot as experienced without triggering the plot.", usage ="{id:}")]
[RequiresArgument("id")]
[RemoteLock]
public static bool Experience(Dictionary<string, object> args)
{
SaveSystem.CurrentSave.StoriesExperienced.Add(args["id"].ToString());
SaveSystem.SaveGame();
return true;
}
}
}

View file

@ -106,6 +106,24 @@ namespace ShiftOS.WinForms
return;
}
foreach(var attr in form.GetType().GetCustomAttributes(true))
{
if(attr is MultiplayerOnlyAttribute)
{
if(KernelWatchdog.MudConnected == false)
{
Infobox.PromptYesNo("Disconnected from MUD", "This application requires a connection to the MUD. Would you like to reconnect?", new Action<bool>((answer) =>
{
if(answer == true)
{
KernelWatchdog.MudConnected = true;
SetupWindow(form);
}
}));
return;
}
}
}
if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType()))
{

View file

@ -66,12 +66,24 @@ namespace ShiftOS.Engine
{
foreach (var attr in type.GetCustomAttributes(false))
{
if (attr is LauncherAttribute)
bool isAllowed = true;
if(attr is MultiplayerOnlyAttribute)
{
var launch = attr as LauncherAttribute;
if (launch.UpgradeInstalled)
if(KernelWatchdog.MudConnected == false)
{
win.Add(new LauncherItem { DisplayData = launch, LaunchType = type });
isAllowed = false;
}
}
if (isAllowed == true)
{
if (attr is LauncherAttribute)
{
var launch = attr as LauncherAttribute;
if (launch.UpgradeInstalled)
{
win.Add(new LauncherItem { DisplayData = launch, LaunchType = type });
}
}
}
}

View file

@ -25,8 +25,44 @@ namespace ShiftOS.Engine
}
}
private static bool _mudConnected = true;
public static bool InKernelMode { get; private set; }
public static bool MudConnected { get; set; }
public static bool MudConnected
{
get
{
return _mudConnected;
}
set
{
if(value == false)
{
foreach(var win in AppearanceManager.OpenForms)
{
foreach(var attr in win.ParentWindow.GetType().GetCustomAttributes(true))
{
if(attr is MultiplayerOnlyAttribute)
{
ConsoleEx.Bold = true;
ConsoleEx.Underline = false;
ConsoleEx.Italic = true;
ConsoleEx.ForegroundColor = ConsoleColor.Red;
Console.Write("Error:");
ConsoleEx.Bold = false;
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Cannot disconnect from multi-user domain because an app that depends on it is open.");
TerminalBackend.PrintPrompt();
return;
}
}
}
}
_mudConnected = value;
Desktop.PopulateAppLauncher();
}
}
public static bool IsSafe(Type type)
{

View file

@ -67,11 +67,14 @@ namespace ShiftOS.Engine.Scripting
{
ServerManager.MessageReceived += (msg) =>
{
if(msg.Name == "run")
if (msg.Name == "run")
{
var cntnts = JsonConvert.DeserializeObject<dynamic>(msg.Contents);
var interp = new LuaInterpreter();
interp.Execute(cntnts.script.ToString());
Desktop.InvokeOnWorkerThread(() =>
{
interp.Execute(cntnts.script.ToString());
});
}
};
}