Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        public static void OnWindowMouseUp(object sender, MouseButtonEventArgs args)
        {
            if (sender != Window)
            {
                return;
            }

            //
            int button = 0;

            if (args.Button == MouseButton.Left)
            {
                button = 1;
            }
            else if (args.Button == MouseButton.Right)
            {
                button = 2;
            }
            else if (args.Button == MouseButton.Middle)
            {
                button = 3;
            }
            Widgets.OnMouseUp(button);
            ClientConsole.OnMouseUp(button);
        }
        public void When_registering_two_commands_with_the_same_name()
        {
            //Arrange
            var console = new ClientConsole(new ConsoleConfiguration {
                RememberStartPosition = false
            });
            var command = new RootCommand(console);
            var cmd1    = new Mock <ICommand>(MockBehavior.Strict);

            cmd1.Setup(x => x.Name).Returns("A");
            cmd1.Setup(x => x.Names).Returns(new string[] {});
            var cmd2 = new Mock <ICommand>(MockBehavior.Strict);

            cmd2.Setup(x => x.Name).Returns("A");
            cmd2.Setup(x => x.Names).Returns(new[] { "A" });
            command.RegisterCommand(cmd1.Object);
            Exception exceptionThrown = null;

            //Act
            try
            {
                command.RegisterCommand(cmd2.Object);
            }
            catch (Exception exception)
            {
                exceptionThrown = exception;
            }

            //Assert
            Assert.That(exceptionThrown, Is.Not.Null);
            Assert.That(exceptionThrown.GetType(), Is.EqualTo(typeof(CommandAlreadyRegisteredException)));
        }
Ejemplo n.º 3
0
        public static void OnWindowDisplay()
        {
            OnWindowLoad();

            FPSCounter++;

            if (!FPSWatch.IsRunning)
            {
                FPSWatch.Start();
            }
            if (FPSWatch.ElapsedMilliseconds > 1000)
            {
                FPS        = FPSCounter;
                FPSCounter = 0;
                FPSWatch.Restart();
                ClientConsole.WriteLineReal(" ~ FPS = {0}.", FPS);
            }

            GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            Client.Mouse.SetCursor(Client.Mouse.CursorDefault);

            Widgets.OnRender();
            ClientConsole.OnRender();

            Client.Mouse.Render();
        }
Ejemplo n.º 4
0
        public static int Open(ref lua_State state)
        {
            ClientConsole.RerouteConsole();
            ClientConsole.Color = new Color(0, 150, 255);
            Lua = GLua.Get(state);

            Lua.CreateTable();

            Lua.Push <Action <string> >(Dump);
            Lua.SetField(-2, "Dump");

            Lua.SetField(GLua.LUA_GLOBALSINDEX, "csluaview");

            var container = NativeInterface.Load <INetworkStringTableContainer>("engine", StringTableInterfaceName.CLIENT);
            var tablePtr  = container.FindTable("client_lua_files");
            var table     = JIT.ConvertInstance <INetworkStringTable>(tablePtr);

            Console.WriteLine($"dotnet table ptr: {tablePtr.ToString("X8")}");
            //var path0 = table.GetString(0); //hangs here

            //for (int i = 0; i < table.GetNumStrings(); i++)
            //{
            //}

            //var stringTable = StringTable.FindTable<int>("client_lua_files");
            //var luaFiles = stringTable.Select(s => new LuaFile { Path = s.String, CRC = s.UserData }).ToList();

            Console.WriteLine("DotNet Clientside Lua Viewer Loaded!");
            return(0);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            using var console = new ClientConsole();
            var command = new RootCommand(console);
            var engine  = new Tharga.Toolkit.Console.CommandEngine(command);

            engine.Start(args);
        }
Ejemplo n.º 6
0
        public static int Open(lua_State L)
        {
            ClientConsole.RerouteConsole();

            ClientConsole.Color = ConsoleColor.Green;
            Console.WriteLine("Hello World!");
            return(0);
        }
