Esempio n. 1
0
        private void DoRow(Rect rect, Command command, int index)
        {
            Widgets.DrawHighlightIfMouseover(rect);
            GUI.BeginGroup(rect);
            Rect rect2 = new Rect(4f, (rect.height - 20f) / 2f, 20f, 20f);
            //Widgets.ThingIcon(rect2, thingDef);
            Rect rect3 = new Rect(rect2.xMax + 4f, 0f, rect.width - 60, 24f);

            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;

            //if (command.Enabled < 1 && thingDef.defName != "Item")
            //{
            //    GUI.color = Color.grey;
            //}

            Widgets.Label(rect3, command.Label.CapitalizeFirst());
            Rect rect4 = new Rect(rect3.width, rect3.y, 60, rect3.height);

            if (Widgets.ButtonText(rect4, "Edit"))
            {
                Window_CommandEditor window = new Window_CommandEditor(command);
                Find.WindowStack.TryRemove(window.GetType());
                Find.WindowStack.Add(window);
            }
            Text.Anchor   = TextAnchor.UpperLeft;
            Text.WordWrap = true;
            GUI.color     = Color.white;
            GUI.EndGroup();
        }
        void TrySubmitNewCommand()
        {
            if (defName == "")
            {
                NewOutputMessage("Name must be longer than 0 chars.");

                return;
            }

            string sanitizedDefName = string.Join("", defName.Split(' ')).ToLower();

            if (DefDatabase <Command> .AllDefs.Any(s => s.defName.ToLower() == sanitizedDefName))
            {
                NewOutputMessage("Command name is already taken");
                return;
            }

            Command newCommand = new Command();

            newCommand.defName         = sanitizedDefName.CapitalizeFirst();
            newCommand.isCustomMessage = true;
            newCommand.label           = sanitizedDefName;
            DefDatabase <Command> .Add(newCommand);

            if (ToolkitSettings.CustomCommandDefs == null)
            {
                ToolkitSettings.CustomCommandDefs = new List <string>();
            }

            ToolkitSettings.CustomCommandDefs.Add(newCommand.defName);

            Toolkit.Mod.WriteSettings();

            Window_CommandEditor window = new Window_CommandEditor(newCommand);

            Find.WindowStack.TryRemove(window.GetType());
            Find.WindowStack.Add(window);
            Close();
        }