/// <summary> /// Initializes the control. /// </summary> /// <param name="teammate">Teammate model to initialize the control from.</param> /// <param name="addIcon">Texture of the add icon.</param> /// <param name="removeIcon">Texture of the remove icon.</param> public void Init(Teammate teammate, Texture addIcon, Texture removeIcon) { Teammate = teammate; var actionIcon = teammate.IsAddedToTeam ? removeIcon : addIcon; var usedTexture = teammate.IsAddedToTeam ? teammate.SmallTexture : teammate.BigTexture; _verticalContainer = GetNode <VBoxContainer>("VerticalContainer"); _teammateButton = _verticalContainer.GetNode <TextureButton>("TeammateButton"); _actionIcon = _teammateButton.GetNode <TextureRect>("ActionIcon"); _teammateName = _verticalContainer.GetNode <Label>("CenterContainer/TeammateName"); _teammateButton.TextureNormal = usedTexture; var teammateButtonSize = _teammateButton.TextureNormal.GetSize(); this.RectMinSize = _teammateButton.TextureNormal.GetSize(); _teammateName.Text = teammate.Name; _actionIcon.Texture = teammate.IsAddedToTeam ? actionIcon : actionIcon; var actionIconSize = _actionIcon.Texture.GetSize(); _actionIcon.SetPosition(new Vector2(teammateButtonSize.x - actionIconSize.x, teammateButtonSize.y - actionIconSize.y)); _teammateButton.Connect("pressed", this, nameof(OnClick)); _verticalContainer.Set("custom_constants/separation", VerticalContainerSeparation); _teammateName.AddFontOverride("font", Font); if (LabelColor.HasValue) { _teammateName.AddColorOverride("font_color", LabelColor.Value); } }
public override void SetInstructions(List <string> instructions) { DeleteInstructions(); foreach (var item in instructions) { var label = new Label(); label.AddFontOverride("font", _instructionsFont); label.AddColorOverride("font_color", _instructionsColor); label.Autowrap = true; label.RectSize = _instructionsBackground.RectSize; label.RectMinSize = new Vector2(_instructionsBackground.RectSize.x - 10, 0); label.Text = item; _instructionsContainer.AddChild(label); } var confirmLabel = new Label(); confirmLabel.AddFontOverride("font", _instructionsFont); confirmLabel.AddColorOverride("font_color", _instructionsColor); confirmLabel.Autowrap = true; confirmLabel.RectSize = _instructionsBackground.RectSize; confirmLabel.RectMinSize = new Vector2(_instructionsBackground.RectSize.x - 10, 0); confirmLabel.Text = ResourceStrings.Nongamified.CompleteSequenceNongamified; _instructionsContainer.AddChild(confirmLabel); }
/// <summary> /// Display the column titles for completed Assignments /// </summary> private void DisplayCompletedHeader() { //Student Name Label lbl = new Label(); lbl.AddFontOverride("font", dFont); lbl.Text = "Assignment" + " "; lbl.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl); Label lbl3 = new Label(); lbl3.AddFontOverride("font", dFont); lbl3.Text = "Teacher" + " "; lbl3.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl3); Label date = new Label(); date.AddFontOverride("font", dFont); date.Text = "DueDate" + " "; date.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(date); Label lbl2 = new Label(); lbl2.AddFontOverride("font", dFont); lbl2.Text = "Score"; lbl2.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl2); }
/// <summary> /// Display column titles for the Student's CreatedLevels /// </summary> private void DisplayHeader() { //Student Name Label lbl = new Label(); lbl.AddFontOverride("font", dFont); lbl.Text = "Game Name" + " "; lbl.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl); Label lbl3 = new Label(); lbl3.AddFontOverride("font", dFont); lbl3.Text = " "; lbl3.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl3); Label lbl4 = new Label(); lbl4.AddFontOverride("font", dFont); lbl4.Text = " "; lbl4.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl4); Label lbl5 = new Label(); lbl5.AddFontOverride("font", dFont); lbl5.Text = " "; lbl5.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl5); }
private void PrepIntelColumn(EncounterState state) { var playerComponent = state.Player.GetComponent <PlayerComponent>(); var intelColumn = GetNode <VBoxContainer>("Columns/IntelColumn"); if (_intelLabels == null) { _intelLabels = new List <Label>(); for (int i = 1; i < state.LevelsInDungeon; i++) { var font = new DynamicFont(); font.FontData = (DynamicFontData)GD.Load(_fontPath); var newLabel = new Label(); newLabel.AddFontOverride("font", font); intelColumn.AddChild(newLabel); _intelLabels.Add(newLabel); newLabel.Text = string.Format("Sector {0}: {1}", i, playerComponent.KnowsIntel(i) ? "KNOWN" : "UNKNOWN"); } } else { for (int i = 1; i < state.LevelsInDungeon; i++) { _intelLabels[i - 1].Text = string.Format("Sector {0}: {1}", i, playerComponent.KnowsIntel(i) ? "KNOWN" : "UNKNOWN"); } } }
/// <summary> /// Displayed Assignments completed by Student /// </summary> private void DisplayCompletedAssignments() { List <AssignmentScore> completedAssignments = assignmentScoreBL.GetStudentCompletedAssignment(Global.StudentId); foreach (AssignmentScore as2 in completedAssignments) { Label name = new Label(); name.AddFontOverride("font", dFont2); name.Text = as2.PublishedAssignment.Assignment.AssignmentName; name.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(name); Label teacher = new Label(); teacher.AddFontOverride("font", dFont2); teacher.Text = as2.PublishedAssignment.Assignment.Teacher.TeacherName; teacher.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(teacher); Label date = new Label(); date.AddFontOverride("font", dFont2); date.Text = as2.PublishedAssignment.DueDate.ToString() + " "; date.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(date); Label score = new Label(); score.AddFontOverride("font", dFont2); score.Text = as2.Score.ToString(); score.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(score); } }
/// <summary> /// Display the game list /// </summary> private void DisplayGameList() { ClearGrid(); DisplayHeader(); gridContainer.Columns = 3; Theme theme = ResourceLoader.Load("res://Assets/GUI/BtnUI4.tres") as Theme; foreach (CustomLevel cl in customLevelList) { Label lbl3 = new Label(); lbl3.AddFontOverride("font", dFont2); lbl3.Text = cl.CustomLevelName + " "; lbl3.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl3); Label lbl2 = new Label(); lbl2.AddFontOverride("font", dFont2); lbl2.Text = cl.Student.StudentName; lbl2.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl2); Button btn = new Button(); btn.RectMinSize = new Vector2(80, 30); btn.Text = "Play"; string[] arr = new string[1] { btn.Name }; Godot.Collections.Array ar = new Godot.Collections.Array(); ar.Add(btn); btn.Name = cl.CustomLevelId.ToString(); btn.Connect("pressed", this, "PlayLevel", ar); btn.Theme = theme; gridContainer.AddChild(btn); } }
public void FillDataPipe(IEnumerable <IEnumerable <int> > data) { int numPipe = 0; foreach (IEnumerable <int> pipe in data) { HBoxContainer actualHBoxContainer = new HBoxContainer(); var actualLabelPipe = new Label(); numPipe++; actualLabelPipe.Text = $" * tube n°{numPipe}"; actualLabelPipe.AddFontOverride("font", ResourceLoader.Load <Font>("res://fonts/fontsmall.tres")); actualLabelPipe.AddColorOverride("font_color", Colors.Black); vBoxContainer.AddChild(actualLabelPipe); vBoxContainer.AddChild(actualHBoxContainer); var hSeparator = new HSeparator(); StyleBoxLine sbl = new StyleBoxLine() { Color = new Color("ad4c4c"), Thickness = 5 }; hSeparator.AddStyleboxOverride("separator", sbl); vBoxContainer.AddChild(hSeparator); foreach (int length in pipe) { actualHBoxContainer.AddChild(CreateLabelPipeDraw(length)); } } RectSize = new Vector2(RectSize.x, (numPipe) * 68); }
/// <summary> /// Display the header for Leaderboard /// </summary> private void AddHeader() { dFont = new DynamicFont(); dFont.FontData = ResourceLoader.Load("res://Fonts/Candy Beans.otf") as DynamicFontData; dFont.Size = 26; Label rank = new Label(); rank.AddFontOverride("font", dFont); rank.Text = "Rank "; rank.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(rank); Label lbl = new Label(); lbl.AddFontOverride("font", dFont); lbl.Text = "Name "; lbl.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl); Label lbl2 = new Label(); lbl2.AddFontOverride("font", dFont); lbl2.Text = "Score"; lbl2.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl2); }
public override void _Ready() { _overlayWrapper = GetNode <MarginContainer>("MarginContainer"); _gameStatusLabel = _overlayWrapper.GetNode <Label>("GameStatusContainer/GameStatusLabel"); _nicknameValue = _overlayWrapper.GetNode <LineEdit>("VBoxContainer/NicknameLabel"); _gameCodeValue = _overlayWrapper.GetNode <LineEdit>("VBoxContainer/GameCodeValue"); _codeErrorLabel = _overlayWrapper.GetNode <Label>("VBoxContainer/CodeErrorLabel"); _enterNicknameLabel = _overlayWrapper.GetNode <Label>("VBoxContainer/EnterNicknameLabel"); _enterCodeLabel = _overlayWrapper.GetNode <Label>("VBoxContainer/EnterCodeLabel"); _startButton = _overlayWrapper.GetNode <Button>("VBoxContainer/StartButton"); _gameStatusLabel.Visible = false; _codeErrorLabel.Visible = false; var font = (DynamicFont)GD.Load($"{Constants.ResourcesPath}Fonts/Montserrat/montserrat_regular.tres"); font.Size = 25; _enterNicknameLabel.AddFontOverride("font", font); _enterCodeLabel.AddFontOverride("font", font); _codeErrorLabel.AddFontOverride("font", font); _nicknameValue.AddFontOverride("font", font); _gameCodeValue.AddFontOverride("font", font); _startButton.AddFontOverride("font", font); var boldFont = (DynamicFont)GD.Load($"{Constants.ResourcesPath}Fonts/Montserrat/montserrat_bold.tres"); boldFont.Size = 55; _gameStatusLabel.AddFontOverride("font", boldFont); _gameStatusLabel.AddColorOverride("font_color", new Color("#bf5034")); _startButton.Connect("pressed", this, nameof(StartButtonPressed)); }
private DynamicPart CreateDynamicPart(int offset, IEnumerable <string> texts, int columns, Font overrideFont = null) { if (columns <= 1) { return(CreateDynamicPart(offset, string.Join("\n", texts))); } var splitTexts = Enumerable.Range(0, columns).Select(_ => new StringBuilder()).ToList(); using (var textEnumerator = texts.GetEnumerator()) { bool done = false; while (!done) { foreach (var column in splitTexts) { if (!textEnumerator.MoveNext()) { done = true; break; } column.AppendLine(textEnumerator.Current); } } } var hBox = new HBoxContainer { // 0.7 == 15% shrink of middle spacing for 2 columns and move position to center. RectPosition = new Vector2(columns == 2 ? RectSize.x * 0.15f : 0, 0), RectMinSize = new Vector2(columns == 2 ? RectSize.x * 0.7f : RectSize.x, 0), }; foreach (var columnText in splitTexts) { var label = new Label { Text = columnText.ToString(), Align = Label.AlignEnum.Center, SizeFlagsHorizontal = (int)SizeFlags.ExpandFill, }; if (overrideFont != null) { label.AddFontOverride("font", overrideFont); } hBox.AddChild(label); } var dynamicPart = new DynamicPart(offset, hBox); AddDynamicItem(dynamicPart); return(dynamicPart); }
public void ItemButtonReleased() { if (_inventory.SelectedItemId < 0) { return; } Item.ItemStack selectedItemStack = _itemList[_inventory.SelectedItemId]; if (_alchemyStage == AlchemyStage.MortarPestle && _mortarPestleStage == MortarPestleStage.PickReagents && _potionReagents.Count < 4) { if (selectedItemStack.stackCount > 1) { _itemList[_inventory.SelectedItemId] = Item.DecreaseItemStackCount(selectedItemStack, 1); } else { _itemList.RemoveAt(_inventory.SelectedItemId); } _inventory.Update(); HBoxContainer itemInfo = new HBoxContainer(); itemInfo.Set("custom_constants/separation", 10f); Control itemIcon = new Control(); itemIcon.RectMinSize = new Vector2(16f, 16f); Sprite itemBG = new Sprite(); itemBG.Texture = _singleItemSlot; itemBG.Centered = false; Sprite itemSprite = new Sprite(); itemSprite.Texture = selectedItemStack.item.IconTex; itemSprite.Centered = false; itemSprite.Position = new Vector2(2f, 2f); itemBG.AddChild(itemSprite); itemIcon.AddChild(itemBG); itemInfo.AddChild(itemIcon); Label itemName = new Label(); itemName.Text = selectedItemStack.item.Name; itemName.AddFontOverride("font", _smallFont); itemName.MarginLeft = 4f; itemInfo.AddChild(itemName); _potionReagentsBox.AddChild(itemInfo); _potionReagents.Add(selectedItemStack.item); _proceedToCrush.Disabled = false; } GD.Print("Selected: " + selectedItemStack.item.Name); }
/// <summary> /// Display the Levels /// </summary> private void DisplayLevels() { Theme theme = ResourceLoader.Load("res://Assets/GUI/BtnUI4.tres") as Theme; customLevelList = customLevelBL.GetStudentCustomLevel(Global.StudentId); foreach (CustomLevel customLevel in customLevelList) { Label name = new Label(); name.AddFontOverride("font", dFont2); name.Text = customLevel.CustomLevelName + " "; name.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(name); Button playBtn = new Button(); playBtn.RectMinSize = new Vector2(80, 30); playBtn.Text = "Play"; string[] playArr = new string[1] { playBtn.Name }; Godot.Collections.Array playAr = new Godot.Collections.Array(); playAr.Add(playBtn); playBtn.Name = customLevel.CustomLevelId.ToString(); playBtn.Connect("pressed", this, "PlayLevel", playAr); playBtn.Theme = theme; gridContainer.AddChild(playBtn); Button btn = new Button(); btn.RectMinSize = new Vector2(80, 30); btn.Text = "Edit"; string[] arr = new string[1] { btn.Name }; Godot.Collections.Array ar = new Godot.Collections.Array(); ar.Add(btn); btn.Name = customLevel.CustomLevelName.ToString(); btn.Connect("pressed", this, "EditLevel", ar); btn.Theme = theme; gridContainer.AddChild(btn); Button btn2 = new Button(); btn2.RectMinSize = new Vector2(80, 30); btn2.Text = "Delete"; string[] arr2 = new string[1] { btn2.Name }; Godot.Collections.Array ar2 = new Godot.Collections.Array(); ar2.Add(btn2); btn2.Name = customLevel.CustomLevelName.ToString() + " "; btn2.Connect("pressed", this, "DeleteLevel", ar2); btn2.Theme = theme; gridContainer.AddChild(btn2); } }
private void AddElement(string stringLabel) { Label label = new Label(); label.RectSize = new Vector2(1000, 80); label.RectPosition = new Vector2(440, yPositionSpawn += 80); label.Align = Godot.Label.AlignEnum.Center; label.AddFontOverride("font", dynamicFont); label.Text = stringLabel; AddChild(label); }
protected override void SetupView() { _textureOff = (Texture)GD.Load($"{_resourcesPath}star_off.png"); _textureOn = (Texture)GD.Load($"{_resourcesPath}star_on.png"); _background.Texture = (Texture)GD.Load($"{_resourcesPath}rating_background.png"); _background.Position = new Vector2(181, 155); var font = (DynamicFont)GD.Load($"{_resourcesPath}montserrat_light.tres"); font.Size = 24; _title.AddFontOverride("font", font); _title.Text = "Ohodnotit"; _windowWrapper.RectPosition = new Vector2(25, 10); _windowWrapper.Set("custom_constants/separation", 21); _marginContainer.Set("custom_constants/margin_left", 28); _horizontalContainer.Set("custom_constants/separation", 15); _commentsMarginContainer = _windowWrapper.GetNode <MarginContainer>("CommentsMarginContainer"); _commentsMarginContainer.Set("custom_constants/margin_left", 7); _commentsContainer = _commentsMarginContainer.GetNode <VBoxContainer>("CommentsContainer"); _commentsContainer.Set("custom_constants/separation", 15); var lineTexture = (Texture)GD.Load($"{_resourcesPath}line.png"); var comments = new string[] { "skvělé\nHana", "Líbí se mi tato verze.\nPetr" }; foreach (var comment in comments) { var line = new TextureRect(); line.Texture = lineTexture; _commentsContainer.AddChild(line); var margin = new MarginContainer(); margin.Set("custom_constants/margin_left", 10); var label = new Label(); label.AddFontOverride("font", font); label.Text = comment; margin.AddChild(label); _commentsContainer.AddChild(margin); } }
public void AddPlayer(int id, String name) { Label playerLabel = new Label(); playerLabel.Name = id.ToString(); playerLabel.Text = name; playerLabel.AddFontOverride("font", (Font)GD.Load("res://Assets/Fonts/Default.tres")); GetNode("UI/VBoxContainer/Players").AddChild(playerLabel); PlayerReference playerReference = new PlayerReference(id, name); ClientVariables.ConnectedPlayers.Add(playerReference); }
/// <summary> /// Display the Credits /// </summary> private void DisplayCredits() { Godot.File file = new Godot.File(); file.Open("res://Credits/credits.txt", Godot.File.ModeFlags.Read); string content = file.GetAsText(); file.Close(); Label name = new Label(); name.AddFontOverride("font", dFont); name.Text = content; name.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(name); }
/// <summary> /// Dislpay Assignments that are published to the class that the Student belongs to /// </summary> private void DisplayAssignment() { foreach (PublishedAssignment assignment in assignmentList) { Label name = new Label(); name.AddFontOverride("font", dFont2); name.Text = assignment.Assignment.AssignmentName; name.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(name); Label teacher = new Label(); teacher.AddFontOverride("font", dFont2); teacher.Text = assignment.Assignment.Teacher.TeacherName; teacher.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(teacher); Label date = new Label(); date.AddFontOverride("font", dFont2); date.Text = assignment.DueDate.ToString(); date.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(date); if (DateTime.Compare(DateTime.Now, assignment.DueDate) > 0) { Label expire = new Label(); expire.AddFontOverride("font", dFont); expire.Text = ""; expire.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(expire); } else { Theme theme = ResourceLoader.Load("res://Assets/GUI/BtnUI4.tres") as Theme; Button btn = new Button(); btn.RectMinSize = new Vector2(80, 30); btn.Text = "Play"; btn.Theme = theme; string[] arr = new string[1] { btn.Name }; Godot.Collections.Array ar = new Godot.Collections.Array(); ar.Add(btn); btn.Name = assignment.Assignment.AssignmentId.ToString(); btn.Connect("pressed", this, "PlayAssignment", ar); gridContainer.AddChild(btn); } } }
private Label CreateLabel(int power, EncounterPosition position) { var label = new Label(); label.Text = power.ToString(); var numCenterPos = PositionComponent.IndexToVector(position.X, position.Y); label.AddFontOverride("font", this._damageFont); label.AddColorOverride("font_color", new Color(1f, 0f, 0f)); // The size isn't determined until after it's first placed, so we place, then reposition according to size to center it. label.SetPosition(numCenterPos); var size = label.RectSize; label.SetPosition(new Vector2(numCenterPos.x - size.x / 2, numCenterPos.y - size.y / 2)); return(label); }
/// <summary> /// Display the Leaderboard /// </summary> /// <param name="leaderboardList"></param> private void DisplayLeaderboard(List <Leaderboard> leaderboardList) { ClearGrid(); DynamicFont dFont2 = new DynamicFont(); dFont2.FontData = ResourceLoader.Load("res://Fonts/Candy Beans.otf") as DynamicFontData; dFont2.Size = 15; int i = 1; foreach (Leaderboard lb in leaderboardList) { Label rank = new Label(); rank.AddFontOverride("font", dFont2); rank.Text = i.ToString(); rank.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(rank); //Student Name Label lbl = new Label(); lbl.AddFontOverride("font", dFont2); lbl.Text = lb.StudentName; lbl.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl); /* * //Sprite * Sprite charSprite = new Sprite(); * var texture = ResourceLoader.Load(String.Format("res://CharSprites/{0}/Head/head.png", lb.CharName)) as Texture; * charSprite.Texture = texture; * charSprite.Scale= new Vector2(0.15f, 0.15f); * gridContainer.AddChild(charSprite); */ //Total Score Label lbl2 = new Label(); lbl2.AddFontOverride("font", dFont2); lbl2.Text = lb.TotalScore.ToString(); lbl2.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl2); //vbox.AddChild(lbl); i++; } // itemList.AddItem(lb.StudentName + " " + lb.TotalScore); }
/// <summary> /// Display Cleared CustomLevels /// </summary> private void DisplayClearedCustomLevels() { ClearGrid(); DisplayHistoryHeader(); gridContainer.Columns = 4; List <CustomLevelScore> customLevelScore = customLevelBL.GetClearedCustomLevels(Global.StudentId); Theme theme = ResourceLoader.Load("res://Assets/GUI/BtnUI4.tres") as Theme; foreach (CustomLevelScore cls in customLevelScore) { Label lbl3 = new Label(); lbl3.AddFontOverride("font", dFont2); lbl3.Text = cls.CustomLevel.CustomLevelName + " "; lbl3.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl3); Label lbl5 = new Label(); lbl5.AddFontOverride("font", dFont2); lbl5.Text = cls.Student.StudentName + " "; lbl5.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl5); Label lbl4 = new Label(); lbl4.AddFontOverride("font", dFont2); lbl4.Text = cls.LevelScore + " "; lbl4.AddColorOverride("font_color", new Color(0, 0, 0)); gridContainer.AddChild(lbl4); Button btn = new Button(); btn.RectMinSize = new Vector2(80, 30); btn.Text = "Play"; string[] arr = new string[1] { btn.Name }; Godot.Collections.Array ar = new Godot.Collections.Array(); ar.Add(btn); //Button da = (Button)GetNode("btn"); btn.Name = cls.CustomLevel.CustomLevelId.ToString(); btn.Connect("pressed", this, "JoinLevel", ar); btn.Theme = theme; gridContainer.AddChild(btn); } }
/// <summary> /// Initializes the control with provided values. /// </summary> /// <param name="deselectedTexture">Texture of deactivated control</param> /// <param name="selectedTexture">Texture of activated control</param> /// <param name="controlValue">Value of the control</param> /// <param name="defaultSelected">Sets whether the control is selected by default</param> /// <param name="labelText">Text of the control's label</param> /// <param name="font">Font of the control's label</param> public void Init(Texture deselectedTexture, Texture selectedTexture, int controlValue, bool defaultSelected = false, string labelText = null, DynamicFont font = null) { base.Init(deselectedTexture, selectedTexture, controlValue, defaultSelected); _labelText = labelText; _font = font; _centerContainer = GetNode <CenterContainer>("CenterContainer"); Label = _centerContainer.GetNode <Label>("Label"); Label.Align = Label.AlignEnum.Center; Label.Valign = Label.VAlign.Center; if (!string.IsNullOrEmpty(_labelText) && _font != null) { Label.AddFontOverride("font", _font); Label.Text = _labelText; } }
protected override void Initialize() { base.Initialize(); IoCManager.InjectDependencies(this); SizeFlagsHorizontal = SizeFlags.None; contents = new Label(); AddChild(contents); contents.AddFontOverride("font", resourceCache.GetResource <FontResource>(new ResourcePath("/Fonts/CALIBRI.TTF")).MakeDefault()); contents.AddColorOverride("font_color_shadow", Color.Black); contents.MarginLeft = contents.MarginTop = 5; var bg = new StyleBoxFlat { BackgroundColor = new Color(255, 105, 67, 138), }; AddStyleBoxOverride("panel", bg); MouseFilter = contents.MouseFilter = MouseFilterMode.Ignore; }
public InvItem(Item item, int count, InvSlot slot) { this.Slot = slot; this.Item = item; this.Count = count; this.Texture = item.GetIcon(); this.HintTooltip = item.Name; this.MarginLeft = 12; this.MarginTop = 12; this.Connect("mouse_entered", this, nameof(OnMouseEntered)); this.Connect("mouse_exited", this, nameof(OnMouseExited)); countLabel = new Label(); countLabel.SetAlign(Label.AlignEnum.Right); countLabel.SetValign(Label.VAlign.Bottom); countLabel.AnchorRight = 1; countLabel.MarginRight = 2; countLabel.AnchorBottom = 1; countLabel.MarginBottom = 2; countLabel.AddColorOverride("font_color", new Color(0, 0, 0, 1)); countLabel.AddFontOverride("font", ResourceLoader.Load("res://assets/ui/small_font.tres") as Font); AddChild(countLabel); }
public override void _Ready() { base._Ready(); _currentPerformance = GetNode <Label>("CurrentPerformance"); _previousAverage = GetNode <Label>("PreviousAverage"); _current1 = _category1.GetNode <Label>("Current"); _previous1 = _category1.GetNode <Label>("Previous"); _current2 = _category2.GetNode <Label>("Current"); _previous2 = _category2.GetNode <Label>("Previous"); _current3 = _category3.GetNode <Label>("Current"); _previous3 = _category3.GetNode <Label>("Previous"); var headlineFont = (DynamicFont)GD.Load($"{_popupResourcesPath}montserrat_extra_bold.tres"); headlineFont.Size = 48; var tableHeaderFont = (DynamicFont)GD.Load($"{_popupResourcesPath}montserrat_bold_small.tres"); tableHeaderFont.Size = 18; var tableDataFont = (DynamicFont)GD.Load($"{_popupResourcesPath}montserrat_bold.tres"); tableDataFont.Size = 24; _headline.AddFontOverride("font", headlineFont); _headline.AddColorOverride("font_color", _mintColor); _currentPerformance.AddFontOverride("font", tableHeaderFont); _currentPerformance.AddColorOverride("font_color", _blackColor); _previousAverage.AddFontOverride("font", tableHeaderFont); _previousAverage.AddColorOverride("font_color", _blackColor); _name1.AddFontOverride("font", tableDataFont); _name2.AddFontOverride("font", tableDataFont); _name3.AddFontOverride("font", tableDataFont); _current1.AddFontOverride("font", tableDataFont); _current2.AddFontOverride("font", tableDataFont); _current3.AddFontOverride("font", tableDataFont); _previous1.AddFontOverride("font", tableDataFont); _previous2.AddFontOverride("font", tableDataFont); _previous3.AddFontOverride("font", tableDataFont); _name1.AddColorOverride("font_color", _mintColor); _name2.AddColorOverride("font_color", _mintColor); _name3.AddColorOverride("font_color", _mintColor); _current1.AddColorOverride("font_color", _blackColor); _current2.AddColorOverride("font_color", _blackColor); _current3.AddColorOverride("font_color", _blackColor); _previous1.AddColorOverride("font_color", _blackColor); _previous2.AddColorOverride("font_color", _blackColor); _previous3.AddColorOverride("font_color", _blackColor); this.Texture = (Texture)GD.Load($"{_popupResourcesPath}task_completed_popup_background.png"); _confirmButton.TextureNormal = (Texture)GD.Load($"{_popupResourcesPath}task_completed_continue_button.png"); _headline.Align = Label.AlignEnum.Center; _headline.RectPosition = new Vector2(480, 210); _currentPerformance.Align = Label.AlignEnum.Center; _currentPerformance.Autowrap = true; _currentPerformance.RectMinSize = new Vector2(120, 0); _currentPerformance.RectPosition = new Vector2(1095, 373); _previousAverage.Align = Label.AlignEnum.Center; _previousAverage.Autowrap = true; _previousAverage.RectMinSize = new Vector2(120, 0); _previousAverage.RectPosition = new Vector2(1320, 370); _name1.RectPosition = new Vector2(440, 474); _name2.RectPosition = new Vector2(440, 576); _name3.RectPosition = new Vector2(440, 683); _current1.Align = Label.AlignEnum.Center; _current1.RectMinSize = new Vector2(105, 40); _current1.RectPosition = new Vector2(1107, 474); _current2.Align = Label.AlignEnum.Center; _current2.RectMinSize = new Vector2(105, 40); _current2.RectPosition = new Vector2(1107, 576); _current3.Align = Label.AlignEnum.Center; _current3.RectMinSize = new Vector2(105, 40); _current3.RectPosition = new Vector2(1107, 683); _previous1.Align = Label.AlignEnum.Center; _previous1.RectMinSize = new Vector2(105, 40); _previous1.RectPosition = new Vector2(1330, 474); _previous2.Align = Label.AlignEnum.Center; _previous2.RectMinSize = new Vector2(105, 40); _previous2.RectPosition = new Vector2(1330, 576); _previous3.Align = Label.AlignEnum.Center; _previous3.RectMinSize = new Vector2(105, 40); _previous3.RectPosition = new Vector2(1330, 683); _confirmButton.RectPosition = new Vector2(859, 812); _upArrowBlue = (Texture)GD.Load($"{_popupResourcesPath}up_arrow_blue.png"); _downArrowRed = (Texture)GD.Load($"{_popupResourcesPath}down_arrow_red.png"); _currentPerformance.Text = ResourceStrings.Nongamified.CurrentPerformance; _previousAverage.Text = ResourceStrings.Nongamified.PreviousAverage; _name1.Text = ResourceStrings.Nongamified.CorrectActionsInSequence; _name2.Text = ResourceStrings.Nongamified.CorrectActionsStreak; _name3.Text = ResourceStrings.Nongamified.TaskTimeLeft; _comparison1.RectPosition = new Vector2(1076, 463); _comparison2.RectPosition = new Vector2(1076, 565); _comparison3.RectPosition = new Vector2(1076, 667); }
public override void _Ready() { base._Ready(); _award = GetNode <Label>("Award"); _gainedPoints = GetNode <Label>("GainedPoints"); _points1 = _category1.GetNode <Label>("Points"); _points2 = _category2.GetNode <Label>("Points"); _points3 = _category3.GetNode <Label>("Points"); _sum = GetNode <Control>("Sum"); _nameSum = _sum.GetNode <Label>("Name"); _pointsSum = _sum.GetNode <Label>("Points"); var headlineFont = (DynamicFont)GD.Load($"{_popupResourcesPath}bebas_neue_headline.tres"); headlineFont.Size = 50; var tableDataFont = (DynamicFont)GD.Load($"{_popupResourcesPath}bebas_neue_data.tres"); tableDataFont.Size = 42; var tableSummaryFont = (DynamicFont)GD.Load($"{_popupResourcesPath}bebas_neue_data.tres"); tableSummaryFont.Size = 58; _headline.AddFontOverride("font", headlineFont); _headline.AddColorOverride("font_color", _whiteColor); _award.AddFontOverride("font", tableDataFont); _award.AddColorOverride("font_color", _whiteColor); _gainedPoints.AddFontOverride("font", tableDataFont); _gainedPoints.AddColorOverride("font_color", _whiteColor); _name1.AddFontOverride("font", tableDataFont); _name2.AddFontOverride("font", tableDataFont); _name3.AddFontOverride("font", tableDataFont); _points1.AddFontOverride("font", tableDataFont); _points2.AddFontOverride("font", tableDataFont); _points3.AddFontOverride("font", tableDataFont); _name1.AddColorOverride("font_color", _paleYellowColor); _name2.AddColorOverride("font_color", _paleYellowColor); _name3.AddColorOverride("font_color", _paleYellowColor); _points1.AddColorOverride("font_color", _paleRedColor); _points2.AddColorOverride("font_color", _paleRedColor); _points3.AddColorOverride("font_color", _paleRedColor); _nameSum.AddFontOverride("font", tableSummaryFont); _nameSum.AddColorOverride("font_color", _yellowColor); _pointsSum.AddFontOverride("font", tableSummaryFont); _pointsSum.AddColorOverride("font_color", _redColor); this.Texture = (Texture)GD.Load($"{_popupResourcesPath}background.png"); _confirmButton.TextureNormal = (Texture)GD.Load($"{_popupResourcesPath}continue_button.png"); _headline.Align = Label.AlignEnum.Center; _headline.Autowrap = true; _headline.RectMinSize = new Vector2(650, 0); _headline.RectPosition = new Vector2(660, 210); _award.Align = Label.AlignEnum.Center; _award.RectPosition = new Vector2(480, 400); _gainedPoints.Align = Label.AlignEnum.Right; _gainedPoints.RectPosition = new Vector2(1400, 400); _name1.RectPosition = new Vector2(480, 495); _name2.RectPosition = new Vector2(480, 585); _name3.RectPosition = new Vector2(480, 675); _points1.Align = Label.AlignEnum.Right; _points1.GrowHorizontal = GrowDirection.Begin; _points1.RectMinSize = new Vector2(105, 40); _points1.RectPosition = new Vector2(1450, 495); _points2.Align = Label.AlignEnum.Right; _points2.GrowHorizontal = GrowDirection.Begin; _points2.RectMinSize = new Vector2(105, 40); _points2.RectPosition = new Vector2(1450, 585); _points3.Align = Label.AlignEnum.Right; _points3.GrowHorizontal = GrowDirection.Begin; _points3.RectMinSize = new Vector2(105, 40); _points3.RectPosition = new Vector2(1450, 675); _nameSum.RectPosition = new Vector2(480, 775); _pointsSum.RectPosition = new Vector2(1450, 775); _pointsSum.RectMinSize = new Vector2(120, 0); _pointsSum.Align = Label.AlignEnum.Right; _pointsSum.GrowHorizontal = GrowDirection.Begin; _confirmButton.RectPosition = new Vector2(855, 850); _upArrowOrange = (Texture)GD.Load($"{_popupResourcesPath}up_arrow_orange.png"); _downArrowRed = (Texture)GD.Load($"{_popupResourcesPath}down_arrow_red.png"); _award.Text = ResourceStrings.Gamified.Award; _gainedPoints.Text = ResourceStrings.Gamified.Points; _name1.Text = ResourceStrings.Gamified.EquipmentQuality; _name2.Text = ResourceStrings.Gamified.PerfectTaskBonusPoints; _name3.Text = ResourceStrings.Gamified.SavedTime; _nameSum.Text = ResourceStrings.Gamified.TotalPoints; _comparison1.RectPosition = new Vector2(1320, 495); _comparison2.RectPosition = new Vector2(1320, 585); _comparison3.RectPosition = new Vector2(1320, 675); }
public void OnLevelCompleted(LevelResult result, SceneManager parent) { this.parent = parent; VBoxContainer textContainer = (VBoxContainer)FindNode("TextContainer"); VBoxContainer splitContainer = (VBoxContainer)FindNode("UISplitContainer"); splitContainer.Set("custom_constants/separation", 200 - result.enemies.Count * 18); DynamicFont headerFont = new DynamicFont(); headerFont.FontData = (DynamicFontData)ResourceLoader.Load("res://fonts/Comfortaa-Bold.ttf"); headerFont.OutlineSize = 3; headerFont.OutlineColor = new Color("#000000"); headerFont.Size = 36; Label waveCompletedLabel = new Label(); waveCompletedLabel.Text = "Game over"; waveCompletedLabel.AddFontOverride("font", headerFont); textContainer.AddChild(waveCompletedLabel); DynamicFont waveClearedFont = new DynamicFont(); waveClearedFont.FontData = (DynamicFontData)ResourceLoader.Load("res://fonts/Comfortaa-Bold.ttf"); waveClearedFont.OutlineSize = 3; waveClearedFont.OutlineColor = new Color("#000000"); waveClearedFont.Size = 24; Label waveClearedLabel = new Label(); waveClearedLabel.Text = "Reached wave " + result.waveNum + " at -" + result.altitude + "M"; waveClearedLabel.AddFontOverride("font", waveClearedFont); textContainer.AddChild(waveClearedLabel); DynamicFont font = new DynamicFont(); font.FontData = (DynamicFontData)ResourceLoader.Load("res://fonts/Comfortaa-Bold.ttf"); font.OutlineSize = 2; font.OutlineColor = new Color("#000000"); font.Size = 16; Label enemyHeaderLabel = new Label(); enemyHeaderLabel.Text = "Enemies slain"; enemyHeaderLabel.AddFontOverride("font", font); textContainer.AddChild(enemyHeaderLabel); int totalXP = 0; foreach (KeyValuePair <string, EnemyResult> entry in result.getEnemies()) { Label label = new Label(); label.Text = " " + entry.Value.count + " x " + entry.Key; label.AddFontOverride("font", font); totalXP += entry.Value.xp * entry.Value.count; textContainer.AddChild(label); } Label totalTotalXpLabel = new Label(); totalTotalXpLabel.Text = "Total xp"; totalTotalXpLabel.AddFontOverride("font", font); textContainer.AddChild(totalTotalXpLabel); Label totalTotalTotalXpLabel = new Label(); totalTotalTotalXpLabel.Text = " " + result.getTotalXp(); totalTotalTotalXpLabel.AddFontOverride("font", font); textContainer.AddChild(totalTotalTotalXpLabel); }