예제 #1
0
파일: GuiPartyInfo.cs 프로젝트: bsimser/CoM
        public GuiPartyInfo(int x = 0, int y = 0)
            : base(x, y)
        {
            IgnoreClipping = true;

            const int INFOLABEL_HEIGHT = 24;

            Width  = 300;
            Height = GuiCharacterFrame.HEIGHT * 2 + INFOLABEL_HEIGHT + 24;

            CharacterPanel = new GuiCharacterFrame[4];
            for (int lp = 0; lp < 4; lp++)
            {
                CharacterPanel[lp] = new GuiCharacterFrame()
                {
                    X = (lp % 2) * (GuiCharacterFrame.WIDTH),
                    Y = (int)(lp / 2) * (GuiCharacterFrame.HEIGHT)
                };
                Add(CharacterPanel[lp]);
            }

            GuiButton RemoveButton = new GuiButton("Remove", 80, 20);

            Add(RemoveButton, 10, Height - 25);

            GuiButton AddButton = new GuiButton("Add", 80, 20);

            Add(AddButton, 100, Height - 25);

            menuButton = new GuiButton("Menu", 80, 20);
            Add(menuButton, 190, Height - 25);

            InfoLabel = new GuiLabel(0, 0, "")
            {
                Height    = INFOLABEL_HEIGHT,
                TextAlign = TextAnchor.MiddleCenter,
                Align     = GuiAlignment.Bottom
            };
            Add(InfoLabel);

            RemoveButton.OnMouseClicked += delegate {
                if (Party.Selected != null)
                {
                    Party.RemoveCharacter(Party.Selected);
                    Sync();
                }
            };

            menuButton.OnMouseClicked += delegate {
                Engine.PushState(new InGameMenuState());
            };

            AddButton.OnMouseClicked += delegate {
                if (Party.MemberCount == 4)
                {
                    return;
                }
                ModalOptionListState <MDRCharacter> chooseCharacterState = new ModalOptionListState <MDRCharacter>("Select a character to add", CoM.GetCharactersInCurrentArea());
                chooseCharacterState.OnStateClose += delegate {
                    if (chooseCharacterState.Result != null)
                    {
                        Party.AddCharacter(chooseCharacterState.Result);
                    }
                    Sync();
                };
                Engine.PushState(chooseCharacterState);
            };
        }