Beispiel #1
0
        public override void Draw(int interval)
        {
            SizeF res  = UIMenu.GetScreenResolutionMantainRatio();
            Point safe = UIMenu.GetSafezoneBounds();

            base.Draw(interval);
            ResText.Draw(Text, new Point((int)res.Width - safe.X - 10, (int)res.Height - safe.Y - (42 + (4 * interval))), 0.5f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);
        }
Beispiel #2
0
 /// <summary>
 /// List item, with left/right arrows.
 /// </summary>
 /// <param name="text">Item label.</param>
 /// <param name="items">List that contains your items.</param>
 /// <param name="index">Index in the list. If unsure user 0.</param>
 /// <param name="description">Description for this item.</param>
 public MenuListItem(string text, List<dynamic> items, int index, string description)
     : base(text, description)
 {
     const int y = 0;
     _items = new List<dynamic>(items);
     _arrowLeft = new Sprite("commonmenu", "arrowleft", new Point(110, 105 + y), new Size(30, 30));
     _arrowRight = new Sprite("commonmenu", "arrowright", new Point(280, 105 + y), new Size(30, 30));
     _itemText = new ResText("", new Point(290, y + 104), 0.35f, Color.White, Common.EFont.ChaletLondon,
         ResText.Alignment.Left) {TextAlignment = ResText.Alignment.Right};
     Index = index;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UIMenuListItem"/> class, from a collection of <see cref="IDisplayItem"/>s.
 /// </summary>
 /// <param name="text">The <see cref="UIMenuListItem"/>'s label.</param>
 /// <param name="description">The <see cref="UIMenuListItem"/>'s description.</param>
 /// <param name="items">The collection of <see cref="IDisplayItem"/>s.</param>
 public UIMenuListItem(string text, string description, IEnumerable<IDisplayItem> items)
     : base(text, description)
 {
     const int y = 0;
     Collection = new DisplayItemsCollection(items);
     _arrowLeft = new Sprite("commonmenu", "arrowleft", new Point(110, 105 + y), new Size(30, 30));
     _arrowRight = new Sprite("commonmenu", "arrowright", new Point(280, 105 + y), new Size(30, 30));
     _itemText = new ResText("", new Point(290, y + 104), 0.35f, Color.White, Common.EFont.ChaletLondon,
         ResText.Alignment.Left)
     { TextAlignment = ResText.Alignment.Right };
 }
 public UIMenuListItem(string text, List<dynamic> items, int index, string description)
     : base(text, description)
 {
     const int y = 0;
     _items = new List<dynamic>(items);
     _arrowLeft = new Sprite("commonmenu", "arrowleft", new Point(110, 105 + y), new Size(30, 30));
     _arrowRight = new Sprite("commonmenu", "arrowright", new Point(280, 105 + y), new Size(30, 30));
     _itemText = new ResText("", new Point(290, y + 104), 0.35f, Color.White, Common.EFont.ChaletLondon,
         ResText.Alignment.Left) {TextAlignment = ResText.Alignment.Right};
     Index = index;
 }
Beispiel #5
0
        public virtual void Draw(int interval)
        {
            SizeF res  = UIMenu.GetScreenResolutionMantainRatio();
            Point safe = UIMenu.GetSafezoneBounds();

            ResText.Draw(Label, new Point((int)res.Width - safe.X - 180, (int)res.Height - safe.Y - (30 + (4 * interval))), 0.3f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);
            Sprite.Draw("timerbars", "all_black_bg", new Point((int)res.Width - safe.X - 298, (int)res.Height - safe.Y - (40 + (4 * interval))), new Size(300, 37), 0f, Color.FromArgb(180, 255, 255, 255));

            NativeFunction.Natives.HideHudComponentThisFrame(7); //AreaName
            NativeFunction.Natives.HideHudComponentThisFrame(9); //StreetName
            NativeFunction.Natives.HideHudComponentThisFrame(6); //VehicleName
        }
        protected void Init()
        {
            _selectedSprite = new Sprite("commonmenu", "gradient_nav", new Point(0, 0), new Size(431, 38), 0, HighlightColor);
            _rectangle = new ResRectangle(new Point(0, 0), new Size(431, 38), Color.FromArgb(150, 0, 0, 0));
            _text = new ResText(Text, new Point(8, 0), 0.33f, Color.WhiteSmoke, Common.EFont.ChaletLondon, ResText.Alignment.Left);
            Description = Description;

            _badgeLeft = new Sprite("commonmenu", "", new Point(0, 0), new Size(40, 40));
            _badgeRight = new Sprite("commonmenu", "", new Point(0, 0), new Size(40, 40));

            _labelText = new ResText("", new Point(0, 0), 0.35f) { TextAlignment = ResText.Alignment.Right };
        }
Beispiel #7
0
        /// <summary>
        /// Basic menu button.
        /// </summary>
        /// <param name="text">Button label.</param>
        /// <param name="description">Description.</param>
        public NativeMenuItem(string text, string description)
        {
            Enabled = true;

            _rectangle = new ResRectangle(new Point(0, 0), new Size(431, 38), Color.FromArgb(150, 0, 0, 0));
            _text = new ResText(text, new Point(8, 0), 0.33f, Color.WhiteSmoke, Common.EFont.ChaletLondon, ResText.Alignment.Left);
            Description = description;
            _selectedSprite = new Sprite("commonmenu", "gradient_nav", new Point(0, 0), new Size(431, 38));

            _badgeLeft = new Sprite("commonmenu", "", new Point(0, 0), new Size(40, 40));
            _badgeRight = new Sprite("commonmenu", "", new Point(0, 0), new Size(40, 40));

            _labelText = new ResText("", new Point(0, 0), 0.35f) {TextAlignment = ResText.Alignment.Right};
        }
Beispiel #8
0
        /// <summary>
        /// Basic menu button.
        /// </summary>
        /// <param name="text">Button label.</param>
        /// <param name="description">Description.</param>
        public UIMenuItem(string text, string description)
        {
            Enabled = true;

            _rectangle      = new ResRectangle(new Point(0, 0), new Size(431, 38), Color.FromArgb(150, 0, 0, 0));
            _text           = new ResText(text, new Point(8, 0), 0.33f, Color.WhiteSmoke, Common.EFont.ChaletLondon, ResText.Alignment.Left);
            Description     = description;
            _selectedSprite = new Sprite("commonmenu", "gradient_nav", new Point(0, 0), new Size(431, 38));

            _badgeLeft  = new Sprite("commonmenu", "", new Point(0, 0), new Size(40, 40));
            _badgeRight = new Sprite("commonmenu", "", new Point(0, 0), new Size(40, 40));

            _labelText = new ResText("", new Point(0, 0), 0.35f)
            {
                TextAlignment = ResText.Alignment.Right
            };
        }
Beispiel #9
0
        /// <summary>
        /// Advanced Menu constructor that allows custom title banner.
        /// </summary>
        /// <param name="title">Title that appears on the big banner. Set to "" if you are using a custom banner.</param>
        /// <param name="subtitle">Subtitle that appears in capital letters in a small black bar.</param>
        /// <param name="offset">Point object with X and Y data for offsets. Applied to all menu elements.</param>
        /// <param name="spriteLibrary">Sprite library name for the banner.</param>
        /// <param name="spriteName">Sprite name for the banner.</param>
        public UIMenu(string title, string subtitle, Point offset, string spriteLibrary, string spriteName)
        {
            _offset = offset;
            Children = new Dictionary<NativeMenuItem, UIMenu>();
            WidthOffset = 0;

            _instructionalButtonsScaleform = new Scaleform(0);
            _instructionalButtonsScaleform.Load("instructional_buttons");
            UpdateScaleform();

            _mainMenu = new Container(new Point(0, 0), new Size(700, 500), Color.FromArgb(0, 0, 0, 0));
            _logo = new Sprite(spriteLibrary, spriteName, new Point(0 + _offset.X, 0 + _offset.Y), new Size(431, 107));
            _mainMenu.Items.Add(Title = new ResText(title, new Point(215 + _offset.X, 20 + _offset.Y), 1.15f, Color.White, Common.EFont.HouseScript, ResText.Alignment.Centered));
            if (!String.IsNullOrWhiteSpace(subtitle))
            {
                _mainMenu.Items.Add(new ResRectangle(new Point(0 + offset.X, 107 + _offset.Y), new Size(431, 37), Color.Black));
                _mainMenu.Items.Add(Subtitle = new ResText(subtitle, new Point(8 + _offset.X, 110 + _offset.Y), 0.35f, Color.WhiteSmoke, 0, ResText.Alignment.Left));

                if (subtitle.StartsWith("~"))
                {
                    CounterPretext = subtitle.Substring(0, 3);
                }
                _counterText = new ResText("", new Point(425 + _offset.X, 110 + _offset.Y), 0.35f, Color.WhiteSmoke, 0, ResText.Alignment.Right);
                _extraYOffset = 37;
            }

            _upAndDownSprite = new Sprite("commonmenu", "shop_arrows_upanddown", new Point(190 + _offset.X, 147 + 37 * (MaxItemsOnScreen + 1) + _offset.Y - 37 + _extraYOffset), new Size(50, 50));
            _extraRectangleUp = new ResRectangle(new Point(0 + _offset.X, 144 + 38 * (MaxItemsOnScreen + 1) + _offset.Y - 37 + _extraYOffset), new Size(431, 18), Color.FromArgb(200, 0, 0, 0));
            _extraRectangleDown = new ResRectangle(new Point(0 + _offset.X, 144 + 18 + 38 * (MaxItemsOnScreen + 1) + _offset.Y - 37 + _extraYOffset), new Size(431, 18), Color.FromArgb(200, 0, 0, 0));

            _descriptionBar = new ResRectangle(new Point(_offset.X, 123), new Size(431, 4), Color.Black);
            _descriptionRectangle = new Sprite("commonmenu", "gradient_bgd", new Point(_offset.X, 127), new Size(431, 30));
            _descriptionText = new ResText("Description", new Point(_offset.X + 5, 125), 0.35f, Color.FromArgb(255, 255, 255, 255), Common.EFont.ChaletLondon, ResText.Alignment.Left);

            _background = new Sprite("commonmenu", "gradient_bgd", new Point(_offset.X, 144 + _offset.Y - 37 + _extraYOffset), new Size(290, 25));

            SetKey(Common.MenuControls.Up, GameControl.CellphoneUp);
            SetKey(Common.MenuControls.Up, GameControl.CursorScrollUp);

            SetKey(Common.MenuControls.Down, GameControl.CellphoneDown);
            SetKey(Common.MenuControls.Down, GameControl.CursorScrollDown);

            SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft);
            SetKey(Common.MenuControls.Right, GameControl.CellphoneRight);
            SetKey(Common.MenuControls.Select, GameControl.FrontendAccept);

            SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel);
            SetKey(Common.MenuControls.Back, GameControl.FrontendPause);
        }
