private void DrawHeader(Rect canvas) { GUI.BeginGroup(canvas); var searchRect = new Rect(canvas.x, canvas.y, Mathf.FloorToInt(canvas.width * 0.3f), Text.LineHeight); var searchLabel = new Rect(searchRect.x, searchRect.y, _searchTextSize.x, searchRect.height); var searchField = new Rect(searchLabel.x + searchLabel.width + 5f, searchRect.y, searchRect.width - searchLabel.width - 5f, searchRect.height); UiHelper.Label(searchLabel, _searchText); if (UiHelper.TextField(searchField, _query, out string input)) { _query = input; NotifySearchRequested(); } if (_query.Length > 0 && UiHelper.ClearButton(searchField)) { _query = ""; NotifySearchRequested(); } float resetWidth = Text.CalcSize(_resetText).x + 16f; var resetRect = new Rect(canvas.width - resetWidth, canvas.y, resetWidth, Text.LineHeight); DrawGlobalResetButton(resetRect); GUI.EndGroup(); }
private void DrawHeader(Rect canvas) { GUI.BeginGroup(canvas); (Rect searchLabel, Rect searchField) = new Rect(canvas.x, canvas.y, canvas.width * 0.19f, Text.LineHeight).Split(0.3f); Widgets.Label(searchLabel, _searchText); if (UiHelper.TextField(searchField, _query, out string input)) { _query = input; NotifySearchRequested(); } if (_query.Length > 0 && UiHelper.ClearButton(searchField)) { _query = ""; NotifySearchRequested(); } float resetBtnWidth = _resetAllTextSize.x + 16f; var gResetRect = new Rect(canvas.x + canvas.width - resetBtnWidth, canvas.y, resetBtnWidth, Text.LineHeight); var gAddPriceRect = new Rect(canvas.width - 5f - 200f - resetBtnWidth - 10f, 0f, 200f, Text.LineHeight); var gRemovePriceRect = new Rect(canvas.width - 5f - 200f - resetBtnWidth - 10f, Text.LineHeight, 200f, Text.LineHeight); DrawGlobalAddPriceField(gAddPriceRect); DrawGlobalRemovePriceField(gRemovePriceRect); DrawGlobalResetButton(gResetRect); GUI.EndGroup(); }
private void DrawContent(Rect contentRect) { var listing = new Listing_Standard(GameFont.Small); listing.Begin(contentRect); Rect usernameRect = listing.GetRect(Text.LineHeight); (Rect usernameLabel, Rect usernameFieldHalf) = usernameRect.Split(_assignedToTextWidth / usernameRect.width); UiHelper.Label(usernameLabel, _assignedToText); _usernameFieldPosition = new Rect(usernameFieldHalf.x, usernameFieldHalf.y, usernameFieldHalf.width - _applyTextWidth - 5f, usernameFieldHalf.height); _username = Widgets.TextField(_usernameFieldPosition, _username).ToToolkit(); if (_username.Length > 0 && UiHelper.ClearButton(_usernameFieldPosition)) { _username = ""; _userFromButton = false; _viewer = null; _lastSeenText = null; } if (_viewer != null && !_viewer.username.EqualsIgnoreCase(_username)) { _userFromButton = false; _viewer = null; _lastSeenText = null; } var usernameApply = new Rect(_usernameFieldPosition.x + _usernameFieldPosition.width + 5f, _usernameFieldPosition.y, _applyTextWidth, Text.LineHeight); if (Widgets.ButtonText(usernameApply, _applyText)) { AssignColonist(); } if (!_userFromButton || _viewer == null) { listing.End(); return; } listing.GapLine(36f); Rect seenAtLine = listing.GetRect(Text.LineHeight * 2f); seenAtLine = seenAtLine.Trim(Direction8Way.East, seenAtLine.width - 5f - _notifyTextWidth); var notifyButton = new Rect(seenAtLine.x + seenAtLine.width + 5f, seenAtLine.y, _notifyTextWidth, Mathf.FloorToInt(seenAtLine.height / 2f)); UiHelper.Label(seenAtLine, _lastSeenText); if (Widgets.ButtonText(notifyButton, _notifyText)) { MessageHelper.ReplyToUser(_viewer.username, _viewerDrawnText); } listing.End(); }