Exemplo n.º 1
0
        public IConsoleObject FindConsoleObject(string name)
        {
            using (FStringUnsafe nameUnsafe = new FStringUnsafe(name))
            {
                IntPtr address = Native_IConsoleManager.FindConsoleObject(Address, ref nameUnsafe.Array);
                if (address != IntPtr.Zero)
                {
                    IConsoleObject consoleObject = new IConsoleObject(address);

                    IConsoleObject consoleVariable = consoleObject.AsVariable();
                    if (consoleVariable != null)
                    {
                        return(consoleVariable);
                    }

                    IConsoleCommand consoleCommand = consoleObject.AsCommand();
                    if (consoleCommand != null)
                    {
                        return(consoleCommand);
                    }

                    return(consoleObject);
                }
                return(null);
            }
        }
Exemplo n.º 2
0
 public bool IsNameRegistered(string name)
 {
     using (FStringUnsafe nameUnsafe = new FStringUnsafe(name))
     {
         return(Native_IConsoleManager.IsNameRegistered(Address, ref nameUnsafe.Array));
     }
 }
Exemplo n.º 3
0
        private void ForEachConsoleObject(FConsoleObjectVisitor visitor, string str, bool startsWith)
        {
            if (visitor == null)
            {
                return;
            }

            // TCHAR*, IConsoleObject*
            Native_IConsoleManager.FConsoleObjectVisitor callback = delegate(IntPtr namePtr, IntPtr consoleObjectAddress)
            {
                string         name          = FStringMarshaler.FromCharPtr(namePtr);
                IConsoleObject consoleObject = new IConsoleObject(consoleObjectAddress);
                visitor(name, consoleObject);
            };

            using (FStringUnsafe strUnsafe = new FStringUnsafe(str))
            {
                if (startsWith)
                {
                    Native_IConsoleManager.ForEachConsoleObjectThatStartsWith(Address, callback, ref strUnsafe.Array);
                }
                else
                {
                    Native_IConsoleManager.ForEachConsoleObjectThatContains(Address, callback, ref strUnsafe.Array);
                }
            }
        }
Exemplo n.º 4
0
        public FDelegateHandle RegisterConsoleVariableSink(FConsoleCommandDelegate handler)
        {
            FDelegateHandle result = default(FDelegateHandle);

            Native_IConsoleManager.RegisterConsoleVariableSink_Handle(Address, handler, ref result);
            managedVariableSinkHandlers[result] = handler;
            return(result);
        }
Exemplo n.º 5
0
 public void AddConsoleHistoryEntry(string key, string input)
 {
     using (FStringUnsafe keyUnsafe = new FStringUnsafe(key))
         using (FStringUnsafe inputUnsafe = new FStringUnsafe(input))
         {
             Native_IConsoleManager.AddConsoleHistoryEntry(Address, ref keyUnsafe.Array, ref inputUnsafe.Array);
         }
 }
Exemplo n.º 6
0
 public bool ProcessUserConsoleInput(string input, UObject world, IntPtr outputDevice)
 {
     using (FStringUnsafe inputUnsafe = new FStringUnsafe(input))
     {
         return(Native_IConsoleManager.ProcessUserConsoleInput(Address, ref inputUnsafe.Array, outputDevice,
                                                               world == null ? IntPtr.Zero : world.Address));
     }
 }
Exemplo n.º 7
0
 public IConsoleVariable FindConsoleVariable(string name)
 {
     using (FStringUnsafe nameUnsafe = new FStringUnsafe(name))
     {
         IntPtr address = Native_IConsoleManager.FindConsoleVariable(Address, ref nameUnsafe.Array);
         return(address == IntPtr.Zero ? null : new IConsoleVariable(address));
     }
 }
