diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..0d09c34e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ \ No newline at end of file diff --git a/Performance1.psess b/Performance1.psess new file mode 100644 index 000000000..7dc9d392d --- /dev/null +++ b/Performance1.psess @@ -0,0 +1,21 @@ + + + Sampling + None + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + + + false + + diff --git a/Subsurface.psess b/Subsurface.psess new file mode 100644 index 000000000..84dfb636d --- /dev/null +++ b/Subsurface.psess @@ -0,0 +1,80 @@ + + + + Subsurface_Solution.sln + Sampling + None + true + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + 500 + + \Fyysinen levy(_Total)\Levyjonon keskiarvo + \Muisti\Sivua/s + \Suoritin(_Total)\Suoritinaika prosentteina + + + + true + false + false + + false + + + false + + + + Subsurface\obj\x86\Debug\Subsurface.exe + 01/01/0001 00:00:00 + true + true + false + false + false + false + false + true + false + Executable + Subsurface\bin\Windows\Debug\Subsurface.exe + Subsurface\bin\Windows\Debug\ + + + IIS + InternetExplorer + true + false + + false + + + false + + {008C0F83-E914-4966-9135-EA885059EDD8}|Subsurface\Subsurface.csproj + Subsurface\Subsurface.csproj + Subsurface + + + + + Subsurface150526.vsp + + + + + :PB:{008C0F83-E914-4966-9135-EA885059EDD8}|Subsurface\Subsurface.csproj + + + \ No newline at end of file diff --git a/Subsurface/Camera.cs b/Subsurface/Camera.cs index 0bdcdea9b..30f5842d8 100644 --- a/Subsurface/Camera.cs +++ b/Subsurface/Camera.cs @@ -198,8 +198,9 @@ namespace Subsurface public Vector2 WorldToScreen(Vector2 coords) { - Vector2 screenCoords = Vector2.Transform(coords, transform); - return new Vector2(screenCoords.X, screenCoords.Y); + coords.Y = -coords.Y; + //Vector2 screenCoords = Vector2.Transform(coords, transform); + return Vector2.Transform(coords, transform); } } } diff --git a/Subsurface/Characters/Character.cs b/Subsurface/Characters/Character.cs index c76555f74..f5dc11ff7 100644 --- a/Subsurface/Characters/Character.cs +++ b/Subsurface/Characters/Character.cs @@ -587,6 +587,51 @@ namespace Subsurface // ConvertUnits.ToDisplayUnits(animController.targetMovement.X, animController.targetMovement.Y), Color.Green); } + + private static GUIProgressBar drowningBar; + public void DrawHud(SpriteBatch spriteBatch, Camera cam) + { + if (drowningBar==null) + { + int width = 200, height = 20; + drowningBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, 20, width, height), Color.Blue, 1.0f); + } + + drowningBar.BarSize = Character.Controlled.Oxygen / 100.0f; + if (drowningBar.BarSize < 1.0f) + drowningBar.Draw(spriteBatch); + + if (Character.Controlled.Inventory != null) + Character.Controlled.Inventory.Draw(spriteBatch); + + if (closestItem!=null) + { + Color color = Color.Orange; + + Vector2 startPos = Position + (closestItem.Position - Position) * 0.7f; + startPos = cam.WorldToScreen(startPos); + + Vector2 textPos = startPos; + + float stringWidth = GUI.font.MeasureString(closestItem.Prefab.Name).X; + textPos -= new Vector2(stringWidth / 2, 20); + spriteBatch.DrawString(GUI.font, closestItem.Prefab.Name, textPos, Color.Black); + spriteBatch.DrawString(GUI.font, closestItem.Prefab.Name, textPos + new Vector2(1, -1), Color.Orange); + + textPos.Y += 50.0f; + foreach (string text in closestItem.HighlightText) + { + textPos.X = startPos.X - GUI.font.MeasureString(text).X / 2; + + spriteBatch.DrawString(GUI.font, text, textPos, Color.Black); + spriteBatch.DrawString(GUI.font, text, textPos + new Vector2(1, -1), Color.Orange); + + textPos.Y += 25; + } + } + + } + public void PlaySound(AIController.AiState state) { if (sounds == null || sounds.Count()==0) return; diff --git a/Subsurface/Characters/Ragdoll.cs b/Subsurface/Characters/Ragdoll.cs index 22c98658b..98f28e7d2 100644 --- a/Subsurface/Characters/Ragdoll.cs +++ b/Subsurface/Characters/Ragdoll.cs @@ -265,7 +265,6 @@ namespace Subsurface Limb limb = f1.Body.UserData as Limb; if (limb != null && (limb.type == LimbType.LeftFoot || limb.type == LimbType.RightFoot)) { - Debug.WriteLine(contact.Manifold.LocalNormal.Y); if (contact.Manifold.LocalNormal.Y >= 0.0f) { stairs = structure; diff --git a/Subsurface/Content/Items/Weapons/spear.png b/Subsurface/Content/Items/Weapons/spear.png new file mode 100644 index 000000000..9ae136cb8 Binary files /dev/null and b/Subsurface/Content/Items/Weapons/spear.png differ diff --git a/Subsurface/Content/Items/Weapons/weapons.xml b/Subsurface/Content/Items/Weapons/weapons.xml index 3d6c71d00..a801f4b9b 100644 --- a/Subsurface/Content/Items/Weapons/weapons.xml +++ b/Subsurface/Content/Items/Weapons/weapons.xml @@ -2,12 +2,12 @@ - + - + @@ -21,7 +21,7 @@ - + @@ -30,11 +30,11 @@ - + - - + + diff --git a/Subsurface/GUI/GUI.cs b/Subsurface/GUI/GUI.cs index 81a0c8b69..a37a1ff21 100644 --- a/Subsurface/GUI/GUI.cs +++ b/Subsurface/GUI/GUI.cs @@ -65,8 +65,6 @@ namespace Subsurface static Texture2D t; public static SpriteFont font; - private static GUIProgressBar drowningBar; - private static GraphicsDevice graphicsDevice; @@ -87,11 +85,7 @@ namespace Subsurface t = new Texture2D(graphicsDevice, 1, 1); t.SetData( new Color[] { Color.White });// fill the texture with white - - int width = 200, height = 20; - drowningBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, 20, width, height), Color.Blue, 1.0f); - - + style = new GUIStyle("Content/HUD/style.xml"); } @@ -262,40 +256,26 @@ namespace Subsurface return clicked; } - public static void Draw(float deltaTime, SpriteBatch spriteBatch) + public static void Draw(float deltaTime, SpriteBatch spriteBatch, Camera cam) { - spriteBatch.DrawString(font, - "FPS: " + (int)Game1.frameCounter.AverageFramesPerSecond - + " - render: "+Game1.renderTimeElapsed, - new Vector2(10, 10), Color.White); + //spriteBatch.DrawString(font, + // "FPS: " + (int)Game1.frameCounter.AverageFramesPerSecond + // + " - render: "+Game1.renderTimeElapsed, + // new Vector2(10, 10), Color.White); - spriteBatch.DrawString(font, - "Physics: " + Game1.world.UpdateTime - + " - bodies: " + Game1.world.BodyList.Count, - new Vector2(10, 30), Color.White); + //spriteBatch.DrawString(font, + // "Physics: " + Game1.world.UpdateTime + // + " - bodies: " + Game1.world.BodyList.Count, + // new Vector2(10, 30), Color.White); - if (Character.Controlled != null) - { - drowningBar.BarSize = Character.Controlled.Oxygen/100.0f; - if (drowningBar.BarSize<1.0f) - drowningBar.Draw(spriteBatch); - if (Character.Controlled.Inventory!=null) - Character.Controlled.Inventory.Draw(spriteBatch); - } + if (Character.Controlled != null) Character.Controlled.DrawHud(spriteBatch, cam); DrawMessages(spriteBatch, (float)deltaTime); DebugConsole.Draw(spriteBatch); } - public static void DrawCharacterHUD(SpriteBatch spriteBatch, Character character) - { - drowningBar.BarSize = character.Oxygen/100.0f; - - drowningBar.Draw(spriteBatch); - } - public static void AddMessage(string message, Color color, float lifeTime = 3.0f) { Vector2 currPos = new Vector2(Game1.GraphicsWidth / 2.0f, Game1.GraphicsHeight * 0.7f); diff --git a/Subsurface/GUI/GUIMessageBox.cs b/Subsurface/GUI/GUIMessageBox.cs new file mode 100644 index 000000000..20f163138 --- /dev/null +++ b/Subsurface/GUI/GUIMessageBox.cs @@ -0,0 +1,57 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Subsurface +{ + class GUIMessageBox + { + public static Queue messageBoxes = new Queue(); + + const int DefaultWidth=400, DefaultHeight=200; + + public delegate bool OnClickedHandler(GUIButton button, object obj); + public OnClickedHandler OnClicked; + + GUIFrame frame; + GUIButton[] buttons; + + public GUIMessageBox(string header, string text) + : this(header, text, new string[] {"OK"}) + { } + + public GUIMessageBox(string header, string text, string[] buttons, Alignment textAlignment = (Alignment.Left |Alignment.Top)) + { + frame = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-DefaultWidth/2, Game1.GraphicsHeight/2-DefaultHeight/2, DefaultWidth, DefaultHeight), + GUI.style.backGroundColor, Alignment.CenterX, GUI.style); + frame.Padding = GUI.style.smallPadding; + + if (buttons == null || buttons.Length == 0) + { + DebugConsole.ThrowError("Creating a message box with no buttons isn't allowed"); + } + + new GUITextBlock(new Rectangle(0, 5, 0, 30), header, Color.Transparent, Color.White, textAlignment, frame, true); + new GUITextBlock(new Rectangle(0,50,0,DefaultHeight-70),text, Color.Transparent, Color.White, textAlignment, frame, true); + + int x = 0; + this.buttons = new GUIButton[buttons.Length]; + for (int i=0; i hull1.Pressure) { - float delta = Math.Min(hull2.Volume - hull2.FullVolume + Hull.MaxCompress / 2.0f, deltaTime * 5000f * sizeModifier); + float delta = Math.Min(hull2.Volume - hull2.FullVolume + Hull.MaxCompress / 2.0f, deltaTime * 8000.0f * sizeModifier); + + flowForce = new Vector2(0.0f, Math.Min(hull2.Pressure-hull1.Pressure,500.0f)); + delta = Math.Max(delta, 0.0f); hull1.Volume += delta; hull2.Volume -= delta; @@ -398,12 +401,13 @@ namespace Subsurface // //water1.WaveY[posX] = delta; // water1.WaveVel[posX] = delta * 0.01f; //} + if (hull1.Volume > hull1.FullVolume) { hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure) / 2); } - flowForce = new Vector2(0.0f, delta); + } //there's water in the upper room, drop to lower diff --git a/Subsurface/Screens/EditCharacterScreen.cs b/Subsurface/Screens/EditCharacterScreen.cs index 6c715279b..da80d76e2 100644 --- a/Subsurface/Screens/EditCharacterScreen.cs +++ b/Subsurface/Screens/EditCharacterScreen.cs @@ -214,7 +214,7 @@ namespace Subsurface } - GUI.Draw((float)deltaTime, spriteBatch); + GUI.Draw((float)deltaTime, spriteBatch, cam); //EntityPrefab.DrawList(spriteBatch, new Vector2(20,50)); diff --git a/Subsurface/Screens/EditMapScreen.cs b/Subsurface/Screens/EditMapScreen.cs index d6b9f4593..5e775503d 100644 --- a/Subsurface/Screens/EditMapScreen.cs +++ b/Subsurface/Screens/EditMapScreen.cs @@ -248,7 +248,7 @@ namespace Subsurface if (selectedTab > -1) GUItabs[selectedTab].Draw(spriteBatch); - GUI.Draw((float)deltaTime, spriteBatch); + GUI.Draw((float)deltaTime, spriteBatch, cam); //EntityPrefab.DrawList(spriteBatch, new Vector2(20,50)); diff --git a/Subsurface/Screens/GameScreen.cs b/Subsurface/Screens/GameScreen.cs index e412715ae..173c82643 100644 --- a/Subsurface/Screens/GameScreen.cs +++ b/Subsurface/Screens/GameScreen.cs @@ -124,7 +124,7 @@ namespace Subsurface } } - GUI.Draw((float)deltaTime, spriteBatch); + GUI.Draw((float)deltaTime, spriteBatch, cam); if (PlayerInput.GetMouseState.LeftButton != ButtonState.Pressed) Inventory.draggingItem = null; diff --git a/Subsurface/Screens/LobbyScreen.cs b/Subsurface/Screens/LobbyScreen.cs index d7f2e21b0..c91b3f346 100644 --- a/Subsurface/Screens/LobbyScreen.cs +++ b/Subsurface/Screens/LobbyScreen.cs @@ -168,7 +168,7 @@ namespace Subsurface rightPanel[selectedRightPanel].Draw(spriteBatch); - GUI.Draw((float)deltaTime, spriteBatch); + GUI.Draw((float)deltaTime, spriteBatch, null); spriteBatch.End(); } diff --git a/Subsurface/Screens/MainMenu.cs b/Subsurface/Screens/MainMenu.cs index 9fa95d42a..26fa90f87 100644 --- a/Subsurface/Screens/MainMenu.cs +++ b/Subsurface/Screens/MainMenu.cs @@ -139,7 +139,7 @@ namespace Subsurface menuTabs[selectedTab].Draw(spriteBatch); - GUI.Draw((float)deltaTime, spriteBatch); + GUI.Draw((float)deltaTime, spriteBatch, null); spriteBatch.End(); } diff --git a/Subsurface/Screens/NetLobbyScreen.cs b/Subsurface/Screens/NetLobbyScreen.cs index b03132a1a..3f3df070c 100644 --- a/Subsurface/Screens/NetLobbyScreen.cs +++ b/Subsurface/Screens/NetLobbyScreen.cs @@ -26,6 +26,9 @@ namespace Subsurface float camAngle; + Body previewPlatform; + Hull previewHull; + public bool isServer; public string SelectedMap @@ -103,6 +106,18 @@ namespace Subsurface public override void Deselect() { textBox.Deselect(); + + if (previewPlatform!=null) + { + Game1.world.RemoveBody(previewPlatform); + previewPlatform = null; + } + + if (previewHull!=null) + { + previewHull.Remove(); + previewHull = null; + } } public override void Select() @@ -203,9 +218,9 @@ namespace Subsurface femaleButton.UserData = Gender.Female; femaleButton.OnClicked += SwitchGender; - new GUITextBlock(new Rectangle(0, 200, 200,30), "Job preferences:", Color.Transparent, Color.Black, Alignment.Left, playerFrame); + new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", Color.Transparent, Color.Black, Alignment.Left, playerFrame); - GUIListBox jobList = new GUIListBox(new Rectangle(0,230,200,250), Color.White, playerFrame); + GUIListBox jobList = new GUIListBox(new Rectangle(0,180,200,0), Color.White, playerFrame); foreach (Job job in Job.jobList) { @@ -275,12 +290,7 @@ namespace Subsurface Game1.gameScreen.Cam.TargetPos = pos; menu.Update((float)deltaTime); - - if (Game1.client != null && Game1.client.Character != null) - { - - } - + durationBar.BarScroll = Math.Max(durationBar.BarScroll, 1.0f / 60.0f); } @@ -294,7 +304,7 @@ namespace Subsurface menu.Draw(spriteBatch); - GUI.Draw((float)deltaTime, spriteBatch); + GUI.Draw((float)deltaTime, spriteBatch, null); spriteBatch.End(); @@ -303,11 +313,15 @@ namespace Subsurface { if (Game1.client.Character != null) { - Vector2 position = new Vector2(playerFrame.Rect.X + playerFrame.Rect.Width * 0.25f, playerFrame.Rect.Y + 100.0f); - Matrix transform = Matrix.CreateTranslation(new Vector3(ConvertUnits.ToDisplayUnits(-Game1.client.Character.SimPosition)+position, 0.0f)); - spriteBatch.Begin(SpriteSortMode.BackToFront, null,null,null,null,null,transform); + Vector2 position = new Vector2(playerFrame.Rect.X + playerFrame.Rect.Width * 0.25f, playerFrame.Rect.Y + 25.0f); + + Vector2 pos = Game1.client.Character.Position; + pos.Y = -pos.Y; + Matrix transform = Matrix.CreateTranslation(new Vector3(-pos+position, 0.0f)); + + spriteBatch.Begin(SpriteSortMode.BackToFront, null,null,null,null,null,transform); Game1.client.Character.Draw(spriteBatch); - spriteBatch.End(); + spriteBatch.End(); } else { @@ -363,15 +377,18 @@ namespace Subsurface character.animController.isStanding = true; - //TODO: only create if hasn't been created yet - //{ - Body platform = BodyFactory.CreateRectangle(Game1.world, 3.0f, 1.0f, 5.0f); - platform.SetTransform(new Vector2(pos.X, pos.Y + 1.5f), 0.0f); - platform.IsStatic = true; + if (previewPlatform==null) + { + Body platform = BodyFactory.CreateRectangle(Game1.world, 3.0f, 1.0f, 5.0f); + platform.SetTransform(new Vector2(pos.X, pos.Y - 2.5f), 0.0f); + platform.IsStatic = true; + } - pos = ConvertUnits.ToDisplayUnits(pos); - new Hull(new Rectangle((int)pos.X - 100, (int)-pos.Y + 100, 200, 200)); - //} + if (previewPlatform==null) + { + pos = ConvertUnits.ToDisplayUnits(pos); + new Hull(new Rectangle((int)pos.X - 100, (int)pos.Y + 100, 200, 200)); + } Physics.Alpha = 1.0f; diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj index 53a9f6d5c..ae23e5186 100644 --- a/Subsurface/Subsurface.csproj +++ b/Subsurface/Subsurface.csproj @@ -73,6 +73,7 @@ + @@ -358,6 +359,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Subsurface/Subsurface.csproj.user b/Subsurface/Subsurface.csproj.user index 505c3a0bf..693505ea4 100644 --- a/Subsurface/Subsurface.csproj.user +++ b/Subsurface/Subsurface.csproj.user @@ -9,6 +9,6 @@ en-US false - ProjectFiles + ShowAllFiles \ No newline at end of file diff --git a/Subsurface150526.vsp b/Subsurface150526.vsp new file mode 100644 index 000000000..1c4abd5ce Binary files /dev/null and b/Subsurface150526.vsp differ diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index ee0e35036..c11d8b0dc 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