Ejemplo n.º 1
0
        protected override void Initialized()
        {
            _playerProfileService = GetService <IPlayerProfileService>();
            _playerProfileService.Authenticate += PlayerProfileServiceOnAuthenticate;

            _profileManager = GetService <ProfileManager>();
            var profiles = _profileManager.GetProfiles("java");

            if (profiles.Length == 1)
            {
                _activeProfile = profiles[0];
            }
            //var javaProfiles = _profileManager.GetProfiles("java");

            if (_activeProfile != null)
            {
                NameInput.Value = _activeProfile.Username;
            }
            else
            {
                var activeProfile = _profileManager.LastUsedProfile;

                if (activeProfile != null)
                {
                    Requester.ClientToken = activeProfile.Profile.ClientToken;
                    NameInput.Value       = activeProfile.Profile.Username;
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadProfiles(IProgressReceiver progressReceiver)
        {
            IPlayerProfileService profileService = ServiceProvider.GetRequiredService <IPlayerProfileService>();
            IStorageSystem        storage        = ServiceProvider.GetRequiredService <IStorageSystem>();

            progressReceiver.UpdateProgress(0, StatusMessage);
            if (storage.TryReadJson(ProfilesFile, out ProfilesFileFormat saveFile))
            //if (File.Exists(ProfilesFile))
            {
                progressReceiver.UpdateProgress(50, StatusMessage);

                //	ProfilesFileFormat saveFile = null;
                SavedProfile[] profiles = null;


                progressReceiver.UpdateProgress(50, StatusMessage);

                if (saveFile != null)
                {
                    profiles = saveFile.Profiles;

                    if (!string.IsNullOrWhiteSpace(saveFile.SelectedProfile))
                    {
                        progressReceiver.UpdateProgress(75, StatusMessage);

                        foreach (var profile in profiles)
                        {
                            //profile.Profile.Type = profile.Type;// == ProfileType.Bedrock;
                            if (profile.Profile.Uuid.Equals(saveFile.SelectedProfile))
                            {
                                progressReceiver.UpdateProgress(90, StatusMessage);
                                LastUsedProfile = profile;
                                //profileService.TryAuthenticateAsync(profile.Profile);
                                //profileService.CurrentProfile = profile;
                                break;
                            }
                        }
                    }

                    progressReceiver.UpdateProgress(99, StatusMessage);
                    foreach (var profile in profiles)
                    {
                        Profiles.Add(profile.Profile.Uuid, profile);
                    }
                }
                else
                {
                    Log.Warn($"Profiles file not found.");
                }
            }
            else
            {
                storage.TryWriteJson(ProfilesFile, new ProfilesFileFormat());
                //	File.WriteAllText(ProfilesFile, JsonConvert.SerializeObject(new ProfilesFileFormat(), Formatting.Indented));
            }

            progressReceiver.UpdateProgress(100, StatusMessage);
        }
Ejemplo n.º 3
0
        public void SaveProfiles()
        {
            IPlayerProfileService profileService = Alex.Services.GetService <IPlayerProfileService>();

            Storage.TryWrite(ProfilesFile, new ProfilesFileFormat()
            {
                Profiles        = Profiles.Values.ToArray(),
                SelectedProfile = profileService?.CurrentProfile?.Uuid ?? string.Empty
            });
        }
Ejemplo n.º 4
0
        //private IHttpContextAccessor httpContextAccessor;


        public AccountController(UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager,
                                 AppDbContext dbContext, IUserScoreService userScoreService, IPlayerProfileService playerProfile)
        {
            this.userManager   = userManager;
            this.signInManager = signInManager;
            this.dbContext     = dbContext;
            _userScoreService  = userScoreService ?? throw new ArgumentNullException(nameof(userScoreService));
            _playerProfile     = playerProfile;
            //this.httpContextAccessor = httpContextAccessor;
        }
Ejemplo n.º 5
0
        public void SaveProfiles()
        {
            IPlayerProfileService profileService = ServiceProvider.GetRequiredService <IPlayerProfileService>();
            IStorageSystem        storage        = ServiceProvider.GetRequiredService <IStorageSystem>();

            //IPlayerProfileService profileService = Alex.Services.GetService<IPlayerProfileService>();
            storage.TryWriteJson(ProfilesFile, new ProfilesFileFormat()
            {
                Profiles        = Profiles.Values.ToArray(),
                SelectedProfile = profileService?.CurrentProfile?.Uuid ?? string.Empty
            });
        }
Ejemplo n.º 6
0
        protected override void Initialized()
        {
            _playerProfileService = Alex.Services.GetService <IPlayerProfileService>();
            _playerProfileService.Authenticate += PlayerProfileServiceOnAuthenticate;

            var activeProfile = Alex.ProfileManager.LastUsedProfile;

            if (activeProfile != null && activeProfile.Type == ProfileManager.ProfileType.Java)
            {
                Requester.ClientToken = activeProfile.Profile.ClientToken;
                NameInput.Value       = activeProfile.Profile.Username;
            }
        }
Ejemplo n.º 7
0
 public GameHub(IGameService gameService,
                IItemService itemService,
                ISummaryService summaryService,
                IRatingService ratingService,
                ICategoryService categoryService,
                IPlayerProfileService profileService,
                ILogger <GameHub> logger)
 {
     _gameService     = gameService;
     _itemService     = itemService;
     _summaryService  = summaryService;
     _ratingService   = ratingService;
     _profileService  = profileService;
     _categoryService = categoryService;
     _logger          = logger;
 }
Ejemplo n.º 8
0
        public void CreateOrUpdateProfile(string type, PlayerProfile profile, bool setActive = false)
        {
            IPlayerProfileService profileService = ServiceProvider.GetRequiredService <IPlayerProfileService>();
            var alex = ServiceProvider.GetRequiredService <Alex>();

            if (profile.Skin?.Texture == null)
            {
                profile.Skin = new Skin();

                if (alex.Resources.TryGetBitmap("entity/alex", out var rawTexture))
                {
                    profile.Skin.Texture = TextureUtils.BitmapToTexture2D(alex.GraphicsDevice, rawTexture);
                    profile.Skin.Slim    = true;
                }
            }
            SavedProfile savedProfile;

            if (Profiles.TryGetValue(profile.Uuid, out savedProfile))
            {
                savedProfile.Type      = type;
                savedProfile.Profile   = profile;
                Profiles[profile.Uuid] = savedProfile;
            }
            else
            {
                savedProfile         = new SavedProfile();
                savedProfile.Type    = type;
                savedProfile.Profile = profile;
                Profiles.Add(profile.Uuid, savedProfile);
            }

            if (setActive)
            {
                //ActiveProfile = savedProfile;
                profileService?.Force(profile);
                //_playerProfileService.Force(profile);
            }

            alex.UIThreadQueue.Enqueue(SaveProfiles);
        }
Ejemplo n.º 9
0
        protected override void Initialized()
        {
            _playerProfileService = GetService <IPlayerProfileService>();
            _playerProfileService.Authenticate += PlayerProfileServiceOnAuthenticate;

            _profileManager = GetService <ProfileManager>();

            if (_activeProfile != null && _activeProfile.Type == "java")
            {
                NameInput.Value = _activeProfile.Username;
            }
            else
            {
                var activeProfile = _profileManager.LastUsedProfile;

                if (activeProfile != null && activeProfile.Type == "java")
                {
                    Requester.ClientToken = activeProfile.Profile.ClientToken;
                    NameInput.Value       = activeProfile.Profile.Username;
                }
            }
        }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
 public UserProfilesController(IPlayerProfileService playerProfileService)
 {
     _playerProfileService = playerProfileService ?? throw new ArgumentNullException(nameof(playerProfileService));
 }
Ejemplo n.º 12
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");*/
        }
 public UserProfileController(IPlayerProfileService playerProfileService, ILogger logger)
 {
     _playerProfileService = playerProfileService ?? throw new ArgumentNullException(nameof(playerProfileService));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Ejemplo n.º 14
0
        //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;
        }
Ejemplo n.º 15
0
        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));
        }
Ejemplo n.º 16
0
 public PlayerProfilesController(IPlayerProfileService repository)
 {
     this.playerProfileService = repository;
 }
Ejemplo n.º 17
0
 public PlayerProfileController(IPlayerProfileService playerProfile, UserManager <IdentityUser> userManager)
 {
     _playerProfileService = playerProfile;
     _userManager          = userManager;
 }