Esempio n. 1
0
        public ModelTextureSelector(CharacterEditorMenu root, IPedVariation component)
        {
            Root      = root;
            Component = component;

            Title      = ComponentNames.ContainsKey(component.ToString()) ? ComponentNames[component.ToString()] : component.ToString();
            OnActivate = OpenComponentMenu;
            OnSelect   = new Action <MenuItem>((menuItem) =>
            {
                if (component.ToString() == "Legs" || component.ToString() == "Shoes")
                {
                    root.Editor.lookAtLegs();
                }
                else if (component.ToString() == "Hats")
                {
                    root.Editor.lookAtHead();
                }
                else
                {
                    root.Editor.lookAtBody();
                }
            });

            // Is this variation a prop or component?
            PedProps      propID;
            PedComponents compID;

            if (Enum.TryParse(Component.ToString(), out propID))
            {
                ComponentID  = (int)propID;
                IsProp       = true;
                AppliedModel = -1;
            }
            else if (Enum.TryParse(Component.ToString(), out compID))
            {
                ComponentID = (int)compID;
            }

            Menu = new MenuModel {
                headerTitle = ComponentNames.ContainsKey(component.ToString()) ? ComponentNames[component.ToString()] : component.ToString(),
                statusTitle = ComponentNames.ContainsKey(component.ToString()) ? ComponentNames[component.ToString()] : component.ToString()
            };

            // Only add the Change Model button if there is more than one model
            if (component.HasVariations)
            {
                ModelSelector = new MenuItemHorSelector <int> {
                    Title              = "Model",
                    Type               = MenuItemHorizontalSelectorType.Number,
                    state              = 0,
                    minState           = 0,
                    maxState           = component.Count - 1,
                    wrapAround         = true,
                    overrideDetailWith = $"{component.Index + 1}/{component.Count}",
                    OnChange           = SetNewModel
                };

                Menu.menuItems.Add(ModelSelector);
            }

            // Only add the Change Texture button if there is more than one texture for this model
            //if( component.HasTextureVariations ) {
            TextureSelector = new MenuItemHorSelector <int> {
                Title              = "Texture",
                Type               = MenuItemHorizontalSelectorType.Number,
                state              = 0,
                minState           = 0,
                maxState           = component.TextureCount - 1,
                wrapAround         = true,
                overrideDetailWith = $"{component.TextureIndex + 1}/{(component.TextureCount == 0 ? "1" : component.TextureCount.ToString())}",
                OnChange           = SetNewTexture
            };

            Menu.menuItems.Add(TextureSelector);
            //}

            Menu.menuItems.Add(new MenuItemStandard {
                Title = "Back", OnActivate = CloseComponentMenu
            });
        }
Esempio n. 2
0
 private void SetNewModel(int selected, MenuItemHorSelector <int> m)
 {
     ApplyChange();
     ModelSelector.overrideDetailWith = $"{ComponentIndex + 1}/{Component.Count}";
     this.Refresh();
 }
Esempio n. 3
0
 private void SetNewTexture(int selected, MenuItemHorSelector <int> m)
 {
     ApplyChange();
     TextureSelector.overrideDetailWith = $"{TextureIndex + 1}/{(Component.TextureCount == 0 ? "1" : Component.TextureCount.ToString())}";
 }
 private void SetNewAppearance(int value, MenuItemHorSelector <int> item)
 {
     API.SetPedEyeColor(Game.PlayerPed.Handle, value);
     Root.AdditionalSaveData.EyeColor = (byte)value;
 }
Esempio n. 5
0
 private void SetNewAppearance(int value, MenuItemHorSelector <int> item)
 {
     Value = value;
     Parent.SetNewAppearance();
 }
