public void BuildWidgetsFailure() { tip = "Error Occured:\n" + loadException.Message + "\nStack Trace:\n" + loadException.StackTrace; wr = new WidgetRenderer(G, font); button = new RectButton(wr, G.Viewport.Bounds.Width - (BOUNDS_OFFSET - BACK_SIZE) * 2, BAR_HEIGHT + BACK_SIZE * 2, COLOR_BACK, Color.Red); button.Anchor = new Point(G.Viewport.Bounds.Width / 2, G.Viewport.Bounds.Height - BOUNDS_OFFSET + BACK_SIZE); button.AlignY = Alignment.BOTTOM; button.AlignX = Alignment.MID; button.OnButtonPress += (b, p) => { State = ScreenState.ChangePrevious; }; button.Hook(); button.LayerDepth = 1f; text = new TextWidget(wr, font); text.Parent = button; text.AlignX = Alignment.MID; text.AlignY = Alignment.MID; text.OffsetAlignX = Alignment.MID; text.OffsetAlignY = Alignment.MID; text.Height = button.Height; text.Color = Color.White; text.Text = "Back To Menu"; text.LayerDepth = 0.5f; }
public void BuildWidgetsSuccess() { wr = new WidgetRenderer(G, font); button = new RectButton(wr, G.Viewport.Bounds.Width - (BOUNDS_OFFSET - BACK_SIZE) * 2, BAR_HEIGHT + BACK_SIZE * 2, COLOR_BACK, Color.Green); button.Anchor = new Point(G.Viewport.Bounds.Width / 2, G.Viewport.Bounds.Height - BOUNDS_OFFSET + BACK_SIZE); button.AlignY = Alignment.BOTTOM; button.AlignX = Alignment.MID; button.OnButtonPress += (b, p) => { State = ScreenState.ChangeNext; }; button.Hook(); button.LayerDepth = 1f; text = new TextWidget(wr, font); text.Parent = button; text.AlignX = Alignment.MID; text.AlignY = Alignment.MID; text.OffsetAlignX = Alignment.MID; text.OffsetAlignY = Alignment.MID; text.Height = button.Height; text.Color = Color.White; text.Text = "Play Game"; text.LayerDepth = 0.5f; }
public override void OnEntry(GameTime gameTime) { KeyboardEventDispatcher.OnKeyPressed += KeyboardEventDispatcher_OnKeyPressed; font = game.Content.Load <SpriteFont>(@"Fonts\CourierNew32"); wr = new WidgetRenderer(G, font); wUsername = new TextWidget(wr); wUsername.Anchor = new Point(G.Viewport.Width / 2, G.Viewport.Height / 2); wUsername.AlignY = Alignment.BOTTOM; wUsername.AlignX = Alignment.MID; wUsername.Color = Color.White; wUsername.Height = 32; ButtonHighlightOptions h1 = new ButtonHighlightOptions(100, 30, Color.Red); ButtonHighlightOptions h2 = new ButtonHighlightOptions(100, 30, Color.Green); bFinish = new RectButton(wr, h1, h2); bFinish.OffsetAlignY = Alignment.BOTTOM; bFinish.OffsetAlignX = Alignment.MID; bFinish.AlignX = Alignment.MID; bFinish.Offset = new Point(0, 0); bFinish.Parent = wUsername; bFinish.OnButtonPress += bFinish_OnButtonPress; bFinish.Hook(); txtLogin = new TextWidget(wr); txtLogin.Height = bFinish.Height; txtLogin.Text = "Login"; txtLogin.Color = Color.Black; txtLogin.AlignX = Alignment.MID; txtLogin.AlignY = Alignment.MID; txtLogin.OffsetAlignX = Alignment.MID; txtLogin.OffsetAlignY = Alignment.MID; txtLogin.Parent = bFinish; tInput = new TextInput(); tInput.OnTextChanged += tInput_OnTextChanged; tInput.Activate(); tInput.Text = UserConfig.UserName; if (UserConfig.UserName.Equals(UserConfig.DEFAULT_USER_NAME)) { // Must Create A Default User Name wUsername.Text = "Please Enter A New Username"; } }
public TeamInitWidget(WidgetRenderer wr, int w, int h, int buf, Color cBack, ButtonHighlightOptions bh1, ButtonHighlightOptions bh2, Color cText) { BackRect = new RectWidget(wr); BackRect.Width = w; BackRect.Height = h; BackRect.Offset = new Point(0, 0); BackRect.OffsetAlignY = Alignment.BOTTOM; BackRect.Color = cBack; BackRect.LayerDepth = 1f; int wh = h - buf * 2; TextIndex = new TextWidget(wr); TextIndex.Offset = new Point(buf, 0); TextIndex.OffsetAlignX = Alignment.LEFT; TextIndex.OffsetAlignY = Alignment.MID; TextIndex.AlignX = Alignment.LEFT; TextIndex.AlignY = Alignment.MID; TextIndex.Height = wh; TextIndex.Color = cText; TextIndex.Parent = BackRect; TextIndex.LayerDepth = 0.3f; TextUser = new TextWidget(wr); TextUser.Offset = new Point(buf, 0); TextUser.OffsetAlignX = Alignment.RIGHT; TextUser.OffsetAlignY = Alignment.MID; TextUser.AlignX = Alignment.LEFT; TextUser.AlignY = Alignment.MID; TextUser.Height = wh; TextUser.Color = cText; TextUser.Parent = TextIndex; TextUser.LayerDepth = 0.3f; ButtonScheme = new RectButton(wr, bh1, bh2); ButtonScheme.Offset = new Point(-buf, 0); ButtonScheme.OffsetAlignX = Alignment.RIGHT; ButtonScheme.OffsetAlignY = Alignment.MID; ButtonScheme.AlignX = Alignment.RIGHT; ButtonScheme.AlignY = Alignment.MID; ButtonScheme.Parent = BackRect; ButtonScheme.LayerDepth = 0.3f; TextScheme = new TextWidget(wr); TextScheme.Height = bh1.Height; TextScheme.Text = "Default"; TextScheme.Offset = new Point(0, 0); TextScheme.OffsetAlignX = Alignment.MID; TextScheme.OffsetAlignY = Alignment.MID; TextScheme.AlignX = Alignment.MID; TextScheme.AlignY = Alignment.MID; TextScheme.Parent = ButtonScheme; TextScheme.Color = cText; TextScheme.LayerDepth = 0f; ButtonRace = new RectButton(wr, bh1, bh2); ButtonRace.Offset = new Point(-buf, 0); ButtonRace.OffsetAlignX = Alignment.LEFT; ButtonRace.OffsetAlignY = Alignment.MID; ButtonRace.AlignX = Alignment.RIGHT; ButtonRace.AlignY = Alignment.MID; ButtonRace.Parent = ButtonScheme; ButtonRace.LayerDepth = 0.3f; TextRace = new TextWidget(wr); TextRace.Height = bh1.Height; TextRace.Text = "Race"; TextRace.Offset = new Point(0, 0); TextRace.OffsetAlignX = Alignment.MID; TextRace.OffsetAlignY = Alignment.MID; TextRace.AlignX = Alignment.MID; TextRace.AlignY = Alignment.MID; TextRace.Parent = ButtonRace; TextRace.Color = cText; TextRace.LayerDepth = 0f; ButtonPlayerType = new RectButton(wr, bh1, bh2); ButtonPlayerType.Offset = new Point(-buf, 0); ButtonPlayerType.OffsetAlignX = Alignment.LEFT; ButtonPlayerType.OffsetAlignY = Alignment.MID; ButtonPlayerType.AlignX = Alignment.RIGHT; ButtonPlayerType.AlignY = Alignment.MID; ButtonPlayerType.Parent = ButtonRace; ButtonPlayerType.LayerDepth = 0.3f; TextPlayerType = new TextWidget(wr); TextPlayerType.Height = bh1.Height; TextPlayerType.Text = "None"; TextPlayerType.Offset = new Point(0, 0); TextPlayerType.OffsetAlignX = Alignment.MID; TextPlayerType.OffsetAlignY = Alignment.MID; TextPlayerType.AlignX = Alignment.MID; TextPlayerType.AlignY = Alignment.MID; TextPlayerType.Parent = ButtonPlayerType; TextPlayerType.Color = cText; TextPlayerType.LayerDepth = 0f; ButtonScheme.Hook(); ButtonRace.Hook(); ButtonPlayerType.Hook(); ButtonScheme.OnButtonPress += ButtonScheme_OnButtonPress; ButtonRace.OnButtonPress += ButtonRace_OnButtonPress; ButtonPlayerType.OnButtonPress += ButtonPlayerType_OnButtonPress; }
public void Hook() { btnPhysical.Hook(); btnImpact.Hook(); }
public void Hook() { combatData.Hook(); }
public override void OnEntry(GameTime gameTime) { SpriteFont f = game.Content.Load <SpriteFont>(uic.Font); wr = new WidgetRenderer(G, f); using (var s = File.OpenRead(uic.SoundHover)) { seHover = SoundEffect.FromStream(s); } // List Of Possible Button Actions Action <RectButton, Vector2>[] fBPs = { OnBPPlay, OnBPOptions, OnBPArmyPainter, OnBPLevelEditor, OnBPExit }; buttons = new RectButton[uic.Buttons.Length]; buttonsText = new TextWidget[buttons.Length]; tPanels = new Texture2D[buttons.Length + 2]; int bw = G.Viewport.Width; bw -= 5 * uic.ButtonSpacing.X; bw /= 4; int bh = G.Viewport.Height - uic.ButtonSpacing.Y * 3 - uic.TitlePanelTextSize; for (int i = 0; i < buttons.Length; i++) { var uicButton = uic.Buttons[i]; using (var s = File.OpenRead(uicButton.ImageFile)) { tPanels[i] = Texture2D.FromStream(G, s); } buttons[i] = new RectButton(wr, bw, bh, uicButton.ColorInactive, uicButton.ColorActive, tPanels[i]); buttons[i].Hook(); buttons[i].OnButtonPress += MenuScreen_OnButtonPress; buttons[i].OnButtonPress += fBPs[uicButton.ActionIndex]; buttons[i].OnMouseEntry += MenuScreen_OnMouseEntry; buttons[i].LayerDepth = 1f; buttons[i].OffsetAlignX = Alignment.RIGHT; buttons[i].Offset = new Point(uic.ButtonSpacing.X, 0); if (i % 3 != 0) { buttons[i].Parent = buttons[i - 1]; } buttonsText[i] = new TextWidget(wr); buttonsText[i].Font = f; buttonsText[i].OffsetAlignX = Alignment.MID; buttonsText[i].OffsetAlignY = Alignment.TOP; buttonsText[i].Offset = new Point(0, 30); buttonsText[i].AlignX = Alignment.MID; buttonsText[i].AlignY = Alignment.MID; buttonsText[i].Parent = buttons[i]; buttonsText[i].LayerDepth = 0.9f; buttonsText[i].Color = uicButton.ColorText; buttonsText[i].Height = uic.ButtonTextSize; buttonsText[i].Text = uicButton.Text; } using (var s = File.OpenRead(uic.ButtonImageUp)) { tPanels[buttons.Length] = Texture2D.FromStream(G, s); } btnUp = new RectButton(wr, bw, bh / 2, uic.ButtonUDInactiveColor, uic.ButtonUDActiveColor, tPanels[buttons.Length]); btnUp.Offset = new Point((bw + uic.ButtonSpacing.X) * 3, 0); btnUp.OnButtonPress += MenuScreen_OnButtonPress; btnUp.OnMouseEntry += MenuScreen_OnMouseEntry; btnUp.OnButtonPress += OnBPUp; btnUp.Hook(); using (var s = File.OpenRead(uic.ButtonImageDown)) { tPanels[buttons.Length + 1] = Texture2D.FromStream(G, s); } btnDown = new RectButton(wr, bw, bh / 2, uic.ButtonUDInactiveColor, uic.ButtonUDActiveColor, tPanels[buttons.Length + 1]); btnDown.OffsetAlignY = Alignment.BOTTOM; btnDown.Parent = btnUp; btnDown.OnButtonPress += MenuScreen_OnButtonPress; btnDown.OnMouseEntry += MenuScreen_OnMouseEntry; btnDown.OnButtonPress += OnBPDown; btnDown.Hook(); row = 0; ViewRow(row); txtMainMenu = new TextWidget(wr); txtMainMenu.Anchor = new Point(G.Viewport.Width / 2, uic.ButtonSpacing.Y); txtMainMenu.Height = uic.TitlePanelTextSize; txtMainMenu.AlignX = Alignment.MID; txtMainMenu.Color = uic.ColorTitleText; txtMainMenu.Text = uic.TitlePanelText; KeyboardEventDispatcher.OnKeyPressed += OnKeyPressed; }