From 9f054ccdc415c6d48ce65e1e04a15036d43a541b Mon Sep 17 00:00:00 2001
From: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com>
Date: Sat, 5 Oct 2019 16:12:18 +0200
Subject: [PATCH] Added stuff
---
2/2.cs | 2 -
Base/Drawing.cs | 49 +++++++++--
LaptopSimulator2015/FakeDesktop.Designer.cs | 16 ++--
LaptopSimulator2015/Tutorial.Designer.cs | 92 ++++++++++++---------
LaptopSimulator2015/Tutorial.cs | 15 ++++
ToDo.txt | 3 +-
6 files changed, 123 insertions(+), 54 deletions(-)
diff --git a/2/2.cs b/2/2.cs
index 244d964..c45b4bd 100644
--- a/2/2.cs
+++ b/2/2.cs
@@ -123,9 +123,7 @@ namespace LaptopSimulator2015.Levels
public void draw(GraphicsWrapper g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{
for (int i = 0; i < enemies.Count; i++)
- //g.g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
g.DrawRectangle(new RectangleF(enemies[i].toPointF(), new SizeF(10, 10)), Color.Red);
- //g.g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
g.DrawRectangle(new RectangleF(player.toPointF(), new SizeF(10, 10)), Color.Green);
g.DrawSizedString(lives.ToString(), 7, player.toPointF(), Brushes.White, true, true);
}
diff --git a/Base/Drawing.cs b/Base/Drawing.cs
index e6c3ffa..dd6c0a8 100644
--- a/Base/Drawing.cs
+++ b/Base/Drawing.cs
@@ -18,13 +18,20 @@ namespace Base
/// Wrap the Graphics object with these excellent High-Quality functions
///
/// The Graphics-object to wrap
+ /// Color used when filling
/// The size of the device the Graphics are drawn to
- public GraphicsWrapper(Graphics g, Color backColor, Rectangle targetSize)
+ /// Whether the quality should be ugly
+ public GraphicsWrapper(Graphics g, Color backColor, Rectangle targetSize, bool isLowQuality = false)
{
_g = BufferedGraphicsManager.Current.Allocate(g ?? throw new ArgumentNullException(nameof(g)), targetSize);
this.g = _g.Graphics;
this.backColor = backColor;
this.targetSize = targetSize;
+ this.g.SmoothingMode = isLowQuality ? SmoothingMode.None : SmoothingMode.HighQuality;
+ this.g.InterpolationMode = isLowQuality ? InterpolationMode.Low : InterpolationMode.HighQualityBicubic;
+ this.g.CompositingMode = isLowQuality ? CompositingMode.SourceCopy : CompositingMode.SourceOver;
+ this.g.CompositingQuality = isLowQuality ? CompositingQuality.HighSpeed : CompositingQuality.HighQuality;
+ this.g.PixelOffsetMode = isLowQuality ? PixelOffsetMode.None : PixelOffsetMode.HighQuality;
}
///
@@ -39,18 +46,25 @@ namespace Base
{
SmoothingMode tmpS = g.SmoothingMode;
InterpolationMode tmpI = g.InterpolationMode;
+ CompositingMode tmpM = g.CompositingMode;
+ CompositingQuality tmpQ = g.CompositingQuality;
PixelOffsetMode tmpP = g.PixelOffsetMode;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ g.CompositingMode = CompositingMode.SourceOver;
+ g.CompositingQuality = CompositingQuality.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
- SizeF sLen = g.MeasureString(s, new Font("Tahoma", size));
+ Font f = new Font("Tahoma", size);
+ SizeF sLen = g.MeasureString(s, f);
RectangleF rectf = new RectangleF(location, sLen);
- if (isLocationCentered)
- rectf = new RectangleF(rectf.X - rectf.Width / 2, rectf.Y - rectf.Height / 2, rectf.Width, rectf.Height);
if (transform)
rectf = w2s(rectf);
- g.DrawString(s, new Font("Tahoma", size), brush, rectf);
+ if (isLocationCentered)
+ rectf = new RectangleF(rectf.X - rectf.Width / 2, rectf.Y - rectf.Height / 2, rectf.Width, rectf.Height);
+ g.DrawString(s, f, brush, rectf);
g.PixelOffsetMode = tmpP;
+ g.CompositingQuality = tmpQ;
+ g.CompositingMode = tmpM;
g.InterpolationMode = tmpI;
g.SmoothingMode = tmpS;
}
@@ -88,9 +102,32 @@ namespace Base
/// The size of the lines used when not filling
public void DrawRectangle(Rect rectangle, Color color, bool filled = true, int unfilledLineSize = 1) => DrawRectangle(rectangle.toRectangleF(), color, false, true, filled, unfilledLineSize);
+ ///
+ /// Draw a line connecting the vectors
+ ///
+ /// Start of the line
+ /// End of the line
+ /// Color to be used
+ /// Width of the line in pixels
+ public void DrawLine(Vector2 p1, Vector2 p2, Color color, float width, bool transform = true) => DrawLine(p1.toPointF(), p2.toPointF(), color, width, transform);
+ ///
+ /// Draw a line connecting the points
+ ///
+ /// Start of the line
+ /// End of the line
+ /// Color to be used
+ /// Width of the line in pixels
+ public void DrawLine(PointF p1, PointF p2, Color color, float width, bool transform = true) => g.DrawLine(new Pen(color, width), transform ? w2s(p1) : p1, transform ? w2s(p2) : p2);
+
+ ///
+ /// Clear the screen with the color provided when creating
+ ///
public void Clear() => g.Clear(backColor);
- public void Dispose()
+ ///
+ /// Render and dispose
+ ///
+ public virtual void Dispose()
{
g.Flush();
_g.Render();
diff --git a/LaptopSimulator2015/FakeDesktop.Designer.cs b/LaptopSimulator2015/FakeDesktop.Designer.cs
index 76666f4..16c84ba 100644
--- a/LaptopSimulator2015/FakeDesktop.Designer.cs
+++ b/LaptopSimulator2015/FakeDesktop.Designer.cs
@@ -288,23 +288,27 @@ namespace LaptopSimulator2015
//
// levelWindowContents
//
+ this.levelWindowContents.Appearance = System.Windows.Forms.TabAppearance.Buttons;
this.levelWindowContents.Controls.Add(this.levelWindow1);
this.levelWindowContents.Controls.Add(this.levelWindow2);
this.levelWindowContents.Controls.Add(this.levelWindow3);
this.levelWindowContents.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.levelWindowContents.ItemSize = new System.Drawing.Size(10, 10);
this.levelWindowContents.Location = new System.Drawing.Point(0, 20);
this.levelWindowContents.Name = "levelWindowContents";
this.levelWindowContents.SelectedIndex = 0;
this.levelWindowContents.Size = new System.Drawing.Size(502, 248);
+ this.levelWindowContents.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.levelWindowContents.TabIndex = 2;
+ this.levelWindowContents.TabStop = false;
//
// levelWindow1
//
this.levelWindow1.Controls.Add(this.levelWindowText1);
- this.levelWindow1.Location = new System.Drawing.Point(4, 19);
+ this.levelWindow1.Location = new System.Drawing.Point(4, 14);
this.levelWindow1.Name = "levelWindow1";
this.levelWindow1.Padding = new System.Windows.Forms.Padding(3);
- this.levelWindow1.Size = new System.Drawing.Size(494, 225);
+ this.levelWindow1.Size = new System.Drawing.Size(494, 230);
this.levelWindow1.TabIndex = 0;
this.levelWindow1.UseVisualStyleBackColor = true;
//
@@ -323,10 +327,10 @@ namespace LaptopSimulator2015
this.levelWindow2.Controls.Add(this.captchaBox);
this.levelWindow2.Controls.Add(this.captchaPanel);
this.levelWindow2.Controls.Add(this.levelWindowText2);
- this.levelWindow2.Location = new System.Drawing.Point(4, 19);
+ this.levelWindow2.Location = new System.Drawing.Point(4, 25);
this.levelWindow2.Name = "levelWindow2";
this.levelWindow2.Padding = new System.Windows.Forms.Padding(3);
- this.levelWindow2.Size = new System.Drawing.Size(494, 225);
+ this.levelWindow2.Size = new System.Drawing.Size(494, 219);
this.levelWindow2.TabIndex = 1;
this.levelWindow2.UseVisualStyleBackColor = true;
//
@@ -364,9 +368,9 @@ namespace LaptopSimulator2015
//
this.levelWindow3.Controls.Add(this.levelWindowProgress);
this.levelWindow3.Controls.Add(this.levelWindowText3);
- this.levelWindow3.Location = new System.Drawing.Point(4, 19);
+ this.levelWindow3.Location = new System.Drawing.Point(4, 25);
this.levelWindow3.Name = "levelWindow3";
- this.levelWindow3.Size = new System.Drawing.Size(494, 225);
+ this.levelWindow3.Size = new System.Drawing.Size(494, 219);
this.levelWindow3.TabIndex = 2;
this.levelWindow3.UseVisualStyleBackColor = true;
//
diff --git a/LaptopSimulator2015/Tutorial.Designer.cs b/LaptopSimulator2015/Tutorial.Designer.cs
index 0d9e0ec..cafafa1 100644
--- a/LaptopSimulator2015/Tutorial.Designer.cs
+++ b/LaptopSimulator2015/Tutorial.Designer.cs
@@ -43,23 +43,25 @@
this.p2privacyLabel = new System.Windows.Forms.Label();
this.p3 = new System.Windows.Forms.TabPage();
this.p3spacingPanel1 = new System.Windows.Forms.Panel();
- this.p3spacingPanel2 = new System.Windows.Forms.Panel();
this.p3continue = new System.Windows.Forms.Button();
- this.progressBar = new System.Windows.Forms.ProgressBar();
- this.cancelButton = new System.Windows.Forms.Button();
- this.progressTimer = new System.Windows.Forms.Timer(this.components);
+ this.p3spacingPanel2 = new System.Windows.Forms.Panel();
this.p4 = new System.Windows.Forms.TabPage();
+ this.tutorialPanel = new System.Windows.Forms.Panel();
this.p5 = new System.Windows.Forms.TabPage();
this.p5completeLabel = new System.Windows.Forms.Label();
this.p5controlPanel = new System.Windows.Forms.Panel();
this.p5reboot = new System.Windows.Forms.Button();
this.p5title = new System.Windows.Forms.Label();
+ this.progressBar = new System.Windows.Forms.ProgressBar();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.progressTimer = new System.Windows.Forms.Timer(this.components);
this.dialog.SuspendLayout();
this.tabs.SuspendLayout();
this.p1.SuspendLayout();
this.p1controlPanel.SuspendLayout();
this.p2.SuspendLayout();
this.p3.SuspendLayout();
+ this.p4.SuspendLayout();
this.p5.SuspendLayout();
this.p5controlPanel.SuspendLayout();
this.SuspendLayout();
@@ -106,6 +108,7 @@
//
// p1
//
+ this.p1.BackColor = System.Drawing.Color.White;
this.p1.Controls.Add(this.p1descLabel);
this.p1.Controls.Add(this.p1controlPanel);
this.p1.Controls.Add(this.p1titleLabel);
@@ -114,7 +117,6 @@
this.p1.Padding = new System.Windows.Forms.Padding(3);
this.p1.Size = new System.Drawing.Size(392, 371);
this.p1.TabIndex = 0;
- this.p1.UseVisualStyleBackColor = true;
//
// p1descLabel
//
@@ -128,6 +130,7 @@
//
// p1controlPanel
//
+ this.p1controlPanel.BackColor = System.Drawing.Color.Silver;
this.p1controlPanel.Controls.Add(this.p1continue);
this.p1controlPanel.Controls.Add(this.p1lang);
this.p1controlPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
@@ -181,10 +184,10 @@
this.p2.Padding = new System.Windows.Forms.Padding(3);
this.p2.Size = new System.Drawing.Size(392, 371);
this.p2.TabIndex = 1;
- this.p2.UseVisualStyleBackColor = true;
//
// p2continue
//
+ this.p2continue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.p2continue.Location = new System.Drawing.Point(311, 345);
this.p2continue.Name = "p2continue";
this.p2continue.Size = new System.Drawing.Size(75, 23);
@@ -204,6 +207,7 @@
//
// p3
//
+ this.p3.BackColor = System.Drawing.Color.White;
this.p3.Controls.Add(this.p3spacingPanel1);
this.p3.Controls.Add(this.p3continue);
this.p3.Controls.Add(this.p3spacingPanel2);
@@ -211,7 +215,6 @@
this.p3.Name = "p3";
this.p3.Size = new System.Drawing.Size(392, 371);
this.p3.TabIndex = 2;
- this.p3.UseVisualStyleBackColor = true;
//
// p3spacingPanel1
//
@@ -221,14 +224,6 @@
this.p3spacingPanel1.Size = new System.Drawing.Size(392, 100);
this.p3spacingPanel1.TabIndex = 2;
//
- // p3spacingPanel2
- //
- this.p3spacingPanel2.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.p3spacingPanel2.Location = new System.Drawing.Point(0, 271);
- this.p3spacingPanel2.Name = "p3spacingPanel2";
- this.p3spacingPanel2.Size = new System.Drawing.Size(392, 100);
- this.p3spacingPanel2.TabIndex = 1;
- //
// p3continue
//
this.p3continue.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -241,39 +236,35 @@
this.p3continue.UseVisualStyleBackColor = true;
this.p3continue.Click += new System.EventHandler(this.continue3_Click);
//
- // progressBar
+ // p3spacingPanel2
//
- this.progressBar.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.progressBar.Location = new System.Drawing.Point(0, 677);
- this.progressBar.Name = "progressBar";
- this.progressBar.Size = new System.Drawing.Size(1300, 23);
- this.progressBar.Step = 1;
- this.progressBar.TabIndex = 2;
- //
- // cancelButton
- //
- this.cancelButton.Location = new System.Drawing.Point(0, 0);
- this.cancelButton.Name = "cancelButton";
- this.cancelButton.Size = new System.Drawing.Size(80, 23);
- this.cancelButton.TabIndex = 3;
- this.cancelButton.Text = "Cancel";
- this.cancelButton.UseVisualStyleBackColor = true;
- this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
- //
- // progressTimer
- //
- this.progressTimer.Tick += new System.EventHandler(this.timer1_Tick);
+ this.p3spacingPanel2.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.p3spacingPanel2.Location = new System.Drawing.Point(0, 271);
+ this.p3spacingPanel2.Name = "p3spacingPanel2";
+ this.p3spacingPanel2.Size = new System.Drawing.Size(392, 100);
+ this.p3spacingPanel2.TabIndex = 1;
//
// p4
//
+ this.p4.BackColor = System.Drawing.Color.White;
+ this.p4.Controls.Add(this.tutorialPanel);
this.p4.Location = new System.Drawing.Point(4, 25);
this.p4.Name = "p4";
this.p4.Size = new System.Drawing.Size(392, 371);
this.p4.TabIndex = 3;
- this.p4.UseVisualStyleBackColor = true;
+ //
+ // tutorialPanel
+ //
+ this.tutorialPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tutorialPanel.Location = new System.Drawing.Point(0, 0);
+ this.tutorialPanel.Name = "tutorialPanel";
+ this.tutorialPanel.Size = new System.Drawing.Size(392, 371);
+ this.tutorialPanel.TabIndex = 0;
+ this.tutorialPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.tutorialPanel_Paint);
//
// p5
//
+ this.p5.BackColor = System.Drawing.Color.White;
this.p5.Controls.Add(this.p5completeLabel);
this.p5.Controls.Add(this.p5controlPanel);
this.p5.Controls.Add(this.p5title);
@@ -281,7 +272,6 @@
this.p5.Name = "p5";
this.p5.Size = new System.Drawing.Size(392, 371);
this.p5.TabIndex = 4;
- this.p5.UseVisualStyleBackColor = true;
//
// p5completeLabel
//
@@ -324,6 +314,30 @@
this.p5title.Text = "LaptopSimulator2015";
this.p5title.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
+ // progressBar
+ //
+ this.progressBar.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.progressBar.Location = new System.Drawing.Point(0, 677);
+ this.progressBar.Name = "progressBar";
+ this.progressBar.Size = new System.Drawing.Size(1300, 23);
+ this.progressBar.Step = 1;
+ this.progressBar.TabIndex = 2;
+ //
+ // cancelButton
+ //
+ this.cancelButton.Location = new System.Drawing.Point(0, 0);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size(80, 23);
+ this.cancelButton.TabIndex = 3;
+ this.cancelButton.Text = "Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+ //
+ // progressTimer
+ //
+ this.progressTimer.Interval = 120;
+ this.progressTimer.Tick += new System.EventHandler(this.timer1_Tick);
+ //
// Tutorial
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -347,6 +361,7 @@
this.p2.ResumeLayout(false);
this.p2.PerformLayout();
this.p3.ResumeLayout(false);
+ this.p4.ResumeLayout(false);
this.p5.ResumeLayout(false);
this.p5controlPanel.ResumeLayout(false);
this.ResumeLayout(false);
@@ -380,5 +395,6 @@
private System.Windows.Forms.Panel p5controlPanel;
private System.Windows.Forms.Button p5reboot;
private System.Windows.Forms.Label p5title;
+ private System.Windows.Forms.Panel tutorialPanel;
}
}
\ No newline at end of file
diff --git a/LaptopSimulator2015/Tutorial.cs b/LaptopSimulator2015/Tutorial.cs
index fae2782..1e6e353 100644
--- a/LaptopSimulator2015/Tutorial.cs
+++ b/LaptopSimulator2015/Tutorial.cs
@@ -9,6 +9,8 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;
+using System.Drawing.Drawing2D;
+using Base;
namespace LaptopSimulator2015
{
@@ -71,10 +73,12 @@ namespace LaptopSimulator2015
{
progressBar.Value = 50 + timertime;
timertime++;
+ tutorialPanel.Invalidate();
}
else
{
tabs.SelectedIndex = 4;
+ progressTimer.Enabled = false;
}
}
@@ -85,5 +89,16 @@ namespace LaptopSimulator2015
Program.splash.Show();
Close();
}
+
+ private void tutorialPanel_Paint(object sender, PaintEventArgs e)
+ {
+ using (GraphicsWrapper g = new GraphicsWrapper(e.Graphics, Color.Red, new Rectangle(Point.Empty, tutorialPanel.Size), true))
+ {
+ for (int i = 0; i < 40; i++)
+ for (int j = 0; j < 40; j++)
+ g.DrawLine(new PointF(tutorialPanel.Width / 2, tutorialPanel.Height / 2), new PointF(i * 10 + 5, j * 10 + 5), Color.DarkGray, 1, false);
+ g.DrawSizedString("This is " + ((timertime < 17) ? "bad" : (timertime <= 33) ? "neutral" : "you"), 10, new PointF(tutorialPanel.Width / 2, tutorialPanel.Height / 2), new SolidBrush((timertime < 17) ? Color.Red : (timertime <= 33) ? Color.White : Color.Green), true, true);
+ }
+ }
}
}
diff --git a/ToDo.txt b/ToDo.txt
index 96644f1..ae5e6e0 100644
--- a/ToDo.txt
+++ b/ToDo.txt
@@ -1,2 +1 @@
-Fully implement new graphics on Goal and Level 3
-OS Install as Tutorial
\ No newline at end of file
+Fully implement new graphics on Goal and Level 3
\ No newline at end of file