public void GetSVarsCallback(object sender, GetSVarsEventArgs args) { _sVars = args.SVars; int off_y = 5; components.Clear(); foreach (MarshalComponentParameter svar in _sVars) { var newLabel = new Label(svar.Family.ToString() + " : " + svar.Parameter.MemberName + " = ", "CALIBRI", _resourceManager); newLabel.Update(0); newLabel.Position = new Point(5, off_y); newLabel.DrawBorder = true; newLabel.DrawBackground = true; GuiComponent newComp = CreateEditField(svar); newComp.Update(0); newComp.Position = new Point(newLabel.ClientArea.Right + 8, off_y); off_y += newLabel.ClientArea.Height + 5; components.Add(newLabel); components.Add(newComp); } }
public void AddLine(string text, Color color) { Label newLabel = new Label(text, "MICROGBE", this._resourceManager); newLabel.Position = new Point(5, last_y); newLabel.TextColor = color; newLabel.Update(0); last_y = newLabel.ClientArea.Bottom; components.Add(newLabel); }
private void PopulateList() { if (assignedComp == null) return; components.Clear(); int pos_y = 10; foreach (PlayerAction act in assignedComp.Actions) { var newButt = new PlayerActionButton(act, _resourceManager); newButt.Position = new Point(10, pos_y); newButt.Update(0); var newLabel = new Label(act.Name, "CALIBRI", _resourceManager); newLabel.Update(0); newLabel.Position = new Point(10 + newButt.ClientArea.Width + 5, pos_y + (int) (newButt.ClientArea.Height/2f) - (int) (newLabel.ClientArea.Height/2f)); components.Add(newButt); components.Add(newLabel); pos_y += 5 + newButt.ClientArea.Height; } }
public override void Update(float frameTime) { const int x_inner = 4; const int y_inner = 25; const int dec_inner = 7; panelBG.Position = Position; healthMeterBg.Position = new Vector2D(Position.X + x_inner, Position.Y + y_inner); healthMeterOverlay.Position = new Vector2D(Position.X + x_inner, Position.Y + y_inner); healthMeterGrid.Position = new Vector2D(Position.X + x_inner, Position.Y + y_inner); ClientArea = Rectangle.Round(panelBG.AABB); healthMeterInner = new Rectangle(Position.X + x_inner + dec_inner, Position.Y + y_inner + dec_inner, (int)(healthMeterOverlay.Width - (2 * dec_inner)), (int)(healthMeterOverlay.Height - (2 * dec_inner))); healthPc.Position = new Point(healthMeterInner.X + 5, (int) (healthMeterInner.Y + (healthMeterInner.Height / 2f) - (healthPc.ClientArea.Height / 2f)) - 2); healthPc.Update(frameTime); Entity entity = _playerManager.ControlledEntity; if (entity != null && entity.HasComponent(ComponentFamily.Damageable)) { var comp = (HealthComponent)entity.GetComponent(ComponentFamily.Damageable); float _health = comp.GetHealth(); healthPct = comp.GetHealth() / comp.GetMaxHealth(); if (float.IsNaN(healthPct)) { healthPct = 1; //This can happen when the components are not ready yet. } interpCol = ColorInterpolator.InterpolateBetween(ColCritical, ColHealthy, healthPct); healthPc.Text.Text = Math.Round((healthPct * 100)).ToString() + "%"; } blipTime += frameTime; }
private void PopulateList() { if (assignedComp == null) { return; } components.Clear(); int pos_y = 10; foreach (PlayerAction act in assignedComp.Actions) { var newButt = new PlayerActionButton(act, _resourceManager); newButt.Position = new Point(10, pos_y); newButt.Update(0); var newLabel = new Label(act.Name, "CALIBRI", _resourceManager); newLabel.Update(0); newLabel.Position = new Point(10 + newButt.ClientArea.Width + 5, pos_y + (int)(newButt.ClientArea.Height / 2f) - (int)(newLabel.ClientArea.Height / 2f)); components.Add(newButt); components.Add(newLabel); pos_y += 5 + newButt.ClientArea.Height; } }
private void HandlePlayerList(NetIncomingMessage message) { byte playerCount = message.ReadByte(); _serverPlayers = playerCount; _tabServer._scPlayerList.components.Clear(); int offY = 0; for (int i = 0; i < playerCount; i++) { string currName = message.ReadString(); var currStatus = (SessionStatus)message.ReadByte(); float currRoundtrip = message.ReadFloat(); Label newLabel = new Label(currName + "\t\tStatus: " + currStatus + "\t\tLatency: " + Math.Truncate(currRoundtrip * 1000) + " ms", "MICROGBE", ResourceManager); newLabel.Position = new Point(0, offY); newLabel.TextColor = Color.Black; newLabel.Update(0); offY += newLabel.ClientArea.Height; _tabServer._scPlayerList.components.Add(newLabel); } }
public JobTab(string uniqueName, Size size, IResourceManager resourceManager) : base(uniqueName, size, resourceManager) { _bttReady = new ImageButton() { ImageNormal = "lobby_ready", ImageHover = "lobby_ready_green", BlendingMode = BlendingModes.None }; _bttReady.Clicked += _bttReady_Clicked; _bttReady.Update(0); _imgWhatDep = new SimpleImage() { Sprite = "lobby_whatdep" }; _imgWhatDep.Update(0); _imgWhatDep.Position = new Point((int)(size.Width / 2f - _imgWhatDep.ClientArea.Width / 2f), 30); _imgWhatDep.Update(0); _imgJobDesc = new SimpleImage() { Sprite = "lobby_descbg" }; _shwDepa = new LobbyShowcase { Position = new Point(60, _imgWhatDep.ClientArea.Bottom + 5), Size = new Size(675, 80), ButtonLeft = "job_arrowleft", ButtonRight = "job_arrowright", SelectionBackground = "dep_glow", ItemSpacing = 20, //ItemOffsets = new Size(40, 0) }; _shwDepa.Update(0); _imgDepGrad = new SimpleImage() { Sprite = "lobby_depgrad", Color = Color.FromArgb(120, Color.White), BlendingMode = BlendingModes.None }; _imgDepGrad.Update(0); _imgDepGrad.Position = new Point(_shwDepa.ClientArea.X + (int)(_shwDepa.ClientArea.Width / 2f - _imgDepGrad.ClientArea.Width / 2f), _shwDepa.ClientArea.Top); _lblDep = new Label("DEPARTMENT", "MICROGBE", resourceManager) { BackgroundColor = Color.WhiteSmoke, DrawBackground = true, TextColor = Color.FromArgb(53, 57, 66) }; _lblDep.Update(0); _lblDep.Position = new Point((int)(size.Width / 2f - _lblDep.ClientArea.Width / 2f), _shwDepa.ClientArea.Bottom + 5); _lblDep.Update(0); _imgJobFluff = new SimpleImage() { Sprite = "lobby_jobfluff" }; _imgJobFluff.Position = new Point(_lblDep.ClientArea.X + (int)(_lblDep.ClientArea.Width / 2f - _imgJobFluff.ClientArea.Width / 2f), _lblDep.ClientArea.Bottom); _shwJobs = new LobbyShowcase { Position = new Point(60, _lblDep.ClientArea.Bottom + 25), Size = new Size(675, 80), ButtonLeft = "job_arrowleft", ButtonRight = "job_arrowright", SelectionBackground = "job_glow" }; _shwJobs.Update(0); _imgJobGrad = new SimpleImage() { Sprite = "lobby_jobgrad", Color = Color.FromArgb(120, Color.White), BlendingMode = BlendingModes.None }; _imgJobGrad.Update(0); _imgJobGrad.Position = new Point(_shwJobs.ClientArea.X + (int)(_shwJobs.ClientArea.Width / 2f - _imgJobGrad.ClientArea.Width / 2f), _shwJobs.ClientArea.Top); _imgJobDesc.Update(0); _imgJobDesc.Position = new Point(0, _shwJobs.ClientArea.Bottom - 12); _imgJobDesc.Update(0); _lbljobName = new Label(" ", "MICROGBE", resourceManager) { TextColor = Color.WhiteSmoke }; _lbljobName.Position = new Point(3, _imgJobDesc.Position.Y + 4); _lbljobName.Update(0); _lbljobDesc = new Label(" ", "MICROGME", resourceManager) { TextColor = Color.WhiteSmoke }; _lbljobDesc.Position = new Point(3, _lbljobName.ClientArea.Bottom + 5); _bttReady.Position = new Point(ClientArea.Width - _bttReady.ClientArea.Width - 5, _imgJobDesc.ClientArea.Bottom + 4); components.Add(_lblDep); components.Add(_imgWhatDep); components.Add(_imgDepGrad); components.Add(_shwDepa); components.Add(_imgJobGrad); components.Add(_shwJobs); components.Add(_imgJobFluff); components.Add(_imgJobDesc); components.Add(_lbljobDesc); components.Add(_lbljobName); components.Add(_bttReady); }
private void BuildTileList(string searchStr = null) { int maxWidth = 0; int yOffset = 5; _tileList.components.Clear(); _tileList.ResetScrollbars(); Type type = typeof (Tile); List<Assembly> asses = AppDomain.CurrentDomain.GetAssemblies().ToList(); List<Type> types = asses.SelectMany(t => t.GetTypes()).Where(p => type.IsAssignableFrom(p) && !p.IsAbstract).ToList(); IEnumerable<string> rawNames = from a in types select a.Name; if (types.Count > 255) { throw new ArgumentOutOfRangeException("types.Count", "Can not load more than 255 types of tiles."); } List<string> typeNames = (searchStr == null) ? rawNames.ToList() : rawNames.Where(x => x.ToLower().Contains(searchStr.ToLower())).ToList(); if (searchStr != null) _clearLabel.BackgroundColor = Color.LightGray; foreach (string entry in typeNames) { var tileLabel = new Label(entry, "CALIBRI", _resourceManager); _tileList.components.Add(tileLabel); tileLabel.Position = new Point(5, yOffset); tileLabel.DrawBackground = true; tileLabel.DrawBorder = true; tileLabel.Update(0); yOffset += 5 + tileLabel.ClientArea.Height; tileLabel.Clicked += TileLabelClicked; if (tileLabel.ClientArea.Width > maxWidth) maxWidth = tileLabel.ClientArea.Width; } foreach (GuiComponent curr in _tileList.components.Where(curr => curr.GetType() == typeof (Label))) ((Label) curr).FixedWidth = maxWidth; }
public JobTab(string uniqueName, Size size, IResourceManager resourceManager) : base(uniqueName, size, resourceManager) { _bttReady = new ImageButton() { ImageNormal = "lobby_ready", ImageHover = "lobby_ready_green", BlendingMode = BlendingModes.None }; _bttReady.Clicked += _bttReady_Clicked; _bttReady.Update(0); _imgWhatDep = new SimpleImage() { Sprite = "lobby_whatdep" }; _imgWhatDep.Update(0); _imgWhatDep.Position = new Point((int)(size.Width / 2f - _imgWhatDep.ClientArea.Width / 2f), 30); _imgWhatDep.Update(0); _imgJobDesc = new SimpleImage() { Sprite = "lobby_descbg" }; _shwDepa = new LobbyShowcase { Position = new Point(60, _imgWhatDep.ClientArea.Bottom + 5), Size = new Size(675, 80), ButtonLeft = "job_arrowleft", ButtonRight = "job_arrowright", SelectionBackground = "dep_glow", ItemSpacing = 20, //ItemOffsets = new Size(40, 0) }; _shwDepa.Update(0); _imgDepGrad = new SimpleImage() { Sprite = "lobby_depgrad", Color = Color.FromArgb(120, Color.White), BlendingMode = BlendingModes.None }; _imgDepGrad.Update(0); _imgDepGrad.Position = new Point(_shwDepa.ClientArea.X + (int)(_shwDepa.ClientArea.Width / 2f - _imgDepGrad.ClientArea.Width / 2f), _shwDepa.ClientArea.Top); _lblDep = new Label("DEPARTMENT", "MICROGBE", resourceManager) { BackgroundColor = Color.WhiteSmoke, DrawBackground = true, TextColor = Color.FromArgb(53,57,66) }; _lblDep.Update(0); _lblDep.Position = new Point((int)(size.Width / 2f - _lblDep.ClientArea.Width / 2f), _shwDepa.ClientArea.Bottom + 5); _lblDep.Update(0); _imgJobFluff = new SimpleImage() { Sprite = "lobby_jobfluff" }; _imgJobFluff.Position = new Point(_lblDep.ClientArea.X + (int)(_lblDep.ClientArea.Width / 2f - _imgJobFluff.ClientArea.Width / 2f), _lblDep.ClientArea.Bottom); _shwJobs = new LobbyShowcase { Position = new Point(60, _lblDep.ClientArea.Bottom + 25), Size = new Size(675, 80), ButtonLeft = "job_arrowleft", ButtonRight = "job_arrowright", SelectionBackground = "job_glow" }; _shwJobs.Update(0); _imgJobGrad = new SimpleImage() { Sprite = "lobby_jobgrad", Color = Color.FromArgb(120, Color.White), BlendingMode = BlendingModes.None }; _imgJobGrad.Update(0); _imgJobGrad.Position = new Point(_shwJobs.ClientArea.X + (int)(_shwJobs.ClientArea.Width / 2f - _imgJobGrad.ClientArea.Width / 2f), _shwJobs.ClientArea.Top); _imgJobDesc.Update(0); _imgJobDesc.Position = new Point(0, _shwJobs.ClientArea.Bottom - 12); _imgJobDesc.Update(0); _lbljobName = new Label(" ", "MICROGBE", resourceManager) { TextColor = Color.WhiteSmoke }; _lbljobName.Position = new Point(3, _imgJobDesc.Position.Y + 4); _lbljobName.Update(0); _lbljobDesc = new Label(" ", "MICROGME", resourceManager) { TextColor = Color.WhiteSmoke }; _lbljobDesc.Position = new Point(3, _lbljobName.ClientArea.Bottom + 5); _bttReady.Position = new Point(ClientArea.Width - _bttReady.ClientArea.Width - 5, _imgJobDesc.ClientArea.Bottom + 4); components.Add(_lblDep); components.Add(_imgWhatDep); components.Add(_imgDepGrad); components.Add(_shwDepa); components.Add(_imgJobGrad); components.Add(_shwJobs); components.Add(_imgJobFluff); components.Add(_imgJobDesc); components.Add(_lbljobDesc); components.Add(_lbljobName); components.Add(_bttReady); }
public ContextMenuButton(ContextMenuEntry entry, Vector2D size, IResourceManager resourceManager) { _resourceManager = resourceManager; UserData = entry.ComponentMessage; Size = size; _currentColor = Color.Gray; _iconSprite = _resourceManager.GetSprite(entry.IconName); _textLabel = new Label(entry.EntryName, "CALIBRI", _resourceManager); _textLabel.Update(0); }