Merge pull request #1 from shiftos-game/master

welp, no longer a dev.
This commit is contained in:
william341 2017-05-28 12:37:00 -07:00 committed by GitHub
commit 771c20cfb3
264 changed files with 61693 additions and 6694 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,30 @@
# Contributing to ShiftOS
## Reporting Bugs
## Reporting Bugs / Suggesting Enhancements
Follow the `Templates/IssueTemplate.md`
### Issue Template
## Suggesting Enhancements
#### What you expected to happen
Follow the `Templates/IssueTemplate.md`
#### What actually happened
#### Steps To Reproduce
# What you expected to happen
# What actually happened
# Steps To Reproduce
### Suggestion Template
#### What should be added to the game/api
#### Why it should be added
# What should be added to the game/api
# Why it should be added
## Pull Requests
@ -14,9 +32,14 @@ Follow our code style
PublicVariableNames privateVariableNames CONSTANT_VARIABLE_NAMES
PublicMethodNames privateMethodNames
ClassNames
BracketsOnNewLines()
ClassNamesLikeThis
{
public Type VariableName;
public void BracketsOnNewLines()
{
var variableName;
}
}
Insert licenses at the top of ALL `.cs` files

View file

@ -6,16 +6,24 @@ The official, open-source, C# revamp of ShiftOS.
## License
We are licensed under the MIT license. A simple description is:
We are licensed under the [MIT license](https://github.com/shiftos-game/ShiftOS/blob/master/LICENSE). A simple description is:
1. Don't steal our code and call it yours
2. If you fork us, leave any copyright statements and license info at the top of all .cs files. You can use the InsertLicense executable to insert the statement into any code files missing the copyright statement.
1. Don't steal our code and claim ownership of it
2. Leave copyright statements and license info at the top of all .cs files. `InsertLicense.exe` can be used to add the license to all files without it.
### Using our code for your own front-end project
### Using our code for your own project
You may use the ShiftOS.Engine, ShiftOS.Objects, and ShiftOS.Server projects to create your own games. You must include the original license and link back to this in your game or credits.
You may use the ShiftOS.Engine, ShiftOS.Objects, and ShiftOS.Server projects to create your own games. You must include the original license and link back to [ShiftOS](https://github.com/shiftos-game/ShiftOS) in your `README` and in your game or credits.
## Compiling the code
To compile the code, simply clone the repository, and open it in Visual Studio. Then, set `ShiftOS.WinForms` as your startup project by right-clicing it in **Solution Explorer**. Then, hit **F5** to compile and run the game.
## Where the hell is the **Issues** tab? This can't be GitHub!
No, you're wrong. We've actually disabled the Issues tab in place of our own in-place [bugtracker](http://getshiftos.ml/Bugs). Please post bugs there. It is easier for us to track and integrate with the rest of the community.
## Contributing
See `CONTRIBUTING.md`
See [`CONTRIBUTING.md`](https://github.com/shiftos-game/ShiftOS/blob/master/CONTRIBUTING.md)

View file

@ -206,7 +206,7 @@ Public Class SkinConverterCommands
skn.Header2Font = New Font("Microsoft Sans Serif", 15, FontStyle.Regular)
skn.Header3Font = New Font("Microsoft Sans Serif", 12.5, FontStyle.Regular)
skn.TerminalBackColor = Color.Black
skn.TerminalBackColorCC = ConsoleColor.Black
Console.WriteLine(" ...done!")
Console.WriteLine("Skin conversion complete.")

View file

@ -33,7 +33,7 @@ Public Class SkinConverter
End Sub
Public Sub OnLoad() Implements IShiftOSWindow.OnLoad
Public Sub OnSOSLoad() Implements IShiftOSWindow.OnLoad
End Sub

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public class ChatRoom
{
public string Id { get; set; }
public string Name { get; set; }
public List<ChatMessage> Messages { get; set; }
}
}

View file

@ -34,5 +34,14 @@ namespace ShiftOS.Objects
{
public string Username { get; set; }
public string Password { get; set; }
public UserPermissions Permissions { get; set; }
}
public enum UserPermissions
{
Root,
Admin,
User,
Guest
}
}

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public class EngineShiftnetSubscription
{
public string Name { get; set; }
public string Description { get; set; }
public int CostPerMonth { get; set; }
public int DownloadSpeed { get; set; }
public string Company { get; set; }
}
}

View file

@ -58,6 +58,16 @@ namespace ShiftOS.Objects
public Dictionary<string, LegionRole> Roles { get; set; }
public Dictionary<LegionRole, string> RoleNames { get; set; }
//Just adding a birbb in here
public UserClass Class { get; set; }
public double RawReputation { get; set; }
public Reputation Reputation
{
get
{
return (Reputation)((int)Math.Round(RawReputation));
}
}
}
}

View file

@ -1,4 +1,4 @@
/*
/*
* MIT License
*
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
@ -64,6 +64,18 @@ namespace ShiftOS.Objects
public string ResponseName { get; private set; }
}
public class ChatLogRequest
{
public ChatLogRequest(string chan, int backtrack = 0)
{
Channel = chan;
Backtrack = backtrack;
}
public int Backtrack { get; set; }
public string Channel { get; set; }
}
}

View file

@ -96,6 +96,10 @@ namespace ShiftOS.Objects
//Don't describe this one. We want it to be hidden from the admin panel's chat editor.
public string ID { get; set; }
[FriendlyName("Requires Patreon?")]
[FriendlyDescription("If checked, this chat will only be shown in the MUD Control Centre if the user's save is marked as a Patreon supporter.")]
public bool RequiresPatreon { get; set; }
[FriendlyName("Chat topic")]
[FriendlyDescription("A more in-depth version of your chat name. Describe what your chat's about in a sentence.")]
public string Topic { get; set; }

View file

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects
{
public enum Reputation
{
Saint = 5,
Moral = 4,
Trustworthy = 3,
WellKnown = 2,
Respected = 1,
Neutral = 0,
Disrespected = -1,
Criminal = -2,
Untrustworthy = -3,
Immoral = -4,
Outcast = -5
}
public enum UserClass
{
/// <summary>
/// The user has no class.
/// </summary>
None = 0,
/// <summary>
/// Skinners, otherwise known as "Shifters" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints.
/// </summary>
Skinner = 1,
/// <summary>
/// Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target.
/// </summary>
Hacker = 2,
/// <summary>
/// Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations.
/// </summary>
Investigator = 3,
/// <summary>
/// Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent.
/// </summary>
Explorer = 4,
/// <summary>
/// Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe.
/// </summary>
SafetyActivist = 5,
/// <summary>
/// Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful.
/// </summary>
PenetrationTester = 6,
/// <summary>
/// Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints.
/// </summary>
Collector = 7,
/// <summary>
/// Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions.
/// </summary>
Programmer = 8
}
}

View file

@ -34,8 +34,40 @@ namespace ShiftOS.Objects
//Better to store this stuff server-side so we can do some neat stuff with hacking...
public class Save
{
public int MusicVolume { get; set; }
public int SfxVolume { get; set; }
[Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")]
public string Username { get; set; }
public long Codepoints { get; set; }
private long _cp = 0;
public long Codepoints
{
get
{
if (!string.IsNullOrWhiteSpace(UniteAuthToken))
{
var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken);
return uc.GetCodepoints();
}
else
return _cp;
}
set
{
if (!string.IsNullOrWhiteSpace(UniteAuthToken))
{
var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken);
uc.SetCodepoints(value);
}
else
_cp = value;
}
}
public Dictionary<string, bool> Upgrades { get; set; }
public int StoryPosition { get; set; }
public string Language { get; set; }
@ -45,6 +77,21 @@ namespace ShiftOS.Objects
public int MinorVersion { get; set; }
public int Revision { get; set; }
public string UniteAuthToken { get; set; }
public bool IsPatreon { get; set; }
public UserClass Class { get; set; }
public double RawReputation { get; set; }
public Reputation Reputation
{
get
{
return (Reputation)((int)Math.Round(RawReputation));
}
}
public string Password { get; set; }
public bool PasswordHashed { get; set; }
public string SystemName { get; set; }
@ -65,6 +112,9 @@ namespace ShiftOS.Objects
}
}
public int LastMonthPaid { get; set; }
public List<string> StoriesExperienced { get; set; }
public int CountUpgrades()
{
int count = 0;
@ -75,6 +125,8 @@ namespace ShiftOS.Objects
}
return count;
}
public List<ClientSave> Users { get; set; }
}
public class SettingsObject : DynamicObject

View file

@ -32,23 +32,16 @@ using System.Threading;
namespace ShiftOS.Objects.ShiftFS
{
public enum Permissions
{
User,
Administrator,
Superuser,
All
}
public class File
{
public string Name;
public byte[] Data;
public byte[] HeaderData;
public bool ReadAccessToLowUsers;
public Permissions permissions;
public UserPermissions permissions;
public System.IO.Stream GetStream()
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
return new System.IO.MemoryStream(Data);
}
@ -59,7 +52,7 @@ namespace ShiftOS.Objects.ShiftFS
return null;
}
public File(string name, byte[] data, bool ReadAccess_to_low_users, Permissions perm)
public File(string name, byte[] data, bool ReadAccess_to_low_users, UserPermissions perm)
{
Name = name;
Data = data;
@ -73,31 +66,31 @@ namespace ShiftOS.Objects.ShiftFS
public List<File> Files = new List<File>();
public List<Directory> Subdirectories = new List<Directory>();
public bool ReadAccessToLowUsers;
public Permissions permissions;
public UserPermissions permissions;
public void AddFile(File file)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
Files.Add(file);
}
}
public void RemoveFile(string name)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
Files.Remove(Files.Find(x => x.Name == name));
}
}
public void RemoveFile(File file)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
Files.Remove(file);
}
}
public File FindFileByName(string name)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
return Files.Find(x => x.Name == name);
}
@ -105,28 +98,28 @@ namespace ShiftOS.Objects.ShiftFS
}
public void AddDirectory(Directory dir)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
Subdirectories.Add(dir);
}
}
public void RemoveDirectory(string name)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
Subdirectories.Remove(Subdirectories.Find(x => x.Name == name));
}
}
public void RemoveDirectory(Directory dir)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
Subdirectories.Remove(dir);
}
}
public Directory FindDirectoryByName(string name)
{
if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All)
if ((int)CurrentUser <= (int)permissions)
{
return Subdirectories.Find(x => x.Name == name);
}
@ -136,7 +129,7 @@ namespace ShiftOS.Objects.ShiftFS
public static class Utils
{
public static Permissions CurrentUser { get; set; }
public static UserPermissions CurrentUser { get; set; }
public static List<Directory> Mounts { get; set; }
@ -173,6 +166,11 @@ namespace ShiftOS.Objects.ShiftFS
t.Start();
}
public static event Action<string> DirectoryCreated;
public static event Action<string> DirectoryDeleted;
public static event Action<string> FileWritten;
public static event Action<string> FileDeleted;
public static void CreateDirectory(string path)
{
@ -190,6 +188,7 @@ namespace ShiftOS.Objects.ShiftFS
Name = pathlist[pathlist.Length - 1],
permissions = CurrentUser,
});
DirectoryCreated?.Invoke(path);
}
else
{
@ -224,14 +223,18 @@ namespace ShiftOS.Objects.ShiftFS
if (!FileExists(path))
{
dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All));
try
{
dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, CurrentUser));
}
catch { }
}
else
{
var f = dir.FindFileByName(pathlist[pathlist.Length - 1]);
f.Data = Encoding.UTF8.GetBytes(contents);
}
FileWritten?.Invoke(path);
}
@ -248,10 +251,12 @@ namespace ShiftOS.Objects.ShiftFS
if (FileExists(path))
{
dir.RemoveFile(pathlist[pathlist.Length - 1]);
FileDeleted?.Invoke(path);
}
else
{
dir.RemoveDirectory(pathlist[pathlist.Length - 1]);
DirectoryDeleted?.Invoke(path);
}
}
@ -269,14 +274,14 @@ namespace ShiftOS.Objects.ShiftFS
if (!FileExists(path))
{
dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, Permissions.All));
dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, CurrentUser));
}
else
{
var f = dir.FindFileByName(pathlist[pathlist.Length - 1]);
f.Data = contents;
}
FileWritten?.Invoke(path);
}
@ -291,10 +296,13 @@ namespace ShiftOS.Objects.ShiftFS
{
string[] pathlist = path.Split('/');
int vol = Convert.ToInt32(pathlist[0].Replace(":", ""));
if (Mounts[vol] == null)
Mounts[vol] = new Directory();
var dir = Mounts[vol];
for (int i = 1; i <= pathlist.Length - 1; i++)
{
dir = dir.FindDirectoryByName(pathlist[i]);
dir = dir?.FindDirectoryByName(pathlist[i]);
}
return dir != null;
@ -390,6 +398,63 @@ namespace ShiftOS.Objects.ShiftFS
return paths.ToArray();
}
/// <summary>
/// Copies a file or directory from one path to another, deleting the original.
/// </summary>
/// <param name="path">THe input path, must be a valid directory or file.</param>
/// <param name="target">The output path.</param>
public static void Move(string path, string target)
{
if (FileExists(path))
{
WriteAllBytes(target, ReadAllBytes(path));
Delete(path);
}
else if (DirectoryExists(path))
{
if (!DirectoryExists(target))
CreateDirectory(target);
foreach (var file in GetFiles(path))
{
var name = GetFileInfo(file).Name;
Copy(file, target + "/" + name);
}
foreach (var dir in GetDirectories(path))
{
string name = GetDirectoryInfo(dir).Name;
Copy(dir, target + "/" + name);
}
Delete(path);
}
}
/// <summary>
/// Copies a file or directory from one path to another.
/// </summary>
/// <param name="path">The input path, must be a valid directory or file.</param>
/// <param name="target">The output path.</param>
public static void Copy(string path, string target)
{
if (FileExists(path))
WriteAllBytes(target, ReadAllBytes(path));
else if (DirectoryExists(path))
{
if (!DirectoryExists(target))
CreateDirectory(target);
foreach(var file in GetFiles(path))
{
var name = GetFileInfo(file).Name;
Copy(file, target + "/" + name);
}
foreach(var dir in GetDirectories(path))
{
string name = GetDirectoryInfo(dir).Name;
Copy(dir, target + "/" + name);
}
}
}
public static string[] GetFiles(string path)
{
string[] pathlist = path.Split('/');

View file

@ -45,16 +45,22 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChatRoom.cs" />
<Compile Include="ClientSave.cs" />
<Compile Include="EngineShiftnetSubscription.cs" />
<Compile Include="Job.cs" />
<Compile Include="Legion.cs" />
<Compile Include="MudAttributes.cs" />
<Compile Include="Objects.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reputation.cs" />
<Compile Include="Save.cs" />
<Compile Include="ShiftFS.cs" />
<Compile Include="ShiftOSMenuRenderer.cs" />
<Compile Include="Shop.cs" />
<Compile Include="UniteClient.cs" />
<Compile Include="Unite\Download.cs" />
<Compile Include="Unite\ReleaseQuery.cs" />
<Compile Include="UserConfig.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View file

@ -1,51 +0,0 @@
/*
* 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.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShiftOS.Objects
{
class ShiftOSMenuRenderer : ToolStripProfessionalRenderer
{
public ShiftOSMenuRenderer() : base(new ShiftOSColorTable())
{
}
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
{
}
}
public class ShiftOSColorTable : ProfessionalColorTable
{
}
}

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects.Unite
{
public class Download
{
public string Id { get; set; }
public string Name { get; set; }
public string Changelog { get; set; }
public string DownloadUrl { get; set; }
public bool Obsolete { get; set; }
public DateTime PostDate { get; set; }
public string ReleasedBy { get; set; }
public string DevUpdateId { get; set; }
public string ScreenshotUrl { get; set; }
public bool IsStable { get; set; }
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Objects.Unite
{
public class ReleaseQuery
{
public bool ShowUnstable { get; set; }
public bool ShowObsolete { get; set; }
public DateTime CurrentBuildDate { get; set; }
}
}

View file

@ -0,0 +1,236 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using ShiftOS.Objects;
namespace ShiftOS.Unite
{
public class UniteClient
{
/// <summary>
/// Gets a string represents the user token for this Unite Client.
/// </summary>
public string Token { get; private set; }
/// <summary>
/// Gets the base URL used in all API calls. Retrieved from the user's servers.json file.
/// </summary>
public string BaseURL
{
get
{
return UserConfig.Get().UniteUrl;
}
}
/// <summary>
/// Get the display name of a user.
/// </summary>
/// <param name="id">The user ID to look at.</param>
/// <returns></returns>
public string GetDisplayNameId(string id)
{
return MakeCall("/API/GetDisplayName/" + id);
}
/// <summary>
/// Get the Pong highscore stats for all users.
/// </summary>
/// <returns></returns>
public PongHighscoreModel GetPongHighscores()
{
return JsonConvert.DeserializeObject<PongHighscoreModel>(MakeCall("/API/GetPongHighscores"));
}
/// <summary>
/// Create a new instance of the <see cref="UniteClient"/> object.
/// </summary>
/// <param name="baseurl">Unused.</param>
/// <param name="usertoken">The user API token to use for this client (see http://getshiftos.ml/Manage and click "API" to see your tokens)</param>
public UniteClient(string baseurl, string usertoken)
{
//Handled by the servers.json file
//BaseURL = baseurl;
Token = usertoken;
}
/// <summary>
/// Make a call to the Unite API using the current user token and base URL.
/// </summary>
/// <param name="url">The path, relative to the base URL, to call.</param>
/// <returns>The server's response.</returns>
internal string MakeCall(string url)
{
var webrequest = WebRequest.Create(BaseURL + url);
webrequest.Headers.Add("Authentication: Token " + Token);
using (var response = webrequest.GetResponse())
{
using (var stream = response.GetResponseStream())
{
using (var reader = new System.IO.StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
}
/// <summary>
/// Get the Pong codepoint highscore for the current user.
/// </summary>
/// <returns>The amount of Codepoints returned by the server</returns>
public int GetPongCP()
{
return Convert.ToInt32(MakeCall("/API/GetPongCP"));
}
/// <summary>
/// Get the pong highest level score for this user
/// </summary>
/// <returns>The highest level the user has reached.</returns>
public int GetPongLevel()
{
return Convert.ToInt32(MakeCall("/API/GetPongLevel"));
}
/// <summary>
/// Set the user's highest level record for Pong.
/// </summary>
/// <param name="value">The level to set the record to.</param>
public void SetPongLevel(int value)
{
MakeCall("/API/SetPongLevel/" + value.ToString());
}
/// <summary>
/// Set the pong Codepoints record for the user
/// </summary>
/// <param name="value">The amount of Codepoints to set the record to</param>
public void SetPongCP(int value)
{
MakeCall("/API/SetPongCP/" + value.ToString());
}
/// <summary>
/// Get the user's email address.
/// </summary>
/// <returns>The user's email address.</returns>
public string GetEmail()
{
return MakeCall("/API/GetEmail");
}
/// <summary>
/// Get the user's system name.
/// </summary>
/// <returns>The user's system name.</returns>
public string GetSysName()
{
return MakeCall("/API/GetSysName");
}
/// <summary>
/// Set the user's system name.
/// </summary>
/// <param name="value">The system name to set the record to.</param>
public void SetSysName(string value)
{
MakeCall("/API/SetSysName/" + value);
}
/// <summary>
/// Get the user's display name.
/// </summary>
/// <returns>The user's display name.</returns>
public string GetDisplayName()
{
return MakeCall("/API/GetDisplayName");
}
/// <summary>
/// Set the user's display name.
/// </summary>
/// <param name="value">The display name to set the user's account to.</param>
public void SetDisplayName(string value)
{
MakeCall("/API/SetDisplayName/" + value.ToString());
}
/// <summary>
/// Get the user's full name if they have set it in their profile.
/// </summary>
/// <returns>Empty string if the user hasn't set their fullname, else, a string representing their fullname.</returns>
public string GetFullName()
{
return MakeCall("/API/GetFullName");
}
/// <summary>
/// Set the user's fullname.
/// </summary>
/// <param name="value">The new fullname.</param>
public void SetFullName(string value)
{
MakeCall("/API/SetFullName/" + value.ToString());
}
/// <summary>
/// Get the user's codepoints.
/// </summary>
/// <returns>The amount of codepoints stored on the server for this user.</returns>
public long GetCodepoints()
{
return Convert.ToInt64(MakeCall("/API/GetCodepoints"));
}
/// <summary>
/// Set the user's codepoints.
/// </summary>
/// <param name="value">The amount of codepoints to set the user's codepoints value to.</param>
public void SetCodepoints(long value)
{
MakeCall("/API/SetCodepoints/" + value.ToString());
}
}
/// <summary>
/// API data model for Unite pong highscores.
/// </summary>
public class PongHighscoreModel
{
/// <summary>
/// Amount of pages in this list.
/// </summary>
public int Pages { get; set; }
/// <summary>
/// An array representing the highscores found on the server.
/// </summary>
public PongHighscore[] Highscores { get; set; }
}
/// <summary>
/// API data model for a single Pong highscore.
/// </summary>
public class PongHighscore
{
/// <summary>
/// The user ID linked to this highscore.
/// </summary>
public string UserId { get; set; }
/// <summary>
/// The highscore's level record.
/// </summary>
public int Level { get; set; }
/// <summary>
/// The highscore's codepoint cashout record.
/// </summary>
public long CodepointsCashout { get; set; }
}
}

View file

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ShiftOS.Objects
{
public class UserConfig
{
public string UniteUrl { get; set; }
public string DigitalSocietyAddress { get; set; }
public int DigitalSocietyPort { get; set; }
public static UserConfig Get()
{
var conf = new UserConfig
{
UniteUrl = "http://getshiftos.ml",
DigitalSocietyAddress = "michaeltheshifter.me",
DigitalSocietyPort = 13370
};
if (!File.Exists("servers.json"))
{
File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented));
}
else
{
conf = JsonConvert.DeserializeObject<UserConfig>(File.ReadAllText("servers.json"));
}
return conf;
}
}
}

View file

@ -1,808 +0,0 @@
/*
* 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.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Bootstrapper;
using Nancy.Hosting.Self;
using Nancy.ModelBinding;
using Nancy.Security;
using Nancy.TinyIoc;
using Newtonsoft.Json;
using ShiftOS.Objects;
namespace ShiftOS.Server.WebAdmin
{
class Program
{
static void Main(string[] args)
{
var HostConf = new HostConfiguration();
HostConf.UrlReservations.CreateAutomatically = true;
HostConf.RewriteLocalhost = true;
using(var nancy = new NancyHost(HostConf, new Uri("http://localhost:13371/mudadmin/")))
{
nancy.Start();
Console.WriteLine($"[{DateTime.Now}] <AdminPanel/NancyInit> Initiating on localhost:13371...");
Console.ReadLine();
}
}
}
public static class PageBuilder
{
public static string Build(string page, Dictionary<string, string> templateParams = null)
{
string templatehtml = Properties.Resources.HtmlTemplate;
if (templateParams == null)
{
templateParams = new Dictionary<string, string>();
}
if (!templateParams.ContainsKey("{logout}"))
{
templateParams.Add("{logout}", "<li><a href=\"/mudadmin/logout\">Log out</a></li>");
}
if (SystemManager.MudIsRunning())
{
templateParams.Add("{mud_power}", "<li><a href='/mudadmin/poweroff'><span class='glyphicon glyphicon-power-off'></span> Power off</a></li>");
templateParams.Add("{mud_restart}", "<li><a href='/mudadmin/restart'><span class='glyphicon glyphicon-refresh'></span> Restart</a></li>");
}
else
{
templateParams.Add("{mud_power}", "<li><a href='/mudadmin/poweron'><span class='glyphicon glyphicon-power-on'></span> Power on</a></li>");
templateParams.Add("{mud_restart}", "");
}
if(templateParams["{logout}"] == "")
{
templateParams["{mud_power}"] = "";
templateParams["{mud_restart}"] = "";
}
switch (page)
{
case "status":
templatehtml = templatehtml.Replace("{body}", Properties.Resources.Status);
break;
case "login":
templatehtml = templatehtml.Replace("{body}", Properties.Resources.LoginView);
break;
case "initialsetup":
templatehtml = templatehtml.Replace("{body}", Properties.Resources.SetupView);
break;
}
try
{
foreach (var param in templateParams)
{
templatehtml = templatehtml.Replace(param.Key, param.Value);
}
}
catch { }
return templatehtml;
}
}
public class MudUserIdentity : IUserIdentity
{
public MudUserIdentity(string username)
{
_username = username;
}
public IEnumerable<string> Claims
{
get
{
return SystemManager.GetClaims(_username);
}
}
private string _username = "";
public string UserName
{
get
{
return _username;
}
}
}
public static class SystemManager
{
public static bool MudIsRunning()
{
var processes = System.Diagnostics.Process.GetProcessesByName("ShiftOS.Server");
return processes.Length > 0;
}
public static void KillMud()
{
var processes = System.Diagnostics.Process.GetProcessesByName("ShiftOS.Server");
for(int i = 0; i < processes.Length; i++)
{
try
{
processes[i].Kill();
}
catch
{
}
}
}
public static List<string> GetClaims(string username)
{
foreach(var save in GetSaves())
{
if (save.IsMUDAdmin)
{
return new List<string> { "User", "Admin" };
}
}
return new List<string>(new[] { "User" });
}
public static Save[] GetSaves()
{
List<Save> saves = new List<Save>();
if (Directory.Exists("saves"))
{
foreach(var saveFile in Directory.GetFiles("saves"))
{
try
{
saves.Add(JsonConvert.DeserializeObject<Save>(Server.Program.ReadEncFile(saveFile)));
}
catch { }
}
}
return saves.ToArray();
}
public static bool Login(string username, string password, out Guid id)
{
foreach (var user in GetSaves())
{
if (user.Username == username && user.Password == password)
{
id = user.ID;
return true;
}
}
id = new Guid();
return false;
}
public static string BuildFormFromObject(object obj)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("<form method='post' action=''><table class='table'>");
foreach(var prop in obj.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
{
string name = "";
string description = "No description.";
foreach(var attrib in prop.GetCustomAttributes(false))
{
if(attrib is FriendlyNameAttribute)
{
name = (attrib as FriendlyNameAttribute).Name;
}
if(attrib is FriendlyDescriptionAttribute)
{
description = (attrib as FriendlyDescriptionAttribute).Description;
}
}
if (name != "")
{
sb.AppendLine("<tr>");
sb.AppendLine($@"<td width=""45%"">
<p><strong>{name}</strong></p>
<p>{description}</p>
</td>
<td>");
if (prop.PropertyType == typeof(bool))
{
string isChecked = ((bool)prop.GetValue(obj) == true) ? "checked" : "";
sb.AppendLine($"<input class='form-control' type='checkbox' name='{prop.Name}' {isChecked}/>");
}
else if (prop.PropertyType == typeof(string))
{
sb.AppendLine($"<input class='form-control' type='text' name='{prop.Name}' value='{prop.GetValue(obj)}'/>");
}
sb.AppendLine("</td></tr>");
}
else
{
sb.AppendLine($"<input type='hidden' name='{prop.Name}' value='{prop.GetValue(obj)}'/>");
}
}
sb.AppendLine("<tr><td></td><td><input class='btn btn-default' type='submit'/></td></tr>");
sb.AppendLine("</table></form>");
return sb.ToString();
}
public static Channel GetChat(string id)
{
if (File.Exists("chats.json"))
foreach (var channel in JsonConvert.DeserializeObject<List<Channel>>(File.ReadAllText("chats.json")))
{
if (channel.ID == id)
return channel;
}
return new Channel();
}
public static string BuildSaveListing(Save[] list)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("<table class=\"table\">");
sb.AppendLine(@"<tr>
<td><strong>Username</strong></td>
<td><strong>System Name</strong></td>
<td><strong>Codepoints</strong></td>
<td><strong>Shiftorium Upgrades</strong></td>
<td><strong>Is MUD Admin</strong></td>
<td><strong>Actions</strong></td>
</tr>");
foreach(var save in list)
{
sb.AppendLine($@"<tr>
<td>{save.Username}</td>
<td>{save.SystemName}</td>
<td>{save.Codepoints}</td>
<td>{save.CountUpgrades()} installed, {save.Upgrades.Count} total</td>
<td>{save.IsMUDAdmin}</td>
<td>
<a href=""/mudadmin/toggleadmin/{save.Username}"" class=""btn btn-danger"">Toggle admin</a>
<a href=""/mudadmin/deletesave/{save.Username}"" class=""btn btn-danger"">Delete save</a>
</td>
</tr>");
}
sb.AppendLine("</table>");
return sb.ToString();
}
public static string GetAllChats()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("<table class=\"table\">");
sb.AppendLine($@"<tr><td><strong>ID</strong></td>
<td><strong>Name</strong></td>
<td><strong>Topic</strong></td>
<td><strong>Is Discord Relay</strong></td>
<td><strong>Discord channel ID</strong></td>
<td><strong>Discord Bot Token</strong></td>
<td><strong>Actions</strong></td></tr>");
if (File.Exists("chats.json"))
{
foreach(var chat in JsonConvert.DeserializeObject<List<Channel>>(File.ReadAllText("chats.json")))
{
sb.AppendLine($@"<tr>
<td>{chat.ID}</td>
<td>{chat.Name}</td>
<td>{chat.Topic}</td>
<td>{chat.IsDiscordProxy}</td>
<td>{chat.DiscordChannelID}</td>
<td>{chat.DiscordBotToken}</td>
<td>
<a href=""/mudadmin/editchat/{chat.ID}"" class=""btn btn-default""><span class=""glyphicon glyphicon-pencil""></span>Edit</a>
<a href=""#"" class=""btn btn-default"" data-toggle=""modal"" data-target=""#modal_{chat.ID}""><span class=""glyphicon glyphicon-delete""></span> Delete</a>
</td>
</tr>");
sb.AppendLine(CreateModal(chat.ID, "Delete " + chat.Name + "?", "Are you sure you want to delete this chat?", "/deletechat/" + chat.ID));
}
}
sb.AppendLine("</table>");
return sb.ToString();
}
public static string CreateModal(string id, string title, string msg, string callbackUrl)
{
return $@"<div id=""modal_{id}"" class=""modal fade"" role=""dialog"">
<div class=""modal-dialog"">
<!-- Modal content-->
<div class=""modal-content"">
<div class=""modal-header"">
<button type=""button"" class=""close"" data-dismiss=""modal"">&times;</button>
<h4 class=""modal-title"">{title}</h4>
</div>
<div class=""modal-body"">
<p>{msg}</p>
</div>
<div class=""modal-footer"">
<a href=""/mudadmin{callbackUrl}"" class=""btn btn-danger"">Yes</a>
<button type=""button"" class=""btn btn-default"" data-dismiss=""modal"">No</button>
</div>
</div>
</div>
</div>";
}
public static string GetCPWorth()
{
if (System.IO.Directory.Exists("saves"))
{
long cp = 0;
foreach(var file in System.IO.Directory.GetFiles("saves"))
{
if (file.EndsWith(".save"))
{
var save = JsonConvert.DeserializeObject<Save>(Server.Program.ReadEncFile(file));
cp += save.Codepoints;
}
}
return cp.ToString();
}
else
{
return "0";
}
}
public static string GetUserCount()
{
if (System.IO.Directory.Exists("saves"))
{
return System.IO.Directory.GetFiles("saves").Length.ToString();
}
else
{
return "0";
}
}
public static MudUserIdentity GetIdentity(Guid id)
{
foreach (var user in GetSaves())
{
if (user.ID == id)
{
return new WebAdmin.MudUserIdentity(user.Username);
}
}
return null;
}
internal static void MakeAdmin(string username)
{
Save sav = null;
foreach(var save in GetSaves())
{
if (save.Username == username)
sav = save;
}
if(sav != null)
{
sav.IsMUDAdmin = true;
Server.Program.WriteEncFile("saves/" + username + ".save", JsonConvert.SerializeObject(sav));
}
}
internal static Save[] GetAdmins()
{
var saves = new List<Save>();
foreach(var save in GetSaves())
{
if(save.IsMUDAdmin == true)
{
saves.Add(save);
}
}
return saves.ToArray();
}
}
public class MudUser
{
[FriendlyName("Username")]
[FriendlyDescription("The username you will appear as in-game.")]
public string Username { get; set; }
[FriendlyName("Password")]
[FriendlyDescription("A password that you will use to log in to the admin panel and the game.")]
public string Password { get; set; }
[FriendlyName("System name")]
[FriendlyDescription("An in-game hostname for your account. In ShiftOS, your user ID is always yourusername@yoursystemname. Be creative.")]
public string SystemName { get; set; }
public Guid ID { get; set; }
}
public class MudBootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
var formsAuthConfiguration = new FormsAuthenticationConfiguration();
formsAuthConfiguration.RedirectUrl = "~/login";
formsAuthConfiguration.UserMapper = container.Resolve<IUserMapper>();
FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
base.ApplicationStartup(container, pipelines);
}
}
public class MudUserMapper : IUserMapper
{
public IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context)
{
return SystemManager.GetIdentity(identifier);
}
}
public class LoginModule : NancyModule
{
public LoginModule()
{
Get["/login"] = parameters =>
{
if (SystemManager.GetSaves().Length > 0)
{
if (SystemManager.GetAdmins().Length > 0)
{
return PageBuilder.Build("login", new Dictionary<string, string>
{
{"{logout}", "" }
});
}
else
{
return PageBuilder.Build("initialsetup", new Dictionary<string, string>
{
{"{logout}", "" },
{"{savelist}", BuildSaveList() }
});
}
}
else
{
return PageBuilder.Build("bla", new Dictionary<string, string>
{
{"{body}", Properties.Resources.NoUsersFound },
{"{user_create_form}", SystemManager.BuildFormFromObject(new MudUser()) }
});
}
};
Get["/logout"] = parameters =>
{
return this.Logout("~/");
};
Post["/login"] = parameters =>
{
if (SystemManager.GetSaves().Length > 0)
{
if (SystemManager.GetAdmins().Length == 0)
{
var user = this.Bind<LoginRequest>();
SystemManager.MakeAdmin(user.username);
Guid id = new Guid();
if(SystemManager.Login(user.username, user.password, out id) == true)
{
return this.Login(id);
}
return new UserModule().Redirect("/login");
}
else
{
var user = this.Bind<LoginRequest>();
Guid id = new Guid();
if (SystemManager.Login(user.username, user.password, out id) == true)
{
return this.Login(id);
}
return new UserModule().Redirect("/login");
}
}
else
{
var newUser = this.Bind<MudUser>();
var save = new Save();
save.Username = newUser.Username;
save.SystemName = newUser.SystemName;
save.Password = newUser.Password;
save.Codepoints = 0;
save.MyShop = "";
save.Upgrades = new Dictionary<string, bool>();
save.IsMUDAdmin = true;
save.StoryPosition = 1;
if (!Directory.Exists("saves"))
Directory.CreateDirectory("saves");
save.ID = Guid.NewGuid();
Server.Program.WriteEncFile("saves/" + save.Username + ".save", JsonConvert.SerializeObject(save));
return this.Login(save.ID);
}
};
}
private string BuildSaveList()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("<table class='table'>");
sb.AppendLine($@"<tr>
<td><strong>Username</strong></td>
<td><strong>System name</strong></td>
<td><strong>Codepoints</strong></td>
<td><strong>Actions</strong></td>
</tr>");
foreach(var save in SystemManager.GetSaves())
{
sb.AppendLine($@"<tr>
<td>{save.Username}</td>
<td>{save.SystemName}</td>
<td>{save.Codepoints}</td>
<td><form method='post' action=''>
<input type='hidden' name='username' value='{save.Username}'/><input type='hidden' name='password' value='{save.Password}'/>
<input type='submit' value='Choose' class='btn btn-default'/>
</form></td>
</tr>");
}
sb.AppendLine("</table>");
return sb.ToString();
}
}
public class UserModule : NancyModule
{
public string Redirect(string url)
{
return $@"<html>
<head>
<meta http-equiv=""refresh"" content=""0; url=/mudadmin{url}"" />
</ head>
</html>";
}
public UserModule()
{
this.RequiresAuthentication();
this.RequiresClaims("Admin");
Get["/"] = _ =>
{
return Redirect("/status");
};
Get["/toggleadmin/{id}"] = parameters =>
{
string id = parameters.id;
for (int i = 0; i < SystemManager.GetSaves().Length; i++)
{
var save = SystemManager.GetSaves()[i];
if(save.Username.ToString() == id)
{
save.IsMUDAdmin = !save.IsMUDAdmin;
Server.Program.WriteEncFile("saves/" + save.Username + ".save", JsonConvert.SerializeObject(save));
}
}
return Redirect("/saves");
};
Get["/deletesave/{username}"] = parameters =>
{
string id = parameters.username;
for (int i = 0; i < SystemManager.GetSaves().Length; i++)
{
if (SystemManager.GetSaves()[i].Username.ToString() == id)
{
File.Delete("saves/" + SystemManager.GetSaves()[i].Username + ".save");
}
}
return Redirect("/saves");
};
Get["/saves"] = _ =>
{
return PageBuilder.Build("bla", new Dictionary<string, string>
{
{ "{body}", Properties.Resources.GenericTableList },
{ "{listtitle}", "Test subjects" },
{ "{listdesc}", "Below is a list of test subjects (save files) on your multi-user domain. You can see their username, system name, Codepoints, amount of installed upgrades, and you can also perform basic actions on each save." },
{ "{list}", SystemManager.BuildSaveListing(SystemManager.GetSaves()) }
});
};
Get["/status"] = _ =>
{
return statusBuilder();
};
Get["/deletechat/{id}"] = parameters =>
{
string chatID = parameters.id;
var chats = JsonConvert.DeserializeObject<List<Channel>>(File.ReadAllText("chats.json"));
for(int i = 0; i < chats.Count; i++)
{
try
{
if (chats[i].ID == chatID)
chats.RemoveAt(i);
}
catch { }
}
File.WriteAllText("chats.json", JsonConvert.SerializeObject(chats, Formatting.Indented));
return Redirect("/chats");
};
Get["/chats"] = _ =>
{
return chatsListBuilder();
};
Get["/createchat"] = _ =>
{
return PageBuilder.Build("editchat", new Dictionary<string, string>
{
{"{body}", Properties.Resources.ChatEditTemplate },
{"{form}", SystemManager.BuildFormFromObject(new Channel()) }
});
};
Post["/createchat"] = parameters =>
{
var chat = this.Bind<Channel>();
chat.ID = chat.Name.ToLower().Replace(" ", "_");
List<Channel> chats = new List<Channel>();
if (File.Exists("chats.json"))
chats = JsonConvert.DeserializeObject<List<Channel>>(File.ReadAllText("chats.json"));
bool chatExists = false;
for (int i = 0; i < chats.Count; i++)
{
if (chats[i].ID == chat.ID)
{
chats[i] = chat;
chatExists = true;
}
}
if (!chatExists)
{
chats.Add(chat);
}
File.WriteAllText("chats.json", JsonConvert.SerializeObject(chats, Formatting.Indented));
return Redirect("/chats");
};
Get["/editchat/{id}"] = parameters =>
{
return PageBuilder.Build("editchat", new Dictionary<string, string>
{
{"{body}", Properties.Resources.ChatEditTemplate },
{"{form}", SystemManager.BuildFormFromObject(SystemManager.GetChat(parameters.id)) }
});
};
Post["/editchat/{id}"] = parameters =>
{
var chat = this.Bind<Channel>();
chat.ID = chat.Name.ToLower().Replace(" ", "_");
List<Channel> chats = new List<Channel>();
if (File.Exists("chats.json"))
chats = JsonConvert.DeserializeObject<List<Channel>>(File.ReadAllText("chats.json"));
bool chatExists = false;
for (int i = 0; i < chats.Count; i++)
{
if (chats[i].ID == chat.ID)
{
chats[i] = chat;
chatExists = true;
}
}
if (!chatExists)
{
chats.Add(chat);
}
File.WriteAllText("chats.json", JsonConvert.SerializeObject(chats, Formatting.Indented));
return Redirect("/chats");
};
Get["/poweron"] = _ =>
{
if (!SystemManager.MudIsRunning())
{
System.Diagnostics.Process.Start("ShiftOS.Server.exe");
}
return Redirect("/");
};
Get["/poweroff"] = _ =>
{
if (SystemManager.MudIsRunning())
{
SystemManager.KillMud();
}
return Redirect("/");
};
Get["/restart"] = _ =>
{
if (SystemManager.MudIsRunning())
{
SystemManager.KillMud();
}
return Redirect("/poweron");
};
}
private string statusBuilder()
{
return PageBuilder.Build("status", new Dictionary<string, string>{
{ "{cp_worth}", SystemManager.GetCPWorth() },
{ "{user_count}", SystemManager.GetUserCount() },
{ "{system_time}", DateTime.Now.ToString() },
});
}
private string chatsListBuilder()
{
return PageBuilder.Build("bla", new Dictionary<string, string>
{
{ "{body}", Properties.Resources.ChatListView },
{ "{chat_table}", SystemManager.GetAllChats() }
});
}
}
public class LoginRequest
{
public string username { get; set; }
public string password { get; set; }
}
}

View file

@ -1,60 +0,0 @@
/*
* 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.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ShiftOS.Server.WebAdmin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShiftOS.Server.WebAdmin")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b29fdd06-e6fe-40a2-8258-283728ced81a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -1,220 +0,0 @@
/*
* 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.
*/
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ShiftOS.Server.WebAdmin.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShiftOS.Server.WebAdmin.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to &lt;h3&gt;Create/edit chat&lt;/h3&gt;
///
///&lt;p&gt;Please fill out the details below for your channel list to be modified.&lt;/p&gt;
///
///{form}.
/// </summary>
internal static string ChatEditTemplate {
get {
return ResourceManager.GetString("ChatEditTemplate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;h3&gt;Chats&lt;/h3&gt;
///
///&lt;p&gt;On this page you can find a list of all chats in the system. Chats are a part of the multi-user domain that allows online players to talk to eachother in the &apos;MUD Chat&apos; application.&lt;/p&gt;
///
///&lt;p&gt;If you have a Discord server for your multi-user domain, you can also designate a ShiftOS chat to listen on a specific channel on your server. You will need to create a Discord Bot Token and specify the ID of the channel you want tolisten to.&lt;/p&gt;
///
///&lt;p&gt;Once the chat is set up, you should see a bot [rest of string was truncated]&quot;;.
/// </summary>
internal static string ChatListView {
get {
return ResourceManager.GetString("ChatListView", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;h3&gt;{listtitle}&lt;/h3&gt;
///
///&lt;p&gt;{listdesc}&lt;/p&gt;
///
///{list}.
/// </summary>
internal static string GenericTableList {
get {
return ResourceManager.GetString("GenericTableList", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;html&gt;
/// &lt;head&gt;
/// &lt;title&gt;Multi-user domain &amp;bull; ShiftOS&lt;/title&gt;
/// &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css&quot; integrity=&quot;sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u&quot; crossorigin=&quot;anonymous&quot;&gt;
///
/// &lt;link rel=&quot;stylesheet&quot; href=&quot;http://getshiftos.ml/css/theme.css&quot;/&gt;
///
/// &lt;!-- Latest compiled and minified JavaScript --&gt;
/// &lt;script src=&quot;https://code.jquery.com/jquery-3.1.1.js&quot; integrity=&quot;sha256-16cdPddA6VdVInumRGo6IbivbERE8p7C [rest of string was truncated]&quot;;.
/// </summary>
internal static string HtmlTemplate {
get {
return ResourceManager.GetString("HtmlTemplate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;h3&gt;Access denied.&lt;/h3&gt;
///
///&lt;p&gt;You require a higher authentication level to access this part of the multi-user domain. Please enter the username and password of whom has access to this sector.&lt;/p&gt;
///
///&lt;form method=&quot;post&quot; action=&quot;&quot;&gt;
/// &lt;table class=&quot;table&quot;&gt;
/// &lt;tr&gt;
/// &lt;td&gt;&lt;strong&gt;Username:&lt;/strong&gt;&lt;/td&gt;
/// &lt;td&gt;&lt;input class=&quot;form-control&quot; type=&quot;text&quot; name=&quot;username&quot;/&gt;&lt;/td&gt;
/// &lt;/tr&gt;
/// &lt;tr&gt;
/// &lt;td&gt;&lt;strong&gt;Password:&lt;/strong&gt;&lt;/td&gt;
/// &lt;td&gt;&lt;input class=&quot;form-control&quot; type=&quot;password&quot; name=&quot;password&quot;/&gt;&lt;/td&gt;
/// &lt;/tr [rest of string was truncated]&quot;;.
/// </summary>
internal static string LoginView {
get {
return ResourceManager.GetString("LoginView", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;h3&gt;No users found.&lt;/h3&gt;
///
///&lt;p&gt;Your multi-user domain is newly-created. Before you can use the admin panel, you must create a ShiftOS user to act as the administrator of the MUD.&lt;/p&gt;
///
///{user_create_form}.
/// </summary>
internal static string NoUsersFound {
get {
return ResourceManager.GetString("NoUsersFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;h1&gt;Initial setup&lt;/h1&gt;
///
///&lt;p&gt;This multi-user domain contains some users, however none of them are administrators. Please choose your user to make it an admin.&lt;/p&gt;
///
///{savelist}.
/// </summary>
internal static string SetupView {
get {
return ResourceManager.GetString("SetupView", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;h3&gt;System status&lt;/h3&gt;
///
///&lt;p&gt;Below is a summary of this multi-user domain&apos;s status.&lt;/p&gt;
///
///&lt;div class=&quot;row&quot;&gt;
/// &lt;div class=&quot;col-xs-6&quot;&gt;
/// &lt;h4&gt;MUD stats&lt;/h4&gt;
/// &lt;ul&gt;
/// &lt;li&gt;This server is worth &lt;strong&gt;{cp_worth}&lt;/strong&gt; Codepoints.&lt;/li&gt;
/// &lt;li&gt;This server has &lt;strong&gt;{user_count}&lt;/strong&gt; players registered.&lt;/li&gt;
/// &lt;/ul&gt;
/// &lt;/div&gt;
/// &lt;div class=&quot;col-xs-6&quot;&gt;
/// &lt;h4&gt;System environment&lt;/h4&gt;
/// &lt;ul&gt;
/// &lt;li&gt;&lt;strong&gt;Current system time:&lt;/strong&gt; {system_time}&lt;/li&gt;
/// &lt;/ul&gt;
/// &lt;/div&gt;
///&lt;/div&gt;.
/// </summary>
internal static string Status {
get {
return ResourceManager.GetString("Status", resourceCulture);
}
}
}
}

View file

@ -1,5 +0,0 @@
<h3>Create/edit chat</h3>
<p>Please fill out the details below for your channel list to be modified.</p>
{form}

View file

@ -1,11 +0,0 @@
<h3>Chats</h3>
<p>On this page you can find a list of all chats in the system. Chats are a part of the multi-user domain that allows online players to talk to eachother in the 'MUD Chat' application.</p>
<p>If you have a Discord server for your multi-user domain, you can also designate a ShiftOS chat to listen on a specific channel on your server. You will need to create a Discord Bot Token and specify the ID of the channel you want tolisten to.</p>
<p>Once the chat is set up, you should see a bot join your Discord server. Once it does, any messages received by the server in that channel will be relayed into ShiftOS, and any messages received by the MUD in the ShiftOS channel will be relayed to Discord.</p>
<a href="/mudadmin/createchat" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create chat</a>
{chat_table}

View file

@ -1,5 +0,0 @@
<h3>{listtitle}</h3>
<p>{listdesc}</p>
{list}

View file

@ -1,58 +0,0 @@
<html>
<head>
<title>Multi-user domain &bull; ShiftOS</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="http://getshiftos.ml/css/theme.css"/>
<!-- Latest compiled and minified JavaScript -->
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="navbar navbar-default">
<div class+"navbar-header">
<a class="navbar-brand" href="http://getshiftos.ml">ShiftOS</a>
</div>
<ul class="nav navbar-nav">
<li>
<a href="/mudadmin/status">System status</a>
</li>
<li>
<a href="/mudadmin/saves">Test subjects</a>
</li>
<li>
<a href="#">Shiftnet (NYI)</a>
</li>
<li>
<a href="#">Scripts (NYI)</a>
</li>
<li>
<a href="#">Legions (NYI)</a>
</li>
<li>
<a href="/mudadmin/chats">Chats</a>
</li>
<li>
<a href="#">Shops (NYI)</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
{mud_restart}
{mud_power}
{logout}
</ul>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid content">
{body}
<p style="text-align:center;"><em>ShiftOS - MUD admin panel - Copyright &copy; 2017 ShiftOS developers</em></p>
</div>
</div>
</body>
</html>

View file

@ -1,31 +0,0 @@
<h3>Access denied.</h3>
<p>You require a higher authentication level to access this part of the multi-user domain. Please enter the username and password of whom has access to this sector.</p>
<form method="post" action="">
<table class="table">
<tr>
<td><strong>Username:</strong></td>
<td><input class="form-control" type="text" name="username"/></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input class="form-control" type="password" name="password"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" class="btn btn-default"/></td>
</tr>
</table>
</form>
<div class="row">
<div class="col-xs-6">
<h4>What are my credentials?</h4>
<p>If you do not know your credentials, you are not a ShiftOS developer with write-access to the GitHub repository and authorized access to the multi-user domain's backend, so we ask that you get off this site and try to hack the MUD in-game. Thank you.</p>
</div>
<div class="col-xs-6">
<h4>I am a developer.</h4>
<p>Please contact Michael VanOverbeek if you are a developer and have not yet received your credentials.</p>
</div>
</div>

View file

@ -1,5 +0,0 @@
<h3>No users found.</h3>
<p>Your multi-user domain is newly-created. Before you can use the admin panel, you must create a ShiftOS user to act as the administrator of the MUD.</p>
{user_create_form}

View file

@ -1,5 +0,0 @@
<h1>Initial setup</h1>
<p>This multi-user domain contains some users, however none of them are administrators. Please choose your user to make it an admin.</p>
{savelist}

View file

@ -1,19 +0,0 @@
<h3>System status</h3>
<p>Below is a summary of this multi-user domain's status.</p>
<div class="row">
<div class="col-xs-6">
<h4>MUD stats</h4>
<ul>
<li>This server is worth <strong>{cp_worth}</strong> Codepoints.</li>
<li>This server has <strong>{user_count}</strong> players registered.</li>
</ul>
</div>
<div class="col-xs-6">
<h4>System environment</h4>
<ul>
<li><strong>Current system time:</strong> {system_time}</li>
</ul>
</div>
</div>

View file

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B29FDD06-E6FE-40A2-8258-283728CED81A}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ShiftOS.Server.WebAdmin</RootNamespace>
<AssemblyName>ShiftOS.Server.WebAdmin</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Authentication.Forms, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Authentication.Stateless, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Authentication.Stateless.1.4.1\lib\net40\Nancy.Authentication.Stateless.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Hosting.Self, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Hosting.Self.1.4.1\lib\net40\Nancy.Hosting.Self.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ShiftOS.Objects\ShiftOS.Objects.csproj">
<Project>{A069089A-8962-4607-B2B2-4CF4A371066E}</Project>
<Name>ShiftOS.Objects</Name>
</ProjectReference>
<ProjectReference Include="..\ShiftOS.Server\ShiftOS.Server.csproj">
<Project>{226c63b4-e60d-4949-b4e7-7a2ddbb96776}</Project>
<Name>ShiftOS.Server</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\HtmlTemplate.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\LoginView.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\SetupView.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Status.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ChatListView.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ChatEditTemplate.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\NoUsersFound.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\GenericTableList.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Nancy" version="1.4.3" targetFramework="net452" />
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net452" />
<package id="Nancy.Authentication.Stateless" version="1.4.1" targetFramework="net452" />
<package id="Nancy.Hosting.Self" version="1.4.1" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
</packages>

View file

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
<loadFromRemoteSources enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0"/>
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1000.0" newVersion="3.0.1000.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View file

@ -1,162 +0,0 @@
/*
* 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.Linq;
using System.Text;
using System.Threading.Tasks;
using ShiftOS.Objects;
using NetSockets;
using Newtonsoft.Json;
using System.IO;
using static ShiftOS.Server.Program;
using Discord;
using Discord.WebSocket;
using Discord.Net.WebSockets;
namespace ShiftOS.Server
{
public static class ChatBackend
{
public static async Task StartDiscordBots()
{
Reinitialized?.Invoke();
if (!File.Exists("chats.json"))
File.WriteAllText("chats.json", "[]");
foreach (var chat in JsonConvert.DeserializeObject<List<ShiftOS.Objects.Channel>>(File.ReadAllText("chats.json")))
{
string chatID = chat.ID;
bool chatKilled = false;
if (chat.IsDiscordProxy == true)
{
DiscordSocketConfig builder = new DiscordSocketConfig();
builder.AudioMode = Discord.Audio.AudioMode.Disabled;
builder.WebSocketProvider = () => Discord.Net.Providers.WS4Net.WS4NetProvider.Instance();
var client = new DiscordSocketClient(builder);
await client.LoginAsync(TokenType.Bot, chat.DiscordBotToken);
await client.ConnectAsync();
await client.SetGameAsync("ShiftOS");
await client.SetStatusAsync(UserStatus.Online);
//Get the Discord channel for this chat.
var Chan = client.GetChannel(Convert.ToUInt64(chat.DiscordChannelID)) as ISocketMessageChannel;
//Relay the message to Discord.
await Chan.SendMessageAsync("**Hello! Multi-user domain is online.**");
client.MessageReceived += async (s) =>
{
if (chatKilled == false)
{
if (s.Channel.Id == Convert.ToUInt64(chat.DiscordChannelID))
{
if (s.Author.Id != client.CurrentUser.Id)
{
server.DispatchAll(new NetObject("chat_msgreceived", new ServerMessage
{
Name = "chat_msgreceived",
GUID = "server",
Contents = JsonConvert.SerializeObject(new ChatMessage(s.Author.Username, "discord_" + s.Channel.Name, (s as SocketUserMessage).Resolve(0), chatID))
}));
}
}
}
};
MessageReceived += (g, msg) =>
{
if (chatKilled == false)
{
//Determine if the message was sent to this channel.
if (msg.Channel == chat.ID)
{
//Get the Discord channel for this chat.
var dChan = client.GetChannel(Convert.ToUInt64(chat.DiscordChannelID)) as ISocketMessageChannel;
//Relay the message to Discord.
dChan.SendMessageAsync($"**[{msg.Username}@{msg.SystemName}]** `<mud/{msg.Channel}>` {msg.Message}");
}
//Relay it back to all MUD clients.
RelayMessage(g, msg);
}
};
Reinitialized += () =>
{
client.DisconnectAsync();
chatKilled = true;
};
}
else
{
MessageReceived += (g, msg) =>
{
if (chatKilled == false)
{
//Just relay it.
RelayMessage(g, msg);
}
};
Reinitialized += () => { chatKilled = true; };
}
}
}
internal static void RelayMessage(string guid, ChatMessage msg)
{
server.DispatchAllExcept(new Guid(guid), new NetObject("chat_msgreceived", new ServerMessage
{
Name = "chat_msgreceived",
GUID = "server",
Contents = JsonConvert.SerializeObject(msg)
}));
}
public static event Action<string, ChatMessage> MessageReceived;
public static event empty Reinitialized;
public delegate void empty();
[MudRequest("chat_getallchannels", null)]
public static void GetAllChannels(string guid, object contents)
{
server.DispatchTo(new Guid(guid), new NetObject("chat_all", new ServerMessage
{
Name = "chat_all",
GUID = "Server",
Contents = (File.Exists("chats.json") == true) ? File.ReadAllText("chats.json") : "[]"
}));
}
[MudRequest("chat_send", typeof(Dictionary<string, string>))]
public static void ReceiveMessage(string guid, object contents)
{
var msg = contents as Dictionary<string, string>;
MessageReceived?.Invoke(guid, new ChatMessage(msg["Username"], msg["SystemName"], msg["Message"], msg["Channel"]));
}
}
}

View file

@ -32,12 +32,44 @@ using NetSockets;
using Newtonsoft.Json;
using System.IO;
using static ShiftOS.Server.Program;
using ShiftOS.Engine
namespace ShiftOS.Server
{
public static class Core
{
[MudRequest("mud_forward", typeof(ServerMessage))]
public static void ForwardMessage(string guid, ServerMessage message)
{
if (message.GUID == "all")
{
Server.Program.server.DispatchAll(new NetObject("forward", new ServerMessage
{
Name = "forward",
GUID = "Server",
Contents = JsonConvert.SerializeObject(message)
}));
}
else
{
try
{
Server.Program.server.DispatchTo(new Guid(message.GUID), new NetObject("forward", new ServerMessage
{
Name = "forward",
GUID = "Server",
Contents = JsonConvert.SerializeObject(message)
}));
}
catch
{
}
}
}
[MudRequest("getguid_reply", typeof(string))]
public static void GuidBounce(string guid, object contents)
{
@ -96,10 +128,11 @@ namespace ShiftOS.Server
{
Name = "run",
GUID = "Server",
Contents = $@"{{
script:""{File.ReadAllText($"scripts/{user}/{script}.lua").Replace("\"", "\\\"")}"",
args:""{sArgs}""
}}"
Contents = JsonConvert.SerializeObject(new
{
script = File.ReadAllText($"scripts/{user}/{script}.lua"),
args = sArgs
})
}));
}
else
@ -115,7 +148,7 @@ namespace ShiftOS.Server
{
Name = "Error",
GUID = "Server",
Contents = JsonConvert.SerializeObject(new MudException("Command parse error"))
Contents = JsonConvert.SerializeObject(new MudException("<script_runner> Script not found or script error detected."))
}));
}
catch
@ -125,5 +158,102 @@ namespace ShiftOS.Server
}
}
[MudRequest("diag_log", typeof(string))]
public static void Diagnostic(string guid, string line)
{
List<string> lines = new List<string>();
if (File.Exists("diagnostics.log"))
lines = new List<string>(File.ReadAllLines("diagnostics.log"));
lines.Add(line);
File.WriteAllLines("diagnostics.log", lines.ToArray());
}
[MudRequest("getusers", typeof(string))]
public static void GetAllUsers(string guid, string contents)
{
List<string> accs = new List<string>();
if(contents == "dead")
{
foreach(var sve in Directory.GetFiles("deadsaves"))
{
if (sve.EndsWith(".save"))
{
var save = JsonConvert.DeserializeObject<Save>(File.ReadAllText(sve));
accs.Add($"{ShiftOS.Engine.SaveSytem.CurrentUser.Username}@{save.SystemName}");
}
}
}
server.DispatchTo(new Guid(guid), new NetObject("h4xx0r", new ServerMessage
{
Name = "allusers",
GUID = "server",
Contents = JsonConvert.SerializeObject(accs)
}));
}
[MudRequest("mud_save_allow_dead", typeof(Save))]
public static void SaveDead(string guid, Save sve)
{
if(File.Exists("saves/" + sve.Username + ".save"))
{
WriteEncFile("saves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve));
}
else if(File.Exists("deadsaves/" + sve.Username + ".save"))
{
File.WriteAllText("deadsaves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve));
}
}
[MudRequest("get_user_data", typeof(Dictionary<string, string>))]
public static void GetUserData(string guid, Dictionary<string, string> contents)
{
string usr = contents["user"];
string sys = contents["sysname"];
foreach(var sve in Directory.GetFiles("deadsaves"))
{
if (sve.EndsWith(".save"))
{
var saveFile = JsonConvert.DeserializeObject<Save>(File.ReadAllText(sve));
if(saveFile.Username == usr && saveFile.SystemName == sys)
{
server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage
{
Name = "user_data",
GUID = "server",
Contents = JsonConvert.SerializeObject(saveFile)
}));
return;
}
}
}
foreach (var sve in Directory.GetFiles("saves"))
{
if (sve.EndsWith(".save"))
{
var saveFile = JsonConvert.DeserializeObject<Save>(ReadEncFile(sve));
if (saveFile.Username == usr && saveFile.SystemName == sys)
{
server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage
{
Name = "user_data",
GUID = "server",
Contents = JsonConvert.SerializeObject(saveFile)
}));
return;
}
}
}
server.DispatchTo(new Guid(guid), new NetObject("n07_50_1337", new ServerMessage
{
Name = "user_data_not_found",
GUID = "server"
}));
}
}
}

View file

@ -86,7 +86,25 @@ namespace ShiftOS.Server
/// <param name="args">The command-line arguments.</param>
public static void Main(string[] args)
{
Thread.Sleep(2000);
AppDomain.CurrentDomain.UnhandledException += (o, a) =>
{
System.Diagnostics.Process.Start("ShiftOS.Server.exe");
Environment.Exit(0);
};
UserConfig.Get();
System.Timers.Timer tmr = new System.Timers.Timer(5000);
tmr.Elapsed += (o, a) =>
{
if (server.IsOnline)
{
server.DispatchAll(new NetObject("heartbeat", new ServerMessage
{
Name = "heartbeat",
GUID = "server"
}));
}
};
if (!Directory.Exists("saves"))
{
Directory.CreateDirectory("saves");
@ -106,11 +124,13 @@ namespace ShiftOS.Server
{
Console.WriteLine($"Server started on address {server.Address}, port {server.Port}.");
ServerStarted?.Invoke(server.Address.ToString());
};
tmr.Start();
};
server.OnStopped += (o, a) =>
{
Console.WriteLine("WARNING! Server stopped.");
tmr.Stop();
};
server.OnError += (o, a) =>
@ -121,8 +141,32 @@ namespace ShiftOS.Server
server.OnClientAccepted += (o, a) =>
{
Console.WriteLine("Client connected.");
server.DispatchTo(a.Guid, new NetObject("welcome", new ServerMessage { Name = "Welcome", Contents = a.Guid.ToString(), GUID = "Server" }));
};
try
{
server.DispatchTo(a.Guid, new NetObject("welcome", new ServerMessage { Name = "Welcome", Contents = a.Guid.ToString(), GUID = "Server" }));
}
catch
{
Console.WriteLine("Oh, you don't have time to finish the handshake? Fine. Get off.");
}
};
server.OnClientDisconnected += (o, a) =>
{
Console.WriteLine("Client disconnected.");
};
server.OnClientRejected += (o, a) =>
{
Console.WriteLine("FUCK. Something HORRIBLE JUST HAPPENED.");
};
AppDomain.CurrentDomain.UnhandledException += (o, a) =>
{
if(server.IsOnline == true)
server.Stop();
System.Diagnostics.Process.Start("ShiftOS.Server.exe");
};
server.OnReceived += (o, a) =>
{
@ -164,8 +208,13 @@ namespace ShiftOS.Server
Console.WriteLine("Server stopping.");
};
/*
var task = ChatBackend.StartDiscordBots();
task.Wait();
*/
RandomUserGenerator.StartThread();
while (server.IsOnline)
{
@ -254,8 +303,6 @@ namespace ShiftOS.Server
/// <param name="msg">Message.</param>
public static void Interpret(ServerMessage msg)
{
Dictionary<string, object> args = null;
try
{
Console.WriteLine($@"[{DateTime.Now}] Message received from {msg.GUID}: {msg.Name}");
@ -283,8 +330,7 @@ namespace ShiftOS.Server
try
{
object contents = null;
bool throwOnNull = false;
if (mAttrib.ExpectedType == typeof(int))
{
@ -312,7 +358,6 @@ namespace ShiftOS.Server
}
else if (mAttrib.ExpectedType == typeof(bool))
{
throwOnNull = true;
if (msg.Contents.ToLower() == "true")
{
contents = true;
@ -329,7 +374,6 @@ namespace ShiftOS.Server
}
else if (mAttrib.ExpectedType == null)
{
throwOnNull = false;
}
else if(mAttrib.ExpectedType == typeof(string))
{

View file

@ -0,0 +1,287 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
using ShiftOS.Objects;
using static ShiftOS.Objects.ShiftFS.Utils;
namespace ShiftOS.Server
{
public static class RandomUserGenerator
{
const string USERPREFIXES = "culled;purged;anon;fatal;unaccounted;netban;killed;old";
const string SYSNAMES = "unknown;error;dead;system;mud";
const string PASSCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_";
public static void StartThread()
{
var t = new Thread(() =>
{
var rnd = new Random();
while (Program.server.IsOnline)
{
if (!Directory.Exists("deadsaves"))
{
Directory.CreateDirectory("deadsaves");
}
var sve = new Save();
int passLength = 0;
int securityGrade = rnd.Next(1, 5);
switch (securityGrade)
{
default:
passLength = 4;
break;
case 2:
passLength = 6;
break;
case 3:
passLength = 10;
break;
case 4:
passLength = 15;
break;
}
string pass = "";
char lastChar = '\0';
for (int i = 0; i < passLength; i++)
{
char c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
while(c == lastChar)
{
c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
}
pass += c;
lastChar = c; //this ensures no repeated sequences.
}
sve.Password = pass;
int id_length = rnd.Next(3, 10);
string id = "";
lastChar = '\0';
for (int i = 0; i < id_length; i++)
{
char c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
while (c == lastChar)
{
c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
}
id += c;
lastChar = c; //this ensures no repeated sequences.
}
string[] names = USERPREFIXES.Split(';');
string name = names[rnd.Next(0, names.Length)];
sve.Username = $"{id}_{name}";
names = SYSNAMES.Split(';');
name = names[rnd.Next(0, names.Length)];
sve.SystemName = name;
//Codepoint generation.
int startCP = 0;
int maxAmt = 0;
switch (securityGrade)
{
default:
startCP = 1000;
maxAmt = 12500;
break;
case 2:
startCP = 25000;
maxAmt = 50000;
break;
case 3:
startCP = 75000;
maxAmt = 150000;
break;
case 4:
startCP = 500000;
maxAmt = 1500000;
break;
}
sve.Codepoints = rnd.Next(startCP, maxAmt);
//FS treasure generation.
/*
//create a ramdisk dir
var dir = new ShiftOS.Objects.ShiftFS.Directory();
//name the directory after the user
dir.Name = sve.Username;
dir.permissions = Objects.ShiftFS.Permissions.All;
//json the object and mount
string json = Newtonsoft.Json.JsonConvert.SerializeObject(dir);
//mount it to the MUD
ShiftOS.Objects.ShiftFS.Utils.Mount(json);
//get the mount id
int mountid = ShiftOS.Objects.ShiftFS.Utils.Mounts.Count - 1;
bool leakShiftnetDataRandomly = (rnd.Next(0, 10) > 5);
//create home directory
CreateDirectory($"{mountid}:/home");
//create downloads directory
CreateDirectory($"{mountid}:/home/downloads");
//if we're leaking shiftnet data...
CreateDirectory($"{mountid}:/home/documents");
//alright, let's leak some shop items.
foreach(var shop in Newtonsoft.Json.JsonConvert.DeserializeObject<Shop[]>(File.ReadAllText("shops.json")))
{
if(shop != null)
{
try
{
foreach(var item in shop.Items)
{
if(rnd.Next(0,10) > 5)
{
if (sve.Codepoints >= item.Cost)
{
//deduct item's codepoints.
sve.Codepoints -= item.Cost;
//create a new file in user's downloads folder...with the item's name and binary contents inside.
WriteAllBytes($"{mountid}:/home/downloads/{item.Name}.{GetFileExt(item.FileType)}", item.MUDFile);
}
}
}
}
catch { }
}
}
//shiftnetData<ntfsFile, sfsFile>
Dictionary<string, string> shiftnetData = new Dictionary<string, string>();
if(leakShiftnetDataRandomly == true)
{
//And maybe let's leak some shiftnet sites.
LeakDirectories($"{mountid}:/home/documents", out shiftnetData);
//Now start saving the directories.
foreach(var kv in shiftnetData)
{
if(!DirectoryExists(kv.Value))
CreateDirectory(kv.Value);
foreach(var file in Directory.GetFiles(kv.Key))
{
WriteAllBytes(kv.Value, File.ReadAllBytes(file));
}
}
}*/
//save the save file to disk.
File.WriteAllText("deadsaves/" + sve.Username + ".save", Newtonsoft.Json.JsonConvert.SerializeObject(sve, Newtonsoft.Json.Formatting.Indented));
//We don't care about the encryption algorithm because these saves can't be logged into as regular users.
/*
//Now we export the mount.
string exportedMount = ExportMount(mountid);
//And save it to disk.
File.WriteAllText("deadsaves/" + sve.Username + ".mfs", exportedMount);
*/
Thread.Sleep((60 * 60) * 1000); //approx. 1 hour.
}
});
t.IsBackground = true;
t.Start();
}
public static void LeakDirectories(string output, out Dictionary<string,string> targets)
{
var rnd = new Random();
List<string> dirs = new List<string>();
foreach(var pth in getDirectories("shiftnet"))
{
if(rnd.Next(0,10) > 5)
{
dirs.Add(pth);
}
}
targets = new Dictionary<string, string>();
foreach(var dir in dirs)
{
if (!string.IsNullOrWhiteSpace(dir))
{
string sDir = dir.Replace("\\", "/");
if (sDir.Contains("shiftnet"))
{
while (!sDir.StartsWith("shiftnet"))
{
sDir = sDir.Remove(0, 1);
}
targets.Add(dir, output + "/" + sDir);
}
}
}
}
private static List<string> getDirectories(string path)
{
List<string> paths = new List<string>();
foreach(var pth in Directory.GetDirectories(path))
{
paths.AddRange(getDirectories(pth).ToArray());
}
paths.Add(path);
return paths;
}
public static string GetFileExt(int fType)
{
switch((FileType)fType)
{
default:
return "bin";
case FileType.Executable:
return "sft";
case FileType.Filesystem:
return "mfs";
case FileType.Image:
return "pic";
case FileType.JSON:
return "json";
case FileType.Lua:
return "lua";
case FileType.Skin:
return "skn";
case FileType.TextFile:
return ".txt";
}
}
public enum FileType
{
TextFile,
Directory,
Mount,
UpOne,
Image,
Skin,
JSON,
Executable,
Lua,
Python,
Filesystem,
Unknown
}
}
}

View file

@ -1,4 +1,4 @@
/*
/*
* MIT License
*
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
@ -32,6 +32,7 @@ using System.IO;
using Newtonsoft.Json;
using NetSockets;
using static ShiftOS.Server.Program;
using System.Net;
namespace ShiftOS.Server
{
@ -43,7 +44,7 @@ namespace ShiftOS.Server
var args = contents as Dictionary<string, object>;
if (!args.ContainsKey("username"))
throw new MudException("No 'username' argument supplied.");
args["username"] = args["username"].ToString().ToLower();
foreach(var savefile in Directory.GetFiles("saves"))
{
var save = ReadSave(savefile);
@ -64,6 +65,7 @@ namespace ShiftOS.Server
var args = contents as Dictionary<string, object>;
if (args["username"] != null && args["password"] != null)
{
args["username"] = args["username"].ToString().ToLower();
foreach (var savefile in Directory.GetFiles("saves"))
{
try
@ -73,6 +75,12 @@ namespace ShiftOS.Server
if (save.Username == args["username"].ToString() && save.Password == args["password"].ToString())
{
if(save.ID == new Guid())
{
save.ID = Guid.NewGuid();
WriteEncFile(savefile, JsonConvert.SerializeObject(save));
}
Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage
{
@ -114,8 +122,9 @@ namespace ShiftOS.Server
public static void CheckUserExists(string guid, object contents)
{
var args = contents as Dictionary<string, object>;
if (args["username"] != null && args["password"] != null)
if (args["username"] != null)
{
args["username"] = args["username"].ToString().ToLower();
foreach (var savefile in Directory.GetFiles("saves"))
{
try
@ -123,7 +132,7 @@ namespace ShiftOS.Server
var save = JsonConvert.DeserializeObject<Save>(ReadEncFile(savefile));
if (save.Username == args["username"].ToString() && save.Password == args["password"].ToString())
if (save.Username == args["username"].ToString())
{
server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage
{
@ -156,12 +165,17 @@ namespace ShiftOS.Server
public static void SaveGame(string guid, object contents)
{
var sav = contents as Save;
if (string.IsNullOrWhiteSpace(sav.Username))
return;
sav.Username = sav.Username.ToLower();
WriteEncFile("saves/" + sav.Username + ".save", JsonConvert.SerializeObject(sav, Formatting.Indented));
try
{
Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage
{
Name = "mud_saved",
@ -169,13 +183,67 @@ namespace ShiftOS.Server
}));
}
catch { }
try
{
//Update the shiftos website with the user's codepoints.
if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken))
{
var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString());
wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken);
wreq.GetResponse();
}
}
catch { }
}
[MudRequest("mud_token_login", typeof(string))]
public static void TokenLogin(string guid, string token)
{
foreach (var savefile in Directory.GetFiles("saves"))
{
try
{
var save = JsonConvert.DeserializeObject<Save>(ReadEncFile(savefile));
if (save.UniteAuthToken==token)
{
if (save.ID == new Guid())
{
save.ID = Guid.NewGuid();
WriteEncFile(savefile, JsonConvert.SerializeObject(save));
}
Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage
{
Name = "mud_savefile",
GUID = "server",
Contents = JsonConvert.SerializeObject(save)
}));
return;
}
}
catch { }
}
try
{
Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage
{
Name = "mud_login_denied",
GUID = "server"
}));
}
catch { }
}
[MudRequest("delete_save", typeof(ClientSave))]
public static void DeleteSave(string guid, object contents)
{
var cSave = contents as ClientSave;
cSave.Username = cSave.Username.ToLower();
foreach(var saveFile in Directory.GetFiles("saves"))
{
try
@ -198,6 +266,7 @@ namespace ShiftOS.Server
var args = contents as Dictionary<string, object>;
if (args["username"] != null && args["amount"] != null)
{
args["username"] = args["username"].ToString().ToLower();
string userName = args["username"] as string;
long cpAmount = (long)args["amount"];
@ -230,6 +299,7 @@ namespace ShiftOS.Server
var args = contents as Dictionary<string, object>;
if (args["username"] != null && args["password"] != null && args["amount"] != null && args["yourusername"] != null)
{
args["username"] = args["username"].ToString().ToLower();
string userName = args["username"] as string;
string passw = args["password"] as string;
int cpAmount = (int)args["amount"];

View file

@ -34,26 +34,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Discord.Net.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Core.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Discord.Net.Providers.WS4Net, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Providers.WS4Net.1.0.0-rc-00595\lib\net45\Discord.Net.Providers.WS4Net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Discord.Net.Rest, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Rest.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Rest.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Discord.Net.Rpc, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.Rpc.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Rpc.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Discord.Net.WebSocket, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Discord.Net.WebSocket.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.WebSocket.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
<Private>True</Private>
@ -65,64 +45,16 @@
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nito.AsyncEx, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nito.AsyncEx.Concurrent, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Concurrent.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nito.AsyncEx.Enlightenment, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.2.3\lib\net451\RestSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.AppContext.4.1.0\lib\net46\System.AppContext.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.0.0\lib\net46\System.Console.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Globalization.Calendars, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Globalization.Calendars.4.0.1\lib\net46\System.Globalization.Calendars.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Interactive.Async.3.1.0\lib\net45\System.Interactive.Async.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.0.1\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
<Private>True</Private>
@ -168,7 +100,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ChatBackend.cs" />
<Compile Include="Core.cs" />
<Compile Include="LegionManager.cs" />
<Compile Include="MemoManager.cs" />
@ -180,6 +111,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="RandomUserGenerator.cs" />
<Compile Include="RemoteTerminal.cs" />
<Compile Include="SaveManager.cs" />
<Compile Include="ShiftnetBackend.cs" />

View file

@ -43,37 +43,49 @@ namespace ShiftOS.Server
string url = contents as string;
if (!url.StartsWith("shiftnet/"))
{
server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage
try
{
Name = "shiftnet_file",
GUID = "server",
Contents = (File.Exists("badrequest.md") == true) ? File.ReadAllText("badrequest.md") : @"# Bad request.
server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage
{
Name = "shiftnet_file",
GUID = "server",
Contents = (File.Exists("badrequest.md") == true) ? File.ReadAllText("badrequest.md") : @"# Bad request.
You have sent a bad request to the multi-user domain. Please try again."
}));
}));
}
catch { }
return;
}
if (File.Exists(url))
{
server.DispatchTo(new Guid(guid), new NetObject("download", new ServerMessage
try
{
Name = "download_meta",
GUID = "server",
Contents = JsonConvert.SerializeObject(File.ReadAllBytes(url))
}));
server.DispatchTo(new Guid(guid), new NetObject("download", new ServerMessage
{
Name = "download_meta",
GUID = "server",
Contents = JsonConvert.SerializeObject(File.ReadAllBytes(url))
}));
}
catch { }
}
else
{
server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage
try
{
Name = "shiftnet_file",
GUID = "server",
Contents = (File.Exists("notfound.md") == true) ? File.ReadAllText("notfound.md") : @"# Not found.
server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage
{
Name = "shiftnet_file",
GUID = "server",
Contents = (File.Exists("notfound.md") == true) ? File.ReadAllText("notfound.md") : @"# Not found.
The page you requested at was not found on this multi-user domain."
}));
}));
}
catch { }
}
}

View file

@ -1,4 +1,4 @@
/*
/*
* MIT License
*
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
@ -185,15 +185,18 @@ namespace ShiftOS.Server
if (File.Exists("shops.json"))
foreach (var shop in JsonConvert.DeserializeObject<List<Shop>>(File.ReadAllText("shops.json")))
{
if (shop.Owner == shopOwner)
if (shop != null)
{
server.DispatchTo(new Guid(guid), new NetObject("ruecuodaL", new ServerMessage
if (shop.Owner == shopOwner)
{
Name = "user_shop",
GUID = "server",
Contents = JsonConvert.SerializeObject(shop)
}));
return;
server.DispatchTo(new Guid(guid), new NetObject("ruecuodaL", new ServerMessage
{
Name = "user_shop",
GUID = "server",
Contents = JsonConvert.SerializeObject(shop)
}));
return;
}
}
}

View file

@ -1,38 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Discord.Net.Core" version="1.0.0-rc-00595" targetFramework="net451" />
<package id="Discord.Net.Providers.WS4Net" version="1.0.0-rc-00595" targetFramework="net461" />
<package id="Discord.Net.Rest" version="1.0.0-rc-00595" targetFramework="net451" />
<package id="Discord.Net.Rpc" version="1.0.0-rc-00595" targetFramework="net451" />
<package id="Discord.Net.WebSocket" version="1.0.0-rc-00595" targetFramework="net451" />
<package id="DynamicLua" version="1.1.2.0" targetFramework="net452" />
<package id="Microsoft.NETCore.Platforms" version="1.0.1" targetFramework="net451" />
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="net461" requireReinstallation="true" />
<package id="NETStandard.Library" version="1.6.0" targetFramework="net451" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net451" />
<package id="RestSharp" version="105.2.3" targetFramework="net451" />
<package id="System.AppContext" version="4.1.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Collections" version="4.0.11" targetFramework="net451" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net451" />
<package id="System.Collections.Immutable" version="1.3.0" targetFramework="net451" />
<package id="System.Console" version="4.0.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net451" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Diagnostics.Tools" version="4.0.1" targetFramework="net451" />
<package id="System.Diagnostics.Tracing" version="4.1.0" targetFramework="net451" />
<package id="System.Globalization" version="4.0.11" targetFramework="net451" />
<package id="System.Globalization.Calendars" version="4.0.1" targetFramework="net461" requireReinstallation="true" />
<package id="System.Interactive.Async" version="3.1.0" targetFramework="net451" />
<package id="System.IO" version="4.1.0" targetFramework="net451" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net451" />
<package id="System.IO.Compression.ZipFile" version="4.0.1" targetFramework="net461" requireReinstallation="true" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.Linq" version="4.3.0" targetFramework="net451" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net451" />
<package id="System.Net.Http" version="4.3.0" targetFramework="net451" />
<package id="System.Net.Primitives" version="4.0.11" targetFramework="net451" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" requireReinstallation="true" />
<package id="System.ObjectModel" version="4.0.12" targetFramework="net451" />
<package id="System.Reflection" version="4.3.0" targetFramework="net451" />
@ -57,6 +29,5 @@
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="net451" />
<package id="System.Threading.Timer" version="4.0.1" targetFramework="net451" />
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="net451" />
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="net451" />
<package id="WebSocket4Net" version="0.14.1" targetFramework="net451" />
</packages>

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ShiftOS.Unite")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShiftOS.Unite")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e57ff1e6-3780-4510-b7ef-64731ec81bb8")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E57FF1E6-3780-4510-B7EF-64731EC81BB8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ShiftOS.Unite</RootNamespace>
<AssemblyName>ShiftOS.Unite</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="UniteClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -7,7 +7,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" />

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ShiftOS.Updater
{
class Program
{
static void Main(string[] args)
{
if (Directory.Exists("updater-work"))
{
//Give the engine time to shutdown before invoking this app.
Thread.Sleep(5000);
foreach (var f in Directory.GetFiles("updater-work"))
{
var bytes = File.ReadAllBytes(f);
var finf = new FileInfo(f);
File.WriteAllBytes(finf.Name, bytes);
}
Directory.Delete("updater-work", true);
}
//Restart the actual game.
System.Diagnostics.Process.Start("ShiftOS.WinForms.exe");
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ShiftOS.Updater")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShiftOS.Updater")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("36bc512f-6fd4-4139-aed7-565fc8d5bcbc")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{36BC512F-6FD4-4139-AED7-565FC8D5BCBC}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ShiftOS.Updater</RootNamespace>
<AssemblyName>ShiftOS.Updater</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ShiftOS.WinForms\ShiftOS.WinForms.csproj">
<Project>{2295d2e2-3a00-4e02-b66f-b961ac329fe6}</Project>
<Name>ShiftOS.WinForms</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -55,7 +55,7 @@ namespace ShiftOS.WinForms.Applications
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.lbshiftit = new System.Windows.Forms.Label();
this.lbaboutdesc = new System.Windows.Forms.Label();
this.lbaboutdesc = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
@ -94,11 +94,11 @@ namespace ShiftOS.WinForms.Applications
this.lbaboutdesc.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lbaboutdesc.Location = new System.Drawing.Point(14, 126);
this.lbaboutdesc.Location = new System.Drawing.Point(23, 158);
this.lbaboutdesc.Multiline = true;
this.lbaboutdesc.Name = "lbaboutdesc";
this.lbaboutdesc.Size = new System.Drawing.Size(498, 328);
this.lbaboutdesc.Size = new System.Drawing.Size(492, 302);
this.lbaboutdesc.TabIndex = 3;
this.lbaboutdesc.Text = "label2";
//
// About
//
@ -121,6 +121,6 @@ namespace ShiftOS.WinForms.Applications
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lbshiftit;
private System.Windows.Forms.Label lbaboutdesc;
private System.Windows.Forms.TextBox lbaboutdesc;
}
}

View file

@ -53,18 +53,73 @@ namespace ShiftOS.WinForms.Applications
lbaboutdesc.Text = $@"ShiftOS
Copyright (c) 2015-{DateTime.Now.Year} Michael VanOverbeek and ShiftOS devs
Engine version: Milestone 3, 1.0 Beta Series (Developer mode ON)
Frontend version: 1.0 Beta 1.2
Multi-user domain version: 1.0 Rolling-Release
Music courtesy of Selulance. Listen to the Fractal Forest album here:
https://www.youtube.com/watch?v=LB5jAYDL3VU&t=913s
Engine version: Milestone 4, 1.0 Beta Series (Developer mode ON)
Frontend version: 1.0 Beta 2.5
Digital Society version: 1.0 Rolling-Release
Project: Unite version: 1.0 Beta 1.7
Special thanks to Philip Adams, the original creator of ShiftOS for helping us grow our community of amazing Shifters by featuring us on the YouTube Millionaire series and advertising us throughout various other series ran by him.
Also, thanks to Rylan Arbour, Victor Tran and the other community moderators and administrators for helping us keep the community peaceful.
Lastly, a huge special thanks to the community themselves - for testing, debugging, fixing, reporting bugs for, and enjoying our game even through its many failures, successes, revamps, etc. You guys are the reason we develop the game!";
Lastly, a huge special thanks to the community themselves - for testing, debugging, fixing, reporting bugs for, and enjoying our game even through its many failures, successes, revamps, etc. You guys are the reason we develop the game!
=== Licensing information
ShiftOS is licensed under the 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.
== Credit where credit is due
-- Development and staff team:
- Rylan Arbour (Lead community administrator)
- Victor Tran (Discord administrator)
- cjhannah (ShiftFS backend developer)
- AShifter (Project: Unite penetration tester)
- arencllc (ShiftLetters developer)
- Michael VanOverbeek (Lead developer, system administrator, the guy who wrote this text)
- fixylol, Nebble, TravisNC, Neptune (Community moderators)
- bandic00t_ (Skin Engine stresstesting)
-- System audio
- Default system event sounds (Infobox, Network Connecting, System Beeps) are from the original ShiftOS 0.0.x source code.
- Ambient music list courtesy of https://www.youtube.com/channel/UC56Qctnsu8wAyvzf4Yx6LIw (ArgoFox | Royalty Free Music)
Tracklist:
Dylan Hardy - Strangely Unaffected
Noxive - Home
Dylan Hardy and Abraham Alberto - Slow Drift
A Himitsu - Easier To Fade
Noxive - Resilience
Wanderflux - Visions
Aerocity - Cold Weather Kids
Aether - Wanderlust
Aerocity - Love Lost
Finally, special thanks to our Patreon supporters. Without you guys, our servers wouldn't be running, and you wouldn't be reading this.";
}
public string GetEngineVersion()
@ -107,7 +162,7 @@ Lastly, a huge special thanks to the community themselves - for testing, debuggi
public bool OnUnload()
{
return false;
return true;
}
public void OnUpgrade()

View file

@ -0,0 +1,136 @@
namespace ShiftOS.WinForms.Applications
{
partial class AddressBook
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddressBook));
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tvcontacts = new System.Windows.Forms.TreeView();
this.panel1 = new System.Windows.Forms.Panel();
this.txtbody = new System.Windows.Forms.Label();
this.lbtitle = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addContactToolStripMenuItem,
this.removeToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(872, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// addContactToolStripMenuItem
//
this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem";
this.addContactToolStripMenuItem.Size = new System.Drawing.Size(86, 20);
this.addContactToolStripMenuItem.Text = "Add Contact";
this.addContactToolStripMenuItem.Click += new System.EventHandler(this.addContactToolStripMenuItem_Click);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.removeToolStripMenuItem.Text = "Remove";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
//
// tvcontacts
//
this.tvcontacts.Dock = System.Windows.Forms.DockStyle.Left;
this.tvcontacts.Location = new System.Drawing.Point(0, 24);
this.tvcontacts.Name = "tvcontacts";
this.tvcontacts.Size = new System.Drawing.Size(224, 551);
this.tvcontacts.TabIndex = 1;
//
// panel1
//
this.panel1.Controls.Add(this.txtbody);
this.panel1.Controls.Add(this.lbtitle);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(224, 24);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(648, 551);
this.panel1.TabIndex = 2;
//
// txtbody
//
this.txtbody.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtbody.Location = new System.Drawing.Point(7, 54);
this.txtbody.Name = "txtbody";
this.txtbody.Size = new System.Drawing.Size(626, 481);
this.txtbody.TabIndex = 1;
this.txtbody.Text = resources.GetString("txtbody.Text");
//
// lbtitle
//
this.lbtitle.AutoSize = true;
this.lbtitle.Location = new System.Drawing.Point(7, 4);
this.lbtitle.Name = "lbtitle";
this.lbtitle.Size = new System.Drawing.Size(73, 13);
this.lbtitle.TabIndex = 0;
this.lbtitle.Tag = "header1";
this.lbtitle.Text = "Address Book";
//
// AddressBook
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Controls.Add(this.tvcontacts);
this.Controls.Add(this.menuStrip1);
this.Name = "AddressBook";
this.Size = new System.Drawing.Size(872, 575);
this.Load += new System.EventHandler(this.AddressBook_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem addContactToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
private System.Windows.Forms.TreeView tvcontacts;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label txtbody;
private System.Windows.Forms.Label lbtitle;
}
}

View file

@ -0,0 +1,179 @@
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;
using static ShiftOS.Objects.ShiftFS.Utils;
using Newtonsoft.Json;
namespace ShiftOS.WinForms.Applications
{
[WinOpen("address_book")]
[AppscapeEntry("Address Book", "Add and edit your contacts within the digital society in an easy-to-use application.", 1024, 750, null, "Office")]
[DefaultTitle("Address Book")]
[Launcher("Address Book", false, null, "Office")]
public partial class AddressBook : UserControl, IShiftOSWindow
{
public AddressBook()
{
InitializeComponent();
}
string data_dir = Paths.GetPath("data") + "/address_book";
public void OnLoad()
{
removeToolStripMenuItem.Visible = false;
if (!DirectoryExists(data_dir))
CreateDirectory(data_dir);
tvcontacts.Nodes.RemoveByKey("userdefined");
var userDefined = new TreeNode();
userDefined.Name = "userdefined";
userDefined.Text = "User-defined";
tvcontacts.Click += (o, a) =>
{
if (tvcontacts.SelectedNode == userDefined)
{
removeToolStripMenuItem.Visible = false;
}
};
foreach(var f in GetFiles(data_dir))
{
try
{
var contact = JsonConvert.DeserializeObject<Contact>(ReadAllText(f));
var node = new TreeNode();
node.Text = contact.UserName + "@" + contact.SystemName;
node.Tag = contact;
userDefined.Nodes.Add(node);
tvcontacts.Click += (o, a) =>
{
if(tvcontacts.SelectedNode == node)
{
lbtitle.Text = contact.Name;
txtbody.Text = $@"Username: {contact.UserName}
System Name: {contact.SystemName}
Description:
{contact.Description}";
removeToolStripMenuItem.Visible = true;
SelectedContact = contact;
}
};
}
catch { }
}
tvcontacts.Nodes.Add(userDefined);
userDefined.Expand();
}
public Contact SelectedContact = null;
public void OnSkinLoad()
{
}
public bool OnUnload()
{
return true;
}
public void OnUpgrade()
{
}
private void addContactToolStripMenuItem_Click(object sender, EventArgs e)
{
Infobox.PromptText("Add Contact", "What is the contact's name?", delegate(string name) {
if (name != "")
{
Infobox.PromptText("Add Contact", "What is the user's username?", delegate (string uname)
{
if (uname != "")
{
Infobox.PromptText("Add Contact", "What is the user's systemname?", delegate(string sysname)
{
if (sysname != "")
{
Infobox.PromptText("Add Contact", "How would you describe this user?", delegate (string desc)
{
if (desc != "")
{
Contact contact= new Contact();
contact.Name = name;
contact.UserName = uname;
contact.SystemName = sysname;
contact.Relationship = ContactRelationship.Acquaintance;
contact.IsStoryCharacter = false;
contact.Description = desc;
var contactJson = JsonConvert.SerializeObject(contact);
WriteAllText(data_dir + "/" + name, contactJson);
OnLoad(); // Reload to show changes
} else
{
Infobox.Show("Add Contact", "Description cannot be empty.");
}
});
} else
{
Infobox.Show("Add Contact", "System name cannot be empty.");
}
});
} else
{
Infobox.Show("Add Contact", "Username cannot be empty.");
}
});
} else
{
Infobox.Show("Add Contact", "Name cannot be empty.");
}
});
}
private void AddressBook_Load(object sender, EventArgs e)
{
}
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
{
if(SelectedContact != null)
{
string file = data_dir + "/" + SelectedContact.Name;
if (FileExists(file))
{
Infobox.PromptYesNo("Remove contact", $"Are you sure you want to remove {SelectedContact.Name} from your Address Book?", (result) =>
{
if (result == true)
{
Delete(file);
OnLoad();
}
});
}
}
}
}
public class Contact
{
public string Name { get; set; }
public string UserName { get; set; }
public string SystemName { get; set; }
public ContactRelationship Relationship { get; set; }
public bool IsStoryCharacter { get; set; }
public string Description { get; set; }
}
public enum ContactRelationship
{
Acquaintance,
Friend,
Enemy
}
}

View file

@ -117,29 +117,14 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ChatEditTemplate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ChatEditTemplate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="ChatListView" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ChatListView.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="GenericTableList" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GenericTableList.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="HtmlTemplate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\HtmlTemplate.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="LoginView" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\LoginView.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="NoUsersFound" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NoUsersFound.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="SetupView" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SetupView.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="Status" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Status.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="txtbody.Text" xml:space="preserve">
<value>The Address Book helps you keep track of all your contacts within the digital society, whether they be friends, enemies, or whatnot.
On the left, we have made a list of all your contacts. You can click on one to view full details on the contact.
To add a contact, simply click "Add Contact", and to remove one, click "Remove". Some contacts may not be removed as they are integral to the progression of your adventures within the digital society.</value>
</data>
</root>

View file

@ -38,9 +38,11 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.WinForms.Tools;
using ShiftOS.Engine;
using System.Diagnostics;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("Artpad", true, "al_artpad", "Graphics")]
[RequiresUpgrade("artpad")]
[WinOpen("artpad")]
@ -54,8 +56,11 @@ namespace ShiftOS.WinForms.Applications
{
try
{
Stopwatch sw = new Stopwatch();
sw.Start();
InitializeComponent();
sw.Stop();
Console.WriteLine("ArtPad construction timespan:" + sw.Elapsed.ToString());
}
catch (Exception ex)
{
@ -140,17 +145,7 @@ namespace ShiftOS.WinForms.Applications
private void Template_Load(object sender, EventArgs e)
{
justopened = true;
this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2;
this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2;
setuppreview();
settoolcolours();
loadcolors();
AddFonts();
setuptoolbox();
determinevisiblepalettes();
tmrsetupui.Start();
//Moved to the engine "OnLoad" method.
}
@ -170,55 +165,24 @@ namespace ShiftOS.WinForms.Applications
needtosave = false;
}
//PHILCODE: I just reduced this function's amount of Windows Forms calls by 66%.
public void setuptoolbox()
{
btnpixelplacer.Hide();
btnpencil.Hide();
btnfloodfill.Hide();
btnoval.Hide();
btnsquare.Hide();
btnlinetool.Hide();
btnpaintbrush.Hide();
btntexttool.Hide();
btneracer.Hide();
btnnew.Hide();
btnopen.Hide();
btnsave.Hide();
btnundo.Hide();
btnredo.Hide();
btnpixelplacermovementmode.Hide();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_pixel_placer") == true)
btnpixelplacer.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_pencil") == true)
btnpencil.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_fill_tool") == true)
btnfloodfill.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_oval_tool") == true)
btnoval.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_rectangle_tool") == true)
btnsquare.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_line_tool") == true)
btnlinetool.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_paintbrush") == true)
btnpaintbrush.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_text_tool") == true)
btntexttool.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_eraser") == true)
btneracer.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_new") == true)
btnnew.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_load") == true)
btnopen.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_save") == true)
btnsave.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_undo") == true)
btnundo.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_redo") == true)
btnredo.Show();
if (ShiftoriumFrontend.UpgradeInstalled("artpad_pp_movement_mode") == true)
btnpixelplacermovementmode.Show();
btnpixelplacer.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pixel_placer") == true);
btnpencil.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pencil") == true);
btnfloodfill.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_fill_tool") == true);
btnoval.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_oval_tool") == true);
btnsquare.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_rectangle_tool") == true);
btnlinetool.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_line_tool") == true);
btnpaintbrush.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_paintbrush") == true);
btntexttool.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_text_tool") == true);
btneracer.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_eraser") == true);
btnnew.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_new") == true);
btnopen.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_load") == true);
btnsave.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_save") == true);
btnundo.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_undo") == true);
btnredo.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_redo") == true);
btnpixelplacermovementmode.Visible = (ShiftoriumFrontend.UpgradeInstalled("artpad_pp_movement_mode") == true);
}
private void AddFonts()
@ -687,290 +651,6 @@ namespace ShiftOS.WinForms.Applications
}
}
//<unused>
public void loadcolors()
{
/*bool allwhite = true;
for (int i = 0; i <= 127; i++)
{
if (ShiftOSDesktop.artpad_colour_palettes(i) == null)
{
}
else {
allwhite = false;
}
}
if (allwhite == true)
{
for (i = 0; i <= 127; i++)
{
ShiftOSDesktop.artpad_colour_palettes(i) = Color.Black;
}
}
colourpalette1.BackColor = ShiftOSDesktop.artpad_colour_palettes(0);
colourpalette2.BackColor = ShiftOSDesktop.artpad_colour_palettes(1);
colourpalette3.BackColor = ShiftOSDesktop.artpad_colour_palettes(2);
colourpalette4.BackColor = ShiftOSDesktop.artpad_colour_palettes(3);
colourpalette5.BackColor = ShiftOSDesktop.artpad_colour_palettes(4);
colourpalette6.BackColor = ShiftOSDesktop.artpad_colour_palettes(5);
colourpalette7.BackColor = ShiftOSDesktop.artpad_colour_palettes(6);
colourpalette8.BackColor = ShiftOSDesktop.artpad_colour_palettes(7);
colourpalette9.BackColor = ShiftOSDesktop.artpad_colour_palettes(8);
colourpalette10.BackColor = ShiftOSDesktop.artpad_colour_palettes(9);
colourpalette11.BackColor = ShiftOSDesktop.artpad_colour_palettes(10);
colourpalette12.BackColor = ShiftOSDesktop.artpad_colour_palettes(11);
colourpalette13.BackColor = ShiftOSDesktop.artpad_colour_palettes(12);
colourpalette14.BackColor = ShiftOSDesktop.artpad_colour_palettes(13);
colourpalette15.BackColor = ShiftOSDesktop.artpad_colour_palettes(14);
colourpalette16.BackColor = ShiftOSDesktop.artpad_colour_palettes(15);
colourpalette17.BackColor = ShiftOSDesktop.artpad_colour_palettes(16);
colourpalette18.BackColor = ShiftOSDesktop.artpad_colour_palettes(17);
colourpalette19.BackColor = ShiftOSDesktop.artpad_colour_palettes(18);
colourpalette20.BackColor = ShiftOSDesktop.artpad_colour_palettes(19);
colourpalette21.BackColor = ShiftOSDesktop.artpad_colour_palettes(20);
colourpalette22.BackColor = ShiftOSDesktop.artpad_colour_palettes(21);
colourpalette23.BackColor = ShiftOSDesktop.artpad_colour_palettes(22);
colourpalette24.BackColor = ShiftOSDesktop.artpad_colour_palettes(23);
colourpalette25.BackColor = ShiftOSDesktop.artpad_colour_palettes(24);
colourpalette26.BackColor = ShiftOSDesktop.artpad_colour_palettes(25);
colourpalette27.BackColor = ShiftOSDesktop.artpad_colour_palettes(26);
colourpalette28.BackColor = ShiftOSDesktop.artpad_colour_palettes(27);
colourpalette29.BackColor = ShiftOSDesktop.artpad_colour_palettes(28);
colourpalette30.BackColor = ShiftOSDesktop.artpad_colour_palettes(29);
colourpalette31.BackColor = ShiftOSDesktop.artpad_colour_palettes(30);
colourpalette32.BackColor = ShiftOSDesktop.artpad_colour_palettes(31);
colourpalette33.BackColor = ShiftOSDesktop.artpad_colour_palettes(32);
colourpalette34.BackColor = ShiftOSDesktop.artpad_colour_palettes(33);
colourpalette35.BackColor = ShiftOSDesktop.artpad_colour_palettes(34);
colourpalette36.BackColor = ShiftOSDesktop.artpad_colour_palettes(35);
colourpalette37.BackColor = ShiftOSDesktop.artpad_colour_palettes(36);
colourpalette38.BackColor = ShiftOSDesktop.artpad_colour_palettes(37);
colourpalette39.BackColor = ShiftOSDesktop.artpad_colour_palettes(38);
colourpalette40.BackColor = ShiftOSDesktop.artpad_colour_palettes(39);
colourpalette41.BackColor = ShiftOSDesktop.artpad_colour_palettes(40);
colourpalette42.BackColor = ShiftOSDesktop.artpad_colour_palettes(41);
colourpalette43.BackColor = ShiftOSDesktop.artpad_colour_palettes(42);
colourpalette44.BackColor = ShiftOSDesktop.artpad_colour_palettes(43);
colourpalette45.BackColor = ShiftOSDesktop.artpad_colour_palettes(44);
colourpalette46.BackColor = ShiftOSDesktop.artpad_colour_palettes(45);
colourpalette47.BackColor = ShiftOSDesktop.artpad_colour_palettes(46);
colourpalette48.BackColor = ShiftOSDesktop.artpad_colour_palettes(47);
colourpalette49.BackColor = ShiftOSDesktop.artpad_colour_palettes(48);
colourpalette50.BackColor = ShiftOSDesktop.artpad_colour_palettes(49);
colourpalette51.BackColor = ShiftOSDesktop.artpad_colour_palettes(50);
colourpalette52.BackColor = ShiftOSDesktop.artpad_colour_palettes(51);
colourpalette53.BackColor = ShiftOSDesktop.artpad_colour_palettes(52);
colourpalette54.BackColor = ShiftOSDesktop.artpad_colour_palettes(53);
colourpalette55.BackColor = ShiftOSDesktop.artpad_colour_palettes(54);
colourpalette56.BackColor = ShiftOSDesktop.artpad_colour_palettes(55);
colourpalette57.BackColor = ShiftOSDesktop.artpad_colour_palettes(56);
colourpalette58.BackColor = ShiftOSDesktop.artpad_colour_palettes(57);
colourpalette59.BackColor = ShiftOSDesktop.artpad_colour_palettes(58);
colourpalette60.BackColor = ShiftOSDesktop.artpad_colour_palettes(59);
colourpalette61.BackColor = ShiftOSDesktop.artpad_colour_palettes(60);
colourpalette62.BackColor = ShiftOSDesktop.artpad_colour_palettes(61);
colourpalette63.BackColor = ShiftOSDesktop.artpad_colour_palettes(62);
colourpalette64.BackColor = ShiftOSDesktop.artpad_colour_palettes(63);
colourpalette65.BackColor = ShiftOSDesktop.artpad_colour_palettes(64);
colourpalette66.BackColor = ShiftOSDesktop.artpad_colour_palettes(65);
colourpalette67.BackColor = ShiftOSDesktop.artpad_colour_palettes(66);
colourpalette68.BackColor = ShiftOSDesktop.artpad_colour_palettes(67);
colourpalette69.BackColor = ShiftOSDesktop.artpad_colour_palettes(68);
colourpalette70.BackColor = ShiftOSDesktop.artpad_colour_palettes(69);
colourpalette71.BackColor = ShiftOSDesktop.artpad_colour_palettes(70);
colourpalette72.BackColor = ShiftOSDesktop.artpad_colour_palettes(71);
colourpalette73.BackColor = ShiftOSDesktop.artpad_colour_palettes(72);
colourpalette74.BackColor = ShiftOSDesktop.artpad_colour_palettes(73);
colourpalette75.BackColor = ShiftOSDesktop.artpad_colour_palettes(74);
colourpalette76.BackColor = ShiftOSDesktop.artpad_colour_palettes(75);
colourpalette77.BackColor = ShiftOSDesktop.artpad_colour_palettes(76);
colourpalette78.BackColor = ShiftOSDesktop.artpad_colour_palettes(77);
colourpalette79.BackColor = ShiftOSDesktop.artpad_colour_palettes(78);
colourpalette80.BackColor = ShiftOSDesktop.artpad_colour_palettes(79);
colourpalette81.BackColor = ShiftOSDesktop.artpad_colour_palettes(80);
colourpalette82.BackColor = ShiftOSDesktop.artpad_colour_palettes(81);
colourpalette83.BackColor = ShiftOSDesktop.artpad_colour_palettes(82);
colourpalette84.BackColor = ShiftOSDesktop.artpad_colour_palettes(83);
colourpalette85.BackColor = ShiftOSDesktop.artpad_colour_palettes(84);
colourpalette86.BackColor = ShiftOSDesktop.artpad_colour_palettes(85);
colourpalette87.BackColor = ShiftOSDesktop.artpad_colour_palettes(86);
colourpalette88.BackColor = ShiftOSDesktop.artpad_colour_palettes(87);
colourpalette89.BackColor = ShiftOSDesktop.artpad_colour_palettes(88);
colourpalette90.BackColor = ShiftOSDesktop.artpad_colour_palettes(89);
colourpalette91.BackColor = ShiftOSDesktop.artpad_colour_palettes(90);
colourpalette92.BackColor = ShiftOSDesktop.artpad_colour_palettes(91);
colourpalette93.BackColor = ShiftOSDesktop.artpad_colour_palettes(92);
colourpalette94.BackColor = ShiftOSDesktop.artpad_colour_palettes(93);
colourpalette95.BackColor = ShiftOSDesktop.artpad_colour_palettes(94);
colourpalette96.BackColor = ShiftOSDesktop.artpad_colour_palettes(95);
colourpalette97.BackColor = ShiftOSDesktop.artpad_colour_palettes(96);
colourpalette98.BackColor = ShiftOSDesktop.artpad_colour_palettes(97);
colourpalette99.BackColor = ShiftOSDesktop.artpad_colour_palettes(98);
colourpalette100.BackColor = ShiftOSDesktop.artpad_colour_palettes(99);
colourpalette101.BackColor = ShiftOSDesktop.artpad_colour_palettes(100);
colourpalette102.BackColor = ShiftOSDesktop.artpad_colour_palettes(101);
colourpalette103.BackColor = ShiftOSDesktop.artpad_colour_palettes(102);
colourpalette104.BackColor = ShiftOSDesktop.artpad_colour_palettes(103);
colourpalette105.BackColor = ShiftOSDesktop.artpad_colour_palettes(104);
colourpalette106.BackColor = ShiftOSDesktop.artpad_colour_palettes(105);
colourpalette107.BackColor = ShiftOSDesktop.artpad_colour_palettes(106);
colourpalette108.BackColor = ShiftOSDesktop.artpad_colour_palettes(107);
colourpalette109.BackColor = ShiftOSDesktop.artpad_colour_palettes(108);
colourpalette110.BackColor = ShiftOSDesktop.artpad_colour_palettes(109);
colourpalette111.BackColor = ShiftOSDesktop.artpad_colour_palettes(110);
colourpalette112.BackColor = ShiftOSDesktop.artpad_colour_palettes(111);
colourpalette113.BackColor = ShiftOSDesktop.artpad_colour_palettes(112);
colourpalette114.BackColor = ShiftOSDesktop.artpad_colour_palettes(113);
colourpalette115.BackColor = ShiftOSDesktop.artpad_colour_palettes(114);
colourpalette116.BackColor = ShiftOSDesktop.artpad_colour_palettes(115);
colourpalette117.BackColor = ShiftOSDesktop.artpad_colour_palettes(116);
colourpalette118.BackColor = ShiftOSDesktop.artpad_colour_palettes(117);
colourpalette119.BackColor = ShiftOSDesktop.artpad_colour_palettes(118);
colourpalette120.BackColor = ShiftOSDesktop.artpad_colour_palettes(119);
colourpalette121.BackColor = ShiftOSDesktop.artpad_colour_palettes(120);
colourpalette122.BackColor = ShiftOSDesktop.artpad_colour_palettes(121);
colourpalette123.BackColor = ShiftOSDesktop.artpad_colour_palettes(122);
colourpalette124.BackColor = ShiftOSDesktop.artpad_colour_palettes(123);
colourpalette125.BackColor = ShiftOSDesktop.artpad_colour_palettes(124);
colourpalette126.BackColor = ShiftOSDesktop.artpad_colour_palettes(125);
colourpalette127.BackColor = ShiftOSDesktop.artpad_colour_palettes(126);
colourpalette128.BackColor = ShiftOSDesktop.artpad_colour_palettes(127);
*/
}
public void savecolors()
{/*
ShiftOSDesktop.artpad_colour_palettes(0) = colourpalette1.BackColor;
ShiftOSDesktop.artpad_colour_palettes(1) = colourpalette2.BackColor;
ShiftOSDesktop.artpad_colour_palettes(2) = colourpalette3.BackColor;
ShiftOSDesktop.artpad_colour_palettes(3) = colourpalette4.BackColor;
ShiftOSDesktop.artpad_colour_palettes(4) = colourpalette5.BackColor;
ShiftOSDesktop.artpad_colour_palettes(5) = colourpalette6.BackColor;
ShiftOSDesktop.artpad_colour_palettes(6) = colourpalette7.BackColor;
ShiftOSDesktop.artpad_colour_palettes(7) = colourpalette8.BackColor;
ShiftOSDesktop.artpad_colour_palettes(8) = colourpalette9.BackColor;
ShiftOSDesktop.artpad_colour_palettes(9) = colourpalette10.BackColor;
ShiftOSDesktop.artpad_colour_palettes(10) = colourpalette11.BackColor;
ShiftOSDesktop.artpad_colour_palettes(11) = colourpalette12.BackColor;
ShiftOSDesktop.artpad_colour_palettes(12) = colourpalette13.BackColor;
ShiftOSDesktop.artpad_colour_palettes(13) = colourpalette14.BackColor;
ShiftOSDesktop.artpad_colour_palettes(14) = colourpalette15.BackColor;
ShiftOSDesktop.artpad_colour_palettes(15) = colourpalette16.BackColor;
ShiftOSDesktop.artpad_colour_palettes(16) = colourpalette17.BackColor;
ShiftOSDesktop.artpad_colour_palettes(17) = colourpalette18.BackColor;
ShiftOSDesktop.artpad_colour_palettes(18) = colourpalette19.BackColor;
ShiftOSDesktop.artpad_colour_palettes(19) = colourpalette20.BackColor;
ShiftOSDesktop.artpad_colour_palettes(20) = colourpalette21.BackColor;
ShiftOSDesktop.artpad_colour_palettes(21) = colourpalette22.BackColor;
ShiftOSDesktop.artpad_colour_palettes(22) = colourpalette23.BackColor;
ShiftOSDesktop.artpad_colour_palettes(23) = colourpalette24.BackColor;
ShiftOSDesktop.artpad_colour_palettes(24) = colourpalette25.BackColor;
ShiftOSDesktop.artpad_colour_palettes(25) = colourpalette26.BackColor;
ShiftOSDesktop.artpad_colour_palettes(26) = colourpalette27.BackColor;
ShiftOSDesktop.artpad_colour_palettes(27) = colourpalette28.BackColor;
ShiftOSDesktop.artpad_colour_palettes(28) = colourpalette29.BackColor;
ShiftOSDesktop.artpad_colour_palettes(29) = colourpalette30.BackColor;
ShiftOSDesktop.artpad_colour_palettes(30) = colourpalette31.BackColor;
ShiftOSDesktop.artpad_colour_palettes(31) = colourpalette32.BackColor;
ShiftOSDesktop.artpad_colour_palettes(32) = colourpalette33.BackColor;
ShiftOSDesktop.artpad_colour_palettes(33) = colourpalette34.BackColor;
ShiftOSDesktop.artpad_colour_palettes(34) = colourpalette35.BackColor;
ShiftOSDesktop.artpad_colour_palettes(35) = colourpalette36.BackColor;
ShiftOSDesktop.artpad_colour_palettes(36) = colourpalette37.BackColor;
ShiftOSDesktop.artpad_colour_palettes(37) = colourpalette38.BackColor;
ShiftOSDesktop.artpad_colour_palettes(38) = colourpalette39.BackColor;
ShiftOSDesktop.artpad_colour_palettes(39) = colourpalette40.BackColor;
ShiftOSDesktop.artpad_colour_palettes(40) = colourpalette41.BackColor;
ShiftOSDesktop.artpad_colour_palettes(41) = colourpalette42.BackColor;
ShiftOSDesktop.artpad_colour_palettes(42) = colourpalette43.BackColor;
ShiftOSDesktop.artpad_colour_palettes(43) = colourpalette44.BackColor;
ShiftOSDesktop.artpad_colour_palettes(44) = colourpalette45.BackColor;
ShiftOSDesktop.artpad_colour_palettes(45) = colourpalette46.BackColor;
ShiftOSDesktop.artpad_colour_palettes(46) = colourpalette47.BackColor;
ShiftOSDesktop.artpad_colour_palettes(47) = colourpalette48.BackColor;
ShiftOSDesktop.artpad_colour_palettes(48) = colourpalette49.BackColor;
ShiftOSDesktop.artpad_colour_palettes(49) = colourpalette50.BackColor;
ShiftOSDesktop.artpad_colour_palettes(50) = colourpalette51.BackColor;
ShiftOSDesktop.artpad_colour_palettes(51) = colourpalette52.BackColor;
ShiftOSDesktop.artpad_colour_palettes(52) = colourpalette53.BackColor;
ShiftOSDesktop.artpad_colour_palettes(53) = colourpalette54.BackColor;
ShiftOSDesktop.artpad_colour_palettes(54) = colourpalette55.BackColor;
ShiftOSDesktop.artpad_colour_palettes(55) = colourpalette56.BackColor;
ShiftOSDesktop.artpad_colour_palettes(56) = colourpalette57.BackColor;
ShiftOSDesktop.artpad_colour_palettes(57) = colourpalette58.BackColor;
ShiftOSDesktop.artpad_colour_palettes(58) = colourpalette59.BackColor;
ShiftOSDesktop.artpad_colour_palettes(59) = colourpalette60.BackColor;
ShiftOSDesktop.artpad_colour_palettes(60) = colourpalette61.BackColor;
ShiftOSDesktop.artpad_colour_palettes(61) = colourpalette62.BackColor;
ShiftOSDesktop.artpad_colour_palettes(62) = colourpalette63.BackColor;
ShiftOSDesktop.artpad_colour_palettes(63) = colourpalette64.BackColor;
ShiftOSDesktop.artpad_colour_palettes(64) = colourpalette65.BackColor;
ShiftOSDesktop.artpad_colour_palettes(65) = colourpalette66.BackColor;
ShiftOSDesktop.artpad_colour_palettes(66) = colourpalette67.BackColor;
ShiftOSDesktop.artpad_colour_palettes(67) = colourpalette68.BackColor;
ShiftOSDesktop.artpad_colour_palettes(68) = colourpalette69.BackColor;
ShiftOSDesktop.artpad_colour_palettes(69) = colourpalette70.BackColor;
ShiftOSDesktop.artpad_colour_palettes(70) = colourpalette71.BackColor;
ShiftOSDesktop.artpad_colour_palettes(71) = colourpalette72.BackColor;
ShiftOSDesktop.artpad_colour_palettes(72) = colourpalette73.BackColor;
ShiftOSDesktop.artpad_colour_palettes(73) = colourpalette74.BackColor;
ShiftOSDesktop.artpad_colour_palettes(74) = colourpalette75.BackColor;
ShiftOSDesktop.artpad_colour_palettes(75) = colourpalette76.BackColor;
ShiftOSDesktop.artpad_colour_palettes(76) = colourpalette77.BackColor;
ShiftOSDesktop.artpad_colour_palettes(77) = colourpalette78.BackColor;
ShiftOSDesktop.artpad_colour_palettes(78) = colourpalette79.BackColor;
ShiftOSDesktop.artpad_colour_palettes(79) = colourpalette80.BackColor;
ShiftOSDesktop.artpad_colour_palettes(80) = colourpalette81.BackColor;
ShiftOSDesktop.artpad_colour_palettes(81) = colourpalette82.BackColor;
ShiftOSDesktop.artpad_colour_palettes(82) = colourpalette83.BackColor;
ShiftOSDesktop.artpad_colour_palettes(83) = colourpalette84.BackColor;
ShiftOSDesktop.artpad_colour_palettes(84) = colourpalette85.BackColor;
ShiftOSDesktop.artpad_colour_palettes(85) = colourpalette86.BackColor;
ShiftOSDesktop.artpad_colour_palettes(86) = colourpalette87.BackColor;
ShiftOSDesktop.artpad_colour_palettes(87) = colourpalette88.BackColor;
ShiftOSDesktop.artpad_colour_palettes(88) = colourpalette89.BackColor;
ShiftOSDesktop.artpad_colour_palettes(89) = colourpalette90.BackColor;
ShiftOSDesktop.artpad_colour_palettes(90) = colourpalette91.BackColor;
ShiftOSDesktop.artpad_colour_palettes(91) = colourpalette92.BackColor;
ShiftOSDesktop.artpad_colour_palettes(92) = colourpalette93.BackColor;
ShiftOSDesktop.artpad_colour_palettes(93) = colourpalette94.BackColor;
ShiftOSDesktop.artpad_colour_palettes(94) = colourpalette95.BackColor;
ShiftOSDesktop.artpad_colour_palettes(95) = colourpalette96.BackColor;
ShiftOSDesktop.artpad_colour_palettes(96) = colourpalette97.BackColor;
ShiftOSDesktop.artpad_colour_palettes(97) = colourpalette98.BackColor;
ShiftOSDesktop.artpad_colour_palettes(98) = colourpalette99.BackColor;
ShiftOSDesktop.artpad_colour_palettes(99) = colourpalette100.BackColor;
ShiftOSDesktop.artpad_colour_palettes(100) = colourpalette101.BackColor;
ShiftOSDesktop.artpad_colour_palettes(101) = colourpalette102.BackColor;
ShiftOSDesktop.artpad_colour_palettes(102) = colourpalette103.BackColor;
ShiftOSDesktop.artpad_colour_palettes(103) = colourpalette104.BackColor;
ShiftOSDesktop.artpad_colour_palettes(104) = colourpalette105.BackColor;
ShiftOSDesktop.artpad_colour_palettes(105) = colourpalette106.BackColor;
ShiftOSDesktop.artpad_colour_palettes(106) = colourpalette107.BackColor;
ShiftOSDesktop.artpad_colour_palettes(107) = colourpalette108.BackColor;
ShiftOSDesktop.artpad_colour_palettes(108) = colourpalette109.BackColor;
ShiftOSDesktop.artpad_colour_palettes(109) = colourpalette110.BackColor;
ShiftOSDesktop.artpad_colour_palettes(110) = colourpalette111.BackColor;
ShiftOSDesktop.artpad_colour_palettes(111) = colourpalette112.BackColor;
ShiftOSDesktop.artpad_colour_palettes(112) = colourpalette113.BackColor;
ShiftOSDesktop.artpad_colour_palettes(113) = colourpalette114.BackColor;
ShiftOSDesktop.artpad_colour_palettes(114) = colourpalette115.BackColor;
ShiftOSDesktop.artpad_colour_palettes(115) = colourpalette116.BackColor;
ShiftOSDesktop.artpad_colour_palettes(116) = colourpalette117.BackColor;
ShiftOSDesktop.artpad_colour_palettes(117) = colourpalette118.BackColor;
ShiftOSDesktop.artpad_colour_palettes(118) = colourpalette119.BackColor;
ShiftOSDesktop.artpad_colour_palettes(119) = colourpalette120.BackColor;
ShiftOSDesktop.artpad_colour_palettes(120) = colourpalette121.BackColor;
ShiftOSDesktop.artpad_colour_palettes(121) = colourpalette122.BackColor;
ShiftOSDesktop.artpad_colour_palettes(122) = colourpalette123.BackColor;
ShiftOSDesktop.artpad_colour_palettes(123) = colourpalette124.BackColor;
ShiftOSDesktop.artpad_colour_palettes(124) = colourpalette125.BackColor;
ShiftOSDesktop.artpad_colour_palettes(125) = colourpalette126.BackColor;
ShiftOSDesktop.artpad_colour_palettes(126) = colourpalette127.BackColor;
ShiftOSDesktop.artpad_colour_palettes(127) = colourpalette128.BackColor;
*/
}
//</unused>
public void settoolcolours()
{
@ -1858,6 +1538,12 @@ namespace ShiftOS.WinForms.Applications
ctrl.Tag = "keepbg";
ctrl.BackColor = Color.Black;
}
setuppreview();
settoolcolours();
AddFonts();
setuptoolbox();
determinevisiblepalettes();
}
public void OnSkinLoad()

View file

@ -52,10 +52,193 @@ namespace ShiftOS.WinForms.Applications
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AudioPlayer));
this.wpaudio = new AxWMPLib.AxWindowsMediaPlayer();
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.lbtracks = new System.Windows.Forms.ListBox();
this.flcontrols = new System.Windows.Forms.FlowLayoutPanel();
this.btnplay = new System.Windows.Forms.Button();
this.pgplaytime = new ShiftOS.WinForms.Controls.ShiftedProgressBar();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.addSongToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shuffleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.loopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.wpaudio)).BeginInit();
this.toolStripContainer1.ContentPanel.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.toolStripContainer1.SuspendLayout();
this.flcontrols.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// wpaudio
//
this.wpaudio.Dock = System.Windows.Forms.DockStyle.Fill;
this.wpaudio.Enabled = true;
this.wpaudio.Location = new System.Drawing.Point(0, 0);
this.wpaudio.Name = "wpaudio";
this.wpaudio.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wpaudio.OcxState")));
this.wpaudio.Size = new System.Drawing.Size(798, 471);
this.wpaudio.TabIndex = 0;
this.wpaudio.Visible = false;
//
// toolStripContainer1
//
//
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Controls.Add(this.lbtracks);
this.toolStripContainer1.ContentPanel.Controls.Add(this.flcontrols);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(798, 447);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.LeftToolStripPanelVisible = false;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer1.Name = "toolStripContainer1";
this.toolStripContainer1.RightToolStripPanelVisible = false;
this.toolStripContainer1.Size = new System.Drawing.Size(798, 471);
this.toolStripContainer1.TabIndex = 1;
this.toolStripContainer1.Text = "toolStripContainer1";
//
// toolStripContainer1.TopToolStripPanel
//
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1);
//
// lbtracks
//
this.lbtracks.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbtracks.FormattingEnabled = true;
this.lbtracks.Location = new System.Drawing.Point(0, 0);
this.lbtracks.Name = "lbtracks";
this.lbtracks.Size = new System.Drawing.Size(798, 418);
this.lbtracks.TabIndex = 1;
this.lbtracks.SelectedIndexChanged += new System.EventHandler(this.lbtracks_SelectedIndexChanged);
//
// flcontrols
//
this.flcontrols.AutoSize = true;
this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flcontrols.Controls.Add(this.btnplay);
this.flcontrols.Controls.Add(this.pgplaytime);
this.flcontrols.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flcontrols.Location = new System.Drawing.Point(0, 418);
this.flcontrols.Name = "flcontrols";
this.flcontrols.Size = new System.Drawing.Size(798, 29);
this.flcontrols.TabIndex = 0;
//
// btnplay
//
this.btnplay.AutoSize = true;
this.btnplay.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnplay.Location = new System.Drawing.Point(3, 3);
this.btnplay.Name = "btnplay";
this.btnplay.Size = new System.Drawing.Size(37, 23);
this.btnplay.TabIndex = 0;
this.btnplay.Text = "Play";
this.btnplay.UseVisualStyleBackColor = true;
this.btnplay.Click += new System.EventHandler(this.btnplay_Click);
//
// pgplaytime
//
this.pgplaytime.Location = new System.Drawing.Point(46, 3);
this.pgplaytime.Maximum = 100;
this.pgplaytime.Name = "pgplaytime";
this.pgplaytime.Size = new System.Drawing.Size(749, 23);
this.pgplaytime.TabIndex = 1;
this.pgplaytime.Tag = "keepbg";
this.pgplaytime.Text = "shiftedProgressBar1";
this.pgplaytime.Value = 0;
this.pgplaytime.MouseDown += new System.Windows.Forms.MouseEventHandler(this.startScrub);
this.pgplaytime.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseMove);
this.pgplaytime.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseUp);
//
// menuStrip1
//
this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addSongToolStripMenuItem,
this.clearToolStripMenuItem,
this.shuffleToolStripMenuItem,
this.removeToolStripMenuItem,
this.loopToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(798, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// addSongToolStripMenuItem
//
this.addSongToolStripMenuItem.Name = "addSongToolStripMenuItem";
this.addSongToolStripMenuItem.Size = new System.Drawing.Size(71, 20);
this.addSongToolStripMenuItem.Text = "Add Song";
this.addSongToolStripMenuItem.Click += new System.EventHandler(this.addSongToolStripMenuItem_Click);
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
this.clearToolStripMenuItem.Text = "Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
//
// shuffleToolStripMenuItem
//
this.shuffleToolStripMenuItem.Name = "shuffleToolStripMenuItem";
this.shuffleToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
this.shuffleToolStripMenuItem.Text = "Shuffle";
this.shuffleToolStripMenuItem.Click += new System.EventHandler(this.shuffleToolStripMenuItem_Click);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.removeToolStripMenuItem.Text = "Remove";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
//
// loopToolStripMenuItem
//
this.loopToolStripMenuItem.CheckOnClick = true;
this.loopToolStripMenuItem.Name = "loopToolStripMenuItem";
this.loopToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
this.loopToolStripMenuItem.Text = "Loop";
//
// AudioPlayer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.toolStripContainer1);
this.Controls.Add(this.wpaudio);
this.Name = "AudioPlayer";
this.Size = new System.Drawing.Size(798, 471);
((System.ComponentModel.ISupportInitialize)(this.wpaudio)).EndInit();
this.toolStripContainer1.ContentPanel.ResumeLayout(false);
this.toolStripContainer1.ContentPanel.PerformLayout();
this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false);
this.toolStripContainer1.TopToolStripPanel.PerformLayout();
this.toolStripContainer1.ResumeLayout(false);
this.toolStripContainer1.PerformLayout();
this.flcontrols.ResumeLayout(false);
this.flcontrols.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private AxWMPLib.AxWindowsMediaPlayer wpaudio;
private System.Windows.Forms.ToolStripContainer toolStripContainer1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem addSongToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem shuffleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
private System.Windows.Forms.ListBox lbtracks;
private System.Windows.Forms.FlowLayoutPanel flcontrols;
private System.Windows.Forms.Button btnplay;
private Controls.ShiftedProgressBar pgplaytime;
private System.Windows.Forms.ToolStripMenuItem loopToolStripMenuItem;
}
}

View file

@ -32,9 +32,15 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
using NAudio;
using System.Threading;
namespace ShiftOS.WinForms.Applications
{
[AppscapeEntry("Audio Player", "Play music and other sounds on your computer.", 3047, 1000, "file_skimmer", "Entertainment")]
[Launcher("Audio Player", false, null, "Entertainment")]
[WinOpen("audio_player")]
[DefaultTitle("Audio Player")]
public partial class AudioPlayer : UserControl, IShiftOSWindow
{
public AudioPlayer()
@ -42,18 +48,24 @@ namespace ShiftOS.WinForms.Applications
InitializeComponent();
}
NAudio.Wave.WaveOut o = null;
public void OnLoad()
{
wpaudio.Hide();
}
public void OnSkinLoad()
{
pgplaytime.Width = flcontrols.Width - btnplay.Width - 25;
}
public bool OnUnload()
{
o?.Dispose();
mp3?.Dispose();
memstream?.Dispose();
return true;
}
@ -61,5 +73,170 @@ namespace ShiftOS.WinForms.Applications
{
}
private void addSongToolStripMenuItem_Click(object sender, EventArgs e)
{
FileSkimmerBackend.GetFile(new[] { ".mp3", ".wav" }, FileOpenerStyle.Open, (path) =>
{
if (!lbtracks.Items.Contains(path))
lbtracks.Items.Add(path);
else
Infobox.Show("Song already added!", "That song is already added to the Audio Player playlist.");
});
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
{
lbtracks.Items.Clear();
}
private void shuffleToolStripMenuItem_Click(object sender, EventArgs e)
{
var lst = new object[lbtracks.Items.Count];
lbtracks.Items.CopyTo(lst, 0);
var shuffle = new List<object>(lst);
shuffle.Shuffle();
lbtracks.Items.Clear();
lbtracks.Items.AddRange(shuffle.ToArray());
}
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
{
lbtracks.Items.RemoveAt(lbtracks.SelectedIndex);
}
private void btnplay_Click(object sender, EventArgs e)
{
if(o == null)
{
if (lbtracks.Items.Count > 0)
{
Play(lbtracks.Items[0].ToString());
btnplay.Text = "Pause";
}
else
Infobox.Show("Error", "No tracks to play! Please add a track to the playlist.");
}
else if(o.PlaybackState == NAudio.Wave.PlaybackState.Paused)
{
o.Resume();
btnplay.Text = "Pause";
}
else if(o.PlaybackState == NAudio.Wave.PlaybackState.Playing)
{
o.Pause();
btnplay.Text = "Play";
}
}
System.IO.Stream memstream = null;
NAudio.Wave.Mp3FileReader mp3 = null;
public void Play(string track)
{
if (o != null)
{
o.Dispose();
mp3.Dispose();
memstream.Dispose();
}
var bytes = ShiftOS.Objects.ShiftFS.Utils.ReadAllBytes(track);
memstream = new System.IO.MemoryStream(bytes);
mp3 = new NAudio.Wave.Mp3FileReader(memstream);
o = new NAudio.Wave.WaveOut();
o.Init(mp3);
o.Play();
pgplaytime.Value = 0;
pgplaytime.Maximum = (int)mp3.Length;
new Thread(() =>
{
while (o.PlaybackState == NAudio.Wave.PlaybackState.Playing || o.PlaybackState == NAudio.Wave.PlaybackState.Paused)
{
long time = mp3.Position;
this.Invoke(new Action(() =>
{
pgplaytime.Value = (int)time;
}));
Thread.Sleep(50);
}
if (o.PlaybackState == NAudio.Wave.PlaybackState.Stopped)
{
this.Invoke(new Action(() =>
{
if (lbtracks.SelectedIndex < lbtracks.Items.Count - 1)
{
lbtracks.SelectedIndex++;
}
else if (loopToolStripMenuItem.Checked == true)
{
lbtracks.SelectedIndex = 0;
}
}));
}
}).Start();
}
private void lbtracks_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
Play(lbtracks.SelectedItem.ToString());
}
catch { }
}
bool scrubbing = false;
private void startScrub(object sender, MouseEventArgs e)
{
scrubbing = true;
}
static public double linear(double x, double x0, double x1, double y0, double y1)
{
if ((x1 - x0) == 0)
{
return (y0 + y1) / 2;
}
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
}
private void pgplaytime_MouseMove(object sender, MouseEventArgs e)
{
if (mp3 != null)
try
{
if (scrubbing)
{
long s_pos = (long)linear(e.X, 0, pgplaytime.Width, 0, (double)mp3.Length);
mp3.Position = s_pos;
}
}
catch { }
}
private void pgplaytime_MouseUp(object sender, MouseEventArgs e)
{
scrubbing = false;
}
}
public static class ListExtensions
{
private static Random rng = new Random();
public static void Shuffle<T>(this IList<T> list)
{
int n = list.Count;
while (n > 1)
{
n--;
int k = rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}
}

View file

@ -0,0 +1,134 @@
<?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>
<data name="wpaudio.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB
AAAAAQAAAAAAAAAAAAAAAKIAAAAAAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA
AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAbgBvAG4AZQAAAAsA
AAALAAAACwD//wsA//8LAAAACAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAAelIAAK4w
AAAL
</value>
</data>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -61,13 +61,23 @@ namespace ShiftOS.WinForms.Applications
this.tsbottombar = new System.Windows.Forms.ToolStrip();
this.txtuserinput = new System.Windows.Forms.ToolStripTextBox();
this.btnsend = new System.Windows.Forms.ToolStripButton();
this.pnlstart = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.txtchatid = new System.Windows.Forms.TextBox();
this.btnjoin = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.tsbottombar.SuspendLayout();
this.pnlstart.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.pnlstart);
this.panel1.Controls.Add(this.rtbchat);
this.panel1.Controls.Add(this.toolStrip1);
this.panel1.Controls.Add(this.tsbottombar);
@ -141,6 +151,82 @@ namespace ShiftOS.WinForms.Applications
this.btnsend.Text = "Send";
this.btnsend.Click += new System.EventHandler(this.btnsend_Click);
//
// pnlstart
//
this.pnlstart.Controls.Add(this.flowLayoutPanel1);
this.pnlstart.Controls.Add(this.label3);
this.pnlstart.Controls.Add(this.label2);
this.pnlstart.Controls.Add(this.label1);
this.pnlstart.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlstart.Location = new System.Drawing.Point(0, 25);
this.pnlstart.Name = "pnlstart";
this.pnlstart.Size = new System.Drawing.Size(633, 268);
this.pnlstart.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Padding = new System.Windows.Forms.Padding(10);
this.label1.Size = new System.Drawing.Size(143, 33);
this.label1.TabIndex = 0;
this.label1.Tag = "header1";
this.label1.Text = "Welcome to SimpleSRC!";
//
// label2
//
this.label2.Dock = System.Windows.Forms.DockStyle.Top;
this.label2.Location = new System.Drawing.Point(0, 33);
this.label2.Name = "label2";
this.label2.Padding = new System.Windows.Forms.Padding(10);
this.label2.Size = new System.Drawing.Size(633, 52);
this.label2.TabIndex = 1;
this.label2.Text = "SimpleSRC is a simple chat program that utilises the ShiftOS Relay Chat protocol." +
" All you have to do is enter a chat code or system name, and SimpleSRC will try " +
"to initiate a chat for you.";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Dock = System.Windows.Forms.DockStyle.Top;
this.label3.Location = new System.Drawing.Point(0, 85);
this.label3.Name = "label3";
this.label3.Padding = new System.Windows.Forms.Padding(10);
this.label3.Size = new System.Drawing.Size(79, 33);
this.label3.TabIndex = 2;
this.label3.Tag = "header3";
this.label3.Text = "Join a chat";
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel1.Controls.Add(this.txtchatid);
this.flowLayoutPanel1.Controls.Add(this.btnjoin);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 118);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(633, 29);
this.flowLayoutPanel1.TabIndex = 3;
//
// txtchatid
//
this.txtchatid.Location = new System.Drawing.Point(3, 3);
this.txtchatid.Name = "txtchatid";
this.txtchatid.Size = new System.Drawing.Size(192, 20);
this.txtchatid.TabIndex = 0;
//
// btnjoin
//
this.btnjoin.Location = new System.Drawing.Point(201, 3);
this.btnjoin.Name = "btnjoin";
this.btnjoin.Size = new System.Drawing.Size(75, 23);
this.btnjoin.TabIndex = 1;
this.btnjoin.Text = "Join";
this.btnjoin.UseVisualStyleBackColor = true;
//
// Chat
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -154,6 +240,10 @@ namespace ShiftOS.WinForms.Applications
this.toolStrip1.PerformLayout();
this.tsbottombar.ResumeLayout(false);
this.tsbottombar.PerformLayout();
this.pnlstart.ResumeLayout(false);
this.pnlstart.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
@ -168,5 +258,12 @@ namespace ShiftOS.WinForms.Applications
private System.Windows.Forms.ToolStrip tsbottombar;
private System.Windows.Forms.ToolStripTextBox txtuserinput;
private System.Windows.Forms.ToolStripButton btnsend;
private System.Windows.Forms.Panel pnlstart;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.TextBox txtchatid;
private System.Windows.Forms.Button btnjoin;
}
}

View file

@ -33,61 +33,27 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using ShiftOS.Engine;
using System.Threading;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[WinOpen("simplesrc")]
[Launcher("SimpleSRC Client", false, null, "Networking")]
[DefaultTitle("SimpleSRC Client")]
[AppscapeEntry("SimpleSRC", "A simple ShiftOS Relay Chat client that allows you to talk with other ShiftOS users from all over the world.", 300, 145, "file_skimmer", "Networking")]
public partial class Chat : UserControl, IShiftOSWindow
{
public Chat(string chatId)
public Chat()
{
InitializeComponent();
id = chatId;
ServerManager.MessageReceived += (msg) =>
{
if (msg.Name == "chat_msgreceived")
{
try
{
this.Invoke(new Action(() =>
{
try
{
var args = JsonConvert.DeserializeObject<Dictionary<string, string>>(msg.Contents);
var cmsg = new ShiftOS.Objects.ChatMessage(args["Username"] as string, args["SystemName"] as string, args["Message"] as string, args["Channel"] as string);
if (id == cmsg.Channel)
rtbchat.AppendText($"[{cmsg.Username}@{cmsg.SystemName}] {cmsg.Message}{Environment.NewLine}");
}
catch (Exception ex)
{
rtbchat.AppendText($"[system@multiuserdomain] Exception thrown by client: {ex}");
}
}));
}
catch { }
}
};
}
public void SendMessage(string msg)
{
if (!string.IsNullOrWhiteSpace(msg))
{
rtbchat.AppendText($"[{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}] {msg}{Environment.NewLine}");
ServerManager.SendMessage("chat_send", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatMessage(SaveSystem.CurrentSave.Username, SaveSystem.CurrentSave.SystemName, msg, id)));
}
else
{
rtbchat.AppendText($"[sys@multiuserdomain] You can't send blank messages. (only you can see this)");
}
}
private string id = "";
public void OnLoad()
{
SendMessage("User has joined the chat.");
AllInstances.Add(this);
if (!string.IsNullOrWhiteSpace(ChatID))
pnlstart.SendToBack();
RefreshUserInput();
}
@ -98,8 +64,8 @@ namespace ShiftOS.WinForms.Applications
public bool OnUnload()
{
SendMessage("User has left the chat.");
id = null;
AllInstances.Remove(this);
ChatID = null;
return true;
}
@ -132,15 +98,102 @@ namespace ShiftOS.WinForms.Applications
{
rtbchat.SelectionStart = rtbchat.Text.Length;
rtbchat.ScrollToCaret();
tschatid.Text = id;
tsuserdata.Text = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}";
tschatid.Text = ChatID;
AppearanceManager.SetWindowTitle(this, tschatid.Text + " - SimpleSRC Client");
tsuserdata.Text = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}";
RefreshUserInput();
}
public static readonly List<Chat> AllInstances = new List<Chat>();
public static void SendMessage(string user, string destination, string msg)
{
foreach(var chat in AllInstances)
{
chat.PostMessage(user, destination, msg);
}
}
public string ChatID = "";
public void PostMessage(string user, string destination, string message)
{
if (ChatID == destination)
{
this.Invoke(new Action(() =>
{
rtbchat.SelectionFont = new Font(rtbchat.Font, FontStyle.Bold);
rtbchat.AppendText($"[{user}] ");
rtbchat.SelectionFont = rtbchat.Font;
rtbchat.AppendText(message);
rtbchat.AppendText(Environment.NewLine + Environment.NewLine);
}));
}
}
private void btnsend_Click(object sender, EventArgs e)
{
SendMessage(txtuserinput.Text);
//Update ALL chat windows with this message if they're connected to this chat.
SendMessage($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}", ChatID, txtuserinput.Text);
txtuserinput.Text = "";
}
[Story("story_thefennfamily")]
public static void Story_TheFennFamily()
{
bool complete = false;
Infobox.Show("SimpleSRC", "A direct message has been sent to you on SimpleSRC from user \"maureenfenn@trisys\".", () =>
{
string ch = "maureenfenn@trisys";
var c = new Chat();
c.ChatID = ch;
AppearanceManager.SetupWindow(c);
string you = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}";
var t = new Thread(() =>
{
SendMessage(you, ch, "User has joined the chat.");
Thread.Sleep(2000);
SendMessage(ch, ch, "Hello, " + you + ". My name is Maureen. Maureen Fenn.");
Thread.Sleep(2500);
SendMessage(ch, ch, "I am the author of the various Tri applications you may see on Appscape.");
Thread.Sleep(2000);
SendMessage(ch, ch, "I need your help with something...");
Thread.Sleep(2500);
SendMessage(ch, ch, "Firstly, a little backstory. There was a time in ShiftOS when none of us were connected.");
Thread.Sleep(2500);
SendMessage(ch, ch, "There wasn't a Digital Society, we didn't have chat applications or anything...");
Thread.Sleep(2000);
SendMessage(ch, ch, "All we had was the Shiftnet.");
Thread.Sleep(2500);
SendMessage(ch, ch, "However, in 2016, something happened called the \"connected revolution\". It was like, the invention of the Internet - it was huge for the world of ShiftOS.");
Thread.Sleep(2500);
SendMessage(ch, ch, "Before this, the only way you could earn Codepoints was through playing games in ShiftOS.");
Thread.Sleep(2500);
SendMessage(ch, ch, "I was the one who coded those games, and I would put them on a Shiftnet website that you can still access today, shiftnet/main/shiftgames.");
Thread.Sleep(2500);
SendMessage(ch, ch, "But when the Connected Revolution took place, things got difficult. My son, Nalyr Fenn, was born, and people stopped using my software and instead moved on to hacking eachother and stealing peoples' Codepoints.");
Thread.Sleep(2500);
SendMessage(ch, ch, "When Nalyr's sentience levels reached near human - i.e, he grew up, we decided to start TriOffice. It was a huge success, thanks to Aiden Nirh, the guy who runs Appscape.");
Thread.Sleep(2500);
SendMessage(ch, ch, "However... a few months ago he cut contact with us and we stopped receiving Codepoints from TriOffice.");
Thread.Sleep(2500);
SendMessage(ch, ch, "I'm running low - I can't afford to keep my system running much longer. You have to help!");
Thread.Sleep(2500);
SendMessage(ch, ch, "Perhaps, you could breach Aiden's server and look for clues as to why he's against us? I'll reward you with the last Codepoints I have.");
Thread.Sleep(2500);
SendMessage(you, ch, "Alright, I'm in - but I don't know where to begin...");
Thread.Sleep(2500);
SendMessage(ch, ch, "A little birdie tells me you know about the RTS exploits going around... Try using that on Aiden's server. You can find his systemname on Appscape under \"Contact Us.\" He has a mailserver on Appscape - and also has RTS on the same server.");
Thread.Sleep(2500);
SendMessage(ch, ch, "Good luck... My life depends on you!");
complete = true;
});
t.IsBackground = true;
t.Start();
});
while (!complete)
Thread.Sleep(10);
}
}
}

View file

@ -27,10 +27,13 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.VisualBasic.Devices;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
@ -49,6 +52,7 @@ namespace ShiftOS.WinForms.Applications
public void OnLoad()
{
AppearanceManager.SetWindowTitle(this, this.Title);
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.infobox);
}
public void OnSkinLoad()
@ -65,10 +69,10 @@ namespace ShiftOS.WinForms.Applications
{
}
internal void OpenInternal(string title, string msg)
internal void OpenInternal(string title, string msg, Action c)
{
AppearanceManager.SetupWindow(this);
Title = title;
AppearanceManager.SetupDialog(this);
lbmessage.Text = msg;
txtinput.Hide();
flyesno.Hide();
@ -76,20 +80,22 @@ namespace ShiftOS.WinForms.Applications
btnok.Click += (o, a) =>
{
AppearanceManager.Close(this);
c?.Invoke();
};
}
public void Open(string title, string msg)
public void Open(string title, string msg, Action c = null)
{
new Dialog().OpenInternal(title, msg);
new Dialog().OpenInternal(title, msg, c);
}
public void PromptTextInternal(string title, string message, Action<string> callback)
public void PromptTextInternal(string title, string message, Action<string> callback, bool isPassword)
{
AppearanceManager.SetupWindow(this);
Title = title;
AppearanceManager.SetupDialog(this);
lbmessage.Text = message;
txtinput.UseSystemPasswordChar = isPassword;
txtinput.Show();
flyesno.Hide();
btnok.Show();
@ -109,9 +115,9 @@ namespace ShiftOS.WinForms.Applications
};
}
public void PromptText(string title, string message, Action<string> callback)
public void PromptText(string title, string message, Action<string> callback, bool isPassword)
{
new Dialog().PromptTextInternal(title, message, callback);
new Dialog().PromptTextInternal(title, message, callback, isPassword);
}
public void PromptYesNo(string title, string message, Action<bool> callback)
@ -123,8 +129,8 @@ namespace ShiftOS.WinForms.Applications
public void PromptYesNoInternal(string title, string message, Action<bool> callback)
{
AppearanceManager.SetupWindow(this);
Title = title;
AppearanceManager.SetupDialog(this);
lbmessage.Text = message;
txtinput.Hide();
flyesno.Show();

View file

@ -41,8 +41,12 @@ using System.IO.Compression;
namespace ShiftOS.WinForms.Applications
{
[Launcher("Downloader", false, null, "Networking")]
[MultiplayerOnly]
[Launcher("Downloader", true, "al_downloader", "Networking")]
[DefaultIcon("iconDownloader")]
[WinOpen("downloader")]
[DefaultTitle("Downloader")]
[RequiresUpgrade("downloader")]
public partial class Downloader : UserControl, IShiftOSWindow
{
public Downloader()
@ -173,18 +177,13 @@ namespace ShiftOS.WinForms.Applications
/// <returns>Download speed in bytes.</returns>
public static int GetDownloadSpeed()
{
switch (SaveSystem.CurrentSave.ShiftnetSubscription)
{
case 0:
return 256/*B*/;
case 1:
return 1024 * 1024/*KB*/;
case 2:
return 1024 * 10240/*KB*/;
case 3:
return 1024 * 1024 * 1024/*MB*/;
}
return 256;
return GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription].DownloadSpeed;
}
public static ShiftOS.Objects.EngineShiftnetSubscription[] GetAllSubscriptions()
{
//For now we'll have them hard-coded into the client but in future they'll be in the MUD.
return JsonConvert.DeserializeObject<ShiftOS.Objects.EngineShiftnetSubscription[]>(Properties.Resources.ShiftnetServices);
}
public static void StartDownload(Download down)

View file

@ -60,9 +60,20 @@ namespace ShiftOS.WinForms.Applications
try
{
var itm = lvitems.SelectedItems[0];
if (FileExists(currentdir + "/" + itm.Text))
if (cbfiletypes.Text != "Directory")
{
txtfilename.Text = itm.Text;
if (FileExists(currentdir + "/" + itm.Text))
{
txtfilename.Text = itm.Text;
}
}
else
{
if (DirectoryExists(currentdir + "/" + itm.Text))
{
txtfilename.Text = itm.Text;
}
}
}
catch { }
@ -72,23 +83,41 @@ namespace ShiftOS.WinForms.Applications
{
string fname = "";
fname = (!string.IsNullOrWhiteSpace(txtfilename.Text)) ? txtfilename.Text : "";
fname = (!fname.EndsWith(cbfiletypes.SelectedItem.ToString())) ? fname + cbfiletypes.SelectedItem.ToString() : fname;
fname = (fname == cbfiletypes.SelectedItem.ToString()) ? "" : fname;
if (cbfiletypes.Text != "Directory")
{
fname = (!fname.EndsWith(cbfiletypes.SelectedItem.ToString())) ? fname + cbfiletypes.SelectedItem.ToString() : fname;
fname = (fname == cbfiletypes.SelectedItem.ToString()) ? "" : fname;
}
switch (style)
{
case FileOpenerStyle.Open:
if(FileExists(currentdir + "/" + fname))
if (cbfiletypes.Text == "Directory")
{
callback?.Invoke(currentdir + "/" + fname);
this.Close();
if (DirectoryExists(currentdir + "/" + fname))
{
callback?.Invoke(currentdir + "/" + fname);
this.Close();
}
else
{
Infobox.Show("{FILE_NOT_FOUND}", "{FILE_NOT_FOUND_EXP}");
}
}
else
{
Infobox.Show("{FILE_NOT_FOUND}", "{FILE_NOT_FOUND_EXP}");
if (FileExists(currentdir + "/" + fname))
{
callback?.Invoke(currentdir + "/" + fname);
this.Close();
}
else
{
Infobox.Show("{FILE_NOT_FOUND}", "{FILE_NOT_FOUND_EXP}");
}
}
break;
case FileOpenerStyle.Save:

View file

@ -54,10 +54,15 @@ namespace ShiftOS.WinForms.Applications
{
this.lvitems = new System.Windows.Forms.ListView();
this.panel1 = new System.Windows.Forms.Panel();
this.pinnedItems = new System.Windows.Forms.TreeView();
this.lbcurrentfolder = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.newFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.connectToRemoteServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
@ -65,16 +70,19 @@ 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);
this.lvitems.SelectedIndexChanged += new System.EventHandler(this.lvitems_SelectedIndexChanged);
this.lvitems.DoubleClick += new System.EventHandler(this.lvitems_DoubleClick);
//
// panel1
//
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);
@ -82,6 +90,15 @@ namespace ShiftOS.WinForms.Applications
this.panel1.Size = new System.Drawing.Size(634, 345);
this.panel1.TabIndex = 1;
//
// pinnedItems
//
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(149, 332);
this.pinnedItems.TabIndex = 3;
this.pinnedItems.Click += new System.EventHandler(this.pinnedItems_Click);
//
// lbcurrentfolder
//
this.lbcurrentfolder.Dock = System.Windows.Forms.DockStyle.Bottom;
@ -95,7 +112,11 @@ namespace ShiftOS.WinForms.Applications
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newFolderToolStripMenuItem,
this.deleteToolStripMenuItem});
this.deleteToolStripMenuItem,
this.connectToRemoteServerToolStripMenuItem,
this.copyToolStripMenuItem,
this.moveToolStripMenuItem,
this.pinToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(634, 24);
@ -114,6 +135,35 @@ namespace ShiftOS.WinForms.Applications
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
this.deleteToolStripMenuItem.Text = "Delete";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// connectToRemoteServerToolStripMenuItem
//
this.connectToRemoteServerToolStripMenuItem.Name = "connectToRemoteServerToolStripMenuItem";
this.connectToRemoteServerToolStripMenuItem.Size = new System.Drawing.Size(153, 20);
this.connectToRemoteServerToolStripMenuItem.Text = "Connect to remote server";
this.connectToRemoteServerToolStripMenuItem.Visible = false;
//
// copyToolStripMenuItem
//
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.copyToolStripMenuItem.Text = "Copy";
this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
//
// moveToolStripMenuItem
//
this.moveToolStripMenuItem.Name = "moveToolStripMenuItem";
this.moveToolStripMenuItem.Size = new System.Drawing.Size(49, 20);
this.moveToolStripMenuItem.Text = "Move";
this.moveToolStripMenuItem.Click += new System.EventHandler(this.moveToolStripMenuItem_Click);
//
// pinToolStripMenuItem
//
this.pinToolStripMenuItem.Name = "pinToolStripMenuItem";
this.pinToolStripMenuItem.Size = new System.Drawing.Size(36, 20);
this.pinToolStripMenuItem.Text = "Pin";
this.pinToolStripMenuItem.Click += new System.EventHandler(this.pinToolStripMenuItem_Click);
//
// FileSkimmer
//
@ -140,5 +190,10 @@ namespace ShiftOS.WinForms.Applications
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem newFolderToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem connectToRemoteServerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem moveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pinToolStripMenuItem;
private System.Windows.Forms.TreeView pinnedItems;
}
}

View file

@ -34,8 +34,8 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using static ShiftOS.Objects.ShiftFS.Utils;
using Newtonsoft.Json;
using ShiftOS.Engine;
using Newtonsoft.Json;
namespace ShiftOS.WinForms.Applications
{
@ -125,6 +125,20 @@ namespace ShiftOS.WinForms.Applications
private string currentdir = "";
public void pinDirectory(string path)
{
int amountsCalled = -1;
amountsCalled = amountsCalled + 1;
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)
{
currentdir = path;
@ -145,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();
@ -233,6 +279,8 @@ namespace ShiftOS.WinForms.Applications
return Properties.Resources.fileicon10;
case FileType.TextFile:
return Properties.Resources.fileicon2;
case FileType.CommandFormat:
return Properties.Resources.fileiconcf;
default:
return Properties.Resources.fileicon1;
}
@ -257,6 +305,9 @@ namespace ShiftOS.WinForms.Applications
public void OnUpgrade()
{
moveToolStripMenuItem.Visible = false;
copyToolStripMenuItem.Visible = false;
deleteToolStripMenuItem.Visible = false;
}
private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
@ -281,7 +332,170 @@ namespace ShiftOS.WinForms.Applications
}
});
}
}
private void lvitems_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (currentdir != "__system")
{
var itm = lvitems.SelectedItems[0];
if (itm.Tag.ToString() != "__..")
{
if (DirectoryExists(currentdir + "/" + itm.Tag.ToString()))
{
deleteToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_recursive_delete");
moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move_folder");
copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy_folder");
}
else if (FileExists(currentdir + "/" + itm.Tag.ToString()))
{
deleteToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_delete");
moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move");
copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy");
}
}
}
}
catch
{
moveToolStripMenuItem.Visible = false;
copyToolStripMenuItem.Visible = false;
}
}
private void lvitems_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
if(lvitems.SelectedItems.Count == 0)
{
moveToolStripMenuItem.Visible = false;
copyToolStripMenuItem.Visible = false;
deleteToolStripMenuItem.Visible = false;
}
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
string path = currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString();
if (DirectoryExists(path))
{
FileSkimmerBackend.GetFile(new[] { "Directory" }, FileOpenerStyle.Save, (newPath) =>
{
Copy(path, newPath);
ResetList();
});
}
else if (FileExists(path))
{
string[] psplit = path.Split('.');
string ext = "." + psplit[psplit.Length - 1];
FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, (newPath) =>
{
Copy(path, newPath);
ResetList();
});
}
}
catch
{
}
}
private void moveToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
string path = currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString();
if (DirectoryExists(path))
{
FileSkimmerBackend.GetFile(new[] { "Directory" }, FileOpenerStyle.Save, (newPath) =>
{
Utils.Move(path, newPath);
ResetList();
});
}
else if (FileExists(path))
{
string[] psplit = path.Split('.');
string ext = psplit[psplit.Length - 1];
FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, (newPath) =>
{
Utils.Move(path, newPath);
ResetList();
});
}
}
catch
{
}
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
Infobox.PromptYesNo("Delete file", "Are you sure you want to delete " + lvitems.SelectedItems[0].Text + "?", (result) =>
{
if (result == true)
{
Delete(currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString());
ResetList();
}
});
}
catch { }
}
private void pinToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
Infobox.PromptYesNo("Pin folder", "Are you sure you want to pin \"" + lvitems.SelectedItems[0].Text + "\"?", (result) =>
{
if (result == true)
{
if (currentdir != "__system" && lvitems.SelectedItems[0].Text != "Up one")
{
pinDirectory(currentdir + "/" + lvitems.SelectedItems[0].Text);
ResetList();
}
else
{
Infobox.Show("Cannot Pin", "You can only pin files or folders.");
}
}
});
}
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 { }
}
}
}

View file

@ -0,0 +1,225 @@
/*
* 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 FormatEditor
{
/// <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.panelEditor = new System.Windows.Forms.Panel();
this.btnAddText = new System.Windows.Forms.Button();
this.btnAddOptionalText = new System.Windows.Forms.Button();
this.btnAddRegexText = new System.Windows.Forms.Button();
this.btnAddCommand = new System.Windows.Forms.Button();
this.lblExampleCommand = new System.Windows.Forms.Label();
this.btnAddColor = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.btnTest = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.btnLoad = new System.Windows.Forms.Button();
this.btnApply = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// panelEditor
//
this.panelEditor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panelEditor.AutoScroll = true;
this.panelEditor.Location = new System.Drawing.Point(4, 4);
this.panelEditor.Name = "panelEditor";
this.panelEditor.Size = new System.Drawing.Size(589, 46);
this.panelEditor.TabIndex = 1;
//
// btnAddText
//
this.btnAddText.Location = new System.Drawing.Point(4, 56);
this.btnAddText.Name = "btnAddText";
this.btnAddText.Size = new System.Drawing.Size(75, 23);
this.btnAddText.TabIndex = 2;
this.btnAddText.Text = "Add Text";
this.btnAddText.UseVisualStyleBackColor = true;
this.btnAddText.Click += new System.EventHandler(this.btnAddText_Click);
//
// btnAddOptionalText
//
this.btnAddOptionalText.Location = new System.Drawing.Point(85, 56);
this.btnAddOptionalText.Name = "btnAddOptionalText";
this.btnAddOptionalText.Size = new System.Drawing.Size(107, 23);
this.btnAddOptionalText.TabIndex = 3;
this.btnAddOptionalText.Text = "Add Optional Text";
this.btnAddOptionalText.UseVisualStyleBackColor = true;
this.btnAddOptionalText.Click += new System.EventHandler(this.btnAddOptionalText_Click);
//
// btnAddRegexText
//
this.btnAddRegexText.Location = new System.Drawing.Point(198, 56);
this.btnAddRegexText.Name = "btnAddRegexText";
this.btnAddRegexText.Size = new System.Drawing.Size(107, 23);
this.btnAddRegexText.TabIndex = 4;
this.btnAddRegexText.Text = "Add Regex Text";
this.btnAddRegexText.UseVisualStyleBackColor = true;
this.btnAddRegexText.Click += new System.EventHandler(this.btnAddRegexText_Click);
//
// btnAddCommand
//
this.btnAddCommand.Location = new System.Drawing.Point(4, 85);
this.btnAddCommand.Name = "btnAddCommand";
this.btnAddCommand.Size = new System.Drawing.Size(85, 23);
this.btnAddCommand.TabIndex = 5;
this.btnAddCommand.Text = "+ Namespace";
this.btnAddCommand.UseVisualStyleBackColor = true;
this.btnAddCommand.Click += new System.EventHandler(this.btnAddCommand_Click);
//
// lblExampleCommand
//
this.lblExampleCommand.AutoSize = true;
this.lblExampleCommand.Location = new System.Drawing.Point(4, 115);
this.lblExampleCommand.Name = "lblExampleCommand";
this.lblExampleCommand.Size = new System.Drawing.Size(290, 13);
this.lblExampleCommand.TabIndex = 8;
this.lblExampleCommand.Text = "Create a command and an example usage will show up here";
//
// btnAddColor
//
this.btnAddColor.Location = new System.Drawing.Point(311, 56);
this.btnAddColor.Name = "btnAddColor";
this.btnAddColor.Size = new System.Drawing.Size(64, 23);
this.btnAddColor.TabIndex = 9;
this.btnAddColor.Text = "Add Color";
this.btnAddColor.UseVisualStyleBackColor = true;
this.btnAddColor.Click += new System.EventHandler(this.btnAddColor_Click);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(7, 132);
this.richTextBox1.Multiline = false;
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(476, 23);
this.richTextBox1.TabIndex = 10;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// btnTest
//
this.btnTest.Location = new System.Drawing.Point(490, 132);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(47, 23);
this.btnTest.TabIndex = 11;
this.btnTest.Text = "Test";
this.btnTest.UseVisualStyleBackColor = true;
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(7, 161);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(47, 23);
this.btnSave.TabIndex = 13;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// btnLoad
//
this.btnLoad.Location = new System.Drawing.Point(60, 161);
this.btnLoad.Name = "btnLoad";
this.btnLoad.Size = new System.Drawing.Size(47, 23);
this.btnLoad.TabIndex = 14;
this.btnLoad.Text = "Load";
this.btnLoad.UseVisualStyleBackColor = true;
this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
//
// btnApply
//
this.btnApply.Location = new System.Drawing.Point(113, 161);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(47, 23);
this.btnApply.TabIndex = 15;
this.btnApply.Text = "Apply";
this.btnApply.UseVisualStyleBackColor = true;
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
//
// FormatEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnApply);
this.Controls.Add(this.btnLoad);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnTest);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.btnAddColor);
this.Controls.Add(this.lblExampleCommand);
this.Controls.Add(this.btnAddText);
this.Controls.Add(this.btnAddOptionalText);
this.Controls.Add(this.btnAddRegexText);
this.Controls.Add(this.btnAddCommand);
this.Controls.Add(this.panelEditor);
this.Name = "FormatEditor";
this.Size = new System.Drawing.Size(596, 426);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panelEditor;
private System.Windows.Forms.Button btnAddText;
private System.Windows.Forms.Button btnAddOptionalText;
private System.Windows.Forms.Button btnAddRegexText;
private System.Windows.Forms.Button btnAddCommand;
private System.Windows.Forms.Label lblExampleCommand;
private System.Windows.Forms.Button btnAddColor;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button btnTest;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button btnLoad;
private System.Windows.Forms.Button btnApply;
}
}

View file

@ -0,0 +1,186 @@
/*
* 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 System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications {
[MultiplayerOnly]
[Launcher("Format Editor", true, "al_format_editor", "Customization")]
[AppscapeEntry("Format Editor", "Edit the syntax of your Terminal to be however you like.", 740, 750, "file_skimmer", "Customization")]
[WinOpen("formateditor")]
[DefaultTitle("Format Editor")]
[DefaultIcon("iconFormatEditor")]
public partial class FormatEditor : UserControl, IShiftOSWindow {
IList<CommandFormat> parts = new List<CommandFormat>();
CommandParser parser = new CommandParser();
IList<Panel> editorBoxes = new List<Panel>();
string commandMode = "namespace";
int avcount = 0;
public FormatEditor() {
InitializeComponent();
}
public void OnLoad() {
OnUpgrade();
}
public void OnSkinLoad() { }
public bool OnUnload() { return true; }
public void OnUpgrade() {
btnAddOptionalText.Visible = ShiftoriumFrontend.UpgradeInstalled("format_editor_optional_text");
btnAddRegexText.Visible = ShiftoriumFrontend.UpgradeInstalled("format_editor_regex");
btnAddColor.Visible = ShiftoriumFrontend.UpgradeInstalled("format_editor_syntax_highlighting");
}
private void addPart(CommandFormat part) {
parser.AddPart(part);
addPart(part.Draw());
}
private void addPart(Control part) {
Panel container = new Panel();
Control drawnPart = part;
container.Size = drawnPart.Size;
container.Controls.Add(drawnPart);
int woffset = 0;
if (editorBoxes.Count > 0) {
woffset = editorBoxes.Last().Width + editorBoxes.Last().Location.X;
} else {
woffset = 0;
}
container.Location = new Point(woffset, 0);
editorBoxes.Add(container);
panelEditor.Controls.Add(container);
}
private void btnAddText_Click(object sender, EventArgs e) {
addPart(new CommandFormatText());
}
private void btnAddOptionalText_Click(object sender, EventArgs e) {
addPart(new CommandFormatOptionalText());
}
private void btnAddRegexText_Click(object sender, EventArgs e) {
}
private void btnAddColor_Click(object sender, EventArgs e) {
}
private void btnAddCommand_Click(object sender, EventArgs e) {
switch (commandMode) {
case "namespace":
addPart(new CommandFormatNamespace());
commandMode = "command";
btnAddCommand.Text = "+ Command";
break;
case "command":
addPart(new CommandFormatCommand());
commandMode = "argument";
btnAddCommand.Text = "+ Argument";
break;
case "argument":
addPart(new CommandFormatArgument());
commandMode = "value";
btnAddCommand.Text = "+ \"Value\"";
break;
case "value":
addPart(new CommandFormatValue());
avcount++;
if (avcount >= 2) {
commandMode = "";
btnAddCommand.Text = "";
btnAddCommand.Enabled = false;
}else {
commandMode = "argument";
btnAddCommand.Text = "+ Argument";
}
break;
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e) {
var result = parser.ParseCommand(richTextBox1.Text);
if (result.Equals(default(KeyValuePair<KeyValuePair<string, string>, Dictionary<string, string>>))) {
lblExampleCommand.Text = "Syntax Error";
} else {
string argvs = "{";
foreach (KeyValuePair<string, string> entry in result.Value) {
argvs += entry.Key + "=\"" + entry.Value + "\", ";
}
argvs += "}";
lblExampleCommand.Text = result.Key + argvs;
}
}
private void btnTest_Click(object sender, EventArgs e) {
}
private void btnSave_Click(object sender, EventArgs e) {
CurrentCommandParser.parser = parser;
FileSkimmerBackend.GetFile(new string[] { ".cf" }, FileOpenerStyle.Save, new Action<string>((result) => {
Objects.ShiftFS.Utils.WriteAllText(result, parser.Save());
}));
}
private void btnLoad_Click(object sender, EventArgs e) {
FileSkimmerBackend.GetFile(new string[] { ".cf" }, FileOpenerStyle.Open, new Action<string>((result) => {
parser = CommandParser.Load(Objects.ShiftFS.Utils.ReadAllText(result));
foreach(CommandFormat part in parser.parts) {
addPart(part.Draw());
}
}));
}
private void btnApply_Click(object sender, EventArgs e) {
CurrentCommandParser.parser = parser;
}
}
}

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
{
@ -82,12 +83,11 @@ namespace ShiftOS.WinForms.Applications
public void btnidlebrowse_Click(object s, EventArgs a)
{
AppearanceManager.SetupDialog(new FileDialog(new[] { ".png", ".jpg", ".bmp", ".pic" }, FileOpenerStyle.Open, new Action<string>((file) =>
AppearanceManager.SetupDialog(new FileDialog(new[] { ".png", ".gif", ".jpg", ".bmp", ".pic" }, FileOpenerStyle.Open, new Action<string>((file) =>
{
ImageAsBinary = Utils.ReadAllBytes(file);
System.IO.File.WriteAllBytes("temp_bin.bmp", ImageAsBinary);
Image = SkinEngine.ImageFromBinary(ImageAsBinary);
Image.Save("temp.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Setup();
})));
}

View file

@ -0,0 +1,157 @@
namespace ShiftOS.WinForms.Applications
{
partial class Installer
{
/// <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.lbtitle = new System.Windows.Forms.Label();
this.pnlselectfile = new System.Windows.Forms.Panel();
this.btnstart = new System.Windows.Forms.Button();
this.btnbrowse = new System.Windows.Forms.Button();
this.txtfilepath = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.lbprogress = new System.Windows.Forms.Label();
this.pginstall = new ShiftOS.WinForms.Controls.ShiftedProgressBar();
this.pnlselectfile.SuspendLayout();
this.SuspendLayout();
//
// lbtitle
//
this.lbtitle.AutoSize = true;
this.lbtitle.Location = new System.Drawing.Point(14, 13);
this.lbtitle.Name = "lbtitle";
this.lbtitle.Size = new System.Drawing.Size(155, 13);
this.lbtitle.TabIndex = 0;
this.lbtitle.Tag = "header2";
this.lbtitle.Text = "Installing MUD Control Centre...";
//
// pnlselectfile
//
this.pnlselectfile.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pnlselectfile.Controls.Add(this.btnstart);
this.pnlselectfile.Controls.Add(this.btnbrowse);
this.pnlselectfile.Controls.Add(this.txtfilepath);
this.pnlselectfile.Controls.Add(this.label1);
this.pnlselectfile.Location = new System.Drawing.Point(17, 48);
this.pnlselectfile.Name = "pnlselectfile";
this.pnlselectfile.Size = new System.Drawing.Size(414, 85);
this.pnlselectfile.TabIndex = 1;
this.pnlselectfile.VisibleChanged += new System.EventHandler(this.pnlselectfile_VisibleChanged);
//
// btnstart
//
this.btnstart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnstart.Location = new System.Drawing.Point(255, 59);
this.btnstart.Name = "btnstart";
this.btnstart.Size = new System.Drawing.Size(75, 23);
this.btnstart.TabIndex = 3;
this.btnstart.Text = "Start";
this.btnstart.UseVisualStyleBackColor = true;
this.btnstart.Click += new System.EventHandler(this.btnstart_Click);
//
// btnbrowse
//
this.btnbrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnbrowse.Location = new System.Drawing.Point(336, 60);
this.btnbrowse.Name = "btnbrowse";
this.btnbrowse.Size = new System.Drawing.Size(75, 23);
this.btnbrowse.TabIndex = 2;
this.btnbrowse.Text = "Browse...";
this.btnbrowse.UseVisualStyleBackColor = true;
this.btnbrowse.Click += new System.EventHandler(this.btnbrowse_Click);
//
// txtfilepath
//
this.txtfilepath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtfilepath.Location = new System.Drawing.Point(16, 34);
this.txtfilepath.Name = "txtfilepath";
this.txtfilepath.Size = new System.Drawing.Size(395, 20);
this.txtfilepath.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(126, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Select a .stp file to install.";
//
// lbprogress
//
this.lbprogress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lbprogress.AutoSize = true;
this.lbprogress.Location = new System.Drawing.Point(17, 140);
this.lbprogress.Name = "lbprogress";
this.lbprogress.Size = new System.Drawing.Size(35, 13);
this.lbprogress.TabIndex = 3;
this.lbprogress.Text = "label1";
//
// pginstall
//
this.pginstall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pginstall.Location = new System.Drawing.Point(17, 161);
this.pginstall.Maximum = 100;
this.pginstall.Name = "pginstall";
this.pginstall.Size = new System.Drawing.Size(414, 23);
this.pginstall.TabIndex = 2;
this.pginstall.Text = "shiftedProgressBar1";
this.pginstall.Value = 0;
//
// Installer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lbprogress);
this.Controls.Add(this.pginstall);
this.Controls.Add(this.pnlselectfile);
this.Controls.Add(this.lbtitle);
this.Name = "Installer";
this.Size = new System.Drawing.Size(447, 203);
this.pnlselectfile.ResumeLayout(false);
this.pnlselectfile.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbtitle;
private System.Windows.Forms.Panel pnlselectfile;
private Controls.ShiftedProgressBar pginstall;
private System.Windows.Forms.Label lbprogress;
private System.Windows.Forms.Button btnstart;
private System.Windows.Forms.Button btnbrowse;
private System.Windows.Forms.TextBox txtfilepath;
private System.Windows.Forms.Label label1;
}
}

View file

@ -0,0 +1,259 @@
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;
using System.Threading;
using static ShiftOS.Objects.ShiftFS.Utils;
using Newtonsoft.Json;
namespace ShiftOS.WinForms.Applications
{
[WinOpen("installer")]
[RequiresUpgrade("installer")]
[MultiplayerOnly]
[DefaultTitle("Installer")]
[Launcher("Installer", true, "al_installer", "Utilities")]
public partial class Installer : UserControl, IShiftOSWindow
{
public Installer()
{
InitializeComponent();
lbtitle.Text = "Select file";
}
public void InitiateInstall(Installation install)
{
pnlselectfile.Hide();
pginstall.Show();
lbprogress.Show();
lbtitle.Text = install.Name;
install.ProgressReported += (p) =>
{
Desktop.InvokeOnWorkerThread(new Action(() =>
{
pginstall.Value = p;
}));
};
install.StatusReported += (s) =>
{
Desktop.InvokeOnWorkerThread(new Action(() =>
{
lbprogress.Text = s;
}));
};
install.InstallCompleted += () =>
{
Desktop.InvokeOnWorkerThread(new Action(() =>
{
lbtitle.Text = "Select file";
pnlselectfile.Show();
}));
isInstalling = false;
InstallCompleted?.Invoke();
};
while (!this.Visible)
{
}
isInstalling = true;
install.Install();
}
public void OnLoad()
{
btnstart.Hide();
pginstall.Hide();
lbprogress.Hide();
}
private bool isInstalling = false;
public void OnSkinLoad()
{
}
public bool OnUnload()
{
return !isInstalling; //Don't close if an install is running.
}
public void OnUpgrade()
{
}
private void pnlselectfile_VisibleChanged(object sender, EventArgs e)
{
if(this.ParentForm != null)
{
this.ParentForm.Height = (pnlselectfile.Visible == true) ? this.ParentForm.Height + pnlselectfile.Height : this.ParentForm.Height - pnlselectfile.Height;
}
}
public event Action InstallCompleted;
private void btnbrowse_Click(object sender, EventArgs e)
{
FileSkimmerBackend.GetFile(new[] { ".stp" }, FileOpenerStyle.Open, (file) =>
{
txtfilepath.Text = file;
btnstart.Show();
});
}
private void btnstart_Click(object sender, EventArgs e)
{
if (FileExists(txtfilepath.Text))
{
var install = new StpInstallation(txtfilepath.Text);
InitiateInstall(install);
}
else
{
Infobox.Show("File not found.", "The file you requested was not found on the system.");
}
}
}
public abstract class Installation
{
/// <summary>
/// The display name of the installation.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Occurs when the installation updates its status.
/// </summary>
public event Action<string> StatusReported;
/// <summary>
/// Occurs when the installation updates its progress percentage.
/// </summary>
public event Action<int> ProgressReported;
/// <summary>
/// Occurs when the installation completes.
/// </summary>
public event Action InstallCompleted;
/// <summary>
/// Start the installation.
/// </summary>
public void Install()
{
var t = new System.Threading.Thread(() =>
{
ProgressReported?.Invoke(0);
StatusReported?.Invoke("");
Run();
ProgressReported?.Invoke(100);
StatusReported?.Invoke("Installation completed.");
InstallCompleted?.Invoke();
});
t.IsBackground = true;
t.Start();
}
/// <summary>
/// Sets the install progress percentage.
/// </summary>
/// <param name="value">The installation percentage.</param>
protected void SetProgress(int value)
{
if (value < 0 || value > 100)
throw new ArgumentOutOfRangeException("value", "A percentage is typically between 0 and 100.... derp...");
ProgressReported?.Invoke(value);
}
/// <summary>
/// Sets the install status text.
/// </summary>
/// <param name="status">Text to display as status.</param>
protected void SetStatus(string status)
{
StatusReported?.Invoke(status);
}
/// <summary>
/// User-defined code to run during install. Once this code is ran, the installation is complete.
/// </summary>
protected abstract void Run();
}
public class StpInstallation : Installation
{
public StpInstallation(string stpfile) : base()
{
if (!FileExists(stpfile))
throw new System.IO.FileNotFoundException("An attempt to install a ShiftOS setup package failed because the package was not found.", stpfile);
string json = ReadAllText(stpfile);
var contents = JsonConvert.DeserializeObject<StpContents>(json);
this.Name = contents.Name;
Contents = contents;
}
public StpContents Contents { get; set; }
protected override void Run()
{
if (Shiftorium.UpgradeInstalled(Contents.Upgrade))
{
Infobox.Show("Installation failed.", "This package has already been installed.");
return;
}
if (!string.IsNullOrWhiteSpace(Contents.Dependencies))
{
SetStatus("Checking Shiftorium for dependencies...");
string[] dependencies = Contents.Dependencies.Split(';');
for (int i = 0; i < dependencies.Length; i++)
{
if (Shiftorium.UpgradeInstalled(dependencies[i]))
{
double percent = (i / dependencies.Length) * 100;
SetProgress((int)percent);
}
else
{
var upg = Shiftorium.GetDefaults().FirstOrDefault(x => x.Id == dependencies[i]);
Infobox.Show("Missing dependency!", $"You are missing the following Shiftorium Upgrade: {upg.Name}\r\n\r\nThe installation cannot continue.");
return;
}
Thread.Sleep(250);
}
}
SetStatus("Installing...");
SetProgress(0);
for(int i = 0; i < 100; i++)
{
SetProgress(i);
Thread.Sleep(50);
}
Desktop.InvokeOnWorkerThread(() =>
{
Shiftorium.Buy(Contents.Upgrade, 0);
Infobox.Show("Install complete.", "The installation has completed successfully.");
SaveSystem.SaveGame();
});
}
}
public class StpContents : RequiresUpgradeAttribute
{
public StpContents(string name, string author, string dependencies = "") : base(name.ToLower().Replace(" ", "_"))
{
Name = name;
Author = author;
Dependencies = dependencies;
}
public string Name { get; set; }
public string Author { get; set; }
public string Dependencies { get; set; }
}
}

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

@ -66,9 +66,13 @@ namespace ShiftOS.WinForms.Applications
this.createLegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.joinLegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.myLegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.chatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.joinAChatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.pnlclasses = new System.Windows.Forms.Panel();
this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel();
this.btnchooseclass = new System.Windows.Forms.Button();
this.lbclasses = new System.Windows.Forms.ListBox();
this.lbclassdesc = new System.Windows.Forms.Label();
this.lbclasstitle = new System.Windows.Forms.Label();
this.you_systemstatus = new System.Windows.Forms.Panel();
this.btndeletesave = new System.Windows.Forms.Button();
this.lblsysstatus = new System.Windows.Forms.Label();
@ -148,6 +152,8 @@ namespace ShiftOS.WinForms.Applications
this.toolStripContainer1.ContentPanel.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.toolStripContainer1.SuspendLayout();
this.pnlclasses.SuspendLayout();
this.flowLayoutPanel6.SuspendLayout();
this.you_systemstatus.SuspendLayout();
this.shop_all.SuspendLayout();
this.shop_view.SuspendLayout();
@ -180,8 +186,7 @@ namespace ShiftOS.WinForms.Applications
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.youToolStripMenuItem,
this.shopsToolStripMenuItem,
this.legionsToolStripMenuItem,
this.chatToolStripMenuItem});
this.legionsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(756, 24);
@ -281,26 +286,12 @@ namespace ShiftOS.WinForms.Applications
this.myLegionToolStripMenuItem.Text = "My Legion";
this.myLegionToolStripMenuItem.Click += new System.EventHandler(this.myLegionToolStripMenuItem_Click);
//
// chatToolStripMenuItem
//
this.chatToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.joinAChatToolStripMenuItem});
this.chatToolStripMenuItem.Name = "chatToolStripMenuItem";
this.chatToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.chatToolStripMenuItem.Text = "Chat";
//
// joinAChatToolStripMenuItem
//
this.joinAChatToolStripMenuItem.Name = "joinAChatToolStripMenuItem";
this.joinAChatToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.joinAChatToolStripMenuItem.Text = "Join a chat";
this.joinAChatToolStripMenuItem.Click += new System.EventHandler(this.joinAChatToolStripMenuItem_Click);
//
// toolStripContainer1
//
//
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Controls.Add(this.pnlclasses);
this.toolStripContainer1.ContentPanel.Controls.Add(this.you_systemstatus);
this.toolStripContainer1.ContentPanel.Controls.Add(this.shop_all);
this.toolStripContainer1.ContentPanel.Controls.Add(this.shop_view);
@ -322,6 +313,75 @@ namespace ShiftOS.WinForms.Applications
//
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1);
//
// pnlclasses
//
this.pnlclasses.Controls.Add(this.flowLayoutPanel6);
this.pnlclasses.Controls.Add(this.lbclasses);
this.pnlclasses.Controls.Add(this.lbclassdesc);
this.pnlclasses.Controls.Add(this.lbclasstitle);
this.pnlclasses.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlclasses.Location = new System.Drawing.Point(0, 0);
this.pnlclasses.Name = "pnlclasses";
this.pnlclasses.Size = new System.Drawing.Size(756, 464);
this.pnlclasses.TabIndex = 3;
//
// flowLayoutPanel6
//
this.flowLayoutPanel6.AutoSize = true;
this.flowLayoutPanel6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel6.Controls.Add(this.btnchooseclass);
this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 415);
this.flowLayoutPanel6.Name = "flowLayoutPanel6";
this.flowLayoutPanel6.Padding = new System.Windows.Forms.Padding(10);
this.flowLayoutPanel6.Size = new System.Drawing.Size(756, 49);
this.flowLayoutPanel6.TabIndex = 3;
//
// btnchooseclass
//
this.btnchooseclass.AutoSize = true;
this.btnchooseclass.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnchooseclass.Location = new System.Drawing.Point(13, 13);
this.btnchooseclass.Name = "btnchooseclass";
this.btnchooseclass.Size = new System.Drawing.Size(53, 23);
this.btnchooseclass.TabIndex = 0;
this.btnchooseclass.Text = "Choose";
this.btnchooseclass.UseVisualStyleBackColor = true;
this.btnchooseclass.Click += new System.EventHandler(this.btnchooseclass_Click);
//
// lbclasses
//
this.lbclasses.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbclasses.FormattingEnabled = true;
this.lbclasses.Location = new System.Drawing.Point(0, 66);
this.lbclasses.Name = "lbclasses";
this.lbclasses.Size = new System.Drawing.Size(756, 398);
this.lbclasses.TabIndex = 2;
//
// lbclassdesc
//
this.lbclassdesc.AutoSize = true;
this.lbclassdesc.Dock = System.Windows.Forms.DockStyle.Top;
this.lbclassdesc.Location = new System.Drawing.Point(0, 33);
this.lbclassdesc.Name = "lbclassdesc";
this.lbclassdesc.Padding = new System.Windows.Forms.Padding(10);
this.lbclassdesc.Size = new System.Drawing.Size(727, 33);
this.lbclassdesc.TabIndex = 1;
this.lbclassdesc.Text = "A class is a way for the multi-user domain to better understand you. It defines w" +
"ho you are as a sentient being, what you do, what you like, and so on.";
//
// lbclasstitle
//
this.lbclasstitle.AutoSize = true;
this.lbclasstitle.Dock = System.Windows.Forms.DockStyle.Top;
this.lbclasstitle.Location = new System.Drawing.Point(0, 0);
this.lbclasstitle.Name = "lbclasstitle";
this.lbclasstitle.Padding = new System.Windows.Forms.Padding(10);
this.lbclasstitle.Size = new System.Drawing.Size(82, 33);
this.lbclasstitle.TabIndex = 0;
this.lbclasstitle.Tag = "header1";
this.lbclasstitle.Text = "Join a class";
//
// you_systemstatus
//
this.you_systemstatus.Controls.Add(this.btndeletesave);
@ -1198,6 +1258,10 @@ namespace ShiftOS.WinForms.Applications
this.toolStripContainer1.TopToolStripPanel.PerformLayout();
this.toolStripContainer1.ResumeLayout(false);
this.toolStripContainer1.PerformLayout();
this.pnlclasses.ResumeLayout(false);
this.pnlclasses.PerformLayout();
this.flowLayoutPanel6.ResumeLayout(false);
this.flowLayoutPanel6.PerformLayout();
this.you_systemstatus.ResumeLayout(false);
this.you_systemstatus.PerformLayout();
this.shop_all.ResumeLayout(false);
@ -1336,8 +1400,12 @@ namespace ShiftOS.WinForms.Applications
private System.Windows.Forms.Button btnremoveitem;
private System.Windows.Forms.Button btnedititem;
private System.Windows.Forms.Button btneditshop;
private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem joinAChatToolStripMenuItem;
private System.Windows.Forms.Button btndeletesave;
private System.Windows.Forms.Panel pnlclasses;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel6;
private System.Windows.Forms.Button btnchooseclass;
private System.Windows.Forms.ListBox lbclasses;
private System.Windows.Forms.Label lbclassdesc;
private System.Windows.Forms.Label lbclasstitle;
}
}

View file

@ -38,7 +38,8 @@ using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
[RequiresUpgrade("mud_fundamentals")]
[MultiplayerOnly]
[RequiresUpgrade("mud_control_centre")]
[Launcher("MUD Control Centre", true, "al_mud_control_centre", "Networking")]
[WinOpen("mud_control_centre")]
[DefaultIcon("iconSysinfo")]
@ -99,7 +100,7 @@ namespace ShiftOS.WinForms.Applications
{
ServerManager.SendMessage("shop_removeowned", JsonConvert.SerializeObject(new
{
username = SaveSystem.CurrentSave.Username
username = SaveSystem.CurrentUser.Username
}));
ShowCreateShop();
}
@ -176,6 +177,42 @@ namespace ShiftOS.WinForms.Applications
};
}
internal void ShowClasses()
{
var descriptions = new Dictionary<UserClass, string> {
{ UserClass.Skinner, "Skinners, otherwise known as \"Shifters\" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints." },
{ UserClass.Hacker, "Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target." },
{ UserClass.Investigator, "Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations."},
{ UserClass.Explorer, "Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent."},
{ UserClass.SafetyActivist, "Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe." },
{ UserClass.PenetrationTester, "Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful." },
{ UserClass.Collector, "Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints." },
{UserClass.Programmer, "Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions." },
};
lbclasses.Items.Clear();
lbclasses.SelectedIndexChanged += (o, a) =>
{
newClass = (UserClass)Enum.Parse(typeof(UserClass), lbclasses.SelectedItem.ToString());
lbclassdesc.Text = descriptions[newClass];
lbclasstitle.Text = newClass.ToString();
};
foreach (var kv in descriptions)
{
lbclasses.Items.Add(kv.Key.ToString());
}
menuStrip1.Hide();
pnlclasses.Show();
pnlclasses.BringToFront();
}
UserClass newClass = UserClass.None;
public void ListAllChats(Channel[] channels)
{
shop_all.BringToFront();
@ -237,9 +274,10 @@ namespace ShiftOS.WinForms.Applications
}
[Obsolete("MUD control center is dying! KILL IT!")]
public void OpenChat(string id)
{
AppearanceManager.SetupWindow(new Chat(id));
// AppearanceManager.SetupWindow(new Chat(id));
}
private Shop editingShop = null;
@ -252,7 +290,7 @@ namespace ShiftOS.WinForms.Applications
creatingShop = true;
editingShop.Name = "My shop";
editingShop.Description = "My shop has lots of awesome items. You should buy from my shop.";
editingShop.Owner = SaveSystem.CurrentSave.Username;
editingShop.Owner = SaveSystem.CurrentUser.Username;
editingShop.Items = new List<ShopItem>();
shop_editor.BringToFront();
PopulateShopEditor();
@ -364,7 +402,7 @@ namespace ShiftOS.WinForms.Applications
lbprice.Text = $"Cost: {item.Cost} CP";
btnbuy.Show();
};
if(shop.Owner == SaveSystem.CurrentSave.Username)
if(shop.Owner == SaveSystem.CurrentUser.Username)
{
btneditshop.Show();
}
@ -522,7 +560,7 @@ namespace ShiftOS.WinForms.Applications
you_systemstatus.BringToFront();
lblsysstatus.Text = $@"Username: {SaveSystem.CurrentSave.Username}
lblsysstatus.Text = $@"Username: {SaveSystem.CurrentUser.Username}
System name: {SaveSystem.CurrentSave.SystemName}
Codepoints: {SaveSystem.CurrentSave.Codepoints}
@ -532,6 +570,8 @@ System version: {SaveSystem.CurrentSave.MajorVersion}.{SaveSystem.CurrentSave.Mi
Shared scripts: {scripts}
Reputation: {SaveSystem.CurrentSave.RawReputation} ({SaveSystem.CurrentSave.Reputation})
Current legions: {legionname}";
}
@ -551,7 +591,7 @@ Current legions: {legionname}";
private void tsMemos_Click(object sender, EventArgs e)
{
ServerManager.SendMessage("get_memos_for_user", $@"{{
username: ""{SaveSystem.CurrentSave.Username}""
username: ""{SaveSystem.CurrentUser.Username}""
}}");
you_memos.BringToFront();
}
@ -603,6 +643,11 @@ Current legions: {legionname}";
ServerManager.SendMessage("legion_get_all", "");
}
public void ShowLegionSelector()
{
ServerManager.SendMessage("legion_get_all", "");
}
private void btnjoinlegion_Click(object sender, EventArgs e)
{
string shortname = lblegiontitle.Text.Split(']')[0].Remove(0, 1);
@ -611,8 +656,12 @@ Current legions: {legionname}";
SaveSystem.SaveGame();
ServerManager.SendMessage("user_get_legion", JsonConvert.SerializeObject(SaveSystem.CurrentSave));
LegionChanged?.Invoke();
}
public event Action LegionChanged;
private void btnleavelegion_Click(object sender, EventArgs e)
{
string shortname = lblegiontitle.Text.Split(']')[0].Remove(0, 1);
@ -763,7 +812,7 @@ Current legions: {legionname}";
{
ServerManager.SendMessage("user_shop_check", JsonConvert.SerializeObject(new
{
username = SaveSystem.CurrentSave.Username
username = SaveSystem.CurrentUser.Username
}));
}
@ -846,7 +895,7 @@ Current legions: {legionname}";
private void myShopToolStripMenuItem_Click(object sender, EventArgs e)
{
ServerManager.SendMessage("user_get_shop", SaveSystem.CurrentSave.Username);
ServerManager.SendMessage("user_get_shop", SaveSystem.CurrentUser.Username);
}
private void btneditshop_Click(object sender, EventArgs e)
@ -874,7 +923,7 @@ Current legions: {legionname}";
{
ServerManager.SendMessage("delete_save", JsonConvert.SerializeObject(new ClientSave
{
Username = SaveSystem.CurrentSave.Username,
Username = SaveSystem.CurrentUser.Username,
Password = SaveSystem.CurrentSave.Password
}));
@ -889,5 +938,21 @@ Current legions: {legionname}";
}
});
}
public event Action ClassChanged;
private void btnchooseclass_Click(object sender, EventArgs e)
{
if(newClass != UserClass.None)
{
SaveSystem.CurrentSave.Class = newClass;
SaveSystem.SaveGame();
ClassChanged?.Invoke();
menuStrip1.Show();
pnlclasses.SendToBack();
this.SetupSystemStatus();
return;
}
}
}
}

View file

@ -38,8 +38,9 @@ using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications {
[Launcher("Name Changer", true, "al_name_changer", "Customization")]
[RequiresUpgrade("name_changer")]
[MultiplayerOnly]
[Launcher("Name Changer", false, null, "Customization")]
[AppscapeEntry("Name Changer", "Want to change the names of applications within ShiftOS? This application lets you do just that.", 342, 500, "skinning;file_skimmer;wm_titlebar", "Customization")]
[WinOpen("name_changer")]
[DefaultTitle("Name Changer")]
[DefaultIcon("iconNameChanger")]

View file

@ -79,6 +79,19 @@ namespace ShiftOS.WinForms.Applications
this.tmrcountdown = new System.Windows.Forms.Timer(this.components);
this.tmrstoryline = new System.Windows.Forms.Timer(this.components);
this.pgcontents = new ShiftOS.WinForms.Controls.Canvas();
this.pnlmultiplayerhandshake = new System.Windows.Forms.Panel();
this.lvotherplayers = new System.Windows.Forms.ListView();
this.lbmpstatus = new System.Windows.Forms.Label();
this.pnlintro = new System.Windows.Forms.Panel();
this.btnmatchmake = new System.Windows.Forms.Button();
this.Label6 = new System.Windows.Forms.Label();
this.btnstartgame = new System.Windows.Forms.Button();
this.Label8 = new System.Windows.Forms.Label();
this.pnlhighscore = new System.Windows.Forms.Panel();
this.lbhighscore = new System.Windows.Forms.ListView();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.button2 = new System.Windows.Forms.Button();
this.label10 = new System.Windows.Forms.Label();
this.pnlgamestats = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.label12 = new System.Windows.Forms.Label();
@ -91,9 +104,6 @@ namespace ShiftOS.WinForms.Applications
this.btncashout = new System.Windows.Forms.Button();
this.Label2 = new System.Windows.Forms.Label();
this.lbllevelreached = new System.Windows.Forms.Label();
this.pnlhighscore = new System.Windows.Forms.Panel();
this.lbhighscore = new System.Windows.Forms.ListBox();
this.label10 = new System.Windows.Forms.Label();
this.pnlfinalstats = new System.Windows.Forms.Panel();
this.btnplayagain = new System.Windows.Forms.Button();
this.lblfinalcodepoints = new System.Windows.Forms.Label();
@ -109,10 +119,6 @@ namespace ShiftOS.WinForms.Applications
this.btnlosetryagain = new System.Windows.Forms.Button();
this.Label5 = new System.Windows.Forms.Label();
this.Label1 = new System.Windows.Forms.Label();
this.pnlintro = new System.Windows.Forms.Panel();
this.Label6 = new System.Windows.Forms.Label();
this.btnstartgame = new System.Windows.Forms.Button();
this.Label8 = new System.Windows.Forms.Label();
this.lblbeatai = new System.Windows.Forms.Label();
this.lblcountdown = new System.Windows.Forms.Label();
this.ball = new ShiftOS.WinForms.Controls.Canvas();
@ -122,16 +128,15 @@ namespace ShiftOS.WinForms.Applications
this.lblstatscodepoints = new System.Windows.Forms.Label();
this.lblstatsY = new System.Windows.Forms.Label();
this.lblstatsX = new System.Windows.Forms.Label();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.button2 = new System.Windows.Forms.Button();
this.pgcontents.SuspendLayout();
this.pnlgamestats.SuspendLayout();
this.pnlmultiplayerhandshake.SuspendLayout();
this.pnlintro.SuspendLayout();
this.pnlhighscore.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.pnlgamestats.SuspendLayout();
this.pnlfinalstats.SuspendLayout();
this.pnllose.SuspendLayout();
this.pnlintro.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// gameTimer
@ -157,11 +162,12 @@ namespace ShiftOS.WinForms.Applications
// pgcontents
//
this.pgcontents.BackColor = System.Drawing.Color.White;
this.pgcontents.Controls.Add(this.pnlmultiplayerhandshake);
this.pgcontents.Controls.Add(this.pnlintro);
this.pgcontents.Controls.Add(this.pnlhighscore);
this.pgcontents.Controls.Add(this.pnlgamestats);
this.pgcontents.Controls.Add(this.pnlfinalstats);
this.pgcontents.Controls.Add(this.pnllose);
this.pgcontents.Controls.Add(this.pnlintro);
this.pgcontents.Controls.Add(this.lblbeatai);
this.pgcontents.Controls.Add(this.lblcountdown);
this.pgcontents.Controls.Add(this.ball);
@ -174,11 +180,155 @@ namespace ShiftOS.WinForms.Applications
this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill;
this.pgcontents.Location = new System.Drawing.Point(0, 0);
this.pgcontents.Name = "pgcontents";
this.pgcontents.Size = new System.Drawing.Size(700, 400);
this.pgcontents.Size = new System.Drawing.Size(912, 504);
this.pgcontents.TabIndex = 20;
this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint);
this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove);
//
// pnlmultiplayerhandshake
//
this.pnlmultiplayerhandshake.Controls.Add(this.lvotherplayers);
this.pnlmultiplayerhandshake.Controls.Add(this.lbmpstatus);
this.pnlmultiplayerhandshake.Location = new System.Drawing.Point(446, 88);
this.pnlmultiplayerhandshake.Name = "pnlmultiplayerhandshake";
this.pnlmultiplayerhandshake.Size = new System.Drawing.Size(396, 231);
this.pnlmultiplayerhandshake.TabIndex = 15;
this.pnlmultiplayerhandshake.Visible = false;
//
// lvotherplayers
//
this.lvotherplayers.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvotherplayers.Location = new System.Drawing.Point(0, 45);
this.lvotherplayers.MultiSelect = false;
this.lvotherplayers.Name = "lvotherplayers";
this.lvotherplayers.Size = new System.Drawing.Size(396, 186);
this.lvotherplayers.TabIndex = 1;
this.lvotherplayers.UseCompatibleStateImageBehavior = false;
this.lvotherplayers.View = System.Windows.Forms.View.Details;
this.lvotherplayers.DoubleClick += new System.EventHandler(this.lvotherplayers_DoubleClick);
//
// lbmpstatus
//
this.lbmpstatus.Dock = System.Windows.Forms.DockStyle.Top;
this.lbmpstatus.Location = new System.Drawing.Point(0, 0);
this.lbmpstatus.Name = "lbmpstatus";
this.lbmpstatus.Size = new System.Drawing.Size(396, 45);
this.lbmpstatus.TabIndex = 0;
this.lbmpstatus.Tag = "header2";
this.lbmpstatus.Text = "Waiting for other players...";
this.lbmpstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// pnlintro
//
this.pnlintro.Controls.Add(this.btnmatchmake);
this.pnlintro.Controls.Add(this.Label6);
this.pnlintro.Controls.Add(this.btnstartgame);
this.pnlintro.Controls.Add(this.Label8);
this.pnlintro.Location = new System.Drawing.Point(0, 0);
this.pnlintro.Name = "pnlintro";
this.pnlintro.Size = new System.Drawing.Size(595, 303);
this.pnlintro.TabIndex = 13;
this.pnlintro.Tag = "header2";
//
// btnmatchmake
//
this.btnmatchmake.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnmatchmake.Location = new System.Drawing.Point(188, 253);
this.btnmatchmake.Name = "btnmatchmake";
this.btnmatchmake.Size = new System.Drawing.Size(242, 28);
this.btnmatchmake.TabIndex = 16;
this.btnmatchmake.Text = "Or, play against another Shifter!";
this.btnmatchmake.UseVisualStyleBackColor = true;
this.btnmatchmake.Click += new System.EventHandler(this.btnmatchmake_Click);
//
// Label6
//
this.Label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Label6.Location = new System.Drawing.Point(3, 39);
this.Label6.Name = "Label6";
this.Label6.Size = new System.Drawing.Size(589, 159);
this.Label6.TabIndex = 15;
this.Label6.Text = "{PONG_DESC}";
this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.Label6.Click += new System.EventHandler(this.Label6_Click);
//
// btnstartgame
//
this.btnstartgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnstartgame.Location = new System.Drawing.Point(188, 215);
this.btnstartgame.Name = "btnstartgame";
this.btnstartgame.Size = new System.Drawing.Size(242, 28);
this.btnstartgame.TabIndex = 15;
this.btnstartgame.Text = "{PLAY}";
this.btnstartgame.UseVisualStyleBackColor = true;
this.btnstartgame.Click += new System.EventHandler(this.btnstartgame_Click);
//
// Label8
//
this.Label8.AutoSize = true;
this.Label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Label8.ForeColor = System.Drawing.Color.Black;
this.Label8.Location = new System.Drawing.Point(250, 5);
this.Label8.Name = "Label8";
this.Label8.Size = new System.Drawing.Size(280, 31);
this.Label8.TabIndex = 14;
this.Label8.Text = "{PONG_WELCOME}";
this.Label8.Click += new System.EventHandler(this.Label8_Click);
//
// pnlhighscore
//
this.pnlhighscore.Controls.Add(this.lbhighscore);
this.pnlhighscore.Controls.Add(this.flowLayoutPanel1);
this.pnlhighscore.Controls.Add(this.label10);
this.pnlhighscore.Location = new System.Drawing.Point(688, 302);
this.pnlhighscore.Name = "pnlhighscore";
this.pnlhighscore.Size = new System.Drawing.Size(539, 311);
this.pnlhighscore.TabIndex = 14;
this.pnlhighscore.Visible = false;
//
// lbhighscore
//
this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbhighscore.Location = new System.Drawing.Point(0, 36);
this.lbhighscore.Name = "lbhighscore";
this.lbhighscore.Size = new System.Drawing.Size(539, 246);
this.lbhighscore.TabIndex = 1;
this.lbhighscore.UseCompatibleStateImageBehavior = false;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel1.Controls.Add(this.button2);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29);
this.flowLayoutPanel1.TabIndex = 2;
//
// button2
//
this.button2.AutoSize = true;
this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.button2.Location = new System.Drawing.Point(476, 3);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(60, 23);
this.button2.TabIndex = 0;
this.button2.Text = "{CLOSE}";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label10
//
this.label10.Dock = System.Windows.Forms.DockStyle.Top;
this.label10.Location = new System.Drawing.Point(0, 0);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(539, 36);
this.label10.TabIndex = 0;
this.label10.Text = "{HIGH_SCORES}";
this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// pnlgamestats
//
this.pnlgamestats.Controls.Add(this.button1);
@ -192,7 +342,7 @@ namespace ShiftOS.WinForms.Applications
this.pnlgamestats.Controls.Add(this.btncashout);
this.pnlgamestats.Controls.Add(this.Label2);
this.pnlgamestats.Controls.Add(this.lbllevelreached);
this.pnlgamestats.Location = new System.Drawing.Point(56, 76);
this.pnlgamestats.Location = new System.Drawing.Point(104, 375);
this.pnlgamestats.Name = "pnlgamestats";
this.pnlgamestats.Size = new System.Drawing.Size(466, 284);
this.pnlgamestats.TabIndex = 6;
@ -307,38 +457,6 @@ namespace ShiftOS.WinForms.Applications
this.lbllevelreached.TabIndex = 0;
this.lbllevelreached.Text = "You Reached Level 2!";
//
// pnlhighscore
//
this.pnlhighscore.Controls.Add(this.lbhighscore);
this.pnlhighscore.Controls.Add(this.flowLayoutPanel1);
this.pnlhighscore.Controls.Add(this.label10);
this.pnlhighscore.Location = new System.Drawing.Point(67, 29);
this.pnlhighscore.Name = "pnlhighscore";
this.pnlhighscore.Size = new System.Drawing.Size(539, 311);
this.pnlhighscore.TabIndex = 14;
this.pnlhighscore.Visible = false;
//
// lbhighscore
//
this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbhighscore.FormattingEnabled = true;
this.lbhighscore.Location = new System.Drawing.Point(0, 36);
this.lbhighscore.MultiColumn = true;
this.lbhighscore.Name = "lbhighscore";
this.lbhighscore.SelectionMode = System.Windows.Forms.SelectionMode.None;
this.lbhighscore.Size = new System.Drawing.Size(539, 246);
this.lbhighscore.TabIndex = 1;
//
// label10
//
this.label10.Dock = System.Windows.Forms.DockStyle.Top;
this.label10.Location = new System.Drawing.Point(0, 0);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(539, 36);
this.label10.TabIndex = 0;
this.label10.Text = "{HIGH_SCORES}";
this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// pnlfinalstats
//
this.pnlfinalstats.Controls.Add(this.btnplayagain);
@ -373,6 +491,7 @@ namespace ShiftOS.WinForms.Applications
this.lblfinalcodepoints.Name = "lblfinalcodepoints";
this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73);
this.lblfinalcodepoints.TabIndex = 15;
this.lblfinalcodepoints.Tag = "header1";
this.lblfinalcodepoints.Text = "134 CP";
this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@ -384,6 +503,7 @@ namespace ShiftOS.WinForms.Applications
this.Label11.Name = "Label11";
this.Label11.Size = new System.Drawing.Size(33, 33);
this.Label11.TabIndex = 14;
this.Label11.Tag = "header2";
this.Label11.Text = "+";
this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@ -394,6 +514,7 @@ namespace ShiftOS.WinForms.Applications
this.lblfinalcomputerreward.Name = "lblfinalcomputerreward";
this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52);
this.lblfinalcomputerreward.TabIndex = 12;
this.lblfinalcomputerreward.Tag = "header2";
this.lblfinalcomputerreward.Text = "34";
this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@ -413,6 +534,7 @@ namespace ShiftOS.WinForms.Applications
this.lblfinallevelreward.Name = "lblfinallevelreward";
this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52);
this.lblfinallevelreward.TabIndex = 10;
this.lblfinallevelreward.Tag = "header2";
this.lblfinallevelreward.Text = "100";
this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@ -432,6 +554,7 @@ namespace ShiftOS.WinForms.Applications
this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext";
this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26);
this.lblfinalcodepointswithtext.TabIndex = 1;
this.lblfinalcodepointswithtext.Tag = "header2";
this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!";
this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
@ -497,50 +620,6 @@ namespace ShiftOS.WinForms.Applications
this.Label1.Text = "You lose!";
this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// pnlintro
//
this.pnlintro.Controls.Add(this.Label6);
this.pnlintro.Controls.Add(this.btnstartgame);
this.pnlintro.Controls.Add(this.Label8);
this.pnlintro.Location = new System.Drawing.Point(52, 29);
this.pnlintro.Name = "pnlintro";
this.pnlintro.Size = new System.Drawing.Size(595, 303);
this.pnlintro.TabIndex = 13;
//
// Label6
//
this.Label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Label6.Location = new System.Drawing.Point(3, 39);
this.Label6.Name = "Label6";
this.Label6.Size = new System.Drawing.Size(589, 227);
this.Label6.TabIndex = 15;
this.Label6.Text = "{PONG_DESC}";
this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.Label6.Click += new System.EventHandler(this.Label6_Click);
//
// btnstartgame
//
this.btnstartgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnstartgame.Location = new System.Drawing.Point(186, 273);
this.btnstartgame.Name = "btnstartgame";
this.btnstartgame.Size = new System.Drawing.Size(242, 28);
this.btnstartgame.TabIndex = 15;
this.btnstartgame.Text = "{PLAY}";
this.btnstartgame.UseVisualStyleBackColor = true;
this.btnstartgame.Click += new System.EventHandler(this.btnstartgame_Click);
//
// Label8
//
this.Label8.AutoSize = true;
this.Label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Label8.ForeColor = System.Drawing.Color.Black;
this.Label8.Location = new System.Drawing.Point(250, 5);
this.Label8.Name = "Label8";
this.Label8.Size = new System.Drawing.Size(280, 31);
this.Label8.TabIndex = 14;
this.Label8.Text = "{PONG_WELCOME}";
this.Label8.Click += new System.EventHandler(this.Label8_Click);
//
// lblbeatai
//
this.lblbeatai.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -548,6 +627,7 @@ namespace ShiftOS.WinForms.Applications
this.lblbeatai.Name = "lblbeatai";
this.lblbeatai.Size = new System.Drawing.Size(600, 30);
this.lblbeatai.TabIndex = 8;
this.lblbeatai.Tag = "header2";
this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!";
this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblbeatai.Visible = false;
@ -577,7 +657,6 @@ namespace ShiftOS.WinForms.Applications
//
this.paddleHuman.BackColor = System.Drawing.Color.Black;
this.paddleHuman.Location = new System.Drawing.Point(10, 134);
this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150);
this.paddleHuman.Name = "paddleHuman";
this.paddleHuman.Size = new System.Drawing.Size(20, 100);
this.paddleHuman.TabIndex = 3;
@ -587,7 +666,7 @@ namespace ShiftOS.WinForms.Applications
//
this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.paddleComputer.BackColor = System.Drawing.Color.Black;
this.paddleComputer.Location = new System.Drawing.Point(666, 134);
this.paddleComputer.Location = new System.Drawing.Point(878, 134);
this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150);
this.paddleComputer.Name = "paddleComputer";
this.paddleComputer.Size = new System.Drawing.Size(20, 100);
@ -599,69 +678,52 @@ namespace ShiftOS.WinForms.Applications
this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbllevelandtime.Location = new System.Drawing.Point(0, 0);
this.lbllevelandtime.Name = "lbllevelandtime";
this.lbllevelandtime.Size = new System.Drawing.Size(700, 22);
this.lbllevelandtime.Size = new System.Drawing.Size(912, 22);
this.lbllevelandtime.TabIndex = 4;
this.lbllevelandtime.Tag = "header1";
this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left";
this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblstatscodepoints
//
this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblstatscodepoints.AutoSize = true;
this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblstatscodepoints.Location = new System.Drawing.Point(239, 356);
this.lblstatscodepoints.Location = new System.Drawing.Point(239, 460);
this.lblstatscodepoints.Name = "lblstatscodepoints";
this.lblstatscodepoints.Size = new System.Drawing.Size(219, 35);
this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23);
this.lblstatscodepoints.TabIndex = 12;
this.lblstatscodepoints.Tag = "header2";
this.lblstatscodepoints.Text = "Codepoints: ";
this.lblstatscodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblstatsY
//
this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.lblstatsY.AutoSize = true;
this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblstatsY.Location = new System.Drawing.Point(542, 356);
this.lblstatsY.Location = new System.Drawing.Point(440, 460);
this.lblstatsY.Name = "lblstatsY";
this.lblstatsY.Size = new System.Drawing.Size(144, 35);
this.lblstatsY.Size = new System.Drawing.Size(76, 23);
this.lblstatsY.TabIndex = 11;
this.lblstatsY.Tag = "header2";
this.lblstatsY.Text = "Yspeed:";
this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblstatsX
//
this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblstatsX.AutoSize = true;
this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblstatsX.Location = new System.Drawing.Point(3, 356);
this.lblstatsX.Location = new System.Drawing.Point(3, 460);
this.lblstatsX.Name = "lblstatsX";
this.lblstatsX.Size = new System.Drawing.Size(144, 35);
this.lblstatsX.Size = new System.Drawing.Size(83, 23);
this.lblstatsX.TabIndex = 5;
this.lblstatsX.Tag = "header2";
this.lblstatsX.Text = "Xspeed: ";
this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel1.Controls.Add(this.button2);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29);
this.flowLayoutPanel1.TabIndex = 2;
//
// button2
//
this.button2.AutoSize = true;
this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.button2.Location = new System.Drawing.Point(476, 3);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(60, 23);
this.button2.TabIndex = 0;
this.button2.Text = "{CLOSE}";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Pong
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -670,23 +732,24 @@ namespace ShiftOS.WinForms.Applications
this.Controls.Add(this.pgcontents);
this.DoubleBuffered = true;
this.Name = "Pong";
this.Text = "{PONG_NAME}";
this.Size = new System.Drawing.Size(820, 500);
this.Size = new System.Drawing.Size(912, 504);
this.Load += new System.EventHandler(this.Pong_Load);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove);
this.pgcontents.ResumeLayout(false);
this.pnlgamestats.ResumeLayout(false);
this.pnlgamestats.PerformLayout();
this.pgcontents.PerformLayout();
this.pnlmultiplayerhandshake.ResumeLayout(false);
this.pnlintro.ResumeLayout(false);
this.pnlintro.PerformLayout();
this.pnlhighscore.ResumeLayout(false);
this.pnlhighscore.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.pnlgamestats.ResumeLayout(false);
this.pnlgamestats.PerformLayout();
this.pnlfinalstats.ResumeLayout(false);
this.pnlfinalstats.PerformLayout();
this.pnllose.ResumeLayout(false);
this.pnlintro.ResumeLayout(false);
this.pnlintro.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit();
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
@ -732,7 +795,7 @@ namespace ShiftOS.WinForms.Applications
internal System.Windows.Forms.Label Label8;
internal System.Windows.Forms.Timer tmrstoryline;
private System.Windows.Forms.Panel pnlhighscore;
private System.Windows.Forms.ListBox lbhighscore;
private System.Windows.Forms.ListView lbhighscore;
private System.Windows.Forms.Label label10;
internal Canvas pgcontents;
internal Canvas ball;
@ -740,5 +803,9 @@ namespace ShiftOS.WinForms.Applications
internal System.Windows.Forms.Label label12;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Button button2;
internal System.Windows.Forms.Button btnmatchmake;
private System.Windows.Forms.Panel pnlmultiplayerhandshake;
private System.Windows.Forms.ListView lvotherplayers;
private System.Windows.Forms.Label lbmpstatus;
}
}

View file

@ -29,14 +29,17 @@ using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using ShiftOS.Engine;
using ShiftOS.Objects;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("Pong", true, "al_pong", "Games")]
[WinOpen("pong")]
[DefaultIcon("iconPong")]
@ -79,9 +82,51 @@ namespace ShiftOS.WinForms.Applications
private void pongMain_MouseMove(object sender, MouseEventArgs e)
{
var loc = this.PointToClient(MousePosition);
paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2));
if (IsMultiplayerSession)
{
if (IsLeader)
{
paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2));
ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleHuman.Top.ToString());
}
else
{
paddleComputer.Location = new Point(paddleComputer.Location.X, (loc.Y) - (paddleComputer.Height / 2));
ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleComputer.Top.ToString());
}
}
else
{
paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2));
}
}
private void CenterPanels()
{
pnlfinalstats.CenterParent();
pnlgamestats.CenterParent();
pnlhighscore.CenterParent();
pnlintro.CenterParent();
pnllose.CenterParent();
lblcountdown.CenterParent();
lblbeatai.Left = (this.Width - lblbeatai.Width) / 2;
SetupStats();
}
public void SetupStats()
{
lblstatsX.Location = new Point(5, this.Height - lblstatsX.Height - 5);
lblstatsY.Location = new Point(this.Width - lblstatsY.Width - 5, this.Height - lblstatsY.Height - 5);
lblstatscodepoints.Top = this.Height - lblstatscodepoints.Height - 5;
lblstatscodepoints.Left = (this.Width - lblstatscodepoints.Width) / 2;
}
int OpponentY = 0;
bool IsLeader = true;
int LeaderX = 0;
int LeaderY = 0;
// ERROR: Handles clauses are not supported in C#
private void gameTimer_Tick(object sender, EventArgs e)
@ -93,40 +138,52 @@ namespace ShiftOS.WinForms.Applications
paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor;
//Check if paddle upgrade has been bought and change paddles accordingly
if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size"))
{
paddleHuman.Height = 150;
paddleComputer.Height = 150;
}
//if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size"))
//{
// paddleHuman.Height = 150;
// paddleComputer.Height = 150;
//}
//I don't know the point of this but I'm fucking 86ing it. - Michael
//Set the computer player to move according to the ball's position.
if (aiShouldIsbeEnabled)
if (ball.Location.X > 500 - xVel * 10 && xVel > 0)
{
if (ball.Location.Y > paddleComputer.Location.Y + 50)
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed);
}
if (ball.Location.Y < paddleComputer.Location.Y + 50)
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed);
}
casualposition = rand.Next(-150, 201);
}
if (IsMultiplayerSession == true)
{
//If we're multiplayer, then we want to set the computer Y to the opponent's Y.
//If we're the leader, we set the AI paddle, else we set the player paddle.
if (IsLeader)
paddleComputer.Top = OpponentY;
else
{
//used to be me.location.y
if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition)
paddleHuman.Top = OpponentY;
}
else
{
if (aiShouldIsbeEnabled)
if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0)
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed);
if (ball.Location.Y > paddleComputer.Location.Y + 50)
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed);
}
if (ball.Location.Y < paddleComputer.Location.Y + 50)
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed);
}
casualposition = rand.Next(-150, 201);
}
//used to be me.location.y
if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition)
else
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed);
//used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael
if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition)
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed);
}
//Rylan is hot. Used to be //used to be me.location.y
if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition)
{
paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed);
}
}
}
}
//Set Xvel and Yvel speeds from decimal
if (xVel > 0)
xVel = (int)Math.Round(xveldec);
@ -137,148 +194,455 @@ namespace ShiftOS.WinForms.Applications
if (yVel < 0)
yVel = (int)-Math.Round(yveldec);
// Move the game ball.
ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel);
bool BallPhysics = true;
// Check for top wall.
if (ball.Location.Y < 0)
if (IsMultiplayerSession)
{
ball.Location = new Point(ball.Location.X, 0);
yVel = -yVel;
}
// Check for bottom wall.
if (ball.Location.Y > pgcontents.Height - ball.Height)
{
ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height);
yVel = -yVel;
}
// Check for player paddle.
if (ball.Bounds.IntersectsWith(paddleHuman.Bounds))
{
ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width, ball.Location.Y);
//randomly increase x or y speed of ball
switch (rand.Next(1, 3))
//Logic for moving the ball in Multiplayer.
if (IsLeader)
{
case 1:
xveldec = xveldec + incrementx;
break;
case 2:
if (yveldec > 0)
yveldec = yveldec + incrementy;
if (yveldec < 0)
yveldec = yveldec - incrementy;
break;
ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel);
}
else
{
//Move it to the leader's ball position.
ball.Location = new Point(LeaderX, LeaderY);
BallPhysics = false;
}
}
else
{// Move the game ball.
ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel);
}
if (BallPhysics)
{
// Check for top wall.
if (ball.Location.Y < 0)
{
ball.Location = new Point(ball.Location.X, 0);
yVel = -yVel;
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
}
// Check for bottom wall.
if (ball.Location.Y > pgcontents.Height - ball.Height)
{
ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height);
yVel = -yVel;
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
}
// Check for player paddle.
if (ball.Bounds.IntersectsWith(paddleHuman.Bounds))
{
ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width + 1, ball.Location.Y);
//randomly increase x or y speed of ball
switch (rand.Next(1, 3))
{
case 1:
xveldec = xveldec + incrementx;
break;
case 2:
if (yveldec > 0)
yveldec = yveldec + incrementy;
if (yveldec < 0)
yveldec = yveldec - incrementy;
break;
}
xVel = -xVel;
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound);
}
// Check for computer paddle.
if (ball.Bounds.IntersectsWith(paddleComputer.Bounds))
{
ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width - 1, ball.Location.Y);
xveldec = xveldec + incrementx;
xVel = -xVel;
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound);
}
xVel = -xVel;
}
// Check for computer paddle.
if (ball.Bounds.IntersectsWith(paddleComputer.Bounds))
{
ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width + 1, ball.Location.Y);
xveldec = xveldec + incrementx;
xVel = -xVel;
}
// Check for left wall.
if (ball.Location.X < -100)
{
ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2);
paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y);
if (xVel > 0)
xVel = -xVel;
pnllose.Show();
gameTimer.Stop();
counter.Stop();
lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}");
if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2"))
//If we are in multiplayer, and not the leader, we won.
if (IsMultiplayerSession)
{
totalreward = levelrewards[level - 1] + beatairewardtotal;
double onePercent = (totalreward / 100);
lblbutyougained.Show();
lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}"));
SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100));
if (IsLeader)
{
//We lost.
NotifyLoseToTarget();
}
else
{
//We won.
NotifyWinToTarget();
Win();
}
}
else
{
lblbutyougained.Hide();
ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2);
paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y);
if (xVel > 0)
xVel = -xVel;
pnllose.Show();
gameTimer.Stop();
counter.Stop();
lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}");
if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2"))
{
totalreward = levelrewards[level - 1] + beatairewardtotal;
double onePercent = (totalreward / 100);
lblbutyougained.Show();
lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}"));
SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100));
}
else
{
lblbutyougained.Hide();
}
}
}
// Check for right wall.
if (ball.Location.X > this.Width - ball.Size.Width - paddleComputer.Width + 100)
{
ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2);
paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y);
if (xVel > 0)
xVel = -xVel;
beatairewardtotal = beatairewardtotal + beataireward;
lblbeatai.Show();
lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD_SECONDARY}}: {beataireward}");
tmrcountdown.Start();
gameTimer.Stop();
counter.Stop();
if (IsMultiplayerSession)
{
//If we are the leader we won.
if (IsLeader)
{
NotifyWinToTarget();
Win();
}
else
{
NotifyLoseToTarget();
}
}
else
{
Win();
}
}
//lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy
lblstatsX.Text = Localization.Parse("{H_VEL}: ") + xveldec;
lblstatsY.Text = Localization.Parse("{V_VEL}: ") + yveldec;
lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString();
lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}");
if (xVel > 20 || xVel < -20)
if (IsMultiplayerSession)
{
paddleHuman.Width = Math.Abs(xVel);
paddleComputer.Width = Math.Abs(xVel);
if (IsLeader)
{
ServerManager.Forward(OpponentGUID, "pong_mp_setballpos", JsonConvert.SerializeObject(ball.Location));
}
}
else
if (IsLeader)
{
paddleHuman.Width = 20;
paddleComputer.Width = 20;
//lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy
lblstatsX.Text = "X vel: " + xveldec;
lblstatsY.Text = "Y vel: " + yveldec;
lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString();
lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " seconds left";
if (xVel > 20 || xVel < -20)
{
paddleHuman.Width = Math.Abs(xVel);
paddleComputer.Width = Math.Abs(xVel);
}
else
{
paddleHuman.Width = 20;
paddleComputer.Width = 20;
}
}
if (!IsMultiplayerSession)
{
computerspeed = Math.Abs(yVel);
}
computerspeed = Math.Abs(yVel);
// pgcontents.Refresh()
// pgcontents.CreateGraphics.FillRectangle(Brushes.Black, ball.Location.X, ball.Location.Y, ball.Width, ball.Height)
}
}
public void ServerMessageReceivedHandler(ServerMessage msg)
{
if (IsMultiplayerSession)
{
if (msg.Name == "pong_mp_setballpos")
{
var pt = JsonConvert.DeserializeObject<Point>(msg.Contents);
LeaderX = pt.X;
LeaderY = pt.Y;
}
else if (msg.Name == "pong_mp_left")
{
this.Invoke(new Action(() =>
{
AppearanceManager.Close(this);
}));
Infobox.Show("Opponent has closed Pong.", "The opponent has closed Pong, therefore the connection between you two has dropped.");
}
else if (msg.Name == "pong_mp_youlose")
{
this.Invoke(new Action(LoseMP));
}
else if (msg.Name == "pong_mp_setopponenty")
{
int y = Convert.ToInt32(msg.Contents);
OpponentY = y;
}
else if (msg.Name == "pong_handshake_matchmake")
{
if (!PossibleMatchmakes.Contains(msg.Contents))
PossibleMatchmakes.Add(msg.Contents);
this.Invoke(new Action(ListMatchmakes));
}
else if (msg.Name == "pong_handshake_resendid")
{
ServerManager.Forward("all", "pong_handshake_matchmake", YouGUID);
}
else if (msg.Name == "pong_handshake_complete")
{
IsLeader = true;
OpponentGUID = msg.Contents;
LeaveMatchmake();
this.Invoke(new Action(() =>
{
pnlmultiplayerhandshake.Hide();
StartLevel();
}));
}
else if(msg.Name == "pong_mp_levelcompleted")
{
level = Convert.ToInt32(msg.Contents) + 1;
this.Invoke(new Action(CompleteLevel));
}
else if (msg.Name == "pong_handshake_chosen")
{
IsLeader = false;
LeaveMatchmake();
OpponentGUID = msg.Contents;
YouGUID = ServerManager.thisGuid.ToString();
//Start the timers.
counter.Start();
SendFollowerGUID();
this.Invoke(new Action(() =>
{
pnlmultiplayerhandshake.Hide();
}));
}
else if(msg.Name == "pong_mp_cashedout")
{
this.Invoke(new Action(() =>
{
btncashout_Click(this, EventArgs.Empty);
}));
Infobox.Show("Cashed out.", "The other player has cashed out their Codepoints. Therefore, we have automatically cashed yours out.");
}
else if(msg.Name == "pong_mp_startlevel")
{
OpponentAgrees = true;
if(YouAgree == false)
{
Infobox.PromptYesNo("Play another level?", "The opponent wants to play another level. Would you like to as well?", (answer)=>
{
YouAgree = answer;
ServerManager.Forward(OpponentGUID, "pong_mp_level_callback", YouAgree.ToString());
});
}
}
else if(msg.Name == "pong_mp_level_callback")
{
bool agreed = bool.Parse(msg.Contents);
OpponentAgrees = agreed;
if (OpponentAgrees)
{
if (IsLeader)
{
//this.Invoke(new Action(()))
}
}
}
else if (msg.Name == "pong_handshake_left")
{
if (this.PossibleMatchmakes.Contains(msg.Contents))
this.PossibleMatchmakes.Remove(msg.Contents);
this.Invoke(new Action(ListMatchmakes));
}
else if(msg.Name == "pong_mp_clockupdate")
{
secondsleft = Convert.ToInt32(msg.Contents);
}
else if (msg.Name == "pong_mp_youwin")
{
this.Invoke(new Action(Win));
}
}
}
bool OpponentAgrees = false;
bool YouAgree = false;
public void ListMatchmakes()
{
lvotherplayers.Items.Clear();
var c = new ColumnHeader();
c.Width = lvotherplayers.Width;
c.Text = "Player";
lvotherplayers.Columns.Clear();
lvotherplayers.Columns.Add(c);
lvotherplayers.FullRowSelect = true;
foreach (var itm in PossibleMatchmakes)
{
if (itm != YouGUID)
{
var l = new ListViewItem();
l.Text = itm;
lvotherplayers.Items.Add(l);
}
}
if (PossibleMatchmakes.Count > 0)
{
lbmpstatus.Text = "Select a player.";
}
else
{
lbmpstatus.Text = "Waiting for players...";
}
}
public void NotifyLoseToTarget()
{
ServerManager.Forward(OpponentGUID, "pong_mp_youwin", null);
}
public void NotifyWinToTarget()
{
ServerManager.Forward(OpponentGUID, "pong_mp_youlose", null);
}
public void LeaveMatchmake()
{
ServerManager.Forward("all", "pong_handshake_left", YouGUID);
}
List<string> PossibleMatchmakes = new List<string>();
public void SendLeaderGUID(string target)
{
ServerManager.Forward(target, "pong_handshake_chosen", YouGUID);
}
public void StartMultiplayer()
{
IsMultiplayerSession = true;
YouGUID = ServerManager.thisGuid.ToString();
ServerManager.SendMessage("pong_handshake_matchmake", YouGUID);
StartMatchmake();
}
public void StartMatchmake()
{
pnlmultiplayerhandshake.Show();
pnlmultiplayerhandshake.CenterParent();
pnlmultiplayerhandshake.BringToFront();
ServerManager.Forward("all", "pong_handshake_resendid", null);
}
public void SendFollowerGUID()
{
ServerManager.Forward(OpponentGUID, "pong_handshake_complete", YouGUID);
}
public void LoseMP()
{
ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2);
if(IsLeader)
if (xVel > 0)
xVel = -xVel;
lblbeatai.Show();
lblbeatai.Text = "The opponent has beaten you!";
tmrcountdown.Start();
gameTimer.Stop();
counter.Stop();
}
public void Win()
{
ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2);
paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y);
if (xVel > 0)
xVel = -xVel;
beatairewardtotal = beatairewardtotal + beataireward;
lblbeatai.Show();
lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD_SECONDARY}}: {beataireward}");
tmrcountdown.Start();
gameTimer.Stop();
counter.Stop();
}
public void CompleteLevel()
{
if (SaveSystem.CurrentSave.UniteAuthToken != null)
{
try
{
var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
if (unite.GetPongLevel() < level)
unite.SetPongLevel(level);
}
catch { }
}
//Only set these stats if the user is the leader.
if (IsLeader)
{
secondsleft = 60;
level = level + 1;
generatenextlevel();
}
pnlgamestats.Show();
pnlgamestats.BringToFront();
pnlgamestats.Location = new Point((pgcontents.Width / 2) - (pnlgamestats.Width / 2), (pgcontents.Height / 2) - (pnlgamestats.Height / 2));
counter.Stop();
gameTimer.Stop();
}
// ERROR: Handles clauses are not supported in C#
private void counter_Tick(object sender, EventArgs e)
{
if (this.Left < Screen.PrimaryScreen.Bounds.Width)
if (IsLeader)
{
secondsleft = secondsleft - 1;
if (secondsleft == 1)
if (this.Left < Screen.PrimaryScreen.Bounds.Width)
{
secondsleft = 60;
level = level + 1;
generatenextlevel();
pnlgamestats.Show();
pnlgamestats.BringToFront();
pnlgamestats.Location = new Point((pgcontents.Width / 2) - (pnlgamestats.Width / 2), (pgcontents.Height / 2) - (pnlgamestats.Height / 2));
secondsleft = secondsleft - 1;
if (secondsleft == 0)
{
CompleteLevel();
}
counter.Stop();
gameTimer.Stop();
SendHighscores();
lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString();
}
lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString();
}
SetupStats();
}
[Obsolete("This method does nothing. Use UniteClient for highscore queries.")]
public void SendHighscores()
{
var highscore = new PongHighscore
{
UserName = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}",
HighestLevel = level,
HighestCodepoints = totalreward
};
ServerManager.SendMessage("pong_sethighscore", JsonConvert.SerializeObject(highscore));
}
// ERROR: Handles clauses are not supported in C#
@ -485,15 +849,18 @@ namespace ShiftOS.WinForms.Applications
case 1:
lblcountdown.Text = "1";
countdown = countdown - 1;
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
break;
case 2:
lblcountdown.Text = "2";
countdown = countdown - 1;
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
break;
case 3:
lblcountdown.Text = "3";
countdown = countdown - 1;
lblcountdown.Show();
ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
break;
}
@ -511,6 +878,27 @@ namespace ShiftOS.WinForms.Applications
lblfinalcomputerreward.Text = beatairewardtotal.ToString();
lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}");
SaveSystem.TransferCodepointsFrom("pong", totalreward);
if (!string.IsNullOrWhiteSpace(SaveSystem.CurrentSave.UniteAuthToken))
{
var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
if (unite.GetPongCP() < totalreward)
{
unite.SetPongCP(totalreward);
}
}
if (IsMultiplayerSession)
{
ServerManager.Forward(OpponentGUID, "pong_mp_cashedout", null);
StopMultiplayerSession();
}
}
public void StopMultiplayerSession()
{
IsMultiplayerSession = false;
IsLeader = true;
OpponentGUID = "";
YouGUID = "";
}
private void newgame()
@ -560,27 +948,69 @@ namespace ShiftOS.WinForms.Applications
SetupHighScores();
}
bool IsMultiplayerSession = false;
string YouGUID = "";
string OpponentGUID = "";
public void SetupHighScores()
{
lbhighscore.Items.Clear();
ServerManager.MessageReceived += (msg) =>
lbhighscore.View = View.Details;
lbhighscore.FullRowSelect = true;
lbhighscore.Columns.Clear();
var n = new ColumnHeader();
n.Text = "Player";
n.Width = lbhighscore.Width / 3;
var l = new ColumnHeader();
l.Text = "Level";
l.Width = n.Width;
var c = new ColumnHeader();
c.Text = "Codepoints";
c.Width = n.Width;
lbhighscore.Columns.Add(n);
lbhighscore.Columns.Add(l);
lbhighscore.Columns.Add(c);
var t = new Thread(() =>
{
if(msg.Name == "pong_highscores")
try
{
var hs = JsonConvert.DeserializeObject<List<PongHighscore>>(msg.Contents);
var orderedhs = hs.OrderByDescending(i => i.HighestLevel);
foreach(var score in orderedhs)
var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
var hs = unite.GetPongHighscores();
foreach (var score in hs.Highscores)
{
if(this.ParentForm.Visible == false)
{
Thread.CurrentThread.Abort();
}
string username = unite.GetDisplayNameId(score.UserId);
this.Invoke(new Action(() =>
{
lbhighscore.Items.Add($"{score.UserName}\t\t\t{score.HighestLevel}\t\t{score.HighestCodepoints} CP");
var name_item = new ListViewItem();
name_item.Text = username;
lbhighscore.Items.Add(name_item);
name_item.SubItems.Add(score.Level.ToString());
name_item.SubItems.Add(score.CodepointsCashout.ToString());
}));
}
}
};
ServerManager.SendMessage("pong_gethighscores", null);
catch
{
try
{
if (this.ParentForm.Visible == true)
{
Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time.");
this.Invoke(new Action(pnlgamestats.BringToFront));
}
}
catch { } //JUST. ABORT. THE. FUCKING. THREAD.
return;
}
});
t.Start();
pnlhighscore.Show();
}
@ -596,6 +1026,11 @@ namespace ShiftOS.WinForms.Applications
newgame();
}
public void StartLevel()
{
newgame();
}
// ERROR: Handles clauses are not supported in C#
private void btnstartgame_Click(object sender, EventArgs e)
{
@ -651,24 +1086,58 @@ namespace ShiftOS.WinForms.Applications
pnlhighscore.Hide();
pnlgamestats.Hide();
pnlfinalstats.Hide();
CenterPanels();
lblbeatai.Hide();
ServerManager.MessageReceived += this.ServerMessageReceivedHandler;
}
public void OnSkinLoad()
{
CenterPanels();
this.SizeChanged += (o, a) =>
{
CenterPanels();
};
}
public bool OnUnload()
{
if(IsMultiplayerSession == true)
{
if(!string.IsNullOrWhiteSpace(OpponentGUID))
ServerManager.Forward(OpponentGUID, "pong_mp_left", null);
LeaveMatchmake();
}
ServerManager.MessageReceived -= this.ServerMessageReceivedHandler;
return true;
}
public void OnUpgrade()
{
CenterPanels();
}
private void button2_Click(object sender, EventArgs e)
{
pnlhighscore.Hide();
}
private void btnmatchmake_Click(object sender, EventArgs e)
{
this.StartMultiplayer();
pnlintro.Hide();
lblbeatai.Text = "Beat the other player to earn Codepoints.";
lblcountdown.Text = "Waiting for another player...";
lblcountdown.Left = (this.Width - lblcountdown.Width) / 2;
}
private void lvotherplayers_DoubleClick(object sender, EventArgs e)
{
if(lvotherplayers.SelectedItems.Count > 0)
{
SendLeaderGUID(lvotherplayers.SelectedItems[0].Text);
}
}
}
}

View file

@ -36,8 +36,9 @@ using System.Windows.Forms;
namespace ShiftOS.WinForms.Applications
{
[MultiplayerOnly]
[Launcher("ShiftLetters", false, null, "Games")]
[RequiresUpgrade("shiftletters")]
[AppscapeEntry("ShiftLetters", "Let's see how much you know about ShiftOS by playing this tiny little Hangman game! Shiftorium Upgrades exist to allow you to buy different word sets!", 300, 150, null, "Games")]
[WinOpen("shiftletters")]
[DefaultIcon("iconShiftLetters")]
public partial class ShiftLetters : UserControl, IShiftOSWindow
@ -50,7 +51,7 @@ namespace ShiftOS.WinForms.Applications
"shiftorium", "codepoints", "shiftletters", "shops", "mud", "notification", "namechanger",
"skinning", "skinloader", "calculator", "fileskimmer", "lua", "shiftnet", "terminal", "textpad"};
List<String> contributorsWordlist = new List<string> { "philipadams", "carverh", "computelinux", "lempamo",
"wowmom", "michaeltheshifter", "arencclc", "therandommelon", "pfg", "craftxbox"};
"wowmom", "michaeltheshifter", "arencllc", "therandommelon", "pfg", "craftxbox", "ashifter"};
List<string> osWordlist = new List<string>
{
@ -90,7 +91,8 @@ namespace ShiftOS.WinForms.Applications
"vienna",
"whistler",
"windowsxp",
"windowsforworkgroups"
"windowsforworkgroups",
"shiftos"
};
public ShiftLetters()

View file

@ -0,0 +1,231 @@
/*
* 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 ShiftLotto
{
/// <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.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShiftLotto));
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.cpUpDown = new System.Windows.Forms.NumericUpDown();
this.difUpDown = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label7 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.cpUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.difUpDown)).BeginInit();
this.SuspendLayout();
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(19, 49);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(376, 39);
this.label2.TabIndex = 2;
this.label2.Text = resources.GetString("label2.Text");
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(35, 122);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(60, 13);
this.label3.TabIndex = 3;
this.label3.Text = "Codepoints\r\n";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(319, 122);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(47, 13);
this.label4.TabIndex = 4;
this.label4.Text = "Difficulty";
//
// button1
//
this.button1.Location = new System.Drawing.Point(22, 164);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(369, 23);
this.button1.TabIndex = 6;
this.button1.Text = "Go!";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label5
//
this.label5.Location = new System.Drawing.Point(120, 136);
this.label5.Name = "label5";
this.label5.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label5.Size = new System.Drawing.Size(173, 23);
this.label5.TabIndex = 7;
this.label5.Text = "0 CP";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(173, 122);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(74, 13);
this.label6.TabIndex = 8;
this.label6.Text = "You could win";
//
// cpUpDown
//
this.cpUpDown.Location = new System.Drawing.Point(22, 138);
this.cpUpDown.Maximum = new decimal(new int[] {
1000000,
0,
0,
0});
this.cpUpDown.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.cpUpDown.Name = "cpUpDown";
this.cpUpDown.Size = new System.Drawing.Size(92, 20);
this.cpUpDown.TabIndex = 9;
this.cpUpDown.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// difUpDown
//
this.difUpDown.Location = new System.Drawing.Point(299, 138);
this.difUpDown.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.difUpDown.Minimum = new decimal(new int[] {
10,
0,
0,
0});
this.difUpDown.Name = "difUpDown";
this.difUpDown.Size = new System.Drawing.Size(92, 20);
this.difUpDown.TabIndex = 10;
this.difUpDown.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(147, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(115, 13);
this.label1.TabIndex = 11;
this.label1.Text = "Welcome to ShiftLotto!";
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label7
//
this.label7.Location = new System.Drawing.Point(22, 190);
this.label7.Name = "label7";
this.label7.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label7.Size = new System.Drawing.Size(369, 23);
this.label7.TabIndex = 12;
this.label7.Text = "Current CP: 0 CP";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ShiftLotto
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label7);
this.Controls.Add(this.label1);
this.Controls.Add(this.difUpDown);
this.Controls.Add(this.cpUpDown);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.button1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Name = "ShiftLotto";
this.Size = new System.Drawing.Size(419, 252);
((System.ComponentModel.ISupportInitialize)(this.cpUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.difUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.NumericUpDown cpUpDown;
private System.Windows.Forms.NumericUpDown difUpDown;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label7;
}
}

View file

@ -0,0 +1,134 @@
/*
* 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 System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
{
[Launcher("ShiftLotto", true, "al_shiftlotto", "Games")]
[MultiplayerOnly]
[DefaultIcon("iconShiftLotto")]
[RequiresUpgrade("shiftlotto")]
[WinOpen("shiftlotto")]
public partial class ShiftLotto : UserControl, IShiftOSWindow
{
public ShiftLotto()
{
InitializeComponent();
}
public void OnLoad()
{
timer1.Start();
}
public void OnSkinLoad()
{
}
public bool OnUnload()
{
return true;
}
public void OnUpgrade()
{
}
// The Dynamic Display
private void timer1_Tick(object sender, EventArgs e)
{
int codePoints = Convert.ToInt32(Math.Round(cpUpDown.Value, 0));
int difficulty = Convert.ToInt32(Math.Round(difUpDown.Value, 0));
label5.Text = codePoints * difficulty + " CP";
label7.Text = "Current CP: " + SaveSystem.CurrentSave.Codepoints.ToString() + " CP";
}
private void button1_Click(object sender, EventArgs e)
{
// Make codePoints and difficulty in this function
int codePoints = Convert.ToInt32(Math.Round(cpUpDown.Value, 0));
int difficulty = Convert.ToInt32(Math.Round(difUpDown.Value, 0));
if (SaveSystem.CurrentSave.Codepoints <= 9)
{
Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to use ShiftLotto!");
}
else
{
if (SaveSystem.CurrentSave.Codepoints - (codePoints * difficulty) <= 0)
{
Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to gamble this amount!");
}
else
{
// Create Random Ints
Random rnd = new Random();
// Set their highest possible number to Difficulty
int guessedNumber = rnd.Next(0, difficulty);
int winningNumber = rnd.Next(0, difficulty);
// Multiply CodePoints * Difficulty
int jackpot = codePoints * difficulty;
// Test the random ints
if (guessedNumber == winningNumber)
{
// If you win
// Add Codepoints
SaveSystem.TransferCodepointsFrom("shiftlotto", jackpot);
// Infobox
Infobox.Show("YOU WON!", "Good Job! " + jackpot.ToString() + " CP has been added to your account. ");
}
else
{
// If you fail
// Remove Codepoints
SaveSystem.TransferCodepointsToVoid(jackpot);
// Infobox
Infobox.Show("YOU FAILED!", "Sorry! " + jackpot.ToString() + " CP has been removed from your account.");
}
}
}
}
}
}

View file

@ -0,0 +1,128 @@
<?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>
<data name="label2.Text" xml:space="preserve">
<value>ShiftLotto lets you to turn a few codepoints into a FOURTUNE! All you need to
do is bet a certain amount of codepoints, set a difficulty, and try your luck.
There have been many winners - Will you be one too?</value>
</data>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -52,90 +52,76 @@ namespace ShiftOS.WinForms.Applications
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.easyPanel = new System.Windows.Forms.TableLayoutPanel();
this.buttonE = new System.Windows.Forms.Button();
this.buttonM = new System.Windows.Forms.Button();
this.buttonH = new System.Windows.Forms.Button();
this.panelGameStatus = new System.Windows.Forms.PictureBox();
this.gamePanel = new System.Windows.Forms.TableLayoutPanel();
this.buttonEasy = new System.Windows.Forms.Button();
this.buttonMedium = new System.Windows.Forms.Button();
this.buttonHard = new System.Windows.Forms.Button();
this.lblmines = new System.Windows.Forms.Label();
this.lbltime = new System.Windows.Forms.Label();
this.lblinfo = new System.Windows.Forms.Label();
this.lblinfo2 = new System.Windows.Forms.Label();
this.flagButton = new System.Windows.Forms.PictureBox();
this.mediumPanel = new System.Windows.Forms.TableLayoutPanel();
this.hardPanel = new System.Windows.Forms.TableLayoutPanel();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.flagButton)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.panelGameStatus)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
// panelGameStatus
//
this.pictureBox1.BackgroundImage = global::ShiftOS.WinForms.Properties.Resources.SweeperNormalFace;
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.pictureBox1.Image = global::ShiftOS.WinForms.Properties.Resources.SweeperNormalFace;
this.pictureBox1.Location = new System.Drawing.Point(264, 3);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.panelGameStatus.BackgroundImage = global::ShiftOS.WinForms.Properties.Resources.SweeperNormalFace;
this.panelGameStatus.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.panelGameStatus.Image = global::ShiftOS.WinForms.Properties.Resources.SweeperNormalFace;
this.panelGameStatus.Location = new System.Drawing.Point(264, 3);
this.panelGameStatus.Name = "panelGameStatus";
this.panelGameStatus.Size = new System.Drawing.Size(32, 32);
this.panelGameStatus.TabIndex = 0;
this.panelGameStatus.TabStop = false;
this.panelGameStatus.Click += new System.EventHandler(this.panelGameStatus_Click);
//
// easyPanel
// gamePanel
//
this.easyPanel.ColumnCount = 9;
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 11.11111F));
this.easyPanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.easyPanel.Location = new System.Drawing.Point(4, 40);
this.easyPanel.Name = "easyPanel";
this.easyPanel.RowCount = 9;
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11136F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11136F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11136F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11136F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11136F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11136F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11136F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11025F));
this.easyPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11025F));
this.easyPanel.Size = new System.Drawing.Size(541, 308);
this.easyPanel.TabIndex = 1;
this.gamePanel.AutoScroll = true;
this.gamePanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.gamePanel.ColumnCount = 1;
this.gamePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.gamePanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.gamePanel.Location = new System.Drawing.Point(4, 40);
this.gamePanel.MaximumSize = new System.Drawing.Size(553, 308);
this.gamePanel.MinimumSize = new System.Drawing.Size(553, 308);
this.gamePanel.Name = "gamePanel";
this.gamePanel.RowCount = 1;
this.gamePanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.gamePanel.Size = new System.Drawing.Size(553, 308);
this.gamePanel.TabIndex = 1;
this.gamePanel.Paint += new System.Windows.Forms.PaintEventHandler(this.gamePanel_Paint);
//
// buttonE
// buttonEasy
//
this.buttonE.Location = new System.Drawing.Point(4, 354);
this.buttonE.Name = "buttonE";
this.buttonE.Size = new System.Drawing.Size(75, 23);
this.buttonE.TabIndex = 2;
this.buttonE.Text = "Easy";
this.buttonE.UseVisualStyleBackColor = true;
this.buttonE.Click += new System.EventHandler(this.buttonE_Click);
this.buttonEasy.Location = new System.Drawing.Point(4, 354);
this.buttonEasy.Name = "buttonEasy";
this.buttonEasy.Size = new System.Drawing.Size(75, 23);
this.buttonEasy.TabIndex = 2;
this.buttonEasy.Text = "Easy";
this.buttonEasy.UseVisualStyleBackColor = true;
this.buttonEasy.Click += new System.EventHandler(this.buttonEasy_Click);
//
// buttonM
// buttonMedium
//
this.buttonM.Location = new System.Drawing.Point(244, 354);
this.buttonM.Name = "buttonM";
this.buttonM.Size = new System.Drawing.Size(75, 23);
this.buttonM.TabIndex = 3;
this.buttonM.Text = "Medium";
this.buttonM.UseVisualStyleBackColor = true;
this.buttonM.Click += new System.EventHandler(this.buttonM_Click);
this.buttonMedium.Location = new System.Drawing.Point(244, 354);
this.buttonMedium.Name = "buttonMedium";
this.buttonMedium.Size = new System.Drawing.Size(75, 23);
this.buttonMedium.TabIndex = 3;
this.buttonMedium.Text = "Medium";
this.buttonMedium.UseVisualStyleBackColor = true;
this.buttonMedium.Click += new System.EventHandler(this.buttonMedium_Click);
//
// buttonH
// buttonHard
//
this.buttonH.Location = new System.Drawing.Point(470, 354);
this.buttonH.Name = "buttonH";
this.buttonH.Size = new System.Drawing.Size(75, 23);
this.buttonH.TabIndex = 4;
this.buttonH.Text = "Hard";
this.buttonH.UseVisualStyleBackColor = true;
this.buttonH.Click += new System.EventHandler(this.buttonH_Click);
this.buttonHard.Location = new System.Drawing.Point(482, 354);
this.buttonHard.Name = "buttonHard";
this.buttonHard.Size = new System.Drawing.Size(75, 23);
this.buttonHard.TabIndex = 4;
this.buttonHard.Text = "Hard";
this.buttonHard.UseVisualStyleBackColor = true;
this.buttonHard.Click += new System.EventHandler(this.buttonHard_Click);
//
// lblmines
//
@ -169,139 +155,26 @@ namespace ShiftOS.WinForms.Applications
this.lblinfo2.AutoSize = true;
this.lblinfo2.Location = new System.Drawing.Point(4, 22);
this.lblinfo2.Name = "lblinfo2";
this.lblinfo2.Size = new System.Drawing.Size(128, 13);
this.lblinfo2.Size = new System.Drawing.Size(231, 13);
this.lblinfo2.TabIndex = 8;
this.lblinfo2.Text = "Right Button: Toggle Flag";
//
// flagButton
//
this.flagButton.Image = global::ShiftOS.WinForms.Properties.Resources.SweeperTileBlock;
this.flagButton.Location = new System.Drawing.Point(525, 14);
this.flagButton.Name = "flagButton";
this.flagButton.Size = new System.Drawing.Size(20, 20);
this.flagButton.TabIndex = 9;
this.flagButton.TabStop = false;
this.flagButton.Click += new System.EventHandler(this.flagButton_Click);
//
// mediumPanel
//
this.mediumPanel.ColumnCount = 16;
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249042F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.249044F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.mediumPanel.Location = new System.Drawing.Point(4, 41);
this.mediumPanel.Name = "mediumPanel";
this.mediumPanel.RowCount = 16;
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249183F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.248558F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.248558F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.mediumPanel.Size = new System.Drawing.Size(541, 307);
this.mediumPanel.TabIndex = 2;
//
// hardPanel
//
this.hardPanel.ColumnCount = 27;
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.hardPanel.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.hardPanel.Location = new System.Drawing.Point(4, 40);
this.hardPanel.Name = "hardPanel";
this.hardPanel.RowCount = 16;
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249183F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.249182F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.248558F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.248558F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.hardPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 6.251231F));
this.hardPanel.Size = new System.Drawing.Size(541, 308);
this.hardPanel.TabIndex = 3;
this.lblinfo2.Text = "Right click to flag, middle click to question mark";
//
// ShiftSweeper
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.hardPanel);
this.Controls.Add(this.mediumPanel);
this.Controls.Add(this.flagButton);
this.Controls.Add(this.lblinfo2);
this.Controls.Add(this.lblinfo);
this.Controls.Add(this.lbltime);
this.Controls.Add(this.lblmines);
this.Controls.Add(this.buttonH);
this.Controls.Add(this.buttonM);
this.Controls.Add(this.buttonE);
this.Controls.Add(this.easyPanel);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.buttonHard);
this.Controls.Add(this.buttonMedium);
this.Controls.Add(this.buttonEasy);
this.Controls.Add(this.gamePanel);
this.Controls.Add(this.panelGameStatus);
this.Name = "ShiftSweeper";
this.Size = new System.Drawing.Size(563, 414);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.flagButton)).EndInit();
this.Size = new System.Drawing.Size(596, 426);
((System.ComponentModel.ISupportInitialize)(this.panelGameStatus)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -309,17 +182,14 @@ namespace ShiftOS.WinForms.Applications
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TableLayoutPanel easyPanel;
private System.Windows.Forms.Button buttonE;
private System.Windows.Forms.Button buttonM;
private System.Windows.Forms.Button buttonH;
private System.Windows.Forms.PictureBox panelGameStatus;
private System.Windows.Forms.TableLayoutPanel gamePanel;
private System.Windows.Forms.Button buttonEasy;
private System.Windows.Forms.Button buttonMedium;
private System.Windows.Forms.Button buttonHard;
private System.Windows.Forms.Label lblmines;
private System.Windows.Forms.Label lbltime;
private System.Windows.Forms.Label lblinfo;
private System.Windows.Forms.Label lblinfo2;
private System.Windows.Forms.PictureBox flagButton;
private System.Windows.Forms.TableLayoutPanel mediumPanel;
private System.Windows.Forms.TableLayoutPanel hardPanel;
}
}

View file

@ -1,4 +1,4 @@
/*
/*
* MIT License
*
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
@ -33,338 +33,334 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
{
namespace ShiftOS.WinForms.Applications {
[Launcher("ShiftSweeper", true, "al_shiftsweeper", "Games")]
[RequiresUpgrade("shiftsweeper")]
[AppscapeEntry("ShiftSweeper", "A simple Minesweeper game built for ShiftOS! Careful, it's a hard one.", 1600, 800, "shiftletters", "Games")]
[MultiplayerOnly]
[WinOpen("shiftsweeper")]
[DefaultIcon("iconShiftSweeper")]
public partial class ShiftSweeper : UserControl, IShiftOSWindow
{
private bool gameplayed = false;
private bool flagtime = false;
private int mineCount = 0;
private int origminecount;
private int[,] minemap; //Represents status of tiles. 0-8 = how many mines surrounding. -1 = mine. -2 = flagged mine. -3 to -11 = flagged safe.
public partial class ShiftSweeper : UserControl, IShiftOSWindow {
int[,] game;
int[,] currentGame;
bool gameCreated = false;
int gameBombCount;
int currentGameWidth;
int currentGameHeight;
private Timer ticking = new Timer();
private int minetimer;
private TableLayoutPanel minefieldPanel;
public ShiftSweeper() { InitializeComponent(); }
private static readonly Random random = new Random();
public void OnLoad()
{
buttonE.Visible = true;
buttonM.Visible = ShiftoriumFrontend.UpgradeInstalled("shiftsweeper_medium");
buttonH.Visible = ShiftoriumFrontend.UpgradeInstalled("shiftsweeper_hard");
ticking.Interval = 1000;
ticking.Tick += Ticking_Tick;
easyPanel.Visible = false;
mediumPanel.Visible = false;
hardPanel.Visible = false;
Size tileSize;
Dictionary<int, string> buttonImages = new Dictionary<int, string>(){
{-3, "?" },
{-2, ">" },
{-1, "#" },
{0, " " },
{1, "1" },
{2, "2" },
{3, "3" },
{4, "4" },
{5, "5" },
{6, "6" },
{7, "7" },
{8, "8" },
{9, "9" }
};
Dictionary<int, Bitmap> buttonImagess = new Dictionary<int, Bitmap>(){
{-2, Properties.Resources.SweeperTileFlag }
};
// Properties.Resources.SweeperTileBomb
const int QUESTIONED = -3;
const int FLAGGED = -2;
const int UNDISCOVERED = -1;
const int REMOVE = -10;
public ShiftSweeper() {
InitializeComponent();
}
private void Ticking_Tick(object sender, EventArgs e)
{
private void Ticking_Tick(object sender, EventArgs e) {
minetimer++;
lbltime.Text = "Time: " + minetimer.ToString();
/*lbltime.Text = Localization.Parse("{SHIFTSWEEPER_TIME}", new Dictionary<string, string>{
{"%time", minetimer.ToString()}
});*/
}
public void OnSkinLoad() { }
public void OnLoad() {
OnUpgrade();
public bool OnUnload() { return true; }
ticking.Interval = 1000;
ticking.Tick += Ticking_Tick;
}
public void OnUpgrade() { }
public void OnSkinLoad() {
private void buttonE_Click(object sender, EventArgs e) { startGame(0); }
}
private void clearPreviousGame()
{
if (minemap != null) for (int x = 0; x < minefieldPanel.ColumnCount; x++)
{
for (int y = 0; y < minefieldPanel.RowCount; y++)
{
minemap[x, y] = 0;
public bool OnUnload() {
return true;
}
if (minefieldPanel.GetControlFromPosition(x,y) != null)
{
minefieldPanel.Controls.Remove(minefieldPanel.GetControlFromPosition(x, y));
public void OnUpgrade() {
buttonEasy.Visible = true;
buttonMedium.Visible = ShiftoriumFrontend.UpgradeInstalled("shiftsweeper_medium");
buttonHard.Visible = ShiftoriumFrontend.UpgradeInstalled("shiftsweeper_hard");
}
public void startGame(int w, int h, int b) {
panelGameStatus.Image = Properties.Resources.SweeperNormalFace;
if (gamePanel.RowCount > w || gamePanel.ColumnCount > h) {
for (int y = 0; y < gamePanel.ColumnCount; y++) {
for (int x = 0; x < gamePanel.RowCount; x++) {
updateTile(x, y, REMOVE);
}
}
}
gamePanel.RowCount = w;
gamePanel.ColumnCount = h;
game = new int[w, h];
currentGame = new int[w, h];
tileSize = new Size(23, 23);
gameCreated = false;
currentGameWidth = w;
currentGameHeight = h;
gameBombCount = b;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
updateTile(x, y, UNDISCOVERED);
}
}
}
private void startGame(int d)
{
pictureBox1.Image = Properties.Resources.SweeperNormalFace;
clearPreviousGame();
lbltime.Text = "Time: 0";
public void updateTile(int x, int y, int type) {
Button tile = new Button();
if (type == REMOVE) {
} else {
tile.Text = buttonImages.ContainsKey(type) ? buttonImages[type] : "";
tile.BackgroundImage = buttonImagess.ContainsKey(type) ? buttonImagess[type] : tile.BackgroundImage;
tile.MouseDown += new MouseEventHandler(tile_ClickDown);
tile.MouseUp += new MouseEventHandler(tile_Click);
tile.FlatStyle = FlatStyle.Flat;
tile.FlatAppearance.BorderSize = (type == 0) ? 0 : 1;
tile.Size = tileSize;
currentGame[x, y] = type;
}
var controlToRemove = gamePanel.GetControlFromPosition(y, x);
if (controlToRemove != null)
gamePanel.Controls.Remove(controlToRemove);
if (type != REMOVE)
gamePanel.Controls.Add(tile, y, x);
}
private void tile_Click(object sender, EventArgs ee) {
panelGameStatus.Image = Properties.Resources.SweeperNormalFace;
MouseEventArgs e = (MouseEventArgs)ee;
Control sen = (Control)sender;
TableLayoutPanelCellPosition tilePos = gamePanel.GetPositionFromControl(sen);
if (e.Button == MouseButtons.Left) {
revealTile(tilePos.Row, tilePos.Column);
} else if (e.Button == MouseButtons.Right) {
toggleTileFlag(tilePos.Row, tilePos.Column);
} else if (e.Button == MouseButtons.Middle) {
toggleTileQuestionMark(tilePos.Row, tilePos.Column);
}
}
private void tile_ClickDown(object sender, EventArgs e) {
panelGameStatus.Image = Properties.Resources.SweeperClickFace;
}
private void createGameIfNotExists(int x, int y) {
if (!gameCreated) {
createGameIfNotExists();
int i = 0;
while (game[x, y] != 0 && i < 1000) {
i++;
createGameIfNotExists();
}
if(i > 999)
Infobox.Show("Error", "Failed to generate game");
return;
}
}
private void createGameIfNotExists() {
if (!gameCreated) {
for (int b = 0; b < gameBombCount; b++) { // place bombs
game[random.Next(0, currentGameWidth), random.Next(0, currentGameHeight)] = 9;
}
gameCreated = true;
ticking.Start();
}
}
private int getBombCountInArea(int x, int y) {
createGameIfNotExists(x, y);
if (game[x, y] == 9) return 9;
int count = 0;
int w = currentGameWidth - 1;
int h = currentGameHeight - 1;
if (x > 0) count += game[x - 1, y] == 9 ? 1 : 0;
if (y > 0) count += game[x, y - 1] == 9 ? 1 : 0;
if (x < w) count += game[x + 1, y] == 9 ? 1 : 0;
if (y < h) count += game[x, y + 1] == 9 ? 1 : 0;
if (x > 0 && y > 0) count += game[x - 1, y - 1] == 9 ? 1 : 0;
if (x < w && y < h) count += game[x + 1, y + 1] == 9 ? 1 : 0;
if (x < w && y > 0) count += game[x + 1, y - 1] == 9 ? 1 : 0;
if (x > 0 && y < h) count += game[x - 1, y + 1] == 9 ? 1 : 0;
return count;
}
private void revealTile(int x, int y) {
createGameIfNotExists(x, y);
int bombs = getBombCountInArea(x, y);
int previousBombs = currentGame[x, y];
updateTile(x, y, bombs);
if (bombs == 0 && previousBombs == UNDISCOVERED) {
int w = currentGameWidth - 1;
int h = currentGameHeight - 1;
if (x > 0) revealTile(x - 1, y);
if (y > 0) revealTile(x, y - 1);
if (x < w) revealTile(x + 1, y);
if (y < h) revealTile(x, y + 1);
if (x > 0 && y > 0) revealTile(x - 1, y - 1);
if (x < w && y < h) revealTile(x + 1, y + 1);
if (x < w && y > 0) revealTile(x + 1, y - 1);
if (x > 0 && y < h) revealTile(x - 1, y + 1);
}
if (bombs != 0) checkWinGame();
if (bombs == 9) loseGame();
}
private void toggleTileFlag(int x, int y) {
if(currentGame[x,y] == UNDISCOVERED) {
updateTile(x, y, FLAGGED);
} else if(currentGame[x, y] == FLAGGED) {
updateTile(x, y, UNDISCOVERED);
}
checkWinGame();
}
private void toggleTileQuestionMark(int x, int y) {
if (currentGame[x, y] == UNDISCOVERED) {
updateTile(x, y, QUESTIONED);
} else if (currentGame[x, y] == QUESTIONED) {
updateTile(x, y, UNDISCOVERED);
}
checkWinGame();
}
private void buttonEasy_Click(object sender, EventArgs e) {
startGame(9, 9, 10);
}
private void buttonMedium_Click(object sender, EventArgs e) {
startGame(16, 16, 40);
}
private void buttonHard_Click(object sender, EventArgs e) {
startGame(30, 30, 99);
}
public void winGame() {
int cp = 0;
int origminecount = gameBombCount * 10;
if (minetimer < 31) cp = (origminecount * 3);
else if (minetimer < 61) cp = (Int32)(origminecount * 2.5);
else if (minetimer < 91) cp = (origminecount * 2);
else if (minetimer < 121) cp = (Int32)(origminecount * 1.5);
else if (minetimer > 120) cp = (origminecount * 1);
SaveSystem.TransferCodepointsFrom("shiftsweeper", cp);
panelGameStatus.Image = Properties.Resources.SweeperWinFace;
disableAllTiles(false);
}
public void loseGame() {
disableAllTiles(true);
panelGameStatus.Image = Properties.Resources.SweeperLoseFace;
}
public void disableAllTiles(bool showBombs) {
ticking.Stop();
minetimer = 0;
ticking.Start();
if (minefieldPanel != null) minefieldPanel.Visible = false;
switch (d)
{
case 0:
minefieldPanel = easyPanel;
mineCount = 10;
minefieldPanel.ColumnCount = 9;
minefieldPanel.RowCount = 9;
break;
case 1:
minefieldPanel = mediumPanel;
mineCount = 40;
minefieldPanel.ColumnCount = 16;
minefieldPanel.RowCount = 16;
break;
case 2:
minefieldPanel = hardPanel;
mineCount = 99;
minefieldPanel.ColumnCount = 30;
minefieldPanel.RowCount = 16;
break;
default:
throw new NullReferenceException();
}
minefieldPanel.Visible = true;
origminecount = mineCount;
lblmines.Text = "Mines: " + mineCount.ToString();
buttonE.Enabled = false;
buttonM.Enabled = false;
buttonH.Enabled = false;
gameplayed = true;
makegrid();
}
private void makegrid()
{
Random rnd1 = new Random();
minemap = new int[minefieldPanel.ColumnCount, minefieldPanel.RowCount];
// Makes the minefield full of buttons
for (int x = 0; x < minefieldPanel.ColumnCount; x++)
{
for (int y = 0; y < minefieldPanel.RowCount; y++)
{
minemap[x, y] = 0;
minefieldPanel.Controls.Add(makeButton(x, y), x, y);
}
}
// Placing the mines
int currminecount = mineCount;
while (currminecount > 0)
{
int mineX = rnd1.Next(minefieldPanel.ColumnCount);
int mineY = rnd1.Next(minefieldPanel.RowCount);
if (minemap[mineX, mineY] == 0)
{
minemap[mineX, mineY] = -1;
currminecount--;
}
}
// Setting the numbers
for (int x = 0; x < minefieldPanel.ColumnCount; x++)
{
for (int y = 0; y < minefieldPanel.RowCount; y++)
{
if (minemap[x, y] != -1)
{
int numMines = 0;
for (int xx = -1; xx < 2; xx++)
{
for (int yy = -1; yy < 2; yy++)
{
if (x + xx >= 0 && y + yy >= 0 && x + xx < minefieldPanel.ColumnCount && y + yy < minefieldPanel.RowCount)
{
if (minemap[x + xx, y + yy] == -1) numMines++;
}
}
}
minemap[x, y] = numMines;
for (int y = 0; y < currentGameHeight; y++) {
for (int x = 0; x < currentGameWidth; x++) {
gamePanel.GetControlFromPosition(y, x).Visible = true;
gamePanel.GetControlFromPosition(y,x).Enabled = false;
if (game[x,y] == 9 && showBombs) {
gamePanel.GetControlFromPosition(y,x).BackgroundImage = Properties.Resources.SweeperTileBomb;
}
}
}
}
private Button makeButton(int col, int row)
{
Button bttn = new Button();
bttn.Text = "";
bttn.Name = col.ToString() + " " + row.ToString();
Controls.AddRange(new System.Windows.Forms.Control[] { bttn, });
bttn.Size = new System.Drawing.Size(minefieldPanel.Width / minefieldPanel.ColumnCount, (minefieldPanel.Height / minefieldPanel.RowCount) + 10);
bttn.Click += new System.EventHandler(bttnOnclick);
bttn.BackgroundImage = Properties.Resources.SweeperTileBlock;
bttn.BackgroundImageLayout = ImageLayout.Stretch;
return bttn;
}
private void bttnOnclick(object sender, EventArgs e)
{
if (!ticking.Enabled) return;
Button bttnClick = sender as Button;
if (bttnClick == null) return; //not a button.
string[] split = bttnClick.Name.Split(new Char[] { ' ' });
int x = System.Convert.ToInt32(split[0]);
int y = System.Convert.ToInt32(split[1]);
if (!flagtime)
{
if (minemap[x, y] == -1)
{
ticking.Enabled = false;
buttonE.Enabled = true;
buttonM.Enabled = true;
buttonH.Enabled = true;
pictureBox1.BackgroundImage = Properties.Resources.SweeperLoseFace;
for (int xx = 0; xx < minefieldPanel.ColumnCount; xx++)
{
for (int yy = 0; yy < minefieldPanel.RowCount; yy++)
{
pictureBox1.BackgroundImage = Properties.Resources.SweeperLoseFace;
minefieldPanel.GetControlFromPosition(xx, yy).Enabled = false;
if (minemap[xx, yy] == -1)
{
minefieldPanel.GetControlFromPosition(xx, yy).BackgroundImage = Properties.Resources.SweeperTileBomb;
}
public void checkWinGame() {
for(int y = 0; y < currentGameHeight; y++) {
for(int x = 0; x < currentGameWidth; x++) {
int tile = currentGame[x, y];
if(tile == UNDISCOVERED || tile == QUESTIONED) {
return;
}
if(tile == FLAGGED) {
if(game[x,y] != 9) {
// looks like you flagged the wrong thing...
return;
}
}
pictureBox1.Image = Properties.Resources.SweeperLoseFace;
}
else if (minemap[x, y] < -1) return;
else removeBlank(x, y);
}
else
{
if (!bttnClick.Enabled) return;
if (minemap[x, y] < -1)
{
minemap[x, y] = (minemap[x, y] * -1) - 3;
bttnClick.BackgroundImage = Properties.Resources.SweeperTileBlock;
mineCount++;
}
else
{
minemap[x, y] = (minemap[x, y] * -1) - 3;
bttnClick.BackgroundImage = Properties.Resources.SweeperTileFlag;
mineCount--;
}
lblmines.Text = "Mines: " + mineCount.ToString();
bool wrongflags = false;
if (mineCount == 0)
{
for (int xx = 0; xx < minefieldPanel.ColumnCount; xx++)
{
if (wrongflags) break;
for (int yy = 0; yy < minefieldPanel.RowCount; yy++)
{
if (wrongflags) break;
if (minemap[xx, yy] < -2) wrongflags = true;
}
if(tile == 9) {
loseGame();
return;
}
if (!wrongflags)
{
ticking.Enabled = false;
buttonE.Enabled = true;
buttonM.Enabled = true;
buttonH.Enabled = true;
for (int xx = 0; xx < minefieldPanel.ColumnCount; xx++)
{
for (int yy = 0; yy < minefieldPanel.RowCount; yy++)
{
minefieldPanel.GetControlFromPosition(xx, yy).Enabled = false;
}
}
Int32 cp = 0;
origminecount = origminecount * 10;
if (minetimer < 31) cp = (origminecount * 3);
if (minetimer < 61) cp = (Int32)(origminecount * 2.5);
if (minetimer < 91) cp = (origminecount * 2);
if (minetimer < 121) cp = (Int32)(origminecount * 1.5);
if (minetimer > 120) cp = (origminecount * 1);
SaveSystem.TransferCodepointsFrom("shiftsweeper", cp);
pictureBox1.Image = Properties.Resources.SweeperWinFace;
}
}
}
winGame();
}
private void removeBlank(int x, int y)
{
minefieldPanel.GetControlFromPosition(x, y).Enabled = false;
trueform(x, y);
if (minemap[x, y] != 0) return;
for (int xx = -1; xx < 2; xx++)
{
for (int yy = -1; yy < 2; yy++)
{
if (x + xx >= 0 && y + yy >= 0 && x + xx < minefieldPanel.ColumnCount && y + yy < minefieldPanel.RowCount)
{
if (minefieldPanel.GetControlFromPosition(x + xx, y + yy).Enabled && minemap[x+xx,y+yy] != -1 && minemap[x + xx, y + yy] != -2)
{
minefieldPanel.GetControlFromPosition(x + xx, y + yy).Enabled = false;
trueform(x + xx, y + yy);
if (minemap[x + xx, y + yy] == 0)
{
removeBlank(x + xx, y + yy);
}
}
}
}
}
private void panelGameStatus_Click(object sender, EventArgs e) {
}
private void trueform(int x, int y)
{
Button bttn = (Button)minefieldPanel.GetControlFromPosition(x, y);
if (minemap[x,y] == 0) bttn.BackgroundImage = Properties.Resources.SweeperTile0;
else if (minemap[x, y] == 1) bttn.BackgroundImage = Properties.Resources.SweeperTile1;
else if (minemap[x, y] == 2) bttn.BackgroundImage = Properties.Resources.SweeperTile2;
else if (minemap[x, y] == 3) bttn.BackgroundImage = Properties.Resources.SweeperTile3;
else if (minemap[x, y] == 4) bttn.BackgroundImage = Properties.Resources.SweeperTile4;
else if (minemap[x, y] == 5) bttn.BackgroundImage = Properties.Resources.SweeperTile5;
else if (minemap[x, y] == 6) bttn.BackgroundImage = Properties.Resources.SweeperTile6;
else if (minemap[x, y] == 7) bttn.BackgroundImage = Properties.Resources.SweeperTile7;
else if (minemap[x, y] == 8) bttn.BackgroundImage = Properties.Resources.SweeperTile8;
}
private void gamePanel_Paint(object sender, PaintEventArgs e) {
private void buttonM_Click(object sender, EventArgs e) { startGame(1); }
private void buttonH_Click(object sender, EventArgs e) { startGame(2); }
private void flagButton_Click(object sender, EventArgs e)
{
if (flagtime)
{
flagButton.Image = Properties.Resources.SweeperTileBlock;
flagtime = false;
}
else
{
flagButton.Image = Properties.Resources.SweeperTileFlag;
flagtime = true;
}
}
}
}

View file

@ -37,11 +37,15 @@ namespace ShiftOS.WinForms.Applications
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
try
{
components.Dispose();
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
base.Dispose(disposing);
catch { }
}
#region Windows Form Designer generated code
@ -52,103 +56,321 @@ namespace ShiftOS.WinForms.Applications
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Shifter));
this.panel1 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.pnlpreview = new System.Windows.Forms.Panel();
this.pnlwindow = new System.Windows.Forms.Panel();
this.pnlcontents = new System.Windows.Forms.Panel();
this.pnltitle = new System.Windows.Forms.Panel();
this.pnlicon = new System.Windows.Forms.Panel();
this.pnlminimize = new System.Windows.Forms.Panel();
this.pnlmaximize = new System.Windows.Forms.Panel();
this.pnlclose = new System.Windows.Forms.Panel();
this.pnltitleleft = new System.Windows.Forms.Panel();
this.pnltitleright = new System.Windows.Forms.Panel();
this.lbtitletext = new System.Windows.Forms.Label();
this.pnlbottom = new System.Windows.Forms.Panel();
this.pnlbottomr = new System.Windows.Forms.Panel();
this.pnlbottoml = new System.Windows.Forms.Panel();
this.pnlright = new System.Windows.Forms.Panel();
this.pnlleft = new System.Windows.Forms.Panel();
this.pnlsettingsholder = new System.Windows.Forms.Panel();
this.flbody = new System.Windows.Forms.FlowLayoutPanel();
this.flcategory = new System.Windows.Forms.FlowLayoutPanel();
this.panel3 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.pnlcategoryholder = new System.Windows.Forms.Panel();
this.flmeta = new System.Windows.Forms.FlowLayoutPanel();
this.btnapply = new System.Windows.Forms.Button();
this.mspreview = new System.Windows.Forms.MenuStrip();
this.menuToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuItem1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuItem2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.subitem1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.subitem2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.subitem3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.separatorToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
this.menuItem3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tspreview = new System.Windows.Forms.ToolStrip();
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
this.pnlintro = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.pnldesktoppreview = new System.Windows.Forms.Panel();
this.pnlscreensaver = new System.Windows.Forms.Panel();
this.pnlssicon = new System.Windows.Forms.Panel();
this.desktoppanel = new System.Windows.Forms.Panel();
this.lbtime = new System.Windows.Forms.Label();
this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel();
this.sysmenuholder = new System.Windows.Forms.Panel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.apps = new System.Windows.Forms.ToolStripMenuItem();
this.pnladvancedal = new System.Windows.Forms.Panel();
this.flapps = new System.Windows.Forms.FlowLayoutPanel();
this.flcategories = new System.Windows.Forms.FlowLayoutPanel();
this.pnlalsystemactions = new System.Windows.Forms.Panel();
this.btnshutdown = new System.Windows.Forms.Button();
this.pnlstatus = new System.Windows.Forms.Panel();
this.lbalstatus = new System.Windows.Forms.Label();
this.item1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.item2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.item3ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.item4ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.item5ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shutdownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.separatorToolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.panel1.SuspendLayout();
this.panel4.SuspendLayout();
this.panel3.SuspendLayout();
this.panel2.SuspendLayout();
this.pnlpreview.SuspendLayout();
this.pnlwindow.SuspendLayout();
this.pnlcontents.SuspendLayout();
this.pnltitle.SuspendLayout();
this.pnlbottom.SuspendLayout();
this.pnlsettingsholder.SuspendLayout();
this.pnlcategoryholder.SuspendLayout();
this.mspreview.SuspendLayout();
this.tspreview.SuspendLayout();
this.pnlintro.SuspendLayout();
this.pnldesktoppreview.SuspendLayout();
this.pnlscreensaver.SuspendLayout();
this.desktoppanel.SuspendLayout();
this.sysmenuholder.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.pnladvancedal.SuspendLayout();
this.pnlalsystemactions.SuspendLayout();
this.pnlstatus.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.panel4);
this.panel1.Controls.Add(this.panel3);
this.panel1.Controls.Add(this.panel2);
this.panel1.Controls.Add(this.pnlpreview);
this.panel1.Controls.Add(this.pnlsettingsholder);
this.panel1.Controls.Add(this.pnlcategoryholder);
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(893, 539);
this.panel1.TabIndex = 0;
//
// panel4
// pnlpreview
//
this.panel4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.pnlpreview.Controls.Add(this.pnldesktoppreview);
this.pnlpreview.Controls.Add(this.pnlintro);
this.pnlpreview.Controls.Add(this.pnlwindow);
this.pnlpreview.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlpreview.Location = new System.Drawing.Point(136, 0);
this.pnlpreview.Name = "pnlpreview";
this.pnlpreview.Size = new System.Drawing.Size(757, 286);
this.pnlpreview.TabIndex = 1;
//
// pnlwindow
//
this.pnlwindow.Controls.Add(this.pnlcontents);
this.pnlwindow.Controls.Add(this.pnltitle);
this.pnlwindow.Controls.Add(this.pnlbottom);
this.pnlwindow.Controls.Add(this.pnlright);
this.pnlwindow.Controls.Add(this.pnlleft);
this.pnlwindow.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlwindow.Location = new System.Drawing.Point(0, 0);
this.pnlwindow.Name = "pnlwindow";
this.pnlwindow.Size = new System.Drawing.Size(757, 286);
this.pnlwindow.TabIndex = 0;
//
// pnlcontents
//
this.pnlcontents.BackColor = System.Drawing.Color.Black;
this.pnlcontents.Controls.Add(this.tspreview);
this.pnlcontents.Controls.Add(this.mspreview);
this.pnlcontents.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlcontents.ForeColor = System.Drawing.Color.White;
this.pnlcontents.Location = new System.Drawing.Point(2, 30);
this.pnlcontents.Name = "pnlcontents";
this.pnlcontents.Size = new System.Drawing.Size(753, 254);
this.pnlcontents.TabIndex = 9;
//
// pnltitle
//
this.pnltitle.BackColor = System.Drawing.Color.Black;
this.pnltitle.Controls.Add(this.pnlicon);
this.pnltitle.Controls.Add(this.pnlminimize);
this.pnltitle.Controls.Add(this.pnlmaximize);
this.pnltitle.Controls.Add(this.pnlclose);
this.pnltitle.Controls.Add(this.pnltitleleft);
this.pnltitle.Controls.Add(this.pnltitleright);
this.pnltitle.Controls.Add(this.lbtitletext);
this.pnltitle.Dock = System.Windows.Forms.DockStyle.Top;
this.pnltitle.Location = new System.Drawing.Point(2, 0);
this.pnltitle.Name = "pnltitle";
this.pnltitle.Size = new System.Drawing.Size(753, 30);
this.pnltitle.TabIndex = 5;
//
// pnlicon
//
this.pnlicon.Location = new System.Drawing.Point(9, -76);
this.pnlicon.Name = "pnlicon";
this.pnlicon.Size = new System.Drawing.Size(200, 100);
this.pnlicon.TabIndex = 6;
//
// pnlminimize
//
this.pnlminimize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pnlminimize.BackColor = System.Drawing.Color.Green;
this.pnlminimize.Location = new System.Drawing.Point(672, 3);
this.pnlminimize.Name = "pnlminimize";
this.pnlminimize.Size = new System.Drawing.Size(24, 24);
this.pnlminimize.TabIndex = 3;
//
// pnlmaximize
//
this.pnlmaximize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pnlmaximize.BackColor = System.Drawing.Color.Yellow;
this.pnlmaximize.Location = new System.Drawing.Point(699, 3);
this.pnlmaximize.Name = "pnlmaximize";
this.pnlmaximize.Size = new System.Drawing.Size(24, 24);
this.pnlmaximize.TabIndex = 2;
//
// pnlclose
//
this.pnlclose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pnlclose.BackColor = System.Drawing.Color.Red;
this.pnlclose.Location = new System.Drawing.Point(726, 3);
this.pnlclose.Name = "pnlclose";
this.pnlclose.Size = new System.Drawing.Size(24, 24);
this.pnlclose.TabIndex = 1;
//
// pnltitleleft
//
this.pnltitleleft.Dock = System.Windows.Forms.DockStyle.Left;
this.pnltitleleft.Location = new System.Drawing.Point(0, 0);
this.pnltitleleft.Name = "pnltitleleft";
this.pnltitleleft.Size = new System.Drawing.Size(2, 30);
this.pnltitleleft.TabIndex = 4;
//
// pnltitleright
//
this.pnltitleright.Dock = System.Windows.Forms.DockStyle.Right;
this.pnltitleright.Location = new System.Drawing.Point(751, 0);
this.pnltitleright.Name = "pnltitleright";
this.pnltitleright.Size = new System.Drawing.Size(2, 30);
this.pnltitleright.TabIndex = 5;
//
// lbtitletext
//
this.lbtitletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel4.Controls.Add(this.flbody);
this.panel4.Controls.Add(this.flcategory);
this.panel4.Location = new System.Drawing.Point(154, 283);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(734, 253);
this.panel4.TabIndex = 2;
this.lbtitletext.AutoSize = true;
this.lbtitletext.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.lbtitletext.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Bold);
this.lbtitletext.ForeColor = System.Drawing.Color.White;
this.lbtitletext.Location = new System.Drawing.Point(75, 9);
this.lbtitletext.Name = "lbtitletext";
this.lbtitletext.Size = new System.Drawing.Size(77, 14);
this.lbtitletext.TabIndex = 0;
this.lbtitletext.Text = "Title text";
this.lbtitletext.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lbtitletext.UseMnemonic = false;
//
// pnlbottom
//
this.pnlbottom.BackColor = System.Drawing.Color.Black;
this.pnlbottom.Controls.Add(this.pnlbottomr);
this.pnlbottom.Controls.Add(this.pnlbottoml);
this.pnlbottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlbottom.Location = new System.Drawing.Point(2, 284);
this.pnlbottom.Name = "pnlbottom";
this.pnlbottom.Size = new System.Drawing.Size(753, 2);
this.pnlbottom.TabIndex = 6;
//
// pnlbottomr
//
this.pnlbottomr.Dock = System.Windows.Forms.DockStyle.Right;
this.pnlbottomr.Location = new System.Drawing.Point(751, 0);
this.pnlbottomr.Name = "pnlbottomr";
this.pnlbottomr.Size = new System.Drawing.Size(2, 2);
this.pnlbottomr.TabIndex = 3;
//
// pnlbottoml
//
this.pnlbottoml.Dock = System.Windows.Forms.DockStyle.Left;
this.pnlbottoml.Location = new System.Drawing.Point(0, 0);
this.pnlbottoml.Name = "pnlbottoml";
this.pnlbottoml.Size = new System.Drawing.Size(2, 2);
this.pnlbottoml.TabIndex = 2;
//
// pnlright
//
this.pnlright.BackColor = System.Drawing.Color.Black;
this.pnlright.Dock = System.Windows.Forms.DockStyle.Right;
this.pnlright.Location = new System.Drawing.Point(755, 0);
this.pnlright.Name = "pnlright";
this.pnlright.Size = new System.Drawing.Size(2, 286);
this.pnlright.TabIndex = 8;
//
// pnlleft
//
this.pnlleft.BackColor = System.Drawing.Color.Black;
this.pnlleft.Dock = System.Windows.Forms.DockStyle.Left;
this.pnlleft.Location = new System.Drawing.Point(0, 0);
this.pnlleft.Name = "pnlleft";
this.pnlleft.Size = new System.Drawing.Size(2, 286);
this.pnlleft.TabIndex = 7;
//
// pnlsettingsholder
//
this.pnlsettingsholder.Controls.Add(this.flbody);
this.pnlsettingsholder.Controls.Add(this.flcategory);
this.pnlsettingsholder.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlsettingsholder.Location = new System.Drawing.Point(136, 286);
this.pnlsettingsholder.Name = "pnlsettingsholder";
this.pnlsettingsholder.Padding = new System.Windows.Forms.Padding(10);
this.pnlsettingsholder.Size = new System.Drawing.Size(757, 253);
this.pnlsettingsholder.TabIndex = 2;
//
// flbody
//
this.flbody.AutoScroll = true;
this.flbody.Dock = System.Windows.Forms.DockStyle.Fill;
this.flbody.Location = new System.Drawing.Point(126, 0);
this.flbody.Location = new System.Drawing.Point(136, 10);
this.flbody.Name = "flbody";
this.flbody.Size = new System.Drawing.Size(608, 253);
this.flbody.Size = new System.Drawing.Size(611, 233);
this.flbody.TabIndex = 3;
//
// flcategory
//
this.flcategory.Dock = System.Windows.Forms.DockStyle.Left;
this.flcategory.Location = new System.Drawing.Point(0, 0);
this.flcategory.Location = new System.Drawing.Point(10, 10);
this.flcategory.Name = "flcategory";
this.flcategory.Size = new System.Drawing.Size(126, 253);
this.flcategory.Size = new System.Drawing.Size(126, 233);
this.flcategory.TabIndex = 2;
//
// panel3
// pnlcategoryholder
//
this.panel3.Controls.Add(this.label1);
this.panel3.Location = new System.Drawing.Point(155, 12);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(640, 360);
this.panel3.TabIndex = 1;
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(640, 360);
this.label1.TabIndex = 0;
this.label1.Text = "Preview not available.";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel2
//
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.panel2.Controls.Add(this.flmeta);
this.panel2.Controls.Add(this.btnapply);
this.panel2.Location = new System.Drawing.Point(12, 12);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(136, 511);
this.panel2.TabIndex = 0;
this.pnlcategoryholder.Controls.Add(this.flmeta);
this.pnlcategoryholder.Controls.Add(this.btnapply);
this.pnlcategoryholder.Dock = System.Windows.Forms.DockStyle.Left;
this.pnlcategoryholder.Location = new System.Drawing.Point(0, 0);
this.pnlcategoryholder.Name = "pnlcategoryholder";
this.pnlcategoryholder.Padding = new System.Windows.Forms.Padding(10);
this.pnlcategoryholder.Size = new System.Drawing.Size(136, 539);
this.pnlcategoryholder.TabIndex = 0;
//
// flmeta
//
this.flmeta.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.flmeta.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flmeta.Location = new System.Drawing.Point(4, 4);
this.flmeta.Location = new System.Drawing.Point(14, 14);
this.flmeta.Name = "flmeta";
this.flmeta.Size = new System.Drawing.Size(126, 450);
this.flmeta.Size = new System.Drawing.Size(126, 458);
this.flmeta.TabIndex = 1;
//
// btnapply
//
this.btnapply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnapply.Location = new System.Drawing.Point(3, 460);
this.btnapply.Location = new System.Drawing.Point(13, 478);
this.btnapply.Name = "btnapply";
this.btnapply.Size = new System.Drawing.Size(127, 48);
this.btnapply.TabIndex = 0;
@ -156,19 +378,407 @@ namespace ShiftOS.WinForms.Applications
this.btnapply.UseVisualStyleBackColor = true;
this.btnapply.Click += new System.EventHandler(this.btnapply_Click);
//
// mspreview
//
this.mspreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuToolStripMenuItem});
this.mspreview.Location = new System.Drawing.Point(0, 0);
this.mspreview.Name = "mspreview";
this.mspreview.Size = new System.Drawing.Size(753, 24);
this.mspreview.TabIndex = 0;
this.mspreview.Text = "menuStrip1";
//
// menuToolStripMenuItem
//
this.menuToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuItem1ToolStripMenuItem,
this.menuItem2ToolStripMenuItem,
this.separatorToolStripMenuItem,
this.menuItem3ToolStripMenuItem});
this.menuToolStripMenuItem.Name = "menuToolStripMenuItem";
this.menuToolStripMenuItem.Size = new System.Drawing.Size(50, 20);
this.menuToolStripMenuItem.Text = "Menu";
//
// menuItem1ToolStripMenuItem
//
this.menuItem1ToolStripMenuItem.Name = "menuItem1ToolStripMenuItem";
this.menuItem1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.menuItem1ToolStripMenuItem.Text = "Menu Item 1";
//
// menuItem2ToolStripMenuItem
//
this.menuItem2ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.subitem1ToolStripMenuItem,
this.subitem2ToolStripMenuItem,
this.subitem3ToolStripMenuItem});
this.menuItem2ToolStripMenuItem.Name = "menuItem2ToolStripMenuItem";
this.menuItem2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.menuItem2ToolStripMenuItem.Text = "Menu Item 2";
//
// subitem1ToolStripMenuItem
//
this.subitem1ToolStripMenuItem.Name = "subitem1ToolStripMenuItem";
this.subitem1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.subitem1ToolStripMenuItem.Text = "Subitem 1";
//
// subitem2ToolStripMenuItem
//
this.subitem2ToolStripMenuItem.Name = "subitem2ToolStripMenuItem";
this.subitem2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.subitem2ToolStripMenuItem.Text = "Subitem 2";
//
// subitem3ToolStripMenuItem
//
this.subitem3ToolStripMenuItem.Name = "subitem3ToolStripMenuItem";
this.subitem3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.subitem3ToolStripMenuItem.Text = "Subitem 3";
//
// separatorToolStripMenuItem
//
this.separatorToolStripMenuItem.Name = "separatorToolStripMenuItem";
this.separatorToolStripMenuItem.Size = new System.Drawing.Size(149, 6);
//
// menuItem3ToolStripMenuItem
//
this.menuItem3ToolStripMenuItem.Name = "menuItem3ToolStripMenuItem";
this.menuItem3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.menuItem3ToolStripMenuItem.Text = "Menu Item 3";
//
// tspreview
//
this.tspreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripLabel1,
this.toolStripButton2,
this.toolStripButton3,
this.toolStripButton1,
this.toolStripSeparator1,
this.toolStripTextBox1});
this.tspreview.Location = new System.Drawing.Point(0, 24);
this.tspreview.Name = "tspreview";
this.tspreview.Size = new System.Drawing.Size(753, 25);
this.tspreview.TabIndex = 1;
this.tspreview.Text = "toolStrip1";
//
// toolStripLabel1
//
this.toolStripLabel1.Name = "toolStripLabel1";
this.toolStripLabel1.Size = new System.Drawing.Size(81, 22);
this.toolStripLabel1.Text = "Toolbar Label:";
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolStripButton1.Enabled = false;
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(56, 22);
this.toolStripButton1.Text = "Disabled";
//
// toolStripButton2
//
this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton2.Name = "toolStripButton2";
this.toolStripButton2.Size = new System.Drawing.Size(51, 22);
this.toolStripButton2.Text = "Regular";
//
// toolStripButton3
//
this.toolStripButton3.Checked = true;
this.toolStripButton3.CheckState = System.Windows.Forms.CheckState.Checked;
this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton3.Name = "toolStripButton3";
this.toolStripButton3.Size = new System.Drawing.Size(57, 22);
this.toolStripButton3.Text = "Checked";
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// toolStripTextBox1
//
this.toolStripTextBox1.Name = "toolStripTextBox1";
this.toolStripTextBox1.Size = new System.Drawing.Size(100, 25);
//
// pnlintro
//
this.pnlintro.Controls.Add(this.label2);
this.pnlintro.Controls.Add(this.label1);
this.pnlintro.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlintro.Location = new System.Drawing.Point(0, 0);
this.pnlintro.Name = "pnlintro";
this.pnlintro.Size = new System.Drawing.Size(757, 286);
this.pnlintro.TabIndex = 2;
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(757, 54);
this.label1.TabIndex = 0;
this.label1.Tag = "header2";
this.label1.Text = "Welcome to the Shifter!";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
this.label2.Location = new System.Drawing.Point(0, 54);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(757, 232);
this.label2.TabIndex = 1;
this.label2.Text = resources.GetString("label2.Text");
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// pnldesktoppreview
//
this.pnldesktoppreview.Controls.Add(this.pnlscreensaver);
this.pnldesktoppreview.Controls.Add(this.desktoppanel);
this.pnldesktoppreview.Controls.Add(this.pnladvancedal);
this.pnldesktoppreview.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnldesktoppreview.Location = new System.Drawing.Point(0, 0);
this.pnldesktoppreview.Name = "pnldesktoppreview";
this.pnldesktoppreview.Size = new System.Drawing.Size(757, 286);
this.pnldesktoppreview.TabIndex = 2;
//
// pnlscreensaver
//
this.pnlscreensaver.Controls.Add(this.pnlssicon);
this.pnlscreensaver.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlscreensaver.Location = new System.Drawing.Point(0, 24);
this.pnlscreensaver.Name = "pnlscreensaver";
this.pnlscreensaver.Size = new System.Drawing.Size(757, 262);
this.pnlscreensaver.TabIndex = 3;
this.pnlscreensaver.Visible = false;
//
// pnlssicon
//
this.pnlssicon.Location = new System.Drawing.Point(303, 495);
this.pnlssicon.Name = "pnlssicon";
this.pnlssicon.Size = new System.Drawing.Size(200, 100);
this.pnlssicon.TabIndex = 0;
//
// desktoppanel
//
this.desktoppanel.BackColor = System.Drawing.Color.Green;
this.desktoppanel.Controls.Add(this.lbtime);
this.desktoppanel.Controls.Add(this.panelbuttonholder);
this.desktoppanel.Controls.Add(this.sysmenuholder);
this.desktoppanel.Dock = System.Windows.Forms.DockStyle.Top;
this.desktoppanel.Location = new System.Drawing.Point(0, 0);
this.desktoppanel.Name = "desktoppanel";
this.desktoppanel.Size = new System.Drawing.Size(757, 24);
this.desktoppanel.TabIndex = 2;
//
// lbtime
//
this.lbtime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.lbtime.AutoSize = true;
this.lbtime.Location = new System.Drawing.Point(-536, 0);
this.lbtime.Name = "lbtime";
this.lbtime.Size = new System.Drawing.Size(35, 13);
this.lbtime.TabIndex = 0;
this.lbtime.Text = "label1";
this.lbtime.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// panelbuttonholder
//
this.panelbuttonholder.AutoSize = true;
this.panelbuttonholder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.panelbuttonholder.Location = new System.Drawing.Point(107, -77);
this.panelbuttonholder.Name = "panelbuttonholder";
this.panelbuttonholder.Size = new System.Drawing.Size(0, 0);
this.panelbuttonholder.TabIndex = 2;
//
// sysmenuholder
//
this.sysmenuholder.Controls.Add(this.menuStrip1);
this.sysmenuholder.Location = new System.Drawing.Point(12, 5);
this.sysmenuholder.Name = "sysmenuholder";
this.sysmenuholder.Size = new System.Drawing.Size(68, 24);
this.sysmenuholder.TabIndex = 1;
//
// menuStrip1
//
this.menuStrip1.Dock = System.Windows.Forms.DockStyle.Fill;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.apps});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(0);
this.menuStrip1.Size = new System.Drawing.Size(68, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// apps
//
this.apps.AutoSize = false;
this.apps.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.item1ToolStripMenuItem,
this.item2ToolStripMenuItem,
this.item3ToolStripMenuItem,
this.item4ToolStripMenuItem,
this.item5ToolStripMenuItem,
this.separatorToolStripMenuItem1,
this.shutdownToolStripMenuItem});
this.apps.Name = "apps";
this.apps.Padding = new System.Windows.Forms.Padding(0);
this.apps.Size = new System.Drawing.Size(58, 20);
this.apps.Tag = "applauncherbutton";
this.apps.Text = "ShiftOS";
//
// pnladvancedal
//
this.pnladvancedal.Controls.Add(this.flapps);
this.pnladvancedal.Controls.Add(this.flcategories);
this.pnladvancedal.Controls.Add(this.pnlalsystemactions);
this.pnladvancedal.Controls.Add(this.pnlstatus);
this.pnladvancedal.Location = new System.Drawing.Point(0, -53);
this.pnladvancedal.Name = "pnladvancedal";
this.pnladvancedal.Size = new System.Drawing.Size(433, 417);
this.pnladvancedal.TabIndex = 4;
this.pnladvancedal.Visible = false;
//
// flapps
//
this.flapps.Dock = System.Windows.Forms.DockStyle.Fill;
this.flapps.Location = new System.Drawing.Point(221, 58);
this.flapps.Name = "flapps";
this.flapps.Size = new System.Drawing.Size(212, 328);
this.flapps.TabIndex = 3;
//
// flcategories
//
this.flcategories.Dock = System.Windows.Forms.DockStyle.Left;
this.flcategories.Location = new System.Drawing.Point(0, 58);
this.flcategories.Name = "flcategories";
this.flcategories.Size = new System.Drawing.Size(221, 328);
this.flcategories.TabIndex = 2;
//
// pnlalsystemactions
//
this.pnlalsystemactions.Controls.Add(this.btnshutdown);
this.pnlalsystemactions.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlalsystemactions.Location = new System.Drawing.Point(0, 386);
this.pnlalsystemactions.Name = "pnlalsystemactions";
this.pnlalsystemactions.Size = new System.Drawing.Size(433, 31);
this.pnlalsystemactions.TabIndex = 1;
//
// btnshutdown
//
this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnshutdown.AutoSize = true;
this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnshutdown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnshutdown.Location = new System.Drawing.Point(363, 3);
this.btnshutdown.Name = "btnshutdown";
this.btnshutdown.Size = new System.Drawing.Size(67, 25);
this.btnshutdown.TabIndex = 0;
this.btnshutdown.Text = "Shutdown";
this.btnshutdown.UseVisualStyleBackColor = true;
//
// pnlstatus
//
this.pnlstatus.Controls.Add(this.lbalstatus);
this.pnlstatus.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlstatus.Location = new System.Drawing.Point(0, 0);
this.pnlstatus.Name = "pnlstatus";
this.pnlstatus.Size = new System.Drawing.Size(433, 58);
this.pnlstatus.TabIndex = 0;
//
// lbalstatus
//
this.lbalstatus.Dock = System.Windows.Forms.DockStyle.Fill;
this.lbalstatus.Location = new System.Drawing.Point(0, 0);
this.lbalstatus.Name = "lbalstatus";
this.lbalstatus.Size = new System.Drawing.Size(433, 58);
this.lbalstatus.TabIndex = 0;
this.lbalstatus.Text = "michael@system\r\n0 Codepoints\r\n0 installed, 0 available";
this.lbalstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// item1ToolStripMenuItem
//
this.item1ToolStripMenuItem.Name = "item1ToolStripMenuItem";
this.item1ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.item1ToolStripMenuItem.Text = "Item 1";
//
// item2ToolStripMenuItem
//
this.item2ToolStripMenuItem.Name = "item2ToolStripMenuItem";
this.item2ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.item2ToolStripMenuItem.Text = "Item 2";
//
// item3ToolStripMenuItem
//
this.item3ToolStripMenuItem.Name = "item3ToolStripMenuItem";
this.item3ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.item3ToolStripMenuItem.Text = "Item 3";
//
// item4ToolStripMenuItem
//
this.item4ToolStripMenuItem.Name = "item4ToolStripMenuItem";
this.item4ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.item4ToolStripMenuItem.Text = "Item 4";
//
// item5ToolStripMenuItem
//
this.item5ToolStripMenuItem.Name = "item5ToolStripMenuItem";
this.item5ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.item5ToolStripMenuItem.Text = "Item 5";
//
// shutdownToolStripMenuItem
//
this.shutdownToolStripMenuItem.Name = "shutdownToolStripMenuItem";
this.shutdownToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.shutdownToolStripMenuItem.Text = "Shutdown";
//
// separatorToolStripMenuItem1
//
this.separatorToolStripMenuItem1.Name = "separatorToolStripMenuItem1";
this.separatorToolStripMenuItem1.Size = new System.Drawing.Size(149, 6);
//
// Shifter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Name = "Shifter";
this.Text = "{SHIFTER_NAME}";
this.Size = new System.Drawing.Size(893, 539);
this.Load += new System.EventHandler(this.Shifter_Load);
this.panel1.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.pnlpreview.ResumeLayout(false);
this.pnlwindow.ResumeLayout(false);
this.pnlcontents.ResumeLayout(false);
this.pnlcontents.PerformLayout();
this.pnltitle.ResumeLayout(false);
this.pnltitle.PerformLayout();
this.pnlbottom.ResumeLayout(false);
this.pnlsettingsholder.ResumeLayout(false);
this.pnlcategoryholder.ResumeLayout(false);
this.mspreview.ResumeLayout(false);
this.mspreview.PerformLayout();
this.tspreview.ResumeLayout(false);
this.tspreview.PerformLayout();
this.pnlintro.ResumeLayout(false);
this.pnldesktoppreview.ResumeLayout(false);
this.pnlscreensaver.ResumeLayout(false);
this.desktoppanel.ResumeLayout(false);
this.desktoppanel.PerformLayout();
this.sysmenuholder.ResumeLayout(false);
this.sysmenuholder.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.pnladvancedal.ResumeLayout(false);
this.pnlalsystemactions.ResumeLayout(false);
this.pnlalsystemactions.PerformLayout();
this.pnlstatus.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -176,13 +786,69 @@ namespace ShiftOS.WinForms.Applications
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel pnlcategoryholder;
private System.Windows.Forms.FlowLayoutPanel flmeta;
private System.Windows.Forms.Button btnapply;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel pnlsettingsholder;
private System.Windows.Forms.FlowLayoutPanel flbody;
private System.Windows.Forms.FlowLayoutPanel flcategory;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Panel pnlpreview;
private System.Windows.Forms.Panel pnlwindow;
private System.Windows.Forms.Panel pnlcontents;
private System.Windows.Forms.Panel pnltitle;
private System.Windows.Forms.Panel pnlicon;
private System.Windows.Forms.Panel pnlminimize;
private System.Windows.Forms.Panel pnlmaximize;
private System.Windows.Forms.Panel pnlclose;
private System.Windows.Forms.Panel pnltitleleft;
private System.Windows.Forms.Panel pnltitleright;
private System.Windows.Forms.Label lbtitletext;
private System.Windows.Forms.Panel pnlbottom;
private System.Windows.Forms.Panel pnlbottomr;
private System.Windows.Forms.Panel pnlbottoml;
private System.Windows.Forms.Panel pnlright;
private System.Windows.Forms.Panel pnlleft;
private System.Windows.Forms.MenuStrip mspreview;
private System.Windows.Forms.ToolStripMenuItem menuToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem menuItem1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem menuItem2ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem subitem1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem subitem2ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem subitem3ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator separatorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem menuItem3ToolStripMenuItem;
private System.Windows.Forms.ToolStrip tspreview;
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.ToolStripButton toolStripButton3;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripTextBox toolStripTextBox1;
private System.Windows.Forms.Panel pnlintro;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel pnldesktoppreview;
private System.Windows.Forms.Panel pnlscreensaver;
private System.Windows.Forms.Panel pnlssicon;
private System.Windows.Forms.Panel desktoppanel;
private System.Windows.Forms.Label lbtime;
private System.Windows.Forms.FlowLayoutPanel panelbuttonholder;
private System.Windows.Forms.Panel sysmenuholder;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem apps;
private System.Windows.Forms.Panel pnladvancedal;
private System.Windows.Forms.FlowLayoutPanel flapps;
private System.Windows.Forms.FlowLayoutPanel flcategories;
private System.Windows.Forms.Panel pnlalsystemactions;
private System.Windows.Forms.Button btnshutdown;
private System.Windows.Forms.Panel pnlstatus;
private System.Windows.Forms.Label lbalstatus;
private System.Windows.Forms.ToolStripMenuItem item1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem item2ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem item3ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem item4ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem item5ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator separatorToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem shutdownToolStripMenuItem;
}
}

File diff suppressed because it is too large Load diff

View file

@ -117,4 +117,74 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>230, 17</value>
</metadata>
<metadata name="tspreview.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>127, 17</value>
</metadata>
<metadata name="mspreview.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="mspreview.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="tspreview.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>127, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="toolStripButton2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="toolStripButton3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="label2.Text" xml:space="preserve">
<value>The Shifter is a brilliant application for ShiftOS that allows you to customize almost every aspect of the user interface.
To use the Shifter, simply select a category from the left, then a list of sub-categories will show up. Choose a sub-category, then a list of settings will appear. You can modify any one of these settings. A live preview of what you are editing will show, and you can use it to see what your new user experience will look like.
When you are done, hit Apply Changes to apply your changes!
You can also earn Codepoints through the Shifter. The more you tweak and customize, the more Codepoints you'll earn! Go nuts! Shift it your way!</value>
</data>
</root>

View file

@ -57,13 +57,12 @@ namespace ShiftOS.WinForms.Applications
this.btnforward = new System.Windows.Forms.Button();
this.txturl = new System.Windows.Forms.TextBox();
this.btngo = new System.Windows.Forms.Button();
this.wbcanvas = new System.Windows.Forms.WebBrowser();
this.pnlcanvas = new System.Windows.Forms.Panel();
this.flcontrols.SuspendLayout();
this.SuspendLayout();
//
// flcontrols
//
this.flcontrols.AutoSize = true;
this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flcontrols.Controls.Add(this.btnback);
this.flcontrols.Controls.Add(this.btnforward);
@ -123,42 +122,35 @@ namespace ShiftOS.WinForms.Applications
this.btngo.UseVisualStyleBackColor = true;
this.btngo.Click += new System.EventHandler(this.btngo_Click);
//
// wbcanvas
// pnlcanvas
//
this.wbcanvas.Dock = System.Windows.Forms.DockStyle.Fill;
this.wbcanvas.IsWebBrowserContextMenuEnabled = false;
this.wbcanvas.Location = new System.Drawing.Point(0, 29);
this.wbcanvas.MinimumSize = new System.Drawing.Size(20, 20);
this.wbcanvas.Name = "wbcanvas";
this.wbcanvas.ScriptErrorsSuppressed = true;
this.wbcanvas.Size = new System.Drawing.Size(805, 510);
this.wbcanvas.TabIndex = 1;
this.wbcanvas.WebBrowserShortcutsEnabled = false;
this.wbcanvas.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbcanvas_Navigated);
this.wbcanvas.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.wbcanvas_Navigating);
this.pnlcanvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlcanvas.Location = new System.Drawing.Point(0, 29);
this.pnlcanvas.Name = "pnlcanvas";
this.pnlcanvas.Size = new System.Drawing.Size(805, 510);
this.pnlcanvas.TabIndex = 1;
//
// Shiftnet
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.wbcanvas);
this.Controls.Add(this.pnlcanvas);
this.Controls.Add(this.flcontrols);
this.Name = "Shiftnet";
this.Size = new System.Drawing.Size(805, 539);
this.flcontrols.ResumeLayout(false);
this.flcontrols.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flcontrols;
private System.Windows.Forms.Button btnback;
private System.Windows.Forms.Button btnforward;
private System.Windows.Forms.TextBox txturl;
private System.Windows.Forms.Button btngo;
private System.Windows.Forms.WebBrowser wbcanvas;
private System.Windows.Forms.Panel pnlcanvas;
private System.Windows.Forms.FlowLayoutPanel flcontrols;
}
}

View file

@ -34,164 +34,52 @@ using System.Windows.Forms;
using ShiftOS.Engine;
using Newtonsoft.Json;
using static ShiftOS.Engine.SkinEngine;
using ShiftOS.WinForms.Tools;
using System.IO;
using System.Reflection;
namespace ShiftOS.WinForms.Applications
{
[Launcher("Shiftnet", false, null, "Networking")]
//OH MY GOD. I HAD TO CORRECT HEAPS OF BADLY PLACED CURLY BRACES.
//
//I DO NOT CARE WHAT THE BLUE SMILEY FACE SAYS. CURLY BRACES BELONG ON THEIR OWN LINE.
//
//READ THE DAMN SHIFTOS CODING GUIDELINES.
[Launcher("Shiftnet", true, "al_shiftnet", "Networking")]
[MultiplayerOnly]
[DefaultTitle("Shiftnet")]
[WinOpen("shiftnet")]
[RequiresUpgrade("victortran_shiftnet")]
[DefaultIcon("iconShiftnet")]
public partial class Shiftnet : UserControl, IShiftOSWindow
public partial class Shiftnet : UserControl, IShiftOSWindow, IShiftnetClient
{
public Shiftnet()
{
InitializeComponent();
ServerManager.MessageReceived += (msg) =>
{
try
{
if (msg.Name == "shiftnet_file")
{
this.Invoke(new Action(() =>
{
wbcanvas.DocumentText = ConstructHtml(msg.Contents);
}));
}
}
catch
{
}
};
}
public string ConstructHtml(string markdown)
{
string html = $@"<html>
<head>
<style>
body {{
background-color: rgb({LoadedSkin.ControlColor.R}, {LoadedSkin.ControlColor.G}, {LoadedSkin.ControlColor.B});
color: rgb({LoadedSkin.ControlTextColor.R}, {LoadedSkin.ControlTextColor.G}, {LoadedSkin.ControlTextColor.B});
font-family: ""{LoadedSkin.MainFont.Name}"";
font-size: {LoadedSkin.MainFont.SizeInPoints}pt;
}}
h1 {{
font-family: ""{LoadedSkin.HeaderFont.Name}"";
font-size: {LoadedSkin.HeaderFont.SizeInPoints}pt;
}}
h2 {{
font-family: ""{LoadedSkin.Header2Font.Name}"";
font-size: {LoadedSkin.Header2Font.SizeInPoints}pt;
}}
h3 {{
font-family: ""{LoadedSkin.Header3Font.Name}"";
font-size: {LoadedSkin.Header3Font.SizeInPoints}pt;
}}
pre, code {{
font-family: ""{LoadedSkin.TerminalFont.Name}"";
font-size: {LoadedSkin.TerminalFont.SizeInPoints}pt;
color: rgb({LoadedSkin.TerminalForeColor.R}, {LoadedSkin.TerminalForeColor.G}, {LoadedSkin.TerminalForeColor.B});
background-color: rgb({LoadedSkin.TerminalBackColor.R}, {LoadedSkin.TerminalBackColor.G}, {LoadedSkin.TerminalBackColor.B});
}}
</style>
</head>
<body>
<markdown/>
</body>
</html>";
string body = CommonMark.CommonMarkConverter.Convert(markdown);
for(int i = 0; i <= Encoding.UTF8.GetBytes(body).Length; i += DownloadManager.GetDownloadSpeed())
{
//halt the page load until 'download' finishes.
}
html = html.Replace("<markdown/>", body);
return html;
}
public string CurrentUrl { get; set; }
private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
string Url = e.Url.ToString().Replace("http://", "");
if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:"))
{
e.Cancel = true;
Future.Clear();
ShiftnetNavigate(Url.ToString());
}
}
public Stack<string> History = new Stack<string>();
public Stack<string> Future = new Stack<string>();
public void ShiftnetNavigate(string Url, bool pushHistory = true)
{
if (Url.EndsWith(".rnp") || !Url.Contains("."))
{
if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory)
History.Push(CurrentUrl);
CurrentUrl = Url;
ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new
{
url = Url
}));
txturl.Text = Url;
}
else
{
ServerMessageReceived smr = null;
smr = (msg) =>
{
if(msg.Name == "download_meta")
{
var bytes = JsonConvert.DeserializeObject<byte[]>(msg.Contents);
string destPath = null;
string ext = Url.Split('.')[Url.Split('.').Length - 1];
this.Invoke(new Action(() =>
{
FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action<string>((file) =>
{
destPath = file;
}));
}));
while (string.IsNullOrEmpty(destPath))
{
}
var d = new Download
{
ShiftnetUrl = Url,
Destination = destPath,
Bytes = bytes,
Progress = 0,
};
DownloadManager.StartDownload(d);
this.Invoke(new Action(() =>
{
AppearanceManager.SetupWindow(new Downloader());
}));
ServerManager.MessageReceived -= smr;
}
};
ServerManager.MessageReceived += smr;
ServerManager.SendMessage("download_start", Url);
}
}
public IShiftnetSite CurrentPage = null;
public void OnLoad()
{
ShiftnetNavigate("shiftnet/main");
NavigateToUrl("shiftnet/main");
}
public void OnSkinLoad()
{
ShiftnetNavigate(CurrentUrl);
CurrentPage?.OnSkinLoad();
btnback.Location = new Point(2, 2);
btnforward.Location = new Point(btnback.Left + btnback.Width + 2, 2);
txturl.Location = new Point(btnforward.Left + btnforward.Width + 2, 2);
txturl.Width = flcontrols.Width - btnback.Width - 2 - btnforward.Width - 2 - (btngo.Width*2) - 2;
btngo.Location = new Point(flcontrols.Width - btngo.Width - 2, 2);
}
public bool OnUnload()
@ -201,6 +89,7 @@ namespace ShiftOS.WinForms.Applications
public void OnUpgrade()
{
CurrentPage?.OnUpgrade();
}
private void btnback_Click(object sender, EventArgs e)
@ -211,7 +100,7 @@ namespace ShiftOS.WinForms.Applications
if (!string.IsNullOrEmpty(hist))
{
Future.Push(hist);
ShiftnetNavigate(hist, false);
NavigateToUrl(hist);
}
}
catch
@ -227,7 +116,8 @@ namespace ShiftOS.WinForms.Applications
string fut = Future.Pop();
if (!string.IsNullOrEmpty(fut))
{
ShiftnetNavigate(fut);
History.Push(CurrentUrl);
NavigateToUrl(fut);
}
}
catch
@ -241,22 +131,109 @@ namespace ShiftOS.WinForms.Applications
if (!string.IsNullOrWhiteSpace(txturl.Text))
{
Future.Clear();
ShiftnetNavigate(txturl.Text);
History.Push(CurrentUrl);
NavigateToUrl(txturl.Text);
}
}
private void txturl_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
if (e.KeyCode == Keys.Enter)
{
btngo_Click(sender, EventArgs.Empty);
e.SuppressKeyPress = true;
}
}
private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e)
public void NavigateToUrl(string url)
{
txturl.Text = url;
foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory))
{
if(exe.EndsWith(".exe") || exe.EndsWith(".dll"))
{
try
{
var asm = Assembly.LoadFile(exe);
foreach (var type in asm.GetTypes())
{
if (type.GetInterfaces().Contains(typeof(IShiftnetSite)))
{
if (type.BaseType == typeof(UserControl))
{
var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute;
if (attribute != null)
{
if (attribute.Url == url)
{
if (Shiftorium.UpgradeAttributesUnlocked(type))
{
var obj = (IShiftnetSite)Activator.CreateInstance(type, null);
obj.GoToUrl += (u) =>
{
History.Push(u);
NavigateToUrl(u);
};
obj.GoBack += () =>
{
string u = History.Pop();
Future.Push(u);
NavigateToUrl(u);
};
CurrentPage = obj;
this.pnlcanvas.Controls.Clear();
this.pnlcanvas.Controls.Add((UserControl)obj);
((UserControl)obj).Show();
((UserControl)obj).Dock = DockStyle.Fill;
obj.OnUpgrade();
obj.OnSkinLoad();
obj.Setup();
return;
}
}
}
}
}
}
}
catch (Exception ex)
{
pnlcanvas.Controls.Clear();
var tlbl = new Label();
tlbl.Text = "Server error in \"" + url + "\" application.";
tlbl.Tag = "header1";
tlbl.AutoSize = true;
tlbl.Location = new Point(10, 10);
tlbl.Dock = DockStyle.Top;
pnlcanvas.Controls.Add(tlbl);
tlbl.Show();
var crash = new Label();
crash.Dock = DockStyle.Fill;
crash.AutoSize = false;
crash.Text = ex.ToString();
pnlcanvas.Controls.Add(crash);
crash.Show();
crash.BringToFront();
ControlManager.SetupControls(pnlcanvas);
return;
}
}
}
pnlcanvas.Controls.Clear();
var lbl = new Label();
lbl.Text = "Page not found!";
lbl.Tag = "header1";
lbl.AutoSize = true;
lbl.Location = new Point(10, 10);
pnlcanvas.Controls.Add(lbl);
lbl.Show();
}
public void RefreshSite()
{
NavigateToUrl(CurrentUrl);
}
}
}

View file

@ -56,20 +56,26 @@ namespace ShiftOS.WinForms.Applications
{
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.lbupgradedesc = new System.Windows.Forms.Label();
this.pnlupgradeactions = new System.Windows.Forms.Panel();
this.btnbuy = new System.Windows.Forms.Button();
this.lbupgradetitle = new System.Windows.Forms.Label();
this.pnllist = new System.Windows.Forms.Panel();
this.lbnoupgrades = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.lblcategorytext = new System.Windows.Forms.Label();
this.btncat_forward = new System.Windows.Forms.Button();
this.btncat_back = new System.Windows.Forms.Button();
this.lbcodepoints = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.pgupgradeprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar();
this.lbupgrades = new System.Windows.Forms.ListBox();
this.label3 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.pnlupgradeactions.SuspendLayout();
this.pnllist.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// panel1
@ -93,30 +99,6 @@ namespace ShiftOS.WinForms.Applications
this.panel2.Size = new System.Drawing.Size(376, 427);
this.panel2.TabIndex = 1;
//
// label2
//
if (ShiftoriumFrontend.UpgradeInstalled("shiftorium_gui_codepoints_display"))
{
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(128, 357);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(135, 13);
this.label2.TabIndex = 3;
this.label2.Text = "You have: %cp Codepoints";
this.label2.Click += new System.EventHandler(this.label2_Click);
} else
{
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(128, 357);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(1, 1);
this.label2.TabIndex = 3;
this.label2.Text = "";
this.label2.Click += new System.EventHandler(this.label2_Click);
}
//
// lbupgradedesc
//
this.lbupgradedesc.Dock = System.Windows.Forms.DockStyle.Fill;
@ -165,7 +147,9 @@ namespace ShiftOS.WinForms.Applications
//
// pnllist
//
this.pnllist.Controls.Add(this.label2);
this.pnllist.Controls.Add(this.lbnoupgrades);
this.pnllist.Controls.Add(this.panel3);
this.pnllist.Controls.Add(this.lbcodepoints);
this.pnllist.Controls.Add(this.label1);
this.pnllist.Controls.Add(this.pgupgradeprogress);
this.pnllist.Controls.Add(this.lbupgrades);
@ -175,6 +159,75 @@ namespace ShiftOS.WinForms.Applications
this.pnllist.Size = new System.Drawing.Size(406, 427);
this.pnllist.TabIndex = 0;
//
// lbnoupgrades
//
this.lbnoupgrades.AutoSize = true;
this.lbnoupgrades.Location = new System.Drawing.Point(69, 183);
this.lbnoupgrades.Name = "lbnoupgrades";
this.lbnoupgrades.Size = new System.Drawing.Size(71, 13);
this.lbnoupgrades.TabIndex = 6;
this.lbnoupgrades.Tag = "header2";
this.lbnoupgrades.Text = "No upgrades!";
this.lbnoupgrades.Visible = false;
//
// panel3
//
this.panel3.Controls.Add(this.lblcategorytext);
this.panel3.Controls.Add(this.btncat_forward);
this.panel3.Controls.Add(this.btncat_back);
this.panel3.Location = new System.Drawing.Point(6, 76);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(394, 23);
this.panel3.TabIndex = 5;
//
// lblcategorytext
//
this.lblcategorytext.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblcategorytext.Location = new System.Drawing.Point(29, 0);
this.lblcategorytext.Name = "lblcategorytext";
this.lblcategorytext.Size = new System.Drawing.Size(336, 23);
this.lblcategorytext.TabIndex = 2;
this.lblcategorytext.Text = "No Upgrades";
this.lblcategorytext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblcategorytext.Click += new System.EventHandler(this.lblcategorytext_Click);
//
// btncat_forward
//
this.btncat_forward.AutoSize = true;
this.btncat_forward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btncat_forward.Dock = System.Windows.Forms.DockStyle.Right;
this.btncat_forward.Location = new System.Drawing.Point(365, 0);
this.btncat_forward.Name = "btncat_forward";
this.btncat_forward.Size = new System.Drawing.Size(29, 23);
this.btncat_forward.TabIndex = 1;
this.btncat_forward.Text = "-->";
this.btncat_forward.UseVisualStyleBackColor = true;
this.btncat_forward.Click += new System.EventHandler(this.btncat_forward_Click);
//
// btncat_back
//
this.btncat_back.AutoSize = true;
this.btncat_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btncat_back.Dock = System.Windows.Forms.DockStyle.Left;
this.btncat_back.Location = new System.Drawing.Point(0, 0);
this.btncat_back.Name = "btncat_back";
this.btncat_back.Size = new System.Drawing.Size(29, 23);
this.btncat_back.TabIndex = 0;
this.btncat_back.Text = "<--";
this.btncat_back.UseVisualStyleBackColor = true;
this.btncat_back.Click += new System.EventHandler(this.btncat_back_Click);
//
// lbcodepoints
//
this.lbcodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lbcodepoints.AutoSize = true;
this.lbcodepoints.Location = new System.Drawing.Point(128, 357);
this.lbcodepoints.Name = "lbcodepoints";
this.lbcodepoints.Size = new System.Drawing.Size(135, 13);
this.lbcodepoints.TabIndex = 3;
this.lbcodepoints.Text = "You have: %cp Codepoints";
this.lbcodepoints.Click += new System.EventHandler(this.lbcodepoints_Click);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -185,27 +238,14 @@ namespace ShiftOS.WinForms.Applications
this.label1.TabIndex = 2;
this.label1.Text = "{UPGRADE_PROGRESS}:";
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 399);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(137, 13);
this.label3.TabIndex = 2;
int upgradepercent = (pgupgradeprogress.Value / 100) * 100;
this.label3.Text = upgradepercent.ToString();
//
// pgupgradeprogress
//
this.pgupgradeprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pgupgradeprogress.BlockSize = 5;
this.pgupgradeprogress.Location = new System.Drawing.Point(146, 390);
this.pgupgradeprogress.Maximum = 100;
this.pgupgradeprogress.Name = "pgupgradeprogress";
this.pgupgradeprogress.Size = new System.Drawing.Size(254, 23);
this.pgupgradeprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.pgupgradeprogress.TabIndex = 1;
this.pgupgradeprogress.Value = 25;
//
@ -216,12 +256,21 @@ namespace ShiftOS.WinForms.Applications
| System.Windows.Forms.AnchorStyles.Right)));
this.lbupgrades.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.lbupgrades.FormattingEnabled = true;
this.lbupgrades.Location = new System.Drawing.Point(3, 66);
this.lbupgrades.Location = new System.Drawing.Point(3, 105);
this.lbupgrades.Name = "lbupgrades";
this.lbupgrades.Size = new System.Drawing.Size(397, 277);
this.lbupgrades.Size = new System.Drawing.Size(397, 238);
this.lbupgrades.TabIndex = 0;
this.lbupgrades.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lbupgrades_DrawItem);
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 399);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(137, 13);
this.label3.TabIndex = 2;
//
// ShiftoriumFrontend
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -230,7 +279,6 @@ namespace ShiftOS.WinForms.Applications
this.Controls.Add(this.panel1);
this.ForeColor = System.Drawing.Color.LightGreen;
this.Name = "ShiftoriumFrontend";
this.Text = "{SHIFTORIUM_NAME}";
this.Size = new System.Drawing.Size(782, 427);
this.Load += new System.EventHandler(this.Shiftorium_Load);
this.panel1.ResumeLayout(false);
@ -239,6 +287,8 @@ namespace ShiftOS.WinForms.Applications
this.pnlupgradeactions.PerformLayout();
this.pnllist.ResumeLayout(false);
this.pnllist.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.ResumeLayout(false);
}
@ -255,7 +305,12 @@ namespace ShiftOS.WinForms.Applications
private System.Windows.Forms.Button btnbuy;
private ShiftedProgressBar pgupgradeprogress;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lbcodepoints;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label lblcategorytext;
private System.Windows.Forms.Button btncat_forward;
private System.Windows.Forms.Button btncat_back;
private System.Windows.Forms.Label lbnoupgrades;
}
}

View file

@ -30,6 +30,7 @@ using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
@ -39,18 +40,24 @@ namespace ShiftOS.WinForms.Applications
{
[Launcher("Shiftorium", true, "al_shiftorium", "Utilities")]
[RequiresUpgrade("shiftorium_gui")]
[MultiplayerOnly]
[WinOpen("shiftorium")]
[DefaultTitle("Shiftorium")]
[DefaultIcon("iconShiftorium")]
public partial class ShiftoriumFrontend : UserControl, IShiftOSWindow
{
public int CategoryId = 0;
public static System.Timers.Timer timer100;
public ShiftoriumFrontend()
{
cp_update = new System.Windows.Forms.Timer();
cp_update.Tick += (o, a) =>
{
lbcodepoints.Text = $"You have {SaveSystem.CurrentSave.Codepoints} Codepoints.";
};
cp_update.Interval = 100;
InitializeComponent();
PopulateShiftorium();
lbupgrades.SelectedIndexChanged += (o, a) =>
@ -84,17 +91,75 @@ namespace ShiftOS.WinForms.Applications
public void PopulateShiftorium()
{
lbupgrades.Items.Clear();
upgrades.Clear();
Timer();
label2.Text = "You have: " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints";
foreach (var upg in backend.GetAvailable())
var t = new Thread(() =>
{
String name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP";
upgrades.Add(name, upg);
lbupgrades.Items.Add(name);
}
try
{
Desktop.InvokeOnWorkerThread(() =>
{
lbnoupgrades.Hide();
lbupgrades.Items.Clear();
upgrades.Clear();
Timer();
});
foreach (var upg in backend.GetAvailable().Where(x => x.Category == backend.GetCategories()[CategoryId]))
{
string name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP";
upgrades.Add(name, upg);
Desktop.InvokeOnWorkerThread(() =>
{
lbupgrades.Items.Add(name);
});
}
if (lbupgrades.Items.Count == 0)
{
Desktop.InvokeOnWorkerThread(() =>
{
lbnoupgrades.Show();
lbnoupgrades.Location = new Point(
(lbupgrades.Width - lbnoupgrades.Width) / 2,
lbupgrades.Top + (lbupgrades.Height - lbnoupgrades.Height) / 2
);
});
}
else
{
Desktop.InvokeOnWorkerThread(() =>
{
lbnoupgrades.Hide();
});
}
Desktop.InvokeOnWorkerThread(() =>
{
try
{
lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId];
btncat_back.Visible = (CategoryId > 0);
btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1);
}
catch
{
}
});
}
catch
{
Desktop.InvokeOnWorkerThread(() =>
{
lbnoupgrades.Show();
lbnoupgrades.Location = new Point(
(lbupgrades.Width - lbnoupgrades.Width) / 2,
lbupgrades.Top + (lbupgrades.Height - lbnoupgrades.Height) / 2
);
});
}
});
t.IsBackground = true;
t.Start();
}
public static bool UpgradeInstalled(string upg)
@ -148,9 +213,38 @@ namespace ShiftOS.WinForms.Applications
private void btnbuy_Click(object sender, EventArgs e)
{
long cpCost = 0;
backend.Silent = true;
backend.Buy(upgrades[lbupgrades.SelectedItem.ToString()].ID, upgrades[lbupgrades.SelectedItem.ToString()].Cost);
backend.Silent = false;
Dictionary<string, long> UpgradesToBuy = new Dictionary<string, long>();
foreach (var itm in lbupgrades.SelectedItems)
{
cpCost += upgrades[itm.ToString()].Cost;
UpgradesToBuy.Add(upgrades[itm.ToString()].ID, upgrades[itm.ToString()].Cost);
}
if (SaveSystem.CurrentSave.Codepoints < cpCost)
{
Infobox.Show("Insufficient Codepoints", $"You do not have enough Codepoints to perform this action. You need {cpCost - SaveSystem.CurrentSave.Codepoints} more.");
}
else
{
foreach(var upg in UpgradesToBuy)
{
SaveSystem.CurrentSave.Codepoints -= upg.Value;
if (SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.Key))
{
SaveSystem.CurrentSave.Upgrades[upg.Key] = true;
}
else
{
SaveSystem.CurrentSave.Upgrades.Add(upg.Key, true);
}
SaveSystem.SaveGame();
backend.InvokeUpgradeInstalled();
}
}
backend.Silent = false;
PopulateShiftorium();
btnbuy.Hide();
}
@ -161,6 +255,8 @@ namespace ShiftOS.WinForms.Applications
public void OnLoad()
{
cp_update.Start();
lbnoupgrades.Hide();
}
public void OnSkinLoad()
@ -168,17 +264,22 @@ namespace ShiftOS.WinForms.Applications
}
System.Windows.Forms.Timer cp_update = new System.Windows.Forms.Timer();
public bool OnUnload()
{
cp_update.Stop();
cp_update = null;
return true;
}
public void OnUpgrade()
{
lbupgrades.SelectionMode = (UpgradeInstalled("shiftorium_gui_bulk_buy") == true) ? SelectionMode.MultiExtended : SelectionMode.One;
lbcodepoints.Visible = Shiftorium.UpgradeInstalled("shiftorium_gui_codepoints_display");
}
private void label2_Click(object sender, EventArgs e)
private void lbcodepoints_Click(object sender, EventArgs e)
{
}
@ -187,9 +288,33 @@ namespace ShiftOS.WinForms.Applications
{
timer100 = new System.Timers.Timer();
timer100.Interval = 2000;
//CLARIFICATION: What is this supposed to do? - Michael
//timer100.Elapsed += ???;
timer100.AutoReset = true;
timer100.Enabled = true;
}
private void btncat_back_Click(object sender, EventArgs e)
{
if(CategoryId > 0)
{
CategoryId--;
PopulateShiftorium();
}
}
private void btncat_forward_Click(object sender, EventArgs e)
{
if(CategoryId < backend.GetCategories().Length - 1)
{
CategoryId++;
PopulateShiftorium();
}
}
private void lblcategorytext_Click(object sender, EventArgs e)
{
}
}
}

View file

@ -47,18 +47,29 @@ namespace ShiftOS.WinForms.Applications
public Skin_Loader()
{
InitializeComponent();
SetupControls(pnlborder);
SetupControls(pnldesktop);
LoadedSkin = JsonConvert.DeserializeObject<Skin>(JsonConvert.SerializeObject(SkinEngine.LoadedSkin));
this.Load += (o, a) => { SetupUI(); };
}
public void SetupControls(Control ctrl)
{
ctrl.Tag = "keepbg keepfg keepfont";
foreach (Control c in ctrl.Controls)
SetupControls(c);
}
public Skin LoadedSkin { get; set; }
public void SetupUI()
{
SetupDesktop();
Setup();
if (LoadedSkin != null)
{
SetupDesktop();
Setup();
}
}
public void SetupDesktop()
@ -70,7 +81,7 @@ namespace ShiftOS.WinForms.Applications
//upgrades
if (SaveSystem.CurrentSave != null)
if (SaveSystem.CurrentSave != null && LoadedSkin != null)
{
desktoppanel.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop");
lbtime.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop_clock_widget");
@ -295,7 +306,7 @@ namespace ShiftOS.WinForms.Applications
System.IO.Directory.CreateDirectory(Paths.SharedFolder + "\\skins");
}
string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentSave.Username + "-" + fname;
string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentUser.Username + "-" + fname;
System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(LoadedSkin));
})));
@ -305,7 +316,15 @@ namespace ShiftOS.WinForms.Applications
{
AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Open, new Action<string>((filename) =>
{
LoadedSkin = JsonConvert.DeserializeObject<Skin>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(filename));
try
{
LoadedSkin = JsonConvert.DeserializeObject<Skin>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(filename));
}
catch
{
Infobox.Show("Invalid Skin", "This skin is not compatible with this version of ShiftOS.");
}
SetupUI();
})));
}
@ -318,6 +337,7 @@ namespace ShiftOS.WinForms.Applications
public void OnSkinLoad()
{
SetupUI();
}
public bool OnUnload()
@ -327,6 +347,7 @@ namespace ShiftOS.WinForms.Applications
public void OnUpgrade()
{
SetupUI();
}
}
}

View file

@ -43,6 +43,7 @@ using System.Collections;
using static ShiftOS.Engine.SkinEngine;
using ShiftOS.Engine;
using ShiftOS.Objects;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
@ -57,7 +58,6 @@ namespace ShiftOS.WinForms.Applications
public static string latestCommmand = "";
public static bool IsInRemoteSystem = false;
public static string RemoteGuid = "";
@ -116,7 +116,7 @@ namespace ShiftOS.WinForms.Applications
[Obsolete("This is used for compatibility with old parts of the backend. Please use TerminalBackend instead.")]
public static void InvokeCommand(string text)
{
TerminalBackend.InvokeCommand(text);
}
@ -130,17 +130,30 @@ namespace ShiftOS.WinForms.Applications
{
this.Invoke(new Action(() =>
{
ResetAllKeywords();
rtbterm.Text = "";
TerminalBackend.PrefixEnabled = true;
TerminalBackend.InStory = false;
Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
if (Shiftorium.UpgradeInstalled("wm_free_placement"))
if (Shiftorium.UpgradeInstalled("first_steps"))
{
this.ParentForm.Width = 640;
this.ParentForm.Height = 480;
this.ParentForm.Left = (Screen.PrimaryScreen.Bounds.Width - 640) / 2;
this.ParentForm.Top = (Screen.PrimaryScreen.Bounds.Height - 480) / 2;
if (!Shiftorium.UpgradeInstalled("desktop"))
{
TerminalBackend.PrefixEnabled = true;
TerminalBackend.InStory = false;
TerminalBackend.PrintPrompt();
if (Shiftorium.UpgradeInstalled("wm_free_placement"))
{
this.ParentForm.Width = 640;
this.ParentForm.Height = 480;
this.ParentForm.Left = (Screen.PrimaryScreen.Bounds.Width - 640) / 2;
this.ParentForm.Top = (Screen.PrimaryScreen.Bounds.Height - 480) / 2;
}
}
else
{
AppearanceManager.Close(this);
}
}
else
{
Story.Start("first_steps");
}
}));
@ -188,52 +201,6 @@ namespace ShiftOS.WinForms.Applications
public static event TextSentEventHandler TextSent;
public void ResetAllKeywords()
{
string primary = SaveSystem.CurrentSave.Username + " ";
string secondary = "shiftos ";
var asm = Assembly.GetExecutingAssembly();
var types = asm.GetTypes();
foreach (var type in types)
{
foreach (var a in type.GetCustomAttributes(false))
{
if (ShiftoriumFrontend.UpgradeAttributesUnlocked(type))
{
if (a is Namespace)
{
var ns = a as Namespace;
if (!primary.Contains(ns.name))
{
primary += ns.name + " ";
}
foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
{
if (ShiftoriumFrontend.UpgradeAttributesUnlocked(method))
{
foreach (var ma in method.GetCustomAttributes(false))
{
if (ma is Command)
{
var cmd = ma as Command;
if (!secondary.Contains(cmd.name))
secondary += cmd.name + " ";
}
}
}
}
}
}
}
}
}
public static void MakeWidget(Controls.TerminalBox txt)
{
AppearanceManager.StartConsoleOut();
@ -243,15 +210,29 @@ namespace ShiftOS.WinForms.Applications
};
txt.KeyDown += (o, a) =>
{
if (a.Control == true || a.Alt == true)
{
a.SuppressKeyPress = true;
return;
}
if (a.KeyCode == Keys.Enter)
{
try
{
a.SuppressKeyPress = true;
Console.WriteLine("");
if (!TerminalBackend.InStory)
a.SuppressKeyPress = false;
if (!TerminalBackend.PrefixEnabled)
{
string textraw = txt.Lines[txt.Lines.Length - 1];
TextSent?.Invoke(textraw);
TerminalBackend.SendText(textraw);
return;
}
var text = txt.Lines.ToArray();
var text2 = text[text.Length - 2];
var text2 = text[text.Length - 1];
var text3 = "";
Console.WriteLine();
var text4 = Regex.Replace(text2, @"\t|\n|\r", "");
if (IsInRemoteSystem == true)
@ -266,17 +247,41 @@ namespace ShiftOS.WinForms.Applications
{
if (TerminalBackend.PrefixEnabled)
{
text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length);
text3 = text4.Remove(0, $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length);
}
TerminalBackend.LastCommand = text3;
TextSent?.Invoke(text4);
TerminalBackend.SendText(text4);
if (TerminalBackend.InStory == false)
{
TerminalBackend.InvokeCommand(text3);
if (text3 == "stop theme")
{
CurrentCommandParser.parser = null;
}
else
{
if (CurrentCommandParser.parser == null)
{
TerminalBackend.InvokeCommand(text3);
}
else
{
var result = CurrentCommandParser.parser.ParseCommand(text3);
if (result.Equals(default(KeyValuePair<KeyValuePair<string, string>, Dictionary<string, string>>)))
{
Console.WriteLine("Syntax Error: Syntax Error");
}
else
{
TerminalBackend.InvokeCommand(result.Key.Key, result.Key.Value, result.Value);
}
}
}
}
if (TerminalBackend.PrefixEnabled)
{
Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
TerminalBackend.PrintPrompt();
}
}
}
@ -290,7 +295,7 @@ namespace ShiftOS.WinForms.Applications
{
var tostring3 = txt.Lines[txt.Lines.Length - 1];
var tostringlen = tostring3.Length + 1;
var workaround = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var workaround = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var derp = workaround.Length + 1;
if (tostringlen != derp)
{
@ -310,7 +315,7 @@ namespace ShiftOS.WinForms.Applications
{
var getstring = txt.Lines[txt.Lines.Length - 1];
var stringlen = getstring.Length + 1;
var header = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var header = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ";
var headerlen = header.Length + 1;
var selstart = txt.SelectionStart;
var remstrlen = txt.TextLength - stringlen;
@ -325,11 +330,10 @@ namespace ShiftOS.WinForms.Applications
a.SuppressKeyPress = true;
}
}
//( ͡° ͜ʖ ͡° ) You found the lennyface without looking at the commit message. Message Michael in the #shiftos channel on Discord saying "ladouceur" somewhere in your message if you see this.
else if (a.KeyCode == Keys.Up)
{
var tostring3 = txt.Lines[txt.Lines.Length - 1];
if (tostring3 == $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ")
if (tostring3 == $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ")
Console.Write(TerminalBackend.LastCommand);
a.SuppressKeyPress = true;
@ -350,8 +354,8 @@ namespace ShiftOS.WinForms.Applications
txt.Focus();
txt.Font = LoadedSkin.TerminalFont;
txt.ForeColor = LoadedSkin.TerminalForeColor;
txt.BackColor = LoadedSkin.TerminalBackColor;
txt.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC);
txt.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC);
}
@ -359,18 +363,17 @@ namespace ShiftOS.WinForms.Applications
{
ServerManager.MessageReceived += (msg) =>
{
if(msg.Name == "trm_handshake_guid")
if (msg.Name == "trm_handshake_guid")
{
IsInRemoteSystem = true;
RemoteGuid = msg.GUID;
}
else if(msg.Name == "trm_handshake_stop")
else if (msg.Name == "trm_handshake_stop")
{
IsInRemoteSystem = false;
RemoteGuid = "";
}
};
}
private void Terminal_FormClosing(object sender, FormClosingEventArgs e)
@ -386,16 +389,136 @@ namespace ShiftOS.WinForms.Applications
if (SaveSystem.CurrentSave != null)
{
TerminalBackend.PrintPrompt();
if (!ShiftoriumFrontend.UpgradeInstalled("window_manager"))
{
rtbterm.Text = AppearanceManager.LastTerminalText;
rtbterm.Select(rtbterm.TextLength, 0);
}
Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ");
}
}
public static string RemoteSystemName { get; set; }
public static string RemoteUser { get; set; }
public static string RemotePass { get; set; }
[Story("first_steps")]
public static void FirstSteps()
{
TerminalBackend.PrefixEnabled = false;
new Thread(() =>
{
TerminalBackend.InStory = true;
Console.WriteLine("Hey there, and welcome to ShiftOS.");
Thread.Sleep(2000);
Console.WriteLine("My name is DevX. I am the developer of this operating system.");
Thread.Sleep(2000);
Console.WriteLine("Right now, I am using the Terminal application as a means of talking to you.");
Thread.Sleep(2000);
Console.WriteLine("ShiftOS is a very early operating system, but I have big plans for it.");
Thread.Sleep(2000);
Console.WriteLine("I can't reveal all my plans to you at this moment, but you play a big role.");
Thread.Sleep(2000);
Console.WriteLine("Your role in all of this is to help me develop ShiftOS more.");
Thread.Sleep(2000);
Console.WriteLine("You may not know how to program, but that's perfectly fine. You don't need to.");
Thread.Sleep(2000);
Console.WriteLine("What you do need to do, is simply use the operating system - like you would a regular computer.");
Thread.Sleep(2000);
Console.WriteLine("As you use ShiftOS, you will earn a special currency called Codepoints.");
Thread.Sleep(2000);
Console.WriteLine("The more things you do, the more Codepoints you get! Simple, right?");
Thread.Sleep(2000);
Console.WriteLine("Once you rack up enough Codepoints, you can use them inside the Shiftorium to buy new features for ShiftOS.");
Thread.Sleep(2000);
Console.WriteLine("These features include new programs, system enhancements, Terminal commands, and so much more!");
Thread.Sleep(2000);
Console.WriteLine("Ahh, that reminds me. I suppose you don't know how to use the Terminal yet, do you...");
Thread.Sleep(2000);
Console.WriteLine("Well, the ShiftOS terminal is similar to a regular Linux terminal, however things are a bit... how you say.... primitive.");
Thread.Sleep(2000);
Console.WriteLine("Let's just say.... I've been focusing more on function than form with this one.... Anyways, here's how the terminal works.");
Thread.Sleep(2000);
Console.WriteLine("Each command is categorized into a \"Namespace\". All a namespace is, is a nice way of distinguishing between commands.");
Thread.Sleep(2000);
Console.WriteLine("...For example you may have a bunch of commands for managing files, and others for opening/closing programs.");
Thread.Sleep(2000);
Console.WriteLine("The three main namespaces you'll be using for the next while are the \"sos\", \"shiftorium\", and \"win\" namespaces.");
Thread.Sleep(2000);
Console.WriteLine("To run a command, simply type its namespace, followed by a period/full-stop, followed by the command name.");
Thread.Sleep(2000);
Console.WriteLine("Give it a try! Type \"sos.help\" in the following prompt to view a list of all ShiftOS commands.");
Thread.Sleep(2000);
TerminalBackend.InStory = false;
TerminalBackend.PrefixEnabled = true;
TerminalBackend.PrintPrompt();
bool help_entered = false;
TerminalBackend.CommandProcessed += (text, args) =>
{
if (text.EndsWith("sos.help") && help_entered == false)
help_entered = true;
};
while (help_entered == false)
Thread.Sleep(10);
TerminalBackend.InStory = true;
TerminalBackend.PrefixEnabled = false;
Thread.Sleep(2000);
Console.WriteLine("Good job! Next, we will look at how to pass data to a command, such as win.open.");
Thread.Sleep(2000);
Console.WriteLine("In ShiftOS, passing data to a command is quite simple! After the command name, place an opening and closing curly brace, like so: \"win.open{}\".");
Thread.Sleep(2000);
Console.WriteLine("Everything between those two curly braces is treated as command data.");
Thread.Sleep(2000);
Console.WriteLine("However, you can't just spam a bunch of 1s and 0s and call it a day, nonono!");
Thread.Sleep(2000);
Console.WriteLine("Command data is split into a list of keys and values.");
Thread.Sleep(2000);
Console.WriteLine("The key tells the command the name of the data, and the value is what the command will see when it looks at the key.");
Thread.Sleep(2000);
Console.WriteLine("There are three main types of values. Booleans, which can be either \"true\" or \"false\", Numbers, which can be any integer number, positive or negative, and Strings - any piece of text as long as it is surrounded by double-quotes.");
Thread.Sleep(2000);
Console.WriteLine("For example, we could write every programmer's first program - by typing \"trm.echo{msg:\"Hello, world!\"}\". Running this will cause the Terminal to print, well, \"Hello, world!\"");
Thread.Sleep(2000);
Console.WriteLine("To open an application in ShiftOS, you can use this principle with the \"win.open\" command.");
Thread.Sleep(2000);
Console.WriteLine("First, type \"win.open\" with no data to see a list of all installed programs.");
Thread.Sleep(2000);
TerminalBackend.InStory = false;
bool winopenEntered = false;
TerminalBackend.PrefixEnabled = true;
TerminalBackend.PrintPrompt();
TerminalBackend.CommandProcessed += (text, args) =>
{
if (help_entered == true)
if (text.EndsWith("win.open") && winopenEntered == false)
winopenEntered = true;
};
while (winopenEntered == false)
Thread.Sleep(10);
TerminalBackend.InStory = true;
TerminalBackend.PrefixEnabled = false;
Thread.Sleep(2000);
Console.WriteLine("Pretty cool, it gave you a nice list of other win.open commands that will let you open each program.");
Thread.Sleep(2000);
Console.WriteLine("You've got the just of using ShiftOS. Now, for your goal.");
Thread.Sleep(2000);
Console.WriteLine("As you know, ShiftOS doesn't have very many features.");
Thread.Sleep(2000);
Console.WriteLine("Using the applications you have, I need you to earn as many Codepoints as you can.");
Thread.Sleep(2000);
Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn even more Codepoints.");
Thread.Sleep(2000);
Console.WriteLine("Once you earn 1,000 Codepoints, I will check back with you and see how well you've done.");
Thread.Sleep(2000);
Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal.");
Thread.Sleep(2000);
TerminalBackend.PrefixEnabled = true;
TerminalBackend.InStory = false;
SaveSystem.SaveGame();
Thread.Sleep(1000);
TerminalBackend.PrintPrompt();
}).Start();
}
public void OnSkinLoad()
@ -403,8 +526,8 @@ namespace ShiftOS.WinForms.Applications
try
{
rtbterm.Font = LoadedSkin.TerminalFont;
rtbterm.ForeColor = LoadedSkin.TerminalForeColor;
rtbterm.BackColor = LoadedSkin.TerminalBackColor;
rtbterm.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC);
rtbterm.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC);
}
catch
{
@ -429,7 +552,7 @@ namespace ShiftOS.WinForms.Applications
if (TerminalBackend.PrefixEnabled)
{
Console.Write($"{SaveSystem.CurrentSave.Username}@shiftos:~$ ");
Console.Write($"{SaveSystem.CurrentUser.Username}@shiftos:~$ ");
}
}
catch (Exception ex)
@ -451,7 +574,10 @@ namespace ShiftOS.WinForms.Applications
{
}
internal void ClearText()
{
rtbterm.Text = "";
}
}
}
//lol you found this comment i made so i chould push a change to make a point.
}

View file

@ -0,0 +1,312 @@
namespace ShiftOS.WinForms.Applications
{
partial class TriPresent
{
/// <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.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.addLabelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.addLabel = new System.Windows.Forms.Panel();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.yLabel = new System.Windows.Forms.Label();
this.xLabel = new System.Windows.Forms.Label();
this.yPosition = new System.Windows.Forms.NumericUpDown();
this.xPosition = new System.Windows.Forms.NumericUpDown();
this.labelContents = new System.Windows.Forms.TextBox();
this.addItemLabel = new System.Windows.Forms.Label();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.designerPanel = new System.Windows.Forms.Panel();
this.menuStrip1.SuspendLayout();
this.addLabel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.yPosition)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.xPosition)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.editToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(758, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openToolStripMenuItem,
this.saveToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "&File";
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
this.openToolStripMenuItem.Text = "&Open";
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
this.saveToolStripMenuItem.Text = "&Save";
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addToolStripMenuItem});
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Text = "&Edit";
//
// addToolStripMenuItem
//
this.addToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addLabelToolStripMenuItem});
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
this.addToolStripMenuItem.Size = new System.Drawing.Size(96, 22);
this.addToolStripMenuItem.Text = "Add";
//
// addLabelToolStripMenuItem
//
this.addLabelToolStripMenuItem.Name = "addLabelToolStripMenuItem";
this.addLabelToolStripMenuItem.Size = new System.Drawing.Size(127, 22);
this.addLabelToolStripMenuItem.Text = "Add Label";
this.addLabelToolStripMenuItem.Click += new System.EventHandler(this.addLabelToolStripMenuItem_Click);
//
// addLabel
//
this.addLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.addLabel.Controls.Add(this.checkBox2);
this.addLabel.Controls.Add(this.checkBox1);
this.addLabel.Controls.Add(this.label1);
this.addLabel.Controls.Add(this.panel1);
this.addLabel.Controls.Add(this.yLabel);
this.addLabel.Controls.Add(this.xLabel);
this.addLabel.Controls.Add(this.yPosition);
this.addLabel.Controls.Add(this.xPosition);
this.addLabel.Controls.Add(this.labelContents);
this.addLabel.Controls.Add(this.addItemLabel);
this.addLabel.Dock = System.Windows.Forms.DockStyle.Fill;
this.addLabel.Location = new System.Drawing.Point(0, 0);
this.addLabel.Name = "addLabel";
this.addLabel.Size = new System.Drawing.Size(252, 456);
this.addLabel.TabIndex = 1;
this.addLabel.Visible = false;
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.checkBox2.Location = new System.Drawing.Point(6, 163);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(48, 17);
this.checkBox2.TabIndex = 11;
this.checkBox2.Text = "Italic";
this.checkBox2.UseVisualStyleBackColor = true;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.checkBox1.Location = new System.Drawing.Point(6, 140);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(51, 17);
this.checkBox1.TabIndex = 10;
this.checkBox1.Text = "Bold";
this.checkBox1.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(115, 144);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(58, 13);
this.label1.TabIndex = 9;
this.label1.Text = "Text Color:";
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.Black;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.ForeColor = System.Drawing.Color.Black;
this.panel1.Location = new System.Drawing.Point(179, 141);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(35, 20);
this.panel1.TabIndex = 8;
this.panel1.Click += new System.EventHandler(this.panel1_Click);
//
// yLabel
//
this.yLabel.AutoSize = true;
this.yLabel.Location = new System.Drawing.Point(200, 96);
this.yLabel.Name = "yLabel";
this.yLabel.Size = new System.Drawing.Size(14, 13);
this.yLabel.TabIndex = 5;
this.yLabel.Text = "Y";
//
// xLabel
//
this.xLabel.AutoSize = true;
this.xLabel.Location = new System.Drawing.Point(3, 95);
this.xLabel.Name = "xLabel";
this.xLabel.Size = new System.Drawing.Size(14, 13);
this.xLabel.TabIndex = 4;
this.xLabel.Text = "X";
//
// yPosition
//
this.yPosition.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.yPosition.Location = new System.Drawing.Point(127, 114);
this.yPosition.Maximum = new decimal(new int[] {
999999999,
0,
0,
0});
this.yPosition.Name = "yPosition";
this.yPosition.Size = new System.Drawing.Size(87, 20);
this.yPosition.TabIndex = 3;
//
// xPosition
//
this.xPosition.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.xPosition.Location = new System.Drawing.Point(3, 114);
this.xPosition.Maximum = new decimal(new int[] {
999999999,
0,
0,
0});
this.xPosition.Name = "xPosition";
this.xPosition.Size = new System.Drawing.Size(87, 20);
this.xPosition.TabIndex = 2;
//
// labelContents
//
this.labelContents.Location = new System.Drawing.Point(3, 26);
this.labelContents.Multiline = true;
this.labelContents.Name = "labelContents";
this.labelContents.Size = new System.Drawing.Size(211, 67);
this.labelContents.TabIndex = 1;
this.labelContents.Text = "Text";
//
// addItemLabel
//
this.addItemLabel.Location = new System.Drawing.Point(0, 0);
this.addItemLabel.Name = "addItemLabel";
this.addItemLabel.Size = new System.Drawing.Size(214, 23);
this.addItemLabel.TabIndex = 0;
this.addItemLabel.Text = "{ADD_ITEM_LABEL}";
this.addItemLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 24);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.addLabel);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.designerPanel);
this.splitContainer1.Size = new System.Drawing.Size(758, 456);
this.splitContainer1.SplitterDistance = 252;
this.splitContainer1.TabIndex = 2;
//
// designerPanel
//
this.designerPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.designerPanel.Location = new System.Drawing.Point(0, 0);
this.designerPanel.Name = "designerPanel";
this.designerPanel.Size = new System.Drawing.Size(502, 456);
this.designerPanel.TabIndex = 0;
this.designerPanel.Click += new System.EventHandler(this.designerPanel_Click);
//
// TriPresent
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.menuStrip1);
this.Name = "TriPresent";
this.Size = new System.Drawing.Size(758, 480);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.addLabel.ResumeLayout(false);
this.addLabel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.yPosition)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.xPosition)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem addLabelToolStripMenuItem;
private System.Windows.Forms.Panel addLabel;
private System.Windows.Forms.Label addItemLabel;
private System.Windows.Forms.Label yLabel;
private System.Windows.Forms.Label xLabel;
private System.Windows.Forms.NumericUpDown yPosition;
private System.Windows.Forms.NumericUpDown xPosition;
private System.Windows.Forms.TextBox labelContents;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Panel designerPanel;
}
}

View file

@ -0,0 +1,91 @@
#define BETA_2_5
using ShiftOS.Objects.ShiftFS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
using System.Threading;
namespace ShiftOS.WinForms.Applications
{
#if !BETA_2_5
[WinOpen("tripresent")]
[AppscapeEntry("TriPresent", "Part of the trilogy of office applications for enhancement of your system. TriPresent is easliy the best presentation creator out there for ShiftOS.", 2048, 1500, "file_skimmer", "Office")]
[DefaultTitle("TriPresent")]
[Launcher("TriPresent", false, null, "Office")]
#endif
public partial class TriPresent : UserControl, IShiftOSWindow
{
public TriPresent()
{
InitializeComponent();
}
private void addLabelToolStripMenuItem_Click(object sender, EventArgs e)
{
addItemLabel.Text = "Add Label";
addLabel.Show();
}
private void button2_Click(object sender, EventArgs e)
{
addLabel.Hide();
}
public void OnLoad()
{
panel1.ForeColor = Color.Black;
panel1.BackColor = Color.Black;
}
public void OnSkinLoad()
{
}
public bool OnUnload()
{
return true;
}
public void OnUpgrade()
{
}
private void placeAdd_Click(object sender, EventArgs e)
{
}
private void panel1_Click(object sender, EventArgs e)
{
AppearanceManager.SetupDialog(new ColorPicker(panel1.BackColor, "Text Color", new Action<Color>((col) =>
{
panel1.ForeColor = col;
panel1.BackColor = col;
})));
}
private void designerPanel_Click(object sender, EventArgs e)
{
if (addLabel.Visible == true)
{
Label label = new Label();
label.Parent = designerPanel;
label.BackColor = Color.Transparent;
label.ForeColor = panel1.BackColor;
label.Text = labelContents.Text;
label.Location = new Point(Cursor.Position.X / 3, Cursor.Position.Y);
label.Text = labelContents.Text;
}
}
}
}

View file

@ -0,0 +1,123 @@
<?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>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,65 @@
namespace ShiftOS.WinForms.Applications
{
partial class TriSheet
{
/// <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.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.toolStripContainer1.SuspendLayout();
this.SuspendLayout();
//
// toolStripContainer1
//
//
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(710, 464);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer1.Name = "toolStripContainer1";
this.toolStripContainer1.Size = new System.Drawing.Size(710, 489);
this.toolStripContainer1.TabIndex = 0;
this.toolStripContainer1.Text = "toolStripContainer1";
//
// TriSheet
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.toolStripContainer1);
this.Name = "TriSheet";
this.Size = new System.Drawing.Size(710, 489);
this.toolStripContainer1.ResumeLayout(false);
this.toolStripContainer1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ToolStripContainer toolStripContainer1;
}
}

View file

@ -0,0 +1,22 @@
#define BETA_2_5
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;
namespace ShiftOS.WinForms.Applications
{
public partial class TriSheet : UserControl
{
public TriSheet()
{
InitializeComponent();
}
}
}

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

@ -0,0 +1,339 @@
namespace ShiftOS.WinForms.Applications
{
partial class TriWrite
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TriWrite));
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tvcontacts = new System.Windows.Forms.TreeView();
this.panel1 = new System.Windows.Forms.Panel();
this.txtbody = new System.Windows.Forms.Label();
this.lbtitle = new System.Windows.Forms.Label();
this.menuStrip2 = new System.Windows.Forms.MenuStrip();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.txtcontents = new System.Windows.Forms.RichTextBox();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.bold = new System.Windows.Forms.ToolStripButton();
this.italic = new System.Windows.Forms.ToolStripButton();
this.underline = new System.Windows.Forms.ToolStripButton();
this.strikethrough = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.fonts = new System.Windows.Forms.ToolStripComboBox();
this.size = new System.Windows.Forms.ToolStripTextBox();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.left = new System.Windows.Forms.ToolStripButton();
this.center = new System.Windows.Forms.ToolStripButton();
this.right = new System.Windows.Forms.ToolStripButton();
this.menuStrip1.SuspendLayout();
this.panel1.SuspendLayout();
this.menuStrip2.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addContactToolStripMenuItem,
this.removeToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(872, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// addContactToolStripMenuItem
//
this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem";
this.addContactToolStripMenuItem.Size = new System.Drawing.Size(12, 20);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(12, 20);
//
// tvcontacts
//
this.tvcontacts.Dock = System.Windows.Forms.DockStyle.Left;
this.tvcontacts.LineColor = System.Drawing.Color.Empty;
this.tvcontacts.Location = new System.Drawing.Point(0, 24);
this.tvcontacts.Name = "tvcontacts";
this.tvcontacts.Size = new System.Drawing.Size(224, 551);
this.tvcontacts.TabIndex = 1;
//
// panel1
//
this.panel1.Controls.Add(this.txtbody);
this.panel1.Controls.Add(this.lbtitle);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(224, 24);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(648, 551);
this.panel1.TabIndex = 2;
//
// txtbody
//
this.txtbody.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtbody.Location = new System.Drawing.Point(7, 54);
this.txtbody.Name = "txtbody";
this.txtbody.Size = new System.Drawing.Size(626, 481);
this.txtbody.TabIndex = 1;
this.txtbody.Text = resources.GetString("txtbody.Text");
//
// lbtitle
//
this.lbtitle.AutoSize = true;
this.lbtitle.Location = new System.Drawing.Point(7, 4);
this.lbtitle.Name = "lbtitle";
this.lbtitle.Size = new System.Drawing.Size(44, 13);
this.lbtitle.TabIndex = 0;
this.lbtitle.Tag = "header1";
this.lbtitle.Text = "TriWrite";
//
// menuStrip2
//
this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem,
this.openToolStripMenuItem,
this.saveToolStripMenuItem});
this.menuStrip2.Location = new System.Drawing.Point(0, 0);
this.menuStrip2.Name = "menuStrip2";
this.menuStrip2.Size = new System.Drawing.Size(652, 24);
this.menuStrip2.TabIndex = 2;
this.menuStrip2.Text = "menuStrip2";
//
// newToolStripMenuItem
//
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Size = new System.Drawing.Size(43, 20);
this.newToolStripMenuItem.Text = "New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.openToolStripMenuItem.Text = "Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(43, 20);
this.saveToolStripMenuItem.Text = "Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// txtcontents
//
this.txtcontents.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtcontents.Location = new System.Drawing.Point(0, 49);
this.txtcontents.Name = "txtcontents";
this.txtcontents.Size = new System.Drawing.Size(652, 365);
this.txtcontents.TabIndex = 4;
this.txtcontents.Text = "";
this.txtcontents.SelectionChanged += new System.EventHandler(this.txtcontents_SelectionChanged);
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.bold,
this.italic,
this.underline,
this.strikethrough,
this.toolStripSeparator1,
this.fonts,
this.size,
this.toolStripSeparator2,
this.left,
this.center,
this.right});
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(652, 25);
this.toolStrip1.TabIndex = 5;
this.toolStrip1.Text = "toolStrip1";
//
// bold
//
this.bold.CheckOnClick = true;
this.bold.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.bold.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold);
this.bold.Image = ((System.Drawing.Image)(resources.GetObject("bold.Image")));
this.bold.ImageTransparentColor = System.Drawing.Color.Magenta;
this.bold.Name = "bold";
this.bold.Size = new System.Drawing.Size(23, 22);
this.bold.Text = "B";
this.bold.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged);
//
// italic
//
this.italic.CheckOnClick = true;
this.italic.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.italic.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Italic);
this.italic.Image = ((System.Drawing.Image)(resources.GetObject("italic.Image")));
this.italic.ImageTransparentColor = System.Drawing.Color.Magenta;
this.italic.Name = "italic";
this.italic.Size = new System.Drawing.Size(23, 22);
this.italic.Text = "I";
this.italic.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged);
//
// underline
//
this.underline.CheckOnClick = true;
this.underline.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.underline.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Underline);
this.underline.Image = ((System.Drawing.Image)(resources.GetObject("underline.Image")));
this.underline.ImageTransparentColor = System.Drawing.Color.Magenta;
this.underline.Name = "underline";
this.underline.Size = new System.Drawing.Size(23, 22);
this.underline.Text = "U";
this.underline.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged);
//
// strikethrough
//
this.strikethrough.CheckOnClick = true;
this.strikethrough.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.strikethrough.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Strikeout, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.strikethrough.Image = ((System.Drawing.Image)(resources.GetObject("strikethrough.Image")));
this.strikethrough.ImageTransparentColor = System.Drawing.Color.Magenta;
this.strikethrough.Name = "strikethrough";
this.strikethrough.Size = new System.Drawing.Size(23, 22);
this.strikethrough.Text = "S";
this.strikethrough.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// fonts
//
this.fonts.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.fonts.Name = "fonts";
this.fonts.Size = new System.Drawing.Size(121, 25);
this.fonts.SelectedIndexChanged += new System.EventHandler(this.fonts_SelectedIndexChanged);
//
// size
//
this.size.AutoSize = false;
this.size.MaxLength = 3;
this.size.Name = "size";
this.size.Size = new System.Drawing.Size(40, 25);
this.size.TextChanged += new System.EventHandler(this.size_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// left
//
this.left.CheckOnClick = true;
this.left.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.left.Image = ((System.Drawing.Image)(resources.GetObject("left.Image")));
this.left.ImageTransparentColor = System.Drawing.Color.Magenta;
this.left.Name = "left";
this.left.Size = new System.Drawing.Size(31, 22);
this.left.Text = "Left";
this.left.Click += new System.EventHandler(this.left_Click);
//
// center
//
this.center.CheckOnClick = true;
this.center.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.center.Image = ((System.Drawing.Image)(resources.GetObject("center.Image")));
this.center.ImageTransparentColor = System.Drawing.Color.Magenta;
this.center.Name = "center";
this.center.Size = new System.Drawing.Size(46, 22);
this.center.Text = "Center";
this.center.Click += new System.EventHandler(this.center_Click);
//
// right
//
this.right.CheckOnClick = true;
this.right.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.right.Image = ((System.Drawing.Image)(resources.GetObject("right.Image")));
this.right.ImageTransparentColor = System.Drawing.Color.Magenta;
this.right.Name = "right";
this.right.Size = new System.Drawing.Size(39, 22);
this.right.Text = "Right";
this.right.Click += new System.EventHandler(this.right_Click);
//
// TriWrite
//
this.Controls.Add(this.txtcontents);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.menuStrip2);
this.Name = "TriWrite";
this.Size = new System.Drawing.Size(652, 414);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.menuStrip2.ResumeLayout(false);
this.menuStrip2.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem addContactToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
private System.Windows.Forms.TreeView tvcontacts;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label txtbody;
private System.Windows.Forms.Label lbtitle;
private System.Windows.Forms.MenuStrip menuStrip2;
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.RichTextBox txtcontents;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton bold;
private System.Windows.Forms.ToolStripButton italic;
private System.Windows.Forms.ToolStripButton underline;
private System.Windows.Forms.ToolStripButton strikethrough;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripComboBox fonts;
private System.Windows.Forms.ToolStripTextBox size;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripButton left;
private System.Windows.Forms.ToolStripButton center;
private System.Windows.Forms.ToolStripButton right;
}
}

View file

@ -0,0 +1,182 @@
using ShiftOS.Objects.ShiftFS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Applications
{
[WinOpen("triwrite")]
[AppscapeEntry("TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, "file_skimmer;textpad", "Office")]
[DefaultTitle("TriWrite")]
[Launcher("TriWrite", false, null, "Office")]
public partial class TriWrite : UserControl, IShiftOSWindow
{
public TriWrite()
{
InitializeComponent(); //From the library of babel: "FIRST COMMIT FROM A MAC WOOOO TURIANS ARE COOL"
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
txtcontents.Text = "";
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
var txt = new List<string>();
txt.Add(".rtf");
FileSkimmerBackend.GetFile(txt.ToArray(), FileOpenerStyle.Open, (path) => LoadFile(path));
}
public void LoadFile(string file)
{
txtcontents.Rtf = Utils.ReadAllText(file);
}
public void SaveFile(string file)
{
if (file.ToLower().EndsWith(".rtf"))
{
Utils.WriteAllText(file, txtcontents.Rtf);
}
else
{
Utils.WriteAllText(file, txtcontents.Text);
}
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
var txt = new List<string>();
txt.Add(".rtf");
txt.Add(".txt");
FileSkimmerBackend.GetFile(txt.ToArray(), FileOpenerStyle.Save, (path) => SaveFile(path));
}
public void OnLoad()
{
UpdateUI();
}
public void OnSkinLoad()
{
ResetFonts();
}
public void ResetFonts()
{
fonts.Items.Clear();
foreach(var font in FontFamily.Families)
{
fonts.Items.Add(font.Name);
}
UpdateUI();
}
public bool OnUnload()
{
return true;
}
public void OnUpgrade()
{
}
public void UpdateUI()
{
bold.Checked = txtcontents.SelectionFont.Bold;
italic.Checked = txtcontents.SelectionFont.Italic;
underline.Checked = txtcontents.SelectionFont.Underline;
strikethrough.Checked = txtcontents.SelectionFont.Strikeout;
fonts.Text = txtcontents.SelectionFont.Name;
size.Text = txtcontents.SelectionFont.Size.ToString();
left.Checked = txtcontents.SelectionAlignment == HorizontalAlignment.Left;
center.Checked = txtcontents.SelectionAlignment == HorizontalAlignment.Center;
right.Checked = txtcontents.SelectionAlignment == HorizontalAlignment.Right;
}
private void txtcontents_SelectionChanged(object sender, EventArgs e)
{
UpdateUI();
}
public void SetFontStyle(bool bold, bool italic, bool underline, bool strikethrough)
{
FontStyle fs = FontStyle.Regular;
if (bold)
fs |= FontStyle.Bold;
if (italic)
fs |= FontStyle.Italic;
if (underline)
fs |= FontStyle.Underline;
if (strikethrough)
fs |= FontStyle.Strikeout;
txtcontents.SelectionFont = new Font(txtcontents.SelectionFont, fs);
UpdateUI();
}
private void bold_CheckedChanged(object sender, EventArgs e)
{
SetFontStyle(bold.Checked, italic.Checked, underline.Checked, strikethrough.Checked);
}
public void SetFontFamily(string family, float emSize)
{
var style = txtcontents.SelectionFont.Style;
var size = emSize;
txtcontents.SelectionFont = new Font(family, size, style);
UpdateUI();
}
private void fonts_SelectedIndexChanged(object sender, EventArgs e)
{
SetFontFamily(fonts.Text, Convert.ToSingle(size.Text));
}
private void left_Click(object sender, EventArgs e)
{
txtcontents.SelectionAlignment = HorizontalAlignment.Left;
UpdateUI();
}
private void center_Click(object sender, EventArgs e)
{
txtcontents.SelectionAlignment = HorizontalAlignment.Center;
UpdateUI();
}
private void right_Click(object sender, EventArgs e)
{
txtcontents.SelectionAlignment = HorizontalAlignment.Right;
UpdateUI();
}
private void size_Click(object sender, EventArgs e)
{
try
{
float s = Convert.ToSingle(size.Text);
if(s != txtcontents.SelectionFont.Size)
{
SetFontFamily(fonts.Text, s);
}
}
catch
{
UpdateUI();
}
}
}
}

Some files were not shown because too many files have changed in this diff Show more