Non-WinForms launcher with auto updater

This commit is contained in:
Regalis
2015-09-11 22:13:44 +03:00
parent ea15397725
commit 29a6260d0f
104 changed files with 46296 additions and 5638 deletions
@@ -170,24 +170,24 @@ namespace Subsurface
GUIImage image = new GUIImage(new Rectangle(0,0,30,30), HeadSprite, Alignment.TopLeft, frame);
int x = 0, y = 0;
new GUITextBlock(new Rectangle(x+80, y, 200, 20), Name, GUI.style, frame);
new GUITextBlock(new Rectangle(x+80, y, 200, 20), Name, GUI.Style, frame);
y += 20;
if (Job!=null)
{
new GUITextBlock(new Rectangle(x+80, y, 200, 20), Job.Name, GUI.style, frame);
new GUITextBlock(new Rectangle(x+80, y, 200, 20), Job.Name, GUI.Style, frame);
y += 30;
var skills = Job.Skills;
skills.Sort((s1, s2) => -s1.Level.CompareTo(s2.Level));
new GUITextBlock(new Rectangle(x, y, 200, 20), "Skills:", GUI.style, frame);
new GUITextBlock(new Rectangle(x, y, 200, 20), "Skills:", GUI.Style, frame);
y += 20;
foreach (Skill skill in skills)
{
Color textColor = Color.White * (0.5f + skill.Level/200.0f);
new GUITextBlock(new Rectangle(x+20, y, 200, 20), skill.Name, Color.Transparent, textColor, Alignment.Left, GUI.style, frame);
new GUITextBlock(new Rectangle(x + 20, y, 200, 20), skill.Level.ToString(), Color.Transparent, textColor, Alignment.Right, GUI.style, frame);
new GUITextBlock(new Rectangle(x+20, y, 200, 20), skill.Name, Color.Transparent, textColor, Alignment.Left, GUI.Style, frame);
new GUITextBlock(new Rectangle(x + 20, y, 200, 20), skill.Level.ToString(), Color.Transparent, textColor, Alignment.Right, GUI.Style, frame);
y += 20;
}
}
+4 -1
View File
@@ -153,6 +153,9 @@ namespace Subsurface
switch (commands[0].ToLower())
{
case "createfilelist":
UpdaterUtil.SaveFileList("filelist.xml");
break;
case "spawn":
if (commands.Length == 1) return;
@@ -165,7 +168,7 @@ namespace Subsurface
SinglePlayerMode mode = Game1.GameSession.gameMode as SinglePlayerMode;
if (mode == null) break;
mode.CrewManager.AddCharacter(Character.Controlled);
mode.CrewManager.SelectCharacter(Character.Controlled);
mode.CrewManager.SelectCharacter(null, Character.Controlled);
}
}
else
+1 -1
View File
@@ -7,7 +7,7 @@ using System.Xml.Linq;
namespace Subsurface
{
class GUIComponentStyle
public class GUIComponentStyle
{
public readonly Vector4 Padding;
+17 -9
View File
@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
@@ -15,9 +16,9 @@ namespace Subsurface
BottomRight = (Bottom | Right), BottomLeft = (Bottom | Left), BottomCenter = (CenterX | Bottom)
}
class GUI
public class GUI
{
public static GUIStyle style;
public static GUIStyle Style;
static Texture2D t;
public static SpriteFont Font, SmallFont, LargeFont;
@@ -31,6 +32,13 @@ namespace Subsurface
private static bool pauseMenuOpen;
private static GUIFrame pauseMenu;
public static void Init(ContentManager content)
{
GUI.Font = ToolBox.TryLoadFont("SpriteFont1", content);
GUI.SmallFont = ToolBox.TryLoadFont("SmallFont", content);
GUI.LargeFont = ToolBox.TryLoadFont("LargeFont", content);
}
public static bool PauseMenuOpen
{
get { return pauseMenuOpen; }
@@ -48,7 +56,7 @@ namespace Subsurface
t.SetData<Color>(
new Color[] { Color.White });// fill the texture with white
style = new GUIStyle("Content/UI/style.xml");
Style = new GUIStyle("Content/UI/style.xml");
}
public static void TogglePauseMenu()
@@ -59,10 +67,10 @@ namespace Subsurface
if (pauseMenuOpen)
{
pauseMenu = new GUIFrame(new Rectangle(0,0,200,300), null, Alignment.Center, style);
pauseMenu = new GUIFrame(new Rectangle(0,0,200,300), null, Alignment.Center, Style);
int y = 0;
var button = new GUIButton(new Rectangle(0, y, 0, 30), "Resume", Alignment.CenterX, GUI.style, pauseMenu);
var button = new GUIButton(new Rectangle(0, y, 0, 30), "Resume", Alignment.CenterX, GUI.Style, pauseMenu);
button.OnClicked = TogglePauseMenu;
y += 60;
@@ -72,7 +80,7 @@ namespace Subsurface
SinglePlayerMode spMode = Game1.GameSession.gameMode as SinglePlayerMode;
if (spMode!=null)
{
button = new GUIButton(new Rectangle(0, y, 0, 30), "Load previous", Alignment.CenterX, GUI.style, pauseMenu);
button = new GUIButton(new Rectangle(0, y, 0, 30), "Load previous", Alignment.CenterX, GUI.Style, pauseMenu);
button.OnClicked += TogglePauseMenu;
button.OnClicked += Game1.GameSession.LoadPrevious;
@@ -85,7 +93,7 @@ namespace Subsurface
SinglePlayerMode spMode = Game1.GameSession.gameMode as SinglePlayerMode;
if (spMode != null)
{
button = new GUIButton(new Rectangle(0, y, 0, 30), "Save & quit", Alignment.CenterX, GUI.style, pauseMenu);
button = new GUIButton(new Rectangle(0, y, 0, 30), "Save & quit", Alignment.CenterX, GUI.Style, pauseMenu);
button.OnClicked += QuitClicked;
button.OnClicked += TogglePauseMenu;
button.UserData = "save";
@@ -95,7 +103,7 @@ namespace Subsurface
}
button = new GUIButton(new Rectangle(0, y, 0, 30), "Quit", Alignment.CenterX, GUI.style, pauseMenu);
button = new GUIButton(new Rectangle(0, y, 0, 30), "Quit", Alignment.CenterX, GUI.Style, pauseMenu);
button.OnClicked += QuitClicked;
button.OnClicked += TogglePauseMenu;
}
@@ -118,7 +126,7 @@ namespace Subsurface
Game1.MainMenuScreen.Select();
Game1.MainMenuScreen.SelectTab(null, (int)MainMenuScreen.Tabs.Main);
//Game1.MainMenuScreen.SelectTab(null, (int)MainMenuScreen.Tabs.Main);
return true;
}
+54 -9
View File
@@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Input;
namespace Subsurface
{
class GUIButton : GUIComponent
public class GUIButton : GUIComponent
{
protected GUITextBlock textBlock;
protected GUIFrame frame;
@@ -16,6 +16,42 @@ namespace Subsurface
public OnPressedHandler OnPressed;
public bool Enabled { get; set; }
public override Color Color
{
get { return base.Color; }
set
{
base.Color = value;
frame.Color = value;
}
}
public override Color HoverColor
{
get { return base.HoverColor; }
set
{
base.HoverColor = value;
frame.HoverColor = value;
}
}
public override Color OutlineColor
{
get { return base.OutlineColor; }
set
{
base.OutlineColor = value;
if (frame != null) frame.OutlineColor = value;
}
}
public Color TextColor
{
get { return textBlock.TextColor; }
set { textBlock.TextColor = value; }
}
public string Text
{
@@ -23,6 +59,8 @@ namespace Subsurface
set { textBlock.Text = value; }
}
public bool Selected { get; set; }
public GUIButton(Rectangle rect, string text, GUIStyle style, GUIComponent parent = null)
: this(rect, text, null, Alignment.Left, style, parent)
{
@@ -39,6 +77,12 @@ namespace Subsurface
}
public GUIButton(Rectangle rect, string text, Color? color, Alignment alignment, GUIStyle style, GUIComponent parent = null)
:this(rect, text, color, alignment, Alignment.Center, style, parent)
{
}
public GUIButton(Rectangle rect, string text, Color? color, Alignment alignment, Alignment textAlignment, GUIStyle style, GUIComponent parent = null)
:base (style)
{
this.rect = rect;
@@ -47,19 +91,20 @@ namespace Subsurface
Enabled = true;
if (parent != null)
parent.AddChild(this);
if (parent != null) parent.AddChild(this);
frame = new GUIFrame(new Rectangle(0,0,0,0), style, this);
if (style!=null) style.Apply(frame, this);
frame = new GUIFrame(Rectangle.Empty, style, this);
if (style != null) style.Apply(frame, this);
textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), text,
Color.Transparent, (this.style==null) ? Color.Black : this.style.textColor,
Alignment.Center, style, this);
textBlock = new GUITextBlock(Rectangle.Empty, text,
Color.Transparent, (this.style == null) ? Color.Black : this.style.textColor,
textAlignment, style, this);
}
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
if (rect.Contains(PlayerInput.MousePosition) && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn)))
{
state = ComponentState.Hover;
@@ -80,7 +125,7 @@ namespace Subsurface
}
else
{
state = ComponentState.None;
state = Selected ? ComponentState.Selected : ComponentState.None;
}
frame.State = state;
+23 -25
View File
@@ -7,7 +7,7 @@ using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
{
abstract class GUIComponent
public abstract class GUIComponent
{
const float FlashDuration = 1.5f;
@@ -53,6 +53,12 @@ namespace Subsurface
set;
}
public bool Visible
{
get;
set;
}
private GUITextBlock toolTipBlock;
//protected float alpha;
@@ -94,7 +100,7 @@ namespace Subsurface
//public Alignment SpriteAlignment { get; set; }
//public bool RepeatSpriteX, RepeatSpriteY;
public Color OutlineColor { get; set; }
public virtual Color OutlineColor { get; set; }
public ComponentState State
{
@@ -125,38 +131,21 @@ namespace Subsurface
set { color = value; }
}
public Color HoverColor
public virtual Color HoverColor
{
get { return hoverColor; }
set { hoverColor = value; }
}
public Color SelectedColor
public virtual Color SelectedColor
{
get { return selectedColor; }
set { selectedColor = value; }
}
//public float Alpha
//{
// get
// {
// return alpha;
// }
// set
// {
// alpha = MathHelper.Clamp(value, 0.0f, 1.0f);
// foreach (GUIComponent child in children)
// {
// child.Alpha = value;
// }
// }
//}
protected GUIComponent(GUIStyle style)
{
//alpha = 1.0f;
Visible = true;
OutlineColor = Color.Transparent;
@@ -218,6 +207,8 @@ namespace Subsurface
public virtual void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
Color currColor = color;
if (state == ComponentState.Selected) currColor = selectedColor;
if (state == ComponentState.Hover) currColor = hoverColor;
@@ -255,20 +246,26 @@ namespace Subsurface
public void DrawToolTip(SpriteBatch spriteBatch)
{
int width = 200;
if (!Visible) return;
int width = 400;
if (toolTipBlock==null || (string)toolTipBlock.userData != ToolTip)
{
string wrappedText = ToolBox.WrapText(ToolTip, width, GUI.SmallFont);
toolTipBlock = new GUITextBlock(new Rectangle(0,0,width, wrappedText.Split('\n').Length*15), ToolTip, GUI.style, null, true);
toolTipBlock = new GUITextBlock(new Rectangle(0,0,width, wrappedText.Split('\n').Length*15), ToolTip, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, null, true, GUI.SmallFont);
toolTipBlock.Color = Color.Black*0.7f;
toolTipBlock.OutlineColor = Color.White;
toolTipBlock.userData = ToolTip;
}
toolTipBlock.rect = new Rectangle((int)PlayerInput.MousePosition.X, (int)PlayerInput.MousePosition.Y, toolTipBlock.rect.Width, toolTipBlock.rect.Height);
toolTipBlock.rect = new Rectangle(MouseOn.Rect.Center.X, MouseOn.rect.Bottom, toolTipBlock.rect.Width, toolTipBlock.rect.Height);
toolTipBlock.Draw(spriteBatch);
}
public virtual void Update(float deltaTime)
{
if (!Visible) return;
if (flashTimer>0.0f) flashTimer -= deltaTime;
if (CanBeFocused)
@@ -276,6 +273,7 @@ namespace Subsurface
if (rect.Contains(PlayerInput.MousePosition))
{
MouseOn = this;
//ToolTip = this.ToolTip;
}
else
{
+138
View File
@@ -0,0 +1,138 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface
{
public class GUIDropDown : GUIComponent
{
private GUIButton button;
private GUIListBox listBox;
public bool Dropped { get; set; }
public object SelectedItemData
{
get
{
if (listBox.Selected == null) return null;
return listBox.Selected.UserData;
}
}
public GUIDropDown(Rectangle rect, string text, GUIStyle style, GUIComponent parent = null)
: base(style)
{
this.rect = rect;
if (parent != null) parent.AddChild(this);
button = new GUIButton(Rectangle.Empty, "", Color.White, Alignment.TopLeft, Alignment.TopLeft, null, this);
button.TextColor = Color.White;
button.Color = Color.Black * 0.8f;
button.HoverColor = Color.DarkGray * 0.8f;
button.OutlineColor = Color.LightGray * 0.8f;
button.OnClicked = OnClicked;
listBox = new GUIListBox(new Rectangle(this.rect.X, this.rect.Bottom, this.rect.Width, 200), style, null);
listBox.OnSelected = SelectItem;
//listBox.ScrollBarEnabled = false;
}
public void AddItem(string text, object userData = null)
{
GUITextBlock textBlock = new GUITextBlock(new Rectangle(0,0,0,20), text, GUI.Style, listBox);
textBlock.UserData = userData;
//int totalHeight = 0;
//foreach (GUIComponent child in listBox.children)
//{
// totalHeight += child.Rect.Height;
//}
//listBox.Rect = new Rectangle(listBox.Rect.X,listBox.Rect.Y,listBox.Rect.Width,totalHeight);
}
private bool SelectItem(GUIComponent component, object obj)
{
GUITextBlock textBlock = component as GUITextBlock;
if (textBlock==null) return false;
button.Text = textBlock.Text;
Dropped = false;
return true;
}
public void SelectItem(object userData)
{
//GUIComponent child = listBox.children.FirstOrDefault(c => c.UserData == userData);
//if (child == null) return;
listBox.Select(userData);
//SelectItem(child, userData);
}
private bool wasOpened;
private bool OnClicked(GUIComponent component, object obj)
{
if (wasOpened) return false;
wasOpened = true;
Dropped = !Dropped;
if (Dropped && parent.children[parent.children.Count-1]!=this)
{
parent.children.Remove(this);
parent.children.Add(this);
}
return true;
}
public override void Update(float deltaTime)
{
if (!Visible) return;
wasOpened = false;
base.Update(deltaTime);
if (Dropped && PlayerInput.LeftButtonClicked())
{
Rectangle listBoxRect = listBox.Rect;
listBoxRect.Width += 20;
if (!listBoxRect.Contains(PlayerInput.MousePosition))
{
Dropped = false;
}
}
button.Update(deltaTime);
if (Dropped) listBox.Update(deltaTime);
}
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
base.Draw(spriteBatch);
button.Draw(spriteBatch);
if (!Dropped) return;
listBox.Draw(spriteBatch);
}
}
}
+2 -2
View File
@@ -3,7 +3,7 @@ using System;
namespace Subsurface
{
class GUIFrame : GUIComponent
public class GUIFrame : GUIComponent
{
public GUIFrame(Rectangle rect, GUIStyle style = null, GUIComponent parent = null)
: this(rect, null, (Alignment.Left | Alignment.Top), style, parent)
@@ -39,7 +39,7 @@ namespace Subsurface
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
if (!Visible) return;
Color currColor = color;
if (state == ComponentState.Selected) currColor = selectedColor;
+3 -1
View File
@@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
{
class GUIImage : GUIComponent
public class GUIImage : GUIComponent
{
Sprite sprite;
@@ -72,6 +72,8 @@ namespace Subsurface
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
Color currColor = color;
if (state == ComponentState.Hover) currColor = hoverColor;
if (state == ComponentState.Selected) currColor = selectedColor;
+12 -7
View File
@@ -5,11 +5,11 @@ using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
{
class GUIListBox : GUIComponent
public class GUIListBox : GUIComponent
{
protected GUIComponent selected;
public delegate bool OnSelectedHandler(object obj);
public delegate bool OnSelectedHandler(GUIComponent component, object obj);
public OnSelectedHandler OnSelected;
public delegate object CheckSelectedHandler();
@@ -34,7 +34,7 @@ namespace Subsurface
return selected;
}
}
public object SelectedData
{
get
@@ -145,13 +145,15 @@ namespace Subsurface
if (child.UserData != selection) continue;
selected = child;
if (OnSelected != null) OnSelected(selected.UserData);
if (OnSelected != null) OnSelected(selected, selected.UserData);
return;
}
}
public override void Update(float deltaTime)
{
if (!Visible) return;
base.Update(deltaTime);
scrollBar.Update(deltaTime);
@@ -165,7 +167,7 @@ namespace Subsurface
if (childIndex >= children.Count || childIndex<0) return;
selected = children[childIndex];
if (OnSelected != null) OnSelected(selected.UserData);
if (OnSelected != null) OnSelected(selected, selected.UserData);
}
public void Deselect()
@@ -238,6 +240,8 @@ namespace Subsurface
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
base.Draw(spriteBatch);
frame.Draw(spriteBatch);
@@ -284,7 +288,8 @@ namespace Subsurface
if (CheckSelected() != selected.UserData) selected = null;
}
}
else if (enabled && (MouseOn == this || (MouseOn != null && this.IsParentOf(MouseOn))) && child.Rect.Contains(PlayerInput.MousePosition))
else if (enabled && child.CanBeFocused &&
(MouseOn == this || (MouseOn != null && this.IsParentOf(MouseOn))) && child.Rect.Contains(PlayerInput.MousePosition))
{
child.State = ComponentState.Hover;
if (PlayerInput.LeftButtonClicked())
@@ -293,7 +298,7 @@ namespace Subsurface
selected = child;
if (OnSelected != null)
{
if (!OnSelected(child.UserData)) selected = null;
if (!OnSelected(selected, child.UserData)) selected = null;
}
}
+4 -4
View File
@@ -40,7 +40,7 @@ namespace Subsurface
public GUIMessageBox(string header, string text, string[] buttons, int width=DefaultWidth, int height=DefaultHeight, Alignment textAlignment = Alignment.TopLeft)
: base(new Rectangle(0,0, width, height),
null, Alignment.Center, GUI.style, null)
null, Alignment.Center, GUI.Style, null)
{
//Padding = GUI.style.smallPadding;
@@ -50,14 +50,14 @@ namespace Subsurface
// return;
//}
new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, GUI.style, this, true);
new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text, Color.Transparent, Color.White, textAlignment, GUI.style, this, true);
new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, GUI.Style, this, true);
new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text, Color.Transparent, Color.White, textAlignment, GUI.Style, this, true);
int x = 0;
this.Buttons = new GUIButton[buttons.Length];
for (int i = 0; i < buttons.Length; i++)
{
this.Buttons[i] = new GUIButton(new Rectangle(x, 0, 150, 30), buttons[i], Alignment.Left | Alignment.Bottom, GUI.style, this);
this.Buttons[i] = new GUIButton(new Rectangle(x, 0, 150, 30), buttons[i], Alignment.Left | Alignment.Bottom, GUI.Style, this);
x += this.Buttons[i].Rect.Width + 20;
}
+3 -1
View File
@@ -3,7 +3,7 @@ using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
{
class GUIProgressBar : GUIComponent
public class GUIProgressBar : GUIComponent
{
private bool isHorizontal;
@@ -67,6 +67,8 @@ namespace Subsurface
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
if (ProgressGetter != null) BarSize = ProgressGetter();
DrawChildren(spriteBatch);
+5 -1
View File
@@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
{
class GUIScrollBar : GUIComponent
public class GUIScrollBar : GUIComponent
{
public static GUIScrollBar draggingBar;
@@ -122,6 +122,8 @@ namespace Subsurface
public override void Update(float deltaTime)
{
if (!Visible) return;
base.Update(deltaTime);
if (draggingBar != this) return;
@@ -132,6 +134,8 @@ namespace Subsurface
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
DrawChildren(spriteBatch);
}
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace Subsurface
{
class GUIStyle
public class GUIStyle
{
private Dictionary<string, GUIComponentStyle> componentStyles;
+20 -17
View File
@@ -3,7 +3,7 @@ using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
{
class GUITextBlock : GUIComponent
public class GUITextBlock : GUIComponent
{
protected string text;
@@ -21,8 +21,6 @@ namespace Subsurface
public bool Wrap;
public override Vector4 Padding
{
get { return padding; }
@@ -75,15 +73,6 @@ namespace Subsurface
{
}
public GUITextBlock(Rectangle rect, string text, GUIStyle style, Alignment alignment = Alignment.TopLeft, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null, bool wrap = false, SpriteFont font =null)
: this (rect, text, null, null, alignment, textAlignment, style, parent, wrap)
{
this.Font = font == null ? GUI.Font : font;
SetTextPos();
}
public GUITextBlock(Rectangle rect, string text, Color? color, Color? textColor, Alignment textAlignment = Alignment.Left, GUIStyle style = null, GUIComponent parent = null, bool wrap = false)
: this(rect, text,color, textColor, Alignment.TopLeft, textAlignment, style, parent, wrap)
{
@@ -105,24 +94,36 @@ namespace Subsurface
public GUITextBlock(Rectangle rect, string text, Color? color, Color? textColor, Alignment alignment, Alignment textAlignment = Alignment.Left, GUIStyle style = null, GUIComponent parent = null, bool wrap = false)
:base (style)
: this (rect, text, style, alignment, textAlignment, parent, wrap, null)
{
if (color != null) this.color = (Color)color;
if (textColor != null) this.textColor = (Color)textColor;
}
public GUITextBlock(Rectangle rect, string text, GUIStyle style, Alignment alignment = Alignment.TopLeft, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null, bool wrap = false, SpriteFont font = null)
:base (style)
{
this.Font = font == null ? GUI.Font : font;
this.rect = rect;
if (color!=null) this.color = (Color)color;
if (textColor!=null) this.textColor = (Color)textColor;
this.text = text;
this.alignment = alignment;
this.textAlignment = textAlignment;
if (parent != null)
parent.AddChild(this);
this.Wrap = wrap;
SetTextPos();
if (rect.Height == 0)
{
this.rect.Height = (int)Font.MeasureString(Text).Y;
}
}
private void SetTextPos()
@@ -201,6 +202,8 @@ namespace Subsurface
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
Color currColor = color;
if (state == ComponentState.Hover) currColor = hoverColor;
if (state == ComponentState.Selected) currColor = selectedColor;
+4
View File
@@ -153,6 +153,8 @@ namespace Subsurface
MouseState previousMouse;
public override void Update(float deltaTime)
{
if (!Visible) return;
if (flashTimer > 0.0f) flashTimer -= deltaTime;
if (!Enabled) return;
@@ -186,6 +188,8 @@ namespace Subsurface
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
DrawChildren(spriteBatch);
Vector2 caretPos = textBlock.CaretPos;
+9 -13
View File
@@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Input;
namespace Subsurface
{
class GUITickBox : GUIComponent
public class GUITickBox : GUIComponent
{
GUIFrame box;
GUITextBlock text;
@@ -41,25 +41,24 @@ namespace Subsurface
box.HoverColor = Color.Gray;
box.SelectedColor = Color.DarkGray;
text = new GUITextBlock(new Rectangle(rect.X + 40, rect.Y, 200, rect.Height), label, Color.Transparent, Color.White, Alignment.TopLeft, null, this);
this.rect = new Rectangle(box.Rect.X, box.Rect.Y, 240, rect.Height);
Enabled = true;
}
public override void Update(float deltaTime)
{
if (rect.Width ==420)
{
int asd = 1;
}
//base.Update(deltaTime);
if (!Visible || !Enabled) return;
if (!Enabled) return;
if (text.Rect.Contains(PlayerInput.MousePosition)) MouseOn = this;
if (box.Rect.Contains(PlayerInput.MousePosition))
{
//ToolTip = this.ToolTip;
MouseOn = this;
box.State = ComponentState.Hover;
@@ -84,10 +83,7 @@ namespace Subsurface
public override void Draw(SpriteBatch spriteBatch)
{
if (rect.Width == 420)
{
int asd = 1;
}
if (!Visible) return;
DrawChildren(spriteBatch);
+34 -23
View File
@@ -17,13 +17,26 @@ namespace Subsurface
float state;
public Vector2 Position;
public Vector2 CenterPosition;
public Vector2 TitlePosition;
public Vector2 TitleSize
{
get { return new Vector2(titleTexture.Width, titleTexture.Height); }
}
public float Scale
{
get;
private set;
}
public TitleScreen(GraphicsDevice graphics)
{
backgroundTexture = Game1.TextureLoader.FromFile("Content/UI/titleBackground.png");
monsterTexture = Game1.TextureLoader.FromFile("Content/UI/titleMonster.png");
titleTexture = Game1.TextureLoader.FromFile("Content/UI/titleText.png");
backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png");
monsterTexture = TextureLoader.FromFile("Content/UI/titleMonster.png");
titleTexture = TextureLoader.FromFile("Content/UI/titleText.png");
renderTarget = new RenderTarget2D(graphics, Game1.GraphicsWidth, Game1.GraphicsHeight);
@@ -40,46 +53,44 @@ namespace Subsurface
graphics.SetRenderTarget(renderTarget);
//Debug.WriteLine(stopwatch.Elapsed.TotalMilliseconds);
float scale = Game1.GraphicsHeight/2048.0f;
Scale = Game1.GraphicsHeight/1500.0f;
state += deltaTime;
Vector2 center = new Vector2(Game1.GraphicsWidth*0.3f, Game1.GraphicsHeight/2.0f) + Position*scale;
if (loadState>-1)
{
CenterPosition = new Vector2(Game1.GraphicsWidth*0.3f, Game1.GraphicsHeight/2.0f);
TitlePosition = CenterPosition + new Vector2(-0.0f + (float)Math.Sqrt(state) * 220.0f, 0.0f) * Scale;
TitlePosition.X = Math.Min(TitlePosition.X, (float)Game1.GraphicsWidth / 2.0f);
}
Vector2 titlePos = center + new Vector2(-0.0f + (float)Math.Sqrt(state) * 220.0f, 0.0f) * scale;
titlePos.X = Math.Min(titlePos.X, (float)Game1.GraphicsWidth / 2.0f);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
graphics.Clear(Color.Black);
spriteBatch.Draw(backgroundTexture, center, null, Color.White * Math.Min(state / 5.0f, 1.0f), 0.0f,
spriteBatch.Draw(backgroundTexture, CenterPosition, null, Color.White * Math.Min(state / 5.0f, 1.0f), 0.0f,
new Vector2(backgroundTexture.Width / 2.0f, backgroundTexture.Height / 2.0f),
scale, SpriteEffects.None, 0.2f);
Scale*1.5f, SpriteEffects.None, 0.2f);
spriteBatch.Draw(monsterTexture,
center + new Vector2(state * 100.0f - 1200.0f, state * 30.0f - 100.0f) * scale, null,
Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.1f);
CenterPosition + new Vector2((state % 40) * 100.0f - 1800.0f, (state % 40) * 30.0f - 200.0f) * Scale, null,
Color.White, 0.0f, Vector2.Zero, Scale, SpriteEffects.None, 0.1f);
spriteBatch.Draw(titleTexture,
titlePos, null,
Color.White * Math.Min((state - 1.0f) / 5.0f, 1.0f), 0.0f, new Vector2(titleTexture.Width / 2.0f, titleTexture.Height / 2.0f), scale, SpriteEffects.None, 0.0f);
TitlePosition, null,
Color.White * Math.Min((state - 1.0f) / 5.0f, 1.0f), 0.0f, new Vector2(titleTexture.Width / 2.0f, titleTexture.Height / 2.0f), Scale, SpriteEffects.None, 0.0f);
spriteBatch.End();
graphics.SetRenderTarget(null);
Matrix transform = Matrix.CreateTranslation(
new Vector3(Game1.GraphicsWidth / 2.0f,
Game1.GraphicsHeight / 2.0f, 0));
Hull.renderer.RenderBack(spriteBatch, renderTarget, transform);
Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
spriteBatch.Draw(titleTexture,
titlePos, null,
Color.White * Math.Min((state - 3.0f) / 5.0f, 1.0f), 0.0f, new Vector2(titleTexture.Width / 2.0f, titleTexture.Height / 2.0f), scale, SpriteEffects.None, 0.0f);
TitlePosition, null,
Color.White * Math.Min((state - 3.0f) / 5.0f, 1.0f), 0.0f, new Vector2(titleTexture.Width / 2.0f, titleTexture.Height / 2.0f), Scale, SpriteEffects.None, 0.0f);
string loadText = "";
if (loadState == 100.0f)
+3 -5
View File
@@ -53,7 +53,7 @@ namespace Subsurface
public static ParticleManager ParticleManager;
public static TextureLoader TextureLoader;
//public static TextureLoader TextureLoader;
public static World World;
@@ -153,7 +153,7 @@ namespace Subsurface
ConvertUnits.SetDisplayUnitToSimUnitRatio(Physics.DisplayToSimRation);
spriteBatch = new SpriteBatch(GraphicsDevice);
TextureLoader = new TextureLoader(GraphicsDevice);
TextureLoader.Init(GraphicsDevice);
titleScreenOpen = true;
TitleScreen = new TitleScreen(GraphicsDevice);
@@ -164,9 +164,7 @@ namespace Subsurface
private float loadState = 0.0f;
private IEnumerable<object> Load()
{
GUI.Font = ToolBox.TryLoadFont("SpriteFont1", Content);
GUI.SmallFont = ToolBox.TryLoadFont("SmallFont", Content);
GUI.LargeFont = ToolBox.TryLoadFont("LargeFont", Content);
GUI.Init(Content);
sw = new Stopwatch();
+3 -3
View File
@@ -53,8 +53,8 @@ namespace Subsurface
characterInfos.Add(new CharacterInfo(subElement));
}
}
public bool SelectCharacter(object selection)
public bool SelectCharacter(GUIComponent component, object selection)
{
//listBox.Select(selection);
Character character = selection as Character;
@@ -137,7 +137,7 @@ namespace Subsurface
AddCharacter(character);
}
if (characters.Count > 0) SelectCharacter(characters[0]);
if (characters.Count > 0) SelectCharacter(null, characters[0]);
}
public void EndShift()
@@ -47,7 +47,7 @@ namespace Subsurface
CargoManager = new CargoManager();
endShiftButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 220, 20, 200, 25), "End shift", Alignment.TopLeft, GUI.style);
endShiftButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 220, 20, 200, 25), "End shift", Alignment.TopLeft, GUI.Style);
endShiftButton.OnClicked = EndShift;
for (int i = 0; i < 3; i++)
@@ -543,7 +543,7 @@ namespace Subsurface
messageBox.Buttons[0].OnClicked += Restart;
messageBox.Buttons[0].OnClicked += messageBox.Close;
messageBox.Buttons[1].UserData = MainMenuScreen.Tabs.Main;
//messageBox.Buttons[1].UserData = MainMenuScreen.Tabs.Main;
messageBox.Buttons[1].OnClicked = Game1.MainMenuScreen.SelectTab;
messageBox.Buttons[1].OnClicked += messageBox.Close;
@@ -605,12 +605,12 @@ namespace Subsurface
height += wrappedText.Split('\n').Length*25;
var infoBlock = new GUIFrame(new Rectangle(-20, 20, width, height), null, Alignment.TopRight, GUI.style);
var infoBlock = new GUIFrame(new Rectangle(-20, 20, width, height), null, Alignment.TopRight, GUI.Style);
//infoBlock.Color = infoBlock.Color * 0.8f;
infoBlock.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
infoBlock.Flash(Color.Green);
new GUITextBlock(new Rectangle(10, 10, width - 40, height), text, GUI.style, infoBlock, true);
new GUITextBlock(new Rectangle(10, 10, width - 40, height), text, GUI.Style, infoBlock, true);
GUI.PlayMessageSound();
+12 -1
View File
@@ -37,6 +37,12 @@ namespace Subsurface
private set;
}
public bool AutoCheckUpdates
{
get;
set;
}
public GameSettings(string filePath)
{
Load(filePath);
@@ -68,6 +74,8 @@ namespace Subsurface
MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", "");
AutoCheckUpdates = ToolBox.GetAttributeBool(doc.Root, "autocheckupdates", true);
foreach (XElement subElement in doc.Root.Elements())
{
switch (subElement.Name.ToString().ToLower())
@@ -91,7 +99,10 @@ namespace Subsurface
doc.Add(new XElement("config"));
}
doc.Root.Add(new XAttribute("masterserverurl", MasterServerUrl));
doc.Root.Add(
new XAttribute("masterserverurl", MasterServerUrl),
new XAttribute("autocheckupdates", AutoCheckUpdates));
XElement gMode = doc.Root.Element("graphicsmode");
if (gMode == null)
@@ -29,7 +29,7 @@ namespace Subsurface
{
this.character = character;
if (icons == null) icons = Game1.TextureLoader.FromFile("Content/UI/inventoryIcons.png");
if (icons == null) icons = TextureLoader.FromFile("Content/UI/inventoryIcons.png");
slotPositions = new Vector2[limbSlots.Length];
@@ -216,7 +216,7 @@ namespace Subsurface.Items.Components
guiFrame = new GUIFrame(
new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Z, (int)rect.W),
new Color(color.X, color.Y, color.Z, color.W), alignment, GUI.style);
new Color(color.X, color.Y, color.Z, color.W), alignment, GUI.Style);
//guiFrame.Alpha = color.W;
break;
+2 -2
View File
@@ -34,12 +34,12 @@ namespace Subsurface.Items.Components
{
if (textBox == null)
{
textBox = new GUITextBox(Rectangle.Empty, GUI.style, GuiFrame);
textBox = new GUITextBox(Rectangle.Empty, GUI.Style, GuiFrame);
textBox.Wrap = true;
textBox.OnTextChanged = TextChanged;
textBox.LimitText = true;
GUIButton button = new GUIButton(new Rectangle(0,0,100,15), "OK", null, Alignment.BottomRight, GUI.style, GuiFrame);
GUIButton button = new GUIButton(new Rectangle(0,0,100,15), "OK", null, Alignment.BottomRight, GUI.Style, GuiFrame);
button.OnClicked = Close;
}
@@ -104,7 +104,7 @@ namespace Subsurface.Items.Components
}
}
private bool SelectItem(object obj)
private bool SelectItem(GUIComponent component, object obj)
{
FabricableItem targetItem = obj as FabricableItem;
if (targetItem == null) return false;
@@ -134,7 +134,7 @@ namespace Subsurface.Items.Components
Alignment.Left, null,
selectedItemFrame);
GUIButton button = new GUIButton(new Rectangle(0,0,100,20), "Create", Color.White, Alignment.CenterX | Alignment.Bottom, GUI.style, selectedItemFrame);
GUIButton button = new GUIButton(new Rectangle(0,0,100,20), "Create", Color.White, Alignment.CenterX | Alignment.Bottom, GUI.Style, selectedItemFrame);
button.OnClicked = StartFabricating;
button.UserData = targetItem;
+5 -5
View File
@@ -82,11 +82,11 @@ namespace Subsurface
int width = 400, height = 500;
int x = 0, y = 0;
frame = new GUIFrame(new Rectangle(0, 0, width, height), Color.White * 0.8f, Alignment.Center, GUI.style);
frame = new GUIFrame(new Rectangle(0, 0, width, height), Color.White * 0.8f, Alignment.Center, GUI.Style);
frame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
frame.UserData = item;
new GUITextBlock(new Rectangle(0,0,200,20), "Attempting to fix " + item.Name, GUI.style, frame);
new GUITextBlock(new Rectangle(0,0,200,20), "Attempting to fix " + item.Name, GUI.Style, frame);
y = y + 40;
foreach (FixRequirement requirement in item.FixRequirements)
@@ -97,7 +97,7 @@ namespace Subsurface
reqFrame.UserData = requirement;
var fixButton = new GUIButton(new Rectangle(0, 0, 50, 20), "Fix", GUI.style, reqFrame);
var fixButton = new GUIButton(new Rectangle(0, 0, 50, 20), "Fix", GUI.Style, reqFrame);
fixButton.OnClicked = FixButtonPressed;
fixButton.UserData = requirement;
@@ -107,7 +107,7 @@ namespace Subsurface
int y2 = 20;
foreach (string itemName in requirement.requiredItems)
{
var itemBlock = new GUITextBlock(new Rectangle(30, y2, 200, 15), itemName, GUI.style, reqFrame);
var itemBlock = new GUITextBlock(new Rectangle(30, y2, 200, 15), itemName, GUI.Style, reqFrame);
itemBlock.Font = GUI.SmallFont;
itemBlock.UserData = itemName;
@@ -117,7 +117,7 @@ namespace Subsurface
y2 = 20;
foreach (Skill skill in requirement.requiredSkills)
{
var skillBlock = new GUITextBlock(new Rectangle(150, y2, 200, 15), skill.Name + " - " + skill.Level, GUI.style, Alignment.Right, Alignment.TopLeft, reqFrame);
var skillBlock = new GUITextBlock(new Rectangle(150, y2, 200, 15), skill.Name + " - " + skill.Level, GUI.Style, Alignment.Right, Alignment.TopLeft, reqFrame);
skillBlock.Font = GUI.SmallFont;
skillBlock.UserData = skill;
+6 -6
View File
@@ -635,11 +635,11 @@ namespace Subsurface
}
}
editingHUD = new GUIFrame(new Rectangle(x, y, width, 60 + (editableProperties.Count() + requiredItemCount) * 30), GUI.style);
editingHUD = new GUIFrame(new Rectangle(x, y, width, 60 + (editableProperties.Count() + requiredItemCount) * 30), GUI.Style);
editingHUD.Padding = new Vector4(10, 10, 0, 0);
editingHUD.UserData = this;
new GUITextBlock(new Rectangle(0, 0, 100, 20), prefab.Name, GUI.style,
new GUITextBlock(new Rectangle(0, 0, 100, 20), prefab.Name, GUI.Style,
Alignment.TopLeft, Alignment.TopLeft, editingHUD, false, GUI.LargeFont);
y += 20;
@@ -649,15 +649,15 @@ namespace Subsurface
if (prefab.IsLinkable)
{
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Hold space to link to another item",
GUI.style, Alignment.TopLeft, Alignment.TopRight, editingHUD);
GUI.Style, Alignment.TopLeft, Alignment.TopRight, editingHUD);
y += 25;
}
foreach (ItemComponent ic in components)
{
foreach (RelatedItem relatedItem in ic.requiredItems)
{
new GUITextBlock(new Rectangle(0, y, 100, 20), ic.Name + ": " + relatedItem.Type.ToString() + " required", GUI.style, editingHUD);
GUITextBox namesBox = new GUITextBox(new Rectangle(0, y, 200, 20), Alignment.Right, GUI.style, editingHUD);
new GUITextBlock(new Rectangle(0, y, 100, 20), ic.Name + ": " + relatedItem.Type.ToString() + " required", GUI.Style, editingHUD);
GUITextBox namesBox = new GUITextBox(new Rectangle(0, y, 200, 20), Alignment.Right, GUI.Style, editingHUD);
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (relatedItem);
PropertyDescriptor property = properties.Find("JoinedNames", false);
@@ -681,7 +681,7 @@ namespace Subsurface
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault<Editable>();
if (editable != null) height = (int)(Math.Ceiling(editable.MaxLength / 20.0f) * 20.0f);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, height), GUI.style, editingHUD);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, height), GUI.Style, editingHUD);
if (height>20) propertyBox.Wrap = true;
object value = objectProperty.GetValue();
+2 -2
View File
@@ -97,7 +97,7 @@ namespace Subsurface
public Level(string seed, float difficulty, int width, int height, int siteInterval)
{
if (shaftTexture == null) shaftTexture = Game1.TextureLoader.FromFile("Content/Map/shaft.png");
if (shaftTexture == null) shaftTexture = TextureLoader.FromFile("Content/Map/shaft.png");
if (basicEffect==null)
{
@@ -106,7 +106,7 @@ namespace Subsurface
basicEffect.VertexColorEnabled = false;
basicEffect.TextureEnabled = true;
basicEffect.Texture = Game1.TextureLoader.FromFile("Content/Map/iceSurface.png");
basicEffect.Texture = TextureLoader.FromFile("Content/Map/iceSurface.png");
}
this.seed = seed;
+1 -1
View File
@@ -46,7 +46,7 @@ namespace Subsurface.Lights
penumbraEffect.TextureEnabled = true;
//shadowEffect.VertexColorEnabled = true;
penumbraEffect.LightingEnabled = false;
penumbraEffect.Texture = Game1.TextureLoader.FromFile("Content/Lights/penumbra.png");
penumbraEffect.Texture = TextureLoader.FromFile("Content/Lights/penumbra.png");
}
if (penumbraVertices==null)
+1 -1
View File
@@ -43,7 +43,7 @@ namespace Subsurface.Lights
if (lightTexture == null)
{
lightTexture = Game1.TextureLoader.FromFile("Content/Lights/light.png");
lightTexture = TextureLoader.FromFile("Content/Lights/light.png");
}
texture = lightTexture;
+1 -1
View File
@@ -41,7 +41,7 @@ namespace Subsurface.Lights
if (alphaClearTexture==null)
{
alphaClearTexture = Game1.TextureLoader.FromFile("Content/Lights/alphaOne.png");
alphaClearTexture = TextureLoader.FromFile("Content/Lights/alphaOne.png");
}
}
+2 -2
View File
@@ -69,8 +69,8 @@ namespace Subsurface
connections = new List<LocationConnection>();
if (iceTexture==null) iceTexture = new Sprite("Content/Map/iceSurface.png", Vector2.Zero);
if (iceCraters == null) iceCraters = Game1.TextureLoader.FromFile("Content/Map/iceCraters.png");
if (iceCrack == null) iceCrack = Game1.TextureLoader.FromFile("Content/Map/iceCrack.png");
if (iceCraters == null) iceCraters = TextureLoader.FromFile("Content/Map/iceCraters.png");
if (iceCrack == null) iceCrack = TextureLoader.FromFile("Content/Map/iceCrack.png");
Rand.SetSyncedSeed(ToolBox.StringToInt(this.seed));
+7 -6
View File
@@ -31,10 +31,10 @@ namespace Subsurface
waterEffect = new Effect(graphicsDevice, bytecode);
waterTexture = Game1.TextureLoader.FromFile("Content/waterbump.jpg");
waterEffect.Parameters["xWaveWidth"].SetValue(0.1f);
waterEffect.Parameters["xWaveHeight"].SetValue(0.1f);
waterEffect.Parameters["xBlurDistance"].SetValue(0.0007f);
waterTexture = TextureLoader.FromFile("Content/waterbump.png");
waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);
if (basicEffect==null)
{
@@ -45,13 +45,14 @@ namespace Subsurface
}
}
public void RenderBack (SpriteBatch spriteBatch, RenderTarget2D texture, Matrix transform)
public void RenderBack (SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0007f)
{
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap);
waterEffect.CurrentTechnique = waterEffect.Techniques["WaterShader"];
waterEffect.Parameters["xTexture"].SetValue(texture);
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
waterEffect.CurrentTechnique.Passes[0].Apply();
wavePos.X += 0.0001f;
+8 -8
View File
@@ -150,17 +150,17 @@ namespace Subsurface
editingHUD.Padding = new Vector4(10, 10, 0, 0);
editingHUD.UserData = this;
new GUITextBlock(new Rectangle(0, 0, 100, 20), "Editing waypoint", GUI.style, editingHUD);
new GUITextBlock(new Rectangle(0, 20, 100, 20), "Hold space to link to another entity", GUI.style, editingHUD);
new GUITextBlock(new Rectangle(0, 40, 100, 20), "Spawnpoint: ", GUI.style, editingHUD);
new GUITextBlock(new Rectangle(0, 0, 100, 20), "Editing waypoint", GUI.Style, editingHUD);
new GUITextBlock(new Rectangle(0, 20, 100, 20), "Hold space to link to another entity", GUI.Style, editingHUD);
new GUITextBlock(new Rectangle(0, 40, 100, 20), "Spawnpoint: ", GUI.Style, editingHUD);
var spawnTypeText = new GUITextBlock(new Rectangle(0, 40, 200, 20), spawnType.ToString(), GUI.style, Alignment.Right, Alignment.TopLeft, editingHUD);
var spawnTypeText = new GUITextBlock(new Rectangle(0, 40, 200, 20), spawnType.ToString(), GUI.Style, Alignment.Right, Alignment.TopLeft, editingHUD);
var button = new GUIButton(new Rectangle(-30,0,20,20), "-", Alignment.Right, GUI.style, spawnTypeText);
var button = new GUIButton(new Rectangle(-30,0,20,20), "-", Alignment.Right, GUI.Style, spawnTypeText);
button.UserData = -1;
button.OnClicked = ChangeSpawnType;
button = new GUIButton(new Rectangle(0, 0, 20, 20), "+", Alignment.Right, GUI.style, spawnTypeText);
button = new GUIButton(new Rectangle(0, 0, 20, 20), "+", Alignment.Right, GUI.Style, spawnTypeText);
button.UserData = 1;
button.OnClicked = ChangeSpawnType;
@@ -169,14 +169,14 @@ namespace Subsurface
y = 40+20;
new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card tags:", Color.Transparent, Color.Black, Alignment.TopLeft, null, editingHUD);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), GUI.style, editingHUD);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), GUI.Style, editingHUD);
propertyBox.Text = string.Join(", ", idCardTags);
propertyBox.OnEnter = EnterIDCardTags;
propertyBox.OnTextChanged = TextBoxChanged;
y = y + 30;
new GUITextBlock(new Rectangle(0, y, 100, 20), "Assigned job:", Color.Transparent, Color.Black, Alignment.TopLeft, null, editingHUD);
propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), GUI.style, editingHUD);
propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), GUI.Style, editingHUD);
propertyBox.Text = (assignedJob == null) ? "None" : assignedJob.Name;
propertyBox.OnEnter = EnterAssignedJob;
+7 -3
View File
@@ -36,7 +36,7 @@ namespace Subsurface.Networking
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
{
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.style, inGameHUD);
var endRoundButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
endRoundButton.OnClicked = EndButtonHit;
this.name = name;
@@ -419,7 +419,7 @@ namespace Subsurface.Networking
AddChatMessage(sender.name + " has joined the server", ChatMessageType.Server);
UpdateNetLobby(null);
UpdateNetLobby(null, null);
}
}
else if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected)
@@ -798,10 +798,14 @@ namespace Subsurface.Networking
y += 50;
}
}
public bool UpdateNetLobby(object obj)
{
return UpdateNetLobby(null, obj);
}
public bool UpdateNetLobby(GUIComponent component, object obj)
{
NetOutgoingMessage msg = server.CreateMessage();
msg.Write((byte)PacketTypes.UpdateNetLobby);
@@ -96,15 +96,15 @@ namespace Subsurface.Networking
Game1.GraphicsWidth - 20 - width,
Game1.GraphicsHeight - 40 - 25 - height,
width, height),
Color.White * 0.5f, GUI.style, inGameHUD);
Color.White * 0.5f, GUI.Style, inGameHUD);
chatMsgBox = new GUITextBox(
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25),
Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.style, inGameHUD);
Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.Style, inGameHUD);
chatMsgBox.Font = GUI.SmallFont;
chatMsgBox.OnEnter = EnterChatMessage;
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.style, inGameHUD);
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.Style, inGameHUD);
crewButton.OnClicked = ToggleCrewFrame;
}
@@ -112,10 +112,10 @@ namespace Subsurface.Networking
{
int width = 500, height = 400;
crewFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.style);
crewFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 200, 300), Color.White * 0.7f, GUI.style, crewFrame);
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 200, 300), Color.White * 0.7f, GUI.Style, crewFrame);
crewList.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
crewList.OnSelected = SelectCharacter;
@@ -138,11 +138,11 @@ namespace Subsurface.Networking
new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.limbs[0].sprite, Alignment.Left, frame);
}
var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.style, crewFrame);
var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.Style, crewFrame);
closeButton.OnClicked = ToggleCrewFrame;
}
private bool SelectCharacter(object obj)
private bool SelectCharacter(GUIComponent component, object obj)
{
Character character = obj as Character;
if (obj == null) return false;
@@ -152,7 +152,7 @@ namespace Subsurface.Networking
var previewPlayer = new GUIFrame(
new Rectangle(0,0, 230, 300),
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.style, crewFrame);
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.Style, crewFrame);
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
previewPlayer.UserData = "selectedcharacter";
+1 -1
View File
@@ -65,7 +65,7 @@ namespace Subsurface
}
}
static class PlayerInput
public static class PlayerInput
{
static MouseState mouseState, oldMouseState;
static KeyboardState keyboardState, oldKeyboardState;
@@ -43,18 +43,18 @@ namespace Subsurface
cam = new Camera();
GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, Game1.GraphicsHeight), GUI.style);
GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, Game1.GraphicsHeight), GUI.Style);
GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Alignment.Left, GUI.style, GUIpanel);
physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Alignment.Left, GUI.Style, GUIpanel);
physicsButton.OnClicked += TogglePhysics;
new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", GUI.style, GUIpanel);
limbList = new GUIListBox(new Rectangle(0, 110, 0, 250), Color.White * 0.7f, GUI.style, GUIpanel);
new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", GUI.Style, GUIpanel);
limbList = new GUIListBox(new Rectangle(0, 110, 0, 250), Color.White * 0.7f, GUI.Style, GUIpanel);
limbList.OnSelected = SelectLimb;
new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", GUI.style, GUIpanel);
jointList = new GUIListBox(new Rectangle(0, 390, 0, 250), Color.White * 0.7f, GUI.style, GUIpanel);
new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", GUI.Style, GUIpanel);
jointList = new GUIListBox(new Rectangle(0, 390, 0, 250), Color.White * 0.7f, GUI.Style, GUIpanel);
while (Character.CharacterList.Count > 1)
{
@@ -304,7 +304,7 @@ namespace Subsurface
}
}
private bool SelectLimb(object selection)
private bool SelectLimb(GUIComponent component, object selection)
{
try
{
+9 -9
View File
@@ -31,34 +31,34 @@ namespace Subsurface
selectedTab = -1;
GUIpanel = new GUIFrame(new Rectangle(0, 0, 150, Game1.GraphicsHeight), GUI.style);
GUIpanel = new GUIFrame(new Rectangle(0, 0, 150, Game1.GraphicsHeight), GUI.Style);
GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
//GUIListBox constructionList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUIpanel);
//constructionList.OnSelected = MapEntityPrefab.SelectPrefab;
//constructionList.CheckSelected = MapEntityPrefab.GetSelected;
GUIButton button = new GUIButton(new Rectangle(0, 50, 100, 20), "Items", Alignment.Left, GUI.style, GUIpanel);
GUIButton button = new GUIButton(new Rectangle(0, 50, 100, 20), "Items", Alignment.Left, GUI.Style, GUIpanel);
button.UserData = 0;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 80, 100, 20), "Structures", Alignment.Left, GUI.style, GUIpanel);
button = new GUIButton(new Rectangle(0, 80, 100, 20), "Structures", Alignment.Left, GUI.Style, GUIpanel);
button.UserData = 1;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 140, 100, 20), "Character mode", Alignment.Left, GUI.style, GUIpanel);
button = new GUIButton(new Rectangle(0, 140, 100, 20), "Character mode", Alignment.Left, GUI.Style, GUIpanel);
button.OnClicked = ToggleCharacterMode;
GUItabs = new GUIComponent[2];
int width = 400, height = 400;
GUItabs[0] = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-width/2, Game1.GraphicsHeight/2-height/2, width, height), GUI.style);
GUItabs[0] = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-width/2, Game1.GraphicsHeight/2-height/2, width, height), GUI.Style);
GUItabs[0].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.style, GUItabs[0]);
GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.Style, GUItabs[0]);
itemList.OnSelected = SelectPrefab;
itemList.CheckSelected = MapEntityPrefab.GetSelected;
GUItabs[1] = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.style);
GUItabs[1] = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
GUItabs[1].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.style, GUItabs[1]);
GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.Style, GUItabs[1]);
structureList.OnSelected = SelectPrefab;
structureList.CheckSelected = MapEntityPrefab.GetSelected;
@@ -154,7 +154,7 @@ namespace Subsurface
return true;
}
private bool SelectPrefab(object obj)
private bool SelectPrefab(GUIComponent component, object obj)
{
MapEntityPrefab.SelectPrefab(obj);
selectedTab = -1;
+1 -1
View File
@@ -246,7 +246,7 @@ namespace Subsurface
//2. pass the renderTarget to the water shader to do the water effect
//----------------------------------------------------------------------------------------
Hull.renderer.RenderBack(spriteBatch, renderTargetWater, Cam.ShaderTransform);
Hull.renderer.RenderBack(spriteBatch, renderTargetWater);
Array.Clear(Hull.renderer.vertices, 0, Hull.renderer.vertices.Length);
Hull.renderer.PositionInBuffer = 0;
+31 -31
View File
@@ -60,29 +60,29 @@ namespace Subsurface
180,
Game1.GraphicsHeight - 80);
leftPanel = new GUIFrame(panelRect, GUI.style);
leftPanel = new GUIFrame(panelRect, GUI.Style);
//leftPanel.Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 200, 25),
"asdfdasfasdf", Color.Transparent, Color.White, Alignment.Left, GUI.style, leftPanel);
"asdfdasfasdf", Color.Transparent, Color.White, Alignment.Left, GUI.Style, leftPanel);
GUITextBlock moneyText = new GUITextBlock(new Rectangle(0, 30, 200, 25),
"", Color.Transparent, Color.White, Alignment.Left, GUI.style, leftPanel);
"", Color.Transparent, Color.White, Alignment.Left, GUI.Style, leftPanel);
moneyText.TextGetter = GetMoney;
GUIButton button = new GUIButton(new Rectangle(0, 70, 100, 30), "Map", null, Alignment.Left, GUI.style, leftPanel);
GUIButton button = new GUIButton(new Rectangle(0, 70, 100, 30), "Map", null, Alignment.Left, GUI.Style, leftPanel);
button.UserData = PanelTab.Map;
button.OnClicked = SelectRightPanel;
button = new GUIButton(new Rectangle(0, 110, 100, 30), "Crew", null, Alignment.Left, GUI.style, leftPanel);
button = new GUIButton(new Rectangle(0, 110, 100, 30), "Crew", null, Alignment.Left, GUI.Style, leftPanel);
button.UserData = PanelTab.Crew;
button.OnClicked = SelectRightPanel;
button = new GUIButton(new Rectangle(0, 150, 100, 30), "Hire", null, Alignment.Left, GUI.style, leftPanel);
button = new GUIButton(new Rectangle(0, 150, 100, 30), "Hire", null, Alignment.Left, GUI.Style, leftPanel);
button.UserData = PanelTab.CurrentLocation;
button.OnClicked = SelectRightPanel;
button = new GUIButton(new Rectangle(0, 190, 100, 30), "Store", null, Alignment.Left, GUI.style, leftPanel);
button = new GUIButton(new Rectangle(0, 190, 100, 30), "Store", null, Alignment.Left, GUI.Style, leftPanel);
button.UserData = PanelTab.Store;
button.OnClicked = SelectRightPanel;
@@ -97,42 +97,42 @@ namespace Subsurface
rightPanel = new GUIFrame[4];
rightPanel[(int)PanelTab.Crew] = new GUIFrame(panelRect, GUI.style);
rightPanel[(int)PanelTab.Crew] = new GUIFrame(panelRect, GUI.Style);
//rightPanel[(int)PanelTab.Crew].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 200, 25), "Crew:", Color.Transparent, Color.White, Alignment.Left, GUI.style, rightPanel[(int)PanelTab.Crew]);
new GUITextBlock(new Rectangle(0, 0, 200, 25), "Crew:", Color.Transparent, Color.White, Alignment.Left, GUI.Style, rightPanel[(int)PanelTab.Crew]);
characterList = new GUIListBox(new Rectangle(0, 30, 300, 0), GUI.style, rightPanel[(int)PanelTab.Crew]);
characterList = new GUIListBox(new Rectangle(0, 30, 300, 0), GUI.Style, rightPanel[(int)PanelTab.Crew]);
characterList.OnSelected = SelectCharacter;
//---------------------------------------
rightPanel[(int)PanelTab.Map] = new GUIFrame(panelRect, GUI.style);
rightPanel[(int)PanelTab.Map] = new GUIFrame(panelRect, GUI.Style);
//rightPanel[(int)PanelTab.Map].Padding = GUI.style.smallPadding;
startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",
Alignment.BottomRight, GUI.style, rightPanel[(int)PanelTab.Map]);
Alignment.BottomRight, GUI.Style, rightPanel[(int)PanelTab.Map]);
startButton.OnClicked = StartShift;
startButton.Enabled = false;
//---------------------------------------
rightPanel[(int)PanelTab.CurrentLocation] = new GUIFrame(panelRect, GUI.style);
rightPanel[(int)PanelTab.CurrentLocation] = new GUIFrame(panelRect, GUI.Style);
//---------------------------------------
rightPanel[(int)PanelTab.Store] = new GUIFrame(panelRect, GUI.style);
rightPanel[(int)PanelTab.Store] = new GUIFrame(panelRect, GUI.Style);
selectedItemList = new GUIListBox(new Rectangle(0, 0, 300, 400), Color.White * 0.7f, GUI.style, rightPanel[(int)PanelTab.Store]);
selectedItemList = new GUIListBox(new Rectangle(0, 0, 300, 400), Color.White * 0.7f, GUI.Style, rightPanel[(int)PanelTab.Store]);
selectedItemList.OnSelected = DeselectItem;
var costText = new GUITextBlock(new Rectangle(0, 0, 200, 25), "Cost: ", GUI.style, Alignment.BottomLeft, Alignment.TopLeft, rightPanel[(int)PanelTab.Store]);
var costText = new GUITextBlock(new Rectangle(0, 0, 200, 25), "Cost: ", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, rightPanel[(int)PanelTab.Store]);
costText.TextGetter = CostTextGetter;
buyButton = new GUIButton(new Rectangle(150, 0, 100, 25), "Buy", Alignment.Bottom, GUI.style, rightPanel[(int)PanelTab.Store]);
buyButton = new GUIButton(new Rectangle(150, 0, 100, 25), "Buy", Alignment.Bottom, GUI.Style, rightPanel[(int)PanelTab.Store]);
buyButton.OnClicked = BuyItems;
itemList = new GUIListBox(new Rectangle(0, 0, 300, 400), Color.White * 0.7f, Alignment.TopRight, GUI.style, rightPanel[(int)PanelTab.Store]);
itemList = new GUIListBox(new Rectangle(0, 0, 300, 400), Color.White * 0.7f, Alignment.TopRight, GUI.Style, rightPanel[(int)PanelTab.Store]);
itemList.OnSelected = SelectItem;
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
@@ -158,18 +158,18 @@ namespace Subsurface
private void UpdateLocationTab(Location location)
{
rightPanel[(int)PanelTab.CurrentLocation] = new GUIFrame(rightPanel[(int)PanelTab.CurrentLocation].Rect, GUI.style);
rightPanel[(int)PanelTab.CurrentLocation] = new GUIFrame(rightPanel[(int)PanelTab.CurrentLocation].Rect, GUI.Style);
rightPanel[(int)PanelTab.CurrentLocation].UserData = location;
//rightPanel[(int)PanelTab.Hire].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, 0, 200, 25),
"Location: "+location.Name, GUI.style, rightPanel[(int)PanelTab.CurrentLocation]);
"Location: "+location.Name, GUI.Style, rightPanel[(int)PanelTab.CurrentLocation]);
new GUITextBlock(new Rectangle(0, 20, 200, 25),
"("+location.Type.Name+")", GUI.style, rightPanel[(int)PanelTab.CurrentLocation]);
"("+location.Type.Name+")", GUI.Style, rightPanel[(int)PanelTab.CurrentLocation]);
if (location.HireManager != null)
{
hireList = new GUIListBox(new Rectangle(0, 60, 300, 0), GUI.style, Alignment.Left, rightPanel[(int)PanelTab.CurrentLocation]);
hireList = new GUIListBox(new Rectangle(0, 60, 300, 0), GUI.Style, Alignment.Left, rightPanel[(int)PanelTab.CurrentLocation]);
hireList.OnSelected = SelectCharacter;
hireList.ClearChildren();
@@ -177,14 +177,14 @@ namespace Subsurface
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
c.Name + " (" + c.Job.Name + ")", GUI.style, hireList);
c.Name + " (" + c.Job.Name + ")", GUI.Style, hireList);
textBlock.UserData = c;
textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
c.Salary.ToString(),
null, null,
Alignment.TopRight, GUI.style, textBlock);
Alignment.TopRight, GUI.Style, textBlock);
}
}
}
@@ -234,7 +234,7 @@ namespace Subsurface
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
c.Name + " (" + c.Job.Name + ")", GUI.style,
c.Name + " (" + c.Job.Name + ")", GUI.Style,
Alignment.Left,
Alignment.Left,
characterList);
@@ -266,7 +266,7 @@ namespace Subsurface
new Rectangle(0, 0, 0, 25),
ep.Price.ToString(),
null, null,
Alignment.TopRight, GUI.style, textBlock);
Alignment.TopRight, GUI.Style, textBlock);
if (ep.sprite != null)
{
@@ -275,7 +275,7 @@ namespace Subsurface
}
}
private bool SelectItem(object obj)
private bool SelectItem(GUIComponent component, object obj)
{
MapEntityPrefab prefab = obj as MapEntityPrefab;
if (prefab == null) return false;
@@ -287,7 +287,7 @@ namespace Subsurface
return false;
}
private bool DeselectItem(object obj)
private bool DeselectItem(GUIComponent component, object obj)
{
MapEntityPrefab prefab = obj as MapEntityPrefab;
if (prefab == null) return false;
@@ -383,7 +383,7 @@ namespace Subsurface
return "Money: " + ((Game1.GameSession == null) ? "" : gameMode.CrewManager.Money.ToString());
}
private bool SelectCharacter(object selection)
private bool SelectCharacter(GUIComponent component, object selection)
{
CharacterInfo characterInfo = selection as CharacterInfo;
if (characterInfo == null) return false;
@@ -394,7 +394,7 @@ namespace Subsurface
{
previewFrame = new GUIFrame(new Rectangle(350, 60, 300, 300),
new Color(0.0f, 0.0f, 0.0f, 0.8f),
Alignment.Top, GUI.style, rightPanel[selectedRightPanel]);
Alignment.Top, GUI.Style, rightPanel[selectedRightPanel]);
previewFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
previewFrame.UserData = characterInfo;
@@ -403,7 +403,7 @@ namespace Subsurface
if (selectedRightPanel == (int)PanelTab.CurrentLocation)
{
GUIButton hireButton = new GUIButton(new Rectangle(0,0, 100, 20), "Hire", Alignment.BottomCenter, GUI.style, previewFrame);
GUIButton hireButton = new GUIButton(new Rectangle(0,0, 100, 20), "Hire", Alignment.BottomCenter, GUI.Style, previewFrame);
hireButton.UserData = characterInfo;
hireButton.OnClicked = HireCharacter;
}
+92 -78
View File
@@ -9,7 +9,9 @@ namespace Subsurface
{
class MainMenuScreen : Screen
{
public enum Tabs { Main = 0, NewGame = 1, LoadGame = 2, HostServer = 3 }
public enum Tabs { NewGame = 1, LoadGame = 2, HostServer = 3 }
GUIFrame buttonsTab;
private GUIFrame[] menuTabs;
private GUIListBox mapList;
@@ -27,145 +29,154 @@ namespace Subsurface
public MainMenuScreen(Game1 game)
{
menuTabs = new GUIFrame[Enum.GetValues(typeof(Tabs)).Length];
menuTabs = new GUIFrame[Enum.GetValues(typeof(Tabs)).Length+1];
Rectangle panelRect = new Rectangle(
Game1.GraphicsWidth / 2 - 250,
Game1.GraphicsHeight/ 2 - 250,
500, 500);
menuTabs[(int)Tabs.Main] = new GUIFrame(panelRect, GUI.style);
buttonsTab = new GUIFrame(new Rectangle(50, 200, 200, 500), Color.Transparent, Alignment.Left);
//menuTabs[(int)Tabs.Main].Padding = GUI.style.smallPadding;
GUIButton button = new GUIButton(new Rectangle(0, 0, 0, 30), "Tutorial", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
Rectangle panelRect = new Rectangle(
Game1.GraphicsWidth / 2 - 250,
buttonsTab.Rect.Y,
500, 360);
GUIButton button = new GUIButton(new Rectangle(0, 0, 0, 30), "Tutorial", Alignment.CenterX, GUI.Style, buttonsTab);
button.OnClicked = TutorialButtonClicked;
button = new GUIButton(new Rectangle(0, 70, 0, 30), "New Game", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 70, 0, 30), "New Game", Alignment.CenterX, GUI.Style, buttonsTab);
button.UserData = (int)Tabs.NewGame;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 130, 0, 30), "Load Game", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 130, 0, 30), "Load Game", Alignment.CenterX, GUI.Style, buttonsTab);
button.UserData = (int)Tabs.LoadGame;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 200, 0, 30), "Join Server", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 200, 0, 30), "Join Server", Alignment.CenterX, GUI.Style, buttonsTab);
//button.UserData = (int)Tabs.JoinServer;
button.OnClicked = JoinServerClicked;
button = new GUIButton(new Rectangle(0, 260, 0, 30), "Host Server", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 260, 0, 30), "Host Server", Alignment.CenterX, GUI.Style, buttonsTab);
button.UserData = (int)Tabs.HostServer;
button.OnClicked = SelectTab;
button = new GUIButton(new Rectangle(0, 330, 0, 30), "Quit", Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.Main]);
button = new GUIButton(new Rectangle(0, 330, 0, 30), "Quit", Alignment.CenterX, GUI.Style, buttonsTab);
button.OnClicked = QuitClicked;
//----------------------------------------------------------------------
menuTabs[(int)Tabs.NewGame] = new GUIFrame(panelRect, GUI.style);
menuTabs[(int)Tabs.NewGame] = new GUIFrame(panelRect, GUI.Style);
//menuTabs[(int)Tabs.NewGame].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, -20, 0, 30), "New Game", null, null, Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.NewGame]);
//new GUITextBlock(new Rectangle(0, -20, 0, 30), "New Game", null, null, Alignment.CenterX, GUI.style, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected submarine:", null, null, Alignment.Left, GUI.style, menuTabs[(int)Tabs.NewGame]);
mapList = new GUIListBox(new Rectangle(0, 60, 200, 360), GUI.style, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Selected submarine:", null, null, Alignment.Left, GUI.Style, menuTabs[(int)Tabs.NewGame]);
mapList = new GUIListBox(new Rectangle(0, 30, 200, panelRect.Height-100), GUI.Style, menuTabs[(int)Tabs.NewGame]);
foreach (Submarine sub in Submarine.SavedSubmarines)
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
sub.Name,
GUI.style,
GUI.Style,
Alignment.Left, Alignment.Left, mapList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = sub;
}
if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]);
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 30, 100, 20),
"Save name: ", GUI.style, Alignment.Left, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 0, 100, 20),
"Save name: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 60, 180, 20),
Alignment.TopLeft, GUI.style, menuTabs[(int)Tabs.NewGame]);
saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 30, 180, 20),
Alignment.TopLeft, GUI.Style, menuTabs[(int)Tabs.NewGame]);
saveNameBox.Text = SaveUtil.CreateSavePath();
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 90, 100, 20),
"Map Seed: ", GUI.style, Alignment.Left, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 60, 100, 20),
"Map Seed: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tabs.NewGame]);
seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 120, 180, 20),
Alignment.TopLeft, GUI.style, menuTabs[(int)Tabs.NewGame]);
seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 90, 180, 20),
Alignment.TopLeft, GUI.Style, menuTabs[(int)Tabs.NewGame]);
seedBox.Text = ToolBox.RandomSeed(8);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, GUI.style, menuTabs[(int)Tabs.NewGame]);
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, GUI.Style, menuTabs[(int)Tabs.NewGame]);
button.OnClicked = StartGame;
//----------------------------------------------------------------------
menuTabs[(int)Tabs.LoadGame] = new GUIFrame(panelRect, GUI.style);
menuTabs[(int)Tabs.LoadGame] = new GUIFrame(panelRect, GUI.Style);
//menuTabs[(int)Tabs.LoadGame].Padding = GUI.style.smallPadding;
menuTabs[(int)Tabs.HostServer] = new GUIFrame(panelRect, GUI.style);
menuTabs[(int)Tabs.HostServer] = new GUIFrame(panelRect, GUI.Style);
//menuTabs[(int)Tabs.JoinServer].Padding = GUI.style.smallPadding;
new GUITextBlock(new Rectangle(0, -25, 0, 30), "Host Server", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.HostServer], false, GUI.LargeFont);
//new GUITextBlock(new Rectangle(0, -25, 0, 30), "Host Server", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.HostServer], false, GUI.LargeFont);
new GUITextBlock(new Rectangle(0, 50, 0, 30), "Server Name:", GUI.style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
serverNameBox = new GUITextBox(new Rectangle(160, 50, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.style, menuTabs[(int)Tabs.HostServer]);
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Server Name:", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
serverNameBox = new GUITextBox(new Rectangle(160, 0, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tabs.HostServer]);
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server port:", GUI.style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
portBox = new GUITextBox(new Rectangle(160, 100, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.style, menuTabs[(int)Tabs.HostServer]);
new GUITextBlock(new Rectangle(0, 50, 0, 30), "Server port:", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
portBox = new GUITextBox(new Rectangle(160, 50, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tabs.HostServer]);
portBox.Text = NetConfig.DefaultPort.ToString();
portBox.ToolTip = "Server port";
new GUITextBlock(new Rectangle(0, 150, 100, 30), "Max players:", GUI.style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
maxPlayersBox = new GUITextBox(new Rectangle(195, 150, 30, 30), null, null, Alignment.TopLeft, Alignment.Center, GUI.style, menuTabs[(int)Tabs.HostServer]);
new GUITextBlock(new Rectangle(0, 100, 100, 30), "Max players:", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
maxPlayersBox = new GUITextBox(new Rectangle(195, 100, 30, 30), null, null, Alignment.TopLeft, Alignment.Center, GUI.Style, menuTabs[(int)Tabs.HostServer]);
maxPlayersBox.Text = "8";
maxPlayersBox.Enabled = false;
var plusPlayersBox = new GUIButton(new Rectangle(230, 150, 30, 30), "+", GUI.style, menuTabs[(int)Tabs.HostServer]);
var plusPlayersBox = new GUIButton(new Rectangle(230, 100, 30, 30), "+", GUI.Style, menuTabs[(int)Tabs.HostServer]);
plusPlayersBox.UserData = 1;
plusPlayersBox.OnClicked = ChangeMaxPlayers;
var minusPlayersBox = new GUIButton(new Rectangle(160, 150, 30, 30), "-", GUI.style, menuTabs[(int)Tabs.HostServer]);
var minusPlayersBox = new GUIButton(new Rectangle(160, 100, 30, 30), "-", GUI.Style, menuTabs[(int)Tabs.HostServer]);
minusPlayersBox.UserData = -1;
minusPlayersBox.OnClicked = ChangeMaxPlayers;
new GUITextBlock(new Rectangle(0, 200, 0, 30), "Password (optional):", GUI.style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
passwordBox = new GUITextBox(new Rectangle(160, 200, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.style, menuTabs[(int)Tabs.HostServer]);
isPublicBox = new GUITickBox(new Rectangle(10, 250, 20, 20), "Public server", Alignment.TopLeft, menuTabs[(int)Tabs.HostServer]);
useUpnpBox = new GUITickBox(new Rectangle(10, 300, 20, 20), "Attempt UPnP port forwarding", Alignment.TopLeft, menuTabs[(int)Tabs.HostServer]);
new GUITextBlock(new Rectangle(0, 330, 0, 30),
"UPnP can be used for forwarding ports on your router to allow players join the server."
+ " However, UPnP isn't supported by all routers, so you may need to setup port forwards manually"
+" if players are unable to join the server (see the readme for instructions).",
GUI.style, Alignment.TopLeft, Alignment.TopLeft, menuTabs[(int)Tabs.HostServer], true, GUI.SmallFont);
new GUITextBlock(new Rectangle(0, 150, 0, 30), "Password (optional):", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tabs.HostServer]);
passwordBox = new GUITextBox(new Rectangle(160, 170, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tabs.HostServer]);
isPublicBox = new GUITickBox(new Rectangle(10, 200, 20, 20), "Public server", Alignment.TopLeft, menuTabs[(int)Tabs.HostServer]);
isPublicBox.ToolTip = "Public servers are shown in the list of available servers in the ''Join Server'' -tab";
GUIButton hostButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.BottomCenter, GUI.style, menuTabs[(int)Tabs.HostServer]);
useUpnpBox = new GUITickBox(new Rectangle(10, 250, 20, 20), "Attempt UPnP port forwarding", Alignment.TopLeft, menuTabs[(int)Tabs.HostServer]);
useUpnpBox.ToolTip = "UPnP can be used for forwarding ports on your router to allow players join the server."
+ " However, UPnP isn't supported by all routers, so you may need to setup port forwards manually"
+" if players are unable to join the server (see the readme for instructions).";
GUIButton hostButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.BottomRight, GUI.Style, menuTabs[(int)Tabs.HostServer]);
hostButton.OnClicked = HostServerClicked;
//----------------------------------------------------------------------
for (int i = 1; i < 4; i++ )
{
button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menuTabs[i]);
button.OnClicked = PreviousTab;
}
this.game = game;
}
public override void Select()
{
base.Select();
selectedTab = 0;
}
public bool SelectTab(GUIButton button, object obj)
{
selectedTab = (int)obj;
if (button != null) button.Selected = true;
foreach (GUIComponent child in buttonsTab.children)
{
GUIButton otherButton = child as GUIButton;
if (otherButton == null || otherButton == button) continue;
otherButton.Selected = false;
}
if (selectedTab == (int)Tabs.LoadGame) UpdateLoadScreen();
this.Select();
if (Selected != this) this.Select();
return true;
}
@@ -229,11 +240,9 @@ namespace Subsurface
{
menuTabs[(int)Tabs.LoadGame].ClearChildren();
new GUITextBlock(new Rectangle(0, -25, 0, 30), "Load Game", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.LoadGame], false, GUI.LargeFont);
string[] saveFiles = SaveUtil.GetSaveFiles();
saveList = new GUIListBox(new Rectangle(0, 60, 200, 360), Color.White, GUI.style, menuTabs[(int)Tabs.LoadGame]);
saveList = new GUIListBox(new Rectangle(0, 0, 200, menuTabs[(int)Tabs.LoadGame].Rect.Height - 80), Color.White, GUI.Style, menuTabs[(int)Tabs.LoadGame]);
saveList.OnSelected = SelectSaveFile;
foreach (string saveFile in saveFiles)
@@ -241,7 +250,7 @@ namespace Subsurface
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
saveFile,
GUI.style,
GUI.Style,
Alignment.Left,
Alignment.Left,
saveList);
@@ -249,14 +258,12 @@ namespace Subsurface
textBlock.UserData = saveFile;
}
var button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.Right | Alignment.Bottom, GUI.style, menuTabs[(int)Tabs.LoadGame]);
var button = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.Right | Alignment.Bottom, GUI.Style, menuTabs[(int)Tabs.LoadGame]);
button.OnClicked = LoadGame;
button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menuTabs[(int)Tabs.LoadGame]);
button.OnClicked = PreviousTab;
}
private bool SelectSaveFile(object obj)
private bool SelectSaveFile(GUIComponent component, object obj)
{
string fileName = (string)obj;
@@ -283,19 +290,19 @@ namespace Subsurface
string mapseed = ToolBox.GetAttributeString(modeElement, "mapseed", "unknown");
GUIFrame saveFileFrame = new GUIFrame(new Rectangle((int)(saveList.Rect.Width + 20), 60, 200, 200), Color.Black*0.4f, GUI.style, menuTabs[(int)Tabs.LoadGame]);
GUIFrame saveFileFrame = new GUIFrame(new Rectangle((int)(saveList.Rect.Width + 20), 0, 200, 200), Color.Black*0.4f, GUI.Style, menuTabs[(int)Tabs.LoadGame]);
saveFileFrame.UserData = "savefileframe";
saveFileFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
new GUITextBlock(new Rectangle(0,0,0,20), fileName, GUI.style, saveFileFrame);
new GUITextBlock(new Rectangle(0,0,0,20), fileName, GUI.Style, saveFileFrame);
new GUITextBlock(new Rectangle(0, 30, 0, 20), "Last saved: ", GUI.style, saveFileFrame).Font = GUI.SmallFont;
new GUITextBlock(new Rectangle(15, 45, 0, 20), saveTime, GUI.style, saveFileFrame).Font = GUI.SmallFont;
new GUITextBlock(new Rectangle(0, 30, 0, 20), "Last saved: ", GUI.Style, saveFileFrame).Font = GUI.SmallFont;
new GUITextBlock(new Rectangle(15, 45, 0, 20), saveTime, GUI.Style, saveFileFrame).Font = GUI.SmallFont;
new GUITextBlock(new Rectangle(0, 65, 0, 20), "Map seed: ", GUI.style, saveFileFrame).Font = GUI.SmallFont;
new GUITextBlock(new Rectangle(15, 80, 0, 20), mapseed, GUI.style, saveFileFrame).Font = GUI.SmallFont;
new GUITextBlock(new Rectangle(0, 65, 0, 20), "Map seed: ", GUI.Style, saveFileFrame).Font = GUI.SmallFont;
new GUITextBlock(new Rectangle(15, 80, 0, 20), mapseed, GUI.Style, saveFileFrame).Font = GUI.SmallFont;
var deleteSaveButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Delete", Alignment.BottomCenter, GUI.style, saveFileFrame);
var deleteSaveButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Delete", Alignment.BottomCenter, GUI.Style, saveFileFrame);
deleteSaveButton.UserData = fileName;
deleteSaveButton.OnClicked = DeleteSave;
@@ -330,9 +337,15 @@ namespace Subsurface
public override void Update(double deltaTime)
{
menuTabs[selectedTab].Update((float)deltaTime);
buttonsTab.Update((float)deltaTime);
if (selectedTab>0) menuTabs[selectedTab].Update((float)deltaTime);
Game1.TitleScreen.Position.Y = MathHelper.Lerp(Game1.TitleScreen.Position.Y, -870.0f, 0.1f);
Game1.TitleScreen.TitlePosition =
Vector2.Lerp(Game1.TitleScreen.TitlePosition, new Vector2(
Game1.TitleScreen.TitleSize.X / 2.0f * Game1.TitleScreen.Scale + 30.0f,
Game1.TitleScreen.TitleSize.Y / 2.0f * Game1.TitleScreen.Scale + 30.0f),
0.1f);
}
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
@@ -345,7 +358,8 @@ namespace Subsurface
spriteBatch.Begin();
menuTabs[selectedTab].Draw(spriteBatch);
buttonsTab.Draw(spriteBatch);
if (selectedTab>0) menuTabs[selectedTab].Draw(spriteBatch);
GUI.Draw((float)deltaTime, spriteBatch, null);
@@ -384,7 +398,7 @@ namespace Subsurface
private bool PreviousTab(GUIButton button, object obj)
{
selectedTab = (int)Tabs.Main;
//selectedTab = (int)Tabs.Main;
return true;
}
+37 -37
View File
@@ -115,7 +115,7 @@ namespace Subsurface
//server info panel ------------------------------------------------------------
infoFrame = new GUIFrame(new Rectangle(0, 0, (int)(panelRect.Width * 0.7f), (int)(panelRect.Height * 0.6f)), GUI.style, menu);
infoFrame = new GUIFrame(new Rectangle(0, 0, (int)(panelRect.Width * 0.7f), (int)(panelRect.Height * 0.6f)), GUI.Style, menu);
//infoFrame.Padding = GUI.style.smallPadding;
//chatbox ----------------------------------------------------------------------
@@ -123,10 +123,10 @@ namespace Subsurface
new Rectangle(0, (int)(panelRect.Height * 0.6f + 20),
(int)(panelRect.Width * 0.7f),
(int)(panelRect.Height * 0.4f - 20)),
GUI.style, menu);
GUI.Style, menu);
chatBox = new GUIListBox(new Rectangle(0,0,0,chatFrame.Rect.Height-80), Color.White, GUI.style, chatFrame);
textBox = new GUITextBox(new Rectangle(0, 25, 0, 25), Alignment.Bottom, GUI.style, chatFrame);
chatBox = new GUIListBox(new Rectangle(0,0,0,chatFrame.Rect.Height-80), Color.White, GUI.Style, chatFrame);
textBox = new GUITextBox(new Rectangle(0, 25, 0, 25), Alignment.Bottom, GUI.Style, chatFrame);
textBox.Font = GUI.SmallFont;
textBox.OnEnter = EnterChatMessage;
@@ -135,24 +135,24 @@ namespace Subsurface
playerFrame = new GUIFrame(
new Rectangle((int)(panelRect.Width * 0.7f + 20), 0,
(int)(panelRect.Width * 0.3f - 20), (int)(panelRect.Height * 0.6f)),
GUI.style, menu);
GUI.Style, menu);
//player list ------------------------------------------------------------------
GUIFrame playerListFrame = new GUIFrame(
new Rectangle((int)(panelRect.Width * 0.7f + 20), (int)(panelRect.Height * 0.6f + 20),
(int)(panelRect.Width * 0.3f - 20), (int)(panelRect.Height * 0.4f - 20)),
GUI.style, menu);
GUI.Style, menu);
playerList = new GUIListBox(new Rectangle(0,0,0,0), null, GUI.style, playerListFrame);
playerList = new GUIListBox(new Rectangle(0,0,0,0), null, GUI.Style, playerListFrame);
//submarine list ------------------------------------------------------------------
int columnWidth = infoFrame.Rect.Width / 5 - 30;
int columnX = 0;
new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Selected submarine:", GUI.style, infoFrame);
subList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), Color.White, GUI.style, infoFrame);
new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Selected submarine:", GUI.Style, infoFrame);
subList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), Color.White, GUI.Style, infoFrame);
subList.OnSelected = SelectMap;
if (Submarine.SavedSubmarines.Count > 0)
@@ -161,7 +161,7 @@ namespace Subsurface
{
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
sub.Name, GUI.style,
sub.Name, GUI.Style,
Alignment.Left, Alignment.Left,
subList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
@@ -178,8 +178,8 @@ namespace Subsurface
//gamemode ------------------------------------------------------------------
new GUITextBlock(new Rectangle(columnX, 120, 0, 30), "Selected game mode: ", GUI.style, infoFrame);
modeList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), GUI.style, infoFrame);
new GUITextBlock(new Rectangle(columnX, 120, 0, 30), "Selected game mode: ", GUI.Style, infoFrame);
modeList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), GUI.Style, infoFrame);
foreach (GameModePreset mode in GameModePreset.list)
@@ -188,7 +188,7 @@ namespace Subsurface
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
mode.Name, GUI.style,
mode.Name, GUI.Style,
Alignment.Left, Alignment.Left,
modeList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
@@ -202,7 +202,7 @@ namespace Subsurface
var modeDescription = new GUITextBlock(
new Rectangle(columnX, 150, (int)(columnWidth * 1.5f), infoFrame.Rect.Height - 150 - 80),
"", Color.Black*0.3f, Color.White, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame, true);
"", Color.Black*0.3f, Color.White, Alignment.TopLeft, Alignment.TopLeft, GUI.Style, infoFrame, true);
modeList.UserData = modeDescription;
@@ -211,31 +211,31 @@ namespace Subsurface
//duration ------------------------------------------------------------------
GUITextBlock durationText = new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 20),
"Game duration: ", GUI.style, Alignment.Left, Alignment.TopLeft, infoFrame);
"Game duration: ", GUI.Style, Alignment.Left, Alignment.TopLeft, infoFrame);
durationText.TextGetter = DurationText;
durationBar = new GUIScrollBar(new Rectangle(columnX, 150, columnWidth, 20),
GUI.style, 0.1f, infoFrame);
GUI.Style, 0.1f, infoFrame);
durationBar.BarSize = 0.1f;
//seed ------------------------------------------------------------------
new GUITextBlock(new Rectangle(columnX, 190, columnWidth, 20),
"Level Seed: ", GUI.style, Alignment.Left, Alignment.TopLeft, infoFrame);
"Level Seed: ", GUI.Style, Alignment.Left, Alignment.TopLeft, infoFrame);
seedBox = new GUITextBox(new Rectangle(columnX, 220, columnWidth, 20),
Alignment.TopLeft, GUI.style, infoFrame);
Alignment.TopLeft, GUI.Style, infoFrame);
seedBox.OnTextChanged = SelectSeed;
LevelSeed = ToolBox.RandomSeed(8);
//server info ------------------------------------------------------------------
var serverName = new GUITextBox(new Rectangle(0, 0, 200, 20), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame);
var serverName = new GUITextBox(new Rectangle(0, 0, 200, 20), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.Style, infoFrame);
serverName.TextGetter = GetServerName;
serverName.Enabled = Game1.Server != null;
serverName.OnTextChanged = ChangeServerName;
serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.style, infoFrame);
serverMessage = new GUITextBox(new Rectangle(0, 30, 360, 70), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.Style, infoFrame);
serverMessage.Wrap = true;
serverMessage.TextGetter = GetServerMessage;
serverMessage.OnTextChanged = UpdateServerMessage;
@@ -270,7 +270,7 @@ namespace Subsurface
if (IsServer && Game1.Server != null)
{
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.BottomRight, GUI.style, infoFrame);
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame);
startButton.OnClicked = Game1.Server.StartGame;
startButton.UserData = "startButton";
@@ -311,42 +311,42 @@ namespace Subsurface
playYourself.UserData = "playyourself";
}
new GUITextBlock(new Rectangle(60, 0, 200, 30), "Name: ", GUI.style, playerFrame);
new GUITextBlock(new Rectangle(60, 0, 200, 30), "Name: ", GUI.Style, playerFrame);
GUITextBox playerName = new GUITextBox(new Rectangle(60, 30, 0, 20),
Alignment.TopLeft, GUI.style, playerFrame);
Alignment.TopLeft, GUI.Style, playerFrame);
playerName.Text = characterInfo.Name;
playerName.OnEnter += ChangeCharacterName;
new GUITextBlock(new Rectangle(0, 70, 200, 30), "Gender: ", GUI.style, playerFrame);
new GUITextBlock(new Rectangle(0, 70, 200, 30), "Gender: ", GUI.Style, playerFrame);
GUIButton maleButton = new GUIButton(new Rectangle(0, 100, 70, 20), "Male",
Alignment.TopLeft, GUI.style, playerFrame);
Alignment.TopLeft, GUI.Style, playerFrame);
maleButton.UserData = Gender.Male;
maleButton.OnClicked += SwitchGender;
GUIButton femaleButton = new GUIButton(new Rectangle(90, 100, 70, 20), "Female",
Alignment.TopLeft, GUI.style, playerFrame);
Alignment.TopLeft, GUI.Style, playerFrame);
femaleButton.UserData = Gender.Female;
femaleButton.OnClicked += SwitchGender;
new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", GUI.style, playerFrame);
new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", GUI.Style, playerFrame);
jobList = new GUIListBox(new Rectangle(0, 180, 180, 0), GUI.style, playerFrame);
jobList = new GUIListBox(new Rectangle(0, 180, 180, 0), GUI.Style, playerFrame);
jobList.Enabled = false;
int i = 1;
foreach (JobPrefab job in JobPrefab.List)
{
GUITextBlock jobText = new GUITextBlock(new Rectangle(0, 0, 0, 20), i + ". " + job.Name, GUI.style, Alignment.Left, Alignment.Right, jobList);
GUITextBlock jobText = new GUITextBlock(new Rectangle(0, 0, 0, 20), i + ". " + job.Name, GUI.Style, Alignment.Left, Alignment.Right, jobList);
jobText.UserData = job;
GUIButton upButton = new GUIButton(new Rectangle(0, 0, 15, 15), "u", GUI.style, jobText);
GUIButton upButton = new GUIButton(new Rectangle(0, 0, 15, 15), "u", GUI.Style, jobText);
upButton.UserData = -1;
upButton.OnClicked += ChangeJobPreference;
GUIButton downButton = new GUIButton(new Rectangle(25, 0, 15, 15), "d", GUI.style, jobText);
GUIButton downButton = new GUIButton(new Rectangle(25, 0, 15, 15), "d", GUI.Style, jobText);
downButton.UserData = 1;
downButton.OnClicked += ChangeJobPreference;
}
@@ -383,7 +383,7 @@ namespace Subsurface
return false;
}
private bool SelectMap(object obj)
private bool SelectMap(GUIComponent component, object obj)
{
if (Game1.Server != null) Game1.Server.UpdateNetLobby(obj);
@@ -401,7 +401,7 @@ namespace Subsurface
{
if (Game1.Server == null) return false;
ServerName = text;
Game1.Server.UpdateNetLobby(null);
Game1.Server.UpdateNetLobby(null, null);
return true;
}
@@ -410,7 +410,7 @@ namespace Subsurface
{
if (Game1.Server == null) return false;
ServerMessage = text;
Game1.Server.UpdateNetLobby(null);
Game1.Server.UpdateNetLobby(null, null);
return true;
}
@@ -421,7 +421,7 @@ namespace Subsurface
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25),
client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")"),
GUI.style, Alignment.Left, Alignment.Left,
GUI.Style, Alignment.Left, Alignment.Left,
playerList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.UserData = client;
@@ -494,7 +494,7 @@ namespace Subsurface
GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, 0, 20),
message,
((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.1f, color,
Alignment.Left, GUI.style, null, true);
Alignment.Left, GUI.Style, null, true);
msg.Font = GUI.SmallFont;
msg.CanBeFocused = false;
@@ -545,7 +545,7 @@ namespace Subsurface
return true;
}
private bool SelectMode(object obj)
private bool SelectMode(GUIComponent component, object obj)
{
GameModePreset modePreset = obj as GameModePreset;
if (modePreset == null) return false;
+20 -20
View File
@@ -41,19 +41,19 @@ namespace Subsurface
Rectangle panelRect = new Rectangle(0, 0, width, height);
menu = new GUIFrame(panelRect, null, Alignment.Center, GUI.style);
menu = new GUIFrame(panelRect, null, Alignment.Center, GUI.Style);
new GUITextBlock(new Rectangle(0, -25, 0, 30), "Join Server", GUI.style, Alignment.CenterX, Alignment.CenterX, menu, false, GUI.LargeFont);
new GUITextBlock(new Rectangle(0, -25, 0, 30), "Join Server", GUI.Style, Alignment.CenterX, Alignment.CenterX, menu, false, GUI.LargeFont);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Your Name:", GUI.style, menu);
clientNameBox = new GUITextBox(new Rectangle(0, 60, 200, 30), GUI.style, menu);
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Your Name:", GUI.Style, menu);
clientNameBox = new GUITextBox(new Rectangle(0, 60, 200, 30), GUI.Style, menu);
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server IP:", GUI.style, menu);
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), GUI.style, menu);
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server IP:", GUI.Style, menu);
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), GUI.Style, menu);
int middleX = (int)(width * 0.4f);
serverList = new GUIListBox(new Rectangle(middleX,60,0,(int)(height*0.7f)), GUI.style, menu);
serverList = new GUIListBox(new Rectangle(middleX,60,0,(int)(height*0.7f)), GUI.Style, menu);
serverList.OnSelected = SelectServer;
float[] columnRelativeX = new float[] { 0.15f, 0.55f, 0.15f, 0.15f };
@@ -64,19 +64,19 @@ namespace Subsurface
if (n > 0) columnX[n] += columnX[n - 1];
}
new GUITextBlock(new Rectangle(middleX, 30, 0, 30), "Password", GUI.style, menu);
new GUITextBlock(new Rectangle(middleX, 30, 0, 30), "Password", GUI.Style, menu);
new GUITextBlock(new Rectangle(middleX + columnX[0], 30, 0, 30), "Name", GUI.style, menu);
new GUITextBlock(new Rectangle(middleX + columnX[1], 30, 0, 30), "Players", GUI.style, menu);
new GUITextBlock(new Rectangle(middleX + columnX[2], 30, 0, 30), "Running", GUI.style, menu);
new GUITextBlock(new Rectangle(middleX + columnX[0], 30, 0, 30), "Name", GUI.Style, menu);
new GUITextBlock(new Rectangle(middleX + columnX[1], 30, 0, 30), "Players", GUI.Style, menu);
new GUITextBlock(new Rectangle(middleX + columnX[2], 30, 0, 30), "Running", GUI.Style, menu);
joinButton = new GUIButton(new Rectangle(-170, 0, 150, 30), "Refresh", Alignment.BottomRight, GUI.style, menu);
joinButton = new GUIButton(new Rectangle(-170, 0, 150, 30), "Refresh", Alignment.BottomRight, GUI.Style, menu);
joinButton.OnClicked = RefreshServers;
joinButton = new GUIButton(new Rectangle(0,0,150,30), "Join", Alignment.BottomRight, GUI.style, menu);
joinButton = new GUIButton(new Rectangle(0,0,150,30), "Join", Alignment.BottomRight, GUI.Style, menu);
joinButton.OnClicked = JoinServer;
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menu);
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.Style, menu);
button.UserData = 0;
button.OnClicked = Game1.MainMenuScreen.SelectTab;
@@ -93,7 +93,7 @@ namespace Subsurface
//UpdateServerList();
}
private bool SelectServer(object obj)
private bool SelectServer(GUIComponent component, object obj)
{
string ip = obj as string;
if (string.IsNullOrWhiteSpace(ip)) return false;
@@ -108,7 +108,7 @@ namespace Subsurface
if (waitingForRefresh) return false;
serverList.ClearChildren();
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Refreshing server list...", GUI.style, serverList);
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Refreshing server list...", GUI.Style, serverList);
CoroutineManager.StartCoroutine(WaitForRefresh());
@@ -141,7 +141,7 @@ namespace Subsurface
if (string.IsNullOrWhiteSpace(masterServerData))
{
var nameText = new GUITextBlock(new Rectangle(0, 0, 0, 20), "Couldn't find any servers", GUI.style, serverList);
var nameText = new GUITextBlock(new Rectangle(0, 0, 0, 20), "Couldn't find any servers", GUI.Style, serverList);
return;
}
@@ -178,12 +178,12 @@ namespace Subsurface
passwordBox.Enabled = false;
passwordBox.UserData = "password";
var nameText = new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, GUI.style, serverFrame);
var nameText = new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, GUI.Style, serverFrame);
int playerCount, maxPlayers;
playerCount = GameClient.ByteToPlayerCount((byte)int.Parse(playerCountStr), out maxPlayers);
var playerCountText = new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, GUI.style, serverFrame);
var playerCountText = new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, GUI.Style, serverFrame);
var gameStartedBox = new GUITickBox(new Rectangle(columnX[2] + (columnX[3] - columnX[2])/ 2, 0, 20, 20), "", Alignment.TopLeft, serverFrame);
gameStartedBox.Selected = gameStarted == "1";
@@ -288,7 +288,7 @@ namespace Subsurface
if (serverList.Selected!=null && (serverList.Selected.GetChild("password") as GUITickBox).Selected)
{
var msgBox = new GUIMessageBox("Password required", "");
var passwordBox = new GUITextBox(new Rectangle(0,0,150,20), Alignment.BottomCenter, GUI.style, msgBox);
var passwordBox = new GUITextBox(new Rectangle(0,0,150,20), Alignment.BottomCenter, GUI.Style, msgBox);
passwordBox.UserData = "password";
var okButton = msgBox.GetChild<GUIButton>();
+2 -2
View File
@@ -7,7 +7,7 @@ using System.Xml.Linq;
namespace Subsurface
{
class Sprite
public class Sprite
{
static List<Sprite> list = new List<Sprite>();
//the file from which the texture is loaded
@@ -170,7 +170,7 @@ namespace Subsurface
if (File.Exists(file))
{
return Game1.TextureLoader.FromFile(file);
return TextureLoader.FromFile(file);
}
else
{
+1 -1
View File
@@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace Subsurface
{
class SaveUtil
public class SaveUtil
{
private const string SaveFolder = "Content/Data/Saves/";
+9 -8
View File
@@ -11,10 +11,11 @@ namespace Subsurface
/// <summary>
/// Based on http://jakepoz.com/jake_poznanski__background_load_xna.html
/// </summary>
public class TextureLoader
public static class TextureLoader
{
static TextureLoader()
{
BlendColorBlendState = new BlendState
{
ColorDestinationBlend = Blend.Zero,
@@ -34,14 +35,14 @@ namespace Subsurface
};
}
public TextureLoader(GraphicsDevice graphicsDevice, bool needsBmp = false)
public static void Init(GraphicsDevice graphicsDevice, bool needsBmp = false)
{
_graphicsDevice = graphicsDevice;
_needsBmp = needsBmp;
_spriteBatch = new SpriteBatch(_graphicsDevice);
}
public Texture2D FromFile(string path, bool preMultiplyAlpha = true)
public static Texture2D FromFile(string path, bool preMultiplyAlpha = true)
{
try
{
@@ -68,7 +69,7 @@ namespace Subsurface
}
#if WINDOWS
private Texture2D FromStream(Stream stream, bool preMultiplyAlpha = true)
private static Texture2D FromStream(Stream stream, bool preMultiplyAlpha = true)
{
Texture2D texture;
@@ -97,7 +98,7 @@ namespace Subsurface
}
#endif
private Texture2D PreMultiplyAlpha(Texture2D texture)
private static Texture2D PreMultiplyAlpha(Texture2D texture)
{
// Setup a render target to hold our final texture which will have premulitplied alpha values
using (RenderTarget2D renderTarget = new RenderTarget2D(_graphicsDevice, texture.Width, texture.Height))
@@ -136,8 +137,8 @@ namespace Subsurface
private static readonly BlendState BlendColorBlendState;
private static readonly BlendState BlendAlphaBlendState;
private readonly GraphicsDevice _graphicsDevice;
private readonly SpriteBatch _spriteBatch;
private readonly bool _needsBmp;
private static GraphicsDevice _graphicsDevice;
private static SpriteBatch _spriteBatch;
private static bool _needsBmp;
}
}
+37 -15
View File
@@ -5,11 +5,12 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace Subsurface
{
static class ToolBox
public static class ToolBox
{
public static XDocument TryLoadXml(string filePath)
{
@@ -195,6 +196,19 @@ namespace Subsurface
return ParseToVector4(val);
}
public static string ElementInnerText(this XElement el)
{
StringBuilder str = new StringBuilder();
foreach (XNode element in el.DescendantNodes().Where(x => x.NodeType == XmlNodeType.Text))
{
str.Append(element.ToString());
}
return str.ToString();
}
public static Vector2 ParseToVector2(string stringVector2, bool errorMessages = true)
{
string[] components = stringVector2.Split(',');
@@ -284,14 +298,16 @@ namespace Subsurface
{
if (font.MeasureString(text).X < lineLength) return text;
string[] words = text.Split(' ', '\n');
text = text.Replace("\n", " \n ");
string[] words = text.Split(' ');//, '\n');
StringBuilder wrappedText = new StringBuilder();
float linePos = 0f;
float spaceWidth = font.MeasureString(" ").X;
for (int i = 0; i < words.Length; ++i)
{
if (string.IsNullOrWhiteSpace(words[i])) continue;
if (string.IsNullOrWhiteSpace(words[i]) && words[i]!="\n") continue;
Vector2 size;
string tempWord = words[i];
@@ -299,9 +315,8 @@ namespace Subsurface
while ((size = font.MeasureString(tempWord)).X > lineLength)
{
tempWord = tempWord.Remove(tempWord.Length - 1, 1);
}
words[i] = tempWord;
if (prevWord.Length> tempWord.Length)
{
@@ -315,22 +330,29 @@ namespace Subsurface
if (linePos + size.X < lineLength)
{
wrappedText.Append(words[i]);
linePos += size.X + spaceWidth;
wrappedText.Append(words[i]);
if (words[i] == "\n")
{
linePos = 0.0f;
}
else
{
linePos += size.X + spaceWidth;
}
}
else
{
//if (i>0)wrappedText.Remove(wrappedText.Length - 1, 1);
wrappedText.Append("\n");
wrappedText.Append(words[i]);
linePos = size.X + spaceWidth;
wrappedText.Append("\n");
wrappedText.Append(words[i]);
linePos = size.X + spaceWidth;
}
if (i<words.Length-1) wrappedText.Append(" ");
if (i < words.Length - 1) wrappedText.Append(" ");
}
return wrappedText.ToString();
+181
View File
@@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
{
public static class UpdaterUtil
{
public static void SaveFileList(string filePath)
{
XDocument doc = new XDocument(CreateFileList());
doc.Save(filePath);
}
public static XElement CreateFileList()
{
XElement root = new XElement("filelist");
string currentDir = Directory.GetCurrentDirectory();
string[] files = Directory.GetFiles(currentDir, "*", SearchOption.AllDirectories);
foreach (string file in files)
{
XElement fileElement = new XElement("file");
fileElement.Add(new XAttribute("path", GetRelativePath(file, currentDir)));
fileElement.Add(new XAttribute("md5", GetFileMd5Hash(file)));
root.Add(fileElement);
}
return root;
}
public static List<string> GetFileList(XDocument fileListDoc)
{
List<string> fileList = new List<string>();
XElement fileListElement = fileListDoc.Root;
if (fileListElement == null)
{
throw new Exception("Received list of new files was corrupted");
}
foreach (XElement file in fileListElement.Elements())
{
string filePath = ToolBox.GetAttributeString(file, "path", "");
fileList.Add(filePath);
}
return fileList;
}
public static List<string> GetRequiredFiles(XDocument fileListDoc)
{
List<string> requiredFiles = new List<string>();
XElement fileList = fileListDoc.Root;
if (fileList==null)
{
throw new Exception("Received list of new files was corrupted");
}
foreach (XElement file in fileList.Elements())
{
string filePath = ToolBox.GetAttributeString(file, "path", "");
if (!File.Exists(filePath))
{
requiredFiles.Add(filePath);
continue;
}
string md5 = ToolBox.GetAttributeString(file, "md5", "");
if (GetFileMd5Hash(filePath) != md5)
{
requiredFiles.Add(filePath);
}
}
return requiredFiles;
}
private static string GetFileMd5Hash(string filePath)
{
Md5Hash md5Hash = null;
var md5 = MD5.Create();
using (var stream = File.OpenRead(filePath))
{
md5Hash = new Md5Hash(md5.ComputeHash(stream));
}
return md5Hash.Hash;
}
public static string GetRelativePath(string filespec, string folder)
{
Uri pathUri = new Uri(filespec);
// Folders must end in a slash
if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
folder += Path.DirectorySeparatorChar;
}
Uri folderUri = new Uri(folder);
return Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar));
}
/// <summary>
/// moves the files in the updatefolder to the install folder
/// if there's an existing file with the same name in the install folder and it can't be removed,
/// it will be renamed as "OLD_[filename]"
/// </summary>
/// <param name="updateFileFolder"></param>
public static void InstallUpdatedFiles(string updateFileFolder)
{
string[] files = Directory.GetFiles(updateFileFolder, "*", SearchOption.AllDirectories);
string currentDir = Directory.GetCurrentDirectory();
foreach (string file in files)
{
string fileRelPath = GetRelativePath(file, updateFileFolder);
if (File.Exists(fileRelPath))
{
try
{
File.Delete(fileRelPath);
}
catch
{
string oldFileName = currentDir+"\\"+Path.GetDirectoryName(fileRelPath)+"\\OLD_"+Path.GetFileName(fileRelPath);
if (File.Exists(oldFileName)) File.Delete(oldFileName);
//couldn't delete file, probably because it's already in use
File.Move(fileRelPath, oldFileName);
}
}
File.Move(file, fileRelPath);
}
Directory.Delete(updateFileFolder);
}
public static void CleanUnnecessaryFiles(List<string> filesToKeep)
{
string currentDir = Directory.GetCurrentDirectory();
string[] files = Directory.GetFiles(currentDir, "*", SearchOption.AllDirectories);
foreach (string file in files)
{
if (filesToKeep.Contains(GetRelativePath(file, currentDir))) continue;
System.Diagnostics.Debug.WriteLine("deleting file "+file);
try
{
File.Delete(currentDir + "\\" + file);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("Could not delete file ''" + file + "'' (" + e.Message + ")");
continue;
}
}
}
}
}