public void Draw()
        {
            if (!Visible) return;

            SizeF res = UIMenu.GetScreenResolutionMantainRatio();
            int middle = Convert.ToInt32(res.Width / 2);

            new Sprite("mpentry", "mp_modenotselected_gradient", new Point(0, 30), new Size(Convert.ToInt32(res.Width), 300),
                0f, Color.FromArgb(230, 255, 255, 255)).Draw();

            new ResText("mission failed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 148, 27, 46), Common.EFont.Pricedown, ResText.Alignment.Centered).Draw();

            new ResText(Reason, new Point(middle, 230), 0.5f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Centered).Draw();

            var scaleform = new Scaleform(0);
            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, NativeFunction.CallByHash(0x0499D7B09FC9B407, typeof(string), 2, (int)GameControl.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();

            NativeFunction.CallByName<uint>("DISABLE_ALL_CONTROL_ACTIONS", 0);
            NativeFunction.CallByName<uint>("ENABLE_CONTROL_ACTION", 0, (int) GameControl.FrontendAccept);

            if (Game.IsControlJustPressed(0, GameControl.FrontendAccept))
            {
                HasPressedContinue = true;
                NativeFunction.CallByHash<uint>(0xB4EDDC19532BFB85);
            }
        }
Пример #2
0
 public void Dispose()
 {
     unsafe
     {
         int handle = _sc.Handle;
         NativeFunction.Natives.SetScaleformMovieAsNoLongerNeeded(ref handle);
     }
     _sc = null;
 }
Пример #3
0
 public void Dispose()
 {
     unsafe
     {
         int handle = _sc.Handle;
         NativeFunction.CallByName<uint>("SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED", &handle);
     }
     _sc = null;
 }
Пример #4
0
 public void Dispose()
 {
     unsafe
     {
         int handle = _sc.Handle;
         NativeFunction.CallByName <uint>("SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED", &handle);
     }
     _sc = null;
 }
Пример #5
0
        public InstructionalButtons()
        {
            Scaleform = new Scaleform();

            Buttons               = new InstructionalButtonsCollection();
            Buttons.ItemAdded    += (c, i) => Update();
            Buttons.ItemRemoved  += (c, i) => Update();
            Buttons.ItemModified += (c, o, n) => Update();
            Buttons.Cleared      += (c) => Update();
        }
Пример #6
0
        public void Load(bool waitToLoad)
        {
            if (_sc != null) return;
            _sc = new Scaleform(0);
            _sc.Load("MP_BIG_MESSAGE_FREEMODE");

            if (waitToLoad)
            {
                var timeout = 1000;
                var start = System.DateTime.Now;
                while (!NativeFunction.CallByName<bool>("HAS_SCALEFORM_MOVIE_LOADED", _sc.Handle) && System.DateTime.Now.Subtract(start).TotalMilliseconds < timeout)
                    GameFiber.Yield();
            }
        }
Пример #7
0
        public void Draw()
        {
            if (needsUpdate ||
                N.HasInputJustChanged(2)) // check so the correct keys or controller buttons are displayed when the user switches between keyboard and controller
            {
                DoUpdate();
            }

            if (ScriptGlobals.TimerBarsInstructionButtonsNumRowsAvailable)
            {
                ScriptGlobals.TimerBarsInstructionButtonsNumRows = NumberOfRows;
            }

            Scaleform.Render2D();
        }
Пример #8
0
        public void Update()
        {
            Scaleform.CallFunction("CLEAR_ALL");
            Scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            Scaleform.CallFunction("CREATE_CONTAINER");

            int dateSlotIndex = 0;

            for (int i = 0; i < Buttons.Count; i++)
            {
                InstructionalButton b = Buttons[i];
                if (b.CanBeDisplayed == null || b.CanBeDisplayed.Invoke(b))
                {
                    Scaleform.CallFunction("SET_DATA_SLOT", dateSlotIndex++, b.GetButtonId(), b.Text ?? "");
                }
            }
            Scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
        }
Пример #9
0
        public void Load(bool waitToLoad)
        {
            if (_sc != null)
            {
                return;
            }
            _sc = new Scaleform(0);
            _sc.Load("MP_BIG_MESSAGE_FREEMODE");

            if (waitToLoad)
            {
                var timeout = 1000;
                var start   = System.DateTime.Now;
                while (!NativeFunction.Natives.HasScaleformMovieLoaded <bool>(_sc.Handle) && System.DateTime.Now.Subtract(start).TotalMilliseconds < timeout)
                {
                    GameFiber.Yield();
                }
            }
        }
Пример #10
0
        public void Load(bool waitToLoad)
        {
            if (_sc != null)
            {
                return;
            }
            _sc = new Scaleform(0);
            _sc.Load("MP_BIG_MESSAGE_FREEMODE");

            if (waitToLoad)
            {
                var timeout = 1000;
                var start   = System.DateTime.Now;
                while (!NativeFunction.CallByName <bool>("HAS_SCALEFORM_MOVIE_LOADED", _sc.Handle) && System.DateTime.Now.Subtract(start).TotalMilliseconds < timeout)
                {
                    GameFiber.Yield();
                }
            }
        }
Пример #11
0
        public void ShowInstructionalButtons()
        {
            if (_sc == null)
            {
                _sc = new Scaleform(0);
                _sc.Load("instructional_buttons");
            }

            _sc.CallFunction("CLEAR_ALL");
            _sc.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            _sc.CallFunction("CREATE_CONTAINER");


            _sc.CallFunction("SET_DATA_SLOT", 0, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.CellphoneSelect, 0), "Select");
            _sc.CallFunction("SET_DATA_SLOT", 1, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.CellphoneCancel, 0), "Back");

            _sc.CallFunction("SET_DATA_SLOT", 2, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.FrontendRb, 0), "");
            _sc.CallFunction("SET_DATA_SLOT", 3, (string)NativeFunction.CallByHash(0x0499d7b09fc9b407, typeof(string), 2, (int)GameControl.FrontendLb, 0), "Browse");

        }