Ejemplo n.º 7
0
 private static void Main(string[] args)
 {
     using (var console = new ClientConsole())
     {
         var command       = new RootCommand(console);
         var commandEngine = new CommandEngine(command);
         commandEngine.Start(args);
     }
 }
Ejemplo n.º 8
0
        public static void OnWindowKeyPress(object sender, KeyPressEventArgs args)
        {
            if (sender != Window)
            {
                return;
            }

            //
            Widgets.OnTextEntered(args.KeyChar);
            ClientConsole.OnTextEntered(args.KeyChar);
        }
Ejemplo n.º 9
0
        public static void OnWindowKeyUp(object sender, KeyboardKeyEventArgs args)
        {
            if (sender != Window)
            {
                return;
            }

            //
            Widgets.OnKeyUp(args.Key);
            ClientConsole.OnKeyUp(args.Key);
        }
        public void PushesCurrentLineIntoBufferOnNewline()
        {
            var terminal = Substitute.For <ITerminal>();

            terminal.GetBuffer().Returns(new List <TerminalMessage>());
            var formatter = Substitute.For <IConsoleFormatter>();
            var client    = Substitute.For <IClientWrapper>();
            var console   = new ClientConsole(terminal, formatter, client);

            console.WriteToCurrentLine("\n");

            terminal.Received(1).WriteCurrentLine(TerminalStyle.Command);
        }
        public void WritesLongStringToCurrentLine()
        {
            var terminal = Substitute.For <ITerminal>();

            terminal.GetBuffer().Returns(new List <TerminalMessage>());
            var formatter = Substitute.For <IConsoleFormatter>();
            var client    = Substitute.For <IClientWrapper>();
            var console   = new ClientConsole(terminal, formatter, client);

            console.WriteToCurrentLine("hello");

            terminal.Received(5).AppendToCurrentLine(Arg.Any <char>());
        }
        public void WritesBackspaceToCurrentLine()
        {
            var terminal = Substitute.For <ITerminal>();

            terminal.GetBuffer().Returns(new List <TerminalMessage>());
            var formatter = Substitute.For <IConsoleFormatter>();
            var client    = Substitute.For <IClientWrapper>();
            var console   = new ClientConsole(terminal, formatter, client);

            console.WriteToCurrentLine("\b");

            terminal.Received(1).Backspace();
        }
Ejemplo n.º 13
0
        private Program(string[] args)
        {
            using (var console = new ClientConsole())
            {
                var rootCommand = new RootCommand(console);
                rootCommand.RegisterCommand(new StartGameConsoleCommand(_game));
                rootCommand.RegisterCommand(new GetBoardCommand(_game));
                rootCommand.RegisterCommand(new MoveCommand(_game));

                var engine = new CommandEngine(rootCommand);
                engine.Start(args);
            }
        }
        public void WritesCharacterToTerminalsCurrentLine()
        {
            var terminal = Substitute.For <ITerminal>();

            terminal.GetBuffer().Returns(new List <TerminalMessage>());
            var formatter = Substitute.For <IConsoleFormatter>();
            var client    = Substitute.For <IClientWrapper>();
            var console   = new ClientConsole(terminal, formatter, client);

            console.WriteToCurrentLine("a");

            terminal.Received(1).AppendToCurrentLine('a');
        }
        public void WritesStringToTerminalsBuffer()
        {
            var terminal = Substitute.For <ITerminal>();

            terminal.GetBuffer().Returns(new List <TerminalMessage>());
            var formatter = Substitute.For <IConsoleFormatter>();
            var client    = Substitute.For <IClientWrapper>();
            var console   = new ClientConsole(terminal, formatter, client);

            console.WriteToBuffer("a");

            terminal.Received(1).WriteLine("a", Arg.Any <TerminalStyle>());
        }
