public SimpleFormDialog(uint formId, BedrockFormManager parent, SimpleForm form, InputManager inputManager) : base(formId, parent, inputManager) { StackMenu = new GuiStackMenu(); StackMenu.Anchor = Alignment.Fill; StackMenu.ChildAnchor = Alignment.MiddleFill; if (!string.IsNullOrWhiteSpace(form.Content)) { StackMenu.AddMenuItem(form.Content, () => {}, false); StackMenu.AddSpacer(); } var btns = form.Buttons.ToArray(); for (var index = 0; index < btns.Length; index++) { var button = btns[index]; int idx = index; Action submitAction = () => { var packet = McpeModalFormResponse.CreateObject(); packet.formId = formId; packet.data = idx.ToString(); //JsonConvert.SerializeObject(idx) parent.SendResponse(packet); parent.Hide(formId); }; if (button.Image != null) { switch (button.Image.Type) { case "url": StackMenu.AddChild(new FormImageButton(button.Image.Url, button.Text, submitAction)); continue; break; case "path": break; } } StackMenu.AddMenuItem(button.Text, submitAction); } Container.AddChild(StackMenu); Container.AddChild(new GuiTextElement() { Anchor = Alignment.TopCenter, Text = form.Title, FontStyle = FontStyle.Bold, Scale = 2f, TextColor = TextColor.White }); AddChild(Container); }
public VersionSelectionState(GuiPanoramaSkyBox skyBox, Action onJavaConfirmed, Action <PlayerProfile> onBedrockConfirmed) { _skyBox = skyBox; JavaConfirmed = onJavaConfirmed; BedrockConfirmed = onBedrockConfirmed; Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Width = 125, Anchor = Alignment.MiddleCenter, ChildAnchor = Alignment.CenterY | Alignment.FillX, //BackgroundOverlay = new Color(Color.Black, 0.35f), ModernStyle = false, }; _mainMenu.AddMenuItem($"Java - Version {JavaProtocol.FriendlyName}", JavaEditionButtonPressed); _mainMenu.AddMenuItem($"Bedrock - Version {McpeProtocolInfo.GameVersion}", BedrockEditionButtonPressed); _mainMenu.AddSpacer(); _mainMenu.AddMenuItem($"Go Back", SinglePlayerButtonPressed); AddChild(_mainMenu); AddChild(_logo = new GuiImage(GuiTextures.AlexLogo) { Margin = new Thickness(0, 25, 0, 0), Anchor = Alignment.TopCenter }); AddChild(_textElement = new GuiTextElement() { TextColor = TextColor.Yellow, Margin = new Thickness(0, 64, 0, 0), Anchor = Alignment.TopCenter, Text = "Select the edition you want to play on...", Scale = 1f }); }
public InGameMenuState() { HeaderTitle.TranslationKey = "menu.game"; HeaderTitle.Anchor = Alignment.TopCenter; HeaderTitle.Scale = 2f; HeaderTitle.FontStyle = FontStyle.DropShadow; _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }; _playerList = new GuiScrollableStackContainer() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 0, 0, 0), Width = 125, MinWidth = 125, Anchor = Alignment.FillRight, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }; _playerList.Orientation = Orientation.Vertical; /* AddChild(new GuiTextElement() * { * TranslationKey = "menu.game", * Anchor = Alignment.TopCenter, * Scale = 2f, * FontStyle = FontStyle.DropShadow * });*/ _mainMenu.AddMenuItem("menu.returnToGame", OnReturnToGameButtonPressed, isTranslationKey: true); _mainMenu.AddMenuItem("menu.options", OnOptionsButtonPressed, isTranslationKey: true); _mainMenu.AddMenuItem("menu.returnToMenu", OnQuitButtonPressed, isTranslationKey: true); AddChild(_mainMenu); AddChild(_playerList); }
private void CreateProtocolMenu() { _protocolMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _protocolMenu.AddMenuItem($"Java - {JavaProtocol.FriendlyName}", JavaEditionButtonPressed); _protocolMenu.AddMenuItem($"Bedrock - {McpeProtocolInfo.GameVersion}", BedrockEditionButtonPressed, false); _protocolMenu.AddMenuItem("Return to main menu", ProtocolBackPressed); }
public ModelDebugState() { _debugInfo = new GuiDebugInfo(); Background = Color.DeepSkyBlue; BlockModelExplorer = new BlockModelExplorer(Alex.Instance, null); EntityModelExplorer = new EntityModelExplorer(Alex.Instance, null); ModelExplorer = BlockModelExplorer; //AddChild(_wrap = new GuiStackContainer() //{ // Orientation = Orientation.Horizontal, // Anchor = Alignment.Fill, // ChildAnchor = Alignment.FillY //}); AddChild(_modelExplorerView = new GuiModelExplorerView(ModelExplorer, new Vector3(0f, 1.85f, 6f), new Vector3(0.5f, 0.5f, 0.5f)) { Anchor = Alignment.Fill, Background = Color.TransparentBlack, BackgroundOverlay = new Color(Color.Black, 0.15f), Margin = new Thickness(0), Width = 92, Height = 128, AutoSizeMode = AutoSizeMode.None, //Anchor = Alignment.BottomRight, // Width = 100, // Height = 100 }); AddChild(_mainMenu = new GuiStackMenu() { Margin = new Thickness(0, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }); //_wrap.AddChild(_modelRenderer = new DebugModelRenderer(Alex) //{ // Anchor = Alignment.Fill, // // Width = 100, // // Height = 100 //}); _mainMenu.AddMenuItem("Skip", () => { Task.Run(() => { ModelExplorer.Skip(); }); }); _mainMenu.AddMenuItem("Next", NextModel); _mainMenu.AddMenuItem("Previous", PrevModel); _mainMenu.AddMenuItem("Switch Models", () => { SwitchModelExplorers(); _modelExplorerView.ModelExplorer = ModelExplorer; }); //AddChild(_mainMenu); _debugInfo.AddDebugRight(() => Alex.DotnetRuntime); //_debugInfo.AddDebugRight(() => MemoryUsageDisplay); _debugInfo.AddDebugRight(() => $"RAM: {PlayingState.GetBytesReadable(_ramUsage, 2)}"); _debugInfo.AddDebugRight(() => $"GPU: {PlayingState.GetBytesReadable(GpuResourceManager.GetMemoryUsage, 2)}"); _debugInfo.AddDebugRight(() => { return ($"Threads: {(_threadsUsed):00}/{_maxThreads}\nCompl.ports: {_complPortUsed:00}/{_maxComplPorts}"); }); _debugInfo.AddDebugRight(() => { if (ModelExplorer == null) { return(string.Empty); } return(ModelExplorer.GetDebugInfo()); }); _keyState = Keyboard.GetState(); }
public SimpleFormDialog(uint formId, BedrockFormManager parent, SimpleForm form, InputManager inputManager) : base(formId, parent, inputManager) { StackMenu = new GuiStackMenu(); StackMenu.Anchor = Alignment.Fill; StackMenu.ChildAnchor = Alignment.MiddleCenter; StackMenu.Background = Color.Black * 0.35f; if (!string.IsNullOrWhiteSpace(form.Content)) { StackMenu.AddLabel(FixContrast(form.Content)); StackMenu.AddSpacer(); } var btns = form.Buttons.ToArray(); for (var index = 0; index < btns.Length; index++) { var button = btns[index]; int idx = index; Action submitAction = () => { var packet = McpeModalFormResponse.CreateObject(); packet.formId = formId; packet.data = idx.ToString(); //JsonConvert.SerializeObject(idx) parent.SendResponse(packet); parent.Hide(formId); }; if (button.Image != null) { switch (button.Image.Type) { case "url": StackMenu.AddChild(new FormImageButton(button.Image.Url, button.Text, submitAction)); continue; break; case "path": break; } } var item = StackMenu.AddMenuItem(button.Text, submitAction); } Background = Color.Transparent; var width = 356; var height = width; ContentContainer.Width = ContentContainer.MinWidth = ContentContainer.MaxWidth = width; ContentContainer.Height = ContentContainer.MinHeight = ContentContainer.MaxHeight = height; SetFixedSize(width, height); ContentContainer.AutoSizeMode = AutoSizeMode.None; Container.Anchor = Alignment.MiddleCenter; var bodyWrapper = new GuiContainer(); bodyWrapper.Anchor = Alignment.Fill; bodyWrapper.Padding = new Thickness(5, 0); bodyWrapper.AddChild(StackMenu); Container.AddChild(bodyWrapper); Container.AddChild(Header = new GuiStackContainer() { Anchor = Alignment.TopFill, ChildAnchor = Alignment.BottomCenter, Height = 32, Padding = new Thickness(3), Background = Color.Black * 0.5f }); Header.AddChild(new GuiTextElement() { Text = FixContrast(form.Title), TextColor = TextColor.White, Scale = 2f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.BottomCenter, }); StackMenu.Margin = new Thickness(0, Header.Height, 0, 0); }
public TitleState() { _backgroundSkyBox = new GuiPanoramaSkyBox(Alex); Background.Texture = _backgroundSkyBox; Background.RepeatMode = TextureRepeatMode.Stretch; MenuItem baseMenu = new MenuItem(MenuType.Menu) { Children = { new MenuItem() { Title = "menu.multiplayer", OnClick = MultiplayerButtonPressed, IsTranslatable = true }, new MenuItem(MenuType.SubMenu) { Title = "Debugging", IsTranslatable = false, Children = { new MenuItem() { Title = "Blockstates", OnClick = (sender, args) => { Debug(new DebugWorldGenerator()); } }, new MenuItem() { Title = "Demo", OnClick = (sender, args) => { Debug(new DemoGenerator()); } }, new MenuItem() { Title = "Flatland", OnClick = (sender, args) => { Debug(new FlatlandGenerator()); } }, new MenuItem() { Title = "Chunk Debug", OnClick = (sender, args) => { Debug(new ChunkDebugWorldGenerator()); } } } }, new MenuItem() { Title = "menu.options", OnClick = (sender, args) => { Alex.GameStateManager.SetActiveState("options"); }, IsTranslatable = true }, new MenuItem() { Title = "menu.quit", OnClick = (sender, args) => { Alex.Exit(); }, IsTranslatable = true }, } }; #region Create MainMenu _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }; ShowMenu(baseMenu); AddChild(_mainMenu); #endregion AddChild(new GuiImage(GuiTextures.AlexLogo) { Margin = new Thickness(95, 25, 0, 0), Anchor = Alignment.TopCenter }); AddChild(_splashText = new GuiTextElement() { TextColor = TextColor.Yellow, Rotation = 17.5f, Margin = new Thickness(240, 15, 0, 0), Anchor = Alignment.TopCenter, Text = "Who liek minecwaf?!", }); var guiItemStack = new GuiStackContainer() { Anchor = Alignment.CenterX | Alignment.CenterY, Orientation = Orientation.Vertical }; AddChild(guiItemStack); var row = new GuiStackContainer() { Orientation = Orientation.Horizontal, Anchor = Alignment.TopFill, ChildAnchor = Alignment.FillCenter, Margin = Thickness.One }; guiItemStack.AddChild(row); _playerProfileService = Alex.Services.GetService <IPlayerProfileService>(); _playerProfileService.ProfileChanged += PlayerProfileServiceOnProfileChanged; /*ScoreboardView scoreboardView; * AddChild(scoreboardView = new ScoreboardView()); * scoreboardView.Anchor = Alignment.MiddleRight; * * scoreboardView.AddString("Title"); * scoreboardView.AddRow("Key", "200"); * scoreboardView.AddRow("Key 2", "200");*/ }
//private GuiItem _guiItem; //private GuiItem _guiItem2; public TitleState() { _backgroundSkyBox = new GuiPanoramaSkyBox(Alex); Background.Texture = _backgroundSkyBox; Background.RepeatMode = TextureRepeatMode.Stretch; #region Create MainMenu _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }; _mainMenu.AddMenuItem("menu.multiplayer", JavaEditionButtonPressed, EnableMultiplayer, true); _mainMenu.AddMenuItem("menu.singleplayer", OnSinglePlayerPressed, true, true); _mainMenu.AddMenuItem("menu.options", () => { Alex.GameStateManager.SetActiveState("options"); }, true, true); _mainMenu.AddMenuItem("menu.quit", () => { Alex.Exit(); }, true, true); #endregion #region Create DebugMenu _debugMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _debugMenu.AddMenuItem("Debug Blockstates", DebugWorldButtonActivated); _debugMenu.AddMenuItem("Demo", DemoButtonActivated); _debugMenu.AddMenuItem("Debug Flatland", DebugFlatland); //_debugMenu.AddMenuItem("Debug Anvil", DebugAnvil); _debugMenu.AddMenuItem("Debug Chunk", DebugChunkButtonActivated); // _debugMenu.AddMenuItem("Debug XBL Login", BedrockEditionButtonPressed); _debugMenu.AddMenuItem("Go Back", DebugGoBackPressed); #endregion #region Create SPMenu _spMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _spMenu.AddMenuItem("SinglePlayer", () => {}, false); _spMenu.AddMenuItem("Debug Worlds", OnDebugPressed); _spMenu.AddMenuItem("Return to main menu", SpBackPressed); #endregion CreateProtocolMenu(); AddChild(_mainMenu); AddChild(new GuiImage(GuiTextures.AlexLogo) { Margin = new Thickness(95, 25, 0, 0), Anchor = Alignment.TopCenter }); AddChild(_splashText = new GuiTextElement() { TextColor = TextColor.Yellow, Rotation = 17.5f, Margin = new Thickness(240, 15, 0, 0), Anchor = Alignment.TopCenter, Text = "Who liek minecwaf?!", }); var guiItemStack = new GuiStackContainer() { Anchor = Alignment.CenterX | Alignment.CenterY, Orientation = Orientation.Vertical }; AddChild(guiItemStack); var row = new GuiStackContainer() { Orientation = Orientation.Horizontal, Anchor = Alignment.TopFill, ChildAnchor = Alignment.FillCenter, Margin = Thickness.One }; guiItemStack.AddChild(row); /*row.AddChild(_guiItem = new GuiItem() * { * Height = 24, * Width = 24, * Background = new Color(Color.Black, 0.2f) * }); * row.AddChild(_guiItem2 = new GuiItem() * { * Height = 24, * Width = 24, * Background = new Color(Color.Black, 0.2f) * }); */ /* guiItemStack.AddChild(new GuiVector3Control(() => _guiItem.Camera.Position, newValue => * { * if (_guiItem.Camera != null) * { * _guiItem.Camera.Position = newValue; * } * if(_guiItem2.Camera != null) * { * _guiItem2.Camera.Position = newValue; * } * }, 0.25f) * { * Margin = new Thickness(2) * });*/ // guiItemStack.AddChild(new GuiVector3Control(() => _guiItem.Camera.TargetPositionOffset, newValue => // { // if (_guiItem.Camera != null) // { // _guiItem.Camera.Target = newValue; // } // if(_guiItem2.Camera != null) // { // _guiItem2.Camera.Target = newValue; // } // }, 0.25f) // { // Margin = new Thickness(2) // }); _playerProfileService = Alex.Services.GetService <IPlayerProfileService>(); _playerProfileService.ProfileChanged += PlayerProfileServiceOnProfileChanged; }
public TitleState() { FpsMonitor = new FpsMonitor(); _backgroundSkyBox = new GuiPanoramaSkyBox(Alex); Background.Texture = _backgroundSkyBox; Background.RepeatMode = TextureRepeatMode.Stretch; #region Create MainMenu _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }; _mainMenu.AddMenuItem("Multiplayer", JavaEditionButtonPressed, EnableMultiplayer); _mainMenu.AddMenuItem("SinglePlayer", OnSinglePlayerPressed); _mainMenu.AddMenuItem("Options", () => { Alex.GameStateManager.SetActiveState("options"); }); _mainMenu.AddMenuItem("Exit", () => { Alex.Exit(); }); #endregion #region Create DebugMenu _debugMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _debugMenu.AddMenuItem("Debug Blockstates", DebugWorldButtonActivated); _debugMenu.AddMenuItem("Debug Flatland", DebugFlatland); //_debugMenu.AddMenuItem("Debug Anvil", DebugAnvil); _debugMenu.AddMenuItem("Debug Chunk", DebugChunkButtonActivated); // _debugMenu.AddMenuItem("Debug XBL Login", BedrockEditionButtonPressed); _debugMenu.AddMenuItem("Go Back", DebugGoBackPressed); #endregion #region Create SPMenu _spMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _spMenu.AddMenuItem("SinglePlayer", () => {}, false); _spMenu.AddMenuItem("Debug Worlds", OnDebugPressed); _spMenu.AddMenuItem("Return to main menu", SpBackPressed); #endregion CreateProtocolMenu(); AddChild(_mainMenu); AddChild(_logo = new GuiImage(GuiTextures.AlexLogo) { Margin = new Thickness(95, 25, 0, 0), Anchor = Alignment.TopCenter }); AddChild(_splashText = new GuiTextElement() { TextColor = TextColor.Yellow, Rotation = 17.5f, Margin = new Thickness(240, 15, 0, 0), Anchor = Alignment.TopCenter, Text = "Who liek minecwaf?!", }); _debugInfo = new GuiDebugInfo(); _debugInfo.AddDebugRight(() => $"GPU Memory: {API.Extensions.GetBytesReadable(GpuResourceManager.GetMemoryUsage)}"); _debugInfo.AddDebugLeft(() => $"FPS: {FpsMonitor.Value:F0}"); _playerProfileService = Alex.Services.GetService <IPlayerProfileService>(); _playerProfileService.ProfileChanged += PlayerProfileServiceOnProfileChanged; Alex.GameStateManager.AddState("options", new OptionsState(_backgroundSkyBox)); }