Пример #12
0
        private void DoUpdate()
        {
            if (!Scaleform.IsLoaded)
            {
                Scaleform.Load(ScaleformName);
                return;
            }

            Scaleform.CallFunction("CLEAR_ALL");
            Scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", MouseButtonsEnabled);
            Scaleform.CallFunction("SET_MAX_WIDTH", MaxWidth);

            for (int i = 0, slot = 0; i < Buttons.Count; i++)
            {
                IInstructionalButtonSlot b = Buttons[i];
                if (b.CanBeDisplayed == null || b.CanBeDisplayed(b))
                {
                    if (MouseButtonsEnabled)
                    {
                        Scaleform.CallFunction("SET_DATA_SLOT", slot++,
                                               b.GetButtonId() ?? string.Empty,
                                               b.Text ?? string.Empty,
                                               b.BindedControl.HasValue,                                    // clickable?
                                               b.BindedControl.HasValue ? (int)b.BindedControl.Value : -1); // control binded to click
                    }
                    else
                    {
                        Scaleform.CallFunction("SET_DATA_SLOT", slot++,
                                               b.GetButtonId() ?? string.Empty,
                                               b.Text ?? string.Empty);
                    }
                }
            }

            Scaleform.CallFunction("SET_BACKGROUND_COLOUR", (int)BackgroundColor.R, (int)BackgroundColor.G, (int)BackgroundColor.B, (int)BackgroundColor.A);
            Scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", 0);

            needsUpdate = false;
        }
Пример #13
0
        private void DrawInstructionalButtonsScaleform()
        {
            var instructButts = new Scaleform();
            instructButts.Load("instructional_buttons");
            instructButts.CallFunction("CLEAR_ALL");
            instructButts.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            instructButts.CallFunction("CREATE_CONTAINER");
            instructButts.CallFunction("SET_DATA_SLOT", 0, Util.GetControlButtonId(GameControl.CellphoneRight), "");
            instructButts.CallFunction("SET_DATA_SLOT", 1, Util.GetControlButtonId(GameControl.CellphoneLeft), "Navigate");
            
            instructButts.CallFunction("SET_DATA_SLOT", 2, Util.GetControlButtonId(GameControl.FrontendRb), "");
            instructButts.CallFunction("SET_DATA_SLOT", 3, Util.GetControlButtonId(GameControl.FrontendLb), "Jump to Markers");


            instructButts.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
        }
Пример #14
0
 public void Draw()
 {
     Scaleform.Render2D();
 }
