void Load(string DefFile) { string[] Lines = File.ReadAllLines(DefFile); RelativeSpawns = new List <Vector3>(); foreach (var L in Lines) { string[] Args = L.Trim().Split(' '); switch (Args[0].ToLower()) { case "model": WorldModel = Importers.Load <Model>(Args[1]); break; case "spawn": RelativeSpawns.Add(new Vector3(Args[1].ParseToFloat(), Args[2].ParseToFloat(), Args[3].ParseToFloat())); break; default: GConsole.WriteLine("Invalid world argument: {0}", L); break; } } if (WorldModel == null) { throw new Exception("World model was not loaded"); } }
internal void ParseLine(string line) { ParsingResult result = new ParsingResult(); foreach (var command in KnownCommands) { result = command.Parse(line); if (result.Type == ParsingResultType.Success || result.Type == ParsingResultType.SuccessReachedEnd || result.Type == ParsingResultType.ParsingFailure || result.Type == ParsingResultType.MissingParam) { break; } } if (result.Type == ParsingResultType.WrongCommand) { string command = line; var parsingResult = ParsingHelpers.TryAnyCommandBody(line); if (parsingResult.WasSuccessful && parsingResult.Value.Length > 0) { command = parsingResult.Value; } GConsole.WriteLine(GConsole.ColorifyText(1, String.Format(Resources.text.UnknownCommand, command))); } }
private void LoadSuggestions() { List <GConsoleItem> sugitems; //Not enough characters typed yet, no suggestions to be shown! if (minCharBeforeSuggestions != 0 && input.text.Length < minCharBeforeSuggestions) { sugitems = new List <GConsoleItem>(); } else { sugitems = GConsole.GetSuggestionItems(input.text); //Ask GConsole for suggestions. } //Display suggestions (and hide unused suggestion boxes by passing null). for (int i = 0; i < suggestions.Length; i++) { if (i < sugitems.Count) { suggestions[i].ShowSuggestion(sugitems[i]); } else { suggestions[i].ShowSuggestion(null); } } }
static int AddCommand(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 4); string arg0 = LuaScriptMgr.GetLuaString(L, 1); string arg1 = LuaScriptMgr.GetLuaString(L, 2); Func <string, string> arg2 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg2 = (Func <string, string>)LuaScriptMgr.GetNetObject(L, 3, typeof(Func <string, string>)); } else { LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 3); arg2 = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); object[] objs = func.PopValues(top); func.EndPCall(top); return((string)objs[0]); }; } string arg3 = LuaScriptMgr.GetLuaString(L, 4); bool o = GConsole.AddCommand(arg0, arg1, arg2, arg3); LuaScriptMgr.Push(L, o); return(1); }
Material ConvertMaterial(AssimpMaterial M) { Material Mat = new Material(); if (M.HasColorDiffuse) { Mat.DiffuseColor = new Vector4(M.ColorDiffuse.R, M.ColorDiffuse.G, M.ColorDiffuse.B, M.ColorDiffuse.A); } if (M.HasTextureDiffuse) { string TexName = ("content/textures/" + M.TextureDiffuse.FilePath).NormalizeFilePath(); Mat.Name = TexName; if (File.Exists(TexName)) { Mat.Diffuse = Importers.Load <Texture>(TexName); Mat.Diffuse.SetWrap(OpenGL.Gl.REPEAT); Mat.Diffuse.SetFilter(OpenGL.Gl.LINEAR_MIPMAP_LINEAR, OpenGL.Gl.NEAREST); Mat.Diffuse.GenerateMipmap(); } else { GConsole.WriteLine("Unknown texture: {0}", TexName); } } return(Mat); }
/// <summary> /// Parse a simple command with one parameter and no flags. /// </summary> /// <param name="line">Input line.</param> /// <param name="command">Command to parse.</param> /// <param name="parameter">Out paremeter parsed from input.</param> /// <returns>Result of the parsing. /// Possible result types are Success, WrongCommand, MissingParam and ParsingFailure. /// See ParsingResult.</returns> public static ParsingResult ParseSimpleCommandWithOneParameter(string line, ICommand command, out string parameter) { parameter = ""; string remainder = ""; var result = ParseSimpleCommandBody(line, command, out remainder); if (result.Type == ParsingResultType.SuccessReachedEnd) { result.Type = ParsingResultType.MissingParam; GConsole.WriteLine(-1.0f, Resources.text.MissingParam, command.Name()); return(result); } if (result.Type != ParsingResultType.Success) { return(result); } var paramResult = TryTextParam(remainder); if (paramResult.WasSuccessful == false || paramResult.Remainder.AtEnd == false) { GConsole.WriteLine(Resources.text.FailureParsingRequiredParam, command.Name()); result.Type = ParsingResultType.ParsingFailure; return(result); } parameter = paramResult.Value; result.Type = ParsingResultType.Success; return(result); }
void Start() { for (int i = 0; i < phoneyCommands.Length; i++) //Add phoney commands to GConsole. { GConsole.AddCommand(phoneyCommands[i], phoneyDescriptions[i], PhoneyCommand); } }
private static void InitPatches() { // Don't need to try running the loop if the list is null or there aren't any files in it. if (options.PatchFiles == null || options.PatchFiles.Count < 1) { return; } for (int i = 0; i < options.PatchFiles.Count; i++) { ILumpContainer container = null; string file = options.PatchFiles [i]; if (File.Exists(file)) { if (ZipLumpContainer.CheckContainer(file)) { container = new ZipLumpContainer(file); } } if (container != null) { GConsole.WriteLine(" Adding \"{0}\", {1} lumps", file, container.Count); LumpManager.AddContainer(container); } else { throw new FatalError(string.Format("Could not identify patch {0}. Stopping execution.", file)); } } }
static int print(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 1); string o = GConsole.print(arg0); LuaScriptMgr.Push(L, o); return(1); }
static int GetSuggestionItems(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 1); List <GConsoleItem> o = GConsole.GetSuggestionItems(arg0); LuaScriptMgr.PushObject(L, o); return(1); }
static int RemoveCommand(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); GConsole obj = (GConsole)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GConsole"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); bool o = obj.RemoveCommand(arg0); LuaScriptMgr.Push(L, o); return(1); }
public void run() { One2OneChannel console = Channel.one2one(); Chef chef = new Chef(supply: supply, toConsole: console.Out()); GConsole chefConsole = new GConsole(toConsole: console.In(), frameLabel: "Chef"); IamCSProcess[] network = { chef, chefConsole }; new CSPParallel(network).run(); }
public void run() { One2OneChannel console = Channel.one2one(); QueuingCanteen servery = new QueuingCanteen(service: service, deliver: deliver, supply: supply, toConsole: console.Out()); GConsole serveryConsole = new GConsole(toConsole: console.In(), frameLabel: "Queuing Servery"); IamCSProcess[] network = { servery, serveryConsole }; new CSPParallel(network).run(); }
public void run() { One2OneChannel console = Channel.one2one(); PhilosopherBehaviour philosopher = new PhilosopherBehaviour(service: service, deliver: deliver, toConsole: console.Out(), id: philosopherId); GConsole philosopherConsole = new GConsole(toConsole: console.In(), frameLabel: "Philosopher " + philosopherId); IamCSProcess[] network = { philosopher, philosopherConsole }; new CSPParallel(network).run(); }
public void PrintManPage() { GConsole.WriteLine(-1.0f, "{0} {1}", GConsole.ColorifyText(1, Resources.text.ManHeaderIntro), GConsole.ColorifyText(1, Name())); GConsole.WriteLine(-1.0f, GConsole.ColorifyText(1, Resources.text.ManHeaderName)); GConsole.WriteLine(-1.0f, "\t{0}", GConsole.ColorifyText(0, Name())); GConsole.WriteLine(-1.0f, GConsole.ColorifyText(1, Resources.text.ManHeaderSynopsis)); GConsole.WriteLine(-1.0f, "\t{0}", GConsole.ColorifyText(0, Name())); GConsole.WriteLine(-1.0f, GConsole.ColorifyText(1, Resources.text.ManHeaderDescription)); GConsole.WriteLine(-1.0f, GConsole.ColorifyText(1, Resources.text.ListMan)); GConsole.WriteLine(-1.0f, " "); }
public override void Load() { AddButton("Exit", () => Engine.CreateYesNoPrompt("Exit Program?", () => Environment.Exit(0)).Center((Engine.Window.WindowSize / 2))); AddButton("Stop", RealSenseCamera.Stop); AddButton("Start", RealSenseCamera.Start); Engine.Camera3D.SetPerspective(Engine.Window.WindowSize, (90.0f).ToRad(), NearClip, 100); LegShader = new ShaderProgram(new ShaderStage(ShaderType.VertexShader, "content/shaders/leg.vert"), new ShaderStage(ShaderType.FragmentShader, "content/shaders/leg.frag")); VertsMesh = new Mesh3D(); VertsMesh.PrimitiveType = PrimitiveType.Points; VertsMesh.SetVertices(new Vertex3()); // Variables Sparse = ConVar.Register(nameof(Sparse).ToLower(), 0); // 3 LegLength = ConVar.Register(nameof(LegLength).ToLower(), 100.0f); // 1.0f LegWidth = ConVar.Register(nameof(LegWidth).ToLower(), 100.0f); // 0.5f PickDistance = ConVar.Register(nameof(PickDistance).ToLower(), 1.0f); PickSize = ConVar.Register(nameof(PickSize).ToLower(), 0.01f); // 0.025f PickSampleNum = ConVar.Register(nameof(PickSampleNum).ToLower(), 10); // 10 ConCmd.Register("list", (Argv) => { GConsole.WriteLine(Sparse); GConsole.WriteLine(LegLength); GConsole.WriteLine(LegWidth); GConsole.WriteLine(PickDistance); GConsole.WriteLine(PickSize); GConsole.WriteLine(PickSampleNum); }); Thread PollingThread = new Thread(() => { while (true) { RealSenseCamera.PollForFrames(OnPointCloud: OnPointCloud); Thread.Sleep(0); } }); PollingThread.IsBackground = true; PollingThread.Start(); Engine.Camera3D.Position = new Vector3(0, 0, -1); Engine.Camera3D.LookAt(Vector3.Zero); Engine.Camera3D.Position = new Vector3(0, 0, -NearClip); }
/// <summary> /// Parse a simple command with flags and no paramters. /// </summary> /// <param name="line">Input line.</param> /// <param name="command">Command to parse.</param> /// <param name="flags">Out Flags containted in the input line. See BoolFlag.</param> /// <returns>Result of the parsing. /// Possible result types are Success, WrongCommand and ParsingFailure. /// See ParsingResult.</returns> public static ParsingResult ParseSimpleCommandWithFlags(string line, ICommand command, out IEnumerable <BoolFlag> flags) { string remainder = ""; var resultFlags = new List <BoolFlag>(); flags = resultFlags; var result = ParseSimpleCommandBody(line, command, out remainder); // Flags are optional if (result.Type == ParsingResultType.SuccessReachedEnd) { result.Type = ParsingResultType.Success; return(result); } var flagsResult = ParsingHelpers.TryFlags(remainder); if (flagsResult.WasSuccessful == false || flagsResult.Remainder.AtEnd == false) { GConsole.WriteLine(Resources.text.FailureParsingFlags, remainder, command.Name()); result.Type = ParsingResultType.ParsingFailure; return(result); } var parsedFlags = flagsResult.Value.ToList(); foreach (var flag in command.GetFlags()) { if (flag.FindInList(ref parsedFlags)) { resultFlags.Add(flag); } } flags = resultFlags; if (parsedFlags.Count > 0) { GConsole.WriteLine(Resources.text.UnknownFlags, String.Join(",", parsedFlags), command.Name()); result.Type = ParsingResultType.ParsingFailure; return(result); } result.Type = ParsingResultType.Success; return(result); }
public void OnInput() { string cmd = input.text; if (string.IsNullOrEmpty(cmd)) { return; } GConsole.Eval(cmd); //Send command to the console input.text = string.Empty; // input.Select(); StartCoroutine(delay()); }
public ParsingResult Parse(string line) { string parameter = ""; var result = ParsingHelpers.ParseSimpleCommandWithOneParameter(line, this, out parameter); if (result.Type == ParsingResultType.Success) { if (GConsole.Instance.Commands.FindMan(parameter) == false) { if (GConsole.Instance.Keywords.FindMan(parameter) == false) { GConsole.WriteLine(GConsole.ColorifyText(1, String.Format(Resources.text.UnknownCommandOrKeywordForMan, parameter))); } } } return(result); }
public override void Load() { FontTest = new MSDFFont("content/fonts/Hack.ttf"); CrosshairTex = Importers.Load <Texture>("content/textures/crosshair_default.png"); /*MSDF = new ShaderProgram(new ShaderStage(ShaderType.VertexShader, "content/shaders/default.vert"), * new ShaderStage(ShaderType.FragmentShader, "content/shaders/msdf.frag"));*/ Ply = new Player(); Engine.SpawnEntity(Ply); GameWorld = new World("content/maps/sandbox.txt"); Ply.Position = GameWorld.RelativeSpawns.FirstOrDefault(); Engine.SpawnEntity(GameWorld); GConsole.RegisterCommand("getcam", () => { GConsole.WriteLine("Pos: " + Ply.Position.ToString()); }); }
public void PrintManPage() { GConsole.WriteLine(-1.0f, "{0} {1}", GConsole.ColorifyText(1, Resources.text.ManHeaderIntro), GConsole.ColorifyText(0, Name())); GConsole.WriteLine(-1.0f, GConsole.ColorifyText(1, Resources.text.ManHeaderName)); GConsole.WriteLine(-1.0f, "\t{0}", GConsole.ColorifyText(1, Name())); GConsole.WriteLine(-1.0f, GConsole.ColorifyText(1, Resources.text.ManHeaderSynopsis)); GConsole.WriteLine(-1.0f, "\t{0} {1}", GConsole.ColorifyText(0, Name()), GConsole.ColorifyText(ConsoleColor.Black, GConsole.Settings.Higlights[0].Foreground, "command")); GConsole.WriteLine(-1.0f, GConsole.ColorifyText(1, Resources.text.ManHeaderDescription)); foreach (var line in Resources.text.ManMan.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) { GConsole.WriteLine(-1.0f, line); } GConsole.WriteLine(-1.0f, " "); }
public void OnInput() { string cmd = input.text; if (string.IsNullOrEmpty(cmd)) { return; } GConsole.Eval(cmd); //Send command to the console if (clearOnSubmit) { input.text = string.Empty; } if (reselectOnSubmit) { input.Select(); input.ActivateInputField(); } }
static int set_newlineAfterCommandOutput(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GConsole obj = (GConsole)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name newlineAfterCommandOutput"); } else { LuaDLL.luaL_error(L, "attempt to index newlineAfterCommandOutput on a nil value"); } } obj.newlineAfterCommandOutput = LuaScriptMgr.GetBoolean(L, 3); return(0); }
static int get_outputStackTrace(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GConsole obj = (GConsole)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name outputStackTrace"); } else { LuaDLL.luaL_error(L, "attempt to index outputStackTrace on a nil value"); } } LuaScriptMgr.Push(L, obj.outputStackTrace); return(1); }
static int set_outputUnityLog(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GConsole obj = (GConsole)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name outputUnityLog"); } else { LuaDLL.luaL_error(L, "attempt to index outputUnityLog on a nil value"); } } obj.outputUnityLog = LuaScriptMgr.GetBoolean(L, 3); return(0); }
public ParsingResult Parse(string line) { var result = ParsingHelpers.ParseSimpleCommand(line, this); if (result.Type == ParsingResultType.Success) { GConsole.WriteLine(-1.0f, "{0} {1} {2}", GConsole.ColorifyText(1, "Currently available commands follow. You can use"), GConsole.ColorifyText(0, Resources.text.ManCommandName), GConsole.ColorifyText(1, "to learn more about them.")); foreach (var command in GConsole.Instance.Commands) { if (command.Available() == true) { GConsole.WriteLine(-1.0f, "\t{0}", GConsole.ColorifyText(0, command.Name())); } } } return(result); }
/*void UpdateCamera(Camera C) { * UniformMatrix4f("View", C.View); * UniformMatrix4f("Project", C.Projection); * }*/ public override void Bind() { if (Camera.ActiveCamera == null) { throw new Exception("No active camera"); } bool Dirty = false; bool Errors = false; foreach (var SS in ShaderStages) { if (SS.WatchHandle) { SS.WatchHandle.Reset(); Dirty = true; if (!SS.Compile(out string Err)) { Errors = true; GConsole.WriteLine(Err); } } } if (Dirty && !Errors) { Link(); } SetModelMatrix(Matrix4.Identity); Uniform2f("Viewport", Camera.ActiveCamera.ViewportSize); UniformMatrix4f("View", Camera.ActiveCamera.View); UniformMatrix4f("Project", Camera.ActiveCamera.Projection); Gl.UseProgram(ID); }
/// <summary> /// Parse a command with parameters and flags. /// </summary> /// <param name="line">Input line.</param> /// <param name="command">Command to parse.</param> /// <param name="hasRequiredParams">Whether the command has at least on required parameters.</param> /// <returns>Result of the parsing. /// Possible result types are Success, WrongCommand, MissingParam and ParsingFailure. /// It splits all the parameters by space into ParsingResult.Parameters. /// See ParsingResult.</returns> public static ParsingResult ParseCommand(string line, ICommand command, bool hasRequiredParams) { string remainder = ""; var result = ParseSimpleCommandBody(line, command, out remainder); if (result.Type == ParsingResultType.SuccessReachedEnd) { if (hasRequiredParams == true) { result.Type = ParsingResultType.MissingParam; GConsole.WriteLine(-1.0f, Resources.text.MissingParam, command.Name()); return(result); } else { result.Type = ParsingResultType.Success; return(result); } } if (result.Type != ParsingResultType.Success) { return(result); } var paramResult = TryTextParam(remainder); if (paramResult.WasSuccessful == false && hasRequiredParams == true) { GConsole.WriteLine(Resources.text.FailureParsingRequiredParam, command.Name()); result.Type = ParsingResultType.ParsingFailure; return(result); } string parameters = paramResult.Value.TrimEnd(); result.Parameters = parameters.Split(new char[] { ' ', '\t' }).ToList(); if (paramResult.Remainder.AtEnd == true) { result.Type = ParsingResultType.Success; return(result); } remainder = remainder.Substring(paramResult.Remainder.Position - 1).TrimEnd(); var flagsResult = ParsingHelpers.TryFlags(remainder); if (flagsResult.WasSuccessful == false || flagsResult.Remainder.AtEnd == false) { GConsole.WriteLine(Resources.text.FailureParsingFlags, remainder, command.Name()); result.Type = ParsingResultType.ParsingFailure; return(result); } var parsedFlags = flagsResult.Value.ToList(); foreach (var flag in command.GetFlags()) { if (flag.FindInList(ref parsedFlags)) { result.Flags.Add(flag); } } if (parsedFlags.Count > 0) { GConsole.WriteLine(Resources.text.UnknownFlags, String.Join(",", parsedFlags), command.Name()); result.Type = ParsingResultType.ParsingFailure; return(result); } result.Type = ParsingResultType.Success; return(result); }
void Awake() { instance = this; DontDestroyOnLoad(this); }
private void LoadBuiltInCommands() { GConsole.AddCommand("help", "Show help on how to use the console", HelpConsoleCommand); }
void Awake() { instance = this; DontDestroyOnLoad(this); commands.Clear(); }