aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-06 12:16:41 -0400
committerMichael <[email protected]>2017-05-06 12:16:41 -0400
commite131f72a9b863cc75a4db71670c41efa319886fb (patch)
treec2b8daa8e4b6ea8a3cc7d4c3d348f70386c0f3a5
parent57277a01d685b0e29a79e5d74a1465a2ceb23ef9 (diff)
downloadshiftos_thereturn-e131f72a9b863cc75a4db71670c41efa319886fb.tar.gz
shiftos_thereturn-e131f72a9b863cc75a4db71670c41efa319886fb.tar.bz2
shiftos_thereturn-e131f72a9b863cc75a4db71670c41efa319886fb.zip
Fix the file skimmer pins.
-rw-r--r--ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs12
-rw-r--r--ShiftOS.WinForms/Applications/FileSkimmer.cs64
-rw-r--r--ShiftOS.WinForms/Applications/Pong.cs2
-rw-r--r--ShiftOS_TheReturn/UserManagementCommands.cs27
4 files changed, 97 insertions, 8 deletions
diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs
index ea9fcec..965e4eb 100644
--- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs
+++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs
@@ -70,9 +70,9 @@ namespace ShiftOS.WinForms.Applications
// lvitems
//
this.lvitems.Dock = System.Windows.Forms.DockStyle.Fill;
- this.lvitems.Location = new System.Drawing.Point(0, 0);
+ this.lvitems.Location = new System.Drawing.Point(149, 0);
this.lvitems.Name = "lvitems";
- this.lvitems.Size = new System.Drawing.Size(634, 332);
+ this.lvitems.Size = new System.Drawing.Size(485, 332);
this.lvitems.TabIndex = 0;
this.lvitems.UseCompatibleStateImageBehavior = false;
this.lvitems.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvitems_ItemSelectionChanged);
@@ -81,8 +81,8 @@ namespace ShiftOS.WinForms.Applications
//
// panel1
//
- this.panel1.Controls.Add(this.pinnedItems);
this.panel1.Controls.Add(this.lvitems);
+ this.panel1.Controls.Add(this.pinnedItems);
this.panel1.Controls.Add(this.lbcurrentfolder);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 24);
@@ -92,10 +92,12 @@ namespace ShiftOS.WinForms.Applications
//
// pinnedItems
//
- this.pinnedItems.Location = new System.Drawing.Point(437, 208);
+ this.pinnedItems.Dock = System.Windows.Forms.DockStyle.Left;
+ this.pinnedItems.Location = new System.Drawing.Point(0, 0);
this.pinnedItems.Name = "pinnedItems";
- this.pinnedItems.Size = new System.Drawing.Size(197, 124);
+ this.pinnedItems.Size = new System.Drawing.Size(149, 332);
this.pinnedItems.TabIndex = 3;
+ this.pinnedItems.Click += new System.EventHandler(this.pinnedItems_Click);
//
// lbcurrentfolder
//
diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs
index c1ffd40..218e9e2 100644
--- a/ShiftOS.WinForms/Applications/FileSkimmer.cs
+++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs
@@ -35,6 +35,7 @@ using System.Windows.Forms;
using static ShiftOS.Objects.ShiftFS.Utils;
using ShiftOS.Engine;
+using Newtonsoft.Json;
namespace ShiftOS.WinForms.Applications
{
@@ -128,8 +129,14 @@ namespace ShiftOS.WinForms.Applications
{
int amountsCalled = -1;
amountsCalled = amountsCalled + 1;
- pinnedItems.Nodes.Add(path);
- pinnedItems.Nodes[amountsCalled].Nodes.Add("test");
+ List<string> Pinned = new List<string>();
+ if(FileExists(Paths.GetPath("data") + "/pinned_items.dat"))
+ {
+ Pinned = JsonConvert.DeserializeObject<List<string>>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat"));
+ }
+ Pinned.Add(path);
+ WriteAllText(Paths.GetPath("data") + "/pinned_items.dat", JsonConvert.SerializeObject(Pinned));
+ ResetList();
}
public void ChangeDirectory(string path)
@@ -152,8 +159,40 @@ namespace ShiftOS.WinForms.Applications
}
}
+ public void PopulatePinned(TreeNode node, string[] items)
+ {
+ foreach(var dir in items)
+ {
+ var treenode = new TreeNode();
+ if (DirectoryExists(dir))
+ {
+ var dinf = GetDirectoryInfo(dir);
+ treenode.Text = dinf.Name;
+ }
+ else if (FileExists(dir))
+ {
+ var finf = GetFileInfo(dir);
+ treenode.Text = finf.Name;
+ }
+ treenode.Tag = dir;
+ node.Nodes.Add(treenode);
+ }
+ }
+
public void ResetList()
{
+ pinnedItems.Nodes.Clear();
+ List<string> Pinned = new List<string>();
+ if(FileExists(Paths.GetPath("data") + "/pinned_items.dat"))
+ {
+ Pinned = JsonConvert.DeserializeObject<List<string>>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat"));
+ }
+ var node = new TreeNode();
+ node.Text = "Pinned";
+ PopulatePinned(node, Pinned.ToArray());
+ pinnedItems.Nodes.Add(node);
+ node.ExpandAll();
+
if(lvitems.LargeImageList == null)
{
lvitems.LargeImageList = new ImageList();
@@ -437,5 +476,26 @@ namespace ShiftOS.WinForms.Applications
}
catch { }
}
+
+ private void pinnedItems_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (pinnedItems.SelectedNode != null)
+ {
+ string path = pinnedItems.SelectedNode.Tag.ToString();
+ if (DirectoryExists(path))
+ {
+ currentdir = path;
+ ResetList();
+ }
+ else if (FileExists(path))
+ {
+ FileSkimmerBackend.OpenFile(path);
+ }
+ }
+ }
+ catch { }
+ }
}
}
diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs
index d63f406..ae70aff 100644
--- a/ShiftOS.WinForms/Applications/Pong.cs
+++ b/ShiftOS.WinForms/Applications/Pong.cs
@@ -1095,8 +1095,8 @@ namespace ShiftOS.WinForms.Applications
{
if(!string.IsNullOrWhiteSpace(OpponentGUID))
ServerManager.Forward(OpponentGUID, "pong_mp_left", null);
+ LeaveMatchmake();
}
- LeaveMatchmake();
ServerManager.MessageReceived -= this.ServerMessageReceivedHandler;
return true;
diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs
index 1c3c0ed..21c984b 100644
--- a/ShiftOS_TheReturn/UserManagementCommands.cs
+++ b/ShiftOS_TheReturn/UserManagementCommands.cs
@@ -53,6 +53,9 @@ namespace ShiftOS.Engine
return true;
}
+
+
+
[Command("set_acl")]
[RequiresArgument("user")]
[RequiresArgument("val")]
@@ -122,7 +125,31 @@ namespace ShiftOS.Engine
[RequiresUpgrade("mud_fundamentals")]
public static class UserManagementCommands
{
+ [Command("login", description = "Log in as another user.")]
+ [RequiresArgument("user")]
+ [RequiresArgument("pass")]
+ public static bool Login(Dictionary<string, object> args)
+ {
+ string user = args["user"].ToString();
+ string pass = args["pass"].ToString();
+ var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user);
+ if(usr==null)
+ {
+ Console.WriteLine("Error: No such user.");
+ return true;
+ }
+
+ if (usr.Password != pass)
+ {
+ Console.WriteLine("Access denied.");
+ return true;
+ }
+
+ SaveSystem.CurrentUser = usr;
+ Console.WriteLine("Access granted.");
+ return true;
+ }
[Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")]
[RequiresArgument("old")]