public void SelectCharacter(Character character) { var characterButton = frame.FindChild(character) as GUIButton; if (characterButton == null) { return; } characterButton.Selected = true; }
private void UpdateLocationTab(Location location) { topPanel.RemoveChild(topPanel.FindChild("locationtitle")); topPanel.UserData = location; var locationTitle = new GUITextBlock(new Rectangle(0, 0, 200, 25), "Location: " + location.Name, Color.Transparent, Color.White, Alignment.TopLeft, "", topPanel); locationTitle.UserData = "locationtitle"; locationTitle.Font = GUI.LargeFont; if (hireList == null) { hireList = new GUIListBox(new Rectangle(0, 40, 300, 0), "", Alignment.Right, bottomPanel[(int)PanelTab.Crew]); new GUITextBlock(new Rectangle(0, 0, 300, 20), "Hire:", "", Alignment.Right, Alignment.Left, bottomPanel[(int)PanelTab.Crew], false, GUI.LargeFont); hireList.OnSelected = SelectCharacter; } if (location.HireManager == null) { hireList.ClearChildren(); hireList.Enabled = false; new GUITextBlock(new Rectangle(0, 0, 0, 0), "No-one available for hire", Color.Transparent, Color.LightGray, Alignment.Center, Alignment.Center, "", hireList); return; } hireList.Enabled = true; hireList.ClearChildren(); foreach (CharacterInfo c in location.HireManager.availableCharacters) { var frame = c.CreateCharacterFrame(hireList, c.Name + " (" + c.Job.Name + ")", c); new GUITextBlock( new Rectangle(0, 0, 0, 25), c.Salary.ToString(), null, null, Alignment.TopRight, "", frame); } }
private bool CreateLoadScreen() { if (characterMode) { ToggleCharacterMode(); } if (wiringMode) { ToggleWiringMode(); } Submarine.RefreshSavedSubs(); int width = 300, height = 400; loadFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "", null); loadFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); var subList = new GUIListBox(new Rectangle(0, 0, 0, height - 50), Color.White, "", loadFrame); subList.OnSelected = (GUIComponent selected, object userData) => { var deleteBtn = loadFrame.FindChild("delete") as GUIButton; if (deleteBtn != null) { deleteBtn.Enabled = true; } return(true); }; foreach (Submarine sub in Submarine.SavedSubmarines) { GUITextBlock textBlock = new GUITextBlock( new Rectangle(0, 0, 0, 25), ToolBox.LimitString(sub.Name, GUI.Font, subList.Rect.Width - 80), "", Alignment.Left, Alignment.CenterY | Alignment.Left, subList); textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f); textBlock.UserData = sub; textBlock.ToolTip = sub.FilePath; if (sub.HasTag(SubmarineTag.Shuttle)) { var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), "Shuttle", "", Alignment.Left, Alignment.CenterY | Alignment.Right, textBlock, false, GUI.SmallFont); shuttleText.TextColor = textBlock.TextColor * 0.8f; shuttleText.ToolTip = textBlock.ToolTip; } } var deleteButton = new GUIButton(new Rectangle(0, 0, 70, 20), "Delete", Alignment.BottomLeft, "", loadFrame); deleteButton.Enabled = false; deleteButton.UserData = "delete"; deleteButton.OnClicked = (btn, userdata) => { if (subList.Selected != null) { TryDeleteSub(subList.Selected.UserData as Submarine); } deleteButton.Enabled = false; return(true); }; var loadButton = new GUIButton(new Rectangle(-90, 0, 80, 20), "Load", Alignment.Right | Alignment.Bottom, "", loadFrame); loadButton.OnClicked = LoadSub; var cancelButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Cancel", Alignment.Right | Alignment.Bottom, "", loadFrame); cancelButton.OnClicked = (GUIButton btn, object userdata) => { loadFrame = null; return(true); }; return(true); }