aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ShiftOS.Server/Program.cs2
-rw-r--r--ShiftOS.WinForms/Applications/MUDControlCentre.cs20
-rw-r--r--ShiftOS.WinForms/Applications/NameChanger.Designer.cs125
-rw-r--r--ShiftOS.WinForms/Applications/NameChanger.cs47
-rw-r--r--ShiftOS.WinForms/WindowBorder.cs20
-rw-r--r--ShiftOS_TheReturn/AppearanceManager.cs45
-rw-r--r--ShiftOS_TheReturn/Skinning.cs3
7 files changed, 221 insertions, 41 deletions
diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs
index 3ad8035..9399859 100644
--- a/ShiftOS.Server/Program.cs
+++ b/ShiftOS.Server/Program.cs
@@ -429,8 +429,10 @@ Contents:
bool legionExists = false;
foreach (var legion in legions)
+ {
if (legion.ShortName == l.ShortName)
legionExists = true;
+ }
if (legionExists == false)
{
diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs
index 439d5ab..34086a7 100644
--- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs
+++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs
@@ -66,21 +66,27 @@ namespace ShiftOS.WinForms.Applications
BannerColor = ConsoleColor.DarkRed
});
}
- else if(msg.Name == "legion_create_ok")
+ else if (msg.Name == "legion_create_ok")
{
SaveSystem.CurrentSave.CurrentLegions.Clear();
SaveSystem.CurrentSave.CurrentLegions.Add(editingLegion.ShortName);
SaveSystem.SaveGame();
- myLegionToolStripMenuItem_Click(this, EventArgs.Empty);
+ this.Invoke(new Action(() =>
+ {
+ myLegionToolStripMenuItem_Click(this, EventArgs.Empty);
+ }));
}
- else if(msg.Name == "legion_alreadyexists")
+ else if (msg.Name == "legion_alreadyexists")
{
- Infobox.Show("Legion already exists", "A legion with the short name you provided already exists. Please choose another.");
+ this.Invoke(new Action(() =>
+ {
+ Infobox.Show("Legion already exists", "A legion with the short name you provided already exists. Please choose another.");
+ }));
}
- else if(msg.Name == "legion_users_found")
+ else if (msg.Name == "legion_users_found")
{
lvusers.Items.Clear();
- foreach(var usr in JsonConvert.DeserializeObject<string[]>(msg.Contents))
+ foreach (var usr in JsonConvert.DeserializeObject<string[]>(msg.Contents))
{
lvusers.Items.Add(usr);
}
@@ -89,7 +95,7 @@ namespace ShiftOS.WinForms.Applications
{
ShowLegionInfo(JsonConvert.DeserializeObject<Legion>(msg.Contents));
}
- else if(msg.Name == "legion_all")
+ else if (msg.Name == "legion_all")
{
PopulateJoinLegion(JsonConvert.DeserializeObject<List<Legion>>(msg.Contents));
}
diff --git a/ShiftOS.WinForms/Applications/NameChanger.Designer.cs b/ShiftOS.WinForms/Applications/NameChanger.Designer.cs
index b51822f..c507ace 100644
--- a/ShiftOS.WinForms/Applications/NameChanger.Designer.cs
+++ b/ShiftOS.WinForms/Applications/NameChanger.Designer.cs
@@ -47,33 +47,134 @@ namespace ShiftOS.WinForms.Applications {
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
- this.listBox1 = new System.Windows.Forms.ListBox();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.flnames = new System.Windows.Forms.FlowLayoutPanel();
+ this.flbuttons = new System.Windows.Forms.FlowLayoutPanel();
+ this.btnclose = new System.Windows.Forms.Button();
+ this.btnloaddefault = new System.Windows.Forms.Button();
+ this.btnimport = new System.Windows.Forms.Button();
+ this.btnexport = new System.Windows.Forms.Button();
+ this.btnapply = new System.Windows.Forms.Button();
+ this.panel1.SuspendLayout();
+ this.flbuttons.SuspendLayout();
this.SuspendLayout();
//
- // listBox1
+ // panel1
//
- this.listBox1.FormattingEnabled = true;
- this.listBox1.Location = new System.Drawing.Point(3, 3);
- this.listBox1.Name = "listBox1";
- this.listBox1.Size = new System.Drawing.Size(138, 342);
- this.listBox1.TabIndex = 0;
- this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
+ this.panel1.Controls.Add(this.flnames);
+ this.panel1.Controls.Add(this.flbuttons);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel1.Location = new System.Drawing.Point(0, 0);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(354, 349);
+ this.panel1.TabIndex = 0;
+ //
+ // flnames
+ //
+ this.flnames.AutoScroll = true;
+ this.flnames.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.flnames.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
+ this.flnames.Location = new System.Drawing.Point(0, 0);
+ this.flnames.Name = "flnames";
+ this.flnames.Size = new System.Drawing.Size(354, 320);
+ this.flnames.TabIndex = 0;
+ this.flnames.WrapContents = false;
+ //
+ // flbuttons
+ //
+ this.flbuttons.AutoSize = true;
+ this.flbuttons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.flbuttons.Controls.Add(this.btnclose);
+ this.flbuttons.Controls.Add(this.btnloaddefault);
+ this.flbuttons.Controls.Add(this.btnimport);
+ this.flbuttons.Controls.Add(this.btnexport);
+ this.flbuttons.Controls.Add(this.btnapply);
+ this.flbuttons.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.flbuttons.Location = new System.Drawing.Point(0, 320);
+ this.flbuttons.Name = "flbuttons";
+ this.flbuttons.Size = new System.Drawing.Size(354, 29);
+ this.flbuttons.TabIndex = 0;
+ //
+ // btnclose
+ //
+ this.btnclose.AutoSize = true;
+ this.btnclose.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.btnclose.Location = new System.Drawing.Point(3, 3);
+ this.btnclose.Name = "btnclose";
+ this.btnclose.Size = new System.Drawing.Size(43, 23);
+ this.btnclose.TabIndex = 0;
+ this.btnclose.Text = "Close";
+ this.btnclose.UseVisualStyleBackColor = true;
+ //
+ // btnloaddefault
+ //
+ this.btnloaddefault.AutoSize = true;
+ this.btnloaddefault.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.btnloaddefault.Location = new System.Drawing.Point(52, 3);
+ this.btnloaddefault.Name = "btnloaddefault";
+ this.btnloaddefault.Size = new System.Drawing.Size(76, 23);
+ this.btnloaddefault.TabIndex = 1;
+ this.btnloaddefault.Text = "Load default";
+ this.btnloaddefault.UseVisualStyleBackColor = true;
+ //
+ // btnimport
+ //
+ this.btnimport.AutoSize = true;
+ this.btnimport.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.btnimport.Location = new System.Drawing.Point(134, 3);
+ this.btnimport.Name = "btnimport";
+ this.btnimport.Size = new System.Drawing.Size(46, 23);
+ this.btnimport.TabIndex = 2;
+ this.btnimport.Text = "Import";
+ this.btnimport.UseVisualStyleBackColor = true;
+ //
+ // btnexport
+ //
+ this.btnexport.AutoSize = true;
+ this.btnexport.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.btnexport.Location = new System.Drawing.Point(186, 3);
+ this.btnexport.Name = "btnexport";
+ this.btnexport.Size = new System.Drawing.Size(47, 23);
+ this.btnexport.TabIndex = 3;
+ this.btnexport.Text = "Export";
+ this.btnexport.UseVisualStyleBackColor = true;
+ //
+ // btnapply
+ //
+ this.btnapply.AutoSize = true;
+ this.btnapply.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.btnapply.Location = new System.Drawing.Point(239, 3);
+ this.btnapply.Name = "btnapply";
+ this.btnapply.Size = new System.Drawing.Size(43, 23);
+ this.btnapply.TabIndex = 4;
+ this.btnapply.Text = "Apply";
+ this.btnapply.UseVisualStyleBackColor = true;
//
// NameChanger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.listBox1);
+ this.Controls.Add(this.panel1);
this.Name = "NameChanger";
- this.Text = "Name Changer";
- this.Size = new System.Drawing.Size(459, 406);
+ this.Size = new System.Drawing.Size(354, 349);
this.Load += new System.EventHandler(this.NameChanger_Load);
+ this.panel1.ResumeLayout(false);
+ this.panel1.PerformLayout();
+ this.flbuttons.ResumeLayout(false);
+ this.flbuttons.PerformLayout();
this.ResumeLayout(false);
}
#endregion
- private System.Windows.Forms.ListBox listBox1;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.FlowLayoutPanel flnames;
+ private System.Windows.Forms.FlowLayoutPanel flbuttons;
+ private System.Windows.Forms.Button btnclose;
+ private System.Windows.Forms.Button btnloaddefault;
+ private System.Windows.Forms.Button btnimport;
+ private System.Windows.Forms.Button btnexport;
+ private System.Windows.Forms.Button btnapply;
}
} \ No newline at end of file
diff --git a/ShiftOS.WinForms/Applications/NameChanger.cs b/ShiftOS.WinForms/Applications/NameChanger.cs
index 8483c22..ce17439 100644
--- a/ShiftOS.WinForms/Applications/NameChanger.cs
+++ b/ShiftOS.WinForms/Applications/NameChanger.cs
@@ -38,8 +38,10 @@ namespace ShiftOS.WinForms.Applications {
[Launcher("Name Changer", true, "al_name_changer", "Customization")]
[RequiresUpgrade("name_changer")]
[WinOpen("name_changer")]
- public partial class NameChanger : UserControl, IShiftOSWindow {
- public NameChanger() {
+ public partial class NameChanger : UserControl, IShiftOSWindow
+ {
+ public NameChanger()
+ {
InitializeComponent();
}
@@ -60,13 +62,50 @@ namespace ShiftOS.WinForms.Applications {
{
}
- private void NameChanger_Load(object sender, EventArgs e) {
+ private void NameChanger_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ }
+
+ public static class NameChangerBackend
+ {
+ public static Dictionary<string, string> GetDefault()
+ {
+ var dict = new Dictionary<string, string>();
+ foreach(var winType in AppearanceManager.GetAllWindowTypes())
+ {
+ if (dict.ContainsKey(winType.Name))
+ dict[winType.Name] = AppearanceManager.GetDefaultTitle(winType);
+ else
+ dict.Add(winType.Name, AppearanceManager.GetDefaultTitle(winType));
+ }
+ return dict;
+ }
+
+ public static Dictionary<string,string> GetCurrent()
+ {
+ if (SkinEngine.LoadedSkin == null)
+ return GetDefault();
+ if (SkinEngine.LoadedSkin.AppNames == null)
+ SkinEngine.LoadedSkin.AppNames = GetDefault();
+ return SkinEngine.LoadedSkin.AppNames;
}
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
+ public static string GetName(IShiftOSWindow win)
{
+ if (SkinEngine.LoadedSkin == null)
+ return AppearanceManager.GetDefaultTitle(win.GetType());
+
+ if (SkinEngine.LoadedSkin.AppNames == null)
+ SkinEngine.LoadedSkin.AppNames = GetDefault();
+
+ if (!SkinEngine.LoadedSkin.AppNames.ContainsKey(win.GetType().Name))
+ SkinEngine.LoadedSkin.AppNames.Add(win.GetType().Name, AppearanceManager.GetDefaultTitle(win.GetType()));
+ return SkinEngine.LoadedSkin.AppNames[win.GetType().Name];
}
}
}
diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs
index be59c70..bb9b478 100644
--- a/ShiftOS.WinForms/WindowBorder.cs
+++ b/ShiftOS.WinForms/WindowBorder.cs
@@ -36,6 +36,7 @@ using static ShiftOS.Engine.SkinEngine;
using System.Runtime.InteropServices;
using ShiftOS.Engine;
using ShiftOS.WinForms.Tools;
+using ShiftOS.WinForms.Applications;
/// <summary>
/// Window border.
@@ -211,7 +212,7 @@ namespace ShiftOS.WinForms
/// </summary>
public void Setup()
{
- this.lbtitletext.Text = Localization.Parse(this._parentWindow.Text);
+ this.lbtitletext.Text = NameChangerBackend.GetName(ParentWindow);
if (SaveSystem.CurrentSave != null)
{
@@ -232,23 +233,6 @@ namespace ShiftOS.WinForms
}
/// <summary>
- /// Gets or sets the text.
- /// </summary>
- /// <value>The text.</value>
- public override string Text
- {
- get
- {
- return lbtitletext?.Text;
- }
-
- set
- {
- lbtitletext.Text = value;
- }
- }
-
- /// <summary>
/// Setups the skin.
/// </summary>
/// <returns>The skin.</returns>
diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs
index dd205b2..112bca5 100644
--- a/ShiftOS_TheReturn/AppearanceManager.cs
+++ b/ShiftOS_TheReturn/AppearanceManager.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -75,6 +76,39 @@ namespace ShiftOS.Engine
}
}
+ public static IEnumerable<Type> GetAllWindowTypes()
+ {
+ List<Type> types = new List<Type>();
+ foreach(var file in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
+ {
+ if(file.EndsWith(".exe") || file.EndsWith(".dll"))
+ {
+ try
+ {
+ var asm = Assembly.LoadFile(file);
+ foreach(var type in asm.GetTypes())
+ {
+ if (type.GetInterfaces().Contains(typeof(IShiftOSWindow)))
+ types.Add(type);
+ }
+ }
+ catch { }
+ }
+ }
+ return types;
+ }
+
+ public static string GetDefaultTitle(Type winType)
+ {
+ foreach(var attrib in winType.GetCustomAttributes(false))
+ {
+ if(attrib is DefaultTitleAttribute)
+ {
+ return (attrib as DefaultTitleAttribute).Title;
+ }
+ }
+ return winType.Name;
+ }
public static string LastTerminalText { get; set; }
public static int CurrentPosition { get; set; }
@@ -205,4 +239,15 @@ namespace ShiftOS.Engine
string Text { get; set; }
IShiftOSWindow ParentWindow { get; set; }
}
+
+ public class DefaultTitleAttribute : Attribute
+ {
+ public DefaultTitleAttribute(string title)
+ {
+ Title = title;
+ }
+
+ public string Title { get; private set; }
+ }
+
}
diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs
index 80945b8..b3dddd3 100644
--- a/ShiftOS_TheReturn/Skinning.cs
+++ b/ShiftOS_TheReturn/Skinning.cs
@@ -137,6 +137,9 @@ namespace ShiftOS.Engine {
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
+ [ShifterHidden]
+ public Dictionary<string, string> AppNames = new Dictionary<string, string>();
+
[ShifterMeta("Windows")]
[ShifterCategory("Titlebar")]
[RequiresUpgrade("shift_title_text")]