Merge remote-tracking branch 'refs/remotes/shiftos-game/master'

This commit is contained in:
lempamo 2017-02-25 09:49:33 -05:00
commit 271c973c3f
8 changed files with 603 additions and 8 deletions

View file

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
@ -28,7 +29,189 @@ namespace ShiftOS.WinForms.Applications
public void SetupUI()
{
fllist.Controls.Clear();
bool showNoNotes = true;
foreach (var note in NotificationDaemon.GetAllFromFile())
{
if (note.Read == false)
{
showNoNotes = false;
var headerLabel = new Label();
headerLabel.Tag = "header2";
ControlManager.SetupControl(headerLabel);
headerLabel.Text = ParseNotification(note);
headerLabel.Width = fllist.Width - 4;
fllist.Controls.Add(headerLabel);
headerLabel.Show();
var markButton = new Button();
ControlManager.SetupControl(markButton);
markButton.Text = "Mark as read";
markButton.Click += (o, a) =>
{
NotificationDaemon.MarkRead(new List<Notification>(NotificationDaemon.GetAllFromFile()).IndexOf(note));
SetupUI();
};
fllist.Controls.Add(markButton);
markButton.Show();
var dataLabel = new Label();
dataLabel.Text = ParseNotificationData(note);
dataLabel.MaximumSize = new Size(fllist.Width - 4, 0);
dataLabel.AutoSize = true;
fllist.Controls.Add(dataLabel);
dataLabel.Show();
}
}
if(showNoNotes == true)
{
var lbl = new Label();
lbl.Tag = "header3";
ControlManager.SetupControl(lbl);
lbl.AutoSize = true;
lbl.Text = "You have no notifications.";
fllist.Controls.Add(lbl);
lbl.Show();
}
}
public string ParseNotificationData(Notification note)
{
string data = "";
data = note.Timestamp.ToString();
data += Environment.NewLine + Environment.NewLine;
switch (note.Type)
{
case NotificationType.ChatBan:
data += "You have been banned from " + note.Data.ToString() + ".";
break;
case NotificationType.CodepointsReceived:
data += "You have received " + note.Data.ToString() + " Codepoints.";
break;
case NotificationType.CodepointsSent:
data += "You have lost " + note.Data.ToString() + " Codepoints.";
break;
case NotificationType.CriticalBugwatch:
data += "ShiftOS is in a critical bugwatch state. If you see any bugs, report them to us immediately.";
break;
case NotificationType.DownloadComplete:
data += "Download of file " + note.Data.ToString() + " complete.";
break;
case NotificationType.DownloadStarted:
data += "Download started. Destination: " + note.Data.ToString() + ".";
break;
case NotificationType.Generic:
data += note.Data.ToString();
break;
case NotificationType.LegionBan:
data += "You have been banned from " + note.Data.ToString();
break;
case NotificationType.LegionInvite:
data += "You have been invited to a legion. Invite code: " + note.Data.ToString();
break;
case NotificationType.LegionKick:
data += "You have been kicked out of " + note.Data.ToString() + ".";
break;
case NotificationType.MemoReceived:
data += "New memo received from " + note.Data.ToString() + "!";
break;
case NotificationType.MemoSent:
data += "Memo successfully sent to " + note.Data.ToString() + ".";
break;
case NotificationType.MUDAnnouncement:
data += note.Data.ToString();
break;
case NotificationType.MUDMaintenance:
data += "The MUD will be going down for a little while at " + note.Data.ToString() + ". Please beware.";
break;
case NotificationType.NewAppveyor:
data += "A new AppVeyor build of ShiftOS has been released.";
break;
case NotificationType.NewDeveloper:
data += "A new developer, " + note.Data.ToString() + " has been added to the team!";
break;
case NotificationType.NewShiftOSStable:
data += "The latest ShiftOS stable, " + note.Data.ToString() + " has been released!";
break;
case NotificationType.NewShiftOSStream:
data += "We're going to be live at http://youtube.com/ShiftOS/live at " + note.Data.ToString() + " (Eastern Standard Time).";
break;
case NotificationType.NewShiftOSUnstable:
data += "A new unstable version of ShiftOS has been released: " + note.Data.ToString() + ".";
break;
case NotificationType.NewShiftOSVideo:
data += "A new ShiftOS video has been released! Get to it before Victor Tran!";
break;
case NotificationType.SavePurge:
data += "A purge has occurred inside the multi-user domain. If you have lost your save, it is because it has gone rogue and has been purged.";
break;
case NotificationType.ShopPurchase:
data += "You have successfully purchased " + note.Data.ToString() + ".";
break;
default:
data += "Corrupt notification data.";
break;
}
return data;
}
public string ParseNotification(Notification note)
{
switch (note.Type)
{
case NotificationType.ChatBan:
return "Banned from chat";
case NotificationType.CodepointsReceived:
return "Codepoints received.";
case NotificationType.CodepointsSent:
return "Codepoints sent.";
case NotificationType.CriticalBugwatch:
return "Critical Bugwatch in progress";
case NotificationType.DownloadComplete:
return "Download complete.";
case NotificationType.DownloadStarted:
return "Download started.";
case NotificationType.Generic:
return "System update";
case NotificationType.LegionBan:
return "Banned from legion";
case NotificationType.LegionInvite:
return "Legion invite received.";
case NotificationType.LegionKick:
return "Kicked from legion";
case NotificationType.MemoReceived:
return "New memo";
case NotificationType.MemoSent:
return "Memo sent.";
case NotificationType.MUDAnnouncement:
return "MUD Announcement";
case NotificationType.MUDMaintenance:
return "MUD maintenance warning!";
case NotificationType.NewAppveyor:
return "New AppVeyor build of ShiftOS";
case NotificationType.NewDeveloper:
return "Please welcome our newest developer...";
case NotificationType.NewShiftOSStable:
return "The newest ShiftOS stable is out!";
case NotificationType.NewShiftOSStream:
return "We're going live soon!";
case NotificationType.NewShiftOSUnstable:
return "The latest ShiftOS unstable is out!";
case NotificationType.NewShiftOSVideo:
return "New ShiftOS video is out!";
case NotificationType.SavePurge:
return "MUD save purge";
case NotificationType.ShopPurchase:
return "Item purchased from shop.";
default:
return "Unknown";
}
}
public void OnLoad()

