diff options
| author | lempamo <[email protected]> | 2017-02-25 08:21:55 -0500 |
|---|---|---|
| committer | lempamo <[email protected]> | 2017-02-25 08:21:55 -0500 |
| commit | cc4b3c6f091828f2b44ffa3688f551ed09557ec6 (patch) | |
| tree | 5edd08769817553e9b17a8a6caaad269d83eeb3e | |
| parent | 0b65949e74b225603e04971ccba8430bded90769 (diff) | |
| parent | 5573e82ca48bb891bbaf6c2f05215dba8e441ce8 (diff) | |
| download | shiftos_thereturn-cc4b3c6f091828f2b44ffa3688f551ed09557ec6.tar.gz shiftos_thereturn-cc4b3c6f091828f2b44ffa3688f551ed09557ec6.tar.bz2 shiftos_thereturn-cc4b3c6f091828f2b44ffa3688f551ed09557ec6.zip | |
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
| -rw-r--r-- | ShiftOS.WinForms/Applications/Notifications.Designer.cs | 73 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Applications/Notifications.cs | 54 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Applications/Notifications.resx | 120 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Resources/Shiftorium.txt | 12 | ||||
| -rw-r--r-- | ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WinformsDesktop.Designer.cs | 19 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WinformsDesktop.cs | 10 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/NotificationDaemon.cs | 91 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 |
9 files changed, 389 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Applications/Notifications.Designer.cs b/ShiftOS.WinForms/Applications/Notifications.Designer.cs new file mode 100644 index 0000000..d9a8388 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Notifications.Designer.cs @@ -0,0 +1,73 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class Notifications + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.lblnotifications = new System.Windows.Forms.Label(); + this.fllist = new System.Windows.Forms.FlowLayoutPanel(); + this.SuspendLayout(); + // + // lblnotifications + // + this.lblnotifications.AutoSize = true; + this.lblnotifications.Dock = System.Windows.Forms.DockStyle.Top; + this.lblnotifications.Location = new System.Drawing.Point(0, 0); + this.lblnotifications.Name = "lblnotifications"; + this.lblnotifications.Padding = new System.Windows.Forms.Padding(10); + this.lblnotifications.Size = new System.Drawing.Size(85, 33); + this.lblnotifications.TabIndex = 0; + this.lblnotifications.Tag = "header1"; + this.lblnotifications.Text = "Notifications"; + // + // fllist + // + this.fllist.Dock = System.Windows.Forms.DockStyle.Fill; + this.fllist.Location = new System.Drawing.Point(0, 33); + this.fllist.Name = "fllist"; + this.fllist.Size = new System.Drawing.Size(437, 487); + this.fllist.TabIndex = 1; + // + // Notifications + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.fllist); + this.Controls.Add(this.lblnotifications); + this.Name = "Notifications"; + this.Size = new System.Drawing.Size(437, 520); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lblnotifications; + private System.Windows.Forms.FlowLayoutPanel fllist; + } +} diff --git a/ShiftOS.WinForms/Applications/Notifications.cs b/ShiftOS.WinForms/Applications/Notifications.cs new file mode 100644 index 0000000..aa8ba71 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Notifications.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Applications +{ + [DefaultTitle("Notifications")] + [Launcher("Notifications", true, "al_notifications", "Utilities")] + public partial class Notifications : UserControl, IShiftOSWindow + { + public Notifications() + { + InitializeComponent(); + onMade = (note) => + { + SetupUI(); + }; + } + + Action<Notification> onMade = null; + + public void SetupUI() + { + + } + + public void OnLoad() + { + SetupUI(); + NotificationDaemon.NotificationMade += onMade; + } + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + NotificationDaemon.NotificationMade -= onMade; + return true; + } + + public void OnUpgrade() + { + } + } +} diff --git a/ShiftOS.WinForms/Applications/Notifications.resx b/ShiftOS.WinForms/Applications/Notifications.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Notifications.resx @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index af30613..9c116be 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -6,6 +6,18 @@ Dependencies: null }, { + Name: "AL Notifications", + Cost: 125, + Dependencies: "app_launcher", + Description: "Want to open the Notifications application from within the App Launcher? This upgrade is for you." + }, + { + Name: "Panel Notifications", + Cost: 150, + Description: "It's good to know what time it is, but how about knowing how many notifications you have? After all, notifications are a great way to tell what's going on! This upgrade adds a button that displays how many notifications you have. If you click it, you will open the Notifications app!", + Dependencies: "desktop_clock_widget" + }, + { Name: "Audio Volume", Cost: 50, Description: "Want to adjust the volume of ShiftOS's audio? This upgrade will let you." diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1b6b2d7..45c1a47 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -124,6 +124,12 @@ <Compile Include="Applications\NameChanger.Designer.cs"> <DependentUpon>NameChanger.cs</DependentUpon> </Compile> + <Compile Include="Applications\Notifications.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Applications\Notifications.Designer.cs"> + <DependentUpon>Notifications.cs</DependentUpon> + </Compile> <Compile Include="Applications\Pong.cs"> <SubType>UserControl</SubType> </Compile> @@ -268,6 +274,9 @@ <EmbeddedResource Include="Applications\NameChanger.resx"> <DependentUpon>NameChanger.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="Applications\Notifications.resx"> + <DependentUpon>Notifications.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Applications\Pong.resx"> <DependentUpon>Pong.cs</DependentUpon> </EmbeddedResource> diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 23f4665..0585199 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -53,6 +53,7 @@ namespace ShiftOS.WinForms private void InitializeComponent() { this.desktoppanel = new System.Windows.Forms.Panel(); + this.btnnotifications = new System.Windows.Forms.Button(); this.lbtime = new System.Windows.Forms.Label(); this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); this.sysmenuholder = new System.Windows.Forms.Panel(); @@ -66,6 +67,7 @@ namespace ShiftOS.WinForms // desktoppanel // this.desktoppanel.BackColor = System.Drawing.Color.Green; + this.desktoppanel.Controls.Add(this.btnnotifications); this.desktoppanel.Controls.Add(this.lbtime); this.desktoppanel.Controls.Add(this.panelbuttonholder); this.desktoppanel.Controls.Add(this.sysmenuholder); @@ -75,6 +77,22 @@ namespace ShiftOS.WinForms this.desktoppanel.Size = new System.Drawing.Size(1296, 24); this.desktoppanel.TabIndex = 0; // + // btnnotifications + // + this.btnnotifications.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnnotifications.AutoSize = true; + this.btnnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnnotifications.BackColor = System.Drawing.Color.Transparent; + this.btnnotifications.FlatAppearance.BorderSize = 0; + this.btnnotifications.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnnotifications.Location = new System.Drawing.Point(1066, -2); + this.btnnotifications.Name = "btnnotifications"; + this.btnnotifications.Size = new System.Drawing.Size(136, 24); + this.btnnotifications.TabIndex = 3; + this.btnnotifications.Text = "Notifications (0)"; + this.btnnotifications.UseVisualStyleBackColor = false; + this.btnnotifications.Click += new System.EventHandler(this.btnnotifications_Click); + // // lbtime // this.lbtime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -156,6 +174,7 @@ namespace ShiftOS.WinForms private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem apps; private System.Windows.Forms.FlowLayoutPanel panelbuttonholder; + private System.Windows.Forms.Button btnnotifications; } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 2bb2715..ded68ba 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -119,6 +119,9 @@ namespace ShiftOS.WinForms lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; } } + + btnnotifications.Left = lbtime.Left - btnnotifications.Width - 2; + btnnotifications.Top = (desktoppanel.Height - btnnotifications.Height) / 2; }; time.Start(); @@ -229,6 +232,8 @@ namespace ShiftOS.WinForms desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); + btnnotifications.Visible = Shiftorium.UpgradeInstalled("panel_notifications"); + //skinning lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; @@ -529,6 +534,11 @@ namespace ShiftOS.WinForms { return this.Size; } + + private void btnnotifications_Click(object sender, EventArgs e) + { + AppearanceManager.SetupWindow(new Applications.Notifications()); + } } [ShiftOS.Engine.Scripting.Exposed("desktop")] diff --git a/ShiftOS_TheReturn/NotificationDaemon.cs b/ShiftOS_TheReturn/NotificationDaemon.cs new file mode 100644 index 0000000..3a2e96a --- /dev/null +++ b/ShiftOS_TheReturn/NotificationDaemon.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using ShiftOS.Objects.ShiftFS; + +namespace ShiftOS.Engine +{ + public static class NotificationDaemon + { + public static Notification[] GetAllFromFile() + { + Notification[] notes = { }; + if (Utils.FileExists(Paths.GetPath("notifications.dat"))) + { + notes = JsonConvert.DeserializeObject<Notification[]>(Utils.ReadAllText(Paths.GetPath("notifications.dat"))); + } + return notes; + } + + internal static void WriteNotes(Notification[] notes) + { + Utils.WriteAllText(Paths.GetPath("notifications.dat"), JsonConvert.SerializeObject(notes, Formatting.Indented)); + } + + public static event Action<Notification> NotificationMade; + + public static void AddNotification(NotificationType note, object data) + { + var lst = new List<Notification>(GetAllFromFile()); + lst.Add(new Engine.Notification(note, data)); + WriteNotes(lst.ToArray()); + NotificationMade?.Invoke(lst[lst.Count - 1]); + } + + + public static void MarkRead(int note) + { + var notes = GetAllFromFile(); + if (note >= notes.Length || note < 0) + throw new ArgumentOutOfRangeException("note", new Exception("You cannot mark a notification that does not exist as read.")); + + notes[note].Read = true; + WriteNotes(notes); + } + } + + public struct Notification + { + public Notification(NotificationType t, object data) + { + Type = t; + Data = data; + Read = false; + Timestamp = DateTime.Now; + } + + public bool Read { get; internal set; } + public NotificationType Type { get; private set; } + public object Data { get; private set; } + public DateTime Timestamp { get; private set; } + } + + public enum NotificationType : byte + { + Generic = 0x00, + MemoReceived = 0x10, + MemoSent = 0x11, + DownloadStarted = 0x20, + DownloadComplete = 0x21, + CodepointsReceived = 0x30, + CodepointsSent = 0x31, + ShopPurchase = 0x40, + LegionInvite = 0x50, + LegionKick = 0x51, + LegionBan = 0x52, + ChatBan = 0x60, + MUDAnnouncement = 0x70, + MUDMaintenance = 0x71, + NewShiftOSUnstable = 0x72, + NewShiftOSStable = 0x73, + NewAppveyor = 0x74, + CriticalBugwatch = 0x75, + NewDeveloper = 0x76, + NewShiftOSVideo = 0x77, + NewShiftOSStream = 0x78, + SavePurge = 0x79, + } +} diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index a8c041d..735d046 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -132,6 +132,7 @@ <Compile Include="Infobox.cs" /> <Compile Include="IShiftOSWindow.cs" /> <Compile Include="Localization.cs" /> + <Compile Include="NotificationDaemon.cs" /> <Compile Include="OutOfBoxExperience.cs" /> <Compile Include="Paths.cs" /> <Compile Include="Program.cs" /> |
