protected void DrawFooter(Rect inRect) { GUI.BeginGroup(inRect); bool flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return; float top = inRect.height - 52; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.SetNextControlName("ColonistNameField"); Rect rect = new Rect(5, top, 400, 35); string text = Widgets.TextField(rect, Filename); if (GenText.IsValidFilename(text)) { Filename = text; var matchingIndex = RandomSettings.pawnFilterList.FindIndex(i => i.name == Filename); if (matchingIndex >= 0) { selectedIndex = matchingIndex; } else { selectedIndex = -1; } } if (!this.focusedColonistNameArea) { GUI.FocusControl("ColonistNameField"); this.focusedColonistNameArea = true; } Rect butRect = new Rect(420, top, inRect.width - 400 - 20, 35); GUI.SetNextControlName("SaveButton"); string buttonName = selectedIndex >= 0 ? "RandomPlus.SaveLoadDialog.OverwriteButton".Translate() : "RandomPlus.SaveLoadDialog.SaveButton".Translate(); if (Widgets.ButtonText(butRect, buttonName, true, false, true) || flag) { if (Filename.Length == 0) { Messages.Message("NeedAName".Translate(), MessageTypeDefOf.RejectInput); } else if (selectedIndex >= 0) { RandomSettings.PawnFilter.name = text; SaveLoader.SaveOverwrite(selectedIndex, RandomSettings.PawnFilter); Close(true); } else { RandomSettings.PawnFilter.name = text; SaveLoader.Save(RandomSettings.PawnFilter); Close(true); } } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); }
protected virtual void DoTypeInField(Rect rect) { GUI.BeginGroup(rect); bool flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return; float y = rect.height - 52f; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.SetNextControlName("MapNameField"); string str = Widgets.TextField(new Rect(5f, y, 400f, 35f), typingName); if (GenText.IsValidFilename(str)) { typingName = str; } if (!focusedNameArea) { UI.FocusControl("MapNameField", this); focusedNameArea = true; } if (Widgets.ButtonText(new Rect(420f, y, rect.width - 400f - 20f, 35f), "SaveGameButton".Translate()) | flag) { if (typingName.NullOrEmpty()) { Messages.Message("NeedAName".Translate(), MessageTypeDefOf.RejectInput, historical: false); } else { DoFileInteraction(typingName); } } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); }
protected override void DoSpecialSaveLoadGUI(Rect inRect) { GUI.BeginGroup(inRect); bool flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return; float top = inRect.height - 52f; GenFont.SetFontSmall(); GUI.skin.textField.alignment = TextAnchor.MiddleLeft; GUI.skin.textField.contentOffset = new Vector2(12f, 0f); GUI.skin.settings.doubleClickSelectsWord = true; GUI.SetNextControlName("MapNameField"); Rect position = new Rect(5f, top, 400f, 35f); string text = GUI.TextField(position, Find.Map.info.fileName); if (GenText.IsValidFilename(text)) { Find.Map.info.fileName = text; } if (!this.focusedMapNameArea) { GUI.FocusControl("MapNameField"); this.focusedMapNameArea = true; } Rect butRect = new Rect(420f, top, inRect.width - 400f - 20f, 35f); if (Widgets.TextButton(butRect, "LoadGameButton".Translate()) || flag) { LoadColonists.LoadFromFile(Find.Map, Find.Map.info.fileName); Find.LayerStack.Remove(this); Find.LayerStack.Add(new ColonistCreationMenu(ColonistManager.Population[0])); } GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.EndGroup(); }
public static bool IsValidName(string s) { if (s.Length == 0) { return(false); } if (!GenText.IsValidFilename(s)) { return(false); } return(true); }
private bool IsValidName(string s) { if (SaveFileUtils.WorldWithNameExists(s)) { Messages.Message("FilUnderscore.PersistentRimWorlds.Save.WorldNameAlreadyUsed".Translate(), MessageTypeDefOf.RejectInput, false); return(false); } else if (!GenText.IsValidFilename(s) || GrammarResolver.ContainsSpecialChars(s)) { // TODO: Invalid chars message. return(false); } return(true); }
protected override void DoSpecialSaveLoadGUI(Rect inRect) { GUI.BeginGroup(inRect); bool flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return; float top = inRect.height - 52f; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.SetNextControlName("BlueprintNameField"); Rect rect = new Rect(5f, top, 400f, 35f); string text = Widgets.TextField(rect, FileName); if (GenText.IsValidFilename(text)) { FileName = text; } if (!this.focusedBlueprintNameField) { GUI.FocusControl("BlueprintNameField"); this.focusedBlueprintNameField = true; } Rect rect2 = new Rect(420f, top, inRect.width - 400f - 20f, 35f); if (Widgets.TextButton(rect2, "BlueprintSave".Translate(), true, false) || flag) { if (FileName.Length == 0) { Messages.Message("BlueprintNeedFileName".Translate(), MessageSound.RejectInput); } else { BlueprintFiles.SaveToFile(ref _bp, FileName); Messages.Message("SavedAs".Translate(new object[] { FileName }), MessageSound.Standard); base.Close(true); } } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); }
public static bool IsValidName(string s) { if (s.Length == 0) { return(false); } if (s.Length > 64) { return(false); } if (!GenText.IsValidFilename(s)) { return(false); } if (GrammarResolver.ContainsSpecialChars(s)) { return(false); } return(true); }
protected override void DoSpecialSaveLoadGUI(Rect inRect) { GUI.BeginGroup(inRect); bool flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return; float top = inRect.height - 52; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.SetNextControlName("PresetNameField"); Rect rect = new Rect(5, top, 400, 35); string text = Widgets.TextField(rect, PrepareCarefully.Instance.Filename); if (GenText.IsValidFilename(text)) { PrepareCarefully.Instance.Filename = text; } if (!this.focusedPresetNameArea) { GUI.FocusControl("PresetNameField"); this.focusedPresetNameArea = true; } Rect butRect = new Rect(420, top, inRect.width - 400 - 20, 35); if (Widgets.ButtonText(butRect, "EdB.SavePresetButton".Translate(), true, false, true) || flag) { if (PrepareCarefully.Instance.Filename.Length == 0) { Messages.Message("NeedAName".Translate(), MessageSound.RejectInput); } else { PresetSaver.SaveToFile(PrepareCarefully.Instance, PrepareCarefully.Instance.Filename); Messages.Message("SavedAs".Translate(new object[] { PrepareCarefully.Instance.Filename }), MessageSound.Standard); Close(true); } } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); }
private void DrawSaveSection(Rect rect) { var infoRect = new Rect(rect.ContractedBy(_margin)); infoRect.height -= 30f + _margin; var nameRect = new Rect(rect.xMin + _margin, infoRect.yMax, (rect.width - 3 * _margin) / 2, 30f); var buttonRect = new Rect(nameRect.xMax + _margin, infoRect.yMax, nameRect.width, 30f); var info = new StringBuilder(); info.AppendLine("FM.CurrentJobs".Translate()); foreach (Pair <string, int> jobCount in _jobCounts) { info.AppendLine(jobCount.First + ": " + jobCount.Second); } Widgets.Label(infoRect, info.ToString()); GUI.SetNextControlName("ManagerJobsNameField"); string name = Widgets.TextField(nameRect, _saveName); if (GenText.IsValidFilename(name)) { _saveName = name; } if (GenText.IsValidFilename(_saveName)) { if (Widgets.ButtonText(buttonRect, "FM.Export".Translate())) { TryExport(_saveName); } } else { GUI.color = Color.gray; Text.Anchor = TextAnchor.MiddleCenter; Widgets.DrawBox(buttonRect); Widgets.Label(buttonRect, "FM.InvalidName".Translate()); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } }
protected override void DoSpecialSaveLoadGUI(Rect inRect) { GUI.BeginGroup(inRect); bool flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return; float top = inRect.height - 52; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.SetNextControlName("ColonistNameField"); Rect rect = new Rect(5, top, 400, 35); string text = Widgets.TextField(rect, Filename); if (GenText.IsValidFilename(text)) { Filename = text; } if (!this.focusedColonistNameArea) { GUI.FocusControl("ColonistNameField"); this.focusedColonistNameArea = true; } Rect butRect = new Rect(420, top, inRect.width - 400 - 20, 35); if (Widgets.ButtonText(butRect, "EdB.PC.Dialog.PawnPreset.Button.Save".Translate(), true, false, true) || flag) { if (Filename.Length == 0) { Messages.Message("NeedAName".Translate(), MessageTypeDefOf.RejectInput); } else { if (action != null) { action(Filename); } Close(true); } } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); }
public static bool _IsValidName(string s) { bool valid = s.Length != 0 && GenText.IsValidFilename(s); if (Current.Game.Info.permadeathMode) { if (valid) { foreach (FileInfo current in GenFilePaths.AllSavedGameFiles) { if (current.Name.Substring(0, current.Name.LastIndexOf('.')).Equals(Current.Game.Info.permadeathModeUniqueName)) { current.MoveTo(current.Directory.FullName + "\\" + s + " (Permadeath)" + current.Extension); } } Current.Game.Info.permadeathModeUniqueName = s + " (Permadeath)"; } } return(valid); }
public static bool _IsValidName(string s) { bool valid = s.Length != 0 && GenText.IsValidFilename(str: s); if (!Current.Game.Info.permadeathMode) { return(valid); } if (!valid) { return(false); } foreach (FileInfo current in GenFilePaths.AllSavedGameFiles) { if (current.Name.Substring(startIndex: 0, length: current.Name.LastIndexOf(value: '.')).Equals(value: Current.Game.Info.permadeathModeUniqueName)) { current.MoveTo(destFileName: current.Directory?.FullName + "\\" + s + " (Permadeath)" + current.Extension); } } Current.Game.Info.permadeathModeUniqueName = s + " (Permadeath)"; return(true); }
public static bool IsValidName(string s) { return(s.Length != 0 && GenText.IsValidFilename(s)); }
public static bool IsValidName(string s) { return(s.Length != 0 && s.Length <= 64 && GenText.IsValidFilename(s) && !GrammarResolver.ContainsSpecialChars(s)); }
private bool IsValidRoomName(string s) { return(s.Length != 0 && GenText.IsValidFilename(s)); }