Esempio n. 6
0
            public void Draw()
            {
                try
                {
                    if (!Initialized)
                    {
                        Init();
                    }

                    MenuOptions o            = menu.current.options; // should save a lot of characters below
                    PointF      itemPosition = Position;
                    menu.current.visibleItems.Select((item, index) => new { item, index }).ToList().ForEach(n =>
                    {
                        var i           = n.item;
                        bool isSelected = menu.current.SelectedIndex == (menu.current.topMostVisibleItem + n.index);
                        if (i is MenuItemStandard)
                        {
                            if (((MenuItemStandard)i).SubDetail != null)
                            {
                                new Rectangle(itemPosition, new SizeF(o.Width, o.ItemWithDetailHeight), isSelected ? o.ItemSelectedBackgroundColor : o.ItemBackgroundColor).Draw();
                                new Text(i.Title, itemPosition.Add(o.ItemPadding), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor).Draw();
                                if (((MenuItemStandard)i).Detail != null)
                                {
                                    new Text(((MenuItemStandard)i).Detail, new PointF(itemPosition.X + o.Width - o.ItemPadding.X, itemPosition.Y + o.ItemPadding.Y), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor, o.ItemFont, Alignment.Right).Draw();
                                }
                                new Text(((MenuItemStandard)i).SubDetail, new PointF(itemPosition.X + o.Width - o.ItemPadding.X, itemPosition.Y + o.ItemPadding.Y + 14f), o.ItemSubDetailTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor, o.ItemFont, Alignment.Right).Draw();
                                itemPosition = itemPosition.Add(new PointF(0, o.ItemWithDetailHeight + o.ItemBottomMargin));
                            }
                            else
                            {
                                new Rectangle(itemPosition, new SizeF(o.Width, o.ItemHeight), isSelected ? o.ItemSelectedBackgroundColor : o.ItemBackgroundColor).Draw();
                                if (((MenuItemStandard)i).Detail != null)
                                {
                                    new Text(((MenuItemStandard)i).Detail, new PointF(itemPosition.X + o.Width - o.ItemPadding.X, itemPosition.Y + o.ItemPadding.Y), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor, o.ItemFont, Alignment.Right).Draw();
                                }
                                new Text(i.Title, itemPosition.Add(o.ItemPadding), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor).Draw();
                                itemPosition = itemPosition.Add(new PointF(0, o.ItemHeight + o.ItemBottomMargin));
                            }
                        }
                        else if (i is MenuItemCheckbox)
                        {
                            new Rectangle(itemPosition, new SizeF(o.Width, o.ItemHeight), isSelected ? o.ItemSelectedBackgroundColor : o.ItemBackgroundColor).Draw();
                            bool isChecked        = ((MenuItemCheckbox)i).State;
                            string checkboxSprite = isSelected ? (isChecked ? "shop_box_tickb" : "shop_box_blankb") : (isChecked ? "shop_box_tick" : "shop_box_blank");
                            UIHelpers.DrawSprite("commonmenu", checkboxSprite, new PointF(itemPosition.X + o.Width - o.ItemPadding.X, itemPosition.Y + o.ItemPadding.Y).Add(o.MenuItemCheckboxOffset), new SizeF(o.MenuItemCheckboxSize), new Size(0, 0), Color.FromArgb(80, 255, 255, 255), false);
                            new Text(i.Title, itemPosition.Add(o.ItemPadding), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor).Draw();
                            itemPosition = itemPosition.Add(new PointF(0, o.ItemHeight + o.ItemBottomMargin));
                        }
                        else if (i is MenuItemHorSelector <int> ) // I gave up on trying to combine these two into one with Reflection methods
                        {
                            MenuItemHorSelector <int> item      = i as MenuItemHorSelector <int>;
                            MenuItemHorizontalSelectorType type = item.Type;
                            int state      = item.state;
                            int maxState   = item.maxState;
                            int minState   = item.minState;
                            bool hasBar    = type == MenuItemHorizontalSelectorType.Bar || type == MenuItemHorizontalSelectorType.NumberAndBar;
                            bool hasNumber = type == MenuItemHorizontalSelectorType.Number || type == MenuItemHorizontalSelectorType.NumberAndBar;
                            new Rectangle(itemPosition, new SizeF(o.Width, hasBar ? o.ItemHorSelWithBarHeight : o.ItemHeight), isSelected ? o.ItemSelectedBackgroundColor : o.ItemBackgroundColor).Draw();
                            new Text(i.Title, itemPosition.Add(o.ItemPadding), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor).Draw();

                            if (hasNumber)
                            {
                                new Text($"{(item.overrideDetailWith != null ? item.overrideDetailWith : $"{state}/{maxState}")}", new PointF(itemPosition.X + o.Width - o.ItemPadding.X, itemPosition.Y + o.ItemPadding.Y), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor, o.ItemFont, Alignment.Right).Draw();
                            }
                            if (hasBar)
                            {
                                float progressFraction = (state - minState) / (float)((maxState - minState));
                                new Rectangle(itemPosition.Add(o.MenuItemHorSelOuterBarOffset), new SizeF(o.Width - 2 * o.MenuItemHorSelOuterBarOffset.X, o.MenuItemHorSelOuterBarHeight), isSelected ? o.ItemHorSelSelectedOuterBgColor : o.ItemHorSelOuterBgColor).Draw();
                                new Rectangle(itemPosition.Add(o.MenuItemHorSelOuterBarOffset).Add(o.MenuItemHorSelInnerBarOffset), new SizeF(progressFraction * (o.Width - 2 * (o.MenuItemHorSelOuterBarOffset.X + o.MenuItemHorSelInnerBarOffset.X)), o.MenuItemHorSelInnerBarHeight), isSelected ? o.ItemHorSelSelectedInnerBgColor : o.ItemHorSelInnerBgColor).Draw();
                            }

                            itemPosition = itemPosition.Add(new PointF(0, (hasBar ? o.ItemHorSelWithBarHeight : o.ItemHeight) + o.ItemBottomMargin));
                        }
                        else if (i is MenuItemHorSelector <float> ) // I gave up on trying to combine these two into one with Reflection methods, dynamic types etc. Feel free
                        {
                            MenuItemHorSelector <float> item    = i as MenuItemHorSelector <float>;
                            MenuItemHorizontalSelectorType type = item.Type;
                            float state    = item.state;
                            float maxState = item.maxState;
                            float minState = item.minState;
                            bool hasBar    = type == MenuItemHorizontalSelectorType.Bar || type == MenuItemHorizontalSelectorType.NumberAndBar;
                            bool hasNumber = type == MenuItemHorizontalSelectorType.Number || type == MenuItemHorizontalSelectorType.NumberAndBar;
                            new Rectangle(itemPosition, new SizeF(o.Width, hasBar ? o.ItemHorSelWithBarHeight : o.ItemHeight), isSelected ? o.ItemSelectedBackgroundColor : o.ItemBackgroundColor).Draw();
                            new Text(i.Title, itemPosition.Add(o.ItemPadding), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor).Draw();

                            if (hasNumber)
                            {
                                new Text($"{(item.overrideDetailWith != null ? item.overrideDetailWith : $"{state:0.00}/{maxState:0.00}")}", new PointF(itemPosition.X + o.Width - o.ItemPadding.X, itemPosition.Y + o.ItemPadding.Y), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor, o.ItemFont, Alignment.Right).Draw();
                            }
                            if (hasBar)
                            {
                                float progressFraction = (state - minState) / (float)((maxState - minState));
                                new Rectangle(itemPosition.Add(o.MenuItemHorSelOuterBarOffset), new SizeF(o.Width - 2 * o.MenuItemHorSelOuterBarOffset.X, o.MenuItemHorSelOuterBarHeight), isSelected ? o.ItemHorSelSelectedOuterBgColor : o.ItemHorSelOuterBgColor).Draw();
                                new Rectangle(itemPosition.Add(o.MenuItemHorSelOuterBarOffset).Add(o.MenuItemHorSelInnerBarOffset), new SizeF(progressFraction * (o.Width - 2 * (o.MenuItemHorSelOuterBarOffset.X + o.MenuItemHorSelInnerBarOffset.X)), o.MenuItemHorSelInnerBarHeight), isSelected ? o.ItemHorSelSelectedInnerBgColor : o.ItemHorSelInnerBgColor).Draw();
                            }

                            itemPosition = itemPosition.Add(new PointF(0, (hasBar ? o.ItemHorSelWithBarHeight : o.ItemHeight) + o.ItemBottomMargin));
                        }
                        else if (i is MenuItemHorNamedSelector) // I gave up on trying to combine these into one with Reflection methods
                        {
                            MenuItemHorNamedSelector item       = i as MenuItemHorNamedSelector;
                            MenuItemHorizontalSelectorType type = item.Type;
                            int maxState     = item.optionList.Count() - 1;
                            int minState     = 0;
                            int state        = (item.state < minState) ? minState : (item.state > maxState) ? maxState : item.state;
                            string stateName = item.optionList[state];
                            bool hasBar      = type == MenuItemHorizontalSelectorType.Bar || type == MenuItemHorizontalSelectorType.NumberAndBar;
                            bool hasNumber   = type == MenuItemHorizontalSelectorType.Number || type == MenuItemHorizontalSelectorType.NumberAndBar;
                            new Rectangle(itemPosition, new SizeF(o.Width, hasBar ? o.ItemHorSelWithBarHeight : o.ItemHeight), isSelected ? o.ItemSelectedBackgroundColor : o.ItemBackgroundColor).Draw();
                            new Text(i.Title, itemPosition.Add(o.ItemPadding), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor).Draw();

                            if (hasNumber)
                            {
                                new Text($"{(item.overrideDetailWith != null ? item.overrideDetailWith : stateName)}", new PointF(itemPosition.X + o.Width - o.ItemPadding.X, itemPosition.Y + o.ItemPadding.Y), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor, o.ItemFont, Alignment.Right).Draw();
                            }
                            if (hasBar)
                            {
                                float progressFraction = (state - minState) / (float)((maxState - minState));
                                new Rectangle(itemPosition.Add(o.MenuItemHorSelOuterBarOffset), new SizeF(o.Width - 2 * o.MenuItemHorSelOuterBarOffset.X, o.MenuItemHorSelOuterBarHeight), isSelected ? o.ItemHorSelSelectedOuterBgColor : o.ItemHorSelOuterBgColor).Draw();
                                new Rectangle(itemPosition.Add(o.MenuItemHorSelOuterBarOffset).Add(o.MenuItemHorSelInnerBarOffset), new SizeF(progressFraction * (o.Width - 2 * (o.MenuItemHorSelOuterBarOffset.X + o.MenuItemHorSelInnerBarOffset.X)), o.MenuItemHorSelInnerBarHeight), isSelected ? o.ItemHorSelSelectedInnerBgColor : o.ItemHorSelInnerBgColor).Draw();
                            }

                            itemPosition = itemPosition.Add(new PointF(0, (hasBar ? o.ItemHorSelWithBarHeight : o.ItemHeight) + o.ItemBottomMargin));
                        }
                        else
                        {
                            new Rectangle(itemPosition, new SizeF(o.Width, o.ItemHeight), isSelected ? o.ItemSelectedBackgroundColor : o.ItemBackgroundColor).Draw();
                            new Text(i.Title, itemPosition.Add(o.ItemPadding), o.ItemTextSize, isSelected ? o.ItemSelectedTextColor : o.ItemTextColor).Draw();
                            itemPosition = itemPosition.Add(new PointF(0, o.ItemHeight + o.ItemBottomMargin));
                        }
                    });
Esempio n. 7
0
 private void SetNewTexture(int selected, MenuItemHorSelector <int> m)
 {
     ApplyChange();
     TextureSelector.overrideDetailWith = string.Format("{0}/{1}", TextureIndex + 1, Component.TextureCount);
 }
Esempio n. 8
0
 private void SetNewModel(int selected, MenuItemHorSelector <int> m)
 {
     ApplyChange();
     ModelSelector.overrideDetailWith = string.Format("{0}/{1}", ComponentIndex + 1, Component.Count);
 }