Exemple #1
0
        public override void Init()
        {
            base.Init();
            _ThemeButtons        = new string[] { _ButtonBack, _ButtonNext, _ButtonRandom, _ButtonIncreaseTeams, _ButtonDecreaseTeams, _ButtonIncreasePlayer, _ButtonDecreasePlayer };
            _ThemeSelectSlides   = new string[] { _SelectSlideTeams, _SelectSlidePlayer };
            _ThemeNameSelections = new string[] { _NameSelection };

            _ChooseAvatarStatic         = GetNewStatic();
            _ChooseAvatarStatic.Visible = false;
            _ChooseAvatarStatic.Aspect  = EAspect.Crop;

            CBase.Profiles.AddProfileChangedCallback(_OnProfileChanged);
        }
Exemple #2
0
        public void Init()
        {
            _PrepareTiles();

            _PlayerSelector = new CStatic(_PartyModeID, _TextureTileSelected, new SColorF(), new SRectF(0, 0, _Theme.Tiles.W + 6, _Theme.Tiles.H + 6, Rect.Z - 0.5f))
            {
                Visible = false
            };

            _UpdateVisibleProfiles();

            UpdateList(0);
        }
Exemple #3
0
        public CStatic(CStatic s)
        {
            _PartyModeID = s._PartyModeID;

            _Texture         = s.Texture;
            Color            = s.Color;
            MaxRect          = s.MaxRect;
            Reflection       = s.Reflection;
            ReflectionSpace  = s.ReflectionHeight;
            ReflectionHeight = s.ReflectionSpace;

            Alpha   = s.Alpha;
            Visible = s.Visible;
        }
Exemple #4
0
        private void _LoadThemeBasics(CXmlReader xmlReader)
        {
            // Backgrounds
            var background = new CBackground(PartyModeID);
            int i          = 1;

            while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader))
            {
                _AddBackground(background);
                background = new CBackground(PartyModeID);
                i++;
            }

            // Statics
            var stat = new CStatic(PartyModeID);

            i = 1;
            while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader))
            {
                _AddStatic(stat);
                stat = new CStatic(PartyModeID);
                i++;
            }

            // Texts
            var text = new CText(PartyModeID);

            i = 1;
            while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader))
            {
                _AddText(text);
                text = new CText(PartyModeID);
                i++;
            }

            // ParticleEffects
            var partef = new CParticleEffect(PartyModeID);

            i = 1;
            while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader))
            {
                _AddParticleEffect(partef);
                partef = new CParticleEffect(PartyModeID);
                i++;
            }
        }
Exemple #5
0
 private void _PrepareTiles()
 {
     _Tiles.Clear();
     for (int i = 0; i < _Theme.Tiles.NumH; i++)
     {
         for (int j = 0; j < _Theme.Tiles.NumW; j++)
         {
             var rect = new SRectF(MaxRect.X + j * (_Theme.Tiles.W + _Theme.Tiles.SpaceW), MaxRect.Y + i * (_Theme.Tiles.H + _Theme.Tiles.SpaceH),
                                   _Theme.Tiles.W, _Theme.Tiles.H, MaxRect.Z);
             var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, _ColorEmptyTile, rect)
             {
                 Aspect = EAspect.Crop
             };
             var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.Tiles.Name.Space, rect.Z, _Theme.Tiles.Name.Height, rect.W, EAlignment.Center,
                                      _Theme.Tiles.Name.Style, _Theme.Tiles.Name.Font, _ColorNameTile, "");
             _Tiles.Add(new CTile(tileStatic, tileText, -1));
         }
     }
     _Rect.X      = MaxRect.X;
     _Rect.Y      = MaxRect.Y;
     _Rect.Right  = _Tiles[_Tiles.Count - 1].Avatar.Rect.Right;
     _Rect.Bottom = _Tiles[_Tiles.Count - 1].Name.Rect.Bottom;
     _Rect.Z      = MaxRect.Z;
 }
Exemple #6
0
 protected void _AddStatic(CStatic stat, String key = null)
 {
     _AddElement(_Statics.Add(stat, key), EType.Static);
 }
Exemple #7
0
 public CTile(CStatic av, CText tex, int pID)
 {
     Avatar    = av;
     Name      = tex;
     ProfileID = pID;
 }