View file

@ -0,0 +1,122 @@
/*
* 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.
*/
namespace ShiftOS.WinForms.Applications
{
partial class ShiftLetters
{
/// <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.lblword = new System.Windows.Forms.Label();
this.tbguess = new System.Windows.Forms.TextBox();
this.lbllives = new System.Windows.Forms.Label();
this.btnrestart = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblword
//
this.lblword.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.lblword.AutoSize = true;
this.lblword.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F);
this.lblword.Location = new System.Drawing.Point(127, 31);
this.lblword.Name = "lblword";
this.lblword.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.lblword.Size = new System.Drawing.Size(72, 18);
this.lblword.TabIndex = 1;
this.lblword.Text = "Loading...";
//
// tbguess
//
this.tbguess.Location = new System.Drawing.Point(147, 108);
this.tbguess.Name = "tbguess";
this.tbguess.Size = new System.Drawing.Size(22, 20);
this.tbguess.TabIndex = 2;
this.tbguess.TextChanged += new System.EventHandler(this.tbguess_TextChanged);
//
// lbllives
//
this.lbllives.AutoSize = true;
this.lbllives.Location = new System.Drawing.Point(127, 190);
this.lbllives.Name = "lbllives";
this.lbllives.Size = new System.Drawing.Size(69, 13);
this.lbllives.TabIndex = 3;
this.lbllives.Text = "Still loading...";
//
// btnrestart
//
this.btnrestart.Location = new System.Drawing.Point(130, 148);
this.btnrestart.Name = "btnrestart";
this.btnrestart.Size = new System.Drawing.Size(75, 23);
this.btnrestart.TabIndex = 4;
this.btnrestart.Text = "Restart";
this.btnrestart.UseVisualStyleBackColor = true;
this.btnrestart.Visible = false;
this.btnrestart.Click += new System.EventHandler(this.btnrestart_Click);
//
// ShiftLetters
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnrestart);
this.Controls.Add(this.lbllives);
this.Controls.Add(this.tbguess);
this.Controls.Add(this.lblword);
this.Name = "ShiftLetters";
this.Size = new System.Drawing.Size(333, 256);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblword;
private System.Windows.Forms.TextBox tbguess;
private System.Windows.Forms.Label lbllives;
private System.Windows.Forms.Button btnrestart;
}
}

View file

