public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; bool flag = false; if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { flag = true; Event.current.Use(); } GUI.SetNextControlName("RenameField"); string text = Widgets.TextField(new Rect(0f, 15f, inRect.width, 35f), curName); if (AcceptsInput && text.Length < MaxNameLength) { curName = text; } else if (!AcceptsInput) { ((TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl)).SelectAll(); } if (!focusedRenameField) { UI.FocusControl("RenameField", this); focusedRenameField = true; } if (!(Widgets.ButtonText(new Rect(15f, inRect.height - 35f - 15f, inRect.width - 15f - 15f, 35f), "OK") | flag)) { return; } AcceptanceReport acceptanceReport = NameIsValid(curName); if (!acceptanceReport.Accepted) { if (acceptanceReport.Reason.NullOrEmpty()) { Messages.Message("NameIsInvalid".Translate(), MessageTypeDefOf.RejectInput, historical: false); } else { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput, historical: false); } } else { SetName(curName); Find.WindowStack.TryRemove(this); } }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; bool flag = false; if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { flag = true; Event.current.Use(); } GUI.SetNextControlName("RenameField"); string text = Widgets.TextField(new Rect(0f, 15f, inRect.width, 35f), this.curName); if (text.Length < this.MaxNameLength) { this.curName = text; } if (!this.focusedRenameField) { UI.FocusControl("RenameField", this); this.focusedRenameField = true; } if (Widgets.ButtonText(new Rect(15f, inRect.height - 35f - 15f, inRect.width - 15f - 15f, 35f), "OK", true, false, true) || flag) { AcceptanceReport acceptanceReport = this.NameIsValid(this.curName); if (!acceptanceReport.Accepted) { if (acceptanceReport.Reason.NullOrEmpty()) { Messages.Message("NameIsInvalid".Translate(), MessageTypeDefOf.RejectInput, false); } else { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput, false); } } else { this.SetName(this.curName); Find.WindowStack.TryRemove(this, true); } } }