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 AlertTuple(int frames, WidgetRenderer wr, int buf, int w, int h, int th) { FramesLeft = frames; Base = new RectWidget(wr); Base.Color = UserConfig.MainScheme.WidgetBase; Base.Width = w; Base.Height = h; Icon = new RectWidget(wr); Icon.Offset = new Point(buf, buf); Icon.Color = Color.White; Icon.Height = h - buf * 2; Icon.Width = Icon.Height; Icon.Parent = Base; Text = new TextWidget(wr); Text.AlignY = Alignment.MID; Text.OffsetAlignX = Alignment.RIGHT; Text.OffsetAlignY = Alignment.MID; Text.Color = UserConfig.MainScheme.Text; Text.Offset = new Point(buf, 0); Text.Parent = Icon; Text.Height = th; }
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 RTSUIBuildPanel(WidgetRenderer wr, int w, int h, int bCount, int sbw, int sbh) { Menu = new ScrollMenu(wr, w, h, bCount, sbw, sbh); Menu.BaseColor = UserConfig.MainScheme.WidgetBase; Menu.HighlightColor = UserConfig.MainScheme.WidgetActive; Menu.TextColor = UserConfig.MainScheme.Text; Menu.ScrollBarBaseColor = UserConfig.MainScheme.WidgetInactive; }
public RTSUnitDataPanel(RTSRenderer renderer, WidgetRenderer wr, UICUnitData _uic, UICCombatStats _uicCS) { uic = _uic; iconLib = renderer.IconLibrary; WidgetBase = new RectWidget(wr, renderer.LoadTexture2D(uic.PanelImage)); WidgetBase.Width = uic.PanelSize.X; WidgetBase.Height = uic.PanelSize.Y; WidgetBase.Color = uic.PanelColor; icon = new RectWidget(wr); icon.Width = uic.IconSize; icon.Height = uic.IconSize; icon.Color = Color.White; icon.Offset = new Point(uic.IconBuffer, uic.IconBuffer); icon.Parent = WidgetBase; rectHealthBack = new RectWidget(wr); rectHealthBack.Width = uic.IconSize; rectHealthBack.Height = uic.HealthHeight; rectHealthBack.AlignX = Alignment.MID; rectHealthBack.OffsetAlignX = Alignment.MID; rectHealthBack.OffsetAlignY = Alignment.BOTTOM; rectHealthBack.Offset = new Point(0, uic.IconBuffer); rectHealthBack.Color = UserConfig.MainScheme.WidgetBorder; rectHealthBack.Parent = icon; rectHealthFore = new RectWidget(wr); rectHealthFore.Width = uic.IconSize; rectHealthFore.Height = uic.HealthHeight; rectHealthFore.AlignX = Alignment.MID; rectHealthFore.AlignY = Alignment.MID; rectHealthFore.OffsetAlignX = Alignment.MID; rectHealthFore.OffsetAlignY = Alignment.MID; rectHealthFore.Offset = new Point(0, 0); rectHealthFore.Color = uic.HealthMaxColor; rectHealthFore.Parent = rectHealthBack; txtName = new TextWidget(wr); txtName.Height = uic.TextHeight; txtName.OffsetAlignX = Alignment.RIGHT; txtName.Offset = new Point(uic.IconBuffer, 0); txtName.Color = UserConfig.MainScheme.Text; txtName.Parent = icon; combatData = new RectButton(wr, uic.CombatSize, uic.CombatSize, Color.Gray, Color.White, renderer.LoadTexture2D(uic.CombatImage)); combatData.AlignX = Alignment.RIGHT; combatData.AlignY = Alignment.BOTTOM; combatData.OffsetAlignX = Alignment.RIGHT; combatData.OffsetAlignY = Alignment.BOTTOM; combatData.Parent = WidgetBase; uiCStats = new RTSUICombatStats(wr, _uicCS); uiCStats.WidgetBase.AlignY = Alignment.BOTTOM; uiCStats.WidgetBase.Anchor = new Point(1000000, 1000000); uiCSHover = new RTSUIHoverPanel(combatData, uiCStats.WidgetBase); }
public RTSUIAlertQueue(WidgetRenderer _wr, UICAlertQueue _uic) { uic = _uic; wr = _wr; WidgetBase = new RectWidget(wr); WidgetBase.Color = Color.Transparent; WidgetBase.LayerOffset = 0.01f; WidgetBase.OffsetAlignX = Alignment.RIGHT; WidgetBase.Offset = new Point(-uic.Width, 0); lRects = new LinkedList <AlertTuple>(); }
public override void OnExit(GameTime gameTime) { if (wr != null) { button.Dispose(); text.Dispose(); wr.Dispose(); wr = null; } font = null; tLoad.Dispose(); tPixel.Dispose(); }
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 override void Build() { input = new InputManager(); wr = new WidgetRenderer(G, game.Content.Load <SpriteFont>(@"Fonts\Default")); wBackPanel = new RectWidget(wr); wBackPanel.Anchor = new Point(0, 0); wBackPanel.Width = 200; wBackPanel.Height = G.Viewport.Height; wBackPanel.LayerDepth = 1f; wBackPanel.Color = new Color(14, 14, 14, 230); sP = new ColorSwatch(10, 30, 170, 15, 35, 5, Color.Black, 0.9f, wr); sS = new ColorSwatch(10, 120, 170, 15, 35, 5, Color.Black, 0.9f, wr); sT = new ColorSwatch(10, 210, 170, 15, 35, 5, Color.Black, 0.9f, wr); sP.OnColorChange += (c) => { colorScheme.Primary = c; }; sS.OnColorChange += (c) => { colorScheme.Secondary = c; }; sT.OnColorChange += (c) => { colorScheme.Tertiary = c; }; }
public RTSUIMinimap(RTSRenderer renderer, WidgetRenderer wr, Texture2D tPhys, Texture2D tImp, UICMinimap uic) { tPhysical = tPhys; tImpact = tImp; WidgetBase = new RectWidget(wr); WidgetBase.Width = uic.ButtonWidth + uic.MapSize + uic.Buffer * 2; WidgetBase.Height = uic.MapSize + uic.Buffer * 2; WidgetBase.Color = uic.BaseColor; int bh = uic.MapSize / 2; btnPhysical = new RectButton(wr, uic.ButtonWidth, bh, uic.PhysicalInactiveColor, uic.PhysicalActiveColor, renderer.LoadTexture2D(uic.PhysicalTexture) ); btnImpact = new RectButton(wr, uic.ButtonWidth, bh, uic.ImpactInactiveColor, uic.ImpactActiveColor, renderer.LoadTexture2D(uic.ImpactTexture) ); btnPhysical.Offset = new Point(uic.Buffer, uic.Buffer); btnPhysical.Parent = WidgetBase; btnImpact.OffsetAlignY = Alignment.BOTTOM; btnImpact.Parent = btnPhysical; MapRect = new RectWidget(wr, tPhysical); MapRect.Width = uic.MapSize; MapRect.Height = uic.MapSize; MapRect.Color = Color.White; MapRect.OffsetAlignX = Alignment.RIGHT; MapRect.Parent = btnPhysical; btnPhysical.OnButtonPress += (b, p) => { MapRect.Texture = tPhysical; }; btnImpact.OnButtonPress += (b, p) => { MapRect.Texture = tImpact; }; }
private void CreateWidgets() { wr = new WidgetRenderer(G, game.Content.Load <SpriteFont>(@"Fonts\Impact32")); voxMenu = new ScrollMenu(wr, 180, 30, 5, 12, 30); voxMenu.Build(dVox.Keys.ToArray()); voxMenu.BaseColor = Color.LightCoral; voxMenu.HighlightColor = Color.Red; voxMenu.TextColor = Color.Black; voxMenu.ScrollBarBaseColor = Color.Green; voxMenu.Widget.AlignY = Alignment.BOTTOM; voxMenu.Widget.Anchor = new Point(0, game.Window.ClientBounds.Height); voxMenu.Hook(); // TODO: Parse In Config leMenu = new LEMenu(wr, new UICLEMenu()); leMenu.Activate(); leMenu.SaveButton.OnButtonPress += SaveButton_OnButtonPress; leMenu.LoadButton.OnButtonPress += LoadButton_OnButtonPress; }
public RTSUI(RTSRenderer renderer, string uicFile, bool showBuildPanel) { uic = ZXParser.ParseFile(uicFile, typeof(UICRTS)) as UICRTS; SpriteFont font = renderer.LoadFont(uic.Font); wrButtonPanel = new WidgetRenderer(renderer.G, font); wrMain = new WidgetRenderer(renderer.G, font); BuildBounds(renderer); BuildMinimap(renderer, uic.UICMinimap); BuildBBPanel(renderer); BuildBuildingPanel(showBuildPanel); BuildSelectionPanel(renderer); BuildUnitDataPanel(renderer); BuildBuildingDataPanel(renderer); BuildTeamDataPanel(); AlertQueue = new RTSUIAlertQueue(wrMain, uic.UICAlertQueue); AlertQueue.WidgetBase.Parent = Minimap.WidgetBase; SelectionToggle = 0; }
public RTSUICombatStats(WidgetRenderer wr, UICCombatStats _uic) { uic = _uic; WidgetBase = new RectWidget(wr); WidgetBase.Color = uic.BaseColor; WidgetBase.Width = uic.PanelWidth; WidgetBase.Height = (uic.TextHeight + uic.TextBuffer) * 5 + uic.TextBuffer; WidgetBase.LayerDepth = 0.1f; texts = new TextWidget[2 * 5]; string[] s = { "Damage", "Range", "Attack Speed", "Armor", "Crit. Chance" }; for (int i = 0; i < texts.Length; i++) { texts[i] = new TextWidget(wr); texts[i].OffsetAlignX = Alignment.MID; texts[i].AlignY = Alignment.BOTTOM; texts[i].Height = uic.TextHeight; texts[i].Color = uic.TextColor; if (i % 2 == 0) { texts[i].AlignX = Alignment.RIGHT; texts[i].Offset = new Point(-uic.TextSeparation / 2, (i / 2 + 1) * (uic.TextHeight + uic.TextBuffer)); texts[i].Text = s[i / 2]; } else { texts[i].AlignX = Alignment.LEFT; texts[i].Offset = new Point(uic.TextSeparation / 2, (i / 2 + 1) * (uic.TextHeight + uic.TextBuffer)); } texts[i].Parent = WidgetBase; } }
public RTSUIPanel2D(WidgetRenderer wr, int r, int c, int s, int buf) { Rows = r; Columns = c; groups = new RTSUIGroup <T> [Columns * Rows]; int i = 0; for (int y = 0; y < Rows; y++) { for (int x = 0; x < Columns; x++) { groups[i] = new RTSUIGroup <T>(wr, s); if (x > 0) { groups[i].Widget.Parent = groups[i - 1].Widget; groups[i].Widget.Offset = new Point(buf, 0); groups[i].Widget.OffsetAlignX = Alignment.RIGHT; } i++; } if (y > 0) { int yi = y * Columns; groups[yi].Widget.Parent = groups[yi - Columns].Widget; groups[yi].Widget.Offset = new Point(0, buf); groups[yi].Widget.OffsetAlignY = Alignment.BOTTOM; } } BackPanel = new RectWidget(wr); BackPanel.Width = Columns * s + (Columns + 1) * buf; BackPanel.Height = Rows * s + (Rows + 1) * buf; groups[0].Widget.Parent = BackPanel; groups[0].Widget.Offset = new Point(buf, buf); LayerDepth = 1f; Clear(); }
public LEMenu(WidgetRenderer wr, UICLEMenu _uic) { uic = _uic; WidgetBase = new RectWidget(wr); WidgetBase.Color = UserConfig.MainScheme.WidgetBase; WidgetBase.Width = uic.TextInputBufferSize.X + uic.WidgetSpacing * 2; btns = new RectButton[5]; for (int i = 0; i < btns.Length; i++) { btns[i] = new RectButton(wr, i == 0 ? uic.TextInputBufferSize.X : (uic.TextInputBufferSize.X - uic.WidgetSpacing) / 2, uic.TextInputBufferSize.Y, UserConfig.MainScheme.WidgetInactive, UserConfig.MainScheme.WidgetActive ); } txts = new TextWidget[3]; for (int i = 0; i < txts.Length; i++) { txts[i] = new TextWidget(wr); txts[i].Height = uic.TextHeight; txts[i].Color = UserConfig.MainScheme.Text; txts[i].OffsetAlignX = Alignment.MID; txts[i].AlignX = Alignment.MID; if (i != 0) { txts[i].OffsetAlignY = Alignment.MID; txts[i].AlignY = Alignment.MID; } } txts[0].Text = "Map Name"; txts[1].Text = "Save"; txts[2].Text = "Load"; tInputs = new TextInputWidget[3]; for (int i = 0; i < tInputs.Length; i++) { tInputs[i] = new TextInputWidget(wr); tInputs[i].Height = uic.TextHeight; tInputs[i].Color = UserConfig.MainScheme.Text; tInputs[i].Caret.Width = 1; tInputs[i].Caret.Color = uic.CaretColor; tInputs[i].OffsetAlignX = Alignment.MID; tInputs[i].OffsetAlignY = Alignment.MID; tInputs[i].AlignX = Alignment.MID; tInputs[i].AlignY = Alignment.MID; } MapLocation = uic.DefaultMapLocText; MapWidth = uic.DefaultWidth; MapHeight = uic.DefaultHeight; txts[0].Parent = WidgetBase; txts[0].Offset = new Point(0, uic.WidgetSpacing); btns[0].OffsetAlignX = Alignment.MID; btns[0].OffsetAlignY = Alignment.BOTTOM; btns[0].Offset = new Point(0, uic.WidgetSpacing); btns[0].AlignX = Alignment.MID; btns[0].Parent = txts[0]; btns[1].OffsetAlignX = Alignment.LEFT; btns[1].OffsetAlignY = Alignment.BOTTOM; btns[1].Offset = new Point(0, uic.WidgetSpacing); btns[1].AlignX = Alignment.LEFT; btns[1].Parent = btns[0]; btns[2].OffsetAlignX = Alignment.RIGHT; btns[2].OffsetAlignY = Alignment.BOTTOM; btns[2].Offset = new Point(0, uic.WidgetSpacing); btns[2].AlignX = Alignment.RIGHT; btns[2].Parent = btns[0]; for (int i = 0; i < 3; i++) { tInputs[i].Parent = btns[i]; } for (int i = 0; i < 2; i++) { btns[i + 3].OffsetAlignY = Alignment.BOTTOM; btns[i + 3].Offset = new Point(0, uic.WidgetSpacing); btns[i + 3].Parent = btns[i + 1]; txts[i + 1].Parent = btns[i + 3]; } WidgetBase.Height = btns[4].Y + btns[4].Height + uic.WidgetSpacing; for (int i = 0; i < 3; i++) { btns[i].OnButtonPress += GetInputActivator(i); } }
public ColorSwatch(int x, int y, int w, int hPart, int hFull, int border, Color bColor, float lD, WidgetRenderer r) { wBorder = new RectWidget(r); wBorder.Anchor = new Point(x, y); wBorder.Width = w + border * 2; wBorder.Height = hPart * 3 + hFull + border * 2; wBorder.LayerDepth = lD; wBorder.Color = bColor; lD -= 0.001f; x += border; y += border; int sw = w - border; int sh = hPart - border; var csbb = new Microsoft.Xna.Framework.Color(28, 28, 28); wR = new RectWidget(r); wR.Anchor = new Point(x, y); wR.Width = w; wR.Height = hPart; wR.LayerDepth = lD; wR.Color = Microsoft.Xna.Framework.Color.Red; y += hPart; sbR = new ScrollBar(r); sbR.Color = csbb; sbR.Width = sw; sbR.Height = sh; sbR.LayerDepth = lD - 0.01f; sbR.ScrollButton.ActiveWidth = sw / 5; sbR.ScrollButton.ActiveHeight = sh; sbR.ScrollButton.InactiveWidth = sw / 5; sbR.ScrollButton.InactiveHeight = sh; sbR.ScrollButton.InactiveColor = Microsoft.Xna.Framework.Color.Black; sbR.ScrollButton.ActiveColor = Microsoft.Xna.Framework.Color.White; sbR.ScrollButton.LayerDepth = lD - 0.02f; sbR.Parent = wR; sbR.OffsetAlignX = Alignment.MID; sbR.OffsetAlignY = Alignment.MID; sbR.AlignX = Alignment.MID; sbR.AlignY = Alignment.MID; sbR.IsVertical = false; sbR.OnScrollValueChanged += (sb, v) => { col.X = v; sbR.ScrollButton.InactiveColor = new Color(col.X, 0f, 0f); wCol.Color = new Color(col.X, col.Y, col.Z); if (OnColorChange != null) { OnColorChange(col); } }; sbR.ScrollRatio = 0; wG = new RectWidget(r); wG.Anchor = new Point(x, y); wG.Width = w; wG.Height = hPart; wG.LayerDepth = lD; wG.Color = Microsoft.Xna.Framework.Color.Green; y += hPart; sbG = new ScrollBar(r); sbG.Color = csbb; sbG.Width = sw; sbG.Height = sh; sbG.LayerDepth = lD - 0.01f; sbG.ScrollButton.ActiveWidth = sw / 5; sbG.ScrollButton.ActiveHeight = sh; sbG.ScrollButton.InactiveWidth = sw / 5; sbG.ScrollButton.InactiveHeight = sh; sbG.ScrollButton.InactiveColor = Microsoft.Xna.Framework.Color.Black; sbG.ScrollButton.ActiveColor = Microsoft.Xna.Framework.Color.White; sbG.ScrollButton.LayerDepth = lD - 0.02f; sbG.Parent = wG; sbG.OffsetAlignX = Alignment.MID; sbG.OffsetAlignY = Alignment.MID; sbG.AlignX = Alignment.MID; sbG.AlignY = Alignment.MID; sbG.IsVertical = false; sbG.OnScrollValueChanged += (sb, v) => { col.Y = v; sbG.ScrollButton.InactiveColor = new Color(0f, col.Y, 0f); wCol.Color = new Color(col.X, col.Y, col.Z); if (OnColorChange != null) { OnColorChange(col); } }; sbG.ScrollRatio = 0; wB = new RectWidget(r); wB.Anchor = new Point(x, y); wB.Width = w; wB.Height = hPart; wB.LayerDepth = lD; wB.Color = Microsoft.Xna.Framework.Color.Blue; y += hPart; sbB = new ScrollBar(r); sbB.Color = csbb; sbB.Width = sw; sbB.Height = sh; sbB.LayerDepth = lD - 0.01f; sbB.ScrollButton.ActiveWidth = sw / 5; sbB.ScrollButton.ActiveHeight = sh; sbB.ScrollButton.InactiveWidth = sw / 5; sbB.ScrollButton.InactiveHeight = sh; sbB.ScrollButton.InactiveColor = Microsoft.Xna.Framework.Color.Black; sbB.ScrollButton.ActiveColor = Microsoft.Xna.Framework.Color.White; sbB.ScrollButton.LayerDepth = lD - 0.02f; sbB.Parent = wB; sbB.OffsetAlignX = Alignment.MID; sbB.OffsetAlignY = Alignment.MID; sbB.AlignX = Alignment.MID; sbB.AlignY = Alignment.MID; sbB.IsVertical = false; sbB.OnScrollValueChanged += (sb, v) => { col.Z = v; sbB.ScrollButton.InactiveColor = new Color(0f, 0f, col.Z); wCol.Color = new Color(col.X, col.Y, col.Z); if (OnColorChange != null) { OnColorChange(col); } }; sbB.ScrollRatio = 0; wCol = new RectWidget(r); wCol.Anchor = new Point(x, y); wCol.Width = w; wCol.Height = hFull; wCol.LayerDepth = lD; Color = Vector3.One; }
public RTSUIBuildingButtonPanel(WidgetRenderer wr, int r, int c, int s, int buf) : base(wr, r, c, s, buf) { }
public RTSUIGroup(WidgetRenderer wr, int s) { Widget = new RectButton(wr, s, s, COLOR_INACTIVE, COLOR_ACTIVE); }
public RTSUISelectionPanel(WidgetRenderer wr, int r, int c, int s, int buf) : base(wr, r, c, s, buf) { }
public RTSBuildingDataPanel(RTSRenderer renderer, WidgetRenderer wr, UICBuildingData _uic) { uic = _uic; iconLib = renderer.IconLibrary; WidgetBase = new RectWidget(wr, renderer.LoadTexture2D(uic.PanelImage)); WidgetBase.Width = uic.PanelSize.X; WidgetBase.Height = uic.PanelSize.Y; WidgetBase.Color = uic.PanelColor; icon = new RectWidget(wr); icon.Width = uic.IconSize; icon.Height = uic.IconSize; icon.Color = Color.White; icon.Offset = new Point(uic.IconBuffer, uic.IconBuffer); icon.Parent = WidgetBase; rectHealthBack = new RectWidget(wr); rectHealthBack.Width = uic.IconSize; rectHealthBack.Height = uic.HealthHeight; rectHealthBack.AlignX = Alignment.MID; rectHealthBack.OffsetAlignX = Alignment.MID; rectHealthBack.OffsetAlignY = Alignment.BOTTOM; rectHealthBack.Offset = new Point(0, uic.IconBuffer); rectHealthBack.Color = UserConfig.MainScheme.WidgetBorder; rectHealthBack.Parent = icon; rectHealthFore = new RectWidget(wr); rectHealthFore.Width = uic.IconSize; rectHealthFore.Height = rectHealthBack.Height; rectHealthFore.AlignX = Alignment.MID; rectHealthFore.AlignY = Alignment.MID; rectHealthFore.OffsetAlignX = Alignment.MID; rectHealthFore.OffsetAlignY = Alignment.MID; rectHealthFore.Offset = new Point(0, 0); rectHealthFore.Color = uic.HealthMaxColor; rectHealthFore.Parent = rectHealthBack; queueButtons = new RectButton[6]; queueButtons[0] = new RectButton(wr, uic.QueueIconMainSize, uic.QueueIconMainSize, Color.White, uic.QueueButtonHighlightColor); queueButtons[0].AlignY = Alignment.BOTTOM; queueButtons[0].OffsetAlignY = Alignment.BOTTOM; queueButtons[0].OffsetAlignX = Alignment.RIGHT; queueButtons[0].Offset = new Point(uic.IconBuffer, 0); queueButtons[0].Parent = rectHealthBack; for (int i = 1; i < 6; i++) { queueButtons[i] = new RectButton(wr, uic.QueueIconQueuedSize, uic.QueueIconQueuedSize, Color.White, uic.QueueButtonHighlightColor); queueButtons[i].AlignY = Alignment.BOTTOM; queueButtons[i].OffsetAlignY = Alignment.BOTTOM; queueButtons[i].OffsetAlignX = Alignment.RIGHT; queueButtons[i].Parent = queueButtons[i - 1]; } rectQueueBack = new RectWidget(wr); rectQueueBack.Width = uic.QueueIconQueuedSize * 5; rectQueueBack.Height = uic.QueueIconMainSize - uic.QueueIconQueuedSize; rectQueueBack.OffsetAlignX = Alignment.RIGHT; rectQueueBack.Color = UserConfig.MainScheme.WidgetBorder; rectQueueBack.Parent = queueButtons[0]; rectQueueFore = new RectWidget(wr); rectQueueFore.Width = uic.IconSize; rectQueueFore.Height = rectQueueBack.Height; rectQueueFore.AlignY = Alignment.MID; rectQueueFore.OffsetAlignY = Alignment.MID; rectQueueFore.Offset = new Point(0, 0); rectQueueFore.Color = uic.QueueMaxColor; rectQueueFore.Parent = rectQueueBack; txtName = new TextWidget(wr); txtName.Height = uic.TextHeight; txtName.OffsetAlignX = Alignment.RIGHT; txtName.Offset = new Point(uic.IconBuffer, 0); txtName.Color = UserConfig.MainScheme.Text; txtName.Parent = icon; }
private void Render(object canvas, IReadOnlyViewport viewport, IEnumerable <IWidget> widgets, float layerOpacity) { WidgetRenderer.Render(canvas, viewport, widgets, WidgetRenders, layerOpacity); }
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; }
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 override void OnEntry(GameTime gameTime) { // Load All The Races And Schemes Races = new Dictionary <string, FileInfo>(); schemes = new Dictionary <string, RTSColorScheme>(); GameEngine.SearchAllInitInfo(new DirectoryInfo("Packs"), Races, schemes); if (schemes.Count < 1) { schemes.Add("Default", RTSColorScheme.Default); } string defScheme = "Default"; foreach (var kvp in schemes) { defScheme = kvp.Key; break; } // Set Init Data To Be Nothing game.LoadScreen.LoadFile = null; eld = new EngineLoadData(); eld.Teams = new TeamInitOption[GameState.MAX_PLAYERS]; for (int i = 0; i < eld.Teams.Length; i++) { eld.Teams[i].InputType = RTSInputType.None; eld.Teams[i].Race = null; eld.Teams[i].PlayerName = null; eld.Teams[i].Colors = schemes[defScheme]; } game.LoadScreen.LoadData = eld; wr = new WidgetRenderer(G, game.Content.Load <SpriteFont>(@"Fonts\Impact32")); widgets = new TeamInitWidget[eld.Teams.Length]; ButtonHighlightOptions bh1 = new ButtonHighlightOptions(120, 36, Color.Black); ButtonHighlightOptions bh2 = new ButtonHighlightOptions(120, 36, Color.DarkGray); string[] pt = { "None", "Player", "Computer", "Environment" }; for (int i = 0; i < widgets.Length; i++) { widgets[i] = new TeamInitWidget(wr, 600, 44, 8, new Color(8, 8, 8), bh1, bh2, Color.Lime); if (i > 0) { widgets[i].Parent = widgets[i - 1].BackRect; } widgets[i].TextIndex.Text = (i + 1).ToString(); widgets[i].TextUser.Text = "Unknown"; widgets[i].Set(pt, Races, schemes); } widgets[0].TextUser.Text = UserConfig.UserName; menuPresets = new ScrollMenu(wr, game.Window.ClientBounds.Width - widgets[0].BackRect.Width - 20, 24, game.Window.ClientBounds.Height / 24, 20, 40 ); menuPresets.BaseColor = UserConfig.MainScheme.WidgetBase; menuPresets.TextColor = UserConfig.MainScheme.Text; menuPresets.ScrollBarBaseColor = UserConfig.MainScheme.WidgetInactive; menuPresets.HighlightColor = UserConfig.MainScheme.WidgetActive; menuPresets.Widget.Anchor = new Point(game.Window.ClientBounds.Width - 20, 0); menuPresets.Widget.AlignX = Alignment.RIGHT; menuPresets.Build((from gp in gPresets select gp.Name).ToArray()); menuPresets.Hook(); textMap = new TextWidget(wr); textMap.Color = UserConfig.MainScheme.Text; textMap.Offset = new Point(0, 5); textMap.Height = 32; textMap.OffsetAlignY = Alignment.BOTTOM; textMap.Parent = widgets[widgets.Length - 1].BackRect; textGTController = new TextWidget(wr); textGTController.Color = UserConfig.MainScheme.Text; textGTController.Offset = new Point(0, 5); textGTController.Height = 32; textGTController.OffsetAlignY = Alignment.BOTTOM; textGTController.Parent = textMap; SetWidgetData(gPresets[0]); DevConsole.OnNewCommand += DevConsole_OnNewCommand; KeyboardEventDispatcher.OnKeyPressed += OnKeyPressed; MouseEventDispatcher.OnMousePress += OnMP; }
public RTSUITeamDataPanel(WidgetRenderer wr) { rectBase = new RectWidget(wr); rectBase.Height = 60; rectPopPic = new RectWidget(wr); rectPopPic.Height = rectBase.Height - 4; rectPopPic.Width = rectPopPic.Height; rectPopPic.Offset = new Point(2, 2); rectPopPic.Parent = rectBase; rectCapital = new RectWidget(wr); rectCapital.Height = rectBase.Height / 2; rectCapital.OffsetAlignX = Alignment.RIGHT; rectCapital.AlignX = Alignment.RIGHT; rectCapital.Parent = rectBase; rectCapital.Color = Color.Transparent; textPopCur = new TextWidget(wr); textPopCur.Offset = new Point(5, 0); textPopCur.OffsetAlignX = Alignment.RIGHT; textPopCur.AlignY = Alignment.BOTTOM; textPopCur.OffsetAlignY = Alignment.MID; textPopCur.Height = rectBase.Height / 2; textPopCur.Parent = rectPopPic; textPopCap = new TextWidget(wr); textPopCap.Offset = new Point(5, 0); textPopCap.OffsetAlignX = Alignment.RIGHT; textPopCap.AlignY = Alignment.TOP; textPopCap.OffsetAlignY = Alignment.MID; textPopCap.Height = rectBase.Height / 2; textPopCap.Parent = rectPopPic; textCapital = new TextWidget(wr); textCapital.AlignX = Alignment.MID; textCapital.AlignY = Alignment.MID; textCapital.OffsetAlignX = Alignment.MID; textCapital.OffsetAlignY = Alignment.MID; textCapital.Height = (int)(rectCapital.Height * 0.9); textCapital.Parent = rectCapital; textVictory = new TextWidget(wr); textVictory.AlignX = Alignment.MID; textVictory.AlignY = Alignment.TOP; textVictory.OffsetAlignX = Alignment.MID; textVictory.OffsetAlignY = Alignment.BOTTOM; textVictory.Height = (int)(rectCapital.Height * 0.9); textVictory.Parent = rectCapital; Width = 400; ColorBase = UserConfig.MainScheme.WidgetBase; ColorPop = Color.White; ColorText = UserConfig.MainScheme.Text; VictoryText = "Victory Condition"; Capital = 0; Population = 0; PopulationCap = 0; }