@ -0,0 +1,146 @@
/*
* 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 System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using Newtonsoft.Json;
using ShiftOS.Engine;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShiftOS.WinForms.Applications
{
[Launcher("ShiftLetters", false, null, "Games")]
[RequiresUpgrade("shiftletters")]
[WinOpen("shiftletters")]
public partial class ShiftLetters : UserControl, IShiftOSWindow
{
int lives = 7;
string word = "";
static Random rng = new Random();
public ShiftLetters()
{
InitializeComponent();
}
private void StartGame()
{
lives = 7;
tbguess.Visible = true;
lbllives.Visible = true;
lblword.Visible = true;
btnrestart.Visible = false;
var wordlist = new List<string>
{
"shiftos",
"devx",
"delicious",
"shifter",
"pong",
"shiftorium",
"codepoints"
};
word = wordlist[rng.Next(wordlist.Count)];
lbllives.Text = "You have 7 lives left!";
lblword.Text = "";
for (int i=0; i<word.Length; i++)
{
lblword.Text = lblword.Text + "_ ";
}
}
public void OnLoad()
{
StartGame();
}
public void OnUpgrade()
{
}
public bool OnUnload()
{
return true;
}
public void OnSkinLoad()
{
}
private void tbguess_TextChanged(object sender, EventArgs e)
{
if (this.tbguess.Text.Length == 1)
{
var charGuessed = this.tbguess.Text;
bool correct = false;
this.tbguess.Text = "";
for (int i=0; i < word.Length; i++)
{
if (word[i] == System.Convert.ToChar(charGuessed) & lives > 0)
{
char[] letters = lblword.Text.ToCharArray();
correct = true;
letters[i * 2] = System.Convert.ToChar(charGuessed);
lblword.Text = string.Join("", letters);
if (!lblword.Text.Contains("_"))
{
int oldlives = lives;
tbguess.Visible = false;
lives = 0;
lbllives.Visible = true;
btnrestart.Visible = true;
long cp = word.Length * oldlives;
lbllives.Text = "You earned: " + cp + " codepoints!";
ShiftOS.Engine.SaveSystem.CurrentSave.Codepoints += cp;
}
}
}
if (correct == false & lives > 0)
{
lives--;
lbllives.Text = "You have: " + lives + " lives left!";
if (lives == 0)
{
tbguess.Visible = false;
lbllives.Visible = false;
btnrestart.Visible = true;
}
}
}
}
private void btnrestart_Click(object sender, EventArgs e)
{
StartGame();
}
}
}

View file

@ -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>

View file

@ -1,4 +1,4 @@
/*
/*
* MIT License
*
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
@ -914,14 +914,16 @@ namespace ShiftOS.WinForms.Properties {
/// Dependencies: null
/// },
/// {
/// Name: &quot;Audio Volume&quot;,
/// Cost: 50,
/// Description: &quot;Want to adjust the volume of ShiftOS&apos;s audio? This upgrade will let you.&quot;
/// Name: &quot;AL Notifications&quot;,
/// Cost: 125,
/// Dependencies: &quot;app_launcher&quot;,
/// Description: &quot;Want to open the Notifications application from within the App Launcher? This upgrade is for you.&quot;
/// },
/// {
/// Name: &quot;Color Depth Dithering&quot;,
/// Cost: 1000,
/// Description: &quot;Right now, if you try to display images on the screen, with a low color depth like we have, the image will be totally unrecogn [rest of string was truncated]&quot;;.
/// Name: &quot;Guess the Word&quot;,
/// Cost: 150,
/// Dependencies: null,
/// Description: &quot;Sick and tired of playing Pong? Buy this upgrade [rest of string was truncated]&quot;;.
/// </summary>
internal static string Shiftorium {
get {

View file

@ -11,6 +11,18 @@
Dependencies: "app_launcher",
Description: "Want to open the Notifications application from within the App Launcher? This upgrade is for you."
},
{
Name: "ShiftLetters",
Cost: 150,
Dependencies: null,
Description: "Sick and tired of playing Pong? Buy this upgrade to get a whole new game!"
},
{
Name: "AL ShiftLetters",
Cost: 100,
Dependencies: "app_launcher;shiftletters",
Description: "This upgrade allows you to find ShiftLetters in your App Launcher."
},
{
Name: "Panel Notifications",
Cost: 150,
@ -19,7 +31,7 @@
},
{
Name: "Audio Volume",
Cost: 50,
Cost: 80,
Description: "Want to adjust the volume of ShiftOS's audio? This upgrade will let you."
},
{

View file

@ -118,6 +118,12 @@
<Compile Include="Applications\GraphicPicker.Designer.cs">
<DependentUpon>GraphicPicker.cs</DependentUpon>
</Compile>
<Compile Include="Applications\ShiftLetters.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Applications\ShiftLetters.Designer.cs">
<DependentUpon>ShiftLetters.cs</DependentUpon>
</Compile>
<Compile Include="Applications\MUDControlCentre.cs">
<SubType>UserControl</SubType>
</Compile>
@ -277,6 +283,9 @@
<EmbeddedResource Include="Applications\GraphicPicker.resx">
<DependentUpon>GraphicPicker.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Applications\ShiftLetters.resx">
<DependentUpon>ShiftLetters.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Applications\MUDControlCentre.resx">
<DependentUpon>MUDControlCentre.cs</DependentUpon>
</EmbeddedResource>

View file

@ -59,6 +59,7 @@ namespace ShiftOS.Engine
AddPath("system", "applauncher");
AddPath("data", "save.json");
AddPath("data", "user.dat");
AddPath("data", "notifications.dat");
AddPath("data", "skin");
AddPath("system", "programs");
AddPath("system", "kernel.sft");