예제 #1
0
        private static void setVar(string args)
        {
            if (args?.Length == 0)
            {
                Pigeon.Console.Log("select category:");
                var           allCategories = Const.Categories;
                StringBuilder stringBuilder = new StringBuilder();
                foreach (var category in allCategories)
                {
                    stringBuilder.Append("+");
                    stringBuilder.Append(category);
                    stringBuilder.Append(" ");
                }
                Pigeon.Console.Log(stringBuilder.ToString());
                return;
            }

            var splitArgs = args.Tokenize();

            switch (splitArgs.Length)
            {
            case 1:
                Pigeon.Console.Log("select variable:");
                var           vars          = Const.GetVarsForCategory(splitArgs[0]);
                StringBuilder stringBuilder = new StringBuilder();
                foreach (var variable in vars)
                {
                    stringBuilder.Append("+");
                    stringBuilder.Append(variable);
                    stringBuilder.Append(" ");
                }
                Pigeon.Console.Log(stringBuilder.ToString());
                break;

            case 2:
                Pigeon.Console.Log("current value: " + Const.GetFloat(splitArgs[0], splitArgs[1]));
                break;

            case 3:
                var before = Const.GetFloat(splitArgs[0], splitArgs[1]);
                Const.SetVar(splitArgs[0], splitArgs[1], splitArgs[2].ToFloat());
                var after = Const.GetFloat(splitArgs[0], splitArgs[1]);
                ConsoleUtilities.LogVariableChange(splitArgs[0] + "." + splitArgs[1], before, after);
                break;

            default:
                Pigeon.Console.Error("too many arguments provided.");
                break;
            }
        }