//---- CONTROLS ---- /* * - In the constructor you must set atleast a size or else crash (textures are loaded on the fly since they are generated) * - Call the function Initialize forms to modify and init your controls. * */ public Menu() { this.Location = new Vector2(100, 100); this.Size = new Vector2(200, 300); /* * - Init blank constructor of control. * - Init properties (size and control dependent properties are required like text for the label) * - LOCATIONS ARE RELATIVE TO THE PARENTS TOP LEFT CORNER * - Example, this menu class is located at 100, 100 and its top left corner will draw at 100,100 * - If a button is given a location of 20, 20 then on the global coord axis (relative to viewport), it will be located at 120, 120 NOT 20, 20 * - After initing properties, set its parent to "this" class. * - Add it to this controls control list. */ startButton = new Button(); startButton.Text = "NEW GAME"; startButton.Click += buttons_Click; startButton.Size = new Vector2(95, 20); startButton.Alignment = ControlAlignment.Center; startButton.Location = new Vector2(0, 20); //startButton.parent = this; Add(startButton); loadButton = new Button(); loadButton.Text = "LOAD GAME"; loadButton.Click += load_Click; loadButton.Size = new Vector2(95, 20); loadButton.Alignment = ControlAlignment.Center; loadButton.Location = new Vector2(0, 45); //loadButton.parent = this; Add(loadButton); //Quest builder questBuilderButton = new Button(); questBuilderButton.Size = new Vector2(95, 20); questBuilderButton.Alignment = ControlAlignment.Center; questBuilderButton.Location = new Vector2(0, 120); questBuilderButton.Text = "Quest Builder"; questBuilderButton.Click += OpenTool; //questBuilderButton.Location = new Vector2((this.Size.X / 2) - (questBuilderButton.Size.X / 2), (this.Size.Y / 2) + 120); //questBuilderButton.parent = this; Add(questBuilderButton); lblHeader = new Label(); lblHeader.Text = "MAIN MENU"; lblHeader.AutoResize = true; lblHeader.Location = new Vector2(0, -130); lblHeader.Alignment = ControlAlignment.Center; //lblHeader.parent = this; Add(lblHeader); }
public PauseMenu() { this.Location = new Vector2(100, 100); this.Size = new Vector2(200, 300); resumeButton = new Button(); resumeButton.Text = "Resume"; resumeButton.Click += resumeButton_Click; resumeButton.Size = new Vector2(110, 20); resumeButton.Location = new Vector2((this.Size.X / 2) - (resumeButton.Size.X / 2), (this.Size.Y / 2) + 20); //resumeButton.parent = this; Add(resumeButton); saveButton = new Button(); saveButton.Text = "Save"; saveButton.Click += saveButton_Click; saveButton.Size = new Vector2(110, 20); saveButton.Location = new Vector2((this.Size.X / 2) - (saveButton.Size.X / 2), (this.Size.Y / 2) + 50); //saveButton.parent = this; Add(saveButton); quitButton = new Button(); quitButton.Text = "Quit"; quitButton.Click += quitButton_Click; quitButton.Size = new Vector2(110, 20); quitButton.Location = new Vector2(this.Size.X / 2 - quitButton.Size.X / 2, this.Size.Y / 2 + 80); Add(quitButton); sqButton = new Button(); sqButton.Text = "Save and Quit"; sqButton.Click += saveButton_Click; sqButton.Click += quitButton_Click; sqButton.Size = new Vector2(110, 20); sqButton.Location = new Vector2(this.Size.X / 2 - quitButton.Size.X / 2, this.Size.Y / 2 + 110); Add(sqButton); lblHeader = new Label(); lblHeader.Text = "Paused!"; lblHeader.AutoResize = true; lblHeader.Location = new Vector2(0, -130); lblHeader.Alignment = ControlAlignment.Center; //lblHeader.parent = this; Add(lblHeader); }
public WeaponWheelUI() { this.Size = new Vector2(500, 200); this.Alignment = ControlAlignment.Center; currentActive = null; // Close button Button closeButton = new Button(); closeButton.Size = new Vector2(15, 15); closeButton.Location = new Vector2(5, 5); closeButton.Alignment = ControlAlignment.Right; closeButton.Text = "X"; closeButton.Click += closeButton_Click; //closeButton.parent = this; Add(closeButton); // Weapon Buttons container. weaponButtonsContainer = new Container(); weaponButtonsContainer.Size = new Vector2(450, 150); weaponButtonsContainer.Alignment = ControlAlignment.Center; //weaponButtonsContainer.parent = this; Add(weaponButtonsContainer); }
public DialogBox(Vector2 size, DialogBoxType type, string header, string description, Vector2? location = null) { this.Size = size; this.type = type; //eventsCompleted = false; if (location != null) this.Location = (Vector2)location; else this.Alignment = ControlAlignment.Center; // Header container Container headerContainer = new Container(); headerContainer.Size = new Vector2(this.Size.X, this.Size.Y * .13f); Add(headerContainer); // Header lbl Label headerLabel = new Label(); headerLabel.Alignment = ControlAlignment.Center; headerLabel.Text = header; headerContainer.Add(headerLabel); // Close dialog button. Button closeButton = new Button(); closeButton.Alignment = ControlAlignment.Right; closeButton.Size = new Vector2(this.Size.Y * .10f, this.Size.Y * .10f); closeButton.Click += closeButton_Click; closeButton.Text = "X"; headerContainer.Add(closeButton); // Fill (description) Container fillContainer = new Container(); fillContainer.Fill = new FillInfo(Color.DarkGray); fillContainer.Border = null; fillContainer.Alignment = ControlAlignment.Center; fillContainer.Size = new Vector2(this.Size.X * .90f, this.Size.Y * .72f); //fillContainer.Location = new Vector2(0, headerContainer.Size.Y); Add(fillContainer); // Fill description Label dialogDescriptionLabel = new Label(); dialogDescriptionLabel.WordWrap = true; dialogDescriptionLabel.Text = description; dialogDescriptionLabel.Alignment = ControlAlignment.Center; fillContainer.Add(dialogDescriptionLabel); // Button container Container buttonsContainer = new Container(); buttonsContainer.Size = new Vector2(this.Size.X, this.Size.Y * .15f); buttonsContainer.Location = new Vector2(0, headerContainer.Size.Y + fillContainer.Size.Y); Add(buttonsContainer); // Buttons Button firstActionButton; Button secondActionButton; switch(type) { case DialogBoxType.Ok: firstActionButton = new Button(); firstActionButton.Text = "OK"; firstActionButton.Alignment = ControlAlignment.Center; firstActionButton.Size = new Vector2(buttonsContainer.Size.X * .50f, buttonsContainer.Size.Y * .80f); firstActionButton.Click += firstActionButton_Click; buttonsContainer.Add(firstActionButton); break; case DialogBoxType.OkCancel: firstActionButton = new Button(); firstActionButton.Text = "OK"; firstActionButton.Alignment = ControlAlignment.Center; firstActionButton.Location = new Vector2(-buttonsContainer.Size.X * .25f, 0); firstActionButton.Size = new Vector2(buttonsContainer.Size.X * .25f, buttonsContainer.Size.Y * .80f); firstActionButton.Click += firstActionButton_Click; buttonsContainer.Add(firstActionButton); secondActionButton = new Button(); secondActionButton.Text = "Cancel"; secondActionButton.Alignment = ControlAlignment.Center; secondActionButton.Location = new Vector2(buttonsContainer.Size.X * .25f, 0); secondActionButton.Size = new Vector2(buttonsContainer.Size.X * .25f, buttonsContainer.Size.Y * .80f); secondActionButton.Click += secondActionButton_Click; buttonsContainer.Add(secondActionButton); break; case DialogBoxType.YesNo: firstActionButton = new Button(); firstActionButton.Text = "Yes"; firstActionButton.Alignment = ControlAlignment.Center; firstActionButton.Location = new Vector2(-buttonsContainer.Size.X * .25f, 0); firstActionButton.Size = new Vector2(buttonsContainer.Size.X * .25f, buttonsContainer.Size.Y * .80f); firstActionButton.Click += firstActionButton_Click; buttonsContainer.Add(firstActionButton); secondActionButton = new Button(); secondActionButton.Text = "No"; secondActionButton.Alignment = ControlAlignment.Center; secondActionButton.Location = new Vector2(buttonsContainer.Size.X * .25f, 0); secondActionButton.Size = new Vector2(buttonsContainer.Size.X * .25f, buttonsContainer.Size.Y * .80f); secondActionButton.Click += secondActionButton_Click; buttonsContainer.Add(secondActionButton); break; } }
/// <summary> /// Constructor: /// - Init size /// - Init location /// - InitializeForms function. /// </summary> public InventoryMenu() { isInventoryLoaded = false; this.Size = new Vector2(650, 450); this.Alignment = ControlAlignment.Center; // Header container Container headerContainer = new Container() { Alignment = ControlAlignment.Left, Size = new Vector2(this.Size.X, this.Size.Y / 16), parent = this }; Add(headerContainer); // Header label Label headerLabel = new Label() { Alignment = ControlAlignment.Center, Text = "INVENTORY", parent = headerContainer }; headerContainer.Add(headerLabel); // Exit inventory button Button xButton = new Button() { Size = new Vector2(15, 15), Location = new Vector2(5, (headerContainer.Size.Y / 2) - 7.5f), Alignment = ControlAlignment.Right, Text = "X", parent = headerContainer }; xButton.Click += closeButton_Click; headerContainer.Add(xButton); // main container Container multiMatContainer = new Container(); multiMatContainer.Size = new Vector2(this.Size.X * .90f, this.Size.Y * .80f); multiMatContainer.Alignment = ControlAlignment.Center; //multiMatContainer.parent = this; // Action button container. Container actionButtonsContainer = new Container() { Size = new Vector2(multiMatContainer.Size.X, this.Size.Y * .10f), Location = new Vector2(0, multiMatContainer.Size.Y / 2 + this.Size.Y * .05f), Alignment = ControlAlignment.Center, parent = this }; Add(actionButtonsContainer); // Close inventory button. Button closeButton = new Button(); closeButton.Size = new Vector2(110, 20); closeButton.Location = new Vector2(10, actionButtonsContainer.Size.Y / 2 - 10); closeButton.Alignment = ControlAlignment.Right; closeButton.Text = "Close Inventory"; closeButton.Click += closeButton_Click; //closeButton.parent = actionButtonsContainer; actionButtonsContainer.Add(closeButton); // Inventory matrix. inventoryMatrix = new DragableMatrixV2(new Vector2(multiMatContainer.Size.X * .80f, multiMatContainer.Size.Y * .75f), 12); inventoryMatrix.Location = new Vector2(10, multiMatContainer.Size.Y / 2 - inventoryMatrix.Size.Y / 2); inventoryMatrix.Alignment = ControlAlignment.Right; //inventoryMatrix.parent = multiMatContainer; multiMatContainer.Add(inventoryMatrix); // Current wep matrix. currentWeaponMatrix = new DragableMatrixV2(new Vector2(inventoryMatrix.ContainerSideLength, inventoryMatrix.ContainerSideLength), 1); currentWeaponMatrix.Location = new Vector2(10, multiMatContainer.Size.Y / 2 - inventoryMatrix.Size.Y / 2); currentWeaponMatrix.Alignment = ControlAlignment.Left; //currentWeaponMatrix.parent = multiMatContainer; multiMatContainer.Add(currentWeaponMatrix); // Add down here for overlap. Add(multiMatContainer); }
/// <summary> /// Load the inventory you want to view. /// </summary> /// <param name="inventory"></param> public void Load(Inventory inventory) { /* currentInventory = inventory; foreach (Item.Item i in inventory.EntityInventory.Where(i => !(i.Equals(inventory.EntityInventory[inventory.ActiveWeapon])))) matrix.AddToMatrix(new DragableControl(i)); if (inventory.ActiveWeapon != -1) matrix.AddOutsideMatrix(new DragableControl(inventory.EntityInventory[inventory.ActiveWeapon]), new Vector2(-90, -10)); isInventoryLoaded = true; * */ currentInventory = inventory; int count = 0; foreach(int i in inventory.Holster) { Weapon weapon = inventory.EntityInventory[i] as Weapon; Button weaponInfoRoot = new Button(); weaponInfoRoot.Location = new Vector2((weaponButtonsContainer.Size.X / inventory.Holster.Length) * count, 0); weaponInfoRoot.Size = new Vector2(weaponButtonsContainer.Size.X / inventory.Holster.Length, weaponButtonsContainer.Size.Y); weaponInfoRoot.Text = weapon.name; weaponInfoRoot.Click += weaponInfoRoot_Click; if(i == inventory.ActiveWeapon) { weaponInfoRoot.DefaultBorder = new BorderInfo(weaponInfoRoot.DefaultBorder.width, Color.Purple); weaponInfoRoot.DefaultFill = new FillInfo(Color.LightGray); weaponInfoRoot.HoverFill = new FillInfo(Color.LightGray); currentActive = weaponInfoRoot; } //weaponInfoRoot.parent = weaponButtonsContainer; weaponButtonsContainer.Add(weaponInfoRoot); // image // name // stats count++; } isInventoryLoaded = true; }
void weaponInfoRoot_Click(object sender, EventArgs e) { // set the weapon on this button to current... Button clicked = sender as Button; if (clicked != null) { string clickedWeaponName = clicked.Text; // find weapon in inventory and set it, update UI foreach (int i in currentInventory.Holster) { Weapon weapon = currentInventory.EntityInventory[i] as Weapon; if(weapon.name == clickedWeaponName) { currentInventory.ActiveWeapon = i; currentActive.DefaultFill = new FillInfo(Color.Gray); currentActive.DefaultBorder = new BorderInfo(clicked.Border.Value.width, Color.Black); currentActive.HoverFill = new FillInfo(Color.Gray); clicked.DefaultBorder = new BorderInfo(clicked.DefaultBorder.width, Color.Purple); clicked.DefaultFill = new FillInfo(Color.LightGray); clicked.HoverFill = new FillInfo(Color.LightGray); currentActive = clicked; return; } } } }
public QuestLogUI() { // Quest pages questInfoBars = new List<QuestInfoBarUI>(); //currentIndex = 0; // this info... this.Size = new Vector2(600, 400); this.Alignment = ControlAlignment.Center; // Header container Container headerContainer = new Container(); headerContainer.Size = new Vector2(this.Size.X, 20); headerContainer.Alignment = ControlAlignment.Left; //headerContainer.parent = this; Add(headerContainer); // Exit quest log Button closeButton = new Button(); closeButton.Size = new Vector2(15, 15); closeButton.Location = new Vector2(5, (headerContainer.Size.Y / 2) - 7.5f); closeButton.Alignment = ControlAlignment.Right; closeButton.Text = "X"; closeButton.Click += closeButton_Click; //closeButton.parent = headerContainer; headerContainer.Add(closeButton); // Header questLogHeaderLabel = new Label(); questLogHeaderLabel.Alignment = ControlAlignment.Center; questLogHeaderLabel.Text = "QUEST LOG"; questLogHeaderLabel.Color = Color.Black; //questLogHeaderLabel.parent = headerContainer; headerContainer.Add(questLogHeaderLabel); // Quest bar container questBarsContainer = new Container(); questBarsContainer.Alignment = ControlAlignment.Left; questBarsContainer.Size = new Vector2(this.Size.X / 2, (this.Size.Y - headerContainer.Size.Y) * .85f); questBarsContainer.Location = new Vector2(0, headerContainer.Size.Y); //questBarsContainer.parent = this; Add(questBarsContainer); // Forward backward button container // Quest UI to display more info on the quest. questUI = new QuestUI(new Vector2(this.Size.X / 2, (this.Size.Y - headerContainer.Size.Y) * .85f)); //questUI.Size = new Vector2(this.Size.X / 2, (this.Size.Y - headerContainer.Size.Y) * .80f); questUI.Alignment = ControlAlignment.Right; questUI.Location = new Vector2(0, headerContainer.Size.Y); //questUI.parent = this; Add(questUI); // quest buttons container. questActionsContainer = new Container(); questActionsContainer.Alignment = ControlAlignment.Right; questActionsContainer.Size = new Vector2(this.Size.X / 2, (this.Size.Y - headerContainer.Size.Y) * .15f); questActionsContainer.Location = new Vector2(0, questUI.Size.Y + headerContainer.Size.Y); //questActionsContainer.parent = this; Add(questActionsContainer); // the buttons... startQuestButton = new Button(); startQuestButton.Alignment = ControlAlignment.Center; startQuestButton.Size = new Vector2(100, 50); startQuestButton.Location = new Vector2(-60, 0); startQuestButton.IsActive = false; startQuestButton.Text = "Start Quest"; startQuestButton.Click += startQuestButton_Click; startQuestButton.Click += closeButton_Click; //startQuestButton.parent = questActionsContainer; questActionsContainer.Add(startQuestButton); stopQuestButton = new Button(); stopQuestButton.Alignment = ControlAlignment.Center; stopQuestButton.Size = new Vector2(100, 50); stopQuestButton.Location = new Vector2(60, 0); stopQuestButton.IsActive = false; stopQuestButton.Text = "Stop Quest"; stopQuestButton.Click += stopQuestButton_Click; //stopQuestButton.parent = questActionsContainer; questActionsContainer.Add(stopQuestButton); // page button container Container pageButtonContainer = new Container(); pageButtonContainer.Alignment = ControlAlignment.Left; pageButtonContainer.Size = new Vector2(this.Size.X / 2, (this.Size.Y - headerContainer.Size.Y) * .15f); pageButtonContainer.Location = new Vector2(0, questUI.Size.Y + headerContainer.Size.Y); //pageButtonContainer.parent = this; Add(pageButtonContainer); // forward button pageForwardButton = new Button(); pageForwardButton.Alignment = ControlAlignment.Center; pageForwardButton.Size = new Vector2(100, 50); pageForwardButton.Location = new Vector2(70, 0); pageForwardButton.IsActive = false; pageForwardButton.Text = "Forward >"; pageForwardButton.Click += pageForwardButton_Click; //pageForwardButton.parent = pageButtonContainer; pageButtonContainer.Add(pageForwardButton); // back button pageBackwardButton = new Button(); pageBackwardButton.Alignment = ControlAlignment.Center; pageBackwardButton.Size = new Vector2(100, 50); pageBackwardButton.Location = new Vector2(-70, 0); pageBackwardButton.IsActive = false; pageBackwardButton.Text = "< Backward"; pageBackwardButton.Click += pageBackwardButton_Click; //pageBackwardButton.parent = pageButtonContainer; pageButtonContainer.Add(pageBackwardButton); currentPageLabel = new Label(); currentPageLabel.Alignment = ControlAlignment.Center; currentPageLabel.Text = "{0} / {1}"; pageButtonContainer.Add(currentPageLabel); }