Exemple #8
0
        private void _Revalidate()
        {
            if (!_NeedsRevalidate)
            {
                return;
            }
            _NeedsRevalidate = false;
            int numvis = Math.Min(_NumVisible, _Values.Count);

            if (numvis != _VisibleElements.Count)
            {
                _VisibleElements.Clear();
                for (int i = 0; i < numvis; i++)
                {
                    var el = new CElement
                    {
                        Text = new CText(0, 0, 0, _TextH, _MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, _TextColor, "T", _PartyModeID),
                        Img  = new CStatic(_PartyModeID)
                    };
                    el.Img.Aspect = EAspect.Crop;
                    _VisibleElements.Add(el);
                }
            }
            if (numvis == 0)
            {
                return;
            }

            float elWidth = (Rect.W - _TextRelativeX * 2) / numvis;
            //Center point of the first entry
            float xStart = Rect.X + _TextRelativeX + elWidth / 2f;

            int offset = _GetCurOffset();

            for (int i = 0; i < numvis; i++)
            {
                CText      text = _VisibleElements[i].Text;
                RectangleF textBounds;
                float      curX = xStart + elWidth * i;
                if (String.IsNullOrEmpty(_Values[i + offset].Text))
                {
                    text.Visible = false;
                    textBounds   = new RectangleF();
                }
                else
                {
                    text.Visible       = true;
                    text.Text          = _Values[i + offset].Text;
                    text.TranslationID = _Values[i + offset].TranslationId;
                    text.Color         = (i + offset == Selection) ? _SelTextColor : _TextColor;
                    textBounds         = CBase.Fonts.GetTextBounds(text);
                    text.X             = curX;
                    text.Z             = Rect.Z;
                }

                CStatic img = _VisibleElements[i].Img;
                if (!DrawTextures || _Values[i + offset].Texture == null)
                {
                    if (text.Visible)
                    {
                        text.Y = Rect.Y + (Rect.H - textBounds.Height) / 2 - _TextRelativeY;
                    }
                    img.Visible = false;
                    _VisibleElements[i].Bounds = new SRectF(text.X - textBounds.Width / 2f, text.Y, textBounds.Width, textBounds.Height, Rect.Z);
                }
                else
                {
                    text.Y      = (int)(Rect.Y + Rect.H - textBounds.Height - _TextRelativeY);
                    img.Texture = _Values[i + offset].Texture;
                    float alpha = (i + offset == _Selection) ? 1f : 0.35f;
                    img.Color = new SColorF(1f, 1f, 1f, alpha);
                    float size = Rect.H - textBounds.Height - 2 * _TextRelativeY;
                    if (size > elWidth)
                    {
                        size = elWidth;
                    }
                    var imgRect = new SRectF(curX - size / 2, Rect.Y + _TextRelativeY, size, size, Rect.Z);
                    img.MaxRect = imgRect;
                    _VisibleElements[i].Bounds = imgRect;
                }
            }
        }
Exemple #9
0
 public static CStatic GetNewStatic(CStatic oldStatic)
 {
     return(new CStatic(oldStatic));
 }
