LOADS of optimizations and Pong fixes.

This commit is contained in:
Michael 2017-04-03 18:36:13 -04:00
parent 29a88a5c46
commit f43f6fe17d
9 changed files with 217 additions and 243 deletions

View file

@ -54,7 +54,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Save.cs" />
<Compile Include="ShiftFS.cs" />
<Compile Include="ShiftOSMenuRenderer.cs" />
<Compile Include="Shop.cs" />
</ItemGroup>
<ItemGroup>

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

@ -79,6 +79,11 @@ 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.pnlhighscore = new System.Windows.Forms.Panel();
this.lbhighscore = new System.Windows.Forms.ListBox();
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 +96,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();
@ -122,16 +124,14 @@ 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.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
@ -174,11 +174,67 @@ 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(1867, 819);
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);
//
// 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.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;
//
// 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 +248,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 +363,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 +397,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 +409,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 +420,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 +440,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 +460,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;
//
@ -502,10 +531,11 @@ namespace ShiftOS.WinForms.Applications
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.Location = new System.Drawing.Point(1139, 41);
this.pnlintro.Name = "pnlintro";
this.pnlintro.Size = new System.Drawing.Size(595, 303);
this.pnlintro.TabIndex = 13;
this.pnlintro.Tag = "header2";
//
// Label6
//
@ -548,6 +578,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 +608,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 +617,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(1833, 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 +629,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(1867, 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, 775);
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(1395, 775);
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, 775);
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 +683,23 @@ 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(1867, 819);
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.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);
}

View file

@ -34,6 +34,7 @@ using System.Windows.Forms;
using Newtonsoft.Json;
using ShiftOS.Engine;
using ShiftOS.Objects;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
@ -83,6 +84,26 @@ namespace ShiftOS.WinForms.Applications
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;
}
// ERROR: Handles clauses are not supported in C#
private void gameTimer_Tick(object sender, EventArgs e)
@ -102,7 +123,7 @@ namespace ShiftOS.WinForms.Applications
//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.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0)
{
if (ball.Location.Y > paddleComputer.Location.Y + 50)
{
@ -116,12 +137,12 @@ namespace ShiftOS.WinForms.Applications
}
else
{
//used to be me.location.y
//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);
}
//used to be me.location.y
//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);
@ -269,6 +290,7 @@ namespace ShiftOS.WinForms.Applications
}
lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString();
}
SetupStats();
}
public void SendHighscores()
@ -652,10 +674,17 @@ namespace ShiftOS.WinForms.Applications
pnlhighscore.Hide();
pnlgamestats.Hide();
pnlfinalstats.Hide();
CenterPanels();
lblbeatai.Hide();
}
public void OnSkinLoad()
{
CenterPanels();
this.SizeChanged += (o, a) =>
{
CenterPanels();
};
}
public bool OnUnload()
@ -665,6 +694,7 @@ namespace ShiftOS.WinForms.Applications
public void OnUpgrade()
{
CenterPanels();
}
private void button2_Click(object sender, EventArgs e)

View file

