public void SetPing(long ms) { _ping = ms; _isPending = false; if (!_isOutdated) { int index = 0; for (int i = _qualityStateTextures.Length - 1; i > 0; i--) { index = i; if (ms > QualityThresholds[i]) { break; } } GuiTexture2D bg = _qualityStateTextures[_qualityStateTextures.Length - index]; if (!bg.HasValue && GuiRenderer != null) { bg = GuiRenderer.GetTexture(QualityStates[QualityStates.Length - index]); } Background = bg; } }
protected BaseLoginState(string title, GuiPanoramaSkyBox skyBox) { Title = title; _backgroundSkyBox = skyBox; Background = new GuiTexture2D(_backgroundSkyBox, TextureRepeatMode.Stretch); BackgroundOverlay = Color.Transparent; Initialize(); }
public MultiplayerServerSelectionState(GuiPanoramaSkyBox skyBox) : base() { _skyBox = skyBox; CancellationTokenSource = new CancellationTokenSource(); _listProvider = GetService <IListStorageProvider <SavedServerEntry> >(); Title = "Multiplayer"; TitleTranslationKey = "multiplayer.title"; Footer.AddRow(row => { row.AddChild(JoinServerButton = new GuiButton("Join Server", OnJoinServerButtonPressed) { TranslationKey = "selectServer.select", Enabled = false }); row.AddChild(DirectConnectButton = new GuiButton("Direct Connect", () => Alex.GameStateManager.SetActiveState <MultiplayerConnectState>()) { TranslationKey = "selectServer.direct", Enabled = false }); row.AddChild(AddServerButton = new GuiButton("Add Server", OnAddItemButtonPressed) { TranslationKey = "selectServer.add" }); }); Footer.AddRow(row => { row.AddChild(EditServerButton = new GuiButton("Edit", OnEditItemButtonPressed) { TranslationKey = "selectServer.edit", Enabled = false }); row.AddChild(DeleteServerButton = new GuiButton("Delete", OnDeleteItemButtonPressed) { TranslationKey = "selectServer.delete", Enabled = false }); row.AddChild(new GuiButton("Refresh", OnRefreshButtonPressed) { TranslationKey = "selectServer.refresh" }); row.AddChild(new GuiBackButton() { TranslationKey = "gui.cancel" }); }); Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); }
public ProfileSelectionState(GuiPanoramaSkyBox skyBox, Alex alex) { Alex = alex; _skyBox = skyBox; ProfileService = GetService <IPlayerProfileService>(); Title = "Select Profile"; Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); base.ListContainer.ChildAnchor = Alignment.MiddleCenter; base.ListContainer.Orientation = Orientation.Horizontal; Footer.AddRow(row => { row.AddChild(_addBtn = new GuiButton("Add", AddClicked) { }); row.AddChild(_editBtn = new GuiButton("Edit", EditClicked) { Enabled = false }); row.AddChild(_deleteBtn = new GuiButton("Delete", DeleteClicked) { Enabled = false }); }); Footer.AddRow(row => { // row.ChildAnchor = Alignment.CenterX; row.AddChild(_selectBtn = new GuiButton("Select Profile", OnProfileSelect) { Enabled = false }); row.AddChild(_cancelBtn = new GuiButton("Cancel", OnCancelButtonPressed) { }); }); if (_defaultSkin == null) { Alex.Instance.Resources.ResourcePack.TryGetBitmap("entity/alex", out var rawTexture); _defaultSkin = new Skin() { Slim = true, Texture = TextureUtils.BitmapToTexture2D(Alex.Instance.GraphicsDevice, rawTexture) }; } Reload(); }
public BEDeviceCodeLoginState(GuiPanoramaSkyBox skyBox, Action <PlayerProfile> readyAction) { Title = "Bedrock Login"; AuthenticationService = GetService <XBLMSAService>(); _backgroundSkyBox = skyBox; Background = new GuiTexture2D(_backgroundSkyBox, TextureRepeatMode.Stretch); BackgroundOverlay = Color.Transparent; Ready = readyAction; ConnectResponse = AuthenticationService.StartDeviceAuthConnect().Result; Initialize(); }
public OptionsStateBase(GuiPanoramaSkyBox skyBox) { _skyBox = skyBox; _optionsProvider = GetService <IOptionsProvider>(); Footer.AddChild(new GuiBackButton() { TranslationKey = "gui.done", Anchor = Alignment.TopFill, Modern = false }); Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); }
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; CanUseClipboard = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); ConnectResponse = AuthenticationService.StartDeviceAuthConnect().Result; Initialize(); }
protected override void OnShow() { if (Alex.InGame) { Background = null; BackgroundOverlay = new Color(Color.Black, 0.65f); } else { Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); //BackgroundOverlay = null; } _optionsProvider.Load(); base.OnShow(); }
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 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 SkinSelectionState(GuiPanoramaSkyBox skyBox, Alex alex) { Alex = alex; _skyBox = skyBox; Storage = GetService <IStorageSystem>(); Title = "Select Skin"; Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); base.ListContainer.ChildAnchor = Alignment.MiddleCenter; base.ListContainer.Orientation = Orientation.Horizontal; Footer.AddRow(row => { // row.ChildAnchor = Alignment.CenterX; row.AddChild(_selectBtn = new GuiButton("Select Skin", OnSkinSelect) { Enabled = false }); row.AddChild(_cancelBtn = new GuiButton("Cancel", OnCancelButtonPressed) { }); }); Footer.AddRow(row => { row.ChildAnchor = Alignment.BottomCenter; row.AddChild(new GuiButton("Open SkinPack folder", OpenSkinPackFOlder, false) { Modern = true }); }); Reload(); }
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 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); }
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); }