Beispiel #10
0
        protected virtual void Draw()
        {
            SizeF res    = UIMenu.GetScreenResolutionMantainRatio();
            int   middle = (int)(res.Width / 2);

            Sprite.Draw("mpentry", "mp_modenotselected_gradient", new Point(0, 10), new Size((int)res.Width, 450 + (Items.Count * 40)), 0.0f, Color.FromArgb(200, 255, 255, 255));

            ResText.Draw(Title, new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Common.EFont.Pricedown, true);

            ResText.Draw(Subtitle, new Point(middle, 230), 0.5f, Color.White, Common.EFont.ChaletLondon, true);
            ResRectangle.Draw(new Point(middle - 300, 290), new Size(600, 2), Color.White);

            for (int i = 0; i < Items.Count; i++)
            {
                MissionPassedScreenItem item = Items[i];

                ResText.Draw(item.Label, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Common.EFont.ChaletLondon, false);
                ResText.Draw(item.Status, new Point(item.Tickbox == MissionPassedScreenItem.TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);

                if (item.Tickbox == MissionPassedScreenItem.TickboxState.None)
                {
                    continue;
                }

                string spriteName;
                if (item.Tickbox == MissionPassedScreenItem.TickboxState.Tick)
                {
                    spriteName = "shop_box_tick";
                }
                else if (item.Tickbox == MissionPassedScreenItem.TickboxState.Cross)
                {
                    spriteName = "shop_box_cross";
                }
                else
                {
                    spriteName = "shop_box_blank";
                }

                Sprite.Draw("commonmenu", spriteName, new Point(middle + 230, 290 + (40 * i)), new Size(48, 48), 0.0f, Color.White);
            }

            ResRectangle.Draw(new Point(middle - 300, 300 + (40 * Items.Count)), new Size(600, 2), Color.White);

            ResText.Draw("Completion", new Point(middle - 150, 320 + (40 * Items.Count)), 0.4f, Color.White, Common.EFont.ChaletLondon, false);
            ResText.Draw(CompletionPercentage + "%", new Point(middle + 150, 320 + (40 * Items.Count)), 0.4f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);

            string medalSprite;

            if (Medal == MedalType.Silver)
            {
                medalSprite = "silvermedal";
            }
            else if (Medal == MedalType.Gold)
            {
                medalSprite = "goldmedal";
            }
            else
            {
                medalSprite = "bronzemedal";
            }

            Sprite.Draw("mpmissionend", medalSprite, new Point(middle + 150, 320 + (40 * Items.Count)), new Size(32, 32), 0.0f, Color.White);

            InstructionalButtons.Draw();
        }
        public void Load(MissionData mission)
        {
            CurrentStage = -1;
            CurrentObjectives = new List<SerializableObjective>();
            CurrentMission = mission;
            IsMissionPlaying = true;

            if (mission.Objectives.Count == 0)
            {
                Game.DisplayNotification("No spawnpoint found for stage 0.");
                AbortMission();
                return;
            }

            _oldModel = Game.LocalPlayer.Model;
            _oldPos = Game.LocalPlayer.Character.Position;
            
            GameFiber.StartNew(delegate
            {
                Game.FadeScreenOut(1000, true);
                LoadInteriors();

                World.Weather = CurrentMission.Weather;
                World.TimeOfDay = new TimeSpan(CurrentMission.Time, 0, 0);

                var res = UIMenu.GetScreenResolutionMantainRatio();

                var name = new ResText(CurrentMission.Name, new Point((int)res.Width - 100, (int)res.Height - 100), 0.7f, Color.WhiteSmoke, Common.EFont.HouseScript, ResText.Alignment.Right);
                name.Outline = true;

                GameFiber.StartNew(delegate
                {
                    DateTime start = DateTime.Now;
                    while (DateTime.Now.Subtract(start).TotalMilliseconds < 10000)
                    {
                        name.Draw();
                        GameFiber.Yield();
                    }
                });

                var startTime = Game.GameTime;

                while (IsMissionPlaying)
                {
                    Game.MaxWantedLevel = CurrentMission.MaxWanted;
                    if (Game.LocalPlayer.WantedLevel < CurrentMission.MinWanted)
                        Game.LocalPlayer.WantedLevel = CurrentMission.MinWanted;

                    if (Game.LocalPlayer.Character.IsDead)
                    {
                        FailMission(true);
                        break;
                    }

                    if (CurrentMission.TimeLimit.HasValue)
                    {
                        var elapsed = TimeSpan.FromMilliseconds(Convert.ToDouble((CurrentMission.TimeLimit.Value*1000) - (Game.GameTime - startTime)));
                        if(TimerBars != null)
                            TimerBars.UpdateValue("GLOBAL_TIME", "TIME", false, string.Format("{0:D2}:{1:D2}.{2:D3}", elapsed.Minutes, elapsed.Seconds, elapsed.Milliseconds));
                    }

                    if (CurrentMission.TimeLimit.HasValue && (Game.GameTime - startTime) > CurrentMission.TimeLimit*1000)
                    {
                        FailMission(reason: "You have run out of time.");
                        break;
                    }

                    if (CurrentObjectives.Count == 0)
                    {
                        AdvanceStage();
                        if (!CurrentMission.Objectives.Any(o => o.ActivateAfter >= CurrentStage))
                        {
                            SucceedMission();
                        }
                    }

                    TimerBars?.Draw();
                    GameFiber.Yield();
                }

                UnloadInteriors();

            });

        }