Ejemplo n.º 16
0
 public CompositeRoot()
 {
     ClientConsole       = new ClientConsole();
     InfluxDbAgentLoader = new InfluxDbAgentLoader();
     FileLoaderAgent     = new FileLoaderAgent();
     ConfigBusiness      = new ConfigBusiness(FileLoaderAgent);
     ConfigBusiness.InvalidConfigEvent += InvalidConfigEvent;
     CounterBusiness   = new CounterBusiness();
     PublisherBusiness = new PublisherBusiness();
     SendBusiness      = new SendBusiness(ConfigBusiness, InfluxDbAgentLoader);
     SendBusiness.SendBusinessEvent += SendBusinessEvent;
     TagLoader = new TagLoader(ConfigBusiness);
 }
Ejemplo n.º 17
0
 public CompositeRoot()
 {
     ClientConsole       = new ClientConsole();
     InfluxDbAgentLoader = new InfluxDbAgentLoader();
     FileLoaderAgent     = new FileLoaderAgent();
     ConfigBusiness      = new ConfigBusiness(FileLoaderAgent);
     ConfigBusiness.InvalidConfigEvent += InvalidConfigEvent;
     CounterBusiness   = new CounterBusiness();
     PublisherBusiness = new PublisherBusiness();
     MetaDataBusiness  = new MetaDataBusiness();
     SendBusiness      = new SendBusiness(ConfigBusiness, new ConsoleQueueEvents(ClientConsole));
     TagLoader         = new TagLoader(ConfigBusiness);
     SocketClient      = new SocketClient();
 }
Ejemplo n.º 18
0
        public async Task _HelpChannel()
        {
            await Context.Message.DeleteAsync();

            StringBuilder sb = new StringBuilder();

            foreach (var command in Starter.Commands.Commands)
            {
                sb.AppendLine($"{command.Name} - {command.Summary}");
            }

            await Context.Channel.SendMessageAsync(sb.ToString());

            await ClientConsole.Log(new TargetedCommandMessage("HelpChannel", Context, Context.Channel));
        }
        public void DoesNotModifyTerminalOutputWhenNormalCharactersTyped()
        {
            var terminal = Substitute.For <ITerminal>();

            terminal.GetBuffer().Returns(new List <TerminalMessage>());
            var formatter = Substitute.For <IConsoleFormatter>();
            var client    = Substitute.For <IClientWrapper>();
            var console   = new ClientConsole(terminal, formatter, client);

            formatter.ClearReceivedCalls();

            console.WriteToCurrentLine("h");

            formatter.Received(0).WriteLine(Arg.Any <TerminalMessage>());
            formatter.Received(0).Backspace();
        }
Ejemplo n.º 20
0
        private static void Main(string[] args)
        {
            var console = new ClientConsole();

            Effort.Provider.EffortProviderConfiguration.RegisterProvider();
            var connection = DbConnectionFactory.CreateTransient();

            using (var context = new SampleDb(connection, "geo"))
            {
                console.WriteLine("Welcome to EF Test Console, type help to check available commands",
                                  OutputLevel.Information, null);

                context.Products.AddRange(new[]
                {
                    new Product {
                        Name = "CocaCola"
                    },
                    new Product {
                        Name = "Pepsi"
                    },
                    new Product {
                        Name = "Starbucks"
                    },
                    new Product {
                        Name = "Donut"
                    }
                });

                context.SaveChanges();

                var ct = new System.Threading.CancellationToken();
                Task.Run(() => { SingletonSampleJob.Instance.RunBackgroundWork(ct); }, ct);

                var command = new RootCommand(console);

                command.RegisterCommand(new FillOrderCommand(context));
                command.RegisterCommand(new EditOrder(context));
                command.RegisterCommand(new QueryAuditTrail(context));
                command.RegisterCommand(new QueryOrder(context));
                command.RegisterCommand(new ToggleController(context));
                command.RegisterCommand(new JobController(context));

                var commandEngine = new CommandEngine(command);

                commandEngine.Run(args);
            }
        }
Ejemplo n.º 21
0
        private static void Main(string[] args)
        {
            var config = new ConsoleConfiguration {
                SplashScreen = "Best Bank ever"
            };

            using (var console = new ClientConsole(config))
            {
                var rootCommand = new RootCommand(console);

                rootCommand.RegisterCommand(Container.GetInstance <Kontener.InterfejsBanku>());

                var commandEngine = new CommandEngine(rootCommand);

                commandEngine.Start(args);
            }
        }
