From 37ac4c684ce3904c5ec614362ed99bb9867ca0f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 May 2017 20:08:30 -0400 Subject: It's amazing what talking to Rylan can do to an integer datatype. --- ShiftOS.WinForms/Applications/Pong.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 84177b7..6d81c64 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -58,10 +58,10 @@ namespace ShiftOS.WinForms.Applications double incrementy = 0.2; int levelxspeed = 3; int levelyspeed = 3; - int beatairewardtotal; - int beataireward = 1; - int[] levelrewards = new int[50]; - int totalreward; + ulong beatairewardtotal; + ulong beataireward = 1; + ulong[] levelrewards = new ulong[50]; + ulong totalreward; int countdown = 3; bool aiShouldIsbeEnabled = true; @@ -297,11 +297,11 @@ namespace ShiftOS.WinForms.Applications 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; + totalreward = (ulong)(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)); + SaveSystem.TransferCodepointsFrom("pong", (ulong)(totalreward / 100)); } else { @@ -715,10 +715,10 @@ namespace ShiftOS.WinForms.Applications { if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { - beataireward = level * 10; + beataireward = (ulong)(level * 10); } else { - beataireward = level * 5; + beataireward = (ulong)(level * 5); } } else @@ -726,11 +726,11 @@ namespace ShiftOS.WinForms.Applications if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 10; + beataireward = (ulong)Math.Round(br) * 10; } else { double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 5; + beataireward = (ulong)Math.Round(br) * 5; } } -- cgit v1.2.3 From 17f3f6f68567b0151474af86d6ba265b35029b8e Mon Sep 17 00:00:00 2001 From: RogueAI42 Date: Sat, 3 Jun 2017 00:43:20 +1000 Subject: Fixed Pong? there are some sound crashes but Michael told me to just make the PR and let him fix the audio backend so that's what I'm doing. --- ShiftOS.WinForms/Applications/Pong.Designer.cs | 3 - ShiftOS.WinForms/Applications/Pong.cs | 406 +++++++++---------------- ShiftOS.WinForms/Applications/Pong.resx | 3 + 3 files changed, 140 insertions(+), 272 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index 0254e94..c5ea375 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -182,7 +182,6 @@ namespace ShiftOS.WinForms.Applications this.pgcontents.Name = "pgcontents"; 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 @@ -250,7 +249,6 @@ namespace ShiftOS.WinForms.Applications 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 // @@ -273,7 +271,6 @@ namespace ShiftOS.WinForms.Applications 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 // diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 6d81c64..87f0306 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -60,11 +60,60 @@ namespace ShiftOS.WinForms.Applications int levelyspeed = 3; ulong beatairewardtotal; ulong beataireward = 1; - ulong[] levelrewards = new ulong[50]; + readonly uint[] levelrewards = { + 0, + 20, + 60, + 140, + 290, + 400, + 600, + 900, + 1200, + 1600, + 2000, + 2500, + 3000, + 4000, + 5000, + 6000, + 8000, + 10000, + 13000, + 16000, + 20000, + 25000, + 32000, + 40000, + 50000, + 60000, + 75000, + 90000, + 110000, + 140000, + 180000, + 220000, + 270000, + 320000, + 400000, + 500000, + 640000, + 800000, + 1000000, + 1500000, + 2000000}; ulong totalreward; int countdown = 3; + int rwdmultiplier; + Thread soundThread; - bool aiShouldIsbeEnabled = true; + bool aiShouldIsbeEnabled = true; // who named this variable? and were they having a stroke? + + private void playsound(System.IO.Stream stream) + { + soundThread = new Thread((a) => ShiftOS.Engine.AudioManager.PlayStream((System.IO.Stream)a)); + soundThread.Start(stream); + } public Pong() { @@ -73,11 +122,9 @@ namespace ShiftOS.WinForms.Applications private void Pong_Load(object sender, EventArgs e) { - setuplevelrewards(); + rwdmultiplier = ShiftoriumFrontend.UpgradeInstalled("pong_upgrade") ? 2 : 1; } - - // Move the paddle according to the mouse position. private void pongMain_MouseMove(object sender, MouseEventArgs e) { @@ -133,9 +180,7 @@ namespace ShiftOS.WinForms.Applications { if (this.Left < Screen.PrimaryScreen.Bounds.Width) { - ball.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleComputer.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; + ball.BackColor = paddleComputer.BackColor = paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; //Check if paddle upgrade has been bought and change paddles accordingly //if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) @@ -146,7 +191,7 @@ namespace ShiftOS.WinForms.Applications //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 (IsMultiplayerSession == true) + if (IsMultiplayerSession) { //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. @@ -160,83 +205,63 @@ namespace ShiftOS.WinForms.Applications if (aiShouldIsbeEnabled) if (ball.Location.X > (this.Width - (this.Width / 3)) - 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); - } + if (ball.Top > paddleComputer.Top + 50) + paddleComputer.Top += computerspeed; + else + paddleComputer.Top -= computerspeed; casualposition = rand.Next(-150, 201); } else { //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); - } + if (paddleComputer.Top > this.Height / 2 - paddleComputer.Height + casualposition) + paddleComputer.Top -= computerspeed; + else + paddleComputer.Top += computerspeed; } } //Set Xvel and Yvel speeds from decimal if (xVel > 0) xVel = (int)Math.Round(xveldec); - if (xVel < 0) + else xVel = (int)-Math.Round(xveldec); if (yVel > 0) yVel = (int)Math.Round(yveldec); - if (yVel < 0) + else yVel = (int)-Math.Round(yveldec); - bool BallPhysics = true; - - if (IsMultiplayerSession) + if (IsMultiplayerSession && !IsLeader) { - //Logic for moving the ball in Multiplayer. - if (IsLeader) - { - 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; - } + // Move it to the leader's ball position. + ball.Location = new Point(LeaderX, LeaderY); } else - {// Move the game ball. - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - if (BallPhysics) { + var newRect = new Rectangle(ball.Location, ball.Size); // copy ball's Bounds + newRect.X += xVel; + newRect.Y += yVel; + // Check for top wall. - if (ball.Location.Y < 0) + if (newRect.Y < 0) { - ball.Location = new Point(ball.Location.X, 0); + newRect.Y = 0; yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); + playsound(Properties.Resources.typesound); } // Check for bottom wall. - if (ball.Location.Y > pgcontents.Height - ball.Height) + if (newRect.Y > pgcontents.Height - ball.Height) { - ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height); + newRect.Y = pgcontents.Height - ball.Height; yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); + playsound(Properties.Resources.typesound); } // Check for player paddle. - if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) + if (newRect.IntersectsWith(paddleHuman.Bounds)) { - ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width + 1, ball.Location.Y); + newRect.X = paddleHuman.Left + ball.Width + 1; //randomly increase x or y speed of ball switch (rand.Next(1, 3)) { @@ -246,23 +271,24 @@ namespace ShiftOS.WinForms.Applications case 2: if (yveldec > 0) yveldec = yveldec + incrementy; - if (yveldec < 0) + else yveldec = yveldec - incrementy; break; } xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); + playsound(Properties.Resources.writesound); } // Check for computer paddle. - if (ball.Bounds.IntersectsWith(paddleComputer.Bounds)) + if (newRect.IntersectsWith(paddleComputer.Bounds)) { - ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width - 1, ball.Location.Y); + newRect.X = paddleComputer.Left - paddleComputer.Width - 1; xveldec = xveldec + incrementx; xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); + playsound(Properties.Resources.writesound); } + ball.Location = newRect.Location; } @@ -297,11 +323,11 @@ namespace ShiftOS.WinForms.Applications 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 = (ulong)(levelrewards[level - 1] + beatairewardtotal); + totalreward = (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal); double onePercent = (totalreward / 100); lblbutyougained.Show(); lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (ulong)(totalreward / 100)); + SaveSystem.TransferCodepointsFrom("pong", (ulong)(onePercent)); } else { @@ -345,7 +371,7 @@ namespace ShiftOS.WinForms.Applications //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(); + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal).ToString(); lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " seconds left"; if (xVel > 20 || xVel < -20) @@ -355,8 +381,7 @@ namespace ShiftOS.WinForms.Applications } else { - paddleHuman.Width = 20; - paddleComputer.Width = 20; + paddleHuman.Width = paddleComputer.Width = 20; } } if (!IsMultiplayerSession) @@ -415,7 +440,7 @@ namespace ShiftOS.WinForms.Applications StartLevel(); })); } - else if(msg.Name == "pong_mp_levelcompleted") + else if (msg.Name == "pong_mp_levelcompleted") { level = Convert.ToInt32(msg.Contents) + 1; this.Invoke(new Action(CompleteLevel)); @@ -434,7 +459,7 @@ namespace ShiftOS.WinForms.Applications pnlmultiplayerhandshake.Hide(); })); } - else if(msg.Name == "pong_mp_cashedout") + else if (msg.Name == "pong_mp_cashedout") { this.Invoke(new Action(() => { @@ -442,19 +467,19 @@ namespace ShiftOS.WinForms.Applications })); 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") + else if (msg.Name == "pong_mp_startlevel") { OpponentAgrees = true; - if(YouAgree == false) + if (YouAgree == false) { - Infobox.PromptYesNo("Play another level?", "The opponent wants to play another level. Would you like to as well?", (answer)=> + 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") + else if (msg.Name == "pong_mp_level_callback") { bool agreed = bool.Parse(msg.Contents); OpponentAgrees = agreed; @@ -472,7 +497,7 @@ namespace ShiftOS.WinForms.Applications this.PossibleMatchmakes.Remove(msg.Contents); this.Invoke(new Action(ListMatchmakes)); } - else if(msg.Name == "pong_mp_clockupdate") + else if (msg.Name == "pong_mp_clockupdate") { secondsleft = Convert.ToInt32(msg.Contents); } @@ -566,7 +591,7 @@ namespace ShiftOS.WinForms.Applications public void LoseMP() { ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - if(IsLeader) + if (IsLeader) if (xVel > 0) xVel = -xVel; lblbeatai.Show(); @@ -634,7 +659,7 @@ namespace ShiftOS.WinForms.Applications CompleteLevel(); } - lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString(); + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal).ToString(); } } SetupStats(); @@ -670,200 +695,56 @@ namespace ShiftOS.WinForms.Applications lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - switch (rand.Next(1, 3)) - { - case 1: - levelxspeed = levelxspeed + 1; - break; - case 2: - levelxspeed = levelxspeed + 2; - break; - } + levelxspeed += rand.Next(1, 3); - switch (rand.Next(1, 3)) - { - case 1: - levelyspeed = levelyspeed + 1; - break; - case 2: - levelyspeed = levelyspeed + 2; - break; - } + levelyspeed += rand.Next(1, 3); - switch (rand.Next(1, 6)) - { - case 1: - incrementx = incrementx + 0.1; - break; - case 2: - incrementx = incrementx + 0.2; - break; - case 3: - incrementy = incrementy + 0.1; - break; - case 4: - incrementy = incrementy + 0.2; - break; - case 5: - incrementy = incrementy + 0.3; - break; - } + int rndinc = rand.Next(1, 6); + if (rndinc == 5) + incrementy += 0.3; + else + incrementy += (((rndinc - 1) % 2) + 1) / 10; lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); if (level < 15) { + beataireward = (ulong)(level * 5); if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = (ulong)(level * 10); - } else - { - beataireward = (ulong)(level * 5); - } + beataireward *= 2; } else - { if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - double br = levelrewards[level - 1] / 10; - beataireward = (ulong)Math.Round(br) * 10; - } else - { - double br = levelrewards[level - 1] / 10; - beataireward = (ulong)Math.Round(br) * 5; - } - } + beataireward = levelrewards[level - 1]; + else + beataireward = (ulong)Math.Round((double) levelrewards[level - 1] / 2); - totalreward = levelrewards[level - 1] + beatairewardtotal; + totalreward = levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal; btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); } - private void setuplevelrewards() - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - levelrewards[0] = 0; - levelrewards[1] = 40; - levelrewards[2] = 120; - levelrewards[3] = 280; - levelrewards[4] = 580; - levelrewards[5] = 800; - levelrewards[6] = 1200; - levelrewards[7] = 1800; - levelrewards[8] = 2400; - levelrewards[9] = 3200; - levelrewards[10] = 4000; - levelrewards[11] = 5000; - levelrewards[12] = 6000; - levelrewards[13] = 8000; - levelrewards[14] = 10000; - levelrewards[15] = 12000; - levelrewards[16] = 16000; - levelrewards[17] = 20000; - levelrewards[18] = 26000; - levelrewards[19] = 32000; - levelrewards[20] = 40000; - levelrewards[21] = 50000; - levelrewards[22] = 64000; - levelrewards[23] = 80000; - levelrewards[24] = 100000; - levelrewards[25] = 120000; - levelrewards[26] = 150000; - levelrewards[27] = 180000; - levelrewards[28] = 220000; - levelrewards[29] = 280000; - levelrewards[30] = 360000; - levelrewards[31] = 440000; - levelrewards[32] = 540000; - levelrewards[33] = 640000; - levelrewards[34] = 800000; - levelrewards[35] = 1000000; - levelrewards[36] = 1280000; - levelrewards[37] = 1600000; - levelrewards[38] = 2000000; - levelrewards[39] = 3000000; - levelrewards[40] = 4000000; - } else - { - levelrewards[0] = 0; - levelrewards[1] = 20; - levelrewards[2] = 60; - levelrewards[3] = 140; - levelrewards[4] = 290; - levelrewards[5] = 400; - levelrewards[6] = 600; - levelrewards[7] = 900; - levelrewards[8] = 1200; - levelrewards[9] = 1600; - levelrewards[10] = 2000; - levelrewards[11] = 2500; - levelrewards[12] = 3000; - levelrewards[13] = 4000; - levelrewards[14] = 5000; - levelrewards[15] = 6000; - levelrewards[16] = 8000; - levelrewards[17] = 10000; - levelrewards[18] = 13000; - levelrewards[19] = 16000; - levelrewards[20] = 20000; - levelrewards[21] = 25000; - levelrewards[22] = 32000; - levelrewards[23] = 40000; - levelrewards[24] = 50000; - levelrewards[25] = 60000; - levelrewards[26] = 75000; - levelrewards[27] = 90000; - levelrewards[28] = 110000; - levelrewards[29] = 140000; - levelrewards[30] = 180000; - levelrewards[31] = 220000; - levelrewards[32] = 270000; - levelrewards[33] = 320000; - levelrewards[34] = 400000; - levelrewards[35] = 500000; - levelrewards[36] = 640000; - levelrewards[37] = 800000; - levelrewards[38] = 1000000; - levelrewards[39] = 1500000; - levelrewards[40] = 2000000; - } - } - // ERROR: Handles clauses are not supported in C# private void countdown_Tick(object sender, EventArgs e) { if (this.Left < Screen.PrimaryScreen.Bounds.Width) { - switch (countdown) + if (countdown == 0) { - case 0: - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - break; - 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; + countdown = 3; + lblcountdown.Hide(); + lblbeatai.Hide(); + gameTimer.Start(); + counter.Start(); + tmrcountdown.Stop(); + return; } - + if (!lblcountdown.Visible) + lblcountdown.Show(); + lblcountdown.Text = countdown.ToString(); + countdown -= 1; + playsound(Properties.Resources.typesound); } } @@ -874,7 +755,7 @@ namespace ShiftOS.WinForms.Applications pnlfinalstats.Show(); lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = levelrewards[level - 1].ToString(); + lblfinallevelreward.Text = (levelrewards[level - 1] * rwdmultiplier).ToString(); lblfinalcomputerreward.Text = beatairewardtotal.ToString(); lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}"); SaveSystem.TransferCodepointsFrom("pong", totalreward); @@ -912,7 +793,8 @@ namespace ShiftOS.WinForms.Applications if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { beataireward = 10; - } else + } + else { beataireward = 5; } @@ -981,7 +863,7 @@ namespace ShiftOS.WinForms.Applications var hs = unite.GetPongHighscores(); foreach (var score in hs.Highscores) { - if(this.ParentForm.Visible == false) + if (this.ParentForm.Visible == false) { Thread.CurrentThread.Abort(); } @@ -1000,7 +882,7 @@ namespace ShiftOS.WinForms.Applications { try { - if (this.ParentForm.Visible == true) + if (this.ParentForm.Visible) { Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); this.Invoke(new Action(pnlgamestats.BringToFront)); @@ -1030,7 +912,7 @@ namespace ShiftOS.WinForms.Applications { newgame(); } - + // ERROR: Handles clauses are not supported in C# private void btnstartgame_Click(object sender, EventArgs e) { @@ -1045,9 +927,7 @@ namespace ShiftOS.WinForms.Applications int i = rand.Next(0, 100); if (i >= 25 && i <= 50) - { tmrstoryline.Stop(); - } } @@ -1057,25 +937,13 @@ namespace ShiftOS.WinForms.Applications tmrstoryline.Stop(); } - private void Label6_Click(object sender, EventArgs e) - { - - } - - private void Label8_Click(object sender, EventArgs e) + private void ball_MouseEnter(object sender, EventArgs e) { - - } - - private void pgcontents_Paint(object sender, PaintEventArgs e) { - - } - - private void ball_MouseEnter(object sender, EventArgs e) { aiShouldIsbeEnabled = false; } - private void ball_MouseLeave(object sender, EventArgs e) { + private void ball_MouseLeave(object sender, EventArgs e) + { aiShouldIsbeEnabled = true; } @@ -1102,9 +970,9 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { - if(IsMultiplayerSession == true) + if (IsMultiplayerSession) { - if(!string.IsNullOrWhiteSpace(OpponentGUID)) + if (!string.IsNullOrWhiteSpace(OpponentGUID)) ServerManager.Forward(OpponentGUID, "pong_mp_left", null); LeaveMatchmake(); } @@ -1134,10 +1002,10 @@ namespace ShiftOS.WinForms.Applications private void lvotherplayers_DoubleClick(object sender, EventArgs e) { - if(lvotherplayers.SelectedItems.Count > 0) + if (lvotherplayers.SelectedItems.Count > 0) { SendLeaderGUID(lvotherplayers.SelectedItems[0].Text); } } } -} +} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/Pong.resx b/ShiftOS.WinForms/Applications/Pong.resx index 3b5619d..cc96099 100644 --- a/ShiftOS.WinForms/Applications/Pong.resx +++ b/ShiftOS.WinForms/Applications/Pong.resx @@ -129,4 +129,7 @@ 17, 17 + + 472, 17 + \ No newline at end of file -- cgit v1.2.3 From e6d58c235c4d772cd5245d89cdc7dde6207165b8 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Jun 2017 17:08:42 -0400 Subject: Use GDI+ to render Pong --- ShiftOS.WinForms/Applications/Pong.Designer.cs | 797 +------------------- ShiftOS.WinForms/Applications/Pong.cs | 995 +++---------------------- ShiftOS.WinForms/Applications/Pong.resx | 15 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 18 +- 4 files changed, 118 insertions(+), 1707 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index c5ea375..11bed40 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -1,64 +1,13 @@ -/* - * 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. - */ - - -/* - * 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 ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications +namespace ShiftOS.WinForms.Applications { partial class Pong { - /// + /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; - /// + /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. @@ -71,738 +20,40 @@ namespace ShiftOS.WinForms.Applications base.Dispose(disposing); } + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.gameTimer = new System.Windows.Forms.Timer(this.components); - this.counter = new System.Windows.Forms.Timer(this.components); - 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(); - this.lblnextstats = new System.Windows.Forms.Label(); - this.Label7 = new System.Windows.Forms.Label(); - this.lblpreviousstats = new System.Windows.Forms.Label(); - this.Label4 = new System.Windows.Forms.Label(); - this.btnplayon = new System.Windows.Forms.Button(); - this.Label3 = new System.Windows.Forms.Label(); - this.btncashout = new System.Windows.Forms.Button(); - this.Label2 = new System.Windows.Forms.Label(); - this.lbllevelreached = 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(); - this.Label11 = new System.Windows.Forms.Label(); - this.lblfinalcomputerreward = new System.Windows.Forms.Label(); - this.Label9 = new System.Windows.Forms.Label(); - this.lblfinallevelreward = new System.Windows.Forms.Label(); - this.lblfinallevelreached = new System.Windows.Forms.Label(); - this.lblfinalcodepointswithtext = new System.Windows.Forms.Label(); - this.pnllose = new System.Windows.Forms.Panel(); - this.lblmissedout = new System.Windows.Forms.Label(); - this.lblbutyougained = new System.Windows.Forms.Label(); - this.btnlosetryagain = new System.Windows.Forms.Button(); - this.Label5 = new System.Windows.Forms.Label(); - this.Label1 = 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(); - this.paddleHuman = new System.Windows.Forms.PictureBox(); - this.paddleComputer = new System.Windows.Forms.Panel(); - this.lbllevelandtime = new System.Windows.Forms.Label(); - this.lblstatscodepoints = new System.Windows.Forms.Label(); - this.lblstatsY = new System.Windows.Forms.Label(); - this.lblstatsX = new System.Windows.Forms.Label(); - this.pgcontents.SuspendLayout(); - this.pnlmultiplayerhandshake.SuspendLayout(); - this.pnlintro.SuspendLayout(); - this.pnlhighscore.SuspendLayout(); - this.flowLayoutPanel1.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); - this.pnlfinalstats.SuspendLayout(); - this.pnllose.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); + this.pnlcanvas = new System.Windows.Forms.Panel(); this.SuspendLayout(); // - // gameTimer - // - this.gameTimer.Interval = 30; - this.gameTimer.Tick += new System.EventHandler(this.gameTimer_Tick); - // - // counter - // - this.counter.Interval = 1000; - this.counter.Tick += new System.EventHandler(this.counter_Tick); - // - // tmrcountdown - // - this.tmrcountdown.Interval = 1000; - this.tmrcountdown.Tick += new System.EventHandler(this.countdown_Tick); - // - // tmrstoryline - // - this.tmrstoryline.Interval = 1000; - this.tmrstoryline.Tick += new System.EventHandler(this.tmrstoryline_Tick); - // - // 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.lblbeatai); - this.pgcontents.Controls.Add(this.lblcountdown); - this.pgcontents.Controls.Add(this.ball); - this.pgcontents.Controls.Add(this.paddleHuman); - this.pgcontents.Controls.Add(this.paddleComputer); - this.pgcontents.Controls.Add(this.lbllevelandtime); - this.pgcontents.Controls.Add(this.lblstatscodepoints); - this.pgcontents.Controls.Add(this.lblstatsY); - this.pgcontents.Controls.Add(this.lblstatsX); - 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(912, 504); - this.pgcontents.TabIndex = 20; - 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; - // - // 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}"; - // - // 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); - this.pnlgamestats.Controls.Add(this.label12); - this.pnlgamestats.Controls.Add(this.lblnextstats); - this.pnlgamestats.Controls.Add(this.Label7); - this.pnlgamestats.Controls.Add(this.lblpreviousstats); - this.pnlgamestats.Controls.Add(this.Label4); - this.pnlgamestats.Controls.Add(this.btnplayon); - this.pnlgamestats.Controls.Add(this.Label3); - 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(104, 375); - this.pnlgamestats.Name = "pnlgamestats"; - this.pnlgamestats.Size = new System.Drawing.Size(466, 284); - this.pnlgamestats.TabIndex = 6; - this.pnlgamestats.Visible = false; - // - // button1 - // - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(32, 223); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(191, 35); - this.button1.TabIndex = 10; - this.button1.Text = "{PONG_VIEW_HIGHSCORES}"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.btnhighscore_Click); - // - // label12 - // - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(8, 187); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(245, 33); - this.label12.TabIndex = 9; - this.label12.Text = "{PONG_HIGHSCORE_EXP}"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblnextstats - // - this.lblnextstats.AutoSize = true; - this.lblnextstats.Location = new System.Drawing.Point(278, 136); - this.lblnextstats.Name = "lblnextstats"; - this.lblnextstats.Size = new System.Drawing.Size(0, 13); - this.lblnextstats.TabIndex = 8; - // - // Label7 - // - this.Label7.AutoSize = true; - this.Label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label7.Location = new System.Drawing.Point(278, 119); - this.Label7.Name = "Label7"; - this.Label7.Size = new System.Drawing.Size(124, 16); - this.Label7.TabIndex = 7; - this.Label7.Text = "Next Level Stats:"; - // - // lblpreviousstats - // - this.lblpreviousstats.AutoSize = true; - this.lblpreviousstats.Location = new System.Drawing.Point(278, 54); - this.lblpreviousstats.Name = "lblpreviousstats"; - this.lblpreviousstats.Size = new System.Drawing.Size(0, 13); - this.lblpreviousstats.TabIndex = 6; - // - // Label4 - // - this.Label4.AutoSize = true; - this.Label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label4.Location = new System.Drawing.Point(278, 37); - this.Label4.Name = "Label4"; - this.Label4.Size = new System.Drawing.Size(154, 16); - this.Label4.TabIndex = 5; - this.Label4.Text = "Previous Level Stats:"; - // - // btnplayon - // - this.btnplayon.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayon.Location = new System.Drawing.Point(32, 147); - this.btnplayon.Name = "btnplayon"; - this.btnplayon.Size = new System.Drawing.Size(191, 35); - this.btnplayon.TabIndex = 4; - this.btnplayon.Text = "Play on for 3 codepoints!"; - this.btnplayon.UseVisualStyleBackColor = true; - this.btnplayon.Click += new System.EventHandler(this.btnplayon_Click); + // pnlcanvas // - // Label3 - // - this.Label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label3.Location = new System.Drawing.Point(8, 111); - this.Label3.Name = "Label3"; - this.Label3.Size = new System.Drawing.Size(245, 33); - this.Label3.TabIndex = 3; - this.Label3.Text = "{PONG_PLAYON_DESC}"; - this.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btncashout - // - this.btncashout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btncashout.Location = new System.Drawing.Point(32, 73); - this.btncashout.Name = "btncashout"; - this.btncashout.Size = new System.Drawing.Size(191, 35); - this.btncashout.TabIndex = 2; - this.btncashout.Text = "Cash out with 1 codepoint!"; - this.btncashout.UseVisualStyleBackColor = true; - this.btncashout.Click += new System.EventHandler(this.btncashout_Click); - // - // Label2 - // - this.Label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label2.Location = new System.Drawing.Point(8, 37); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(245, 33); - this.Label2.TabIndex = 1; - this.Label2.Text = "{PONG_CASHOUT_DESC}"; - this.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbllevelreached - // - this.lbllevelreached.AutoSize = true; - this.lbllevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelreached.Location = new System.Drawing.Point(149, 6); - this.lbllevelreached.Name = "lbllevelreached"; - this.lbllevelreached.Size = new System.Drawing.Size(185, 20); - this.lbllevelreached.TabIndex = 0; - this.lbllevelreached.Text = "You Reached Level 2!"; - // - // pnlfinalstats - // - this.pnlfinalstats.Controls.Add(this.btnplayagain); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepoints); - this.pnlfinalstats.Controls.Add(this.Label11); - this.pnlfinalstats.Controls.Add(this.lblfinalcomputerreward); - this.pnlfinalstats.Controls.Add(this.Label9); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreward); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreached); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepointswithtext); - this.pnlfinalstats.Location = new System.Drawing.Point(172, 74); - this.pnlfinalstats.Name = "pnlfinalstats"; - this.pnlfinalstats.Size = new System.Drawing.Size(362, 226); - this.pnlfinalstats.TabIndex = 9; - this.pnlfinalstats.Visible = false; - // - // btnplayagain - // - this.btnplayagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayagain.Location = new System.Drawing.Point(5, 194); - this.btnplayagain.Name = "btnplayagain"; - this.btnplayagain.Size = new System.Drawing.Size(352, 29); - this.btnplayagain.TabIndex = 16; - this.btnplayagain.Text = "{PLAY}"; - this.btnplayagain.UseVisualStyleBackColor = true; - this.btnplayagain.Click += new System.EventHandler(this.btnplayagain_Click); - // - // lblfinalcodepoints - // - this.lblfinalcodepoints.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepoints.Location = new System.Drawing.Point(3, 124); - 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; - // - // Label11 - // - this.Label11.AutoSize = true; - this.Label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label11.Location = new System.Drawing.Point(162, 82); - 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; - // - // lblfinalcomputerreward - // - this.lblfinalcomputerreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcomputerreward.Location = new System.Drawing.Point(193, 72); - 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; - // - // Label9 - // - this.Label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label9.Location = new System.Drawing.Point(179, 31); - this.Label9.Name = "Label9"; - this.Label9.Size = new System.Drawing.Size(180, 49); - this.Label9.TabIndex = 11; - this.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreward - // - this.lblfinallevelreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreward.Location = new System.Drawing.Point(12, 72); - 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; - // - // lblfinallevelreached - // - this.lblfinallevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreached.Location = new System.Drawing.Point(3, 31); - this.lblfinallevelreached.Name = "lblfinallevelreached"; - this.lblfinallevelreached.Size = new System.Drawing.Size(170, 49); - this.lblfinallevelreached.TabIndex = 9; - this.lblfinallevelreached.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcodepointswithtext - // - this.lblfinalcodepointswithtext.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepointswithtext.Location = new System.Drawing.Point(3, 2); - 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; - // - // pnllose - // - this.pnllose.Controls.Add(this.lblmissedout); - this.pnllose.Controls.Add(this.lblbutyougained); - this.pnllose.Controls.Add(this.btnlosetryagain); - this.pnllose.Controls.Add(this.Label5); - this.pnllose.Controls.Add(this.Label1); - this.pnllose.Location = new System.Drawing.Point(209, 71); - this.pnllose.Name = "pnllose"; - this.pnllose.Size = new System.Drawing.Size(266, 214); - this.pnllose.TabIndex = 10; - this.pnllose.Visible = false; - // - // lblmissedout - // - this.lblmissedout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblmissedout.Location = new System.Drawing.Point(3, 175); - this.lblmissedout.Name = "lblmissedout"; - this.lblmissedout.Size = new System.Drawing.Size(146, 35); - this.lblmissedout.TabIndex = 3; - this.lblmissedout.Text = "You Missed Out On: 500 Codepoints"; - this.lblmissedout.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblbutyougained - // - this.lblbutyougained.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbutyougained.Location = new System.Drawing.Point(3, 125); - this.lblbutyougained.Name = "lblbutyougained"; - this.lblbutyougained.Size = new System.Drawing.Size(146, 35); - this.lblbutyougained.TabIndex = 3; - this.lblbutyougained.Text = "But you gained 5 Codepoints"; - this.lblbutyougained.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnlosetryagain - // - this.btnlosetryagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnlosetryagain.Location = new System.Drawing.Point(155, 176); - this.btnlosetryagain.Name = "btnlosetryagain"; - this.btnlosetryagain.Size = new System.Drawing.Size(106, 35); - this.btnlosetryagain.TabIndex = 2; - this.btnlosetryagain.Text = "Try Again"; - this.btnlosetryagain.UseVisualStyleBackColor = true; - this.btnlosetryagain.Click += new System.EventHandler(this.btnlosetryagain_Click); - // - // Label5 - // - this.Label5.Location = new System.Drawing.Point(7, 26); - this.Label5.Name = "Label5"; - this.Label5.Size = new System.Drawing.Size(260, 163); - this.Label5.TabIndex = 1; - // - // Label1 - // - this.Label1.Dock = System.Windows.Forms.DockStyle.Top; - this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label1.Location = new System.Drawing.Point(0, 0); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(266, 16); - this.Label1.TabIndex = 0; - this.Label1.Text = "You lose!"; - this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // lblbeatai - // - this.lblbeatai.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbeatai.Location = new System.Drawing.Point(47, 41); - 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; - // - // lblcountdown - // - this.lblcountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblcountdown.Location = new System.Drawing.Point(182, 152); - this.lblcountdown.Name = "lblcountdown"; - this.lblcountdown.Size = new System.Drawing.Size(315, 49); - this.lblcountdown.TabIndex = 7; - this.lblcountdown.Text = "3"; - this.lblcountdown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblcountdown.Visible = false; - // - // ball - // - this.ball.BackColor = System.Drawing.Color.Black; - this.ball.Location = new System.Drawing.Point(300, 152); - this.ball.Name = "ball"; - this.ball.Size = new System.Drawing.Size(20, 20); - this.ball.TabIndex = 2; - this.ball.MouseEnter += new System.EventHandler(this.ball_MouseEnter); - this.ball.MouseLeave += new System.EventHandler(this.ball_MouseLeave); - // - // paddleHuman - // - this.paddleHuman.BackColor = System.Drawing.Color.Black; - this.paddleHuman.Location = new System.Drawing.Point(10, 134); - this.paddleHuman.Name = "paddleHuman"; - this.paddleHuman.Size = new System.Drawing.Size(20, 100); - this.paddleHuman.TabIndex = 3; - this.paddleHuman.TabStop = false; - // - // paddleComputer - // - 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(878, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); - this.paddleComputer.Name = "paddleComputer"; - this.paddleComputer.Size = new System.Drawing.Size(20, 100); - this.paddleComputer.TabIndex = 1; - // - // lbllevelandtime - // - this.lbllevelandtime.Dock = System.Windows.Forms.DockStyle.Top; - 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(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) - | 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, 460); - this.lblstatscodepoints.Name = "lblstatscodepoints"; - 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(440, 460); - this.lblstatsY.Name = "lblstatsY"; - 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, 460); - this.lblstatsX.Name = "lblstatsX"; - 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; + this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlcanvas.Location = new System.Drawing.Point(0, 0); + this.pnlcanvas.Name = "pnlcanvas"; + this.pnlcanvas.Size = new System.Drawing.Size(620, 469); + this.pnlcanvas.TabIndex = 0; + this.pnlcanvas.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlcanvas_Paint); + this.pnlcanvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlcanvas_MouseMove); // // Pong // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.pgcontents); - this.DoubleBuffered = true; + this.Controls.Add(this.pnlcanvas); this.Name = "Pong"; - 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.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); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); + this.Size = new System.Drawing.Size(620, 469); this.ResumeLayout(false); } - internal System.Windows.Forms.Panel paddleComputer; - internal System.Windows.Forms.Timer gameTimer; - internal System.Windows.Forms.PictureBox paddleHuman; - internal System.Windows.Forms.Label lbllevelandtime; - internal System.Windows.Forms.Label lblstatsX; - internal System.Windows.Forms.Timer counter; - internal System.Windows.Forms.Panel pnlgamestats; - internal System.Windows.Forms.Label lblnextstats; - internal System.Windows.Forms.Label Label7; - internal System.Windows.Forms.Label lblpreviousstats; - internal System.Windows.Forms.Label Label4; - internal System.Windows.Forms.Button btnplayon; - internal System.Windows.Forms.Label Label3; - internal System.Windows.Forms.Button btncashout; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Label lbllevelreached; - internal System.Windows.Forms.Label lblcountdown; - internal System.Windows.Forms.Timer tmrcountdown; - internal System.Windows.Forms.Label lblbeatai; - internal System.Windows.Forms.Panel pnlfinalstats; - internal System.Windows.Forms.Button btnplayagain; - internal System.Windows.Forms.Label lblfinalcodepoints; - internal System.Windows.Forms.Label Label11; - internal System.Windows.Forms.Label lblfinalcomputerreward; - internal System.Windows.Forms.Label Label9; - internal System.Windows.Forms.Label lblfinallevelreward; - internal System.Windows.Forms.Label lblfinallevelreached; - internal System.Windows.Forms.Label lblfinalcodepointswithtext; - internal System.Windows.Forms.Panel pnllose; - internal System.Windows.Forms.Label lblmissedout; - internal System.Windows.Forms.Label lblbutyougained; - internal System.Windows.Forms.Button btnlosetryagain; - internal System.Windows.Forms.Label Label5; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.Label lblstatscodepoints; - internal System.Windows.Forms.Label lblstatsY; - internal System.Windows.Forms.Panel pnlintro; - internal System.Windows.Forms.Label Label6; - internal System.Windows.Forms.Button btnstartgame; - internal System.Windows.Forms.Label Label8; - internal System.Windows.Forms.Timer tmrstoryline; - private System.Windows.Forms.Panel pnlhighscore; - private System.Windows.Forms.ListView lbhighscore; - private System.Windows.Forms.Label label10; - internal Canvas pgcontents; - internal Canvas ball; - internal System.Windows.Forms.Button button1; - 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; + + #endregion + + private System.Windows.Forms.Panel pnlcanvas; } } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 87f0306..a88d69f 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -1,1011 +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; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; +using System.Data; 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")] + [DefaultTitle("Pong")] [DefaultIcon("iconPong")] public partial class Pong : UserControl, IShiftOSWindow { - //I can assure you guaranteed that there is an acorn somewhere, in this place, and the sailors are looking for it - int xVel = 7; - int yVel = 8; - int computerspeed = 8; - int level = 1; - int secondsleft = 60; - int casualposition; - double xveldec = 3.0; - double yveldec = 3.0; - double incrementx = 0.4; - double incrementy = 0.2; - int levelxspeed = 3; - int levelyspeed = 3; - ulong beatairewardtotal; - ulong beataireward = 1; - readonly uint[] levelrewards = { - 0, - 20, - 60, - 140, - 290, - 400, - 600, - 900, - 1200, - 1600, - 2000, - 2500, - 3000, - 4000, - 5000, - 6000, - 8000, - 10000, - 13000, - 16000, - 20000, - 25000, - 32000, - 40000, - 50000, - 60000, - 75000, - 90000, - 110000, - 140000, - 180000, - 220000, - 270000, - 320000, - 400000, - 500000, - 640000, - 800000, - 1000000, - 1500000, - 2000000}; - ulong totalreward; - int countdown = 3; - int rwdmultiplier; - Thread soundThread; - - bool aiShouldIsbeEnabled = true; // who named this variable? and were they having a stroke? - - private void playsound(System.IO.Stream stream) - { - soundThread = new Thread((a) => ShiftOS.Engine.AudioManager.PlayStream((System.IO.Stream)a)); - soundThread.Start(stream); - } - public Pong() { InitializeComponent(); - } - - private void Pong_Load(object sender, EventArgs e) - { - rwdmultiplier = ShiftoriumFrontend.UpgradeInstalled("pong_upgrade") ? 2 : 1; - } - - // Move the paddle according to the mouse position. - private void pongMain_MouseMove(object sender, MouseEventArgs e) - { - var loc = this.PointToClient(MousePosition); - 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 + paddleWidth = pnlcanvas.Width / 30; + drawTimer = new Timer(); + drawTimer.Interval = 16; + drawTimer.Tick += (o, a) => { - 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; + UpdateBall(); + pnlcanvas.Refresh(); + }; } - int OpponentY = 0; - - bool IsLeader = true; + private double ballX = 0.0f; + private double ballY = 0.0f; - int LeaderX = 0; - int LeaderY = 0; - // ERROR: Handles clauses are not supported in C# - private void gameTimer_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - ball.BackColor = paddleComputer.BackColor = 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; - //} - //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 (IsMultiplayerSession) - { - //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 - paddleHuman.Top = OpponentY; - } - else - { - if (aiShouldIsbeEnabled) - if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) - { - if (ball.Top > paddleComputer.Top + 50) - paddleComputer.Top += computerspeed; - else - paddleComputer.Top -= computerspeed; - casualposition = rand.Next(-150, 201); - } - else - { - //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.Top > this.Height / 2 - paddleComputer.Height + casualposition) - paddleComputer.Top -= computerspeed; - else - paddleComputer.Top += computerspeed; - } - } - //Set Xvel and Yvel speeds from decimal - if (xVel > 0) - xVel = (int)Math.Round(xveldec); - else - xVel = (int)-Math.Round(xveldec); - if (yVel > 0) - yVel = (int)Math.Round(yveldec); - else - yVel = (int)-Math.Round(yveldec); - - if (IsMultiplayerSession && !IsLeader) - { - // Move it to the leader's ball position. - ball.Location = new Point(LeaderX, LeaderY); - } - else - { - var newRect = new Rectangle(ball.Location, ball.Size); // copy ball's Bounds - newRect.X += xVel; - newRect.Y += yVel; - - // Check for top wall. - if (newRect.Y < 0) - { - newRect.Y = 0; - yVel = -yVel; - playsound(Properties.Resources.typesound); - } - - // Check for bottom wall. - if (newRect.Y > pgcontents.Height - ball.Height) - { - newRect.Y = pgcontents.Height - ball.Height; - yVel = -yVel; - playsound(Properties.Resources.typesound); - } - - - // Check for player paddle. - if (newRect.IntersectsWith(paddleHuman.Bounds)) - { - newRect.X = paddleHuman.Left + ball.Width + 1; - //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; - else - yveldec = yveldec - incrementy; - break; - } - xVel = -xVel; - playsound(Properties.Resources.writesound); - - } - - // Check for computer paddle. - if (newRect.IntersectsWith(paddleComputer.Bounds)) - { - newRect.X = paddleComputer.Left - paddleComputer.Width - 1; - xveldec = xveldec + incrementx; - xVel = -xVel; - playsound(Properties.Resources.writesound); - } - ball.Location = newRect.Location; - } - - - - // Check for left wall. - if (ball.Location.X < -100) - { - //If we are in multiplayer, and not the leader, we won. - if (IsMultiplayerSession) - { - if (IsLeader) - { - //We lost. - NotifyLoseToTarget(); - } - else - { - //We won. - NotifyWinToTarget(); - Win(); - } - } - else - { - 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] * (ulong) rwdmultiplier + beatairewardtotal); - double onePercent = (totalreward / 100); - lblbutyougained.Show(); - lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (ulong)(onePercent)); - } - else - { - lblbutyougained.Hide(); - } - } - } + private double speedFactor = 0.025; - // Check for right wall. - if (ball.Location.X > this.Width - ball.Size.Width - paddleComputer.Width + 100) - { - if (IsMultiplayerSession) - { - //If we are the leader we won. - if (IsLeader) - { - NotifyWinToTarget(); - Win(); - } - else - { - NotifyLoseToTarget(); - } - } - else - { - Win(); - } - } + private double xVel = 1; + private double yVel = 1; - if (IsMultiplayerSession) - { - if (IsLeader) - { - ServerManager.Forward(OpponentGUID, "pong_mp_setballpos", JsonConvert.SerializeObject(ball.Location)); - } - } + private int paddleWidth; - if (IsLeader) - { - //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] * (ulong) rwdmultiplier + 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 = paddleComputer.Width = 20; - } - } - if (!IsMultiplayerSession) - { - computerspeed = Math.Abs(yVel); - } - } - } + private double playerY = 0.0; + private double opponentY = 0.0; - public void ServerMessageReceivedHandler(ServerMessage msg) + public void UpdateBall() { - if (IsMultiplayerSession) - { - if (msg.Name == "pong_mp_setballpos") - { - var pt = JsonConvert.DeserializeObject(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)); - } - } - } + double ballXLocal = linear(ballX, -1.0, 1.0, 0, pnlcanvas.Width); + double ballYLocal = linear(ballY, -1.0, 1.0, 0, pnlcanvas.Height); - bool OpponentAgrees = false; - bool YouAgree = false; + ballXLocal -= ((double)paddleWidth / 2); + ballYLocal -= ((double)paddleWidth / 2); - 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); - } - } + double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); + double opponentYLocal = linear(opponentY, -1.0, 1.0, 0, pnlcanvas.Height); - if (PossibleMatchmakes.Count > 0) - { - lbmpstatus.Text = "Select a player."; - } - else - { - lbmpstatus.Text = "Waiting for players..."; - } - } + int paddleHeight = pnlcanvas.Height / 5; - public void NotifyLoseToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youwin", null); - } - public void NotifyWinToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youlose", null); - } + Rectangle ballRect = new Rectangle((int)ballXLocal, (int)ballYLocal, paddleWidth, paddleWidth); - public void LeaveMatchmake() - { - ServerManager.Forward("all", "pong_handshake_left", YouGUID); - } + Rectangle playerRect = new Rectangle((int)paddleWidth, (int)(playerYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); + Rectangle opponentRect = new Rectangle((int)(pnlcanvas.Width - (paddleWidth * 2)), (int)(opponentYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); - List PossibleMatchmakes = new List(); + //Top and bottom walls: + if (ballRect.Top <= 0 || ballRect.Bottom >= pnlcanvas.Height) + yVel = -yVel; //reverse the Y velocity - public void SendLeaderGUID(string target) - { - ServerManager.Forward(target, "pong_handshake_chosen", YouGUID); - } + //Left and right walls (NOTE: TEMPORARY) + if (ballRect.Left <= 0 || ballRect.Right >= pnlcanvas.Width) + xVel = -xVel; //reverse the Y velocity - 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) + //Enemy paddle: + if (ballRect.IntersectsWith(opponentRect)) + { + //check if the ball x is greater than the player paddle's middle coordinate + if (ballRect.Right <= opponentRect.Right - (opponentRect.Width / 2)) + { + //reverse x velocity to send the ball the other way 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(); - } + //set y velocity based on where the ball hit the paddle + yVel = linear((ballRect.Top + (ballRect.Height / 2)), opponentRect.Top, opponentRect.Bottom, -1, 1); - 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 (IsLeader) + //Player paddle: + if (ballRect.IntersectsWith(playerRect)) { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) + //check if the ball x is greater than the player paddle's middle coordinate + if(ballRect.Left >= playerRect.Left + (playerRect.Width / 2)) { - secondsleft = secondsleft - 1; - if (secondsleft == 0) - { - CompleteLevel(); - } - - lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal).ToString(); - } - } - SetupStats(); - } - - [Obsolete("This method does nothing. Use UniteClient for highscore queries.")] - public void SendHighscores() - { - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayon_Click(object sender, EventArgs e) - { - xveldec = levelxspeed; - yveldec = levelyspeed; - - secondsleft = 60; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, paddleHuman.Location.Y + paddleHuman.Height / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - //Increase the ball speed stats for the next level - private void generatenextlevel() - { - lbllevelreached.Text = Localization.Parse("{YOU_REACHED_LEVEL} " + level + "!"); - - lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - levelxspeed += rand.Next(1, 3); - - levelyspeed += rand.Next(1, 3); + //reverse x velocity to send the ball the other way + xVel = -xVel; - int rndinc = rand.Next(1, 6); - if (rndinc == 5) - incrementy += 0.3; - else - incrementy += (((rndinc - 1) % 2) + 1) / 10; + //set y velocity based on where the ball hit the paddle + yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); - lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); + } - if (level < 15) - { - beataireward = (ulong)(level * 5); - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - beataireward *= 2; } - else - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - beataireward = levelrewards[level - 1]; - else - beataireward = (ulong)Math.Round((double) levelrewards[level - 1] / 2); - totalreward = levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal; - btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); - btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); - } - // ERROR: Handles clauses are not supported in C# - private void countdown_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - if (countdown == 0) - { - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - return; - } - if (!lblcountdown.Visible) - lblcountdown.Show(); - lblcountdown.Text = countdown.ToString(); - countdown -= 1; - playsound(Properties.Resources.typesound); - } - } - // ERROR: Handles clauses are not supported in C# - private void btncashout_Click(object sender, EventArgs e) - { - pnlgamestats.Hide(); - pnlfinalstats.Show(); - lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); - lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = (levelrewards[level - 1] * rwdmultiplier).ToString(); - 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() - { - pnlfinalstats.Hide(); - pnllose.Hide(); - pnlintro.Hide(); + ballX += xVel * speedFactor; + ballY += yVel * speedFactor; - level = 1; - totalreward = 0; - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = 10; - } - else - { - beataireward = 5; - } - beatairewardtotal = 0; - secondsleft = 60; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: "); - //reset stats text - lblstatsX.Text = Localization.Parse("{H_VEL}: "); - lblstatsY.Text = Localization.Parse("{V_VEL}: "); - - levelxspeed = 3; - levelyspeed = 3; - - incrementx = 0.4; - incrementy = 0.2; - - xveldec = levelxspeed; - yveldec = levelyspeed; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, (paddleHuman.Location.Y + paddleHuman.Height) / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{{LEVEL}}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); } - public void btnhighscore_Click(object s, EventArgs a) + private void pnlcanvas_Paint(object sender, PaintEventArgs e) { - pnlhighscore.BringToFront(); - SetupHighScores(); - } - bool IsMultiplayerSession = false; + paddleWidth = pnlcanvas.Width / 30; + double ballXLocal = linear(ballX, -1.0, 1.0, 0, pnlcanvas.Width); + double ballYLocal = linear(ballY, -1.0, 1.0, 0, pnlcanvas.Height); - string YouGUID = ""; - string OpponentGUID = ""; + ballXLocal -= ((double)paddleWidth / 2); + ballYLocal -= ((double)paddleWidth / 2); - public void SetupHighScores() - { - lbhighscore.Items.Clear(); - 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(() => - { - try - { - 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(() => - { - 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()); - })); - } - } - catch - { - try - { - if (this.ParentForm.Visible) - { - 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(); - } + e.Graphics.Clear(pnlcanvas.BackColor); - // ERROR: Handles clauses are not supported in C# - private void btnplayagain_Click(object sender, EventArgs e) - { - newgame(); - } + //draw the ball + e.Graphics.FillEllipse(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)ballXLocal, (float)ballYLocal, (float)paddleWidth, (float)paddleWidth)); - // ERROR: Handles clauses are not supported in C# - private void btnlosetryagain_Click(object sender, EventArgs e) - { - newgame(); - } + double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); + double opponentYLocal = linear(opponentY, -1.0, 1.0, 0, pnlcanvas.Height); - public void StartLevel() - { - newgame(); - } + int paddleHeight = pnlcanvas.Height / 5; - // ERROR: Handles clauses are not supported in C# - private void btnstartgame_Click(object sender, EventArgs e) - { - newgame(); - } + int paddleStart = paddleWidth; - Random rand = new Random(); - // ERROR: Handles clauses are not supported in C# - private void tmrstoryline_Tick(object sender, EventArgs e) - { - // Random chance of showing getshiftnet storyline - int i = rand.Next(0, 100); + //draw player paddle + e.Graphics.FillRectangle(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)paddleWidth, (float)(playerYLocal - (float)(paddleHeight / 2)), (float)paddleWidth, (float)paddleHeight)); - if (i >= 25 && i <= 50) - tmrstoryline.Stop(); + //draw opponent + e.Graphics.FillRectangle(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)(pnlcanvas.Width - (paddleWidth*2)), (float)(opponentYLocal - (float)(paddleHeight / 2)), (float)paddleWidth, (float)paddleHeight)); } - // ERROR: Handles clauses are not supported in C# - private void me_closing(object sender, FormClosingEventArgs e) + static public double linear(double x, double x0, double x1, double y0, double y1) { - tmrstoryline.Stop(); - } - - private void ball_MouseEnter(object sender, EventArgs e) - { - aiShouldIsbeEnabled = false; + if ((x1 - x0) == 0) + { + return (y0 + y1) / 2; + } + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); } - private void ball_MouseLeave(object sender, EventArgs e) - { - aiShouldIsbeEnabled = true; - } + Timer drawTimer = null; public void OnLoad() { - pnlintro.BringToFront(); - pnlintro.Show(); - pnlhighscore.Hide(); - pnlgamestats.Hide(); - pnlfinalstats.Hide(); - CenterPanels(); - lblbeatai.Hide(); - ServerManager.MessageReceived += this.ServerMessageReceivedHandler; + drawTimer.Start(); } public void OnSkinLoad() { - CenterPanels(); - this.SizeChanged += (o, a) => - { - CenterPanels(); - }; } public bool OnUnload() { - if (IsMultiplayerSession) - { - if (!string.IsNullOrWhiteSpace(OpponentGUID)) - ServerManager.Forward(OpponentGUID, "pong_mp_left", null); - LeaveMatchmake(); - } - ServerManager.MessageReceived -= this.ServerMessageReceivedHandler; - + drawTimer.Stop(); 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) + private void pnlcanvas_MouseMove(object sender, MouseEventArgs e) { - if (lvotherplayers.SelectedItems.Count > 0) - { - SendLeaderGUID(lvotherplayers.SelectedItems[0].Text); - } + playerY = linear(e.Y, 0, pnlcanvas.Height, -1, 1); } } -} \ No newline at end of file +} diff --git a/ShiftOS.WinForms/Applications/Pong.resx b/ShiftOS.WinForms/Applications/Pong.resx index cc96099..1af7de1 100644 --- a/ShiftOS.WinForms/Applications/Pong.resx +++ b/ShiftOS.WinForms/Applications/Pong.resx @@ -117,19 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 227, 17 - - - 134, 17 - - - 340, 17 - - - 17, 17 - - - 472, 17 - \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 31de44e..9e16b19 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -77,6 +77,12 @@ IconManager.cs + + UserControl + + + Pong.cs + UserControl @@ -197,12 +203,6 @@ Notifications.cs - - UserControl - - - Pong.cs - UserControl @@ -490,6 +490,9 @@ IconManager.cs + + Pong.cs + TriPresent.cs @@ -547,9 +550,6 @@ Notifications.cs - - Pong.cs - Shifter.cs -- cgit v1.2.3 From 6a28bbbb634cb0e17d8b07cec35acb18f7613d34 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Jun 2017 17:45:57 -0400 Subject: Ball prediction AI --- ShiftOS.WinForms/Applications/Pong.cs | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index a88d69f..1221729 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -33,6 +33,9 @@ namespace ShiftOS.WinForms.Applications private double ballX = 0.0f; private double ballY = 0.0f; + private double aiBallX = 0.0f; + private double aiBallY = 0.0f; + private double speedFactor = 0.025; @@ -44,6 +47,8 @@ namespace ShiftOS.WinForms.Applications private double playerY = 0.0; private double opponentY = 0.0; + bool doAi = true; + public void UpdateBall() { double ballXLocal = linear(ballX, -1.0, 1.0, 0, pnlcanvas.Width); @@ -52,6 +57,13 @@ namespace ShiftOS.WinForms.Applications ballXLocal -= ((double)paddleWidth / 2); ballYLocal -= ((double)paddleWidth / 2); + double aiBallXLocal = linear(aiBallX, -1.0, 1.0, 0, pnlcanvas.Width); + double aiBallYLocal = linear(aiBallY, -1.0, 1.0, 0, pnlcanvas.Height); + + aiBallXLocal -= ((double)paddleWidth / 2); + aiBallYLocal -= ((double)paddleWidth / 2); + + double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); double opponentYLocal = linear(opponentY, -1.0, 1.0, 0, pnlcanvas.Height); @@ -60,6 +72,9 @@ namespace ShiftOS.WinForms.Applications Rectangle ballRect = new Rectangle((int)ballXLocal, (int)ballYLocal, paddleWidth, paddleWidth); + Rectangle aiBallRect = new Rectangle((int)aiBallXLocal, (int)aiBallYLocal, paddleWidth, paddleWidth); + + Rectangle playerRect = new Rectangle((int)paddleWidth, (int)(playerYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); Rectangle opponentRect = new Rectangle((int)(pnlcanvas.Width - (paddleWidth * 2)), (int)(opponentYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); @@ -90,6 +105,16 @@ namespace ShiftOS.WinForms.Applications } + //Enemy paddle - AI: + if (aiBallRect.IntersectsWith(opponentRect)) + { + //check if the ball x is greater than the player paddle's middle coordinate + if (aiBallRect.Right <= opponentRect.Right - (opponentRect.Width / 2)) + { + doAi = false; + } + + } //Player paddle: @@ -104,6 +129,10 @@ namespace ShiftOS.WinForms.Applications //set y velocity based on where the ball hit the paddle yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); + //reset the ai location + aiBallX = ballX; + aiBallY = ballY; + doAi = true; } } @@ -115,6 +144,23 @@ namespace ShiftOS.WinForms.Applications ballX += xVel * speedFactor; ballY += yVel * speedFactor; + aiBallX += xVel * (speedFactor * 2); + aiBallY += yVel * (speedFactor * 2); + + if (doAi == true) + { + if (opponentY != aiBallY) + { + if (opponentY < aiBallY) + { + opponentY += speedFactor; + } + else + { + opponentY -= speedFactor; + } + } + } } private void pnlcanvas_Paint(object sender, PaintEventArgs e) -- cgit v1.2.3 From 11ff04a384b7c11746dde10114bd5aee6bb9a3d4 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Jun 2017 18:13:07 -0400 Subject: ai improvements and codepoints --- ShiftOS.WinForms/Applications/Pong.cs | 63 ++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 5 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 1221729..235a049 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -44,6 +44,10 @@ namespace ShiftOS.WinForms.Applications private int paddleWidth; + private long codepointsToEarn = 0; + private int level = 1; + + private double playerY = 0.0; private double opponentY = 0.0; @@ -82,11 +86,22 @@ namespace ShiftOS.WinForms.Applications if (ballRect.Top <= 0 || ballRect.Bottom >= pnlcanvas.Height) yVel = -yVel; //reverse the Y velocity - //Left and right walls (NOTE: TEMPORARY) - if (ballRect.Left <= 0 || ballRect.Right >= pnlcanvas.Width) - xVel = -xVel; //reverse the Y velocity + //Left wall + if(ballRect.Left <= 0) + { + //You lose. + codepointsToEarn = 0; + Lose(); + } + //Right wall + if(ballRect.Right >= pnlcanvas.Width) + { + //You win. + codepointsToEarn += CalculateAIBeatCP(); + Win(); + } //Enemy paddle: if (ballRect.IntersectsWith(opponentRect)) @@ -153,16 +168,45 @@ namespace ShiftOS.WinForms.Applications { if (opponentY < aiBallY) { - opponentY += speedFactor; + if (opponentY < 0.9) + opponentY += speedFactor; } else { - opponentY -= speedFactor; + if (opponentY > -0.9) + opponentY -= speedFactor; } } } } + public void Lose() + { + InitializeCoordinates(); + } + + public long CalculateAIBeatCP() + { + return 2 * (10 * level); + } + + public void Win() + { + InitializeCoordinates(); + } + + public void InitializeCoordinates() + { + ballX = 0; + ballY = 0; + xVel = 1; + yVel = 1; + opponentY = 0; + aiBallX = 0; + aiBallY = 0; + doAi = true; + } + private void pnlcanvas_Paint(object sender, PaintEventArgs e) { @@ -192,6 +236,15 @@ namespace ShiftOS.WinForms.Applications //draw opponent e.Graphics.FillRectangle(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)(pnlcanvas.Width - (paddleWidth*2)), (float)(opponentYLocal - (float)(paddleHeight / 2)), (float)paddleWidth, (float)paddleHeight)); + string cp_text = Localization.Parse("{CODEPOINTS}: " + codepointsToEarn); + + var tSize = e.Graphics.MeasureString(cp_text, SkinEngine.LoadedSkin.Header3Font); + + var tLoc = new PointF((pnlcanvas.Width - (int)tSize.Width) / 2, + (pnlcanvas.Height - (int)tSize.Height) + + ); + e.Graphics.DrawString(cp_text, SkinEngine.LoadedSkin.Header3Font, new SolidBrush(pnlcanvas.ForeColor), tLoc); } static public double linear(double x, double x0, double x1, double y0, double y1) -- cgit v1.2.3 From f9ef8e021ca391f1b2f902ed3d91cb711a753f82 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Jun 2017 20:01:26 -0400 Subject: More optimizations --- ShiftOS.WinForms/Applications/Pong.Designer.cs | 4 +- ShiftOS.WinForms/Applications/Pong.cs | 242 ++++++++++++++++--------- 2 files changed, 160 insertions(+), 86 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index 11bed40..22ad6f6 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -36,7 +36,7 @@ this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill; this.pnlcanvas.Location = new System.Drawing.Point(0, 0); this.pnlcanvas.Name = "pnlcanvas"; - this.pnlcanvas.Size = new System.Drawing.Size(620, 469); + this.pnlcanvas.Size = new System.Drawing.Size(879, 450); this.pnlcanvas.TabIndex = 0; this.pnlcanvas.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlcanvas_Paint); this.pnlcanvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlcanvas_MouseMove); @@ -47,7 +47,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.pnlcanvas); this.Name = "Pong"; - this.Size = new System.Drawing.Size(620, 469); + this.Size = new System.Drawing.Size(879, 450); this.ResumeLayout(false); } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 235a049..079c880 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -22,12 +22,25 @@ namespace ShiftOS.WinForms.Applications InitializeComponent(); paddleWidth = pnlcanvas.Width / 30; drawTimer = new Timer(); - drawTimer.Interval = 16; + drawTimer.Interval = 1; drawTimer.Tick += (o, a) => { UpdateBall(); pnlcanvas.Refresh(); }; + counterTimer = new Timer(); + counterTimer.Interval = 1000; + counterTimer.Tick += (o, a) => + { + if(secondsleft > 0) + { + secondsleft--; + } + else + { + LevelComplete(); + } + }; } private double ballX = 0.0f; @@ -37,144 +50,154 @@ namespace ShiftOS.WinForms.Applications private double aiBallY = 0.0f; - private double speedFactor = 0.025; + private double speedFactor = 0.0125; private double xVel = 1; private double yVel = 1; private int paddleWidth; + Timer counterTimer = null; + private long codepointsToEarn = 0; private int level = 1; private double playerY = 0.0; private double opponentY = 0.0; - + private int secondsleft = 60; bool doAi = true; + bool doBallCalc = true; + + private string header = "Pong - Technology Demo"; + + private string counter = ""; public void UpdateBall() { - double ballXLocal = linear(ballX, -1.0, 1.0, 0, pnlcanvas.Width); - double ballYLocal = linear(ballY, -1.0, 1.0, 0, pnlcanvas.Height); + if (doBallCalc) + { + double ballXLocal = linear(ballX, -1.0, 1.0, 0, pnlcanvas.Width); + double ballYLocal = linear(ballY, -1.0, 1.0, 0, pnlcanvas.Height); - ballXLocal -= ((double)paddleWidth / 2); - ballYLocal -= ((double)paddleWidth / 2); + ballXLocal -= ((double)paddleWidth / 2); + ballYLocal -= ((double)paddleWidth / 2); - double aiBallXLocal = linear(aiBallX, -1.0, 1.0, 0, pnlcanvas.Width); - double aiBallYLocal = linear(aiBallY, -1.0, 1.0, 0, pnlcanvas.Height); + double aiBallXLocal = linear(aiBallX, -1.0, 1.0, 0, pnlcanvas.Width); + double aiBallYLocal = linear(aiBallY, -1.0, 1.0, 0, pnlcanvas.Height); - aiBallXLocal -= ((double)paddleWidth / 2); - aiBallYLocal -= ((double)paddleWidth / 2); + aiBallXLocal -= ((double)paddleWidth / 2); + aiBallYLocal -= ((double)paddleWidth / 2); - double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); - double opponentYLocal = linear(opponentY, -1.0, 1.0, 0, pnlcanvas.Height); + double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); + double opponentYLocal = linear(opponentY, -1.0, 1.0, 0, pnlcanvas.Height); - int paddleHeight = pnlcanvas.Height / 5; + int paddleHeight = pnlcanvas.Height / 5; - Rectangle ballRect = new Rectangle((int)ballXLocal, (int)ballYLocal, paddleWidth, paddleWidth); + Rectangle ballRect = new Rectangle((int)ballXLocal, (int)ballYLocal, paddleWidth, paddleWidth); - Rectangle aiBallRect = new Rectangle((int)aiBallXLocal, (int)aiBallYLocal, paddleWidth, paddleWidth); + Rectangle aiBallRect = new Rectangle((int)aiBallXLocal, (int)aiBallYLocal, paddleWidth, paddleWidth); - Rectangle playerRect = new Rectangle((int)paddleWidth, (int)(playerYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); - Rectangle opponentRect = new Rectangle((int)(pnlcanvas.Width - (paddleWidth * 2)), (int)(opponentYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); + Rectangle playerRect = new Rectangle((int)paddleWidth, (int)(playerYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); + Rectangle opponentRect = new Rectangle((int)(pnlcanvas.Width - (paddleWidth * 2)), (int)(opponentYLocal - (int)(paddleHeight / 2)), (int)paddleWidth, (int)paddleHeight); - //Top and bottom walls: - if (ballRect.Top <= 0 || ballRect.Bottom >= pnlcanvas.Height) - yVel = -yVel; //reverse the Y velocity + //Top and bottom walls: + if (ballRect.Top <= 0 || ballRect.Bottom >= pnlcanvas.Height) + yVel = -yVel; //reverse the Y velocity - //Left wall - if(ballRect.Left <= 0) - { - //You lose. - codepointsToEarn = 0; - Lose(); - } + //Left wall + if (ballRect.Left <= 0) + { + //You lose. + codepointsToEarn = 0; + Lose(); + } - //Right wall - if(ballRect.Right >= pnlcanvas.Width) - { - //You win. - codepointsToEarn += CalculateAIBeatCP(); - Win(); - } + //Right wall + if (ballRect.Right >= pnlcanvas.Width) + { + //You win. + codepointsToEarn += CalculateAIBeatCP(); + Win(); + } - //Enemy paddle: - if (ballRect.IntersectsWith(opponentRect)) - { - //check if the ball x is greater than the player paddle's middle coordinate - if (ballRect.Right <= opponentRect.Right - (opponentRect.Width / 2)) + //Enemy paddle: + if (ballRect.IntersectsWith(opponentRect)) { - //reverse x velocity to send the ball the other way - xVel = -xVel; + //check if the ball x is greater than the player paddle's middle coordinate + if (ballRect.Right >= opponentRect.Left) + { + //reverse x velocity to send the ball the other way + xVel = -xVel; - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), opponentRect.Top, opponentRect.Bottom, -1, 1); + //set y velocity based on where the ball hit the paddle + yVel = linear((ballRect.Top + (ballRect.Height / 2)), opponentRect.Top, opponentRect.Bottom, -1, 1); + doAi = false; + } } - } - - //Enemy paddle - AI: - if (aiBallRect.IntersectsWith(opponentRect)) - { - //check if the ball x is greater than the player paddle's middle coordinate - if (aiBallRect.Right <= opponentRect.Right - (opponentRect.Width / 2)) + //Enemy paddle - AI: + if (aiBallRect.IntersectsWith(opponentRect)) { - doAi = false; - } + //check if the ball x is greater than the player paddle's middle coordinate + if (aiBallRect.Right >= opponentRect.Left) + { + doAi = false; + } - } + } - //Player paddle: - if (ballRect.IntersectsWith(playerRect)) - { - //check if the ball x is greater than the player paddle's middle coordinate - if(ballRect.Left >= playerRect.Left + (playerRect.Width / 2)) + //Player paddle: + if (ballRect.IntersectsWith(playerRect)) { - //reverse x velocity to send the ball the other way - xVel = -xVel; + //check if the ball x is greater than the player paddle's middle coordinate + if (ballRect.Left >= playerRect.Left) + { + //reverse x velocity to send the ball the other way + xVel = -xVel; - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); + //set y velocity based on where the ball hit the paddle + yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); - //reset the ai location - aiBallX = ballX; - aiBallY = ballY; - doAi = true; - } + //reset the ai location + aiBallX = ballX; + aiBallY = ballY; + doAi = true; + } - } + } - ballX += xVel * speedFactor; - ballY += yVel * speedFactor; + ballX += xVel * speedFactor; + ballY += yVel * speedFactor; - aiBallX += xVel * (speedFactor * 2); - aiBallY += yVel * (speedFactor * 2); + aiBallX += xVel * (speedFactor * 2); + aiBallY += yVel * (speedFactor * 2); - if (doAi == true) - { - if (opponentY != aiBallY) + if (doAi == true) { - if (opponentY < aiBallY) - { - if (opponentY < 0.9) - opponentY += speedFactor; - } - else + if (opponentY != aiBallY) { - if (opponentY > -0.9) - opponentY -= speedFactor; + if (opponentY < aiBallY) + { + if (opponentY < 0.9) + opponentY += speedFactor; + } + else + { + if (opponentY > -0.9) + opponentY -= speedFactor; + } } } } @@ -185,6 +208,13 @@ namespace ShiftOS.WinForms.Applications InitializeCoordinates(); } + public void LevelComplete() + { + level++; + speedFactor += speedFactor / level; + secondsleft = 60; + } + public long CalculateAIBeatCP() { return 2 * (10 * level); @@ -192,7 +222,24 @@ namespace ShiftOS.WinForms.Applications public void Win() { + header = "You beat the AI! " + CalculateAIBeatCP() + " Codepoints!."; InitializeCoordinates(); + new System.Threading.Thread(() => + { + doBallCalc = false; + counter = "3"; + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + System.Threading.Thread.Sleep(1000); + counter = "2"; + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + System.Threading.Thread.Sleep(1000); + counter = "1"; + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + System.Threading.Thread.Sleep(1000); + doBallCalc = true; + header = ""; + counter = ""; + }).Start(); } public void InitializeCoordinates() @@ -221,6 +268,7 @@ namespace ShiftOS.WinForms.Applications e.Graphics.Clear(pnlcanvas.BackColor); //draw the ball + if(doBallCalc) e.Graphics.FillEllipse(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)ballXLocal, (float)ballYLocal, (float)paddleWidth, (float)paddleWidth)); double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); @@ -245,6 +293,30 @@ namespace ShiftOS.WinForms.Applications ); e.Graphics.DrawString(cp_text, SkinEngine.LoadedSkin.Header3Font, new SolidBrush(pnlcanvas.ForeColor), tLoc); + tSize = e.Graphics.MeasureString(counter, SkinEngine.LoadedSkin.Header2Font); + + tLoc = new PointF((pnlcanvas.Width - (int)tSize.Width) / 2, + (pnlcanvas.Height - (int)tSize.Height) / 2 + + ); + e.Graphics.DrawString(counter, SkinEngine.LoadedSkin.Header2Font, new SolidBrush(pnlcanvas.ForeColor), tLoc); + tSize = e.Graphics.MeasureString(header, SkinEngine.LoadedSkin.Header2Font); + + tLoc = new PointF((pnlcanvas.Width - (int)tSize.Width) / 2, + (pnlcanvas.Height - (int)tSize.Height) / 4 + + ); + e.Graphics.DrawString(header, SkinEngine.LoadedSkin.Header2Font, new SolidBrush(pnlcanvas.ForeColor), tLoc); + + string l = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); + tSize = e.Graphics.MeasureString(l, SkinEngine.LoadedSkin.Header3Font); + + tLoc = new PointF((pnlcanvas.Width - (int)tSize.Width) / 2, + (tSize.Height) + ); + e.Graphics.DrawString(l, SkinEngine.LoadedSkin.Header3Font, new SolidBrush(pnlcanvas.ForeColor), tLoc); + + } static public double linear(double x, double x0, double x1, double y0, double y1) @@ -261,6 +333,7 @@ namespace ShiftOS.WinForms.Applications public void OnLoad() { drawTimer.Start(); + counterTimer.Start(); } public void OnSkinLoad() @@ -270,6 +343,7 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { drawTimer.Stop(); + counterTimer.Stop(); return true; } -- cgit v1.2.3 From be544f77de3c1e63627477467887a6895e1e703a Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Jun 2017 21:01:36 -0400 Subject: UI changes --- ShiftOS.WinForms/Applications/Pong.Designer.cs | 147 +++++++++++++++++++++++++ ShiftOS.WinForms/Applications/Pong.cs | 51 ++++++++- ShiftOS.WinForms/Applications/Pong.resx | 7 ++ 3 files changed, 201 insertions(+), 4 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index 22ad6f6..aee599b 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -28,7 +28,23 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Pong)); this.pnlcanvas = new System.Windows.Forms.Panel(); + this.pnllevelwon = new System.Windows.Forms.Panel(); + this.lbltitle = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btncashout = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.pnlgamestart = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.button2 = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.pnllevelwon.SuspendLayout(); + this.panel1.SuspendLayout(); + this.pnlgamestart.SuspendLayout(); + this.panel3.SuspendLayout(); this.SuspendLayout(); // // pnlcanvas @@ -41,13 +57,133 @@ this.pnlcanvas.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlcanvas_Paint); this.pnlcanvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pnlcanvas_MouseMove); // + // pnllevelwon + // + this.pnllevelwon.Controls.Add(this.label1); + this.pnllevelwon.Controls.Add(this.panel1); + this.pnllevelwon.Controls.Add(this.lbltitle); + this.pnllevelwon.Location = new System.Drawing.Point(57, 75); + this.pnllevelwon.Name = "pnllevelwon"; + this.pnllevelwon.Size = new System.Drawing.Size(301, 184); + this.pnllevelwon.TabIndex = 0; + this.pnllevelwon.Visible = false; + // + // lbltitle + // + this.lbltitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbltitle.Location = new System.Drawing.Point(0, 0); + this.lbltitle.Name = "lbltitle"; + this.lbltitle.Size = new System.Drawing.Size(301, 13); + this.lbltitle.TabIndex = 0; + this.lbltitle.Tag = "header2"; + this.lbltitle.Text = "You\'ve reached level 2!"; + this.lbltitle.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Location = new System.Drawing.Point(0, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(301, 139); + this.label1.TabIndex = 1; + this.label1.Text = "You have survived this level of Pong. You now have a chance to cash out your Code" + + "points or play on for more."; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel1 + // + this.panel1.Controls.Add(this.button1); + this.panel1.Controls.Add(this.btncashout); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 152); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(301, 32); + this.panel1.TabIndex = 2; + // + // btncashout + // + this.btncashout.Location = new System.Drawing.Point(48, 6); + this.btncashout.Name = "btncashout"; + this.btncashout.Size = new System.Drawing.Size(93, 23); + this.btncashout.TabIndex = 0; + this.btncashout.Text = "Cash out"; + this.btncashout.UseVisualStyleBackColor = true; + this.btncashout.Click += new System.EventHandler(this.btncashout_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(159, 6); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(93, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Play on"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // pnlgamestart + // + this.pnlgamestart.Controls.Add(this.label2); + this.pnlgamestart.Controls.Add(this.panel3); + this.pnlgamestart.Controls.Add(this.label3); + this.pnlgamestart.Location = new System.Drawing.Point(289, 133); + this.pnlgamestart.Name = "pnlgamestart"; + this.pnlgamestart.Size = new System.Drawing.Size(301, 280); + this.pnlgamestart.TabIndex = 1; + this.pnlgamestart.Visible = false; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Fill; + this.label2.Location = new System.Drawing.Point(0, 42); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(301, 206); + this.label2.TabIndex = 1; + this.label2.Text = resources.GetString("label2.Text"); + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel3 + // + this.panel3.Controls.Add(this.button2); + this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel3.Location = new System.Drawing.Point(0, 248); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(301, 32); + this.panel3.TabIndex = 2; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(100, 6); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(116, 23); + this.button2.TabIndex = 1; + this.button2.Text = "Play some Pong!"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label3 + // + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + this.label3.Location = new System.Drawing.Point(0, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(301, 42); + this.label3.TabIndex = 0; + this.label3.Tag = "header2"; + this.label3.Text = "Welcome to Pong."; + this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // // Pong // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.pnlgamestart); + this.Controls.Add(this.pnllevelwon); this.Controls.Add(this.pnlcanvas); this.Name = "Pong"; this.Size = new System.Drawing.Size(879, 450); + this.pnllevelwon.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.pnlgamestart.ResumeLayout(false); + this.panel3.ResumeLayout(false); this.ResumeLayout(false); } @@ -55,5 +191,16 @@ #endregion private System.Windows.Forms.Panel pnlcanvas; + private System.Windows.Forms.Panel pnllevelwon; + private System.Windows.Forms.Label lbltitle; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button btncashout; + private System.Windows.Forms.Panel pnlgamestart; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Label label3; } } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 079c880..f776ebb 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { @@ -69,7 +70,7 @@ namespace ShiftOS.WinForms.Applications bool doAi = true; bool doBallCalc = true; - private string header = "Pong - Technology Demo"; + private string header = ""; private string counter = ""; @@ -157,8 +158,7 @@ namespace ShiftOS.WinForms.Applications //Player paddle: if (ballRect.IntersectsWith(playerRect)) { - //check if the ball x is greater than the player paddle's middle coordinate - if (ballRect.Left >= playerRect.Left) + if (ballRect.Left <= playerRect.Right) { //reverse x velocity to send the ball the other way xVel = -xVel; @@ -211,6 +211,15 @@ namespace ShiftOS.WinForms.Applications public void LevelComplete() { level++; + doAi = false; + doBallCalc = false; + counterTimer.Stop(); + pnllevelwon.CenterParent(); + pnllevelwon.Show(); + pnllevelwon.BringToFront(); + lbltitle.Text = "You've reached level " + level + "!"; + lbltitle.Height = (int)CreateGraphics().MeasureString(lbltitle.Text, lbltitle.Font).Height; + codepointsToEarn += CalculateAIBeatCP() * 2; speedFactor += speedFactor / level; secondsleft = 60; } @@ -332,8 +341,12 @@ namespace ShiftOS.WinForms.Applications public void OnLoad() { + doAi = false; + doBallCalc = false; + pnlgamestart.Show(); + pnlgamestart.BringToFront(); + pnlgamestart.CenterParent(); drawTimer.Start(); - counterTimer.Start(); } public void OnSkinLoad() @@ -355,5 +368,35 @@ namespace ShiftOS.WinForms.Applications { playerY = linear(e.Y, 0, pnlcanvas.Height, -1, 1); } + + private void button1_Click(object sender, EventArgs e) + { + pnllevelwon.Hide(); + doAi = true; + doBallCalc = true; + counterTimer.Start(); + } + + private void btncashout_Click(object sender, EventArgs e) + { + pnllevelwon.Hide(); + SaveSystem.CurrentSave.Codepoints += (ulong)codepointsToEarn; + level = 1; + speedFactor = 0.0125; + Infobox.Show("Codepoints transferred.", "Pong has transferred " + codepointsToEarn + " Codepoints to your system."); + codepointsToEarn = 0; + pnlgamestart.Show(); + pnlgamestart.BringToFront(); + pnlgamestart.CenterParent(); + + } + + private void button2_Click(object sender, EventArgs e) + { + counterTimer.Start(); + doAi = true; + doBallCalc = true; + pnlgamestart.Hide(); + } } } diff --git a/ShiftOS.WinForms/Applications/Pong.resx b/ShiftOS.WinForms/Applications/Pong.resx index 1af7de1..685deff 100644 --- a/ShiftOS.WinForms/Applications/Pong.resx +++ b/ShiftOS.WinForms/Applications/Pong.resx @@ -117,4 +117,11 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Pong is the modern-day recreation of the classic 70s game called, you guessed it, Pong. + +In Pong, you must try your best to keep the fast-moving ball from going past your side of the screen using your mouse to move your paddle in the way of the ball, while getting the ball to go past the opponent's paddle. + +Once you start Pong, you have 60 seconds to beat the opponent and survive as much as possible. The game will get faster as you play, and the more 60-second levels you play, the more Codepoints you'll earn. If you lose the level, you will start back at Level 1 with 0 Codepoints. At the end of the level, you may choose to cash out or play on. + \ No newline at end of file -- cgit v1.2.3 From eb4b032b355e7a1477a73fae9ba7a379314c4c4b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Jun 2017 12:06:49 -0400 Subject: fix losing system --- ShiftOS.WinForms/Applications/Pong.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index f776ebb..87b7a93 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -206,6 +206,16 @@ namespace ShiftOS.WinForms.Applications public void Lose() { InitializeCoordinates(); + counterTimer.Stop(); + secondsleft = 60; + level = 1; + speedFactor = 0.0125; + pnlgamestart.Show(); + pnlgamestart.BringToFront(); + pnlgamestart.CenterParent(); + Infobox.Show("You lose.", "You lost the game! Guess you should've cashed out..."); + doAi = false; + doBallCalc = false; } public void LevelComplete() @@ -255,8 +265,6 @@ namespace ShiftOS.WinForms.Applications { ballX = 0; ballY = 0; - xVel = 1; - yVel = 1; opponentY = 0; aiBallX = 0; aiBallY = 0; -- cgit v1.2.3 From 79fe2101aef62b744b150203dee6953b0d17f5aa Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Jun 2017 20:36:43 -0400 Subject: Get rid of namespaces in commands. --- ModLauncher/Program.cs | 11 - ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb | 1 - ShiftOS.Modding.VirtualMachine/Form1.cs | 1 - .../Applications/CoherenceOverlay.Designer.cs | 61 -- ShiftOS.WinForms/Applications/CoherenceOverlay.cs | 123 ---- ShiftOS.WinForms/Applications/Downloader.cs | 1 - ShiftOS.WinForms/Applications/Pong.cs | 25 +- ShiftOS.WinForms/Commands.cs | 299 --------- ShiftOS.WinForms/HackerCommands.cs | 723 +-------------------- ShiftOS.WinForms/OobeStory.cs | 1 - ShiftOS.WinForms/Servers/RemoteTerminalServer.cs | 1 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 6 - ShiftOS.WinForms/SkinCommands.cs | 1 - ShiftOS.WinForms/TestCommandsForUpgrades.cs | 22 +- ShiftOS.WinForms/TrailerCommands.cs | 48 -- ShiftOS.WinForms/WinformsDesktop.cs | 1 - ShiftOS_TheReturn/Command.cs | 36 - ShiftOS_TheReturn/Commands.cs | 274 +------- ShiftOS_TheReturn/PythonAPI.cs | 1 - ShiftOS_TheReturn/ReflectMan.cs | 1 - ShiftOS_TheReturn/TerminalBackend.cs | 66 +- ShiftOS_TheReturn/UserManagementCommands.cs | 2 - 22 files changed, 66 insertions(+), 1639 deletions(-) delete mode 100644 ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/CoherenceOverlay.cs (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ModLauncher/Program.cs b/ModLauncher/Program.cs index 4b99cf5..4637b4e 100644 --- a/ModLauncher/Program.cs +++ b/ModLauncher/Program.cs @@ -32,7 +32,6 @@ using ShiftOS.Engine; namespace ModLauncher { - [Namespace("modlauncher")] public static class Program { /// @@ -43,15 +42,5 @@ namespace ModLauncher { ShiftOS.WinForms.Program.Main(); } - - [Command("throwcrash")] - public static bool ThrowCrash() - { - new Thread(() => - { - throw new Exception("User triggered crash using modlauncher.throwcrash command."); - }).Start(); - return true; - } } } diff --git a/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb b/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb index 161012d..3a2e106 100644 --- a/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb +++ b/ShiftOS.Modding.VB.LegacySkinConverter/Module1.vb @@ -14,7 +14,6 @@ Module Module1 End Module - Public Class SkinConverterCommands diff --git a/ShiftOS.Modding.VirtualMachine/Form1.cs b/ShiftOS.Modding.VirtualMachine/Form1.cs index 5b6b047..1615091 100644 --- a/ShiftOS.Modding.VirtualMachine/Form1.cs +++ b/ShiftOS.Modding.VirtualMachine/Form1.cs @@ -154,7 +154,6 @@ namespace ShiftOS.Modding.VirtualMachine } } - [Namespace("svm")] public static class Compiler { public static byte[] Compile(string prg) diff --git a/ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs b/ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs deleted file mode 100644 index 0764059..0000000 --- a/ShiftOS.WinForms/Applications/CoherenceOverlay.Designer.cs +++ /dev/null @@ -1,61 +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. - */ - -namespace ShiftOS.WinForms.Applications -{ - partial class CoherenceOverlay - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - } - - #endregion - } -} diff --git a/ShiftOS.WinForms/Applications/CoherenceOverlay.cs b/ShiftOS.WinForms/Applications/CoherenceOverlay.cs deleted file mode 100644 index 1bfc8e8..0000000 --- a/ShiftOS.WinForms/Applications/CoherenceOverlay.cs +++ /dev/null @@ -1,123 +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.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; - -namespace ShiftOS.WinForms.Applications -{ - public partial class CoherenceOverlay : UserControl, IShiftOSWindow - { - public CoherenceOverlay(IntPtr handle, CoherenceCommands.RECT rect) - { - InitializeComponent(); - this.Load += (o, a) => - { - try - { - int left = this.ParentForm.Left; - int top = this.ParentForm.Top; - int oldwidth = this.ParentForm.Width; - int oldheight = this.ParentForm.Height; - - var t = new Thread(new ThreadStart(() => - { - while (CoherenceCommands.GetWindowRect(handle, ref rect)) - { - - if (left != rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth) - { - this.Invoke(new Action(() => - { - this.ParentForm.Left = rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth; - left = rect.Left - SkinEngine.LoadedSkin.LeftBorderWidth; - })); - } - if (top != rect.Top - SkinEngine.LoadedSkin.TitlebarHeight) - { - this.Invoke(new Action(() => - { - - this.ParentForm.Top = rect.Top - SkinEngine.LoadedSkin.TitlebarHeight; - top = rect.Top - SkinEngine.LoadedSkin.TitlebarHeight; - })); - } - int width = (rect.Right - rect.Left) + 1; - int height = (rect.Bottom - rect.Top) + 1; - - if (oldheight != SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth) - { - this.Invoke(new Action(() => - { - this.ParentForm.Height = SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth; - oldheight = SkinEngine.LoadedSkin.TitlebarHeight + height + SkinEngine.LoadedSkin.BottomBorderWidth; - })); - } - if (oldwidth != SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth) - { - this.Invoke(new Action(() => - { - this.ParentForm.Width = SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth; - oldwidth = SkinEngine.LoadedSkin.LeftBorderWidth + width + SkinEngine.LoadedSkin.RightBorderWidth; - })); - } - } - })); - t.IsBackground = true; - t.Start(); - } - catch - { - - } - }; - } - - public void OnLoad() - { - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - } -} diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs index b3d2cea..bcad56a 100644 --- a/ShiftOS.WinForms/Applications/Downloader.cs +++ b/ShiftOS.WinForms/Applications/Downloader.cs @@ -216,7 +216,6 @@ namespace ShiftOS.WinForms.Applications public int Progress { get; set; } } - [Namespace("dev")] public static class DownloaderDebugCommands { [Command("setsubscription", description ="Use to set the current shiftnet subscription.", usage ="{value:int32}")] diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 87b7a93..3f06676 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -42,6 +42,15 @@ namespace ShiftOS.WinForms.Applications LevelComplete(); } }; +#if DEBUG + this.KeyDown += (o, a) => + { + if(a.KeyCode == Keys.D) + { + drawAiBall = !drawAiBall; + } + }; +#endif } private double ballX = 0.0f; @@ -266,11 +275,14 @@ namespace ShiftOS.WinForms.Applications ballX = 0; ballY = 0; opponentY = 0; + xVel = 1; aiBallX = 0; aiBallY = 0; doAi = true; } + private bool drawAiBall = false; + private void pnlcanvas_Paint(object sender, PaintEventArgs e) { @@ -281,11 +293,22 @@ namespace ShiftOS.WinForms.Applications ballXLocal -= ((double)paddleWidth / 2); ballYLocal -= ((double)paddleWidth / 2); + double aiballXLocal = linear(aiBallX, -1.0, 1.0, 0, pnlcanvas.Width); + double aiballYLocal = linear(aiBallY, -1.0, 1.0, 0, pnlcanvas.Height); + + aiballXLocal -= ((double)paddleWidth / 2); + aiballYLocal -= ((double)paddleWidth / 2); + e.Graphics.Clear(pnlcanvas.BackColor); + //draw the ai ball + if (drawAiBall) + e.Graphics.FillEllipse(new SolidBrush(Color.Gray), new RectangleF((float)aiballXLocal, (float)aiballYLocal, (float)paddleWidth, (float)paddleWidth)); + + //draw the ball - if(doBallCalc) + if (doBallCalc) e.Graphics.FillEllipse(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)ballXLocal, (float)ballYLocal, (float)paddleWidth, (float)paddleWidth)); double playerYLocal = linear(playerY, -1.0, 1.0, 0, pnlcanvas.Height); diff --git a/ShiftOS.WinForms/Commands.cs b/ShiftOS.WinForms/Commands.cs index b04ffe7..e69de29 100644 --- a/ShiftOS.WinForms/Commands.cs +++ b/ShiftOS.WinForms/Commands.cs @@ -1,299 +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.Engine; -using System.IO; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Threading; -using Newtonsoft.Json; - -/// -/// Coherence commands. -/// -namespace ShiftOS.WinForms -{ - [Namespace("trm")] - public static class TerminalExtensions - { - [Command("exit")] - public static bool StopRemoting() - { - if(TerminalBackend.IsForwardingConsoleWrites == true) - { - ServerManager.SendMessage("trm_handshake_stop", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"" -}}"); - Console.WriteLine("Goodbye!"); - } - else - { - return false; - } - - return true; - } - - - [Command("setpass", true)] - [RequiresArgument("pass")] - public static bool setPass(Dictionary args) - { - SaveSystem.CurrentSave.Password = args["pass"] as string; - return true; - } - - [Command("remote", "username:,sysname:,password:", "Allows you to control a remote system on the multi-user domain given a username, password and system name.")] - [RequiresArgument("username")] - [RequiresArgument("sysname")] - [RequiresArgument("password")] - public static bool RemoteControl(Dictionary args) - { - ServerManager.SendMessage("trm_handshake_request", JsonConvert.SerializeObject(args)); - return true; - } - } - - [Namespace("coherence")] - [RequiresUpgrade("kernel_coherence")] - public static class CoherenceCommands - { - /// - /// Sets the window position. - /// - /// The window position. - /// H window. - /// H window insert after. - /// X. - /// Y. - /// Cx. - /// Cy. - /// U flags. - [DllImport("user32.dll")] - static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); - - /// - /// The HWN d TOPMOS. - /// - static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); - - /// - /// The SW p SHOWWINDO. - /// - const UInt32 SWP_SHOWWINDOW = 0x0040; - - - [DllImport("user32.dll")] - /// - /// Gets the window rect. - /// - /// The window rect. - /// H window. - /// Lp rect. - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect); - - /// - /// REC. - /// - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int Left; // x position of upper-left corner - public int Top; // y position of upper-left corner - public int Right; // x position of lower-right corner - public int Bottom; // y position of lower-right corner - } - - [Command("launch", "process: \"C:\\path\\to\\process\" - The process path to launch.", "Launch a process inside kernel coherence.")] - [RequiresArgument("process")] - /// - /// Launchs the app. - /// - /// The app. - /// Arguments. - public static bool LaunchApp(Dictionary args) - { - string process = args["process"].ToString(); - var prc = Process.Start(process); - StartCoherence(prc); - return true; - } - - /// - /// Starts the coherence. - /// - /// The coherence. - /// Prc. - private static void StartCoherence(Process prc) - { - RECT rct = new RECT(); - - - while (!GetWindowRect(prc.MainWindowHandle, ref rct)) - { - } - - - - AppearanceManager.Invoke(new Action(() => - { - IShiftOSWindow coherenceWindow = new Applications.CoherenceOverlay(prc.MainWindowHandle, rct); - - AppearanceManager.SetupWindow(coherenceWindow); - SetWindowPos(prc.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - - //MakeExternalWindowBorderless(prc.MainWindowHandle); - })); - - } - - /// - /// The W s BORDE. - /// - const int WS_BORDER = 8388608; - - /// - /// The W s DLGFRAM. - /// - const int WS_DLGFRAME = 4194304; - - /// - /// The W s CAPTIO. - /// - const int WS_CAPTION = WS_BORDER | WS_DLGFRAME; - - /// - /// The W s SYSMEN. - /// - const int WS_SYSMENU = 524288; - - /// - /// The W s THICKFRAM. - /// - const int WS_THICKFRAME = 262144; - - /// - /// The W s MINIMIZ. - /// - const int WS_MINIMIZE = 536870912; - - /// - /// The W s MAXIMIZEBO. - /// - const int WS_MAXIMIZEBOX = 65536; - - /// - /// The GW l STYL. - /// - const int GWL_STYLE = -16; - - /// - /// The GW l EXSTYL. - /// - const int GWL_EXSTYLE = -20; - - /// - /// The W s E x DLGMODALFRAM. - /// - const int WS_EX_DLGMODALFRAME = 0x1; - - /// - /// The SW p NOMOV. - /// - const int SWP_NOMOVE = 0x2; - - /// - /// The SW p NOSIZ. - /// - const int SWP_NOSIZE = 0x1; - - /// - /// The SW p FRAMECHANGE. - /// - const int SWP_FRAMECHANGED = 0x20; - - /// - /// The M f BYPOSITIO. - /// - const uint MF_BYPOSITION = 0x400; - - /// - /// The M f REMOV. - /// - const uint MF_REMOVE = 0x1000; - - /// - /// Gets the window long. - /// - /// The window long. - /// H window. - /// N index. - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] - public static extern int GetWindowLong(IntPtr hWnd, int nIndex); - - /// - /// Sets the window long. - /// - /// The window long. - /// H window. - /// N index. - /// Dw new long. - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] - public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); - - /// - /// Sets the window position. - /// - /// The window position. - /// H window. - /// H window insert after. - /// X. - /// Y. - /// Cx. - /// Cy. - /// U flags. - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); - public static void MakeExternalWindowBorderless(IntPtr MainWindowHandle) - { - int Style = 0; - Style = GetWindowLong(MainWindowHandle, GWL_STYLE); - Style = Style & ~WS_CAPTION; - Style = Style & ~WS_SYSMENU; - Style = Style & ~WS_THICKFRAME; - Style = Style & ~WS_MINIMIZE; - Style = Style & ~WS_MAXIMIZEBOX; - SetWindowLong(MainWindowHandle, GWL_STYLE, Style); - Style = GetWindowLong(MainWindowHandle, GWL_EXSTYLE); - SetWindowLong(MainWindowHandle, GWL_EXSTYLE, Style | WS_EX_DLGMODALFRAME); - SetWindowPos(MainWindowHandle, new IntPtr(0), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - } - } -} diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index dd8bde8..5f28270 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -1,722 +1 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.Objects; -using ShiftOS.Objects.ShiftFS; -using ShiftOS.WinForms.Applications; -using static ShiftOS.Objects.ShiftFS.Utils; - -namespace ShiftOS.WinForms -{ - [Namespace("puppy")] - [RequiresUpgrade("hacker101_deadaccts")] - [KernelMode] - public static class KernelPuppyCommands - { - [Command("clear", true)] - public static bool ClearLogs() - { - WriteAllText("0:/system/data/kernel.log", ""); - Console.WriteLine(" logs cleared successfully."); - return true; - } - } - - [Namespace("krnl")] - public static class KernelCommands - { - [Command("control", true)] - [RequiresArgument("pass")] - public static bool Control(Dictionary args) - { - if(args["pass"].ToString() == ServerManager.thisGuid.ToString()) - { - KernelWatchdog.Log("warn", "User has breached the kernel."); - KernelWatchdog.EnterKernelMode(); - TerminalBackend.PrintPrompt(); - } - return true; - } - - [Command("lock_session")] - [KernelMode] - public static bool LeaveControl() - { - KernelWatchdog.Log("inf", "User has left the kernel-mode session."); - KernelWatchdog.LeaveKernelMode(); - KernelWatchdog.MudConnected = true; - return true; - } - } - - [Namespace("hacker101")] - [RequiresUpgrade("hacker101_deadaccts")] - public static class HackerCommands - { - private static void writeSlow(string text) - { - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - ConsoleEx.Bold = false; - ConsoleEx.Italic = false; - Console.Write("["); - ConsoleEx.ForegroundColor = ConsoleColor.Magenta; - ConsoleEx.Bold = true; - Console.Write("hacker101"); - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - ConsoleEx.Italic = true; - Console.Write("@"); - ConsoleEx.ForegroundColor = ConsoleColor.White; - Console.Write("undisclosed"); - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - ConsoleEx.Bold = false; - ConsoleEx.Italic = false; - Console.Write("]: "); - Thread.Sleep(850); - Console.WriteLine(text); - Thread.Sleep(4000); - } - - [Story("hacker101_deadaccts")] - public static void DeadAccountsStory() - { - if (!terminalIsOpen()) - { - AppearanceManager.SetupWindow(new Terminal()); - } - - var t = new Thread(() => - { - Console.WriteLine("[sys@mud]: Warning: User connecting to system..."); - Thread.Sleep(75); - Console.WriteLine("[sys@mud]: UBROADCAST: Username: hacker101 - Sysname: undisclosed"); - Thread.Sleep(50); - Console.Write("--locking mud connection resources..."); - Thread.Sleep(50); - Console.WriteLine("...done."); - Console.Write("--locking user input... "); - Thread.Sleep(75); - TerminalBackend.PrefixEnabled = false; - TerminalBackend.InStory = true; - Console.WriteLine("...done."); - - Thread.Sleep(2000); - writeSlow($"Hello there, fellow multi-user domain user."); - writeSlow("My name, as you can tell, is hacker101."); - writeSlow("And yours must be... don't say it... it's " + SaveSystem.CurrentUser.Username + "@" + SaveSystem.CurrentSave.SystemName + ", right?"); - writeSlow("Of course it is."); - writeSlow("And I bet you 10,000 Codepoints that you have... " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints."); - writeSlow("Oh, and how much upgrades have you installed since you first started using ShiftOS?"); - writeSlow("That would be... uhh... " + SaveSystem.CurrentSave.CountUpgrades().ToString() + "."); - writeSlow("I'm probably freaking you out right now. You are probably thinking that you're unsafe and need to lock yourself down."); - writeSlow("But, don't worry, I mean no harm."); - writeSlow("In fact, I am a multi-user domain safety activist and security professional."); - writeSlow("I need your help with something."); - writeSlow("Inside the multi-user domain, every now and then these 'dead' user accounts pop up."); - writeSlow("They're infesting everything. They're in every legion, they infest chatrooms, and they take up precious hard drive space."); - writeSlow("Eventually there's going to be tons of them just sitting there taking over the MUD. We can't have that."); - writeSlow("It sounds like a conspiracy theory indeed, but it's true, in fact, these dead accounts hold some valuable treasures."); - writeSlow("I'm talking Codepoints, skins, documents, the possibilities are endless."); - writeSlow("I'm going to execute a quick sys-script that will show you how you can help get rid of these accounts, and also gain some valuable resources to help you on your digital frontier."); - writeSlow("This script will also show you the fundamentals of security exploitation and theft of resources - which if you want to survive in the multi-user domain is paramount."); - writeSlow("Good luck."); - Thread.Sleep(1000); - Console.WriteLine("--user disconnected"); - Thread.Sleep(75); - Console.WriteLine("--commands unlocked - check sos.help."); - Thread.Sleep(45); - SaveSystem.SaveGame(); - Console.Write("--unlocking user input..."); - Thread.Sleep(75); - Console.Write(" ..done"); - TerminalBackend.InStory = false; - TerminalBackend.PrefixEnabled = true; - Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - StartHackerTutorial(); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - }); - t.IsBackground = true; - t.Start(); - TerminalBackend.PrefixEnabled = false; - } - - internal static void StartHackerTutorial() - { - Desktop.InvokeOnWorkerThread(() => - { - var tut = new TutorialBox(); - AppearanceManager.SetupWindow(tut); - - new Thread(() => - { - - - int tutPos = 0; - Action ondec = () => - { - tutPos++; - }; - TerminalBackend.CommandProcessed += (o, a) => - { - switch (tutPos) - { - - case 0: - case 10: - if (o.ToLower().StartsWith("mud.disconnect")) - { - tutPos++; - } - break; - case 11: - if (o.ToLower().StartsWith("krnl.lock_session")) - tutPos++; - break; - case 1: - if (o.ToLower().StartsWith("hacker101.brute_decrypt")) - { - if (a.Contains("0:/system/data/kernel.log")) - { - tutPos++; - } - } - break; - case 3: - if (o.ToLower().StartsWith("krnl.control")) - { - tutPos++; - } - break; - case 4: - if (o.ToLower().StartsWith("puppy.clear")) - tutPos++; - break; - case 5: - if (o.ToLower().StartsWith("mud.reconnect")) - tutPos++; - break; - case 6: - if (o.ToLower().StartsWith("mud.sendmsg")) - { - var msg = JsonConvert.DeserializeObject(a); - try - { - if (msg.header == "getusers" && msg.body == "dead") - tutPos++; - } - catch - { - - } - } - break; - case 7: - if (o.ToLower().StartsWith("hacker101.breach_user_password")) - tutPos++; - break; - case 8: - if (o.ToLower().StartsWith("hacker101.print_user_info")) - tutPos++; - break; - case 9: - if (o.ToLower().StartsWith("hacker101.steal_codepoints")) - tutPos++; - break; - } - }; - tut.SetObjective("Welcome to the dead account exploitation tutorial. In this tutorial you will learn the basics of hacking within the multi-user domain."); - Thread.Sleep(1000); - tut.SetObjective("We will start with a simple system exploit - gaining kernel-level access to ShiftOS. This can help you perform actions not ever possible in the user level."); - Thread.Sleep(1000); - tut.SetObjective("To gain root access, you will first need to breach the system watchdog to keep it from dialing home to DevX."); - Thread.Sleep(1000); - tut.SetObjective("The watchdog can only function when it has a successful connection to the multi-user domain. You will need to use the MUD Control Centre to disconnect yourself from the MUD. This will lock you out of most features. To disconnect from the multi-user domain, simply run the 'mud.disconnect' command."); - while(tutPos == 0) - { - - } - tut.SetObjective("As you can see, the kernel watchdog has shut down temporarily, however before the disconnect it was able to tell DevX that it has gone offline."); - Thread.Sleep(1000); - tut.SetObjective("You'll also notice that commands like the shiftorium, MUD control centre and various applications that utilize these system components no longer function."); - Thread.Sleep(1000); - tut.SetObjective("The watchdog, however, is still watching. DevX was smart and programmed the kernel to log all events to a local file in 0:/system/data/kernel.log."); - Thread.Sleep(1000); - tut.SetObjective("You will need to empty out this file before you can connect to the multi-user domain, as the watchdog will send the contents of this file straight to DevX."); - Thread.Sleep(1000); - tut.SetObjective("Or, you can do what we're about to do and attempt to decrypt the log and sniff out the kernel-mode access password."); - Thread.Sleep(1000); - tut.SetObjective("This will allow us to gain kernel-level access to our system using the krnl.control{pass:} command."); - Thread.Sleep(1000); - tut.SetObjective("Let's start decrypting the log file using the hacker101.brute_decrypt{file:} script. The file: argument is a string and should point to a .log file. When the script succeeds, you will see a TextPad open with the decrypted contents."); - while(tutPos == 1) - { - - } - onCompleteDecrypt += ondec; - tut.SetObjective("This script isn't the most agile script ever, but it'll get the job done."); - tutPos = 3; // For some reason, it refuses to go to part 3. - while(tutPos == 2) - { - - } - onCompleteDecrypt -= ondec; - tut.SetObjective("Alright - it's done. Here's how it's laid out. In each log entry, you have the timestamp, then the event name, then the event description."); - Thread.Sleep(1000); - tut.SetObjective("Look for the most recent 'mudhandshake' event. This contains the kernel access code."); - Thread.Sleep(1000); - tut.SetObjective("Once you have it, run 'krnl.control{pass:\"the-kernel-code-here\"}. This will allow you to gain access to the kernel."); - while(tutPos == 3) - { - - } - tut.SetObjective("You are now in kernel mode. Every command you enter will run on the kernel. Now, let's clear the watchdog's logfile and reconnect to the multi-user domain."); - Thread.Sleep(1000); - tut.SetObjective("To clear the log, simply run 'puppy.clear'."); - while(tutPos == 4) - { - - } - tut.SetObjective("Who's a good dog... You are, ShiftOS. Now, we can connect back to the MUD using 'mud.reconnect'."); - Thread.Sleep(1000); - while(tutPos == 5) - { - - } - tut.SetObjective("We have now snuck by the watchdog and DevX has no idea. With kernel-level access, everything you do is not logged, however if you perform too much in one shot, you'll get kicked off and locked out of the multi-user domain temporarily."); - Thread.Sleep(1000); - tut.SetObjective("So, let's focus on the job. You want to get into one of those fancy dead accounts, don't ya? Well, first, we need to talk with the MUD to get a list of these accounts."); - Thread.Sleep(1000); - tut.SetObjective("Simply run the `mud.sendmsg` command, specifying a 'header' of \"getusers\", and a body of \"dead\"."); - while(tutPos == 6) - { - - } - tut.SetObjective("Great. We now have the usernames and sysnames of all dead accounts on the MUD. Now let's use the hacker101.breach_user_password{user:,sys:} command to breach one of these accounts' passwords."); - while(tutPos == 7) - { - - } - tut.SetObjective("There - you now have access to that account. Use its password, username and sysname and run the hacker101.print_user_info{user:,pass:,sys:} command to print the entirety of this user's information."); - while(tutPos == 8) - { - - } - tut.SetObjective("Now you can see a list of the user's Codepoints among other things. Now you can steal their codepoints by using the hacker101.steal_codepoints{user:,pass:,sys;,amount:} command. Be careful. This may alert DevX."); - while(tutPos == 9) - { - - } - if(devx_alerted == true) - { - tut.SetObjective("Alright... enough fun and games. DevX just found out we were doing this."); - Thread.Sleep(500); - tut.SetObjective("Quick! Disconnect from the MUD!!"); - while(tutPos == 10) - { - - } - tut.SetObjective("Now, get out of kernel mode! To do that, run krnl.lock_session."); - while(tutPos == 11) - { - - } - - } - else - { - tut.SetObjective("OK, that was risky, but we pulled it off. Treat yourself! But first, let's get you out of kernel mode."); - Thread.Sleep(500); - tut.SetObjective("First we need to get you off the MUD. Simply run mud.disconnect again."); - while (tutPos == 10) - { - - } - tut.SetObjective("Now, let's run krnl.lock_session. This will lock you back into the user mode, and reconnect you to the MUD."); - while (tutPos == 11) - { - - } - tut.SetObjective("If, for some reason, DevX DOES find out, you have to be QUICK to get off of kernel mode. You don't want to make him mad."); - } - - Thread.Sleep(1000); - tut.SetObjective("So that's all for now. Whenever you're in kernel mode again, and you have access to a user account, try breaching their filesystem next time. You can use sos.help{ns:} to show commands from a specific namespace to help you find more commands easily."); - Thread.Sleep(1000); - tut.SetObjective("You can now close this window."); - tut.IsComplete = true; - - }).Start(); - }); - } - - private static bool devx_alerted = false; - - private static event Action onCompleteDecrypt; - - private static bool terminalIsOpen() - { - foreach(var win in AppearanceManager.OpenForms) - { - if (win.ParentWindow is Terminal) - return true; - } - return false; - } - - const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_"; - - [MultiplayerOnly] - [Command("breach_user_password")] - [KernelMode] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool BreachUserPassword(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking system thread..."); - - msgReceived = (msg) => - { - if(msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - var rnd = new Random(); - var sw = new Stopwatch(); - sw.Start(); - Thread.Sleep(2000); - if(rnd.Next(0, 100) >= 75) - { - Console.WriteLine("--operation took too long - failed."); - ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrefixEnabled = true; - return; - } - sw.Stop(); - Console.WriteLine(sve.Password); - Console.WriteLine(); - Console.WriteLine("--password breached. Operation took " + sw.ElapsedMilliseconds + " milliseconds."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - else if(msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--beginning brute-force attack on " + usr + "@" + sys + "..."); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - TerminalBackend.PrefixEnabled = false; - Thread.Sleep(500); - return true; - } - - - [MultiplayerOnly] - [Command("print_user_info")] - [KernelMode] - [RequiresArgument("pass")] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool PrintUserInfo(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - string pass = args["pass"].ToString(); - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking multi-user domain response call..."); - - msgReceived = (msg) => - { - if (msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - if(sve.Password == pass) - { - Console.WriteLine("Username: " + SaveSystem.CurrentUser.Username); - Console.WriteLine("Password: " + sve.Password); - Console.WriteLine("System name: " + sve.SystemName); - Console.WriteLine(); - Console.WriteLine("Codepoints: " + sve.Codepoints.ToString()); - - } - else - { - Console.WriteLine("--access denied."); - } - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - - } - else if (msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--contacting multi-user domain..."); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - Thread.Sleep(500); - TerminalBackend.PrefixEnabled = false; - return true; - } - - [MultiplayerOnly] - [Command("steal_codepoints")] - [KernelMode] - [RequiresArgument("amount")] - [RequiresArgument("pass")] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool StealCodepoints(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - string pass = args["pass"].ToString(); - ulong amount = (ulong)args["amount"]; - if(amount < 0) - { - Console.WriteLine("--invalid codepoint amount - halting..."); - return true; - } - - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking multi-user domain response call..."); - - msgReceived = (msg) => - { - if (msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - if (sve.Password == pass) - { - if(amount > sve.Codepoints) - { - Console.WriteLine("--can't steal this many codepoints from user."); - ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); - TerminalBackend.PrefixEnabled = true; - return; - } - - sve.Codepoints -= amount; - SaveSystem.TransferCodepointsFrom(SaveSystem.CurrentUser.Username, amount); - ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); - SaveSystem.SaveGame(); - } - else - { - Console.WriteLine("--access denied."); - } - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - else if (msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - TerminalBackend.PrintPrompt(); - } - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--contacting multi-user domain..."); - Thread.Sleep(500); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - Thread.Sleep(500); - TerminalBackend.PrefixEnabled = false; - return true; - } - - [MultiplayerOnly] - [Command("purge_user")] - [KernelMode] - [RequiresArgument("pass")] - [RequiresArgument("user")] - [RequiresArgument("sys")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool PurgeUser(Dictionary args) - { - string usr = args["user"].ToString(); - string sys = args["sys"].ToString(); - string pass = args["pass"].ToString(); - ServerMessageReceived msgReceived = null; - - Console.WriteLine("--hooking multi-user domain response call..."); - - msgReceived = (msg) => - { - if (msg.Name == "user_data") - { - var sve = JsonConvert.DeserializeObject(msg.Contents); - if (sve.Password == pass) - { - ServerManager.SendMessage("delete_dead_save", JsonConvert.SerializeObject(sve)); - Console.WriteLine(" User purged successfully."); - } - else - { - Console.WriteLine("--access denied."); - } - ServerManager.MessageReceived -= msgReceived; - } - else if (msg.Name == "user_data_not_found") - { - Console.WriteLine("--access denied."); - ServerManager.MessageReceived -= msgReceived; - } - TerminalBackend.PrintPrompt(); - TerminalBackend.PrefixEnabled = true; - }; - - Console.WriteLine("--contacting multi-user domain..."); - Thread.Sleep(500); - ServerManager.MessageReceived += msgReceived; - - ServerManager.SendMessage("get_user_data", JsonConvert.SerializeObject(new - { - user = usr, - sysname = sys - })); - Thread.Sleep(500); - TerminalBackend.PrefixEnabled = false; - return true; - } - - - [Command("brute_decrypt", true)] - [RequiresArgument("file")] - public static bool BruteDecrypt(Dictionary args) - { - if (FileExists(args["file"].ToString())) - { - string pass = new Random().Next(1000, 10000).ToString(); - string fake = ""; - Console.WriteLine("Beginning brute-force attack on password."); - var s = new Stopwatch(); - s.Start(); - for(int i = 0; i < pass.Length; i++) - { - for(int num = 0; num < 10; num++) - { - if(pass[i].ToString() == num.ToString()) - { - fake += num.ToString(); - Console.Write(num); - } - } - } - s.Stop(); - - Console.WriteLine("...password cracked - operation took " + s.ElapsedMilliseconds + " milliseconds."); - var tp = new TextPad(); - AppearanceManager.SetupWindow(tp); - WriteAllText("0:/temp.txt", ReadAllText(args["file"].ToString())); - tp.LoadFile("0:/temp.txt"); - Delete("0:/temp.txt"); - onCompleteDecrypt?.Invoke(); - } - else - { - Console.WriteLine("brute_decrypt: file not found"); - } - return true; - } - } - - [MultiplayerOnly] - [Namespace("storydev")] - public static class StoryDevCommands - { - [Command("start", description = "Starts a story plot.", usage ="id:string")] - [RequiresArgument("id")] - [RemoteLock] - public static bool StartStory(Dictionary args) - { - Story.Start(args["id"].ToString()); - return true; - } - - [Command("list", description ="Lists all story IDs.")] - public static bool ListIds() - { - foreach(var type in ReflectMan.Types) - foreach(var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - var attr = method.GetCustomAttributes(false).FirstOrDefault(x => x is StoryAttribute); - if (attr != null) - Console.WriteLine(" - " + (attr as StoryAttribute).StoryID); - } - return true; - } - - [Command("unexperience", description = "Marks a story plot as not-experienced yet.", usage ="id:string")] - [RemoteLock] - [RequiresArgument("id")] - public static bool Unexperience(Dictionary args) - { - string id = args["id"].ToString(); - if (SaveSystem.CurrentSave.StoriesExperienced.Contains(id)) - { - Console.WriteLine("Unexperiencing " + id + "."); - SaveSystem.CurrentSave.StoriesExperienced.Remove(id); - SaveSystem.SaveGame(); - } - else - { - Console.WriteLine("Story ID not found."); - } - - return true; - } - - [Command("experience", description = "Marks a story plot as experienced without triggering the plot.", usage ="{id:}")] - [RequiresArgument("id")] - [RemoteLock] - public static bool Experience(Dictionary args) - { - SaveSystem.CurrentSave.StoriesExperienced.Add(args["id"].ToString()); - SaveSystem.SaveGame(); - return true; - } - } -} + \ No newline at end of file diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index cab1ec8..0d9b817 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -13,7 +13,6 @@ using ShiftOS.Objects; namespace ShiftOS.WinForms { - [Namespace("test")] public class OobeStory { [Command("test")] diff --git a/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs index d57e28f..849049f 100644 --- a/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs +++ b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs @@ -10,7 +10,6 @@ using ShiftOS.Objects; namespace ShiftOS.WinForms.Servers { - [Namespace("rts")] [Server("Remote Terminal Server", 21)] //[RequiresUpgrade("story_hacker101_breakingthebonds")] //Uncomment when story is implemented. public class RemoteTerminalServer : Server diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9e16b19..00b4d83 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -131,12 +131,6 @@ Chat.cs - - UserControl - - - CoherenceOverlay.cs - UserControl diff --git a/ShiftOS.WinForms/SkinCommands.cs b/ShiftOS.WinForms/SkinCommands.cs index 1f32d96..f35c449 100644 --- a/ShiftOS.WinForms/SkinCommands.cs +++ b/ShiftOS.WinForms/SkinCommands.cs @@ -9,7 +9,6 @@ using ShiftOS.Objects.ShiftFS; namespace ShiftOS.WinForms { - [Namespace("skins")] public static class SkinCommands { [Command("reset")] diff --git a/ShiftOS.WinForms/TestCommandsForUpgrades.cs b/ShiftOS.WinForms/TestCommandsForUpgrades.cs index 739a2a2..5f28270 100644 --- a/ShiftOS.WinForms/TestCommandsForUpgrades.cs +++ b/ShiftOS.WinForms/TestCommandsForUpgrades.cs @@ -1,21 +1 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms -{ - [Namespace("test")] - public static class TestCommandsForUpgrades - { - [Command("simpletest")] - public static bool Simple() - { - return true; - } - } - - -} + \ No newline at end of file diff --git a/ShiftOS.WinForms/TrailerCommands.cs b/ShiftOS.WinForms/TrailerCommands.cs index 182d03d..e69de29 100644 --- a/ShiftOS.WinForms/TrailerCommands.cs +++ b/ShiftOS.WinForms/TrailerCommands.cs @@ -1,48 +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. - */ - -#define TRAILER -#if TRAILER -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms -{ - [Namespace("trailer")] - public static class TrailerCommands - { - [Command("init")] - public static bool TrailerInit() - { - var oobe = new Oobe(); - oobe.StartTrailer(); - return true; - } - } -} -#endif \ No newline at end of file diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index f6c4383..82d99f0 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -47,7 +47,6 @@ namespace ShiftOS.WinForms /// /// Winforms desktop. /// - [Namespace("desktop")] public partial class WinformsDesktop : Form, IDesktop { public MainMenu.MainMenu ParentMenu = null; diff --git a/ShiftOS_TheReturn/Command.cs b/ShiftOS_TheReturn/Command.cs index 09cf206..b90f604 100644 --- a/ShiftOS_TheReturn/Command.cs +++ b/ShiftOS_TheReturn/Command.cs @@ -135,42 +135,6 @@ namespace ShiftOS.Engine } } - /// - /// Denotes a Terminal command namespace. - /// - public class Namespace : Attribute - { - /// - /// The namespace's name. - /// - public string name; - /// - /// Whether the namespace should be hidden from the help system. Overrides all child s' hide values. - /// - public bool hide; - - /// - /// Creates a new instance of the . - /// - /// The name of the namespace. - public Namespace(string n) - { - name = n; - } - - - /// - /// Creates a new instance of the . - /// - /// The name of the namespace. - /// Whether this namespace should be hidden from the user. - public Namespace(string n, bool hide) - { - name = n; - this.hide = hide; - } - } - /// /// Marks a Terminal command as obsolete. /// diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 6f3ab15..9221bba 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -44,7 +44,6 @@ using ShiftOS.Objects.ShiftFS; namespace ShiftOS.Engine { - [Namespace("infobox", hide = true)] [RequiresUpgrade("desktop;wm_free_placement")] public static class InfoboxDebugCommands { @@ -107,7 +106,6 @@ namespace ShiftOS.Engine } - [Namespace("audio")] public static class AudioCommands { [Command("setvol", description = "Set the volume of the system audio to anywhere between 0 and 100.")] @@ -129,79 +127,7 @@ namespace ShiftOS.Engine } } - [RequiresUpgrade("mud_fundamentals")] - [Namespace("mud")] - public static class MUDCommands - { - [MultiplayerOnly] - [Command("status")] - public static bool Status() - { - ServerManager.PrintDiagnostics(); - return true; - } - - [Command("connect")] - public static bool Connect(Dictionary args) - { - try - { - string ip = (args.ContainsKey("addr") == true) ? args["addr"] as string : "michaeltheshifter.me"; - int port = (args.ContainsKey("port") == true) ? Convert.ToInt32(args["port"] as string) : 13370; - try - { - ServerManager.Initiate(ip, port); - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - } - - TerminalBackend.PrefixEnabled = false; - return true; - } - catch (Exception ex) - { - Console.WriteLine("Error running script:" + ex); - return false; - } - } - - [Command("reconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Reconnect() - { - Console.WriteLine("--reconnecting to multi-user domain..."); - KernelWatchdog.MudConnected = true; - Console.WriteLine("--done."); - return true; - } - - [MultiplayerOnly] - [Command("disconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Disconnect() - { - Console.WriteLine("--connection to multi-user domain severed..."); - KernelWatchdog.MudConnected = false; - return true; - } - - [MultiplayerOnly] - [Command("sendmsg")] - [KernelMode] - [RequiresUpgrade("hacker101_deadaccts")] - [RequiresArgument("header")] - [RequiresArgument("body")] - public static bool SendMessage(Dictionary args) - { - ServerManager.SendMessage(args["header"].ToString(), args["body"].ToString()); - return true; - } - } - [TutorialLock] - [Namespace("trm")] public static class TerminalCommands { [Command("clear")] @@ -220,167 +146,6 @@ namespace ShiftOS.Engine } } -#if DEVEL - internal class Rock : Exception - { - internal Rock() : base("Someone threw a rock at the window, and the Terminal shattered.") - { - - } - } - - [MultiplayerOnly] - [Namespace("dev")] - public static class ShiftOSDevCommands - { - [Command("buy")] - public static bool UnlockUpgrade(Dictionary args) - { - string upg = args["id"].ToString(); - try - { - SaveSystem.CurrentSave.Upgrades[upg] = true; - Shiftorium.InvokeUpgradeInstalled(); - SaveSystem.SaveGame(); - } - catch - { - Console.WriteLine("Upgrade not found."); - } - return true; - } - - [Command("rock", description = "A little surprise for unstable builds...")] - public static bool ThrowASandwichingRock() - { - Infobox.Show("He who lives in a glass house shouldn't throw stones...", new Rock().Message); - return false; - } - - - [Command("unbuy")] - [RequiresArgument("upgrade")] - public static bool UnbuyUpgrade(Dictionary args) - { - try - { - SaveSystem.CurrentSave.Upgrades[args["upgrade"].ToString()] = false; - SaveSystem.SaveGame(); - Desktop.PopulateAppLauncher(); - Desktop.CurrentDesktop.SetupDesktop(); - } - catch - { - Console.WriteLine("Upgrade not found."); - } - return true; - } - - [Command("getallupgrades")] - public static bool GetAllUpgrades() - { - Console.WriteLine(JsonConvert.SerializeObject(SaveSystem.CurrentSave.Upgrades, Formatting.Indented)); - return true; - } - - [Command("multarg")] - [RequiresArgument("id")] - [RequiresArgument("name")] - [RequiresArgument("type")] - public static bool MultArg(Dictionary args) - { - Console.WriteLine("Success! "+args.ToString()); - return true; - } - - [Command("restart")] - public static bool Restart() - { - SaveSystem.CurrentSave.Upgrades = new Dictionary(); - SaveSystem.CurrentSave.Codepoints = 0; - SaveSystem.CurrentSave.StoriesExperienced.Clear(); - SaveSystem.CurrentSave.StoriesExperienced.Add("mud_fundamentals"); - SaveSystem.SaveGame(); - Shiftorium.InvokeUpgradeInstalled(); - return true; - } - - [Command("freecp")] - public static bool FreeCodepoints(Dictionary args) - { - if (args.ContainsKey("amount")) - try - { - ulong codepointsToAdd = Convert.ToUInt64(args["amount"].ToString()); - SaveSystem.CurrentSave.Codepoints += codepointsToAdd; - return true; - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - return true; - } - - SaveSystem.CurrentSave.Codepoints += 1000; - return true; - } - - [Command("unlockeverything")] - public static bool UnlockAllUpgrades() - { - foreach (var upg in Shiftorium.GetDefaults()) - { - if (!SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.ID)) - SaveSystem.CurrentSave.Upgrades.Add(upg.ID, true); - else - SaveSystem.CurrentSave.Upgrades[upg.ID] = true; - } - Shiftorium.InvokeUpgradeInstalled(); - SkinEngine.LoadSkin(); - return true; - } - - [Command("info")] - public static bool DevInformation() - { - Console.WriteLine("{SHIFTOS_PLUS_MOTTO}"); - Console.WriteLine("{SHIFTOS_VERSION_INFO}" + Assembly.GetExecutingAssembly().GetName().Version); - return true; - } - [Command("pullfile")] - public static bool PullFile(Dictionary args) - { - if (args.ContainsKey("physical") && args.ContainsKey("virtual")) - { - string file = (string)args["physical"]; - string dest = (string)args["virtual"]; - if (System.IO.File.Exists(file)) - { - Console.WriteLine("Pulling physical file to virtual drive..."); - byte[] filebytes = System.IO.File.ReadAllBytes(file); - ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(dest, filebytes); - } - else - { - Console.WriteLine("The specified file does not exist on the physical drive."); - } - } - else - { - Console.WriteLine("You must supply a physical path."); - } - return true; - } - [Command("crash")] - public static bool CrashInstantly() - { - CrashHandler.Start(new Exception("ShiftOS was sent a command to forcefully crash.")); - return true; - } - } -#endif - - [Namespace("sos")] public static class ShiftOSCommands { @@ -478,38 +243,17 @@ namespace ShiftOS.Engine } [Command("help", "{COMMAND_HELP_USAGE", "{COMMAND_HELP_DESCRIPTION}")] - public static bool Help(Dictionary args) + public static bool Help() { var sb = new StringBuilder(); sb.AppendLine("Retrieving help data."); - - if (args.ContainsKey("ns")) + //print all unique namespaces. + foreach (var n in TerminalBackend.Commands.Select(x => x.CommandInfo).Distinct().OrderBy(x=>x.name)) { - string ns = args["ns"].ToString(); - //First let's check for a command that has this namespace. - var cmdtest = TerminalBackend.Commands.FirstOrDefault(x => x.NamespaceInfo.name == ns); - if (cmdtest == null) //Namespace not found. - sb.AppendLine("Error retrieving help for namespace \"" + ns + "\". Namespace not found."); - else - { - //Now do the actual scan. - sb.AppendLine("Namespace: " + ns); - foreach(var cmd in TerminalBackend.Commands.Where(x => x.NamespaceInfo.name == ns)) - { - string str = cmd.ToString(); - str = str.Replace(str.Substring(str.LastIndexOf("|")), ""); - sb.AppendLine(str); - } - } - } - else - { - - //print all unique namespaces. - foreach(var n in TerminalBackend.Commands.Select(x => x.NamespaceInfo.name).Distinct()) - { - sb.AppendLine("sos.help{ns:\"" + n + "\"}"); - } + sb.Append(n.name); + if (Shiftorium.UpgradeInstalled("help_descriptions")) + sb.Append(" - " + n.description); + sb.AppendLine(); } Console.WriteLine(sb.ToString()); @@ -565,7 +309,6 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, } [MultiplayerOnly] - [Namespace("shiftorium")] public static class ShiftoriumCommands { [Command("buy")] @@ -668,7 +411,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); return true; } - [Command("list")] + [Command("shiftorium", description ="Lists all available Shiftorium upgrades.")] public static bool ListAll(Dictionary args) { try @@ -742,7 +485,6 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); } } - [Namespace("win")] public static class WindowCommands { diff --git a/ShiftOS_TheReturn/PythonAPI.cs b/ShiftOS_TheReturn/PythonAPI.cs index cc3798c..7db4c45 100644 --- a/ShiftOS_TheReturn/PythonAPI.cs +++ b/ShiftOS_TheReturn/PythonAPI.cs @@ -291,7 +291,6 @@ namespace ShiftOS.Engine } #if DEBUG - [Namespace("dev")] public static class PythonCmds { [Command("runpystring", description = "Run some Python code. (Only present in DEBUG builds of ShiftOS)")] diff --git a/ShiftOS_TheReturn/ReflectMan.cs b/ShiftOS_TheReturn/ReflectMan.cs index 78f6bf3..d194754 100644 --- a/ShiftOS_TheReturn/ReflectMan.cs +++ b/ShiftOS_TheReturn/ReflectMan.cs @@ -104,7 +104,6 @@ namespace ShiftOS.Engine } #if DEBUG - [Namespace("dev")] public static class ReflectDebug { [Command("listalltypes", description = "List all types that were found by ReflectMan. Only present in DEBUG builds of ShiftOS.")] diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 81ea971..4594eb3 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -148,7 +148,6 @@ namespace ShiftOS.Engine return hash; } - public Namespace NamespaceInfo { get; set; } public Command CommandInfo { get; set; } public List RequiredArguments { get; set; } @@ -161,16 +160,14 @@ namespace ShiftOS.Engine public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append(this.NamespaceInfo.name); - sb.Append("."); sb.Append(this.CommandInfo.name); if (this.RequiredArguments.Count > 0) { - sb.Append("{"); + sb.Append(" "); foreach (var arg in RequiredArguments) { - sb.Append(arg); - sb.Append(":"); + sb.Append("--" + arg); + sb.Append(" "); if (RequiredArguments.IndexOf(arg) < RequiredArguments.Count - 1) sb.Append(','); } @@ -295,41 +292,42 @@ namespace ShiftOS.Engine public static void PopulateTerminalCommands() { Commands = new List(); - foreach(var type in ReflectMan.Types) + foreach (var type in ReflectMan.Types) { - var ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace; - if(ns != null) + foreach (var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command); + if (cmd != null) { - var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command); - if(cmd != null) - { - var tc = new TerminalCommand(); - tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + var tc = new TerminalCommand(); + tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); - tc.NamespaceInfo = ns; - tc.CommandInfo = cmd as Command; - tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); - tc.RequiredArguments = new List(); - foreach (var arg in mth.GetCustomAttributes(false).Where(x=>x is RequiresArgument)) - { - var rarg = arg as RequiresArgument; - tc.RequiredArguments.Add(rarg.argument); - } - var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; - if (rupg != null) - tc.Dependencies = rupg.Upgrade; - else - tc.Dependencies = ""; - tc.CommandType = type; - tc.CommandHandler = mth; - if (!Commands.Contains(tc)) - Commands.Add(tc); + tc.CommandInfo = cmd as Command; + tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + tc.RequiredArguments = new List(); + foreach (var arg in mth.GetCustomAttributes(false).Where(x => x is RequiresArgument)) + { + var rarg = arg as RequiresArgument; + tc.RequiredArguments.Add(rarg.argument); } + var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; + if (rupg != null) + tc.Dependencies = rupg.Upgrade; + else + tc.Dependencies = ""; + tc.CommandType = type; + tc.CommandHandler = mth; + + var ambiguity = Commands.FirstOrDefault(x => x.CommandInfo.name == tc.CommandInfo.name); + if (ambiguity != null) + throw new Exception("Command ambiguity error. You can't have two commands with the same name: " + $"{tc} == {ambiguity}"); + + if (!Commands.Contains(tc)) + Commands.Add(tc); } } + } Console.WriteLine("[termdb] " + Commands.Count + " commands found."); } @@ -465,7 +463,7 @@ namespace ShiftOS.Engine string[] split = text.Split('.'); - var cmd = Commands.FirstOrDefault(x => x.NamespaceInfo.name == split[0] && x.CommandInfo.name == split[1]); + var cmd = Commands.FirstOrDefault(x => x.CommandInfo.name == text); if (cmd == null) return false; if (!Shiftorium.UpgradeInstalled(cmd.Dependencies)) diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs index a64c99c..cac535b 100644 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -10,7 +10,6 @@ namespace ShiftOS.Engine /// /// Administrative user management terminal commands. /// - [Namespace("admin")] [KernelMode] [RequiresUpgrade("mud_fundamentals")] public static class AdminUserManagementCommands @@ -173,7 +172,6 @@ namespace ShiftOS.Engine /// /// Non-administrative user management terminal commands. /// - [Namespace("user")] [RequiresUpgrade("mud_fundamentals")] public static class UserManagementCommands { -- cgit v1.2.3 From 77cb4a9a14de07023e86a9a5cda7171fcb4ec8ec Mon Sep 17 00:00:00 2001 From: RogueAI42 Date: Sat, 17 Jun 2017 14:23:39 +1000 Subject: Changed how bounces work in Pong + Fixed Shutdown --- ShiftOS.WinForms/Applications/Pong.cs | 36 +++++++++++++++++------------------ ShiftOS.WinForms/WinformsDesktop.cs | 6 +++--- 2 files changed, 20 insertions(+), 22 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 3f06676..c260ae3 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -83,6 +83,15 @@ namespace ShiftOS.WinForms.Applications private string counter = ""; + private void Bounce(Rectangle ball, Rectangle paddle) + { + // reverse x velocity to send the ball the other way + xVel = -xVel; + + // adjust y velocity based on where the ball hit the paddle + yVel += linear((ball.Top + (ball.Height / 2)), paddle.Top, paddle.Bottom, -1, 1); + } + public void UpdateBall() { if (doBallCalc) @@ -141,11 +150,7 @@ namespace ShiftOS.WinForms.Applications //check if the ball x is greater than the player paddle's middle coordinate if (ballRect.Right >= opponentRect.Left) { - //reverse x velocity to send the ball the other way - xVel = -xVel; - - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), opponentRect.Top, opponentRect.Bottom, -1, 1); + Bounce(ballRect, opponentRect); doAi = false; } @@ -169,11 +174,7 @@ namespace ShiftOS.WinForms.Applications { if (ballRect.Left <= playerRect.Right) { - //reverse x velocity to send the ball the other way - xVel = -xVel; - - //set y velocity based on where the ball hit the paddle - yVel = linear((ballRect.Top + (ballRect.Height / 2)), playerRect.Top, playerRect.Bottom, -1, 1); + Bounce(ballRect, playerRect); //reset the ai location aiBallX = ballX; @@ -255,15 +256,12 @@ namespace ShiftOS.WinForms.Applications new System.Threading.Thread(() => { doBallCalc = false; - counter = "3"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); - counter = "2"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); - counter = "1"; - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - System.Threading.Thread.Sleep(1000); + for (int i = 3; i > 0; i--) + { + counter = i.ToString(); + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + System.Threading.Thread.Sleep(1000); + } doBallCalc = true; header = ""; counter = ""; diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 82d99f0..e8ad298 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -824,7 +824,7 @@ namespace ShiftOS.WinForms item.Text = Localization.Parse("{SHUTDOWN}"); item.Click += (o, a) => { - TerminalBackend.InvokeCommand("sos.shutdown"); + TerminalBackend.InvokeCommand("shutdown"); }; apps.DropDownItems.Add(item); if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) @@ -853,7 +853,7 @@ namespace ShiftOS.WinForms catbtn.Height = 24; flcategories.Controls.Add(catbtn); catbtn.Show(); - catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("sos.shutdown"); + catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("shutdown"); } } } @@ -1109,7 +1109,7 @@ namespace ShiftOS.WinForms private void btnshutdown_Click(object sender, EventArgs e) { - TerminalBackend.InvokeCommand("sos.shutdown"); + TerminalBackend.InvokeCommand("shutdown"); } public void HideAppLauncher() -- cgit v1.2.3 From e3f9a6028b3774f7376617502e7f6016dc50dd0e Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Jun 2017 14:45:42 -0400 Subject: Localize a LOT of the UI --- ShiftOS.WinForms/Applications/MindBlow.cs | 12 +- ShiftOS.WinForms/Applications/Pong.Designer.cs | 74 +++--- ShiftOS.WinForms/Applications/Pong.cs | 34 ++- ShiftOS.WinForms/Applications/Pong.resx | 7 - ShiftOS.WinForms/MainMenu/Loading.Designer.cs | 2 +- ShiftOS.WinForms/MainMenu/Loading.cs | 1 + ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs | 62 ++--- ShiftOS.WinForms/MainMenu/MainMenu.cs | 47 +--- ShiftOS.WinForms/Resources/strings_en.txt | 354 +++++++++---------------- ShiftOS_TheReturn/Commands.cs | 263 ++++++------------ ShiftOS_TheReturn/SaveSystem.cs | 120 +++------ ShiftOS_TheReturn/UserManagementCommands.cs | 54 ++-- 12 files changed, 377 insertions(+), 653 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/MindBlow.cs b/ShiftOS.WinForms/Applications/MindBlow.cs index 0f0df80..7cd2a8f 100644 --- a/ShiftOS.WinForms/Applications/MindBlow.cs +++ b/ShiftOS.WinForms/Applications/MindBlow.cs @@ -35,7 +35,17 @@ namespace ShiftOS.WinForms.Applications public override long Length => box.Text.Length; - public override long Position { get => Length; set => throw new NotImplementedException(); } + public override long Position + { + get + { + return Length; + } + set + { + //nothing + } + } public override void Flush() { diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index aee599b..fd82735 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -28,18 +28,17 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Pong)); this.pnlcanvas = new System.Windows.Forms.Panel(); this.pnllevelwon = new System.Windows.Forms.Panel(); - this.lbltitle = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); - this.btncashout = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); + this.btncashout = new System.Windows.Forms.Button(); + this.lbltitle = new System.Windows.Forms.Label(); this.pnlgamestart = new System.Windows.Forms.Panel(); this.label2 = new System.Windows.Forms.Label(); this.panel3 = new System.Windows.Forms.Panel(); - this.button2 = new System.Windows.Forms.Button(); + this.btnplay = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.pnllevelwon.SuspendLayout(); this.panel1.SuspendLayout(); @@ -68,17 +67,6 @@ this.pnllevelwon.TabIndex = 0; this.pnllevelwon.Visible = false; // - // lbltitle - // - this.lbltitle.Dock = System.Windows.Forms.DockStyle.Top; - this.lbltitle.Location = new System.Drawing.Point(0, 0); - this.lbltitle.Name = "lbltitle"; - this.lbltitle.Size = new System.Drawing.Size(301, 13); - this.lbltitle.TabIndex = 0; - this.lbltitle.Tag = "header2"; - this.lbltitle.Text = "You\'ve reached level 2!"; - this.lbltitle.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // // label1 // this.label1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -86,8 +74,7 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(301, 139); this.label1.TabIndex = 1; - this.label1.Text = "You have survived this level of Pong. You now have a chance to cash out your Code" + - "points or play on for more."; + this.label1.Text = "{PONG_BEATLEVELDESC}"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // panel1 @@ -100,25 +87,36 @@ this.panel1.Size = new System.Drawing.Size(301, 32); this.panel1.TabIndex = 2; // + // button1 + // + this.button1.Location = new System.Drawing.Point(159, 6); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(93, 23); + this.button1.TabIndex = 1; + this.button1.Text = "{PONG_PLAYON}"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // btncashout // this.btncashout.Location = new System.Drawing.Point(48, 6); this.btncashout.Name = "btncashout"; this.btncashout.Size = new System.Drawing.Size(93, 23); this.btncashout.TabIndex = 0; - this.btncashout.Text = "Cash out"; + this.btncashout.Text = "{PONG_CASHOUT}"; this.btncashout.UseVisualStyleBackColor = true; this.btncashout.Click += new System.EventHandler(this.btncashout_Click); // - // button1 + // lbltitle // - this.button1.Location = new System.Drawing.Point(159, 6); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(93, 23); - this.button1.TabIndex = 1; - this.button1.Text = "Play on"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.lbltitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbltitle.Location = new System.Drawing.Point(0, 0); + this.lbltitle.Name = "lbltitle"; + this.lbltitle.Size = new System.Drawing.Size(301, 13); + this.lbltitle.TabIndex = 0; + this.lbltitle.Tag = "header2"; + this.lbltitle.Text = "You\'ve reached level 2!"; + this.lbltitle.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // pnlgamestart // @@ -138,27 +136,27 @@ this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(301, 206); this.label2.TabIndex = 1; - this.label2.Text = resources.GetString("label2.Text"); + this.label2.Text = "{PONG_DESC}"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // panel3 // - this.panel3.Controls.Add(this.button2); + this.panel3.Controls.Add(this.btnplay); this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel3.Location = new System.Drawing.Point(0, 248); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(301, 32); this.panel3.TabIndex = 2; // - // button2 + // btnplay // - this.button2.Location = new System.Drawing.Point(100, 6); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(116, 23); - this.button2.TabIndex = 1; - this.button2.Text = "Play some Pong!"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.btnplay.Location = new System.Drawing.Point(100, 6); + this.btnplay.Name = "btnplay"; + this.btnplay.Size = new System.Drawing.Size(116, 23); + this.btnplay.TabIndex = 1; + this.btnplay.Text = "{PONG_PLAY}"; + this.btnplay.UseVisualStyleBackColor = true; + this.btnplay.Click += new System.EventHandler(this.button2_Click); // // label3 // @@ -168,7 +166,7 @@ this.label3.Size = new System.Drawing.Size(301, 42); this.label3.TabIndex = 0; this.label3.Tag = "header2"; - this.label3.Text = "Welcome to Pong."; + this.label3.Text = "{PONG_WELCOME}"; this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // Pong @@ -200,7 +198,7 @@ private System.Windows.Forms.Panel pnlgamestart; private System.Windows.Forms.Label label2; private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button btnplay; private System.Windows.Forms.Label label3; } } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index c260ae3..d8f93f7 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -223,7 +223,7 @@ namespace ShiftOS.WinForms.Applications pnlgamestart.Show(); pnlgamestart.BringToFront(); pnlgamestart.CenterParent(); - Infobox.Show("You lose.", "You lost the game! Guess you should've cashed out..."); + Infobox.Show("{TITLE_PONG_YOULOSE}", "{PROMPT_PONGLOST}"); doAi = false; doBallCalc = false; } @@ -237,7 +237,10 @@ namespace ShiftOS.WinForms.Applications pnllevelwon.CenterParent(); pnllevelwon.Show(); pnllevelwon.BringToFront(); - lbltitle.Text = "You've reached level " + level + "!"; + lbltitle.Text = Localization.Parse("{PONG_LEVELREACHED}", new Dictionary + { + ["%level"] = level.ToString() + }); lbltitle.Height = (int)CreateGraphics().MeasureString(lbltitle.Text, lbltitle.Font).Height; codepointsToEarn += CalculateAIBeatCP() * 2; speedFactor += speedFactor / level; @@ -251,8 +254,12 @@ namespace ShiftOS.WinForms.Applications public void Win() { - header = "You beat the AI! " + CalculateAIBeatCP() + " Codepoints!."; + header = Localization.Parse("{PONG_BEATAI}", new Dictionary + { + ["%amount"] = CalculateAIBeatCP().ToString() + }); InitializeCoordinates(); + counterTimer.Stop(); new System.Threading.Thread(() => { doBallCalc = false; @@ -265,6 +272,10 @@ namespace ShiftOS.WinForms.Applications doBallCalc = true; header = ""; counter = ""; + Desktop.InvokeOnWorkerThread(() => + { + counterTimer.Start(); + }); }).Start(); } @@ -322,7 +333,10 @@ namespace ShiftOS.WinForms.Applications //draw opponent e.Graphics.FillRectangle(new SolidBrush(pnlcanvas.ForeColor), new RectangleF((float)(pnlcanvas.Width - (paddleWidth*2)), (float)(opponentYLocal - (float)(paddleHeight / 2)), (float)paddleWidth, (float)paddleHeight)); - string cp_text = Localization.Parse("{CODEPOINTS}: " + codepointsToEarn); + string cp_text = Localization.Parse("{PONG_STATUSCP}", new Dictionary + { + ["%cp"] = codepointsToEarn.ToString() + }); var tSize = e.Graphics.MeasureString(cp_text, SkinEngine.LoadedSkin.Header3Font); @@ -346,7 +360,11 @@ namespace ShiftOS.WinForms.Applications ); e.Graphics.DrawString(header, SkinEngine.LoadedSkin.Header2Font, new SolidBrush(pnlcanvas.ForeColor), tLoc); - string l = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); + string l = Localization.Parse("{PONG_STATUSLEVEL}", new Dictionary + { + ["%level"] = level.ToString(), + ["%time"] = secondsleft.ToString() + }); tSize = e.Graphics.MeasureString(l, SkinEngine.LoadedSkin.Header3Font); tLoc = new PointF((pnlcanvas.Width - (int)tSize.Width) / 2, @@ -412,7 +430,11 @@ namespace ShiftOS.WinForms.Applications SaveSystem.CurrentSave.Codepoints += (ulong)codepointsToEarn; level = 1; speedFactor = 0.0125; - Infobox.Show("Codepoints transferred.", "Pong has transferred " + codepointsToEarn + " Codepoints to your system."); + Infobox.Show("{TITLE_CODEPOINTSTRANSFERRED}", Localization.Parse("{PROMPT_CODEPOINTSTRANSFERRED}", new Dictionary + { + ["%transferrer"] = "Pong", + ["%amount"] = codepointsToEarn.ToString() + })); codepointsToEarn = 0; pnlgamestart.Show(); pnlgamestart.BringToFront(); diff --git a/ShiftOS.WinForms/Applications/Pong.resx b/ShiftOS.WinForms/Applications/Pong.resx index 685deff..1af7de1 100644 --- a/ShiftOS.WinForms/Applications/Pong.resx +++ b/ShiftOS.WinForms/Applications/Pong.resx @@ -117,11 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Pong is the modern-day recreation of the classic 70s game called, you guessed it, Pong. - -In Pong, you must try your best to keep the fast-moving ball from going past your side of the screen using your mouse to move your paddle in the way of the ball, while getting the ball to go past the opponent's paddle. - -Once you start Pong, you have 60 seconds to beat the opponent and survive as much as possible. The game will get faster as you play, and the more 60-second levels you play, the more Codepoints you'll earn. If you lose the level, you will start back at Level 1 with 0 Codepoints. At the end of the level, you may choose to cash out or play on. - \ No newline at end of file diff --git a/ShiftOS.WinForms/MainMenu/Loading.Designer.cs b/ShiftOS.WinForms/MainMenu/Loading.Designer.cs index 95619d9..5cf42d6 100644 --- a/ShiftOS.WinForms/MainMenu/Loading.Designer.cs +++ b/ShiftOS.WinForms/MainMenu/Loading.Designer.cs @@ -40,7 +40,7 @@ this.label.Name = "label"; this.label.Size = new System.Drawing.Size(284, 262); this.label.TabIndex = 0; - this.label.Text = "Loading..."; + this.label.Text = "{GEN_LOADING}"; this.label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // Loading diff --git a/ShiftOS.WinForms/MainMenu/Loading.cs b/ShiftOS.WinForms/MainMenu/Loading.cs index 555f1d4..c1c0ba0 100644 --- a/ShiftOS.WinForms/MainMenu/Loading.cs +++ b/ShiftOS.WinForms/MainMenu/Loading.cs @@ -16,6 +16,7 @@ namespace ShiftOS.WinForms.MainMenu public Loading() { InitializeComponent(); + label.Text = Localization.Parse(label.Text); } private void Loading_FormShown(object sender, EventArgs e) diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs b/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs index b716b4e..a9291d3 100644 --- a/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs +++ b/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs @@ -36,8 +36,6 @@ this.button5 = new System.Windows.Forms.Button(); this.lbticker = new System.Windows.Forms.Label(); this.pnloptions = new System.Windows.Forms.Panel(); - this.txtubase = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); this.txtdsport = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.txtdsaddress = new System.Windows.Forms.TextBox(); @@ -81,7 +79,7 @@ this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(181, 23); this.button1.TabIndex = 0; - this.button1.Text = "Campaign"; + this.button1.Text = "{MAINMENU_CAMPAIGN}"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // @@ -92,7 +90,7 @@ this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(181, 23); this.button2.TabIndex = 1; - this.button2.Text = "Sandbox"; + this.button2.Text = "{MAINMENU_SANDBOX}"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // @@ -103,7 +101,7 @@ this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(181, 23); this.button3.TabIndex = 2; - this.button3.Text = "Settings"; + this.button3.Text = "{GEN_SETTINGS}"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // @@ -114,7 +112,7 @@ this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(181, 23); this.button4.TabIndex = 3; - this.button4.Text = "About"; + this.button4.Text = "{GEN_ABOUT}"; this.button4.UseVisualStyleBackColor = true; // // button5 @@ -124,7 +122,7 @@ this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(181, 23); this.button5.TabIndex = 4; - this.button5.Text = "Exit"; + this.button5.Text = "{GEN_EXIT}"; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // @@ -140,8 +138,6 @@ // // pnloptions // - this.pnloptions.Controls.Add(this.txtubase); - this.pnloptions.Controls.Add(this.label3); this.pnloptions.Controls.Add(this.txtdsport); this.pnloptions.Controls.Add(this.label2); this.pnloptions.Controls.Add(this.txtdsaddress); @@ -149,25 +145,9 @@ this.pnloptions.Controls.Add(this.flowLayoutPanel1); this.pnloptions.Location = new System.Drawing.Point(49, 26); this.pnloptions.Name = "pnloptions"; - this.pnloptions.Size = new System.Drawing.Size(432, 290); + this.pnloptions.Size = new System.Drawing.Size(432, 167); this.pnloptions.TabIndex = 2; // - // txtubase - // - this.txtubase.Location = new System.Drawing.Point(146, 133); - this.txtubase.Name = "txtubase"; - this.txtubase.Size = new System.Drawing.Size(225, 20); - this.txtubase.TabIndex = 6; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(22, 136); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(106, 13); - this.label3.TabIndex = 5; - this.label3.Text = "Unite API base URL:"; - // // txtdsport // this.txtdsport.Location = new System.Drawing.Point(146, 85); @@ -180,9 +160,9 @@ this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(22, 88); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(99, 13); + this.label2.Size = new System.Drawing.Size(125, 13); this.label2.TabIndex = 3; - this.label2.Text = "Digital Society Port:"; + this.label2.Text = "{MAINMENU_DSPORT}"; // // txtdsaddress // @@ -196,9 +176,9 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(22, 57); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(118, 13); + this.label1.Size = new System.Drawing.Size(147, 13); this.label1.TabIndex = 1; - this.label1.Text = "Digital Society Address:"; + this.label1.Text = "{MAINMENU_DSADDRESS}"; // // flowLayoutPanel1 // @@ -208,7 +188,7 @@ this.flowLayoutPanel1.Controls.Add(this.btnsave); this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 259); + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 136); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Size = new System.Drawing.Size(432, 31); this.flowLayoutPanel1.TabIndex = 0; @@ -218,11 +198,11 @@ this.opt_btncancel.AutoSize = true; this.opt_btncancel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.opt_btncancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.opt_btncancel.Location = new System.Drawing.Point(377, 3); + this.opt_btncancel.Location = new System.Drawing.Point(331, 3); this.opt_btncancel.Name = "opt_btncancel"; - this.opt_btncancel.Size = new System.Drawing.Size(52, 25); + this.opt_btncancel.Size = new System.Drawing.Size(98, 25); this.opt_btncancel.TabIndex = 0; - this.opt_btncancel.Text = "Cancel"; + this.opt_btncancel.Text = "{GEN_CANCEL}"; this.opt_btncancel.UseVisualStyleBackColor = true; this.opt_btncancel.Click += new System.EventHandler(this.opt_btncancel_Click); // @@ -231,11 +211,11 @@ this.btnsave.AutoSize = true; this.btnsave.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.btnsave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnsave.Location = new System.Drawing.Point(327, 3); + this.btnsave.Location = new System.Drawing.Point(241, 3); this.btnsave.Name = "btnsave"; - this.btnsave.Size = new System.Drawing.Size(44, 25); + this.btnsave.Size = new System.Drawing.Size(84, 25); this.btnsave.TabIndex = 1; - this.btnsave.Text = "Save"; + this.btnsave.Text = "{GEN_SAVE}"; this.btnsave.UseVisualStyleBackColor = true; this.btnsave.Click += new System.EventHandler(this.btnsave_Click); // @@ -259,7 +239,7 @@ this.btnnewgame.Name = "btnnewgame"; this.btnnewgame.Size = new System.Drawing.Size(181, 23); this.btnnewgame.TabIndex = 0; - this.btnnewgame.Text = "New Game"; + this.btnnewgame.Text = "{MAINMENU_NEWGAME}"; this.btnnewgame.UseVisualStyleBackColor = true; this.btnnewgame.Click += new System.EventHandler(this.btnnewgame_Click); // @@ -270,7 +250,7 @@ this.btncontinue.Name = "btncontinue"; this.btncontinue.Size = new System.Drawing.Size(181, 23); this.btncontinue.TabIndex = 1; - this.btncontinue.Text = "Continue"; + this.btncontinue.Text = "{GEN_CONTINUE}"; this.btncontinue.UseVisualStyleBackColor = true; this.btncontinue.Click += new System.EventHandler(this.btncontinue_Click); // @@ -281,7 +261,7 @@ this.button10.Name = "button10"; this.button10.Size = new System.Drawing.Size(181, 23); this.button10.TabIndex = 4; - this.button10.Text = "Back"; + this.button10.Text = "{GEN_BACK}"; this.button10.UseVisualStyleBackColor = true; this.button10.Click += new System.EventHandler(this.button10_Click); // @@ -357,8 +337,6 @@ private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.Button opt_btncancel; private System.Windows.Forms.Button btnsave; - private System.Windows.Forms.TextBox txtubase; - private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox txtdsport; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtdsaddress; diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.cs b/ShiftOS.WinForms/MainMenu/MainMenu.cs index 1936fec..7ace42a 100644 --- a/ShiftOS.WinForms/MainMenu/MainMenu.cs +++ b/ShiftOS.WinForms/MainMenu/MainMenu.cs @@ -116,29 +116,7 @@ namespace ShiftOS.WinForms.MainMenu private string GetTickerMessage() { - switch (rnd.Next(0, 10)) - { - case 0: - return "Did you know that you can skin this very menu? Just goes to show how much you can shift it your way."; - case 1: - return "Want to pick up a few skins or mods from the community? Head on over to http://getshiftos.ml/Skins!"; - case 2: - return "Sandbox mode is a special version of ShiftOS that allows you to use the operating system without having to deal with Codepoints, the Shiftorium or having to play through the storyline. Handy..."; - case 3: - return "ArtPad not good enough? You can use an external image editor to create ShiftOS skin textures. Just save your files to the Shared Directory and they'll be imported into ShiftOS on the 1:/ drive."; - case 4: - return "Terminal too weird for ya? You can use the Format Editor to generate your own Terminal command parser. No coding knowledge needed!"; - case 5: - return "Contests are a good way to earn heaps of Codepoints. Head on over to http://getshiftos.ml/Contests for info on current community contests."; - case 6: - return "There's no bugs in this game... But if you find some, please submit them to http://getshiftos.ml/Bugs."; - case 7: - return "SHIFTOS - PROPERTY OF MICHAEL VANOVERBEEK. FOR INTERNAL USE ONLY. Build number = sos_tr_133764 [Just kidding. ShiftOS is open-source. Find the code at http://github.com/shiftos-game/ShiftOS!]"; - case 8: - return "Hold your Codepoints against the wall... when they take everything away. Hold your Codepoints against the wall..."; - default: - return "Good God. We don't know what to put here."; - } + return Localization.Parse("{MAINMENU_TIPTEXT_" + rnd.Next(10) + "}"); } private void button1_Click(object sender, EventArgs e) @@ -175,7 +153,6 @@ namespace ShiftOS.WinForms.MainMenu { var conf = ShiftOS.Objects.UserConfig.Get(); - txtubase.Text = conf.UniteUrl; txtdsaddress.Text = conf.DigitalSocietyAddress; txtdsport.Text = conf.DigitalSocietyPort.ToString(); @@ -201,32 +178,14 @@ namespace ShiftOS.WinForms.MainMenu int p = 0; - if(int.TryParse(txtdsport.Text, out p) == false) + if(int.TryParse(txtdsport.Text, out p) == false || p < 0 || p > 65535) { - Infobox.Show("Invalid port number", "The Digital Society Port must be a valid whole number between 0 and 65535."); + Infobox.Show("{TITLE_INVALIDPORT}", "{PROMPT_INVALIDPORT}"); return; } - else - { - if(p < 0 || p > 65535) - { - Infobox.Show("Invalid port number", "The Digital Society Port must be a valid whole number between 0 and 65535."); - return; - } - } conf.DigitalSocietyPort = p; - string unite = txtubase.Text; - if (unite.EndsWith("/")) - { - int len = unite.Length; - int index = len - 1; - int end = 1; - unite = unite.Remove(index, end); - } - conf.UniteUrl = unite; - System.IO.File.WriteAllText("servers.json", Newtonsoft.Json.JsonConvert.SerializeObject(conf, Newtonsoft.Json.Formatting.Indented)); HideOptions(); diff --git a/ShiftOS.WinForms/Resources/strings_en.txt b/ShiftOS.WinForms/Resources/strings_en.txt index f63f0e0..a3b407b 100644 --- a/ShiftOS.WinForms/Resources/strings_en.txt +++ b/ShiftOS.WinForms/Resources/strings_en.txt @@ -1,244 +1,134 @@ +/* + * ShiftOS English Language Pack + * + * This is the default language pack distributed within the game. + */ + { - "{SUBMIT}":"Submit", + //General strings + //These strings can be used anywhere in the UI where language context isn't necessary. + "{GEN_PROGRAMS}": "Programs", + "{GEN_COMMANDS}": "Commands", + "{GEN_OBJECTIVES}": "Objectives", + "{GEN_CURRENTPROCESSES}": "Current processes", + "{GEN_WELCOME}": "Welcome to ShiftOS.", + "{GEN_SYSTEMNAME}": "System name", + "{GEN_PASSWORD}": "Password", + "{GEN_LPROMPT}": "%sysname login: ", + "{GEN_SYSTEMSTATUS}": "System status", + "{GEN_USERS}": "Users", + "{GEN_CODEPOINTS}": "Codepoints", + "{GEN_LOADING}": "Loading...", + "{GEN_SAVE}": "Save", + "{GEN_CANCEL}": "Cancel", + "{GEN_CONTINUE}": "Continue", + "{GEN_BACK}": "Back", + "{GEN_YES}": "Yes", + "{GEN_NO}": "No", + "{GEN_OK}": "OK", + "{GEN_SETTINGS}": "Settings", + "{GEN_ABOUT}": "About", + "{GEN_EXIT}": "Exit", -"{TERMINAL_TUTORIAL_1}":"Welcome to the ShiftOS terminal. This is where you will spend the bulk of your time within ShiftOS. - -A brief rundown of how to use the terminal is as follows. You can use the 'sos.help' command to show a list of all commands. Simply type it in and strike to view all commands. - -Commands can be sent arguments by specifying a key-value pair inside a {} block at the end of the command. For example: - -some.command{print:\"hello\"} -math.add{op1:1,op2:2} -set.value{key:\"somekey\", value:true} - -You have been given 50 Codepoints - use your knowledge to use them to buy the MUD Fundamentals Shiftorium Upgrade using the terminal. -To buy MUD Fundamentals, type shiftorium.buy{upgrade:\"mud_fundamentals\"} This is also true for any other thing you want to buy from the shiftorium, just replace mud_fundementals with any other upgrade id. -", + //General errors + //Syntax errors, command errors, you name it.. + "{ERR_BADBOOL}": "The value you entered must be either true or false.", + "{ERR_BADPERCENT}": "The value you entered must be a value from 0 to 100.", + "{ERR_NOLANG}": "The language you entered does not exist!", + "{ERR_NOTENOUGHCODEPOINTS}": "You don't have enough Codepoints to do that.", + "{ERR_NOUPGRADE}": "We couldn't find that upgrade.", + "{ERR_GENERAL}": "An error has occurred performing this operation.", + "{ERR_EMPTYCATEGORY}": "The category you specified either has no items in it, or was not found.", + "{ERR_NOMOREUPGRADES}": "There are no more Shiftorium Upgrades to show!", + "{ERR_BADWINID}": "You must specify a value between 0 and %max.", + "{ERR_USERFOUND}": "That user already exists.", + "{ERR_NOUSER}": "That user was not found.", + "{ERR_REMOVEYOU}": "You can't remove your own user account.", + "{ERR_BADACL}": "You must specify a value between 0 (guest) and 3 (root) for a user permission.", + "{ERR_ACLHIGHERVALUE}": "You can't set a user's permissions to a value higher than your own.", + "{ERR_HIGHERPERMS}": "That user has more rights than you!", + "{ERR_PASSWD_MISMATCH}": "Passwords don't match!", + //Command results + "{RES_ACLUPDATED}": "User permissions updated.", + "{RES_LANGUAGE_CHANGED}": "System language changed successfully.", + "{RES_NOOBJECTIVES}": "No objectives to display! Check back for more.", + "{RES_UPGRADEINSTALLED}": "Upgrade installed!", + "{RES_WINDOWCLOSED}": "The window was closed.", + "{RES_CREATINGUSER}": "Creating new user with username %name.", + "{RES_REMOVINGUSER}": "Removing user with username %name from your system.", + "{RES_DENIED}": "Access denied.", + "{RES_GRANTED}": "Access granted.", + "{RES_PASSWD_SET}": "Password set successfully.", - "{TERMINAL_TUTORIAL_2}":"You successfully passed the test. ShiftOS will now start installing it's base functionality.", - "{ABOUT}":"About", - "{HIGH_SCORES}":"High scores", - "{PONG_VIEW_HIGHSCORES}":"See the high scores", - "{PONG_HIGHSCORE_EXP}":"Want to see what other users have gotten?", - "{START_SYSTEM_SCAN}":"Start system-wide scan", - "{SCAN_HOME}":"Scan 0:/home", - "{SCAN_SYSTEM}":"Scan 0:/system", - "{RESULTS}":"Results", - "{VIRUSSCANNER_ABOUT}":"Welcome to the ShiftOS virus scanner. - -The ShiftOS virus scanner is a utility that allows you to scan any file on your system and see if it is a virus. If a virus is detected, you have the option to delete it after the scan by clicking 'Remove'. + //Shiftorium messages. + "{SHFM_UPGRADE}": "%id - %cost Codepoints", + "{SHFM_CATEGORY}": " - %name: %available upgrades left.", + "{SHFM_QUERYERROR}": "Shiftorium Query Error", + "{SHFM_NOUPGRADES}": "No upgrades!", -If a system file is deleted by the virus scanner, it will be replaced.", - "{PLAY}":"Play", - "{APPLICATIONS}":"Applications", - "{TERMINAL}":"Terminal", - "{PONG}":"Pong", - "{CODEPOINTS}":"Codepoints", - "{SHIFTORIUM}":"Shiftorium", - "{HACK}":"Hack", - "{SHIFTER}":"Shifter", - "{MUD_SHORT}":"MUD", - "{MUD}":"Multi-user domain", - "{DESKTOP}":"Desktop", - "{WINDOW}":"Window", - "{WINDOW_MANAGER}":"Window manager", - "{UPGRADE}":"Upgrade", - "{UPGRADES}":"Upgrades", - "{APPLICATION}":"Application", - "{SCRIPT}":"Script", - "{ERROR}":"Error", - "{SCRIPTS}":"Scripts", - "{NULL}":"null", - "{ID}":"ID Num", - "{SYSTEM_INITIATED}":"System initiated", - "{PASSWORD}":"Password", - "{CRACK}":"Crack", - "{ARTPAD_UNDO_ERROR}":"Artpad - Undo error", - "{ARTPAD_NEXT_STEP_WILL_KILL_CANVAS_JUST_FLIPPING_CLICK_NEW}":"You cannot undo the previous action as it would delete the canvas. If you'd like to clear the canvas, click New.", - "{ARTPAD_REDO_ERROR}":"Artpad - Redo error", - "{ARTPAD_NOTHING_TO_REDO}": "Artpad has nothing to redo! Remember that when you undo and then draw on the canvas, all redo history is wiped.", - "{ARTPAD_MAGNIFIER_ERROR}": "Artpad - Magnifier error", - "{ARTPAD_MAGNIFICATION_ERROR_EXP_2}": "Artpad cannot zoom out any further as the canvas would disappear!", - "{ARTPAD_MAGNIFICATION_ERROR_EXP}": "Artpad cannot zoom any further into the canvas. Well, it can, it just doesn't want to.", - "{SHUTDOWN}":"Shutdown", - "{CONNECTING_TO_MUD}":"Connecting to the multi-user domain...", - "{READING_FS}":"Reading filesystem...", - "{INIT_KERNEL}":"Initiating kernel...", - "{START_DESKTOP}":"Starting desktop session...", - "{DONE}": "done", - "{READING_CONFIG}":"Reading configuration...", - "{ID_TAKEN}":"ID has been taken! Use chat.join to join this chat.", - "{CHAT_NOT_FOUND_OR_TOO_MANY_MEMBERS}":"This chat either doesn't exist or has too many users in it.", - "{CHAT_NOT_FOUND_OR_NOT_IN_CHAT}":"You are not currently in this chat.", - "{CHAT_PLEASE_PROVIDE_VALID_CHANNEL_DATA}":"You did not specify valid chat metadata! Please do chat.create{id:\"your_id\", name:\"Your chat\", topic:\"Your chat's topic\"}.", - "{UPGRADE_PROGRESS}":"Upgrade progress", - "{WIN_PROVIDEID}":"Please provide a valid Window ID from win.list.", - "{WIN_CANTCLOSETERMINAL}":"You cannot close this terminal.", - "{WELCOME_TO_SHIFTORIUM}":"Welcome to the Shiftorium", - "{SUCCESSFULLY_CREATED_CHAT}":"Successfully created chat. Use chat.join{id:\"chat_id_here\"} to join it.", - "{CHAT_HAS_JOINED}":"has joined the chat.", - "{HAS_LEFT_CHAT}":"has left the chat.", - "{SHIFTORIUM_EXP}":"The Shiftorium is your one-stop-shop for ShiftOS system enhancements, upgrades and applications. - - You can buy upgrades in the Shiftorium using a currency called Codepoints, which you can earn by doing various tasks within ShiftOS, such as playing Pong, stealing them from other users, and finding ways to make your own. It's up to you how you get your Codepoints. - - You can then use them to buy new applications, features, enhancements and upgrades for ShiftOS that make the user experience a lot better. Be careful though, buying too many system enhancements without buying new ways of earning Codepoints first can leave you in the dust and unable to upgrade the system. - - Anyways, feel free to browse from our wonderful selection! You can see a list of available upgrades on the left, as well as a progress bar showing how much you've upgraded the system compared to how much you still can.", - "{PONG_WELCOME}":"Welcome to Pong.", - "{PONG_DESC}":"Pong is an arcade game where your goal is to get the ball past the opponent paddle while keeping it from getting past yours. - - In ShiftOS, Pong is modified - you only have one chance, the game is divided into 60 second levels, and you can earn Codepoints by surviving a level, and beating the opponent.", - "{NO_APP_TO_OPEN}":"No app found for this file!", - "{NO_APP_TO_OPEN_EXP}":"File Skimmer could not find an application that can open this file.", - "{CLIENT_DIAGNOSTICS}":"Client diagnostics", - "{GUID}":"GUID", - "{CLIENT_DATA}":"Client data", - "{CLOSE}":"Close", - "{LOAD_DEFAULT}":"Load default", - "{IMPORT}":"Import", - "{EXPORT}":"Export", - "{APPLY}":"Apply", - "{TEMPLATE}":"Template", - "{H_VEL}":"Horizontal velocity", - "{V_VEL}":"Vertical velocity", - "{LEVEL}":"Level", - "{UPGRADE_DEVELOPMENT}":"Development Upgrade", - "{UPGRADE_DEVELOPMENT_DESCRIPTION}":"Development Upgrade Don't Buy", - "{SECONDS_LEFT}":"seconds left", - "{CASH_OUT_WITH_CODEPOINTS}":"Cash out with your codepoints", - "{PONG_PLAY_ON_FOR_MORE}":"Play on for more!", - "{YOU_REACHED_LEVEL}":"You've reached level", - "{PONG_BEAT_AI_REWARD}":"Reward for beating AI (CP)", - "{PONG_BEAT_AI_REWARD_SECONDARY}":"Codepoints for beating AI:", - "{CODEPOINTS_FOR_BEATING_LEVEL}":"Codepoints for beating level", - "{YOU_WON}":"You won", - "{YOU_LOSE}":"You lose", - "{TRY_AGAIN}":"Try again", - "{CODEPOINTS_SHORT}":"CP", - "{TERMINAL_FORMATTING_DRIVE}":"Formatting drive... %percent %", - "{INSTALLING_SHIFTOS}":"Installing ShiftOS on %domain.", - "{YOU_MISSED_OUT_ON}":"You missed out on", - "{BUT_YOU_GAINED}":"But you gained", - "{PONG_PLAYON_DESC}":"Or do you want to try your luck on the next level to increase your reward?", - "{PONG_CASHOUT_DESC}":"Would you like the end the game now and cash out with your reward?", - "{INITIAL_H_VEL}":"Initial H Vel", - "{INITIAL_V_VEL}":"Initial V Vel", - "{INC_H_VEL}":"Increment H Vel", - "{INC_V_VEL}":"Increment V Vel", - "{MULTIPLAYER_ONLY}":"Program not compatible with single-user domain.", - "{MULTIPLAYER_ONLY_EXP}":"This program cannot run within a single-user domain. You must be within a multi-user domain to use this program.", - "{SHIFTER_SKIN_APPLIED}":"Shifter - Settings applied!", - "{YOU_HAVE_EARNED}":"You have earned", - "{CREATING_PATH}":"Creating directory: %path", - "{CREATING_FILE}":"Creating file: %path", - "{SHIFTORIUM_HELP_DESCRIPTION}": "Help Descriptions", - "{CREATING_USER}":"Creating user %username", - "{SEPERATOR}":" - ", - "{NAMESPACE}":"Namespace ", - "{COMMAND}": "| Command ", - "{SHIFTOS_HAS_BEEN_INSTALLED}":"ShiftOS has been installed on %domain.", - "{WARN}": "WARN: ", - "{ERROR}": "!ERROR! ", - "{OBSOLETE_CHEATS_FREECP}": "The %ns.%cmd command is obsolete and has been replaced with %newcommand", - "{REBOOTING_SYSTEM}":"Rebooting system in %i seconds...", - "{ERROR_ARGUMENT_REQUIRED}": "You must supply an %argument value", - "{ERROR_ARGUMENT_REQUIRED_NO_USAGE}": "You are missing some arguments.", - "{GENERATING_PATHS}":"Generating paths...", - "{ERROR_COMMAND_WRONG}": "Check your syntax and try again", - "{LOGIN_EXP}": "Login as the admin of the multi user domain.", - - "{USAGE}": "Usage: ", - - "{NAMESPACE_SOS_DESCRIPTION}":"The ShiftOS Namespace", - "{COMMAND_HELP_USAGE}":"%ns.%cmd{[topic:]}", - "{COMMAND_HELP_DESCRIPTION}":"Lists all commands", - "{COMMAND_SOS_SHUTDOWN_USAGE}":"%ns.%cmd", - "{COMMAND_SOS_SHUTDOWN_DESCRIPTION}":"Saves and shuts down ShiftOS", - "{COMMAND_SOS_STATUS_USAGE}":"%ns.%cmd", - "{COMMAND_SOS_STATUS_DESCRIPTION}":"Displays how many codepoints you have", - "{COMMAND_SOS_LANG_USAGE}":"%ns.%cmd{language:\"deutsch\"}", - "{COMMAND_SOS_LANG_DESCRIPTION}":"Change the language.", - "{COMMAND_DEV_CRASH_USAGE}":"%ns.%cmd", - "{COMMAND_DEV_CRASH_DESCRIPTION}":"Shuts down ShiftOS forcefully", - "{COMMAND_DEV_UNLOCKEVERYTHING_USAGE}":"%ns.%cmd", - "{COMMAND_DEV_UNLOCKEVERYTHING_DESCRIPTION}":"Unlocks all shiftorium upgrades", - "{COMMAND_DEV_FREECP_USAGE}":"%ns.%cmd{amount:1000}", - "{COMMAND_DEV_FREECP_DESCRIPTION}":"Gives [amount] codepoints", - "{COMMAND_TRM_CLEAR_USAGE}":"%ns.%cmd", - "{COMMAND_TRM_CLEAR_DESCRIPTION}":"Clears the terminal", - "{COMMAND_SHIFTORIUM_BUY_USAGE}":"%ns.%cmd{upgrade:}", - "{COMMAND_SHIFTORIUM_BUY_DESCRIPTION}":"Buys [upgrade]", - "{COMMAND_SHIFTORIUM_LIST_USAGE}":"%ns.%cmd", - "{COMMAND_SHIFTORIUM_LIST_DESCRIPTION}":"Lists the upgrades that you can get", - "{COMMAND_SHIFTORIUM_INFO_USAGE}":"%ns.%cmd{upgrade:}", - "{COMMAND_SHIFTORIUM_INFO_DESCRIPTION}":"Gives a description about an upgrade", - "{COMMAND_DEV_MULTARG_USAGE}":"%ns.%cmd{id:,name:,type:}", - "{COMMAND_DEV_MULTARG_DESCRIPTION}":"A command which requiers multiple arguments", + //Command data strings + "{COM_STATUS}": "ShiftOS build %version\r\n\r\nCodepoints: %cp \r\n Upgrades: %installed installed, %available available\r\n\r\n", + "{COM_UPGRADEINFO}": "%category: %name - %cost Codepoints.\r\n\r\n%description\r\n\r\nUpgrade ID: %id", - "{ERR_COMMAND_NOT_FOUND}":"Command not found.", - "{ERROR_EXCEPTION_THROWN_IN_METHOD}":"An error occurred within the command. Error details:", - "{MUD_ERROR}":"MUD error", - - "{PROLOGUE_NO_USER_DETECTED}":"No user detected. Please enter a username.", - "{PROLOGUE_BADUSER}":"Invalid username detected.", - "{PROLOGUE_NOSPACES}":"Usernames must not contain spaces.", - "{PROLOGUE_PLEASE_ENTER_USERNAME}":"Please enter a valid username. Blank usernames are not permitted.", + //Terminal Command Descriptions + //These strings show up when running the "commands" command in your Terminal. + "{DESC_CLEAR}": "Clears the screen of the current Terminal.", + "{DESC_SETSFXENABLED}": "Sets whether or not system sounds are enabled.", + "{DESC_SETMUSICENABLED}": "Sets whether or not music is enabled in ShiftOS.", + "{DESC_SETVOLUME}": "Sets the volume of sounds and music if they're enabled.", + "{DESC_SHUTDOWN}": "Safely shuts down your computer.", + "{DESC_LANG}": "Change the system language of ShiftOS.", + "{DESC_COMMANDS}": "Shows a list of Terminal commands inside ShiftOS.", + "{DESC_HELP}": "Type this command to get general help with using ShiftOS.", + "{DESC_SAVE}": "Saves the in-memory configuration of ShiftOS.", + "{DESC_STATUS}": "Shows basic status information such as how many Codepoints you have and your current objective.", + "{DESC_BUY}": "Buys the specified Shiftorium upgrade.", + "{DESC_BULKBUY}": "Buys the specified Shiftorium upgrades in bulk.", + "{DESC_UPGRADEINFO}": "Shows information about the specified Shiftorium upgrade.", + "{DESC_UPGRADECATEGORIES}": "Shows all the available Shiftorium categories and how many upgrades are available in them.", + "{DESC_UPGRADES}": "Shows a list of available Shiftorium upgrades.", + "{DESC_PROCESSES}": "Shows a list of currently running app processes.", + "{DESC_PROGRAMS}": "Shows a list of programs you can run.", + "{DESC_CLOSE}": "Closes the specified application window.", + "{DESC_ADDUSER}": "Add a user to your system.", + "{DESC_REMOVEUSER}": "Remove a user from your computer.", + "{DESC_SETUSERPERMISSIONS}": "Set the permissions of a user.", + "{DESC_USERS}": "Lists all users on your computer.", + "{DESC_SU}": "Change your identity to another user's.", + "{DESC_PASSWD}": "Change your user account password.", - "{SHIFTORIUM_NOTENOUGHCP}":"Not enough codepoints: ", - "{SHIFTORIUM_TRANSFERRED_FROM}":"Received Codepoints from", - "{SHIFTORIUM_TRANSFERRED_TO}":"Transferred Codepoints to", + //Window titles. + "{TITLE_PONG_YOULOSE}": "You lose", + "{TITLE_CODEPOINTSTRANSFERRED}": "Codepoints transferred.", + "{TITLE_INVALIDPORT}": "Invalid port number.", - "{SE_SAVING}":"Saving game to disk", - "{SE_TIPOFADVICE}":"Tip of advice: ShiftOS will always save your game after big events or when you shut down the operating system. You can also invoke a save yourself using 'sos.save'.", + //Infobox prompt messages + "{PROMPT_PONGLOST}": "You lost this game of Pong. Guess you should've cashed out...", + "{PROMPT_CODEPOINTSTRANSFERRED}": "%transferrer has transferred %amount Codepoints to your system.", + "{PROMPT_INVALIDPORT}": "The Digital Society Port must be a valid whole number between 0 and 65535.", - "{STORY_WELCOME}":"Welcome to ShiftOS", - "{STORY_SENTIENCEUNKNOWN}":"Your sentience is currently unknown. Please strike the Enter key to prove you are alive.", + //Pong + "{PONG_LEVELREACHED}": "You've reached level %level!", + "{PONG_BEATAI}": "You've beaten the opponent! %amount Codepoints!", + "{PONG_STATUSCP}": "Codepoints: %cp", + "{PONG_STATUSLEVEL}": "Level %level. %time seconds to go!", + "{PONG_PLAY}": "Play some Pong!", + "{PONG_DESC}": "Pong is the modern-day recreation of the classic 70s game called, you guessed it, Pong.\r\n\r\nIn Pong, you must try your best to keep the fast-moving ball from going past your side of the screen using your mouse to move your paddle in the way of the ball, while getting the ball to go past the opponent's paddle.\r\n\r\nOnce you start Pong, you have 60 seconds to beat the opponent and survive as much as possible. The game will get faster as you play, and the more 60-second levels you play, the more Codepoints you'll earn. If you lose the level, you will start back at Level 1 with 0 Codepoints. At the end of the level, you may choose to cash out or play on.", + "{PONG_WELCOME}": "Welcome to Pong.", + "{PONG_BEATLEVELDESC}": "You have survived this level of Pong. You now have a chance to cash out your Codepoints or play on for more.", + "{PONG_PLAYON}": "Play on", + "{PONG_CASHOUT}": "Cash out", - "{SENTIENCE_BASIC}":"Sentience: Basic - User can respond to basic instructions.", - "{SENTIENCE_BASICPLUS}":"Sentience: Basic+ - User can invoke commands within the ecosystem.", - "{SENTIENCE_POSSIBLEHUMAN}":"Sentience: Possible human - user can perform actions based on a choice.", - "{SENTIENCE_POSSIBLEHUMANPLUS}":"Sentience: Possible human+ - user can infer, and can pass arguments.", - "{SENTIENCE_HUMAN}":"Sentience: Human. Thanks for your patience.", - "{SENTIENCE_INVALIDPASSWORD}":"The password you entered is invalid.", - - "{ARGS_PASSWORD}":"password", + //Main menu tip messages - "{SHIFTOS_PLUS_MOTTO}":"ShiftOS, Shift it YOUR way.", - "{SHIFTOS_VERSION_INFO}":"ShiftOS Version: ", - "{USER_NAME}":"Username", - "{DISCOURSE_INTEGRATION}":"Discourse Integration", - "{SYSTEM_NAME}":"System Name", - "{USER_INFO}":"User Information", - "{SELECT_LANG}":"Select language", - "{WELCOME_TO_SHIFTOS}":"Welcome to ShiftOS Alpha!", - "{CREATE}":"Create", - "{INSTALL}":"Install", - "{ALIAS}":"Alias:", - "{OBSOLETE_SYS_SHUTDOWN}":"sys.shutdown is obsolete", - "{PY_EXCEPTION}":"There was an error running python code.", - "{LUA_ERROR}":"There was an error running lua code.", - "{LANGUAGE_CHANGED}":"The language has been changed. Please restart ShiftOS for changes to take full effect.", + //Main menu - Settings + "{MAINMENU_DSADDRESS}": "Digital Society address: ", + "{MAINMENU_DSPORT": "Digital Society port: ", - "{TERMINAL_NAME}":"Terminal", - "{ARTPAD_NAME}":"Artpad", - "{PONG_NAME}":"Pong", - "{WAV_PLAYER_NAME}":"WAV Player", - "{SHIFTORIUM_NAME}":"Shiftorium", - "{TEXTPAD_NAME}":"TextPad", - "{VIRUS_SCANNER_NAME}":"Virus Scanner", - "{SKIN_LOADER_NAME}":"Skin Loader", - "{SHIFTER_NAME}":"Shifter", - "{NAME_CHANGER_NAME}":"Name Changer", - "{MUD_PASSWORD_CRACKER_NAME}":"Multi-User Domain Password Cracker v1.0", - "{MUD_CONTROL_CENTRE_NAME}":"MUD Control Centre", - "{MUD_AUTHENTICATOR_NAME}":"Multi-User Domain Admin Panel", - "{GRAPHIC_PICKER_NAME}":"Graphic Picker", - "{FILE_SKIMMER_NAME}":"File Skimmer", - "{FILE_DIALOG_NAME}":"File Dialog", - "{DIALOG_NAME}":"Dialog", - "{COLOR_PICKER_NAME}":"Color Picker", - "{CHAT_NAME}":"Chat", - "{NOTIFICATIONS}":"Notifications", -} + //Main Menu - General text + "{MAINMENU_TITLE}": "Main menu", + "{MAINMENU_CAMPAIGN}": "Campaign", + "{MAINMENU_SANDBOX}": "Sandbox", + "{MAINMENU_NEWGAME}": "New game", +} \ No newline at end of file diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index c2e414d..3a2b79a 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -38,118 +38,26 @@ using Newtonsoft.Json; using System.IO.Compression; using ShiftOS.Objects; -using Discoursistency.Base.Models.Authentication; using ShiftOS.Engine.Scripting; using ShiftOS.Objects.ShiftFS; namespace ShiftOS.Engine { - [RequiresUpgrade("desktop;wm_free_placement")] - public static class InfoboxDebugCommands - { - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("show")] - public static bool ShowInfo(Dictionary args) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.Show(args["title"].ToString(), args["msg"].ToString()); - })); - return true; - } - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("yesno")] - public static bool ShowYesNo(Dictionary args) - { - bool forwarding = TerminalBackend.IsForwardingConsoleWrites; - var fGuid = TerminalBackend.ForwardGUID; - Action callback = (result) => - { - TerminalBackend.IsForwardingConsoleWrites = forwarding; - TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - string resultFriendly = (result == true) ? "yes" : "no"; - Console.WriteLine($"{SaveSystem.CurrentUser.Username} says {resultFriendly}."); - TerminalBackend.IsForwardingConsoleWrites = false; - }; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.PromptYesNo(args["title"].ToString(), args["msg"].ToString(), callback); - - })); - return true; - } - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("text")] - public static bool ShowText(Dictionary args) - { - bool forwarding = TerminalBackend.IsForwardingConsoleWrites; - var fGuid = TerminalBackend.ForwardGUID; - Action callback = (result) => - { - TerminalBackend.IsForwardingConsoleWrites = forwarding; - TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - Console.WriteLine($"{SaveSystem.CurrentUser.Username} says \"{result}\"."); - TerminalBackend.IsForwardingConsoleWrites = false; - }; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.PromptText(args["title"].ToString(), args["msg"].ToString(), callback); - })); - return true; - } - - } - - public static class AudioCommands - { - [Command("setvol", description = "Set the volume of the system audio to anywhere between 0 and 100.")] - [RequiresArgument("value")] - [RequiresUpgrade("audio_volume")] - public static bool SetVolume(Dictionary args) - { - int val = Convert.ToInt32(args["value"].ToString()); - float volume = (val / 100F); - AudioManager.SetVolume(volume); - return true; - } - [RequiresUpgrade("audio_volume")] - [Command("mute", description = "Sets the volume of the system audio to 0")] - public static bool MuteAudio() - { - AudioManager.SetVolume(0); - return true; - } - } - [TutorialLock] public static class TerminalCommands { - [Command("clear")] + [Command("clear", description = "{DESC_CLEAR}")] public static bool Clear() { AppearanceManager.ConsoleOut.Clear(); return true; } - - [Command("echo")] - [RequiresArgument("text")] - public static bool Echo(Dictionary args) - { - Console.WriteLine(args["text"]); - return true; - } } public static class ShiftOSCommands { - [Command("setsfxenabled", description = "Set whether or not sound effects are enabled in the system.")] + [Command("setsfxenabled", description = "{DESC_SETSFXENABLED}")] [RequiresArgument("value")] public static bool SetSfxEnabled(Dictionary args) { @@ -161,14 +69,14 @@ namespace ShiftOS.Engine } catch { - Console.WriteLine("Error: Value must be either true or false."); + Console.WriteLine("{ERR_BADBOOL}"); } return true; } - [Command("setmusicenabled", description = "Set whether or not music is enabled in the system.")] + [Command("setmusicenabled", description = "{DESC_SETMUSICENABLED}")] [RequiresArgument("value")] public static bool SetMusicEnabled(Dictionary args) { @@ -180,14 +88,14 @@ namespace ShiftOS.Engine } catch { - Console.WriteLine("Error: Value must be either true or false."); + Console.WriteLine("{ERR_BADBOOL}"); } return true; } - [Command("setsfxvolume", description ="Set the system sound volume to a value between 1 and 100.")] + [Command("setvolume", description ="{DESC_SETVOLUME}")] [RequiresArgument("value")] public static bool SetSfxVolume(Dictionary args) { @@ -199,13 +107,13 @@ namespace ShiftOS.Engine } else { - Console.WriteLine("Volume must be between 0 and 100!"); + Console.WriteLine("{ERR_BADPERCENT}"); } return true; } [RemoteLock] - [Command("shutdown")] + [Command("shutdown", description = "{DESC_SHUTDOWN}")] public static bool Shutdown() { TerminalBackend.InvokeCommand("sos.save"); @@ -213,7 +121,7 @@ namespace ShiftOS.Engine return true; } - [Command("lang", "{COMMAND_SOS_LANG_USAGE}", "{COMMAND_SOS_LANG_DESCRIPTION}")] + [Command("lang", description = "{DESC_LANG}")] [RequiresArgument("language")] public static bool SetLanguage(Dictionary userArgs) { @@ -221,20 +129,17 @@ namespace ShiftOS.Engine { string lang = ""; - if (userArgs.ContainsKey("language")) - lang = (string)userArgs["language"]; - else - throw new Exception("You must specify a valid 'language' value."); - + lang = (string)userArgs["language"]; + if (Localization.GetAllLanguages().Contains(lang)) { SaveSystem.CurrentSave.Language = lang; SaveSystem.SaveGame(); - Console.WriteLine("{LANGUAGE_CHANGED}"); + Console.WriteLine("{RES_LANGUAGE_CHANGED}"); return true; } - throw new Exception($"Couldn't find language with ID: {lang}"); + throw new Exception("{ERR_NOLANG}"); } catch { @@ -242,11 +147,11 @@ namespace ShiftOS.Engine } } - [Command("commands", "", "{COMMAND_COMMANDS_DESCRIPTION}")] + [Command("commands", "", "{DESC_COMMANDS}")] public static bool Commands() { var sb = new StringBuilder(); - sb.AppendLine("Commands"); + sb.AppendLine("{GEN_COMMANDS}"); sb.AppendLine("================="); sb.AppendLine(); //print all unique namespaces. @@ -254,7 +159,7 @@ namespace ShiftOS.Engine { sb.Append(n.CommandInfo.name); if (!string.IsNullOrWhiteSpace(n.CommandInfo.description)) - if (Shiftorium.UpgradeInstalled("help_descriptions")) + if (Shiftorium.UpgradeInstalled("help_description")) sb.Append(" - " + n.CommandInfo.description); sb.AppendLine(); } @@ -264,7 +169,7 @@ namespace ShiftOS.Engine return true; } - [Command("help", description = "Type this command to list all the things you can do in ShiftOS.")] + [Command("help", description = "{DESC_HELP}")] public static bool Help() { Commands(); @@ -274,7 +179,7 @@ namespace ShiftOS.Engine [MultiplayerOnly] - [Command("save")] + [Command("save", description = "{DESC_SAVE}")] public static bool Save() { SaveSystem.SaveGame(); @@ -282,19 +187,23 @@ namespace ShiftOS.Engine } [MultiplayerOnly] - [Command("status")] + [Command("status", description = "{DESC_STATUS}")] public static bool Status() { - string status = $@"ShiftOS version {Assembly.GetExecutingAssembly().GetName().Version.ToString()} + string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); -Codepoints: {SaveSystem.CurrentSave.Codepoints} -Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, - {Shiftorium.GetAvailable().Length} available + string cp = SaveSystem.CurrentSave.Codepoints.ToString(); + string installed = SaveSystem.CurrentSave.CountUpgrades().ToString(); + string available = Shiftorium.GetAvailable().Length.ToString(); -"; - - Console.WriteLine(status); - Console.WriteLine("Objectives:"); + Console.WriteLine(Localization.Parse("{COM_STATUS}", new Dictionary + { + ["%cp"] = cp, + ["%version"] = version, + ["%installed"] = installed, + ["%available"] = available + })); + Console.WriteLine("{GEN_OBJECTIVES}"); try { if (Story.CurrentObjectives.Count > 0) @@ -309,12 +218,12 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, } else { - Console.WriteLine(" - No objectives are running. Check back later!"); + Console.WriteLine("{RES_NOOBJECTIVES}"); } } catch { - Console.WriteLine(" - No objectives are running. Check back later!"); + Console.WriteLine("{RES_NOOBJECTIVES}"); } return true; } @@ -323,7 +232,7 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, [MultiplayerOnly] public static class ShiftoriumCommands { - [Command("buy")] + [Command("buy", description = "{DESC_BUY}")] [RequiresArgument("upgrade")] public static bool BuyUpgrade(Dictionary userArgs) { @@ -331,30 +240,31 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, { string upgrade = ""; - if (userArgs.ContainsKey("upgrade")) - upgrade = (string)userArgs["upgrade"]; - else - throw new Exception("You must specify a valid 'upgrade' value."); + upgrade = (string)userArgs["upgrade"]; - foreach (var upg in Shiftorium.GetAvailable()) + var upg = Shiftorium.GetAvailable().FirstOrDefault(x => x.ID == upgrade); + if(upg != null) { - if (upg.ID == upgrade) - { - Shiftorium.Buy(upgrade, upg.Cost); - return true; - } + if (Shiftorium.Buy(upg.ID, upg.Cost) == true) + Console.WriteLine("{RES_UPGRADEINSTALLED}"); + else + Console.WriteLine("{ERR_NOTENOUGHCODEPOINTS}"); + } + else + { + Console.WriteLine("{ERR_NOUPGRADE}"); } - throw new Exception($"Couldn't find upgrade with ID: {upgrade}"); } catch { - return false; + Console.WriteLine("{ERR_GENERAL}"); } + return true; } [RequiresUpgrade("shiftorium_bulk_buy")] - [Command("bulkbuy")] + [Command("bulkbuy", description = "{DESC_BULKBUY}")] [RequiresArgument("upgrades")] public static bool BuyBulk(Dictionary args) { @@ -368,15 +278,11 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, BuyUpgrade(dict); } } - else - { - throw new Exception("Please specify a list of upgrades in the 'upgrades' argument. Each upgrade is separated by a comma."); - } return true; } - [Command("upgradeinfo", description ="Shows information about a specific upgrade.")] + [Command("upgradeinfo", description ="{DESC_UPGRADEINFO}")] [RequiresArgument("upgrade")] public static bool ViewInfo(Dictionary userArgs) { @@ -384,29 +290,26 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, { string upgrade = ""; - if (userArgs.ContainsKey("upgrade")) - upgrade = (string)userArgs["upgrade"]; - else - throw new Exception("You must specify a valid 'upgrade' value."); + upgrade = (string)userArgs["upgrade"]; foreach (var upg in Shiftorium.GetDefaults()) { if (upg.ID == upgrade) { - Console.WriteLine($@"Information for {upgrade}: - -{upg.Category}: {upg.Name} - {upg.Cost} Codepoints ------------------------------------------------------- + Console.WriteLine(Localization.Parse("{COM_UPGRADEINFO}", new Dictionary + { + ["%id"] = upg.ID, + ["%category"] = upg.Category, + ["%name"] = upg.Name, + ["%cost"] = upg.Cost.ToString(), + ["%description"] = upg.Description + })); -{upg.Description} - -To buy this upgrade, run: -shiftorium.buy{{upgrade:""{upg.ID}""}}"); return true; } } - throw new Exception($"Couldn't find upgrade with ID: {upgrade}"); + throw new Exception("{ERR_NOUPGRADE}"); } catch { @@ -414,17 +317,21 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); } } - [Command("upgradecategories", description = "Shows all available Shiftorium upgrade categories, and how many upgrades are available in them.")] + [Command("upgradecategories", description = "{DESC_UPGRADECATEGORIES}")] public static bool ListCategories() { foreach(var cat in Shiftorium.GetCategories()) { - Console.WriteLine($"{cat} - {Shiftorium.GetAvailable().Where(x=>x.Category==cat).Count()} upgrades"); + Console.WriteLine(Localization.Parse("{SHFM_CATEGORY}", new Dictionary + { + ["%name"] = cat, + ["%available"] = Shiftorium.GetAvailable().Where(x=>x.Category==cat).Count().ToString() + })); } return true; } - [Command("upgrades", description ="Lists all available Shiftorium upgrades.")] + [Command("upgrades", description ="{DESC_UPGRADES}")] public static bool ListAll(Dictionary args) { try @@ -449,11 +356,11 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); { ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("Shiftorium Query Error"); + Console.WriteLine("{SHFM_QUERYERROR}"); Console.WriteLine(); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.WriteLine("Either there are no upgrades in the category \"" + cat + "\" or the category was not found."); + Console.WriteLine("{ERR_EMPTYCATEGORY}"); return true; } upglist = Shiftorium.GetAvailable().Where(x => x.Category == cat); @@ -464,11 +371,11 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); { ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("No upgrades available!"); + Console.WriteLine("{SHFM_NOUPGRADES}"); Console.WriteLine(); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.WriteLine("You have installed all available upgrades for your system. Please check back later for more."); + Console.WriteLine("{ERR_NOMOREUPGRADES}"); return true; } @@ -482,11 +389,13 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); upgrades.Add(upg.ID, upg.Cost); } - Console.WriteLine("ID".PadRight((maxLength + 5) - 2) + "Cost (Codepoints)"); - foreach (var upg in upgrades) { - Console.WriteLine(upg.Key.PadRight((maxLength + 5) - upg.Key.Length) + " " + upg.Value.ToString()); + Console.WriteLine(Localization.Parse("{SHFM_UPGRADE}", new Dictionary + { + ["%id"] = upg.Key, + ["%cost"] = upg.Value.ToString() + })); } return true; } @@ -500,14 +409,11 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); public static class WindowCommands { - - - [RemoteLock] - [Command("processes", description = "Shows all running applications.")] + [Command("processes", description = "{DESC_PROCESSES}")] public static bool List() { - Console.WriteLine("Window ID\tName"); + Console.WriteLine("{GEN_CURRENTPROCESSES}"); foreach (var app in AppearanceManager.OpenForms) { //Windows are displayed the order in which they were opened. @@ -516,17 +422,17 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); return true; } - [Command("programs", description = "Lists all the programs installed in ShiftOS.")] + [Command("programs", description = "{DESC_PROGRAMS}")] public static bool Programs() { - Console.WriteLine("Programs:"); + Console.WriteLine("{GEN_PROGRAMS}"); Console.WriteLine("==============="); Console.WriteLine(); foreach(var cmd in TerminalBackend.Commands.Where(x=>x is TerminalBackend.WinOpenCommand && Shiftorium.UpgradeInstalled(x.Dependencies)).OrderBy(x => x.CommandInfo.name)) { Console.Write(" - " + cmd.CommandInfo.name); if (!string.IsNullOrWhiteSpace(cmd.CommandInfo.description)) - if (Shiftorium.UpgradeInstalled("help_descriptions")) + if (Shiftorium.UpgradeInstalled("help_description")) Console.Write(": " + cmd.CommandInfo.description); Console.WriteLine(); } @@ -534,7 +440,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); } [RemoteLock] - [Command("close", usage = "{win:integer32}", description ="Closes the specified window.")] + [Command("close", usage = "{win:integer32}", description ="{DESC_CLOSE}")] [RequiresArgument("win")] [RequiresUpgrade("close_command")] public static bool CloseWindow(Dictionary args) @@ -545,11 +451,14 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); string err = null; if (winNum < 0 || winNum >= AppearanceManager.OpenForms.Count) - err = "The window number must be between 0 and " + (AppearanceManager.OpenForms.Count - 1).ToString() + "."; + err = Localization.Parse("{ERR_BADWINID}", new Dictionary + { + ["%max"] = (AppearanceManager.OpenForms.Count - 1).ToString() + }); if (string.IsNullOrEmpty(err)) { - Console.WriteLine($"Closing {AppearanceManager.OpenForms[winNum].Text}..."); + Console.WriteLine("{RES_WINDOWCLOSED}"); AppearanceManager.Close(AppearanceManager.OpenForms[winNum].ParentWindow); } else diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 97cc26e..306a49b 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -126,9 +126,9 @@ namespace ShiftOS.Engine } Thread.Sleep(350); - Console.WriteLine("ShiftKernel v0.4.2"); + Console.WriteLine("{MISC_KERNELVERSION}"); Thread.Sleep(50); - Console.WriteLine("(MIT) DevX 2017, Very Little Rights Reserved"); + Console.WriteLine("Copyright (c) 2018 DevX. Licensed under MIT."); Console.WriteLine(""); Console.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); Console.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); @@ -139,39 +139,20 @@ namespace ShiftOS.Engine Console.WriteLine("SOFTWARE."); Console.WriteLine(""); Thread.Sleep(250); - Console.WriteLine("[init] Kernel boot complete."); - Console.WriteLine("[sfs] Loading SFS driver v3"); + Console.WriteLine("{MISC_KERNELBOOTED}"); + Console.WriteLine("{MISC_SHIFTFSDRV}"); Thread.Sleep(350); - Console.WriteLine("[sfs] 4096 blocks read."); - if (loadingJoke1 == 0) - Console.WriteLine("[sos] Getting good and ready..."); - if (loadingJoke1 == 1) - Console.WriteLine("[sos] Shifting the OS..."); - if (loadingJoke1 == 2) - Console.WriteLine("[sos] Placing things everywhere..."); - if (loadingJoke1 == 3) - Console.WriteLine("[sos] Making an an errors..."); - if (loadingJoke1 == 4) - Console.WriteLine("[sos] Testing to see if this OS is indeed on..."); - if (loadingJoke1 == 5) - Console.WriteLine("[sos] Calming user..."); - if (loadingJoke1 == 6) - Console.WriteLine("[sos] Cleaning room..."); - if (loadingJoke1 == 7) - Console.WriteLine("[sos] Checking for piracy..."); - if (loadingJoke1 == 8) - Console.WriteLine("[sos] Getting Jim that important office memo..."); - if (loadingJoke1 == 9) - Console.WriteLine("[sos] Using imagination..."); + Console.WriteLine("{MISC_SHIFTFSBLOCKSREAD}"); + Console.WriteLine("{MISC_LOADINGMSG1_" + loadingJoke1 + "}"); Thread.Sleep(500); - Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); + Console.WriteLine("{MISC_LOADINGCONFIG}"); Thread.Sleep(30); - Console.WriteLine("[termdb] Building command database from filesystem..."); + Console.WriteLine("{MISC_BUILDINGCMDS}"); TerminalBackend.PopulateTerminalCommands(); if (IsSandbox == false) { - Console.WriteLine("[inetd] Connecting to network..."); + Console.WriteLine("{MISC_CONNECTINGTONETWORK}"); Ready = false; @@ -192,28 +173,9 @@ namespace ShiftOS.Engine { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("[inetd] Connection successful."); + Console.WriteLine("{INIT_CONNECTIONSUCCESSFUL}"); Thread.Sleep(100); - if (loadingJoke2 == 0) - Console.WriteLine("[sos] Running final checks (gotta be sure!)..."); - if (loadingJoke2 == 1) - Console.WriteLine("[sos] Fixing the time because we think we got it wrong..."); - if (loadingJoke2 == 2) - Console.WriteLine("[sos] Fun Fact: there is a 12% chance you will read this..."); - if (loadingJoke2 == 3) - Console.WriteLine("[sos] Fixing sloppy code..."); - if (loadingJoke2 == 4) - Console.WriteLine("[sos] Welcoming new users..."); - if (loadingJoke2 == 5) - Console.WriteLine("[sos] Taking inspiration from GMod..."); - if (loadingJoke2 == 6) - Console.WriteLine("[sos] Getting help..."); - if (loadingJoke2 == 7) - Console.WriteLine("[sos] I'm very clevery guy..."); - if (loadingJoke2 == 8) - Console.WriteLine("[sos] Waiting a bit..."); - if (loadingJoke2 == 9) - Console.WriteLine("[sos] Do a digital dancing..."); + Console.WriteLine("{MISC_LOADINGMSG2_" + loadingJoke2 + "}"); Thread.Sleep(500); }; @@ -227,12 +189,12 @@ namespace ShiftOS.Engine { Thread.Sleep(10); } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); + Console.WriteLine("{MISC_DHCPHANDSHAKEFINISHED}"); FinishBootstrap(); } else { - Console.WriteLine("[inetd] No suitable network interface card found, skipping network connection."); + Console.WriteLine("{MISC_NONETWORK}"); FinishBootstrap(); } } @@ -259,7 +221,7 @@ namespace ShiftOS.Engine } else { - Console.WriteLine("[inetd] Sandbox mode initiating..."); + Console.WriteLine("{MISC_SANDBOXMODE}"); CurrentSave = new Save { IsSandbox = true, @@ -328,8 +290,6 @@ namespace ShiftOS.Engine /// private static void FinishBootstrap() { - KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); - ServerMessageReceived savehandshake = null; savehandshake = (msg) => @@ -343,7 +303,7 @@ namespace ShiftOS.Engine } catch { - Console.WriteLine("[system] [SEVERE] Cannot parse configuration file."); + Console.WriteLine("{ENGINE_CANNOTLOADSAVE}"); oobe.PromptForLogin(); } } @@ -373,7 +333,7 @@ namespace ShiftOS.Engine Thread.Sleep(75); Thread.Sleep(50); - Console.WriteLine("[usr-man] Accepting logins on local tty 1."); + Console.WriteLine("{MISC_ACCEPTINGLOGINS}"); Sysname: bool waitingForNewSysName = false; @@ -381,16 +341,16 @@ namespace ShiftOS.Engine if (string.IsNullOrWhiteSpace(CurrentSave.SystemName)) { - Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name) => + Infobox.PromptText("{TITLE_ENTERSYSNAME}", "{PROMPT_ENTERSYSNAME}", (name) => { if (string.IsNullOrWhiteSpace(name)) - Infobox.Show("Invalid name", "Please enter a valid name.", () => + Infobox.Show("{TITLE_INVALIDNAME}", "{PROMPT_INVALIDNAME}.", () => { gobacktosysname = true; waitingForNewSysName = false; }); else if (name.Length < 5) - Infobox.Show("Value too small.", "Your system name must have at least 5 characters in it.", () => + Infobox.Show("{TITLE_VALUESMALL}", "{PROMPT_SMALLSYSNAME}", () => { gobacktosysname = true; waitingForNewSysName = false; @@ -398,11 +358,6 @@ namespace ShiftOS.Engine else { CurrentSave.SystemName = name; - if (!string.IsNullOrWhiteSpace(CurrentSave.UniteAuthToken)) - { - var unite = new Unite.UniteClient("http://getshiftos.ml", CurrentSave.UniteAuthToken); - unite.SetSysName(name); - } SaveSystem.SaveGame(); gobacktosysname = false; waitingForNewSysName = false; @@ -429,18 +384,18 @@ namespace ShiftOS.Engine `-:/++++::.` .+ydNMMMMMNNMMMMMNhs/. /yNMMmy+:-` `````.-/ohNMMms- - `oNMMh/.`:oydmNMMMMNmhs+- .+dMMm+` Welcome to ShiftOS. + `oNMMh/.`:oydmNMMMMNmhs+- .+dMMm+` {{GEN_WELCOME}} `oMMmo``+dMMMMMMMMMMMMMMMMMNh/`.sNMN+ - :NMN+ -yMMMMMMMNdhyssyyhdmNMMMMNs``sMMd. SYSTEM STATUS: + :NMN+ -yMMMMMMMNdhyssyyhdmNMMMMNs``sMMd. {{GEN_SYSTEMSTATUS}} oMMd.`sMMMMMMd+. `/MMMMN+ -mMN: ---------------------- oMMh .mMMMMMM/ `-::::-.` :MMMMMMh`.mMM: - :MMd .NMMMMMMs .dMMMMMMMMMNddMMMMMMMd`.NMN. Codepoints: {SaveSystem.CurrentSave.Codepoints} - mMM. dMMMMMMMo -mMMMMMMMMMMMMMMMMMMMMs /MMy Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed - :MMh :MMMMMMMMm` .+shmMMMMMMMMMMMMMMMN` NMN` {Shiftorium.GetAvailable().Count()} available - oMM+ sMMMMMMMMMN+` `-/smMMMMMMMMMMM: hMM: Filesystems: {Utils.Mounts.Count} filesystems mounted in memory. + :MMd .NMMMMMMs .dMMMMMMMMMNddMMMMMMMd`.NMN. {{GEN_CODEPOINTS}}: {SaveSystem.CurrentSave.Codepoints} + mMM. dMMMMMMMo -mMMMMMMMMMMMMMMMMMMMMs /MMy + :MMh :MMMMMMMMm` .+shmMMMMMMMMMMMMMMMN` NMN` + oMM+ sMMMMMMMMMN+` `-/smMMMMMMMMMMM: hMM: sMM+ sMMMMMMMMMMMMds/-` .sMMMMMMMMM/ yMM/ - +MMs +MMMMMMMMMMMMMMMMMmhs:` +MMMMMMMM- dMM- System name: {CurrentSave.SystemName.ToUpper()} - .MMm `NMMMMMMMMMMMMMMMMMMMMMo `NMMMMMMd .MMN Users: {Users.Count()} found. + +MMs +MMMMMMMMMMMMMMMMMmhs:` +MMMMMMMM- dMM- {{GEN_SYSTEMNAME}}: {CurrentSave.SystemName.ToUpper()} + .MMm `NMMMMMMMMMMMMMMMMMMMMMo `NMMMMMMd .MMN {{GEN_USERS}}: {Users.Count()}. hMM+ +MMMMMMmsdNMMMMMMMMMMN/ -MMMMMMN- yMM+ `NMN- oMMMMMd `-/+osso+- .mMMMMMN: +MMd -NMN: /NMMMm` :yMMMMMMm- oMMd` @@ -460,7 +415,7 @@ namespace ShiftOS.Engine Password = "", Permissions = UserPermissions.Root }); - Console.WriteLine("[usr-man] WARN: No users found. Creating new user with username \"root\", with no password."); + Console.WriteLine("{MISC_NOUSERS}"); } TerminalBackend.InStory = false; @@ -492,18 +447,21 @@ namespace ShiftOS.Engine int progress = 0; bool goback = false; TextSentEventHandler ev = null; + string loginstr = Localization.Parse("{GEN_LPROMPT}", new Dictionary + { + ["%sysname"] = CurrentSave.SystemName + }); ev = (text) => { if (progress == 0) { - string loginstr = CurrentSave.SystemName + " login: "; string getuser = text.Remove(0, loginstr.Length); if (!string.IsNullOrWhiteSpace(getuser)) { if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) { Console.WriteLine(); - Console.WriteLine("User not found."); + Console.WriteLine("{ERR_NOUSER}"); goback = true; progress++; TerminalBackend.TextSent -= ev; @@ -515,7 +473,7 @@ namespace ShiftOS.Engine else { Console.WriteLine(); - Console.WriteLine("Username not provided."); + Console.WriteLine("{ERR_NOUSER}"); TerminalBackend.TextSent -= ev; goback = true; progress++; @@ -523,20 +481,20 @@ namespace ShiftOS.Engine } else if (progress == 1) { - string passwordstr = "password: "; + string passwordstr = Localization.Parse("{GEN_PASSWORD}: "); string getpass = text.Remove(0, passwordstr.Length); var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); if (user.Password == getpass) { Console.WriteLine(); - Console.WriteLine("Welcome to ShiftOS."); + Console.WriteLine("{GEN_WELCOME}"); CurrentUser = user; progress++; } else { Console.WriteLine(); - Console.WriteLine("Access denied."); + Console.WriteLine("{RES_DENIED}"); goback = true; progress++; } @@ -545,7 +503,7 @@ namespace ShiftOS.Engine }; TerminalBackend.TextSent += ev; Console.WriteLine(); - Console.Write(CurrentSave.SystemName + " login: "); + Console.Write(loginstr); ConsoleEx.Flush(); while (progress == 0) { @@ -554,7 +512,7 @@ namespace ShiftOS.Engine if (goback) goto Login; Console.WriteLine(); - Console.Write("password: "); + Console.Write("{GEN_PASSWORD}: "); ConsoleEx.Flush(); while (progress == 1) Thread.Sleep(10); diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs index cac535b..7936820 100644 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -19,14 +19,14 @@ namespace ShiftOS.Engine /// /// Command arguments. /// Command result. - [Command("add", description = "Add a user to the system.", usage ="name:")] + [Command("adduser", description = "{DESC_ADDUSER}")] [RequiresArgument("name")] public static bool AddUser(Dictionary args) { string name = args["name"].ToString(); - if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==name) != null) + if (SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name) != null) { - Console.WriteLine("Error: User already exists."); + Console.WriteLine("{ERR_USERFOUND}"); return true; } @@ -37,7 +37,10 @@ namespace ShiftOS.Engine Permissions = UserPermissions.User }; SaveSystem.CurrentSave.Users.Add(user); - Console.WriteLine($"Creating new user \"{name}\" with no password and User permissions."); + Console.WriteLine(Localization.Parse("{RES_CREATINGUSER}", new Dictionary + { + { "%name", name } + })); SaveSystem.SaveGame(); return true; } @@ -48,25 +51,28 @@ namespace ShiftOS.Engine /// Command arguments. /// Command result. - [Command("remove", description = "Remove a user from the system.", usage = "name:")] + [Command("removeuser", description = "{DESC_REMOVEUSER}")] [RequiresArgument("name")] public static bool RemoveUser(Dictionary args) { string name = args["name"].ToString(); if (SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name) == null) { - Console.WriteLine("Error: User doesn't exist."); + Console.WriteLine("{ERR_NOUSER}"); return true; } var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name); - if(user.Username != SaveSystem.CurrentUser.Username) + if (user.Username != SaveSystem.CurrentUser.Username) { - Console.WriteLine("Error: Cannot remove yourself."); + Console.WriteLine("{ERR_REMOVEYOU}"); return true; } SaveSystem.CurrentSave.Users.Remove(user); - Console.WriteLine($"Removing user \"{name}\" from system..."); + Console.WriteLine(Localization.Parse("{RES_REMOVINGUSER}", new Dictionary + { + ["%name"] = name + })); SaveSystem.SaveGame(); return true; } @@ -79,7 +85,7 @@ namespace ShiftOS.Engine /// Command arguments. /// Command result. - [Command("set_acl")] + [Command("setuserpermissions", description = "{DESC_SETUSERPERMISSIONS}")] [RequiresArgument("user")] [RequiresArgument("val")] public static bool SetUserPermission(Dictionary args) @@ -92,13 +98,13 @@ namespace ShiftOS.Engine } catch { - Console.WriteLine("Error: Permission value must be an integer."); + Console.WriteLine("{ERR_BADACL}"); return true; } if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==username) == null) { - Console.WriteLine("Error: User not found."); + Console.WriteLine("{ERR_NOUSER}"); return true; } @@ -119,26 +125,26 @@ namespace ShiftOS.Engine uperm = UserPermissions.Root; break; default: - Console.WriteLine("Permission value must be between 0 and 4."); + Console.WriteLine("{ERR_BADACL}"); return true; } //Permissions are backwards... oops... if(uperm < SaveSystem.CurrentUser.Permissions) { - Console.WriteLine("Error: Cannot set user permissions to values greater than your own!"); + Console.WriteLine("{ERR_ACLHIGHERVALUE}"); return true; } var oldperm = SaveSystem.Users.FirstOrDefault(x => x.Username == username).Permissions; if (SaveSystem.CurrentUser.Permissions > oldperm) { - Console.WriteLine("Error: Can't set the permission of this user. They have more rights than you."); + Console.WriteLine("{ERR_HIGHERPERMS}"); return true; } SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == username).Permissions = uperm; - Console.WriteLine("User permissions updated."); + Console.WriteLine("{RES_ACLUPDATED}"); return true; } @@ -148,7 +154,7 @@ namespace ShiftOS.Engine /// Command arguments. /// Command result. - [Command("users", description = "Get a list of all users on the system.")] + [Command("users", description = "{DESC_USERS}")] public static bool GetUsers() { foreach (var u in SaveSystem.CurrentSave.Users) @@ -180,7 +186,7 @@ namespace ShiftOS.Engine /// /// Command arguments. /// Command result. - [Command("login", description = "Log in as another user.")] + [Command("su", description = "{DESC_SU}")] [RequiresArgument("user")] [RequiresArgument("pass")] public static bool Login(Dictionary args) @@ -191,18 +197,18 @@ namespace ShiftOS.Engine var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); if(usr==null) { - Console.WriteLine("Error: No such user."); + Console.WriteLine("{ERR_NOUSER}"); return true; } if (usr.Password != pass) { - Console.WriteLine("Access denied."); + Console.WriteLine("{RES_DENIED}"); return true; } SaveSystem.CurrentUser = usr; - Console.WriteLine("Access granted."); + Console.WriteLine("{RES_GRANTED}"); return true; } @@ -211,7 +217,7 @@ namespace ShiftOS.Engine /// /// Command arguments. /// Command result. - [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] + [Command("passwd", description ="{DESC_PASSWD}", usage ="old:,new:")] [RequiresArgument("old")] [RequiresArgument("new")] public static bool SetPassword(Dictionary args) @@ -223,12 +229,12 @@ namespace ShiftOS.Engine { SaveSystem.CurrentUser.Password = newpass; SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == SaveSystem.CurrentUser.Username).Password = newpass; - Console.WriteLine("Password set successfully."); + Console.WriteLine("{RES_PASSWD_SET}"); SaveSystem.SaveGame(); } else { - Console.WriteLine("Passwords do not match."); + Console.WriteLine("{ERR_PASSWD_MISMATCH}"); } return true; } -- cgit v1.2.3 From 44d80428b88db2d39d7e7e219d78da81cb8a68fd Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Jun 2017 17:08:21 -0400 Subject: fix some pong issues --- ShiftOS.WinForms/Applications/Pong.cs | 26 ++++++++++++++++++++------ ShiftOS.WinForms/MainMenu/MainMenu.cs | 10 +++++----- 2 files changed, 25 insertions(+), 11 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Pong.cs') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index d8f93f7..53d410e 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -65,6 +65,10 @@ namespace ShiftOS.WinForms.Applications private double xVel = 1; private double yVel = 1; + private double aiXVel = 1; + private double aiYVel = 1; + + private int paddleWidth; Timer counterTimer = null; @@ -89,7 +93,7 @@ namespace ShiftOS.WinForms.Applications xVel = -xVel; // adjust y velocity based on where the ball hit the paddle - yVel += linear((ball.Top + (ball.Height / 2)), paddle.Top, paddle.Bottom, -1, 1); + yVel = linear((ball.Top + (ball.Height / 2)), paddle.Top, paddle.Bottom, -1, 1); } public void UpdateBall() @@ -127,6 +131,10 @@ namespace ShiftOS.WinForms.Applications if (ballRect.Top <= 0 || ballRect.Bottom >= pnlcanvas.Height) yVel = -yVel; //reverse the Y velocity + //top and bottom walls - ai + if (aiBallRect.Top <= 0 || aiBallRect.Bottom >= pnlcanvas.Height) + aiYVel = -aiYVel; //reverse the Y velocity + //Left wall if (ballRect.Left <= 0) @@ -151,6 +159,8 @@ namespace ShiftOS.WinForms.Applications if (ballRect.Right >= opponentRect.Left) { Bounce(ballRect, opponentRect); + aiXVel = xVel; + aiYVel = yVel; doAi = false; } @@ -175,6 +185,8 @@ namespace ShiftOS.WinForms.Applications if (ballRect.Left <= playerRect.Right) { Bounce(ballRect, playerRect); + aiXVel = xVel; + aiYVel = yVel; //reset the ai location aiBallX = ballX; @@ -191,8 +203,8 @@ namespace ShiftOS.WinForms.Applications ballX += xVel * speedFactor; ballY += yVel * speedFactor; - aiBallX += xVel * (speedFactor * 2); - aiBallY += yVel * (speedFactor * 2); + aiBallX += aiXVel * (speedFactor * 1.5); + aiBallY += aiYVel * (speedFactor * 1.5); if (doAi == true) { @@ -201,12 +213,12 @@ namespace ShiftOS.WinForms.Applications if (opponentY < aiBallY) { if (opponentY < 0.9) - opponentY += speedFactor; + opponentY += speedFactor * level; } else { if (opponentY > -0.9) - opponentY -= speedFactor; + opponentY -= speedFactor * level; } } } @@ -287,10 +299,12 @@ namespace ShiftOS.WinForms.Applications xVel = 1; aiBallX = 0; aiBallY = 0; + aiXVel = xVel; + aiYVel = yVel; doAi = true; } - private bool drawAiBall = false; + private bool drawAiBall = true; private void pnlcanvas_Paint(object sender, PaintEventArgs e) { diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.cs b/ShiftOS.WinForms/MainMenu/MainMenu.cs index 7ace42a..f6bc833 100644 --- a/ShiftOS.WinForms/MainMenu/MainMenu.cs +++ b/ShiftOS.WinForms/MainMenu/MainMenu.cs @@ -47,7 +47,7 @@ namespace ShiftOS.WinForms.MainMenu flmenu.BringToFront(); flmenu.CenterParent(); currentMenu = flmenu; - CategoryText = "Main menu"; + CategoryText = Localization.Parse("{MAINMENU_TITLE}"); } public string CategoryText @@ -108,7 +108,7 @@ namespace ShiftOS.WinForms.MainMenu tickerreset.Start(); currentMenu = flmenu; - CategoryText = "Main menu"; + CategoryText = Localization.Parse("{MAINMENU_TITLE}"); } @@ -134,7 +134,7 @@ namespace ShiftOS.WinForms.MainMenu flcampaign.BringToFront(); flcampaign.CenterParent(); currentMenu = flcampaign; - CategoryText = "Campaign"; + CategoryText = Localization.Parse("{MAINMENU_CAMPAIGN}"); } @@ -161,7 +161,7 @@ namespace ShiftOS.WinForms.MainMenu pnloptions.BringToFront(); pnloptions.CenterParent(); currentMenu = pnloptions; - CategoryText = "Settings"; + CategoryText = Localization.Parse("{GEN_SETTINGS}"); } @@ -198,7 +198,7 @@ namespace ShiftOS.WinForms.MainMenu flmenu.BringToFront(); flmenu.CenterParent(); currentMenu = flmenu; - CategoryText = "Main menu"; + CategoryText = Localization.Parse("{MAINMENU_TITLE}"); } private void btncontinue_Click(object sender, EventArgs e) -- cgit v1.2.3