public GuiConnectionPingIcon() : base() { Background = GuiTextures.ServerPing0; SetFixedSize(10, 8); _playerCountElement = new GuiTextElement(false) { //Font = renderer.Font, Text = string.Empty, Anchor = Alignment.TopRight, Margin = new Thickness(5, 0, Background.Width + 15, 0), // Enabled = false }; }
private GuiServerListEntryElement(IServerQueryProvider queryProvider, string serverName, string serverAddress) { QueryProvider = queryProvider; SetFixedSize(355, 36); ServerName = serverName; ServerAddress = serverAddress; Margin = new Thickness(5, 5, 5, 5); Padding = Thickness.One; Anchor = Alignment.TopFill; AddChild(_serverIcon = new GuiTextureElement() { Width = ServerIconSize, Height = ServerIconSize, Anchor = Alignment.TopLeft, Background = GuiTextures.DefaultServerIcon, }); AddChild(_pingStatus = new GuiConnectionPingIcon() { Anchor = Alignment.TopRight, }); AddChild(_textWrapper = new GuiStackContainer() { ChildAnchor = Alignment.TopFill, Anchor = Alignment.TopLeft }); _textWrapper.Padding = new Thickness(0, 0); _textWrapper.Margin = new Thickness(ServerIconSize + 5, 0, 0, 0); _textWrapper.AddChild(_serverName = new GuiTextElement() { Text = ServerName, Margin = Thickness.Zero }); _textWrapper.AddChild(_serverMotd = new GuiTextElement() { TranslationKey = "multiplayer.status.pinging", Margin = new Thickness(0, 0, 5, 0), //Anchor = center }); }
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 ScoreboardElement(string left, uint value) { Left = new GuiTextElement() { Text = left, Anchor = Alignment.TopLeft, Margin = new Thickness(0, 0, 2, 0) }; Right = new GuiTextElement() { Anchor = Alignment.TopRight, Text = value.ToString() }; AddChild(Left); AddChild(Right); }
public LoadingWorldState() { HeaderTitle.TranslationKey = "menu.loadingLevel"; _textDisplay = new GuiTextElement() { Text = Text, TextColor = TextColor.White, Anchor = Alignment.TopLeft, HasShadow = false }; _percentageDisplay = new GuiTextElement() { Text = Text, TextColor = TextColor.White, Anchor = Alignment.TopRight, HasShadow = false }; _progressBar = new GuiProgressBar() { Width = 300, Height = 9, Anchor = Alignment.BottomFill, }; var progContainer = new GuiContainer() { Width = 300, Height = 25, }; progContainer.AddChild(_textDisplay); progContainer.AddChild(_percentageDisplay); progContainer.AddChild(_progressBar); var progressRow = Footer.AddRow(progContainer); UpdateProgress(LoadingState.ConnectingToServer, 10); }
public DisconnectedScreen() { TitleTranslationKey = "multiplayer.disconnect.generic"; Body.ChildAnchor = Alignment.MiddleCenter; Body.AddChild(DisconnectedTextElement = new GuiTextElement() { Text = Reason, TextColor = TextColor.Red, Anchor = Alignment.MiddleCenter }); Footer.AddChild(new GuiButton(MenuButtonClicked) { TranslationKey = "gui.toTitle", Anchor = Alignment.MiddleCenter, Modern = false }); }
public MultiplayerConnectState() { Title = "Connect to Server"; AddGuiElement(_hostnameInput = new GuiTextInput() { Width = 200, Anchor = Alignment.MiddleCenter, PlaceHolder = "Server Address..." }); AddGuiElement(_connectButton = new GuiButton("Join Server", OnConnectButtonPressed) { Margin = new Thickness(5) }); AddGuiElement(_errorMessage = new GuiTextElement() { TextColor = TextColor.Red }); }
public ScoreboardObjective(string name, string displayName, int sortOrder, string criteriaName) { _displayNameElement = new GuiTextElement(displayName) { Anchor = Alignment.CenterX }; Entries = new ConcurrentDictionary <string, ScoreboardEntry>(); Name = name; DisplayName = displayName; SortOrder = sortOrder; CriteriaName = criteriaName; ChildAnchor = Alignment.Fill; _container = new GuiContainer(); _container.AddChild(_displayNameElement); AddChild(_container); }
public BedrockLoginState(GuiPanoramaSkyBox skyBox, Action <PlayerProfile> readyAction, XboxAuthService xboxAuthService) { Title = "Bedrock Login"; AuthenticationService = xboxAuthService; _backgroundSkyBox = skyBox; Background = new GuiTexture2D(_backgroundSkyBox, TextureRepeatMode.Stretch); BackgroundOverlay = Color.Transparent; Ready = readyAction; _authCodeElement = new GuiTextElement() { TextColor = TextColor.Cyan, Text = "Please wait...\nStarting authentication process...", FontStyle = FontStyle.Italic, Scale = 1.1f }; CanUseClipboard = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); Initialize(); }
public GuiInventoryBase(InventoryBase inventory, GuiTextures background, int width, int height) { Inventory = inventory; ContentContainer.Background = background; ContentContainer.BackgroundOverlay = null; ContentContainer.Width = ContentContainer.MinWidth = ContentContainer.MaxWidth = width; ContentContainer.Height = ContentContainer.MinHeight = ContentContainer.MaxHeight = height; SetFixedSize(width, height); ContentContainer.AutoSizeMode = AutoSizeMode.None; AddChild( TextOverlay = new GuiTextElement(true) { HasShadow = true, Background = new Color(Color.Black, 0.35f), Enabled = false, FontStyle = FontStyle.DropShadow, TextColor = TextColor.Yellow, ClipToBounds = false, Anchor = Alignment.TopLeft //BackgroundOverlay = new Color(Color.Black, 0.35f), }); AddChild(CursorItemRenderer = new GuiItem() { IsVisible = false, ClipToBounds = false, AutoSizeMode = AutoSizeMode.None, Height = 18, Width = 18, Anchor = Alignment.TopLeft }); Inventory.SlotChanged += InventoryOnSlotChanged; Inventory.CursorChanged += InventoryOnCursorChanged; }
public InventoryContainerItem() { SetFixedSize(16, 16); Padding = new Thickness(0); // AddChild(TextureElement = new GuiTextureElement() // { // Anchor = Alignment.Fill // }); AddChild(GuiItem = new GuiItem() { Anchor = Alignment.MiddleCenter, Height = 18, Width = 18, }); /* AddChild(_counTextElement = new GuiTextElement() * { * TextColor = TextColor.White, * Anchor = Alignment.BottomRight, * Text = "", * Scale = 0.75f, * Margin = new Thickness(0, 0, 1, 1), * FontStyle = FontStyle.DropShadow, * CanHighlight = false, * CanFocus = false * });*/ GuiItem.AddChild(_counTextElement = new GuiTextElement() { TextColor = TextColor.White, Anchor = Alignment.BottomRight, Text = "", Scale = 0.75f, Margin = new Thickness(0, 0, 1, 1), FontStyle = FontStyle.DropShadow, //CanHighlight = false, // CanFocus = false }); }
protected override void OnInit(IGuiRenderer renderer) { AddGuiRow( ProcessingThreads = CreateSlider("Processing Threads: {0}", o => Options.NetworkOptions.NetworkThreads, 1, Environment.ProcessorCount, 1)); AddDescription(ProcessingThreads, "Processing Threads", "The amount of threads that get assigned to datagram processing", "Note: A restart is required for this setting to take affect."); Description = new GuiTextElement() { Anchor = Alignment.MiddleLeft, Margin = new Thickness(5, 15, 5, 5), MinHeight = 80 }; var row = AddGuiRow(Description); row.ChildAnchor = Alignment.MiddleLeft; base.OnInit(renderer); }
public TitleComponent() { Anchor = Alignment.MiddleFill; Orientation = Orientation.Vertical; _title = new GuiTextElement() { //Anchor = Alignment.TopCenter, TextColor = TextColor.White, FontStyle = FontStyle.DropShadow, Scale = 2f, Text = "" }; _subTitle = new GuiTextElement() { //Anchor = Alignment.MiddleCenter, TextColor = TextColor.White, FontStyle = FontStyle.None, Scale = 1f, Text = "" }; }
public GuiGameStateBase() { GuiTextElement cc; AddChild(cc = new GuiTextElement() { Anchor = Alignment.BottomLeft, Text = "github.com/kennyvv/Alex", TextColor = TextColor.White, TextOpacity = 0.5f, Scale = 0.5f, Margin = new Thickness(5, 0, 0, 5) }); AddChild(new GuiTextElement() { Anchor = Alignment.BottomRight, Text = "Not affiliated with Mojang/Minecraft", TextColor = TextColor.White, TextOpacity = 0.5f, Scale = 0.5f, Margin = new Thickness(0, 0, 5, 5) }); }
public GuiInventoryItem() { Height = 18; Width = 18; AddChild(Texture = new GuiTextureElement() { Anchor = Alignment.TopLeft, Height = 16, Width = 16, Margin = new Thickness(4, 4) }); AddChild(_counTextElement = new GuiTextElement() { TextColor = TextColor.White, Anchor = Alignment.BottomRight, Text = "", Scale = 0.75f, Margin = new Thickness(0, 0, 5, 3) }); }
protected override void OnInit(IGuiRenderer renderer) { base.OnInit(renderer); _offlineTexture = renderer.GetTexture(_offlineState); for (int i = 0; i < _qualityStates.Length; i++) { _qualityStateTextures[i] = renderer.GetTexture(_qualityStates[i]); } for (int i = 0; i < _connectingStates.Length; i++) { _connectingStateTextures[i] = renderer.GetTexture(_connectingStates[i]); } AddChild(_playerCountElement = new GuiTextElement(false) { Font = renderer.Font, Text = string.Empty, Anchor = Alignment.TopRight, Margin = new Thickness(5, 0, Background.Width + 15, 0) }); }
private void Initialize() { base.HeaderTitle.Anchor = Alignment.MiddleCenter; base.HeaderTitle.FontStyle = FontStyle.Bold | FontStyle.DropShadow; Footer.ChildAnchor = Alignment.MiddleCenter; GuiTextElement t; Footer.AddChild(t = new GuiTextElement() { Text = "We are NOT in anyway or form affiliated with Mojang/Minecraft or Microsoft!", TextColor = TextColor.Yellow, Scale = 1f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.MiddleCenter }); GuiTextElement info; Footer.AddChild(info = new GuiTextElement() { Text = "We will never collect/store or do anything with your data.", TextColor = TextColor.Yellow, Scale = 0.8f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.MiddleCenter, Padding = new Thickness(0, 5, 0, 0) }); /* * "We will never collect/store or do anything with your data.\n" + * "You can read more about the authentication method we use on here: https://wiki.vg/Authentication" */ Body.BackgroundOverlay = new Color(Color.Black, 0.5f); Body.ChildAnchor = Alignment.MiddleCenter; var usernameRow = AddGuiRow(new GuiTextElement() { Text = "Username:"******"Username...", Margin = new Thickness(5), }); usernameRow.ChildAnchor = Alignment.MiddleCenter; var passwordRow = AddGuiRow(new GuiTextElement() { Text = "Password:"******"Password...", Margin = new Thickness(5), IsPasswordInput = true }); passwordRow.ChildAnchor = Alignment.MiddleCenter; var buttonRow = AddGuiRow(LoginButton = new GuiButton(OnLoginButtonPressed) { AccessKey = Keys.Enter, Text = "Login", Margin = new Thickness(5), Modern = false, Width = 100 }, new GuiButton(OnCancelButtonPressed) { AccessKey = Keys.Escape, TranslationKey = "gui.cancel", Margin = new Thickness(5), Modern = false, Width = 100 }); buttonRow.ChildAnchor = Alignment.MiddleCenter; AddGuiElement(ErrorMessage = new GuiTextElement() { TextColor = TextColor.Yellow }); Initialized(); }
protected override void OnInit(IGuiRenderer renderer) { AddGuiRow( RenderDistance = CreateSlider("Render Distance: {0} chunks", o => Options.VideoOptions.RenderDistance, 2, 32, 1), GuiScaleGlider = CreateSlider(v => $"GUI Scale: {((int) v == 0 ? "Auto" : v.ToString("0"))}", options => options.VideoOptions.GuiScale, 0, 3, 1)); AddGuiRow( ProcessingThreads = CreateSlider("Processing Threads: {0}", o => Options.VideoOptions.ChunkThreads, 1, Environment.ProcessorCount, 1), Brightness = CreateSlider("Brightness: {0}%", o => Options.VideoOptions.Brightness, 0, 100, 1)); AddGuiRow(Antialiasing = CreateSlider(v => { string subText = $"x{v:0}"; return($"Antialiasing: {((int) v == 0 ? "Disabled" : subText)}"); }, options => options.VideoOptions.Antialiasing, 0, 16, 2)); AddGuiRow( FrameRateLimiter = CreateToggle("Limit Framerate: {0}", options => options.VideoOptions.LimitFramerate), FpsSlider = CreateSlider($"{GuiRenderer.GetTranslation("options.framerateLimit")}: {{0}} fps", o => Options.VideoOptions.MaxFramerate, 1, 120, 1)); AddGuiRow( VSync = CreateToggle($"{GuiRenderer.GetTranslation("options.vsync")}: {{0}}", o => { return(Options.VideoOptions.UseVsync); }), Fullscreen = CreateToggle("Fullscreen: {0}", o => { return(Options.VideoOptions.Fullscreen); })); AddGuiRow(Depthmap = CreateToggle("Use DepthMap: {0}", options => options.VideoOptions.Depthmap), Minimap = CreateToggle("Minimap: {0}", options => options.VideoOptions.Minimap)); AddGuiRow(Skybox = CreateToggle("Render Skybox: {0}", options => options.VideoOptions.Skybox), CustomSkins = CreateToggle("Custom entity models: {0}", options => options.VideoOptions.CustomSkins)); AddGuiRow( ClientSideLighting = CreateToggle( "Client Side Lighting: {0}", options => options.VideoOptions.ClientSideLighting), SmoothLighting = CreateToggle("Smooth Lighting: {0}", o => o.VideoOptions.SmoothLighting)); AddGuiRow( ChunkMeshInRam = CreateToggle("Meshes in RAM: {0}", options => options.MiscelaneousOptions.MeshInRam), new GuiElement()); Description = new GuiTextElement() { Anchor = Alignment.MiddleLeft, Margin = new Thickness(5, 15, 5, 5), MinHeight = 80 }; var row = AddGuiRow(Description); row.ChildAnchor = Alignment.MiddleLeft; Descriptions.Add(RenderDistance, $"{TextColor.Bold}Render Distance:{TextColor.Reset}\n{TextColor.Red}High values may decrease performance significantly!\n"); Descriptions.Add(ProcessingThreads, $"{TextColor.Bold}Processing Threads:{TextColor.Reset}\nThe maximum amount of concurrent chunk updates to execute.\nIf you are experiencing lag spikes, try lowering this value."); Descriptions.Add(Minimap, $"{TextColor.Bold}Minimap:{TextColor.Reset}\nIf enabled, renders a minimap in the top right corner of the screen.\nMay impact performance heavily."); Descriptions.Add(Depthmap, $"{TextColor.Bold}Use DepthMap:{TextColor.Reset}\n{TextColor.Bold}{TextColor.Red}EXPERIMENTAL FEATURE{TextColor.Reset}\nHeavy performance impact"); Descriptions.Add(Skybox, $"{TextColor.Bold}Render Skybox:{TextColor.Reset}\nEnabled: Renders skybox in game\nDisabled: May improve performance slightly"); Descriptions.Add(Antialiasing, $"{TextColor.Bold}Antialiasing:{TextColor.Reset}\nImproves sharpness on textures\nMay significantly impact performance on lower-end hardware"); Descriptions.Add(FrameRateLimiter, $"{TextColor.Bold}Limit Framerate:{TextColor.Reset}\nLimit the framerate to value set in Max Framerate slider\n"); Descriptions.Add(FpsSlider, $"{TextColor.Bold}Max Framerate:{TextColor.Reset}\nOnly applies if Limit Framerate is set to true\nLimit's the game's framerate to set value."); Descriptions.Add(VSync, $"{TextColor.Bold}Use VSync:{TextColor.Reset}\nEnabled: Synchronizes the framerate with the monitor's refresh rate.\n"); Descriptions.Add(CustomSkins, $"{TextColor.Bold}Custom entity models:{TextColor.Reset}\nEnabled: Shows custom entity models. May impact performance heavily!\nDisabled: Do not show custom models, may improve performance."); Descriptions.Add(ClientSideLighting, $"{TextColor.Bold}Client Side Lighting:{TextColor.Reset}\nEnabled: Calculate lighting on the client.\nDisabled: May improve chunk loading performance"); Descriptions.Add(ChunkMeshInRam, $"{TextColor.Bold}Meshes in RAM:{TextColor.Reset}\nEnabled: May significantly improve chunk processing performance (High memory usage)\nDisabled: Do not keep chunks meshes in memory (Lower memory usage)"); Descriptions.Add(SmoothLighting, $"{TextColor.Bold}Smooth Lighting:{TextColor.Reset}\nEnabled: Smoother transition in lighting.\nDisabled: May improve chunk loading performance"); base.OnInit(renderer); }
public MultiplayerAddEditServerState(string serverType, string name, string address, Action <AddOrEditCallback> callbackAction, GuiPanoramaSkyBox skyBox) : base(callbackAction) { _serverTypeManager = GetService <ServerTypeManager>(); _skyBox = skyBox; Title = "Add Server"; TitleTranslationKey = "addServer.title"; base.HeaderTitle.Anchor = Alignment.MiddleCenter; base.HeaderTitle.FontStyle = FontStyle.Bold | FontStyle.DropShadow; Body.BackgroundOverlay = new Color(Color.Black, 0.5f); Body.ChildAnchor = Alignment.MiddleCenter; var usernameRow = AddGuiRow(new GuiTextElement() { Text = "Server Name:", TranslationKey = "addServer.enterName", Margin = new Thickness(0, 0, 5, 0) }, _nameInput = new GuiTextInput() { TabIndex = 1, Width = 200, PlaceHolder = "Name of the server", Margin = new Thickness(23, 5, 5, 5), }); usernameRow.ChildAnchor = Alignment.MiddleCenter; usernameRow.Orientation = Orientation.Horizontal; var hostnameRow = AddGuiRow(new GuiTextElement() { Text = "Server Address:", TranslationKey = "addServer.enterIp", Margin = new Thickness(0, 0, 5, 0) }, _hostnameInput = new GuiTextInput() { TabIndex = 2, Width = 200, PlaceHolder = "Hostname or IP", Margin = new Thickness(5), }); hostnameRow.ChildAnchor = Alignment.MiddleCenter; hostnameRow.Orientation = Orientation.Horizontal; var typeLabelRow = AddGuiRow(_serverTypeLabel = new GuiTextElement() { Text = "Server Type:", Margin = new Thickness(0, 0, 5, 0) }); typeLabelRow.ChildAnchor = Alignment.MiddleCenter; typeLabelRow.Orientation = Orientation.Horizontal; AddGuiRow(_serverTypeGroup = new GuiButtonGroup() { Orientation = Orientation.Horizontal, ChildAnchor = Alignment.MiddleCenter }); int tabIndex = 3; foreach (var type in _serverTypeManager.GetAll()) { if (_selectedImplementation == null) { _selectedImplementation = type; } GuiToggleButton element; _serverTypeGroup.AddChild( element = new GuiToggleButton(type.DisplayName) { Margin = new Thickness(5), Modern = true, Width = 50, Checked = serverType == type.Id, CheckedOutlineThickness = new Thickness(1), DisplayFormat = new ValueFormatter <bool>((val) => $"{type.DisplayName} {(val ? "[Active]" : "")}"), TabIndex = tabIndex++ }); element.ValueChanged += (sender, value) => { if (value) { _selectedImplementation = type; } }; } var buttonRow = AddGuiRow(_saveButton = new GuiButton(OnSaveButtonPressed) { AccessKey = Keys.Enter, TranslationKey = "addServer.add", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 5 }, new GuiButton(OnCancelButtonPressed) { AccessKey = Keys.Escape, TranslationKey = "gui.cancel", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 6 }); buttonRow.ChildAnchor = Alignment.MiddleCenter; AddGuiElement(_errorMessage = new GuiTextElement() { TextColor = TextColor.Red }); if (!string.IsNullOrWhiteSpace(name)) { _nameInput.Value = name; } if (!string.IsNullOrWhiteSpace(address)) { _hostnameInput.Value = address; } if (_entry != null) { //EnableButtonsFor(_entry.ServerType); } Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); }
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)); }
//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 GuiPlayerInventoryDialog(Player player, Inventory inventory) { Player = player; Inventory = inventory; // Subscribe to events _guiHotBarInventoryItems = new InventoryContainerItem[inventory?.SlotCount ?? 0]; if (_guiHotBarInventoryItems.Length != 46) { throw new ArgumentOutOfRangeException(nameof(inventory), inventory?.SlotCount ?? 0, "Expected player inventory containing 46 slots."); } ContentContainer.Background = GuiTextures.InventoryPlayerBackground; ContentContainer.Width = ContentContainer.MinWidth = ContentContainer.MaxWidth = 176; ContentContainer.Height = ContentContainer.MinHeight = ContentContainer.MaxHeight = 166; SetFixedSize(176, 166); ContentContainer.AutoSizeMode = AutoSizeMode.None; AddChild(_debug = new GuiAutoUpdatingTextElement(() => { if (base.GuiRenderer == null) { return(""); } var position = Mouse.GetState().Position; return($"Cursor: {position}"); }, true) { Background = new Color(Color.Black, 0.35f), Anchor = Alignment.TopCenter, Margin = new Thickness(0, 0, 0, 200) }); var texture = player.ModelRenderer.Texture; if (texture == null) { } var modelRenderer = player.ModelRenderer; var mob = new PlayerMob(player.Name, player.Level, player.Network, player.ModelRenderer.Texture, true) { ModelRenderer = modelRenderer, }; ContentContainer.AddChild(_playerEntityModelView = new GuiEntityModelView(mob) { Margin = new Thickness(7, 25), Width = 49, Height = 70, Anchor = Alignment.TopLeft, AutoSizeMode = AutoSizeMode.None, Background = null, BackgroundOverlay = null }); int lx = 7, ly = 83; int idx = 9; Color color = Color.Blue; for (int y = 0; y < 4; y++) { for (int x = 0; x < 9; x++) { var item = new InventoryContainerItem() { Item = Inventory[idx], HighlightedBackground = new Microsoft.Xna.Framework.Color(color, 0.5f), Anchor = Alignment.TopLeft, AutoSizeMode = AutoSizeMode.None, // Name = idx.ToString(), Margin = new Thickness(lx, ly, 0, 0) }; _guiHotBarInventoryItems[idx] = item; ContentContainer.AddChild(item); idx++; lx += item.Width; } lx = 7; if (idx == 36) { idx = 0; ly = 141; color = Color.GreenYellow; } else { ly += _guiHotBarInventoryItems[idx - 1].Height; } } lx = 7; ly = 7; for (int i = 0; i < 4; i++) { var element = new InventoryContainerItem() { HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Red, 0.5f), Anchor = Alignment.TopLeft, Margin = new Thickness(ly, lx), AutoSizeMode = AutoSizeMode.None, //Item = Inventory[] }; ContentContainer.AddChild(element); ly += element.Height; } var shieldSlot = new InventoryContainerItem() { HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Orange, 0.5f), Anchor = Alignment.TopLeft, Margin = new Thickness(61, 76), AutoSizeMode = AutoSizeMode.None }; ContentContainer.AddChild(shieldSlot); AddChild(TextOverlay = new GuiTextElement(true) { HasShadow = true, Background = new Color(Color.Black, 0.35f), Enabled = false, FontStyle = FontStyle.DropShadow, TextColor = TextColor.Yellow, ClipToBounds = false, //BackgroundOverlay = new Color(Color.Black, 0.35f), }); foreach (var child in ContentContainer.ChildElements.Where(x => x is InventoryContainerItem).Cast <InventoryContainerItem>()) { child.CursorPressed += InventoryItemPressed; child.CursorEnter += ChildOnCursorEnter; child.CursorLeave += ChildOnCursorLeave; } }
public MultiplayerAddEditServerState(ServerType serverType, string name, string address, Action <SavedServerEntry> callbackAction, GuiPanoramaSkyBox skyBox) : base(callbackAction) { _savedServersStorage = GetService <IListStorageProvider <SavedServerEntry> >(); _skyBox = skyBox; Title = "Add Server"; TitleTranslationKey = "addServer.title"; base.HeaderTitle.Anchor = Alignment.MiddleCenter; base.HeaderTitle.FontStyle = FontStyle.Bold | FontStyle.DropShadow; Body.BackgroundOverlay = new Color(Color.Black, 0.5f); Body.ChildAnchor = Alignment.MiddleCenter; var usernameRow = AddGuiRow(new GuiTextElement() { Text = "Server Name:", TranslationKey = "addServer.enterName", Margin = new Thickness(0, 0, 5, 0) }, _nameInput = new GuiTextInput() { TabIndex = 1, Width = 200, PlaceHolder = "Name of the server", Margin = new Thickness(23, 5, 5, 5), }); usernameRow.ChildAnchor = Alignment.MiddleCenter; usernameRow.Orientation = Orientation.Horizontal; var hostnameRow = AddGuiRow(new GuiTextElement() { Text = "Server Address:", TranslationKey = "addServer.enterIp", Margin = new Thickness(0, 0, 5, 0) }, _hostnameInput = new GuiTextInput() { TabIndex = 2, Width = 200, PlaceHolder = "Hostname or IP", Margin = new Thickness(5), }); hostnameRow.ChildAnchor = Alignment.MiddleCenter; hostnameRow.Orientation = Orientation.Horizontal; var typeLabelRow = AddGuiRow(_serverTypeLabel = new GuiTextElement() { Text = "Server Type:", Margin = new Thickness(0, 0, 5, 0) }); typeLabelRow.ChildAnchor = Alignment.MiddleCenter; typeLabelRow.Orientation = Orientation.Horizontal; AddGuiRow(_serverTypeGroup = new GuiButtonGroup() { Orientation = Orientation.Horizontal, ChildAnchor = Alignment.MiddleCenter }); _serverTypeGroup.AddChild(_javaEditionButton = new GuiToggleButton("Java") { Margin = new Thickness(5), Modern = true, Width = 50, Checked = serverType == ServerType.Java, CheckedOutlineThickness = new Thickness(1), DisplayFormat = new ValueFormatter <bool>((val) => $"Java {(val ? "[Active]" : "")}"), TabIndex = 3 }); _serverTypeGroup.AddChild(_bedrockEditionButton = new GuiToggleButton("Bedrock") { Margin = new Thickness(5), Modern = true, Width = 50, Checked = serverType == ServerType.Bedrock, CheckedOutlineThickness = new Thickness(1), DisplayFormat = new ValueFormatter <bool>((val) => $"Bedrock {(val ? "[Active]" : "")}"), TabIndex = 4 }); // var portRow = AddGuiRow(); // portRow.ChildAnchor = Alignment.MiddleCenter; var buttonRow = AddGuiRow(_saveButton = new GuiButton(OnSaveButtonPressed) { AccessKey = Keys.Enter, TranslationKey = "addServer.add", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 5 }, new GuiButton(OnCancelButtonPressed) { AccessKey = Keys.Escape, TranslationKey = "gui.cancel", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 6 }); buttonRow.ChildAnchor = Alignment.MiddleCenter; AddGuiElement(_errorMessage = new GuiTextElement() { TextColor = TextColor.Red }); if (!string.IsNullOrWhiteSpace(name)) { _nameInput.Value = name; } if (!string.IsNullOrWhiteSpace(address)) { _hostnameInput.Value = address; } if (_entry != null) { //EnableButtonsFor(_entry.ServerType); } Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); }
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 void Initialize() { _playerProfileService = GetService <IPlayerProfileService>(); _playerProfileService.Authenticate += PlayerProfileServiceOnAuthenticate; base.HeaderTitle.Anchor = Alignment.MiddleCenter; base.HeaderTitle.FontStyle = FontStyle.Bold | FontStyle.DropShadow; Footer.ChildAnchor = Alignment.MiddleCenter; GuiTextElement t; Footer.AddChild(t = new GuiTextElement() { Text = "We are NOT in anyway or form affiliated with Mojang/Minecraft or Microsoft!", TextColor = TextColor.Yellow, Scale = 1f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.MiddleCenter }); GuiTextElement info; Footer.AddChild(info = new GuiTextElement() { Text = "We will never collect/store or do anything with your data.", TextColor = TextColor.Yellow, Scale = 0.8f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.MiddleCenter, Padding = new Thickness(0, 5, 0, 0) }); Body.BackgroundOverlay = new Color(Color.Black, 0.5f); Body.ChildAnchor = Alignment.MiddleCenter; Body.AddChild(_authCodeElement); //ShowCode(); if (CanUseClipboard) { AddGuiElement(new GuiTextElement() { Text = $"If you click Sign-In, the above auth code will be copied to your clipboard!" }); } var buttonRow = AddGuiRow(LoginButton = new GuiButton(OnLoginButtonPressed) { AccessKey = Keys.Enter, Text = "Sign-In with Xbox", Margin = new Thickness(5), Modern = false, Width = 100, Enabled = ConnectResponse != null }, new GuiButton(OnCancelButtonPressed) { AccessKey = Keys.Escape, TranslationKey = "gui.cancel", Margin = new Thickness(5), Modern = false, Width = 100 }); buttonRow.ChildAnchor = Alignment.MiddleCenter; }
public LoadingWorldState(IGameState parent = null) { GuiStackContainer progressBarContainer; AddChild(progressBarContainer = new GuiStackContainer() { //Width = 300, //Height = 35, //Margin = new Thickness(12), Anchor = Alignment.MiddleCenter, Background = Color.Transparent, BackgroundOverlay = Color.Transparent, Orientation = Orientation.Vertical }); if (parent == null) { Background = new GuiTexture2D { TextureResource = GuiTextures.OptionsBackground, RepeatMode = TextureRepeatMode.Tile, Scale = new Vector2(2f, 2f), }; BackgroundOverlay = new Color(Color.Black, 0.65f); } else { ParentState = parent; HeaderTitle.IsVisible = false; } progressBarContainer.AddChild(_textDisplay = new GuiTextElement() { Text = Text, TextColor = TextColor.White, Anchor = Alignment.TopCenter, HasShadow = false, Scale = 1.5f }); GuiElement element; progressBarContainer.AddChild(element = new GuiElement() { Width = 300, Height = 35, Margin = new Thickness(12), }); element.AddChild(_percentageDisplay = new GuiTextElement() { Text = Text, TextColor = TextColor.White, Anchor = Alignment.TopRight, HasShadow = false }); element.AddChild(_progressBar = new GuiProgressBar() { Width = 300, Height = 9, Anchor = Alignment.MiddleCenter, }); progressBarContainer.AddChild( _subTextDisplay = new GuiTextElement() { Text = Text, TextColor = TextColor.White, Anchor = Alignment.BottomLeft, HasShadow = false }); HeaderTitle.TranslationKey = "menu.loadingLevel"; UpdateProgress(LoadingState.ConnectingToServer, 10); }