Exemple #1
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var decodedPass = MachineCrypto.ValidatedDecode(ClientSettings.Default.UI_EnteredPassword) ?? string.Empty;

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the login fields
            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Name:");
            _cNameText = new TextBox(cScreen, new Vector2(220, 260), new Vector2(200, 40))
            { IsMultiLine = false, Text = ClientSettings.Default.UI_EnteredUserName };
            _cNameText.KeyPressed += cNameText_KeyPressed;
            _cNameText.TextChanged += cNameText_TextChanged;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 320), "Password:"******"Remember Password",
                Value = ClientSettings.Default.UI_RememberPassword,
                ForeColor = Color.White,
                Font = GameScreenHelper.DefaultChatFont
            };
            _cRememberPassword.ValueChanged += _cRememberPassword_ValueChanged;

            // NOTE: Display the admin account info
            const string adminAccountInfo =
                "Use the following account for the default admin account:" + "\n    Username: Spodi" + "\n    Password: qwerty123";
            new Label(cScreen, _cRememberPassword.Position + new Vector2(-32, _cRememberPassword.Size.Y + 32))
            { Text = adminAccountInfo, ForeColor = Color.Green, Font = GameScreenHelper.DefaultChatFont };

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Login", "Back");
            _btnLogin = menuButtons["Login"];
            _btnLogin.Clicked += _btnLogin_Clicked;
            menuButtons["Back"].Clicked += LoginScreen_Clicked;

            cScreen.SetFocus();

            // Set up the networking stuff for this screen
            _sockets = ClientSockets.Instance;
            _sockets.StatusChanged -= _sockets_StatusChanged;
            _sockets.StatusChanged += _sockets_StatusChanged;
            _sockets.PacketHandler.ReceivedLoginSuccessful += PacketHandler_ReceivedLoginSuccessful;
            _sockets.PacketHandler.ReceivedLoginUnsuccessful += PacketHandler_ReceivedLoginUnsuccessful;
        }
Exemple #2
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Login", "New Account", "Options", "Quit");

            menuButtons["Login"].Clicked += delegate { ScreenManager.SetScreen<LoginScreen>(); };
            menuButtons["New Account"].Clicked += delegate { ScreenManager.SetScreen<NewAccountScreen>(); };
            menuButtons["Options"].Clicked += delegate { ScreenManager.SetScreen<OptionsScreen>(); };
            menuButtons["Quit"].Clicked += delegate { ScreenManager.Game.Dispose(); };
        }
Exemple #3
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            _menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Accept", "Cancel");
            _menuButtons["Accept"].Clicked += accept_Clicked;
            _menuButtons["Cancel"].Clicked += cancel_Clicked;

            // Create the options
            var pos = new Vector2(60, 180);
            var lblSound = GameScreenHelper.CreateMenuLabel(cScreen, pos, "Sound (0 to 100):");
            _txtSound = new TextBox(cScreen, pos + new Vector2(lblSound.Size.X + 10, -6), 
                new Vector2(128, lblSound.ClientSize.Y + 4)) { AllowKeysHandler = TextEventArgsFilters.IsDigitFunc };

            pos.Y += _txtSound.Size.Y + 16;
            var lblMusic = GameScreenHelper.CreateMenuLabel(cScreen, pos, "Music (0 to 100):");
            _txtMusic = new TextBox(cScreen, pos + new Vector2(lblMusic.Size.X + 10, -6), 
                new Vector2(128, lblMusic.ClientSize.Y + 4)) { AllowKeysHandler = TextEventArgsFilters.IsDigitFunc };
        }
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Create character", "Back");
            _btnCreateCharacter = menuButtons["Create character"];
            _btnCreateCharacter.Clicked += ClickButton_CreateCharacter;
            menuButtons["Back"].Clicked += ClickButton_Back;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Name:");

            _txtName = new TextBox(cScreen, new Vector2(220, 260), new Vector2(200, 40))
            { IsMultiLine = false, Text = "", IsEnabled = true };

            var textBoxPos = new Vector2(60, _txtName.Position.Y + _txtName.Size.Y + 20);
            var textBoxSize = new Vector2(cScreen.ClientSize.X - (textBoxPos.X * 2), cScreen.ClientSize.Y - textBoxPos.Y - 60);
            _cStatus = new TextBox(cScreen, textBoxPos, textBoxSize)
            { ForeColor = Color.Red, Border = null, CanFocus = false, IsMultiLine = true, IsEnabled = false };
        }
