protected override void FillWindow(Rect inRect) { Text.Font = GameFont.Small; GUI.BeginGroup(inRect); bool flag = false; if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { flag = true; Event.current.Use(); } string text = Widgets.TextField(new Rect(0f, 15f, inRect.width, 35f), this._name); if (text.Length < MaxNameLength) { this._name = text; } if (Widgets.TextButton(new Rect(15f, inRect.height - 35f - 15f, inRect.width - 15f - 15f, 35f), "OK") || flag) { Blueprint bp = BlueprintFiles.LoadFromFile(_fileName); bp.Name = _name; _assembly.AssemblyBillStack.AddBill(new AssemblyBill(_assembly.AssemblyBillStack, bp)); Close(); } GUI.EndGroup(); }
public static Blueprint LoadFromFile(string fileName) { Blueprint blueprint = new Blueprint(); try { Scribe.InitLoading(BlueprintFiles.FilePathForSavedBlueprint(fileName)); try { Scribe_Deep.LookDeep(ref blueprint, "Blueprint", null); } catch (Exception e) { Messages.Message("Error when loading blueprint", MessageSound.RejectInput); Log.Error(e.ToString()); } } catch (Exception e) { Log.Error(e.ToString()); } finally { Scribe.mode = LoadSaveMode.Inactive; } return(blueprint); }
protected override void DoMapEntryInteraction(string blueprintName) { FileName = blueprintName; BlueprintFiles.SaveToFile(ref _bp, FileName); Messages.Message("SavedAs".Translate(FileName), MessageSound.Standard); Close(); }
protected override void DoMapEntryInteraction(string fileName) { Blueprint bp = BlueprintFiles.LoadFromFile(fileName); Messages.Message("BlueprintLoaded".Translate(fileName), MessageSound.Standard); _oldPage.Blueprint = bp; Close(); }
public Dialog_SaveBlueprint(ref Blueprint bp) { FileName = string.Empty; this.interactButLabel = "BlueprintSave".Translate(); bottomAreaHeight = 85f; FileName = BlueprintFiles.UnusedDefaultName(); _bp = bp; }
public static string UnusedDefaultName() { string text = String.Empty; int num = 1; do { text = "Blueprint" + num.ToString(); num++; }while (BlueprintFiles.HaveBlueprintNamed(text)); return(text); }
public static void SaveToFile(ref Blueprint bp, string fileName) { try { Scribe.InitWriting(BlueprintFiles.FilePathForSavedBlueprint(fileName), "blueprint"); bp.BpName = fileName; Scribe_Deep.LookDeep(ref bp, "Blueprint"); } catch (Exception e) { Log.Error("Failed to save blueprint"); throw e; } finally { Scribe.FinalizeWriting(); Scribe.mode = LoadSaveMode.Inactive; } }
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(); }