Пример #15
0
 private void DrawInstructionalButtonsScaleform()
 {
     var instructButts = new Scaleform();
     instructButts.Load("instructional_buttons");
     instructButts.CallFunction("CLEAR_ALL");
     instructButts.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
     instructButts.CallFunction("CREATE_CONTAINER");
     instructButts.CallFunction("SET_DATA_SLOT", 0, Util.GetControlButtonId(GameControl.Attack), "Place Waypoint");
     instructButts.CallFunction("SET_DATA_SLOT", 1, Util.GetControlButtonId(GameControl.Attack), "Waypoint Properties");
     instructButts.CallFunction("SET_DATA_SLOT", 2, Util.GetControlButtonId(GameControl.CreatorDelete), "Remove Waypoint");
     instructButts.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
 }
        public void Draw()
        {
            if (!Visible) return;

            SizeF res = UIMenu.GetScreenResolutionMantainRatio();
            int middle = Convert.ToInt32(res.Width / 2);

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

            new ResText("mission passed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Common.EFont.Pricedown, ResText.Alignment.Centered).Draw();

            new ResText(Title, new Point(middle, 230), 0.5f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Centered).Draw();

            new ResRectangle(new Point(middle - 300, 290), new Size(600, 2), Color.White).Draw();

            for (int i = 0; i < _items.Count; i++)
            {
                new ResText(_items[i].Item1, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Left).Draw();
                new ResText(_items[i].Item2, new Point(_items[i].Item3 == TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right).Draw();
                if (_items[i].Item3 == TickboxState.None) continue;
                string spriteName = "shop_box_blank";
                switch (_items[i].Item3)
                {
                    case TickboxState.Tick:
                        spriteName = "shop_box_tick";
                        break;
                    case TickboxState.Cross:
                        spriteName = "shop_box_cross";
                        break;
                }
                new Sprite("commonmenu", spriteName, new Point(middle + 230, 290 + (40 * i)), new Size(48, 48)).Draw();
            }
            new ResRectangle(new Point(middle - 300, 300 + (40 * _items.Count)), new Size(600, 2), Color.White).Draw();

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

            string medalSprite = "bronzemedal";
            switch (_medal)
            {
                case Medal.Silver:
                    medalSprite = "silvermedal";
                    break;
                case Medal.Gold:
                    medalSprite = "goldmedal";
                    break;
            }

            new Sprite("mpmissionend", medalSprite, new Point(middle + 150, 320 + (40 * _items.Count)), new Size(32, 32)).Draw();

            var scaleform = new Scaleform(0);
            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, NativeFunction.CallByHash(0x0499D7B09FC9B407,typeof(string), 2, (int)GameControl.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();

            NativeFunction.CallByName<uint>("DISABLE_ALL_CONTROL_ACTIONS", 0);
            NativeFunction.CallByName<uint>("ENABLE_CONTROL_ACTION", 0, (int)GameControl.FrontendAccept);

            if (Game.IsControlJustPressed(0, GameControl.FrontendAccept))
            {
                HasPressedContinue = true;
                NativeFunction.CallByHash<uint>(0xB4EDDC19532BFB85);
            }
        }
Пример #17
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);
        }
Пример #18
0
        public Editor()
        {
            Children = new List<INestedMenu>();

            #region NativeUI Initialization
            _menuPool = new MenuPool();
            #region Main Menu
            _mainMenu = new UIMenu("Mission Creator", "MAIN MENU");
            _mainMenu.ResetKey(Common.MenuControls.Back);
            _mainMenu.ResetKey(Common.MenuControls.Up);
            _mainMenu.ResetKey(Common.MenuControls.Down);
            _mainMenu.SetKey(Common.MenuControls.Up, GameControl.CellphoneUp, 0);
            _mainMenu.SetKey(Common.MenuControls.Down, GameControl.CellphoneDown, 0);
            _menuPool.Add(_mainMenu);

            {
                var menuItem = new NativeMenuItem("Create a Mission", "Create a new mission.");
                menuItem.Activated += (sender, item) =>
                {
                    CreateNewMission();
                    EnterFreecam();
                };
                _mainMenu.AddItem(menuItem);
            }

            {
                var menuItem = new NativeMenuItem("Play Mission", "Play a mission.");
                menuItem.Activated += (sender, item) =>
                {
                    GameFiber.StartNew(delegate
                    {
                        DisableControlEnabling = true;
                        var newMenu = new LoadMissionMenu();
                        _mainMenu.Visible = false;
                        newMenu.RebuildMenu();
                        newMenu.ParentMenu = _mainMenu;
                        newMenu.Visible = true;
                        while (newMenu.Visible)
                        {
                            newMenu.ProcessControl();
                            newMenu.Draw();
                            GameFiber.Yield();
                        }
                        DisableControlEnabling = false;
                        if (newMenu.ReturnedData == null) return;
                        LeaveEditor();
                        EntryPoint.MissionPlayer.Load(newMenu.ReturnedData);
                    });
                };
                _mainMenu.AddItem(menuItem);
            }

            {
                var menuItem = new NativeMenuItem("Load Mission", "Load your mission for editing.");
                menuItem.Activated += (sender, item) =>
                {
                    GameFiber.StartNew(delegate
                    {
                        DisableControlEnabling = true;
                        _mainMenu.Visible = false;
                        var newMenu = new LoadMissionMenu();
                        newMenu.RebuildMenu();
                        newMenu.ParentMenu = _mainMenu;
                        newMenu.Visible = true;
                        while (newMenu.Visible)
                        {
                            newMenu.ProcessControl();
                            newMenu.Draw();
                            GameFiber.Yield();
                        }
                        DisableControlEnabling = false;
                        if (newMenu.ReturnedData == null) return;
                        LoadMission(newMenu.ReturnedData);
                    });
                };
                _mainMenu.AddItem(menuItem);
            }

            {
                var menuItem = new NativeMenuItem("Exit to Grand Theft Auto V", "Leave the Mission Creator");
                menuItem.Activated += (sender, item) =>
                {
                    if(!EntryPoint.MissionPlayer.IsMissionPlaying)
                        LeaveEditor();
                    else
                    {
                        GameFiber.StartNew(delegate
                        {
                            _mainMenu.Visible = false;
                            EntryPoint.MissionPlayer.FailMission(reason: "You canceled the mission.");

                            IsInMainMenu = false;
                            _menuPool.CloseAllMenus();
                            BigMinimap = false;
                            IsInFreecam = false;
                            IsInEditor = false;
                        });
                    }
                };
                _mainMenu.AddItem(menuItem);
            }

            _menuPool.ToList().ForEach(menu =>
            {
                menu.RefreshIndex();
                menu.MouseControlsEnabled = false;
                menu.MouseEdgeEnabled = false;
            });
            #endregion

            #region Editor Menu
            _missionMenu = new UIMenu("Mission Creator", "MISSION MAIN MENU");
            _missionMenu.ResetKey(Common.MenuControls.Back);
            _missionMenu.MouseControlsEnabled = false;
            _missionMenu.ResetKey(Common.MenuControls.Up);
            _missionMenu.ResetKey(Common.MenuControls.Down);
            _missionMenu.SetKey(Common.MenuControls.Up, GameControl.CellphoneUp, 0);
            _missionMenu.SetKey(Common.MenuControls.Down, GameControl.CellphoneDown, 0);
            _menuPool.Add(_missionMenu);
            #endregion
            

            #endregion

            RingData = new RingData()
            {
                Display = true,
                Type = RingType.HorizontalCircleSkinny,
                Radius = 2f,
                Color = Color.Gray,
            };

            MarkerData = new MarkerData()
            {
                Display = false,
            };

            MarkerData.OnMarkerTypeChange += (sender, args) =>
            {
                if (string.IsNullOrEmpty(MarkerData.MarkerType))
                {
                    if (_mainObject != null && _mainObject.IsValid())
                        _mainObject.Delete();
                    return;
                }
                var pos = Game.LocalPlayer.Character.Position;
                if (_mainObject != null && _mainObject.IsValid())
                {
                    pos = _mainObject.Position;
                    _mainObject.Delete();
                }
                GameFiber.StartNew(delegate
                {
                    _mainObject = new Object(Util.RequestModel(MarkerData.MarkerType), pos);
                    NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", _mainObject.Handle.Value, false, 0);
                });
            };

            _cutsceneUi = new CutsceneUi();

            CameraClampMax = -30f;
            CameraClampMin = -85f;

            _blips = new List<Blip>();

            _instructButts = new Scaleform();

            if (!Directory.Exists(basePath))
            {
                try
                {
                    Directory.CreateDirectory(basePath);
                }
                catch (UnauthorizedAccessException)
                {
                    Game.DisplayNotification("~r~~h~ERROR~h~~n~~w~Access denied for folder creation. Run as administrator.");
                }
            }
        }