Exemple #10
0
        public override bool HandleMouse(SMouseEvent mouseEvent)
        {
            bool stopSelectingFast = false;

            if (_SelectingFast)
            {
                _NameSelections[_NameSelection].HandleMouse(mouseEvent);
            }
            else
            {
                base.HandleMouse(mouseEvent);
            }

            //Check if LeftButton is hold and Select-Mode inactive
            if (mouseEvent.LBH && _SelectedProfileID < 0 && !_SelectingFast)
            {
                //Save mouse-coords
                _OldMouseX = mouseEvent.X;
                _OldMouseY = mouseEvent.Y;
                //Check if mouse if over tile
                if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
                {
                    //Get player-number of tile
                    _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
                    if (_SelectedProfileID != -1)
                    {
                        //Update of Drag/Drop-Texture
                        CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
                        _ChooseAvatarStatic.Visible = true;
                        _ChooseAvatarStatic.MaxRect = selectedPlayer.Rect;
                        _ChooseAvatarStatic.Z       = CBase.Settings.GetZNear();
                        _ChooseAvatarStatic.Color   = new SColorF(1, 1, 1, 1);
                        _ChooseAvatarStatic.Texture = selectedPlayer.Texture;
                    }
                }
            }
            //Check if LeftButton is hold and Select-Mode active
            if (mouseEvent.LBH && _SelectedProfileID >= 0 && !_SelectingFast)
            {
                //Update coords for Drag/Drop-Texture
                _ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX;
                _ChooseAvatarStatic.Y += mouseEvent.Y - _OldMouseY;
                _OldMouseX             = mouseEvent.X;
                _OldMouseY             = mouseEvent.Y;
            }
            // LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
            else if (_SelectedProfileID >= 0 && !_SelectingFast)
            {
                //Check if mouse is in drop-area
                if (CHelper.IsInBounds(_SelectSlides[_SelectSlidePlayer].Rect, mouseEvent))
                {
                    if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
                    {
                        return(true);
                    }

                    _AddPlayer(_CurrentTeam, _SelectedProfileID);
                }

                //Reset variables
                _SelectedProfileID          = -1;
                _ChooseAvatarStatic.Visible = false;
            }
            if (mouseEvent.LB && _SelectingFast)
            {
                if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
                {
                    //Get player-number of tile
                    _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
                    if (_SelectedProfileID != -1)
                    {
                        if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
                        {
                            return(true);
                        }

                        _AddPlayer(_CurrentTeam, _SelectedProfileID);

                        if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
                        {
                            stopSelectingFast = true;
                        }
                        else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
                        {
                            stopSelectingFast = true;
                        }
                    }
                    else
                    {
                        stopSelectingFast = true;
                    }
                }
            }

            else if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent))
            {
                if (_Buttons[_ButtonBack].Selected)
                {
                    Back();
                }

                if (_Buttons[_ButtonNext].Selected)
                {
                    Next();
                }

                if (_Buttons[_ButtonRandom].Selected)
                {
                    _SelectRandom();
                }

                if (_Buttons[_ButtonIncreaseTeams].Selected)
                {
                    IncreaseTeamNum();
                }

                if (_Buttons[_ButtonDecreaseTeams].Selected)
                {
                    DecreaseTeamNum();
                }

                if (_Buttons[_ButtonIncreasePlayer].Selected)
                {
                    IncreasePlayerNum(_CurrentTeam);
                }

                if (_Buttons[_ButtonDecreasePlayer].Selected)
                {
                    DecreasePlayerNum(_CurrentTeam);
                }

                if (_SelectSlides[_SelectSlideTeams].Selected)
                {
                    _OnChangeTeamSlide();
                }

                //Update Tiles-List
                _NameSelections[_NameSelection].UpdateList();
            }

            if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast)
            {
                _SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
                if (_SelectedProfileID > -1)
                {
                    if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
                    {
                        return(true);
                    }

                    _AddPlayer(_CurrentTeam, _SelectedProfileID);
                }
            }

            if (mouseEvent.RB && _SelectingFast)
            {
                stopSelectingFast = true;
            }
            else if (mouseEvent.RB)
            {
                bool exit = true;
                if (_SelectSlides[_SelectSlidePlayer].Selected && _TeamList[_CurrentTeam].Count > _SelectSlides[_SelectSlidePlayer].Selection)
                {
                    int currentSelection = _SelectSlides[_SelectSlidePlayer].Selection;
                    int id = _TeamList[_CurrentTeam][currentSelection];
                    _RemovePlayer(_CurrentTeam, id);
                    _UpdatePlayerSlide();
                    exit = false;
                }

                if (exit)
                {
                    Back();
                }
            }

            if (mouseEvent.MB && _SelectingFast)
            {
                if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
                {
                    stopSelectingFast = true;
                }
                else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
                {
                    stopSelectingFast = true;
                }
            }
            else if (mouseEvent.MB)
            {
                _SelectingFast           = true;
                _SelectingFastPlayerNr   = (_CurrentTeam + 1);
                _SelectingKeyboardActive = true;
                _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr);
            }

            //Check mouse-wheel for scrolling
            if (mouseEvent.Wheel != 0)
            {
                if (CHelper.IsInBounds(_NameSelections[_NameSelection].Rect, mouseEvent))
                {
                    int offset = _NameSelections[_NameSelection].Offset + mouseEvent.Wheel;
                    _NameSelections[_NameSelection].UpdateList(offset);
                }
            }

            if (stopSelectingFast)
            {
                _SelectingFast           = false;
                _SelectingFastPlayerNr   = 0;
                _SelectingKeyboardActive = false;
                _NameSelections[_NameSelection].FastSelection(false, -1);
            }
            return(true);
        }