Ejemplo n.º 22
0
        public static void Main(string[] args)
        {
            //LoadedAssembly();
            if (args.Length == 0)
            {
                SwitchDomainForRazorEngine();
            }
            var console  = new ClientConsole();
            var command  = new RootCommand(console);
            var razorcmd = new RazorCommand();

            command.RegisterCommand(razorcmd);
            command.RegisterCommand(new TestCaseCommand(razorcmd));
            var commandEngine = new CommandEngine(command);

            commandEngine.Run(args);
        }
Ejemplo n.º 23
0
        public async Task _HelpDM()
        {
            await Context.Message.DeleteAsync();

            IDMChannel dm = await Context.User.GetOrCreateDMChannelAsync();

            StringBuilder sb = new StringBuilder();

            foreach (var command in Starter.Commands.Commands)
            {
                sb.AppendLine($"!{command.Name} - {command.Summary}");
            }

            await dm.SendMessageAsync(sb.ToString());

            await ClientConsole.Log(new TargetedCommandMessage("HelpDM", Context, Context.User));
        }
Ejemplo n.º 24
0
        public static void Main(string[] args)
        {
            AddResourceWrapper("main.res");
            AddResourceWrapper("graphics.res");
            AddResourceWrapper("music.res");
            AddResourceWrapper("sfx.res");
            AddResourceWrapper("world.res");
            AddResourceWrapper("patch.res");
            AddResourceWrapper("scenario.res");

            // lets assume that we aren't hosting the server
            Mouse.LoadAll();
            Fonts.LoadAll();
            Widgets.SetRootWidget(new MainMenu());
            AllodsWindow.SetVideoMode(1024, 768, false);
            // redirect console to clientconsole. note that with this, all messages are tied to the main client loop.
            ClientConsole.AttachInterceptor();
            AllodsWindow.Run();
        }
Ejemplo n.º 25
0
        public async Task _ReactChannelAdd()
        {
            List <ulong> adminIds = await SaveSystem.GetAdminIds();

            if (adminIds.Contains(Context.User.Id) || adminIds.Count == 0)
            {
                List <ulong> reactChannels = await SaveSystem.GetReactChannel();

                if (!reactChannels.Contains(Context.Channel.Id))
                {
                    await SaveSystem.AddReactChannel(Context.Channel.Id);

                    await ClientConsole.Log(new TargetedCommandMessage("AddReactChannel", Context, Context.Channel));

                    await Context.Channel.SendMessageAsync("Starting reactions in this channel");
                }
            }
            await Context.Message.DeleteAsync();
        }
Ejemplo n.º 26
0
        private static void Main(string[] args)
        {
            using (var console = new ClientConsole())
            {
                var connection = new ExampleContext(console).Connection;
                var container  = InjectionHelper.GetIocContainer(connection);

                var rootCommand = new RootCommand(console, new CommandResolver(type => (ICommand)container.Resolve(type)));
                rootCommand.RegisterCommand <ConnectionConsoleCommands>();
                rootCommand.RegisterCommand <ConfigurationConsoleCommands>();
                rootCommand.RegisterCommand <TimeConsoleCommands>();
                rootCommand.RegisterCommand <SimulatorConsoleCommands>();
                rootCommand.RegisterCommand <LightConsoleCommand>();
                rootCommand.RegisterCommand <TextConsoleCommand>();
                rootCommand.RegisterCommand <BeepConsoleCommand>();
                rootCommand.RegisterCommand <RawDataConsoleCommands>();

                var engine = new CommandEngine(rootCommand);
                engine.Start(args);
            }
        }
