protected override void DoMapEntryInteraction(string MapName)
 {
     PrepareCarefully.Instance.Filename = MapName;
     PresetSaver.SaveToFile(PrepareCarefully.Instance, PrepareCarefully.Instance.Filename);
     Messages.Message("SavedAs".Translate(new object[] {
         PrepareCarefully.Instance.Filename
     }), MessageSound.Standard);
     Close(true);
 }
Example #2
0
 public void SavePreset(string name)
 {
     PrepareCarefully.Instance.Filename = name;
     if (string.IsNullOrEmpty(name))
     {
         Logger.Warning("Trying to save a preset without a name");
         return;
     }
     PresetSaver.SaveToFile(PrepareCarefully.Instance, PrepareCarefully.Instance.Filename);
     state.AddMessage("SavedAs".Translate(PrepareCarefully.Instance.Filename));
 }
        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();
        }