private void InitNavKeys() { FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.Escape, null, () => { if (currentContent != null && FocusManager.FocusedControl != null && (FocusManager.FocusedControl == currentContent || (currentContent is ConsolePanel && (currentContent as ConsolePanel).Descendents.Contains(FocusManager.FocusedControl))) ) { currentNavButton?.TryFocus(); } else { AnimatedDialog.Show((dialogHandle) => { var contentBg = RGB.Yellow; var bgCompliment = contentBg.GetCompliment(); var textColor = RGB.Black.CalculateDistanceTo(bgCompliment) < RGB.MaxDistance * .75f ? RGB.Black : bgCompliment; var panel = new ConsolePanel() { Height = 11, Width = (int)Math.Round(LayoutRoot.Width * .5f), Background = contentBg }; var label = panel.Add(new Label() { Text = "Press enter to quit or escape to resume".ToConsoleString(textColor, contentBg) }).CenterBoth(); FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.Enter, null, Stop, panel); FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.Escape, null, dialogHandle.CloseDialog, panel); return(panel); }); } }, this); }
private async Task <ServerInfo> CollectServerInfoFromUser() { var serverInfo = new ServerInfo { Server = "192.168.1.16", Port = 8080 }; Task dialogTask = null; await QueueAction(() => { var panel = new ConsolePanel() { Height = 10 }; var form = panel.Add(new Form(FormOptions.FromObject(serverInfo))).Fill(padding: new Thickness(1, 1, 1, 2)); var okButton = panel.Add(new Button() { X = 1, Text = "OK".ToConsoleString(), Shortcut = new KeyboardShortcut(ConsoleKey.Enter) }).DockToBottom(padding: 1); okButton.Pressed.SubscribeOnce(Dialog.Dismiss); dialogTask = Dialog.Show(new ControlDialogOptions() { Content = panel, MaxHeight = 8 }).AsAwaitable(); }).AsAwaitable(); await dialogTask; return(serverInfo); }
public void ConsoleAppLifecycleTestBasic() { ConsoleProvider.Current = new CliUnitTestConsole(); ConsoleApp app = new ConsoleApp(0, 0, 80, 10); int addCounter = 0, removeCounter = 0; app.ControlAdded.SubscribeForLifetime((c) => { addCounter++; }, app); app.ControlRemoved.SubscribeForLifetime((c) => { removeCounter++; }, app); app.LayoutRoot.Id = "LayoutRoot"; ConsolePanel panel = app.LayoutRoot.Add(new ConsolePanel() { Id = "First panel" }); // direct child Assert.AreEqual(1, addCounter); Assert.AreEqual(0, removeCounter); var button = panel.Add(new Button() { Id = "Button on first panel" }); // grandchild Assert.AreEqual(2, addCounter); Assert.AreEqual(0, removeCounter); var innerPanel = new ConsolePanel() { Id = "InnerPanel" }; var innerInnerPanel = innerPanel.Add(new ConsolePanel() { Id = "Inner Inner Panel" }); // no change since not added to the app yet Assert.AreEqual(2, addCounter); Assert.AreEqual(0, removeCounter); panel.Add(innerPanel); // both child and grandchild found on add Assert.AreEqual(4, addCounter); Assert.AreEqual(0, removeCounter); // remove a nested child innerPanel.Controls.Remove(innerInnerPanel); Assert.AreEqual(4, addCounter); Assert.AreEqual(1, removeCounter); app.LayoutRoot.Controls.Clear(); Assert.AreEqual(4, addCounter); Assert.AreEqual(4, removeCounter); }
private void Console_Click(object sender, EventArgs e) { if (ConsolePanel.Visible) { ConsolePanel.Hide(); } else { ConsolePanel.Show(); } }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); panel = GetComponentInChildren <ConsolePanel>(); panel.gameObject.SetActive(false); Shown = false; } else if (instance != this) { Destroy(gameObject); } }
public MainWindow() { InitializeComponent(); var cP = new ConsolePanel(); var scP = new ServerControlPanel(cP); var sP = new SettingsPanel(cP); CenterView.Children.Add(scP); CenterView.Children.Add(sP); CenterView.Children.Add(cP); bUIdictionary.Add(Serv, scP); bUIdictionary.Add(Sett, sP); bUIdictionary.Add(Cons, cP); ManageButtons(Serv, new RoutedEventArgs()); }
private void CloseConsoleButton_Click(object sender, EventArgs e) { ConsolePanel.Hide(); }
public override void Begin(params object[] parameters) { base.Begin(parameters); IMouseCursorService service = Services.GetService <IMouseCursorService>(); if (service != null) { service.AddKey("Loading"); } Diagnostics.Log("GameClientState_GameLaunched."); int num = 0; ISessionService service2 = Services.GetService <ISessionService>(); Diagnostics.Assert(service2 != null); Diagnostics.Assert(service2.Session != null); Diagnostics.Assert(service2.Session.IsOpened); string text = service2.Session.SteamIDUser.ToString(); Diagnostics.Assert(service2.Session.SteamIDUser.AccountID == Amplitude.Unity.Framework.Application.UserUniqueID); PlayerController playerController = new PlayerController(base.GameClient) { PlayerID = "player#" + service2.Session.SteamIDUser.AccountID }; for (;;) { string x = string.Format("Empire{0}", num); string lobbyData = service2.Session.GetLobbyData <string>(x, null); if (string.IsNullOrEmpty(lobbyData)) { break; } if (lobbyData.Contains(text)) { goto IL_113; } num++; } Diagnostics.LogError("Player doesn't belong here (SteamUserID: {0}).", new object[] { text }); goto IL_12C; IL_113: playerController.Empire = base.GameClient.Game.Empires[num]; IL_12C: int num2 = 0; for (;;) { string x2 = string.Format("Empire{0}", num2); string lobbyData2 = service2.Session.GetLobbyData <string>(x2, null); if (string.IsNullOrEmpty(lobbyData2)) { break; } base.GameClient.Game.Empires[num2].IsControlledByAI = true; MajorEmpire majorEmpire = base.GameClient.Game.Empires[num2] as MajorEmpire; if (majorEmpire != null) { if (!lobbyData2.StartsWith("AI")) { majorEmpire.IsControlledByAI = false; if (Steamworks.SteamAPI.IsSteamRunning) { string[] array = lobbyData2.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { Steamworks.SteamID steamID = new Steamworks.SteamID(Convert.ToUInt64(array[i], 16)); if (!service2.Session.GetLobbyMemberData <bool>(steamID, "Ready", false) && base.GameClient.Session.SessionMode != SessionMode.Single) { majorEmpire.BindPlayer(new Player(majorEmpire) { Type = PlayerType.AI, Location = ((base.GameClient.Session.GameServer == null) ? PlayerLocation.Remote : PlayerLocation.Local), LocalizedName = MajorEmpire.GenerateBasicAIName(majorEmpire.Index) }); } else { string text2 = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(steamID); if (text2 == null) { text2 = AgeLocalizer.Instance.LocalizeString("%DefaultPlayerName"); } majorEmpire.BindPlayer(new Player(majorEmpire) { Type = PlayerType.Human, Location = ((!(steamID == base.GameClient.SteamIDUser)) ? PlayerLocation.Remote : PlayerLocation.Local), LocalizedName = text2, SteamID = steamID }); } } } else { Diagnostics.LogWarning("Steam is not running, cannot get player's name, setting a default one."); majorEmpire.BindPlayer(new Player(majorEmpire) { Type = PlayerType.Human, Location = PlayerLocation.Local, LocalizedName = AgeLocalizer.Instance.LocalizeString("%DefaultPlayerName"), SteamID = Steamworks.SteamID.Zero }); } } else { majorEmpire.BindPlayer(new Player(majorEmpire) { Type = PlayerType.AI, Location = ((base.GameClient.Session.GameServer == null) ? PlayerLocation.Remote : PlayerLocation.Local), LocalizedName = MajorEmpire.GenerateBasicAIName(majorEmpire.Index) }); } } num2++; } IPlayerControllerRepositoryService service3 = base.GameClient.Game.GetService <IPlayerControllerRepositoryService>(); if (service3 != null) { for (int j = 0; j < base.GameClient.Game.Empires.Length; j++) { PlayerController playerController2 = new PlayerController(base.GameClient) { Empire = base.GameClient.Game.Empires[j], PlayerID = base.GameClient.Game.Empires[j].PlayerID }; service3.Register(playerController2); base.GameClient.Game.Empires[j].PlayerController = playerController2; base.GameClient.Game.Empires[j].PlayerControllers.Client = playerController2; } } if (service3 != null) { service3.Register(playerController); service3.SetActivePlayerController(playerController); } Ticket.ResetCounter(0UL); Amplitude.Unity.View.IViewService service4 = Services.GetService <Amplitude.Unity.View.IViewService>(); if (service4 != null) { WorldView worldView = (WorldView)service4.FindByType(typeof(WorldView)); if (worldView != null) { worldView.WorldViewTechniqueChange += this.WorldView_WorldViewTechniqueChange; } service4.PostViewChange(typeof(WorldView), new object[0]); } Amplitude.Unity.Gui.IGuiService service5 = Services.GetService <Amplitude.Unity.Gui.IGuiService>(); Diagnostics.Assert(service5 != null); ConsolePanel guiPanel = service5.GetGuiPanel <ConsolePanel>(); Diagnostics.Assert(guiPanel != null); guiPanel.Load(); guiPanel.Hide(false); }
private void InitMenu() { var menuStack = layout.Add(new StackPanel() { Orientation = Orientation.Vertical }, 0, 0); menuStack.Add(new Label() { Text = "Samples Menu".ToYellow(underlined: true) }); menuStack.Add(new Label() { Text = ConsoleString.Empty }); var overviewButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.O, null), Text = "Overview".ToWhite() }); SetupMenuItem(overviewButton, () => { var panel = new ConsolePanel(); var label = panel.Add(new Label() { Text = "Welcome to the PowerArgs sample app.".ToGreen() }).CenterBoth(); return(panel); }); var calculatorButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.C, null), Text = "Calculator program".ToWhite() }); SetupMenuItem(calculatorButton, () => { var panel = new ConsolePanel(); var console = panel.Add(new SampleConsole(() => new CommandLineArgumentsDefinition(typeof(CalculatorProgram)))).Fill(); return(panel); }); var args = new PerfTestArgs() { Test = TestCase.FallingChars }; var perfButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.P, null), Text = "Perf Test".ToWhite() }); SetupMenuItem(perfButton, () => { var panel = new StackPanel() { Height = 3, Orientation = Orientation.Vertical }; panel.Add(new Form(FormOptions.FromObject(args)) { Height = 2 }).FillHorizontally(); var runButton = panel.Add(new Button() { Text = "Run".ToWhite(), Shortcut = new KeyboardShortcut(ConsoleKey.R) }); runButton.Pressed.SubscribeOnce(() => { panel.Controls.Clear(); var console = panel.Add(new PerfTest(args)).Fill(); }); QueueAction(() => panel.Descendents.Where(d => d.CanFocus).FirstOrDefault()?.TryFocus()); return(panel); }); var colorArgs = new ColorTestArgs { From = ConsoleColor.Black, To = ConsoleColor.Green, Mode = ConsoleMode.VirtualTerminal }; var colorButton = menuStack.Add(new Button() { Tag = MenuTag, Shortcut = new KeyboardShortcut(ConsoleKey.R, null), Text = "RGB Test".ToWhite() }); SetupMenuItem(colorButton, () => { var panel = new ConsolePanel() { Height = 4 }; panel.Add(new Form(FormOptions.FromObject(colorArgs)) { Height = 3 }).FillHorizontally(); var runButton = panel.Add(new Button() { Y = 3, Text = "Run".ToWhite(), Shortcut = new KeyboardShortcut(ConsoleKey.R) }); runButton.Pressed.SubscribeOnce(() => { panel.Controls.Clear(); if (colorArgs.Mode == ConsoleMode.VirtualTerminal) { ConsoleProvider.Fancy = true; } if (colorArgs.Mode == ConsoleMode.Console) { ConsoleProvider.Fancy = false; } var toColor = panel.Add(new ConsolePanel() { Width = 20, Height = 3, Background = colorArgs.From }).CenterBoth(); var label = toColor.Add(new Label() { Text = toColor.Background.ToRGBString().ToWhite(toColor.Background, underlined: true) }).CenterBoth(); RGB.AnimateAsync(new RGBAnimationOptions() { Transitions = new System.Collections.Generic.List <System.Collections.Generic.KeyValuePair <RGB, RGB> >() { new System.Collections.Generic.KeyValuePair <RGB, RGB>(colorArgs.From, colorArgs.To), } , Duration = 1500, EasingFunction = Animator.EaseInOut, AutoReverse = true, Loop = this, AutoReverseDelay = 500, OnColorsChanged = (c) => { toColor.Background = c[0]; label.Text = toColor.Background.ToRGBString().ToWhite(toColor.Background, underlined: true); } }); }); QueueAction(() => panel.Descendents.Where(d => d.CanFocus).FirstOrDefault()?.TryFocus()); return(panel); }); overviewButton.Pressed.Fire(); }
public ConsoleStreamWriter(ConsolePanel output) { this.output = output; }
public HeadsUpDisplay(GameApp app) { this.gameApp = app; this.Height = 7; var topPanel = Add(new StackPanel() { Orientation = Orientation.Horizontal, Height = 6 }).FillHoriontally(); var leftPanel = topPanel.Add(new StackPanel() { Orientation = Orientation.Vertical, Width = 12 }).FillVertically(); var middleGrid = topPanel.Add(new Grid(new List <object>() { new WeaponRow { Weapon = "".ToWhite(), Trigger = "".ToWhite(), Amount = "".ToWhite() }, new WeaponRow { Weapon = "".ToWhite(), Trigger = "".ToWhite(), Amount = "".ToWhite() }, }) { Gutter = 0, ShowEndIfComplete = false, CanFocus = false, Width = 35 }).FillVertically(); messagePanel = topPanel.Add(new ConsolePanel() { IsVisible = false, Width = 31, Background = ConsoleColor.White }).FillVertically(padding: new Thickness(0, 0, 1, 1)); var bottomPanel = Add(new StackPanel() { Orientation = Orientation.Horizontal, Margin = 2, Height = 1 }).FillHoriontally().DockToBottom(); var hpLabel = leftPanel.Add(new Label() { Text = "HP".ToGray() }).FillHoriontally(); var hpValue = leftPanel.Add(new Label() { Text = ConsoleString.Empty }).FillHoriontally(); var spacer = leftPanel.Add(new Label() { Text = ConsoleString.Empty }); var aimLabel = leftPanel.Add(new Label() { Text = "AIM".ToGray() }).FillHoriontally(); var aimValue = leftPanel.Add(new Label() { Text = "".ToWhite() }).FillHoriontally(); middleGrid.VisibleColumns[0].ColumnDisplayName = new ConsoleString(middleGrid.VisibleColumns[0].ColumnDisplayName.ToString(), ConsoleColor.Gray); middleGrid.VisibleColumns[1].ColumnDisplayName = new ConsoleString(middleGrid.VisibleColumns[1].ColumnDisplayName.ToString(), ConsoleColor.Gray); middleGrid.VisibleColumns[2].ColumnDisplayName = new ConsoleString(middleGrid.VisibleColumns[2].ColumnDisplayName.ToString(), ConsoleColor.Gray); middleGrid.VisibleColumns[0].OverflowBehavior = new TruncateOverflowBehavior() { TruncationText = "", ColumnWidth = 15 }; middleGrid.VisibleColumns[1].OverflowBehavior = new TruncateOverflowBehavior() { TruncationText = "", ColumnWidth = 10 }; middleGrid.VisibleColumns[2].OverflowBehavior = new TruncateOverflowBehavior() { TruncationText = "", ColumnWidth = 10 }; var menuLabel = bottomPanel.Add(new Label() { Text = "".ToYellow() }); var pauseLabel = bottomPanel.Add(new Label() { Text = "".ToYellow() }); var quitLabel = bottomPanel.Add(new Label() { Text = "Quit [ESC]".ToYellow() }); messageLabel = messagePanel.Add(new Label() { Mode = LabelRenderMode.MultiLineSmartWrap, Background = ConsoleColor.White, Text = "".ToBlack(bg: ConsoleColor.White) }).Fill(padding: new Thickness(1, 1, 1, 1)); app.SubscribeProxiedForLifetime(app, nameof(app.MainCharacter) + "." + nameof(MainCharacter.HealthPoints), () => { var hp = app.MainCharacter?.HealthPoints; hpValue.Text = hp.HasValue ? FormatHPValue(hp.Value) : "unknown".ToRed(); }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.InputManager) + "." + nameof(GameInputManager.KeyMap) + "." + nameof(KeyMap.MenuKey), () => { menuLabel.Text = $"Menu [{app.InputManager.KeyMap.MenuKey}]".ToYellow(); }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.InputManager) + "." + nameof(GameInputManager.KeyMap) + "." + nameof(KeyMap.TogglePauseKey), () => { pauseLabel.Text = $"Pause [{app.InputManager.KeyMap.TogglePauseKey}]".ToYellow(); }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.InputManager) + "." + nameof(GameInputManager.KeyMap) + "." + ObservableObject.AnyProperty, () => { var primaryWeaponRow = ((WeaponRow)(middleGrid.DataSource as MemoryDataSource).Items[0]); primaryWeaponRow.Trigger = $"[{this.gameApp.InputManager.KeyMap.PrimaryWeaponKey}]".ToWhite(); var explosiveWeaponRow = ((WeaponRow)(middleGrid.DataSource as MemoryDataSource).Items[1]); explosiveWeaponRow.Trigger = $"[{this.gameApp.InputManager.KeyMap.ExplosiveWeaponKey}]".ToWhite(); aimLabel.Text = $"Aim[{this.gameApp.InputManager.KeyMap.AimToggleKey}]".ToGray(); }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.MainCharacter) + "." + nameof(MainCharacter.Inventory) + "." + nameof(Inventory.PrimaryWeapon), () => { var row = ((WeaponRow)(middleGrid.DataSource as MemoryDataSource).Items[0]); var weaponName = app.MainCharacter?.Inventory?.PrimaryWeapon?.GetType().Name; row.Weapon = weaponName != null ? weaponName.ToWhite() : "none".ToRed(); if (weaponName != null) { ShowMessage("Equipped ".ToBlack() + weaponName.ToDarkBlue(), TimeSpan.FromSeconds(4)); } }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.MainCharacter) + "." + nameof(MainCharacter.Inventory) + "." + nameof(Inventory.PrimaryWeapon) + "." + nameof(Weapon.AmmoAmount), () => { var row = ((WeaponRow)(middleGrid.DataSource as MemoryDataSource).Items[0]); var ammo = app.MainCharacter?.Inventory?.PrimaryWeapon?.AmmoAmount; row.Amount = ammo.HasValue ? FormatAmmoAmmount(ammo.Value): "empty".ToRed(); }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.MainCharacter) + "." + nameof(MainCharacter.Inventory) + "." + nameof(Inventory.ExplosiveWeapon), () => { var row = ((WeaponRow)(middleGrid.DataSource as MemoryDataSource).Items[1]); var weaponName = app.MainCharacter?.Inventory?.ExplosiveWeapon?.GetType().Name; row.Weapon = weaponName != null ? weaponName.ToWhite() : "none".ToRed(); if (weaponName != null) { ShowMessage("Equipped ".ToBlack() + weaponName.ToDarkBlue(), TimeSpan.FromSeconds(4)); } }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.MainCharacter) + "." + nameof(MainCharacter.Inventory) + "." + nameof(Inventory.ExplosiveWeapon) + "." + nameof(Weapon.AmmoAmount), () => { var row = ((WeaponRow)(middleGrid.DataSource as MemoryDataSource).Items[1]); var ammo = app.MainCharacter?.Inventory?.ExplosiveWeapon?.AmmoAmount; row.Amount = ammo.HasValue ? FormatAmmoAmmount(ammo.Value) : "empty".ToRed(); }, this.LifetimeManager); app.SynchronizeProxiedForLifetime(app, nameof(app.MainCharacter) + "." + nameof(MainCharacter.AimMode), () => { var aimMode = app.MainCharacter?.AimMode; aimValue.Text = aimMode.HasValue ? aimMode.Value.ToString().ToConsoleString(aimMode.Value == AimMode.Auto ? ConsoleColor.White : ConsoleColor.Cyan) : "".ToConsoleString(); }, this.LifetimeManager); }
/// <summary> /// Создать новое окно с консолью /// </summary> public void CreateNewConsole() { Schematix.Panels.ConsolePanel console = new ConsolePanel("cmd", string.Empty); ShowPanel(console, AnchorableShowStrategy.Bottom); }
private void OnDestroy() { m_Inst = null; }
private void Awake() { m_Inst = this; gameObject.SetActive(_bShow); }
public ConsoleStreamWriter(ConsolePanel output) { this.output = output; }