Exemplo n.º 8
0
 public string[] GetConsoleHistory(string key)
 {
     using (FStringUnsafe keyUnsafe = new FStringUnsafe(key))
         using (TArrayUnsafe <string> result = new TArrayUnsafe <string>())
         {
             Native_IConsoleManager.GetConsoleHistory(Address, ref keyUnsafe.Array, result.Address);
             return(result.ToArray());
         }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Create a float console variable
 /// </summary>
 /// <param name="name">must not be 0</param>
 /// <param name="defaultValue"></param>
 /// <param name="help">must not be 0</param>
 /// <param name="flags">bitmask combined from EConsoleVariableFlags</param>
 /// <returns></returns>
 public IConsoleVariable RegisterConsoleVariable(string name, float defaultValue, string help, EConsoleVariableFlags flags = EConsoleVariableFlags.Default)
 {
     using (FStringUnsafe nameUnsafe = new FStringUnsafe(name))
         using (FStringUnsafe helpUnsafe = new FStringUnsafe(help))
         {
             IntPtr address = Native_IConsoleManager.RegisterConsoleVariableFloat(
                 Address, ref nameUnsafe.Array, defaultValue, ref helpUnsafe.Array, flags);
             return(address == IntPtr.Zero ? null : new IConsoleVariable(address));
         }
 }
Exemplo n.º 10
0
        public static IConsoleManager Get()
        {
            IntPtr address = Native_IConsoleManager.Get();

            if (singleton == null || singleton.Address != address)
            {
                singleton = new IConsoleManager(address);
            }
            return(singleton);
        }
Exemplo n.º 11
0
        private IConsoleCommand RegisterConsoleCommand(string name, string help, Delegate command, CommandDelegateType type, EConsoleVariableFlags flags)
        {
            ManagedCommand managedCommand = new ManagedCommand(command, type);

            if (managedCommand.Command != null && managedCommand.NativeCallback != null)
            {
                using (FStringUnsafe nameUnsafe = new FStringUnsafe(name))
                    using (FStringUnsafe helpUnsafe = new FStringUnsafe(help))
                    {
                        IntPtr address = IntPtr.Zero;
                        switch (type)
                        {
                        case CommandDelegateType.Default:
                            address = Native_IConsoleManager.RegisterConsoleCommandDefault(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithArgs:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithArgs(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithWorld:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithWorld(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithWorldAndArgs:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithWorldAndArgs(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;

                        case CommandDelegateType.WithOutputDevice:
                            address = Native_IConsoleManager.RegisterConsoleCommandWithOutputDevice(
                                Address, ref nameUnsafe.Array, ref helpUnsafe.Array, managedCommand.NativeCallback, flags);
                            break;
                        }
                        if (address != IntPtr.Zero)
                        {
                            managedCommand.NativeCommand = new IConsoleCommand(address);
                            managedCommands[address]     = managedCommand;
                            return(managedCommand.NativeCommand);
                        }
                    }
            }
            return(null);
        }
Exemplo n.º 12
0
        public void UnregisterConsoleObject(IConsoleObject consoleObject, bool keepState = true)
        {
            if (consoleObject == null)
            {
                return;
            }

            ManagedVariableChangedHandler managedVariableChangedHandler;

            if (managedVariableOnChangedHandlers.TryGetValue(consoleObject.Address, out managedVariableChangedHandler))
            {
                Native_IConsoleVariable.ClearOnChangedCallback(consoleObject.Address);
                managedVariableOnChangedHandlers.Remove(consoleObject.Address);
            }

            ManagedCommand managedCommand;

            if (managedCommands.TryGetValue(consoleObject.Address, out managedCommand))
            {
                managedCommands.Remove(consoleObject.Address);
            }

            Native_IConsoleManager.UnregisterConsoleObject(Address, consoleObject.Address, keepState);
        }
Exemplo n.º 13
0
 public void CallAllConsoleVariableSinks()
 {
     Native_IConsoleManager.CallAllConsoleVariableSinks(Address);
 }
Exemplo n.º 14
0
 public void UnregisterConsoleVariableSink(FDelegateHandle handle)
 {
     managedVariableSinkHandlers.Remove(handle);
     Native_IConsoleManager.UnregisterConsoleVariableSink_Handle(Address, ref handle);
 }