Ejemplo n.º 27
0
        public async Task _MockRemovePerson()
        {
            await Context.Message.DeleteAsync();

            List <ulong> adminIds = await SaveSystem.GetAdminIds();

            if (adminIds.Contains(Context.User.Id) || adminIds.Count == 0)
            {
                List <ulong> mocked = await SaveSystem.GetMocked();

                IReadOnlyCollection <SocketUser> mentioned = Context.Message.MentionedUsers;

                if (mentioned.Count == 0 && mocked.Contains(Context.User.Id))
                {
                    await SaveSystem.RemoveMocked(Context.User.Id);

                    await ClientConsole.Log(new TargetedCommandMessage("RemoveReactUser", Context, Context.Channel));

                    await Context.Channel.SendMessageAsync($"Stopped mocking messages from {Context.User.Mention}");

                    return;
                }

                foreach (SocketUser user in mentioned)
                {
                    if (mocked.Contains(user.Id))
                    {
                        await SaveSystem.RemoveMocked(user.Id);

                        await ClientConsole.Log(new TargetedCommandMessage("RemoveMockUser", Context, user));

                        await Context.Channel.SendMessageAsync($"Stopped mocking messages from {user.Mention}");
                    }
                }
            }
        }
Ejemplo n.º 28
0
        public async Task _ReactPersonRemove()
        {
            await Context.Message.DeleteAsync();

            List <ulong> reactUsers = await SaveSystem.GetReactUser();

            IReadOnlyCollection <SocketUser> mentioned = Context.Message.MentionedUsers;

            if (mentioned.Count == 0 && reactUsers.Contains(Context.User.Id))
            {
                await SaveSystem.RemoveReactUser(Context.User.Id);

                await ClientConsole.Log(new TargetedCommandMessage("RemoveReactUser", Context, Context.User));

                await Context.Channel.SendMessageAsync($"Stopped adding claps to messages from {Context.User.Mention}");

                return;
            }

            List <ulong> adminIds = await SaveSystem.GetAdminIds();

            if (adminIds.Contains(Context.User.Id) || adminIds.Count == 0)
            {
                foreach (SocketUser user in mentioned)
                {
                    if (reactUsers.Contains(user.Id))
                    {
                        await SaveSystem.RemoveReactUser(user.Id);

                        await ClientConsole.Log(new TargetedCommandMessage("RemoveReactUser", Context, user));

                        await Context.Channel.SendMessageAsync($"Stopped adding claps to messages from {user.Mention}");
                    }
                }
            }
        }
Ejemplo n.º 29
0
        public ExampleContext(ClientConsole console)
        {
            _console = console;
            var transport = new Transport();

            Connection = new Connection(transport);

            Connection.ScanEvent                          += OnScanEvent;
            Connection.ButtonPressedEvent                 += OnButtonPressedEvent;
            Connection.SignalChangedEvent                 += OnSignalChangedEvent;
            Connection.ConnectionChangedEvent             += OnConnectionChangedEvent;
            Connection.ButtonConfirmationNotreceivedEvent += OnButtonConfirmationNotreceivedEvent;
            Connection.ScanConfirmationNotreceivedEvent   += OnScanConfirmationNotreceivedEvent;
            Connection.MessageEvent                       += OnMessageEvent;
            Connection.ConfigurationEvent                 += OnConfigurationEvent;
            if (!string.IsNullOrEmpty(Connection.OpenPortName))
            {
                Connection.Open(transport);
            }
            else
            {
                _console.OutputWarning("Not connected to any serial port. Use the connection command.");
            }
        }
Ejemplo n.º 30
0
        public override void OnTick()
        {
            if (ClientConsole.CheckXY(Mouse.X, Mouse.Y))
            {
                ButtonClicked = 0;
                ButtonHovered = 0;
                return;
            }

            uint px = TexMenuMask.GetPixelAt(Mouse.X - (GlobalX + Width / 2 - TexMenu.Width / 2),
                                             Mouse.Y - (GlobalY + Height / 2 - TexMenu.Height / 2));

            px  &= 0xF0;
            px >>= 4;
            if (px >= 8 && px <= 16)
            {
                px -= 7;
            }
            else
            {
                px = 0;
            }
            ButtonHovered = (int)px;
        }