misc UI stuff, gamesession additions, limbs don't have individual health anymore, background music

This commit is contained in:
Regalis
2015-06-09 18:18:34 +03:00
parent d3896383fd
commit d7fde606e9
50 changed files with 595 additions and 282 deletions
+22 -19
View File
@@ -3,27 +3,29 @@ using System.Collections.Generic;
namespace Subsurface
{
class GUIMessageBox
class GUIMessageBox : GUIFrame
{
public static Queue<GUIMessageBox> messageBoxes = new Queue<GUIMessageBox>();
const int DefaultWidth=400, DefaultHeight=200;
public delegate bool OnClickedHandler(GUIButton button, object obj);
public OnClickedHandler OnClicked;
//public delegate bool OnClickedHandler(GUIButton button, object obj);
//public OnClickedHandler OnClicked;
GUIFrame frame;
//GUIFrame frame;
GUIButton[] buttons;
public GUIMessageBox(string header, string text)
: this(header, text, new string[] {"OK"})
{ }
public GUIMessageBox(string header, string text, string[] buttons, Alignment textAlignment = (Alignment.Left |Alignment.Top))
{
frame = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-DefaultWidth/2, Game1.GraphicsHeight/2-DefaultHeight/2, DefaultWidth, DefaultHeight),
GUI.style.backGroundColor, Alignment.CenterX, GUI.style);
frame.Padding = GUI.style.smallPadding;
this.buttons[0].OnClicked = OkClicked;
}
public GUIMessageBox(string header, string text, string[] buttons, Alignment textAlignment = (Alignment.Left | Alignment.Top))
: base(new Rectangle(Game1.GraphicsWidth / 2 - DefaultWidth / 2, Game1.GraphicsHeight / 2 - DefaultHeight / 2, DefaultWidth, DefaultHeight),
GUI.style.backGroundColor, Alignment.CenterX, GUI.style)
{
Padding = GUI.style.smallPadding;
if (buttons == null || buttons.Length == 0)
{
@@ -31,24 +33,25 @@ namespace Subsurface
return;
}
new GUITextBlock(new Rectangle(0, 5, 0, 30), header, Color.Transparent, Color.White, textAlignment, frame, true);
new GUITextBlock(new Rectangle(0,50,0,DefaultHeight-70),text, Color.Transparent, Color.White, textAlignment, frame, true);
new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, this, true);
new GUITextBlock(new Rectangle(0, 30, 0, DefaultHeight - 70), text, Color.Transparent, Color.White, textAlignment, this, true);
int x = 0;
this.buttons = new GUIButton[buttons.Length];
for (int i=0; i<buttons.Length; i++)
for (int i = 0; i < buttons.Length; i++)
{
this.buttons[i] = new GUIButton(new Rectangle(x,0,150,30), buttons[i], GUI.style, Alignment.Left, frame);
this.buttons[i].OnClicked = ButtonClicked;
this.buttons[i] = new GUIButton(new Rectangle(x, 0, 150, 30), buttons[i], GUI.style, Alignment.Left | Alignment.Bottom, this);
x += this.buttons[i].Rect.Width + 20;
}
messageBoxes.Enqueue(this);
}
private bool ButtonClicked(GUIButton button, object obj)
private bool OkClicked(GUIButton button, object obj)
{
if (OnClicked==null) return true;
return OnClicked(button, obj);
messageBoxes.Dequeue();
return true;
}
}