Exemple #5
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            BasicConfigurator.Configure(_logger);

            ScreenManager.Updated -= ScreenManager_Updated;
            ScreenManager.Updated += ScreenManager_Updated;

            _consoleFont = ScreenManager.Content.LoadFont("Font/Courier New", 14, ContentLevel.GameScreen);

            _cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize) { Border = ControlBorder.Empty };

            // The main console output textbox
            _txtOutput = new TextBox(_cScreen, Vector2.Zero, _cScreen.Size)
            {
                Font = _consoleFont,
                Size = _cScreen.Size,
                Border = ControlBorder.Empty,
                MaxBufferSize = 200,
                BufferTruncateSize = 80,
                CanFocus = false,
                CanDrag = false,
                IsMultiLine = true,
                IsEnabled = false
            };
            _txtOutput.Resized += delegate { UpdateConsoleBufferSize(); };
            _txtOutput.FontChanged += delegate { UpdateConsoleBufferSize(); };

            // Create the panel that holds the settings options
            var settingsButtonSize = _consoleFont.MeasureString("Show Settings") + new Vector2(10, 4);
            _btnShowSettings = new Button(_cScreen, new Vector2(_cScreen.Size.X, 0), settingsButtonSize) { Font = _consoleFont, Text = "Hide Settings" };
            _btnShowSettings.Position += new Vector2(-4, 4);
            _btnShowSettings.Clicked += btnShowSettings_Clicked;

            var settingsPanelSize = new Vector2(400, 400);
            _cSettingsPanel = new Panel(_cScreen, new Vector2(_cScreen.Size.X - settingsPanelSize.X - 4, _btnShowSettings.Position.Y + _btnShowSettings.Size.Y + 8), settingsPanelSize) 
                { IsVisible = true, CanDrag = false };

            // Create the logging level checkboxes
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Fatal, 0));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Error, 1));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Warn, 2));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Info, 3));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Debug, 4));

            // Disable debug by default
            _logLevelCheckBoxes.First(x => (Level)x.Tag == Level.Debug).Value = false;
        }