@ -64,7 +64,10 @@ namespace ShiftOS.WinForms
{
while(typing == true)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
charcount = texttotype.Length;
@ -452,6 +455,10 @@ namespace ShiftOS.WinForms
TextType("Go ahead and type 'sos.help' to see a list of commands.");
while (TutorialProgress == 0)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("As you can see, sos.help gives you a list of all commands in the system.");
@ -461,6 +468,10 @@ namespace ShiftOS.WinForms
TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does.");
while (TutorialProgress == 1)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("Brilliant. The sos.status command will tell you how many Codepoints you have, as well as how many upgrades you have installed and how many are available.");
@ -478,6 +489,10 @@ namespace ShiftOS.WinForms
TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades.");
while (TutorialProgress == 2)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
Clear();
@ -502,13 +517,21 @@ namespace ShiftOS.WinForms
TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID.");
while (TutorialProgress == 3)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!");
Thread.Sleep(500);
TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!");
while (!Shiftorium.UpgradeInstalled("mud_fundamentals"))
{
{ //JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("Hooray! You now have the MUD Fundamentals upgrade.");
@ -520,6 +543,10 @@ namespace ShiftOS.WinForms
TextType("Just run win.open without arguments, and this tutorial will be completed!");
while (TutorialProgress == 4)
{
//JESUS CHRIST PAST MICHAEL.
//We should PROBABLY block the thread... You know... not everyone has a 10-core processor.
Thread.Sleep(100);
}
TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world.");
@ -528,6 +555,7 @@ namespace ShiftOS.WinForms
{
OnComplete?.Invoke(this, EventArgs.Empty);
SaveSystem.CurrentSave.StoryPosition = 2;
this.Close();
SaveSystem.SaveGame();
AppearanceManager.SetupWindow(new Applications.Terminal());
});

View file

@ -67,91 +67,6 @@ namespace ShiftOS.WinForms.Tools
}
public static void SetupWindows()
{
if (SaveSystem.CurrentSave != null)
{
int screen_height_start = 0;
if (Shiftorium.UpgradeInstalled("wm_free_placement"))
{
}
else if (Shiftorium.UpgradeInstalled("wm_4_windows"))
{
int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2;
int screen_height_half = (Screen.PrimaryScreen.Bounds.Height - screen_height_start) / 2;
for (int i = 0; i < OpenForms.Count; i++)
{
var frm = OpenForms[i] as WindowBorder;
switch (i)
{
case 0:
frm.Location = new System.Drawing.Point(0, screen_height_start);
frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2);
break;
case 1:
frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start);
frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2);
break;
case 2:
frm.Location = new System.Drawing.Point(0, screen_height_half + screen_height_start);
frm.Size = new System.Drawing.Size((OpenForms.Count > 3) ? screen_width_half : screen_width_half * 2, screen_height_half);
break;
case 3:
frm.Location = new System.Drawing.Point(screen_width_half, screen_height_half + screen_height_start);
frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2);
break;
}
}
}
else if (Shiftorium.UpgradeInstalled("window_manager"))
{
int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2;
int screen_height = (Screen.PrimaryScreen.Bounds.Height) - screen_height_start;
for (int i = 0; i < OpenForms.Count; i++)
{
var frm = OpenForms[i] as WindowBorder;
switch (i)
{
case 0:
frm.Location = new System.Drawing.Point(0, screen_height_start);
frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, screen_height);
break;
case 1:
frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start);
frm.Size = new System.Drawing.Size(screen_width_half, screen_height);
break;
}
OpenForms[i] = frm;
}
}
else
{
var frm = OpenForms[0] as WindowBorder;
frm.Location = new Point(0, 0);
frm.Size = Desktop.Size;
OpenForms[0] = frm;
}
}
else
{
var frm = OpenForms[0] as WindowBorder;
frm.Location = new Point(0, 0);
frm.Size = Desktop.Size;
OpenForms[0] = frm;
}
}
internal static Color ConvertColor(ConsoleColor cCol)
{
switch (cCol)
@ -214,9 +129,22 @@ namespace ShiftOS.WinForms.Tools
#endif
}
/// <summary>
/// Centers the control along its parent.
/// </summary>
/// <param name="ctrl">The control to center (this is an extension method - you can call it on a control as though it was a method in that control)</param>
public static void CenterParent(this Control ctrl)
{
ctrl.Location = new Point(
(ctrl.Parent.Width - ctrl.Width) / 2,
(ctrl.Parent.Height - ctrl.Height) / 2
);
}
public static void SetupControl(Control ctrl)
{
SuspendDrawing(ctrl);
ctrl.SuspendLayout();
SetCursor(ctrl);
if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip))
{
@ -270,13 +198,7 @@ namespace ShiftOS.WinForms.Tools
a.SuppressKeyPress = true;
if (SaveSystem.CurrentSave != null)
{
if (Shiftorium.UpgradeInstalled("window_manager"))
{
Engine.AppearanceManager.SetupWindow(new Applications.Terminal());
}
}
Engine.AppearanceManager.SetupWindow(new Applications.Terminal());
}
ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a);
@ -293,6 +215,7 @@ namespace ShiftOS.WinForms.Tools
}
MakeDoubleBuffered(ctrl);
ctrl.ResumeLayout();
ResumeDrawing(ctrl);
}

View file

@ -664,10 +664,17 @@ namespace ShiftOS.WinForms
/// <param name="act">Act.</param>
public void InvokeOnWorkerThread(Action act)
{
this.Invoke(new Action(()=>
try
{
act?.Invoke();
}));
this.Invoke(new Action(() =>
{
act?.Invoke();
}));
}
catch
{
}
}
public void OpenAppLauncher(Point loc)

View file

@ -184,20 +184,21 @@ namespace ShiftOS.WinForms
if (maxWindows > 0)
{
List<WindowBorder> formstoclose = new List<WindowBorder>();
for (int i = 0; i < maxWindows && i < AppearanceManager.OpenForms.Count; i++)
var windows = new List<WindowBorder>();
foreach(var WB in AppearanceManager.OpenForms)
{
var frm = AppearanceManager.OpenForms[i] as WindowBorder;
if(!frm.IsDialog)
formstoclose.Add(frm);
if (WB is WindowBorder)
windows.Add(WB as WindowBorder);
}
List<WindowBorder> formstoclose = new List<WindowBorder>(windows.Where(x => x.IsDialog == false).ToArray());
while (formstoclose.Count > maxWindows - 1)
{
formstoclose[0].Close();
this.Close(formstoclose[0].ParentWindow);
AppearanceManager.OpenForms.Remove(formstoclose[0]);
formstoclose.RemoveAt(0);
}
}
}

View file

@ -46,6 +46,23 @@ namespace ShiftOS.Engine
Installed?.Invoke();
}
public static string GetCategory(string id)
{
var upg = GetDefaults().FirstOrDefault(x => x.ID == id);
if (upg == null)
return "Other";
return (upg.Category == null) ? "Other" : upg.Category;
}
public static IEnumerable<ShiftoriumUpgrade> GetAllInCategory(string cat)
{
return GetDefaults().Where(x => x.Category == cat);
}
public static bool IsCategoryEmptied(string cat)
{
return GetDefaults().Where(x => x.Category == cat).FirstOrDefault(x => x.Installed == false) == null;
}
public static bool Buy(string id, int cost)
{
@ -278,8 +295,15 @@ namespace ShiftOS.Engine
public string Description { get; set; }
public int Cost { get; set; }
public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } }
public string Id { get; }
public string Id { get; set; }
public string Category { get; set; }
public bool Installed
{
get
{
return Shiftorium.UpgradeInstalled(ID);
}
}
public string Dependencies { get; set; }
}
}