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 Alex(LaunchSettings launchSettings) { EntityProperty.Factory = new AlexPropertyFactory(); /*MiNET.Utils.DedicatedThreadPool fastThreadPool = * ReflectionHelper.GetPrivateStaticPropertyValue<MiNET.Utils.DedicatedThreadPool>( * typeof(MiNetServer), "FastThreadPool"); * * fastThreadPool?.Dispose(); * fastThreadPool?.WaitForThreadsExit(); * * ReflectionHelper.SetPrivateStaticPropertyValue<MiNET.Utils.DedicatedThreadPool>( * typeof(MiNetServer), "FastThreadPool", * new MiNET.Utils.DedicatedThreadPool( * new MiNET.Utils.DedicatedThreadPoolSettings(8, "MiNETServer Fast")));*/ ThreadPool.GetMaxThreads(out _, out var completionPortThreads); //ThreadPool.SetMaxThreads(Environment.ProcessorCount, completionPortThreads); Instance = this; LaunchSettings = launchSettings; OperatingSystem = $"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} ({System.Runtime.InteropServices.RuntimeInformation.OSArchitecture})"; DeviceManager = new GraphicsDeviceManager(this) { PreferMultiSampling = false, SynchronizeWithVerticalRetrace = false, GraphicsProfile = GraphicsProfile.Reach, }; DeviceManager.PreparingDeviceSettings += (sender, args) => { Gpu = args.GraphicsDeviceInformation.Adapter.Description; args.GraphicsDeviceInformation.PresentationParameters.DepthStencilFormat = DepthFormat.Depth24Stencil8; DeviceManager.PreferMultiSampling = true; }; Content = new StreamingContentManager(base.Services, "assets"); // Content.RootDirectory = "assets"; IsFixedTimeStep = false; // graphics.ToggleFullScreen(); this.Window.AllowUserResizing = true; this.Window.ClientSizeChanged += (sender, args) => { if (DeviceManager.PreferredBackBufferWidth != Window.ClientBounds.Width || DeviceManager.PreferredBackBufferHeight != Window.ClientBounds.Height) { if (DeviceManager.IsFullScreen) { DeviceManager.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; DeviceManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; } else { DeviceManager.PreferredBackBufferWidth = Window.ClientBounds.Width; DeviceManager.PreferredBackBufferHeight = Window.ClientBounds.Height; } DeviceManager.ApplyChanges(); //CefWindow.Size = new System.Drawing.Size(Window.ClientBounds.Width, Window.ClientBounds.Height); } }; JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { Converters = new List <JsonConverter>() { new Texture2DJsonConverter(GraphicsDevice) }, Formatting = Formatting.Indented }; ServerTypeManager = new ServerTypeManager(); PluginManager = new PluginManager(); Storage = new StorageSystem(LaunchSettings.WorkDir); Options = new OptionsProvider(Storage); IServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <Alex>(this); serviceCollection.AddSingleton <ContentManager>(Content); serviceCollection.AddSingleton <IStorageSystem>(Storage); serviceCollection.AddSingleton <IOptionsProvider>(Options); InitiatePluginSystem(serviceCollection); AudioEngine = new AudioEngine(Storage); ConfigureServices(serviceCollection); Services = serviceCollection.BuildServiceProvider(); PluginManager.Setup(Services); PluginManager.LoadPlugins(); ServerTypeManager.TryRegister("java", new JavaServerType(this)); ServerTypeManager.TryRegister( "bedrock", new BedrockServerType(this, Services.GetService <XboxAuthService>())); UIThreadQueue = new ConcurrentQueue <Action>(); FpsMonitor = new FpsMonitor(); Resources = Services.GetRequiredService <ResourceManager>(); // ThreadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount, // ThreadType.Background, "Dedicated ThreadPool")); KeyboardInputListener.InstanceCreated += KeyboardInputCreated; TextureUtils.RenderThread = Thread.CurrentThread; TextureUtils.QueueOnRenderThread = action => UIThreadQueue.Enqueue(action); }