Exemple #6
0
        /// <summary>
        /// Initializes the GUI components.
        /// </summary>
        void InitializeGUI()
        {
            // Set up the fonts
            _guiFont = GameScreenHelper.DefaultGameGUIFont;
            GUIManager.Font = _guiFont;
            GUIManager.Tooltip.Font = _guiFont;
            Character.NameFont = _guiFont;

            _cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize) { CanFocus = true };

            // Set up all the forms used by this screen
            _statsForm = new StatsForm(UserInfo, _cScreen);
            _statsForm.RequestRaiseStat += StatsForm_RequestRaiseStat;

            _inventoryForm = new InventoryForm(_dragDropHandler, x => x == UserInfo.Inventory, InventoryInfoRequester,
                new Vector2(250, 0), _cScreen);
            _inventoryForm.RequestDropItem += InventoryForm_RequestDropItem;
            _inventoryForm.RequestUseItem += InventoryForm_RequestUseItem;

            _shopForm = new ShopForm(_dragDropHandler, new Vector2(250, 0), _cScreen);
            _shopForm.RequestPurchase += ShopForm_RequestPurchase;

            _skillsForm = new SkillsForm(SkillCooldownManager, new Vector2(100, 0), _cScreen, UserInfo.KnownSkills);
            _skillsForm.RequestUseSkill += SkillsForm_RequestUseSkill;

            _infoBox = new InfoBox(GameData.ScreenSize - new Vector2(5, 5), _guiFont);

            _equippedForm = new EquippedForm(_dragDropHandler, EquipmentInfoRequester, new Vector2(500, 0), _cScreen);
            _equippedForm.RequestUnequip += EquippedForm_RequestUnequip;

            _chatForm = new ChatForm(_cScreen, new Vector2(0, _cScreen.Size.Y));
            _chatForm.Say += ChatForm_Say;

            _chatDialogForm = new NPCChatDialogForm(new Vector2(50, 50), _cScreen);
            _chatDialogForm.SelectResponse += ChatDialogForm_SelectResponse;
            _chatDialogForm.RequestEndDialog += ChatDialogForm_RequestEndDialog;

            _statusEffectsForm = new StatusEffectsForm(_cScreen, new Vector2(_cScreen.Size.X, 0), this);

            _quickBarForm = new QuickBarForm(this, _cScreen, _cScreen.Position);

            _guildForm = new GuildForm(_cScreen, new Vector2(100, 100)) { GuildInfo = UserInfo.GuildInfo, IsVisible = false };
            _guildForm.JoinRequested += _guildForm_JoinRequested;
            _guildForm.LeaveRequested += _guildForm_LeaveRequested;

            _groupForm = new GroupForm(_cScreen, new Vector2(50, 350), new Vector2(150, 150)) { GroupInfo = UserInfo.GroupInfo };

            Func<QuestID, bool> questStartReqs = x => UserInfo.HasStartQuestRequirements.HasRequirements(x) ?? false;
            Func<QuestID, bool> questFinishReqs =
                x =>
                UserInfo.QuestInfo.ActiveQuests.Contains(x) && (UserInfo.HasFinishQuestRequirements.HasRequirements(x) ?? false);
            _availableQuestsForm = new AvailableQuestsForm(_cScreen, new Vector2(200), new Vector2(250, 350), questStartReqs,
                questFinishReqs);
            _availableQuestsForm.QuestAccepted += availableQuestsForm_QuestAccepted;

            _latencyLabel = new Label(_cScreen, new Vector2(_cScreen.ClientSize.X - 75, 5))
            { Text = string.Format(_latencyString, 0), ForeColor = Color.White };

            _skillCastProgressBar = new SkillCastProgressBar(_cScreen);

            var toolbar = new Toolbar(_cScreen, new Vector2(200, 200));
            toolbar.ItemClicked += Toolbar_ItemClicked;

            var gameMenu = new GameMenuForm(_cScreen);
            gameMenu.ClickedLogOut += GameMenuClickedLogOut;

            _peerTradeForm = new PeerTradeForm(_cScreen, new Vector2(200))
            { PeerTradeInfoHandler = Socket.PacketHandler.PeerTradeInfoHandler };

            // Add the forms to the GUI settings manager (which also restores any existing settings)
            _guiStatePersister = new GUIStatePersister("Default"); // FUTURE: Allow changing of the profile
            _guiStatePersister.Add("InventoryForm", _inventoryForm);
            _guiStatePersister.Add("EquippedForm", _equippedForm);
            _guiStatePersister.Add("StatsForm", _statsForm);
            _guiStatePersister.Add("ChatForm", _chatForm);
            _guiStatePersister.Add("ToolbarForm", toolbar);
            _guiStatePersister.Add("GuildForm", _guildForm);
            _guiStatePersister.Add("StatusEffectsForm", _statusEffectsForm);
            _guiStatePersister.Add("SkillsForm", _skillsForm);
            _guiStatePersister.Add("QuickBarForm", _quickBarForm);
            _guiStatePersister.Add("PeerTradeForm", _peerTradeForm);

            // Set the focus to the screen container
            _cScreen.SetFocus();
        }
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Log out");
            menuButtons["Log out"].Clicked += ClickButton_LogOut;

            // Create the character slots
            _charSlotControls = new CharacterSlotControl[GameData.MaxCharactersPerAccount];
            for (var i = 0; i < GameData.MaxCharactersPerAccount; i++)
            {
                var c = new CharacterSlotControl(cScreen, (byte)i);
                c.Clicked += ClickButton_CharacterSelection;
                c.DeleteCharacterClicked += ClickButton_DeleteCharacter;
                _charSlotControls[i] = c;
            }
        }
Exemple #8
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            _sockets = ClientSockets.Instance;

            _sockets.PacketHandler.ReceivedCreateAccount -= PacketHandler_ReceivedCreateAccount;
            _sockets.PacketHandler.ReceivedCreateAccount += PacketHandler_ReceivedCreateAccount;

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the new account fields. Use a different font since our default TextBox font doesn't support some characters
            // needed for email, and it'd look funny to only change it for the email textbox.
            var textBoxFont = GameScreenHelper.DefaultChatFont;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 180), "Name:");
            _cNameText = new TextBox(cScreen, new Vector2(220, 180), new Vector2(200, 40)) { IsMultiLine = false, Text = string.Empty, Font = textBoxFont };

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Password:"******"Email:");
            _cEmailText = new TextBox(cScreen, new Vector2(220, 320), new Vector2(200, 40)) { IsMultiLine = false, Text = string.Empty, Font = textBoxFont };

            var textBoxPos = new Vector2(60, _cEmailText.Position.Y + _cEmailText.Size.Y + 20);
            var textBoxSize = new Vector2(cScreen.ClientSize.X - (textBoxPos.X * 2), cScreen.ClientSize.Y - textBoxPos.Y - 60);
            _cStatus = new TextBox(cScreen, textBoxPos, textBoxSize) { ForeColor = Color.Red, Border = null, CanFocus = false, IsMultiLine = true, IsEnabled = false };

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Create Account", "Back");
            menuButtons["Create Account"].Clicked += ClickButton_CreateAccount;
            menuButtons["Back"].Clicked += delegate { ScreenManager.SetScreen<MainMenuScreen>(); };

            _createAccountButton = menuButtons["Create Account"];

            _sockets.StatusChanged -= _sockets_StatusChanged;
            _sockets.StatusChanged += _sockets_StatusChanged;
        }