Beispiel #1
1
        /// <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<UIMenuItem, UIMenu>();
            WidthOffset = 0;

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

            _mainMenu = new UIContainer(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 UIResText(title, new Point(215 + _offset.X, 20 + _offset.Y), 1.15f, Color.White, Font.HouseScript, UIResText.Alignment.Centered));
            if (!String.IsNullOrWhiteSpace(subtitle))
            {
                _mainMenu.Items.Add(new UIResRectangle(new Point(0 + offset.X, 107 + _offset.Y), new Size(431, 37), Color.Black));
                _mainMenu.Items.Add(Subtitle = new UIResText(subtitle, new Point(8 + _offset.X, 110 + _offset.Y), 0.35f, Color.WhiteSmoke, 0, UIResText.Alignment.Left));

                if (subtitle.StartsWith("~"))
                {
                    CounterPretext = subtitle.Substring(0, 3);
                }
                _counterText = new UIResText("", new Point(425 + _offset.X, 110 + _offset.Y), 0.35f, Color.WhiteSmoke, 0, UIResText.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 UIResRectangle(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 UIResRectangle(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 UIResRectangle(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 UIResText("Description", new Point(_offset.X + 5, 125), 0.35f, Color.FromArgb(255, 255, 255, 255), Font.ChaletLondon, UIResText.Alignment.Left);

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

            SetKey(MenuControls.Up, Control.PhoneUp);
            SetKey(MenuControls.Down, Control.PhoneDown);
            SetKey(MenuControls.Left, Control.PhoneLeft);
            SetKey(MenuControls.Right, Control.PhoneRight);
            SetKey(MenuControls.Select, Control.FrontendAccept);

            SetKey(MenuControls.Back, Control.PhoneCancel);
            SetKey(MenuControls.Back, Control.FrontendPause);
        }
Beispiel #2
0
        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 UIResText("mission failed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 148, 27, 46), Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Reason, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.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, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
            if (Game.IsControlJustPressed(0, Control.FrontendAccept))
            {
                Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
            }
        }
Beispiel #3
0
        public static Model LoadObject(int hash)
        {
            int counter = 0;
            var res = UIMenu.GetScreenResolutionMantainRatio();

            var m = new Model(hash);

            if (!m.IsValid || !m.IsInCdImage)
            {
                if (!ObjectDatabase.InvalidHashes.Contains(hash))
                {
                    ObjectDatabase.InvalidHashes.Add(hash);
                    ObjectDatabase.SaveInvalidHashes();
                }
                return null;
            }
            globalCounter++;
            var 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, "b_50", Translation.Translate("Loading Model"));
            sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            while (!m.IsLoaded && counter < 200)
            {
                m.Request();
                Script.Yield();
                counter++;
                sc.Render2D();
            }
            return m;
        }
Beispiel #4
0
        public static Model LoadObject(int hash)
        {
            int counter = 0;
            var res     = UIMenu.GetScreenResolutionMaintainRatio();

            var m = new Model(hash);

            if (!m.IsValid || !m.IsInCdImage)
            {
                if (!ObjectDatabase.InvalidHashes.Contains(hash))
                {
                    ObjectDatabase.InvalidHashes.Add(hash);
                    ObjectDatabase.SaveInvalidHashes();
                }
                return(null);
            }
            globalCounter++;
            var 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, "b_50", Translation.Translate("Loading Model"));
            sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            while (!m.IsLoaded && counter < 200)
            {
                m.Request();
                Script.Yield();
                counter++;
                sc.Render2D();
            }
            return(m);
        }
Beispiel #5
0
        public void Draw()
        {
            if (!Visible)
            {
                return;
            }

            var res    = UIMenu.GetScreenResolutionMantainRatio();
            var 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), Font.Pricedown, ResText.Alignment.Centered).Draw();

            new ResText(Reason, new Point(middle, 230), 0.5f, Color.White, Font.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.Natives.x0499D7B09FC9B407 <string>(2, 201, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();

            if (!Game.IsKeyDown(Keys.Enter))
            {
                return;
            }
            NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0); // Doesn't work
        }
Beispiel #6
0
 public ClassicChat()
 {
     CurrentInput   = "";
     _mainScaleform = new Scaleform(0);
     _mainScaleform.Load("multiplayer_chat");
     _messages = new List <Tuple <string, Color> >();
 }
Beispiel #7
0
        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 UIResText("mission failed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 148, 27, 46), Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Reason, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.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, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
            if (Game.IsControlJustPressed(0, Control.FrontendAccept))
            {
                Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
            }
        }
        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);
        }
Beispiel #9
0
        public void Load()
        {
            if (_sc != null)
            {
                return;
            }
            _sc = new Scaleform(0);
            _sc.Load("MP_BIG_MESSAGE_FREEMODE");
            var timeout = 1000;
            var start   = DateTime.Now;

            while (!Function.Call <bool>(Hash.HAS_SCALEFORM_MOVIE_LOADED, _sc.Handle) && DateTime.Now.Subtract(start).TotalMilliseconds < timeout)
            {
                Script.Yield();
            }
        }
Beispiel #10
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);
        }
Beispiel #11
0
        public Prop CreateObject(Model model, Vector3 position, Vector3 rotation, bool dynamic, int netHash)
        {
            if (model == null)
            {
                LogManager.DebugLog("Model was null?");
                return(null);
            }

            int counter = 0;
            var 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, "b_50", "Loading Model");
            sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            while (!model.IsLoaded && counter < 500)
            {
                model.Request();
                Script.Yield();
                counter++;
                sc.Render2D();
            }

            var veh = new Prop(Function.Call <int>(Hash.CREATE_OBJECT_NO_OFFSET, model.Hash, position.X, position.Y, position.Z, true, true, dynamic));

            veh.Rotation    = rotation;
            veh.Position    = position;
            veh.LodDistance = 3000;

            if (!dynamic)
            {
                veh.FreezePosition = true;
            }

            lock (HandleMap)
                if (!HandleMap.Reverse.ContainsKey(veh.Handle))
                {
                    HandleMap.Reverse.Add(veh.Handle, netHash);
                }

            model.MarkAsNoLongerNeeded();
            return(veh);
        }
Beispiel #12
0
        public Chatbox(Main Main)
            : base(new Point(10, 10), new Size(400, 160), Color.FromArgb(0, 0, 0, 0))
        {
            this.Main = Main;

            int x = 5;
            int y = 5;
            for(int index = 0; index < 10; index++) {
                Items.Add(new UIText("", new Point(x, y), 0.3f));
                y += 15;
            }

            ScaleForm = new Scaleform(0);
            ScaleForm.Load("multiplayer_chat");

            ScaleForm.CallFunction("SET_FOCUS", 2, 2, "ALL");
            ScaleForm.CallFunction("SET_FOCUS", 1, 2, "ALL");
        }
Beispiel #13
0
        public static void DrawScaleform()
        {
            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, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.Jump, 0), "Begin Assault");
            scaleform.CallFunction("SET_DATA_SLOT", 1, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendCancel, 0), "Cancel");
            scaleform.CallFunction("SET_DATA_SLOT", 2, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneRight, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 3, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneLeft, 0), "Change Mission");
            scaleform.CallFunction("SET_DATA_SLOT", 4, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendRb, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 5, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendLb, 0), "Change Entry Point");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
        }
Beispiel #14
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, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneSelect, 0), UIMenu._selectTextLocalized);
            _sc.CallFunction("SET_DATA_SLOT", 1, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneCancel, 0), UIMenu._backTextLocalized);

            _sc.CallFunction("SET_DATA_SLOT", 2, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendRb, 0), "");
            _sc.CallFunction("SET_DATA_SLOT", 3, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendLb, 0), _browseTextLocalized);
        }
Beispiel #15
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");
        }
        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);
            }
        }
Beispiel #17
0
        public void OnActivate()
        {
            camera = new Camera(true);
            camera.SetRotationYaw(Game.LocalPlayer.Character.CurrentVehicle.Heading);
            camera.AttachToEntity(Game.LocalPlayer.Character.CurrentVehicle, HeliCamOffsetsDictionary.Instance[Game.LocalPlayer.Character.CurrentVehicle.Model], true);

            hudScaleform = new Scaleform();
            hudScaleform.Load("heli_cam");

            NativeFunction.Natives.RequestStreamedTextureDict("helicopterhud", true);

            hudScaleform.CallFunction("SET_CAM_LOGO", lsCountyLogoEnabled);

            backgroundSound    = new Sound();
            turnSound          = new Sound();
            zoomSound          = new Sound();
            searchLoopSound    = new Sound();
            searchSuccessSound = new Sound();

            Sound.RequestAmbientAudioBank("SCRIPT\\POLICE_CHOPPER_CAM");

            NativeFunction.Natives.SetNoiseoveride(true);
            NativeFunction.Natives.SetNoisinessoveride(0.15f);
        }
        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 UIResText("race completed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Title, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw();

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

            for (int i = 0; i < _items.Count; i++)
            {
                new UIResText(_items[i].Item1, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Left).Draw();
                new UIResText(_items[i].Item2, new Point(_items[i].Item3 == TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.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 UIResRectangle(new Point(middle - 300, 300 + (40 * _items.Count)), new Size(600, 2), Color.White).Draw();

            new UIResText("Completion", new Point(middle - 150, 320 + (40 * _items.Count)), 0.4f).Draw();
            new UIResText(_completionRate + "%", new Point(middle + 150, 320 + (40 * _items.Count)), 0.4f, Color.White, Font.ChaletLondon, UIResText.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, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
            if (Game.IsControlJustPressed(0, Control.FrontendAccept))
            {
                Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                ContinueHit();
            }
        }
        public void Draw()
        {
            if (!Visible)
            {
                return;
            }

            var res    = UIMenu.GetScreenResolutionMantainRatio();
            var 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), Font.Pricedown, ResText.Alignment.Centered).Draw();

            new ResText(Title, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, ResText.Alignment.Centered).Draw();
            new ResRectangle(new Point(middle - 300, 290), new Size(600, 2), Color.White).Draw();

            for (var i = 0; i < _items.Count; i++)
            {
                new ResText(_items[i].Label, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, ResText.Alignment.Left).Draw();
                new ResText(_items[i].Status, new Point(_items[i].TickState == TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, ResText.Alignment.Right).Draw();
                if (_items[i].TickState == TickboxState.None)
                {
                    continue;
                }
                var spriteName = "shop_box_blank";
                if (_items[i].TickState == TickboxState.Tick)
                {
                    spriteName = "shop_box_tick";
                }
                else if (_items[i].TickState == TickboxState.Cross)
                {
                    spriteName = "shop_box_cross";
                }

                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(_completeValue + "%", new Point(middle + 150, 320 + (40 * _items.Count)), 0.4f, Color.White, Font.ChaletLondon, ResText.Alignment.Right).Draw();

            var medalSprite = "bronzemedal";

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

            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.Natives.x0499D7B09FC9B407 <string>(2, 201, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();

            if (!Game.IsKeyDown(Keys.Enter))
            {
                return;
            }
            NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0); // Doesn't work
            //Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET"); -- todo figure this out
            ContinueHit();
        }
Beispiel #20
0
        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 UIResText("mission passed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Title, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw();

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

            for (int i = 0; i < _items.Count; i++)
            {
                new UIResText(_items[i].Item1, new Point(middle - 230, 300 + (40*i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Left).Draw();
                new UIResText(_items[i].Item2, new Point(_items[i].Item3 == TickboxState.None ? middle + 265 : middle + 230, 300 + (40*i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.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 UIResRectangle(new Point(middle - 300, 300 + (40 * _items.Count)), new Size(600, 2), Color.White).Draw();

            new UIResText("Completion", new Point(middle - 150, 320 + (40 * _items.Count)), 0.4f).Draw();
            new UIResText(_completionRate + "%", new Point(middle + 150, 320 + (40 * _items.Count)), 0.4f, Color.White, Font.ChaletLondon, UIResText.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, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
            if (Game.IsControlJustPressed(0, Control.FrontendAccept))
            {
                Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                ContinueHit();
            }
        }
	    public void OnTick(object sender, EventArgs e)
	    {
		    if (DateTime.Now.Second != _lasttime.Second)
		    {
			    _seconds++;
			    _lasttime = DateTime.Now;
			    if (_isInRace && _countdown > 0)
			    {
				    var screen = UIMenu.GetScreenResolutionMantainRatio();
				    var w = Convert.ToInt32(screen.Width/2);
				    _countdown--;
					if(_countdown > 3) return;
				    _fadeoutSprite = new Sprite("mpinventory", "in_world_circle", new Point(w - 125, 200), new Size(250, 250), 0f, _countdown == 0 ? Color.FromArgb(49, 235, 126) : Color.FromArgb(241, 247, 57));
					Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
					Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
					if (_countdown == 0)
				    {
					    _participants.ForEach(car => car.FreezePosition = false);
					    _missionStart = _seconds;
				    }
			    }
				else if (_isInRace && _countdown == 0)
				{
					_countdown = -1;
				}
		    }

			GUI.MainMenu.ProcessControl();
			GUI.MainMenu.ProcessMouse();
			GUI.MainMenu.Draw();

			_quitMenu.ProcessControl();
			_quitMenu.ProcessMouse();
			_quitMenu.Draw();

			GUI.DrawSettings(_previewRace, _previewVehicle);

			_passed?.Draw();

			if (_countdown > -1 && _countdown <= 3)
		    {
				var screen = UIMenu.GetScreenResolutionMantainRatio();
				var w = Convert.ToInt32(screen.Width / 2);
				new UIResText(_countdown == 0 ? "GO" : _countdown.ToString(), new Point(w, 260), 2f, Color.White, Font.Pricedown, UIResText.Alignment.Centered).Draw();
		    }

		    if (_fadeoutSprite?.Color.A > 5)
		    {
			    _fadeoutSprite.Color = Color.FromArgb(_fadeoutSprite.Color.A - 5, _fadeoutSprite.Color.R, _fadeoutSprite.Color.G,
				    _fadeoutSprite.Color.B);
				_fadeoutSprite.Draw();
		    }


            /* COURIER */
            GUICourier.Init();
            GUICourier.MainMenu.ProcessControl();
            GUICourier.MainMenu.ProcessMouse();
            var safe = UIMenu.GetSafezoneBounds();
            var res = UIMenu.GetScreenResolutionMantainRatio();

            new UIResRectangle(new Point(((int)res.Width-200), 0), new Size(200, 400), Color.FromArgb(200,0,0,0)).Draw();

            GUICourier.MainMenu.Draw();

            if (activeDeliveries.Count == 0 || (_seconds - lastSpawn > 60 && activeDeliveries.Count < 3))
            {
                Delivery d = Delivery.CreateDelivery();
                d.activate();
                activeDeliveries.Add(d);
                lastSpawn = _seconds;
                UI.Notify("New delivery available");
            }

            int pick = 0,drop = 0;
            Vector3 me = Game.Player.Character.Position;
            String posStr = String.Format("{0} {1} {2}", me.X.ToString("F02"), me.Y.ToString("F02"), me.Z.ToString("F02"));


            new UIResText("Pickup", new Point(Convert.ToInt32(res.Width) - 190, 20), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left) { DropShadow = true }.Draw();
            new UIResText("Dropoff", new Point(Convert.ToInt32(res.Width) - 190, 210), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left) { DropShadow = true }.Draw();
            foreach (Delivery d in activeDeliveries.GetRange(0,activeDeliveries.Count)) {
                d.tick();
                if (d.isActive == false)
                {
                    activeDeliveries.Remove(d);
                    continue;
                }

 
                if (d._isStarted)
                {
                    float dist = me.DistanceTo(d.end);
                    String posStr2 = String.Format("{0} {1} {2}", d.end.X.ToString("F02"), d.end.Y.ToString("F02"), d.end.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.end_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (drop + 2) + 210), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

                    drop++;
                }
                else {
                    float dist = me.DistanceTo(d.start);
                    String posStr2 = String.Format("{0} {1} {2}", d.start.X.ToString("F02"), d.start.Y.ToString("F02"), d.start.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.start_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (pick + 2)), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

                    pick++;
                }
                //new UIResText("WORLD", new Point(Convert.ToInt32(res.Width) - 190, 40), .35f, Color.DodgerBlue, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();

            }
            /* COURIER */

            if (!_isInRace)
		    {
				if(GUI.IsInMenu) return;
			    foreach (var race in _races)
			    {
				    World.DrawMarker(MarkerType.VerticalCylinder, race.Trigger, new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(5f, 5f, 1f), Color.FromArgb(200, 255, 255, 255));
					if(!Game.Player.Character.IsInRangeOf(race.Trigger, 50f)) continue;
				    var tmpSF = new Scaleform(0);
				    tmpSF.Load("PLAYER_NAME_01");
					tmpSF.CallFunction("SET_PLAYER_NAME", race.Name);
				    
					tmpSF.Render3D(race.Trigger + new Vector3(0f, 0f, 2f), new Vector3(0f, 0f, _oldAngle), new Vector3(12, 6, 2));

					var tmpT = new Scaleform(0);
					tmpT.Load("PLAYER_NAME_02");
					tmpT.CallFunction("SET_PLAYER_NAME", "Community Race");

					tmpT.Render3D(race.Trigger + new Vector3(0f, 0f, 1.5f), new Vector3(0f, 0f, _oldAngle), new Vector3(6, 3, 1));

					_oldAngle += 2f;

                    if (!Game.Player.Character.IsInRangeOf(race.Trigger, 5f)) continue;

                    Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
                    Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, "Press ~INPUT_CONTEXT~ to participate in this Community Race.");
                    Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);

                    if (Game.IsControlJustPressed(0, GTA.Control.Context))
				    {
					    Game.Player.CanControlCharacter = false;
					    Game.Player.Character.Position = race.Trigger + new Vector3(4f, 0f, -1f);
					    _previewRace = race;
						BuildMenu(race);
					    GUI.MainMenu.Visible = true;
					    GUI.IsInMenu = true;
					    break;
				    }
			    }
				
		    }
		    else if(_isInRace)
		    {
				if(!_raceSettings["Wanted"])
					Function.Call(Hash.SET_MAX_WANTED_LEVEL, 0);
				//if(Game.Player.Character.IsInVehicle())
				Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.VehicleExit);
			    if ((Game.IsControlJustPressed(0, GTA.Control.VehicleExit) && Game.Player.Character.IsInVehicle()) || (!Game.Player.Character.IsInVehicle() && !Game.Player.Character.IsGettingIntoAVehicle && Game.IsControlJustPressed(0, GTA.Control.Enter)))
			    {
					_quitMenu.RefreshIndex();
				    _quitMenu.Visible = !_quitMenu.Visible;
			    }
				
			    if (!Convert.ToBoolean(_raceSettings["Traffic"]))
			    {
				    Vehicle[] close = World.GetNearbyVehicles(Game.Player.Character, 10000f);
				    foreach (Vehicle vehicle in close)
				    {
					    if (_currentRivals.Any(riv => riv.Vehicle.Handle == vehicle.Handle) ||
					        Game.Player.Character.IsInVehicle(vehicle)) continue;
						vehicle.GetPedOnSeat(VehicleSeat.Driver)?.Delete();
						vehicle?.Delete();
				    }
			    }

			//    var res = UIMenu.GetScreenResolutionMantainRatio();
			//    var safe = UIMenu.GetSafezoneBounds();
			    const int interval = 45;
			    if (_countdown <= 0)
			    {
				    new UIResText("TIME",new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (1*interval))),0.3f, Color.White).Draw();
				    new UIResText(FormatTime((int) unchecked(_seconds - _missionStart)),new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (1*interval))),0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
				    new Sprite("timerbars", "all_black_bg",new Point(Convert.ToInt32(res.Width) - safe.X - 248,Convert.ToInt32(res.Height) - safe.Y - (100 + (1*interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

					new UIResText("POSITION", new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (2 * interval))), 0.3f, Color.White).Draw();
					new UIResText((CalculatePlayerPositionInRace() + 1) + "/" + (_currentRivals.Count + 1), new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (2 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
					new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - 248, Convert.ToInt32(res.Height) - safe.Y - (100 + (2 * interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

				    if (_raceSettings["Laps"] > 1)
				    {
						int playerCheckpoint = _currentRace.Checkpoints.Length - _checkpoints.Count;
					    int currentLap = Convert.ToInt32(Math.Floor(playerCheckpoint/(decimal)_totalLaps)) + 1;

						new UIResText("LAP",new Point(Convert.ToInt32(res.Width) - safe.X - 180,Convert.ToInt32(res.Height) - safe.Y - (90 + (3*interval))), 0.3f, Color.White).Draw();
					    new UIResText(currentLap + "/" + _raceSettings["Laps"], new Point(Convert.ToInt32(res.Width) - safe.X - 20,Convert.ToInt32(res.Height) - safe.Y - (102 + (3*interval))), 0.5f, Color.White, Font.ChaletLondon,UIResText.Alignment.Right).Draw();
					    new Sprite("timerbars", "all_black_bg",new Point(Convert.ToInt32(res.Width) - safe.X - 248,Convert.ToInt32(res.Height) - safe.Y - (100 + (3*interval))), new Size(250, 37), 0f,Color.FromArgb(200, 255, 255, 255)).Draw();
				    }
			    }


			    for (int i = 0; i < _rivalCheckpointStatus.Count; i++)
			    {
				    Tuple<Rival, int> tuple = _rivalCheckpointStatus[i];
				    if (tuple.Item1.Vehicle.IsInRangeOf(_currentRace.Checkpoints[tuple.Item2], 10f))
				    {
					    tuple.Item1.Character.Task.ClearAll();
					    if (_currentRace.Checkpoints.Length <= tuple.Item2 + 1)
					    {
						    if (!_finishedParticipants.Contains(tuple.Item1))
							    _finishedParticipants.Add(tuple.Item1);
						    tuple.Item1.Vehicle.HandbrakeOn = true;
						    continue;
					    }
					    _rivalCheckpointStatus[i] = new Tuple<Rival, int>(tuple.Item1,tuple.Item2 + 1);
					    Function.Call(Hash.TASK_VEHICLE_MISSION_COORS_TARGET, tuple.Item1.Character.Handle, tuple.Item1.Vehicle.Handle,
						    _currentRace.Checkpoints[tuple.Item2 + 1].X, _currentRace.Checkpoints[tuple.Item2 + 1].Y,
						    _currentRace.Checkpoints[tuple.Item2 + 1].Z, Mode, 200f, Rival.MainDrivingStyle, 5f, 0f, 0); // TODO: Debuggin // old - 6
				    }
			    }


			    World.DrawMarker(MarkerType.VerticalCylinder, _checkpoints[0], new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(10f, 10f, 2f), Color.FromArgb(100, 241, 247, 57));
			    if (_nextBlip == null)
				    _nextBlip = World.CreateBlip(_checkpoints[0]);
			    if (_checkpoints.Count >= 2)
			    {
				    if (_secondBlip == null)
				    {
					    _secondBlip = World.CreateBlip(_checkpoints[1]);
					    _secondBlip.Scale = 0.5f;
						if(_checkpoints.Count == 2)
							_secondBlip.Sprite = BlipSprite.RaceFinish;
				    }
				    Vector3 dir = _checkpoints[1] - _checkpoints[0];
					dir.Normalize();
					World.DrawMarker(MarkerType.ChevronUpx1, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(60f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
			    }
			    else
			    {
					Vector3 dir = Game.Player.Character.Position - _checkpoints[0];
					dir.Normalize();
				    World.DrawMarker(MarkerType.CheckeredFlagRect, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(0f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
					_nextBlip.Sprite = BlipSprite.RaceFinish;
			    }

			    if (Game.Player.Character.IsInVehicle() && Game.Player.Character.IsInRangeOf(_checkpoints[0], 10f))
			    {
					Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
					Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
					_checkpoints.RemoveAt(0);
					_nextBlip?.Remove();
					_secondBlip?.Remove();
				    _nextBlip = null;
				    _secondBlip = null;
				    if (_checkpoints.Count == 0)
				    {
					    Game.Player.CanControlCharacter = false;
						Function.Call(Hash._START_SCREEN_EFFECT, "HeistCelebPass", 0, true);
						if(Game.Player.Character.IsInVehicle())
							Game.Player.Character.CurrentVehicle.HandbrakeOn = true;
						World.DestroyAllCameras();
					    World.RenderingCamera = World.CreateCamera(GameplayCamera.Position, GameplayCamera.Rotation, 60f);
						Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_UNDER_THE_BRIDGE", "HUD_MINI_GAME_SOUNDSET");
						int position = _finishedParticipants.Count + 1;
					    int peoplecount = _currentRivals.Count + 1;
					    int score = 100 - ((position - 1)*10);
					    if (score < 0)
						    score = 0;
						_passed = new MissionPassedScreen(_currentRace.Name, score, score > 50 ? score > 90 ? MissionPassedScreen.Medal.Gold : MissionPassedScreen.Medal.Silver : MissionPassedScreen.Medal.Bronze);
						_passed.AddItem("Time Elapsed", FormatTime((int)unchecked(_seconds - _missionStart)), MissionPassedScreen.TickboxState.None);
						_passed.AddItem("Position", position + "/" + peoplecount, position == 1 ? MissionPassedScreen.TickboxState.Tick : MissionPassedScreen.TickboxState.Empty);
					    _passed.OnContinueHit += () =>
					    {
							Game.FadeScreenOut(1000);
							Wait(1000);
							Function.Call(Hash._STOP_SCREEN_EFFECT, "HeistCelebPass");
						    Game.Player.Character.Position = _currentRace.Trigger;
						    Game.Player.CanControlCharacter = true;
						    World.RenderingCamera = null;
							EndRace();
						    _passed = null;
							Game.FadeScreenIn(1500);
					    };
						_passed.Show();
						_isInRace = false;
				    }
			    }
			}
	    }
Beispiel #22
0
 public void Load()
 {
     if (_sc != null) return;
     _sc = new Scaleform(0);
     _sc.Load("MP_BIG_MESSAGE_FREEMODE");
     var timeout = 1000;
     var start = DateTime.Now;
     while (!Function.Call<bool>(Hash.HAS_SCALEFORM_MOVIE_LOADED, _sc.Handle) && DateTime.Now.Subtract(start).TotalMilliseconds < timeout) Script.Yield();
 }
Beispiel #23
0
        public void OnTick(object sender, EventArgs e)
        {
            if (DateTime.Now.Second != _lasttime.Second)
            {
                _seconds++;
                _lasttime = DateTime.Now;
                if (_isInRace && _countdown > 0)
                {
                    var screen = UIMenu.GetScreenResolutionMantainRatio();
                    var w      = Convert.ToInt32(screen.Width / 2);
                    _countdown--;
                    if (_countdown > 3)
                    {
                        return;
                    }
                    _fadeoutSprite = new Sprite("mpinventory", "in_world_circle", new Point(w - 125, 200), new Size(250, 250), 0f, _countdown == 0 ? Color.FromArgb(49, 235, 126) : Color.FromArgb(241, 247, 57));
                    Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
                    Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
                    if (_countdown == 0)
                    {
                        _participants.ForEach(car => car.FreezePosition = false);
                        _missionStart = _seconds;
                    }
                }
                else if (_isInRace && _countdown == 0)
                {
                    _countdown = -1;
                }
            }

            GUI.MainMenu.ProcessControl();
            GUI.MainMenu.ProcessMouse();
            GUI.MainMenu.Draw();

            _quitMenu.ProcessControl();
            _quitMenu.ProcessMouse();
            _quitMenu.Draw();

            GUI.DrawSettings(_previewRace, _previewVehicle);

            _passed?.Draw();

            if (_countdown > -1 && _countdown <= 3)
            {
                var screen = UIMenu.GetScreenResolutionMantainRatio();
                var w      = Convert.ToInt32(screen.Width / 2);
                new UIResText(_countdown == 0 ? "GO" : _countdown.ToString(), new Point(w, 260), 2f, Color.White, Font.Pricedown, UIResText.Alignment.Centered).Draw();
            }

            if (_fadeoutSprite?.Color.A > 5)
            {
                _fadeoutSprite.Color = Color.FromArgb(_fadeoutSprite.Color.A - 5, _fadeoutSprite.Color.R, _fadeoutSprite.Color.G,
                                                      _fadeoutSprite.Color.B);
                _fadeoutSprite.Draw();
            }


            /* COURIER */
            GUICourier.Init();
            GUICourier.MainMenu.ProcessControl();
            GUICourier.MainMenu.ProcessMouse();
            var safe = UIMenu.GetSafezoneBounds();
            var res  = UIMenu.GetScreenResolutionMantainRatio();

            new UIResRectangle(new Point(((int)res.Width - 200), 0), new Size(200, 400), Color.FromArgb(200, 0, 0, 0)).Draw();

            GUICourier.MainMenu.Draw();

            if (activeDeliveries.Count == 0 || (_seconds - lastSpawn > 60 && activeDeliveries.Count < 3))
            {
                Delivery d = Delivery.CreateDelivery();
                d.activate();
                activeDeliveries.Add(d);
                lastSpawn = _seconds;
                UI.Notify("New delivery available");
            }

            int     pick = 0, drop = 0;
            Vector3 me     = Game.Player.Character.Position;
            String  posStr = String.Format("{0} {1} {2}", me.X.ToString("F02"), me.Y.ToString("F02"), me.Z.ToString("F02"));


            new UIResText("Pickup", new Point(Convert.ToInt32(res.Width) - 190, 20), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left)
            {
                DropShadow = true
            }.Draw();
            new UIResText("Dropoff", new Point(Convert.ToInt32(res.Width) - 190, 210), .45f, Color.White, Font.HouseScript, UIResText.Alignment.Left)
            {
                DropShadow = true
            }.Draw();
            foreach (Delivery d in activeDeliveries.GetRange(0, activeDeliveries.Count))
            {
                d.tick();
                if (d.isActive == false)
                {
                    activeDeliveries.Remove(d);
                    continue;
                }


                if (d._isStarted)
                {
                    float  dist    = me.DistanceTo(d.end);
                    String posStr2 = String.Format("{0} {1} {2}", d.end.X.ToString("F02"), d.end.Y.ToString("F02"), d.end.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.end_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (drop + 2) + 210), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left)
                    {
                        DropShadow = true
                    }.Draw();

                    drop++;
                }
                else
                {
                    float  dist    = me.DistanceTo(d.start);
                    String posStr2 = String.Format("{0} {1} {2}", d.start.X.ToString("F02"), d.start.Y.ToString("F02"), d.start.Z.ToString("F02"));
                    new UIResText(String.Format("{0} {1}", dist.ToString("F02"), d.start_text), new Point(Convert.ToInt32(res.Width) - 190, 20 * (pick + 2)), .35f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left)
                    {
                        DropShadow = true
                    }.Draw();

                    pick++;
                }
                //new UIResText("WORLD", new Point(Convert.ToInt32(res.Width) - 190, 40), .35f, Color.DodgerBlue, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true }.Draw();
            }
            /* COURIER */

            if (!_isInRace)
            {
                if (GUI.IsInMenu)
                {
                    return;
                }
                foreach (var race in _races)
                {
                    World.DrawMarker(MarkerType.VerticalCylinder, race.Trigger, new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(5f, 5f, 1f), Color.FromArgb(200, 255, 255, 255));
                    if (!Game.Player.Character.IsInRangeOf(race.Trigger, 50f))
                    {
                        continue;
                    }
                    var tmpSF = new Scaleform(0);
                    tmpSF.Load("PLAYER_NAME_01");
                    tmpSF.CallFunction("SET_PLAYER_NAME", race.Name);

                    tmpSF.Render3D(race.Trigger + new Vector3(0f, 0f, 2f), new Vector3(0f, 0f, _oldAngle), new Vector3(12, 6, 2));

                    var tmpT = new Scaleform(0);
                    tmpT.Load("PLAYER_NAME_02");
                    tmpT.CallFunction("SET_PLAYER_NAME", "Community Race");

                    tmpT.Render3D(race.Trigger + new Vector3(0f, 0f, 1.5f), new Vector3(0f, 0f, _oldAngle), new Vector3(6, 3, 1));

                    _oldAngle += 2f;

                    if (!Game.Player.Character.IsInRangeOf(race.Trigger, 5f))
                    {
                        continue;
                    }

                    Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
                    Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, "Press ~INPUT_CONTEXT~ to participate in this Community Race.");
                    Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);

                    if (Game.IsControlJustPressed(0, GTA.Control.Context))
                    {
                        Game.Player.CanControlCharacter = false;
                        Game.Player.Character.Position  = race.Trigger + new Vector3(4f, 0f, -1f);
                        _previewRace = race;
                        BuildMenu(race);
                        GUI.MainMenu.Visible = true;
                        GUI.IsInMenu         = true;
                        break;
                    }
                }
            }
            else if (_isInRace)
            {
                if (!_raceSettings["Wanted"])
                {
                    Function.Call(Hash.SET_MAX_WANTED_LEVEL, 0);
                }
                //if(Game.Player.Character.IsInVehicle())
                Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.VehicleExit);
                if ((Game.IsControlJustPressed(0, GTA.Control.VehicleExit) && Game.Player.Character.IsInVehicle()) || (!Game.Player.Character.IsInVehicle() && !Game.Player.Character.IsGettingIntoAVehicle && Game.IsControlJustPressed(0, GTA.Control.Enter)))
                {
                    _quitMenu.RefreshIndex();
                    _quitMenu.Visible = !_quitMenu.Visible;
                }

                if (!Convert.ToBoolean(_raceSettings["Traffic"]))
                {
                    Vehicle[] close = World.GetNearbyVehicles(Game.Player.Character, 10000f);
                    foreach (Vehicle vehicle in close)
                    {
                        if (_currentRivals.Any(riv => riv.Vehicle.Handle == vehicle.Handle) ||
                            Game.Player.Character.IsInVehicle(vehicle))
                        {
                            continue;
                        }
                        vehicle.GetPedOnSeat(VehicleSeat.Driver)?.Delete();
                        vehicle?.Delete();
                    }
                }

                //    var res = UIMenu.GetScreenResolutionMantainRatio();
                //    var safe = UIMenu.GetSafezoneBounds();
                const int interval = 45;
                if (_countdown <= 0)
                {
                    new UIResText("TIME", new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (1 * interval))), 0.3f, Color.White).Draw();
                    new UIResText(FormatTime((int)unchecked (_seconds - _missionStart)), new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (1 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                    new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - 248, Convert.ToInt32(res.Height) - safe.Y - (100 + (1 * interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

                    new UIResText("POSITION", new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (2 * interval))), 0.3f, Color.White).Draw();
                    new UIResText((CalculatePlayerPositionInRace() + 1) + "/" + (_currentRivals.Count + 1), new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (2 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                    new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - 248, Convert.ToInt32(res.Height) - safe.Y - (100 + (2 * interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();

                    if (_raceSettings["Laps"] > 1)
                    {
                        int playerCheckpoint = _currentRace.Checkpoints.Length - _checkpoints.Count;
                        int currentLap       = Convert.ToInt32(Math.Floor(playerCheckpoint / (decimal)_totalLaps)) + 1;

                        new UIResText("LAP", new Point(Convert.ToInt32(res.Width) - safe.X - 180, Convert.ToInt32(res.Height) - safe.Y - (90 + (3 * interval))), 0.3f, Color.White).Draw();
                        new UIResText(currentLap + "/" + _raceSettings["Laps"], new Point(Convert.ToInt32(res.Width) - safe.X - 20, Convert.ToInt32(res.Height) - safe.Y - (102 + (3 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                        new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - 248, Convert.ToInt32(res.Height) - safe.Y - (100 + (3 * interval))), new Size(250, 37), 0f, Color.FromArgb(200, 255, 255, 255)).Draw();
                    }
                }


                for (int i = 0; i < _rivalCheckpointStatus.Count; i++)
                {
                    Tuple <Rival, int> tuple = _rivalCheckpointStatus[i];
                    if (tuple.Item1.Vehicle.IsInRangeOf(_currentRace.Checkpoints[tuple.Item2], 10f))
                    {
                        tuple.Item1.Character.Task.ClearAll();
                        if (_currentRace.Checkpoints.Length <= tuple.Item2 + 1)
                        {
                            if (!_finishedParticipants.Contains(tuple.Item1))
                            {
                                _finishedParticipants.Add(tuple.Item1);
                            }
                            tuple.Item1.Vehicle.HandbrakeOn = true;
                            continue;
                        }
                        _rivalCheckpointStatus[i] = new Tuple <Rival, int>(tuple.Item1, tuple.Item2 + 1);
                        Function.Call(Hash.TASK_VEHICLE_MISSION_COORS_TARGET, tuple.Item1.Character.Handle, tuple.Item1.Vehicle.Handle,
                                      _currentRace.Checkpoints[tuple.Item2 + 1].X, _currentRace.Checkpoints[tuple.Item2 + 1].Y,
                                      _currentRace.Checkpoints[tuple.Item2 + 1].Z, Mode, 200f, Rival.MainDrivingStyle, 5f, 0f, 0);               // TODO: Debuggin // old - 6
                    }
                }


                World.DrawMarker(MarkerType.VerticalCylinder, _checkpoints[0], new Vector3(0, 0, 0), new Vector3(0, 0, 0), new Vector3(10f, 10f, 2f), Color.FromArgb(100, 241, 247, 57));
                if (_nextBlip == null)
                {
                    _nextBlip = World.CreateBlip(_checkpoints[0]);
                }
                if (_checkpoints.Count >= 2)
                {
                    if (_secondBlip == null)
                    {
                        _secondBlip       = World.CreateBlip(_checkpoints[1]);
                        _secondBlip.Scale = 0.5f;
                        if (_checkpoints.Count == 2)
                        {
                            _secondBlip.Sprite = BlipSprite.RaceFinish;
                        }
                    }
                    Vector3 dir = _checkpoints[1] - _checkpoints[0];
                    dir.Normalize();
                    World.DrawMarker(MarkerType.ChevronUpx1, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(60f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
                }
                else
                {
                    Vector3 dir = Game.Player.Character.Position - _checkpoints[0];
                    dir.Normalize();
                    World.DrawMarker(MarkerType.CheckeredFlagRect, _checkpoints[0] + new Vector3(0f, 0f, 2f), dir, new Vector3(0f, 0f, 0f), new Vector3(4f, 4f, 4f), Color.FromArgb(200, 87, 193, 250));
                    _nextBlip.Sprite = BlipSprite.RaceFinish;
                }

                if (Game.Player.Character.IsInVehicle() && Game.Player.Character.IsInRangeOf(_checkpoints[0], 10f))
                {
                    Function.Call(Hash.REQUEST_SCRIPT_AUDIO_BANK, "HUD_MINI_GAME_SOUNDSET", true);
                    Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_NORMAL", "HUD_MINI_GAME_SOUNDSET");
                    _checkpoints.RemoveAt(0);
                    _nextBlip?.Remove();
                    _secondBlip?.Remove();
                    _nextBlip   = null;
                    _secondBlip = null;
                    if (_checkpoints.Count == 0)
                    {
                        Game.Player.CanControlCharacter = false;
                        Function.Call(Hash._START_SCREEN_EFFECT, "HeistCelebPass", 0, true);
                        if (Game.Player.Character.IsInVehicle())
                        {
                            Game.Player.Character.CurrentVehicle.HandbrakeOn = true;
                        }
                        World.DestroyAllCameras();
                        World.RenderingCamera = World.CreateCamera(GameplayCamera.Position, GameplayCamera.Rotation, 60f);
                        Function.Call(Hash.PLAY_SOUND_FRONTEND, 0, "CHECKPOINT_UNDER_THE_BRIDGE", "HUD_MINI_GAME_SOUNDSET");
                        int position    = _finishedParticipants.Count + 1;
                        int peoplecount = _currentRivals.Count + 1;
                        int score       = 100 - ((position - 1) * 10);
                        if (score < 0)
                        {
                            score = 0;
                        }
                        _passed = new MissionPassedScreen(_currentRace.Name, score, score > 50 ? score > 90 ? MissionPassedScreen.Medal.Gold : MissionPassedScreen.Medal.Silver : MissionPassedScreen.Medal.Bronze);
                        _passed.AddItem("Time Elapsed", FormatTime((int)unchecked (_seconds - _missionStart)), MissionPassedScreen.TickboxState.None);
                        _passed.AddItem("Position", position + "/" + peoplecount, position == 1 ? MissionPassedScreen.TickboxState.Tick : MissionPassedScreen.TickboxState.Empty);
                        _passed.OnContinueHit += () =>
                        {
                            Game.FadeScreenOut(1000);
                            Wait(1000);
                            Function.Call(Hash._STOP_SCREEN_EFFECT, "HeistCelebPass");
                            Game.Player.Character.Position  = _currentRace.Trigger;
                            Game.Player.CanControlCharacter = true;
                            World.RenderingCamera           = null;
                            EndRace();
                            _passed = null;
                            Game.FadeScreenIn(1500);
                        };
                        _passed.Show();
                        _isInRace = false;
                    }
                }
            }
        }
Beispiel #24
0
 public Chat()
 {
     CurrentInput   = "";
     _mainScaleform = new Scaleform(0);
     _mainScaleform.Load("multiplayer_chat");
 }
Beispiel #25
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, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneSelect, 0), "Select");
            _sc.CallFunction("SET_DATA_SLOT", 1, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneCancel, 0), "Back");

            _sc.CallFunction("SET_DATA_SLOT", 2, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendRb, 0), "");
            _sc.CallFunction("SET_DATA_SLOT", 3, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendLb, 0), "Browse");
        }
Beispiel #26
0
 public Chat()
 {
     CurrentInput = "";
     _mainScaleform = new Scaleform(0);
     _mainScaleform.Load("multiplayer_chat");
 }
Beispiel #27
0
        public MapEditor()
        {
            Tick += OnTick;
            KeyDown += OnKeyDown;

            if (!Directory.Exists("scripts\\MapEditor"))
                Directory.CreateDirectory("scripts\\MapEditor");

            ObjectDatabase.SetupRelationships();
            LoadSettings();

            try
            {
                Translation.Load("scripts\\MapEditor", _settings.Translation);
            }
            catch (Exception e)
            {
                UI.Notify("~b~~h~Map Editor~h~~w~~n~Failed to load translations. Falling back to English.");
                UI.Notify(e.Message);
            }

            _scaleform = new Scaleform(0);
            _scaleform.Load("instructional_buttons");

            _objectInfoMenu = new UIMenu("", "~b~" + Translation.Translate("PROPERTIES"), new Point(0, -107));
            _objectInfoMenu.ResetKey(UIMenu.MenuControls.Back);
            _objectInfoMenu.DisableInstructionalButtons(true);
            _objectInfoMenu.SetBannerType(new UIResRectangle(new Point(), new Size()));
            _menuPool.Add(_objectInfoMenu);

            ModManager.InitMenu();

            _objectsMenu = new UIMenu("Map Editor", "~b~" + Translation.Translate("PLACE OBJECT"));

            ObjectDatabase.LoadFromFile("scripts\\ObjectList.ini", ref ObjectDatabase.MainDb);
            ObjectDatabase.LoadInvalidHashes();
            ObjectDatabase.LoadFromFile("scripts\\PedList.ini", ref ObjectDatabase.PedDb);
            ObjectDatabase.LoadFromFile("scripts\\VehicleList.ini", ref ObjectDatabase.VehicleDb);

            _crosshairPath = Path.GetFullPath("scripts\\MapEditor\\crosshair.png");
            _crosshairBluePath = Path.GetFullPath("scripts\\MapEditor\\crosshair_blue.png");
            _crosshairYellowPath = Path.GetFullPath("scripts\\MapEditor\\crosshair_yellow.png");

            if (!File.Exists("scripts\\MapEditor\\crosshair.png"))
                _crosshairPath = Sprite.WriteFileFromResources(Assembly.GetExecutingAssembly(), "MapEditor.crosshair.png", "scripts\\MapEditor\\crosshair.png");
            if (!File.Exists("scripts\\MapEditor\\crosshair_blue.png"))
                _crosshairBluePath = Sprite.WriteFileFromResources(Assembly.GetExecutingAssembly(), "MapEditor.crosshair_blue.png", "scripts\\MapEditor\\crosshair_blue.png");
            if (!File.Exists("scripts\\MapEditor\\crosshair_yellow.png"))
                _crosshairYellowPath = Sprite.WriteFileFromResources(Assembly.GetExecutingAssembly(), "MapEditor.crosshair_yellow.png", "scripts\\MapEditor\\crosshair_yellow.png");

            RedrawObjectsMenu();
            _objectsMenu.OnItemSelect += OnObjectSelect;
            _objectsMenu.OnIndexChange += OnIndexChange;
            _menuPool.Add(_objectsMenu);

            _objectsMenu.ResetKey(UIMenu.MenuControls.Back);
            _objectsMenu.AddInstructionalButton(new InstructionalButton(Control.SelectWeapon, Translation.Translate("Change Axis")));
            _objectsMenu.AddInstructionalButton(new InstructionalButton(Control.MoveUpDown, Translation.Translate("Zoom")));
            _objectsMenu.AddInstructionalButton(new InstructionalButton(Control.Jump, Translation.Translate("Search")));

            _searchMenu = new UIMenu("Map Editor", "~b~" + Translation.Translate("PLACE OBJECT"));
            _searchMenu.OnItemSelect += OnObjectSelect;
            _searchMenu.OnIndexChange += OnIndexChange;
            _menuPool.Add(_searchMenu);

            _searchMenu.ResetKey(UIMenu.MenuControls.Back);
            _searchMenu.AddInstructionalButton(new InstructionalButton(Control.SelectWeapon, Translation.Translate("Change Axis")));
            _searchMenu.AddInstructionalButton(new InstructionalButton(Control.MoveUpDown, Translation.Translate("Zoom")));
            _searchMenu.AddInstructionalButton(new InstructionalButton(Control.Jump, Translation.Translate("Search")));

            _mainMenu = new UIMenu("Map Editor", "~b~" + Translation.Translate("MAIN MENU"));
            _mainMenu.AddItem(new UIMenuItem(Translation.Translate("Enter/Exit Map Editor")));
            _mainMenu.AddItem(new UIMenuItem(Translation.Translate("New Map"), Translation.Translate("Remove all current objects and start a new map.")));
            _mainMenu.AddItem(new UIMenuItem(Translation.Translate("Save Map"), Translation.Translate("Save all current objects to a file.")));
            _mainMenu.AddItem(new UIMenuItem(Translation.Translate("Load Map"), Translation.Translate("Load objects from a file and add them to the world.")));
            _mainMenu.RefreshIndex();
            _mainMenu.DisableInstructionalButtons(true);
            _menuPool.Add(_mainMenu);

            _formatMenu = new UIMenu("Map Editor", "~b~" + Translation.Translate("SELECT FORMAT"));
            _formatMenu.DisableInstructionalButtons(true);
            _formatMenu.ParentMenu = _mainMenu;
            RedrawFormatMenu();
            _menuPool.Add(_formatMenu);

            _metadataMenu = new UIMenu("Map Editor", "~b~" + Translation.Translate("SAVE MAP"));
            _metadataMenu.DisableInstructionalButtons(true);
            _metadataMenu.ParentMenu = _formatMenu;
            RedrawMetadataMenu();
            _menuPool.Add(_metadataMenu);

            _filepicker = new UIMenu("Map Editor", "~b~" + Translation.Translate("PICK FILE"));
            _filepicker.DisableInstructionalButtons(true);
            _filepicker.ParentMenu = _formatMenu;
            _menuPool.Add(_filepicker);

            _mainMenu.OnItemSelect += (m, it, i) =>
            {
                switch (i)
                {
                    case 0: // Enter/Exit Map Editor
                        IsInFreecam = !IsInFreecam;
                        Game.Player.Character.FreezePosition = IsInFreecam;
                        Game.Player.Character.IsVisible = !IsInFreecam;
                        World.RenderingCamera = null;
                        if (!IsInFreecam)
                        {
                            Game.Player.Character.Position -= new Vector3(0f, 0f, Game.Player.Character.HeightAboveGround - 1f);
                            return;
                        }
                        World.DestroyAllCameras();
                        _mainCamera = World.CreateCamera(GameplayCamera.Position, GameplayCamera.Rotation, 60f);
                        _objectPreviewCamera = World.CreateCamera(new Vector3(1200.016f, 3980.998f, 86.05062f), new Vector3(0f, 0f, 0f), 60f);
                        World.RenderingCamera = _mainCamera;
                        break;
                    case 1: // New Map
                        JavascriptHook.StopAllScripts();
                        PropStreamer.RemoveAll();
                        PropStreamer.Markers.Clear();
                        _currentObjectsMenu.Clear();
                        PropStreamer.Identifications.Clear();
                        PropStreamer.ActiveScenarios.Clear();
                        PropStreamer.ActiveRelationships.Clear();
                        PropStreamer.ActiveWeapons.Clear();
                        PropStreamer.Doors.Clear();
                        PropStreamer.CurrentMapMetadata = new MapMetadata();
                        ModManager.CurrentMod?.ModDisconnectInvoker();
                        ModManager.CurrentMod = null;
                        foreach (MapObject o in PropStreamer.RemovedObjects)
                        {
                            var t = World.CreateProp(o.Hash, o.Position, o.Rotation, true, false);
                            t.PositionNoOffset = o.Position;
                        }
                        PropStreamer.RemovedObjects.Clear();
                        _loadedEntities = 0;
                        _changesMade = 0;
                        _lastAutosave = DateTime.Now;
                        UI.Notify("~b~~h~Map Editor~h~~w~~n~" + Translation.Translate("Loaded new map."));
                        break;
                    case 2:
                        if (ModManager.CurrentMod != null)
                        {
                            string filename = Game.GetUserInput(255);
                            if (String.IsNullOrWhiteSpace(filename))
                            {
                                UI.Notify("~r~~h~Map Editor~h~~n~~w~" + Translation.Translate("The filename was empty."));
                                return;
                            }
                            Map tmpMap = new Map();
                            tmpMap.Objects.AddRange(PropStreamer.GetAllEntities());
                            tmpMap.RemoveFromWorld.AddRange(PropStreamer.RemovedObjects);
                            tmpMap.Markers.AddRange(PropStreamer.Markers);
                            UI.Notify("~b~~h~Map Editor~h~~n~~w~" + Translation.Translate("Map sent to external mod for saving."));
                            ModManager.CurrentMod.MapSavedInvoker(tmpMap, filename);
                            return;
                        }
                        _savingMap = true;
                        _mainMenu.Visible = false;
                        RedrawFormatMenu();
                        _formatMenu.Visible = true;
                        break;
                    case 3:
                        _savingMap = false;
                        _mainMenu.Visible = false;
                        RedrawFormatMenu();
                        _formatMenu.Visible = true;
                        break;
                }
            };

            _formatMenu.OnItemSelect += (m, item, indx) =>
            {
                if (_savingMap)
                {
                    string filename = "";
                    if (indx != 0)
                        filename = Game.GetUserInput(255);

                    switch (indx)
                    {
                        case 0: // XML
                            // TODO: Send to another menu
                            _formatMenu.Visible = false;
                            RedrawMetadataMenu();
                            _metadataMenu.Visible = true;
                            break;
                        case 1: // Objects.ini
                            if (!filename.EndsWith(".ini")) filename += ".ini";
                            SaveMap(filename, MapSerializer.Format.SimpleTrainer);
                            break;
                        case 2: // C#
                            if (!filename.EndsWith(".cs")) filename += ".cs";
                            SaveMap(filename, MapSerializer.Format.CSharpCode);
                            break;
                        case 3: // Raw
                            if (!filename.EndsWith(".txt")) filename += ".txt";
                            SaveMap(filename, MapSerializer.Format.Raw);
                            break;
                        case 4: // SpoonerLegacy
                            if (!filename.EndsWith(".SP00N")) filename += ".SP00N";
                            SaveMap(filename, MapSerializer.Format.SpoonerLegacy);
                            break;
                        case 5: // Menyoo
                            if (!filename.EndsWith(".xml")) filename += ".xml";
                            SaveMap(filename, MapSerializer.Format.Menyoo);
                            break;
                    }
                }
                else
                {
                    string filename = "";
                    if (indx != 4)
                        filename = Game.GetUserInput(255);

                    MapSerializer.Format tmpFor = MapSerializer.Format.NormalXml;
                    switch (indx)
                    {
                        case 0: // XML
                            tmpFor = MapSerializer.Format.NormalXml;
                            break;
                        case 1: // Objects.ini
                            tmpFor = MapSerializer.Format.SimpleTrainer;
                            break;
                        case 2: // Spooner
                            tmpFor = MapSerializer.Format.SpoonerLegacy;
                            break;
                        case 3: // Spooner
                            tmpFor = MapSerializer.Format.Menyoo;
                            break;
                        case 4: // File picker
                            _formatMenu.Visible = false;
                            RedrawFilepickerMenu();
                            _filepicker.Visible = true;
                            return;
                    }
                    LoadMap(filename, tmpFor);
                }
                _formatMenu.Visible = false;
            };

            _settingsMenu = new UIMenu("Map Editor", "~b~" + Translation.Translate("SETTINGS"));

            for (int i = -_possibleRange; i <= _possibleRange; i++)
            {
                _possiblePositions.Add(i * 0.01);
            }

            for (int i = -36000; i <= 36000; i++)
            {
                _possibleRoll.Add(i * 0.01);
            }

            var possibleLangauges = new List<string>
            {
                "Auto"
            };
            possibleLangauges.AddRange(Translation.Translations.Select(t => t.Language).ToList());

            var language = new UIMenuListItem(Translation.Translate("Language"),
                possibleLangauges.Select(t => (dynamic) t).ToList(), possibleLangauges.IndexOf(_settings.Translation));

            language.OnListChanged += (sender, index) =>
            {
                var newLanguage = sender.IndexToItem(index).ToString();
                Translation.SetLanguage(newLanguage);
                _settings.Translation = newLanguage;
                SaveSettings();
                if (newLanguage == "Auto")
                {
                    language.Description = "Use your game's language settings.";
                    return;
                }
                var descFile = Translation.Translations.FirstOrDefault(t => t.Language == newLanguage);
                if (descFile == null) return;
                language.Description = "~h~" + Translation.Translate("Translator") + ":~h~ " + descFile.Translator;
            };

            var checkem = new UIMenuListItem(Translation.Translate("Marker"), new List<dynamic>(Enum.GetNames(typeof(CrosshairType))), Enum.GetNames(typeof(CrosshairType)).ToList().FindIndex(x => x == _settings.CrosshairType.ToString()));
            checkem.OnListChanged += (i, indx) =>
            {
                CrosshairType outHash;
                Enum.TryParse(i.IndexToItem(indx).ToString(), out outHash);
                _settings.CrosshairType = outHash;
                SaveSettings();
            };

            List<dynamic> autosaveList = new List<dynamic> {Translation.Translate("Disable")};
            for (int i = 5; i <= 60; i += 5)
            {
                autosaveList.Add(i);
            }
            int aIndex = autosaveList.IndexOf(_settings.AutosaveInterval);
            if (aIndex == -1)
                aIndex = 0;

            var autosaveItem = new UIMenuListItem(Translation.Translate("Autosave Interval"), autosaveList, aIndex, Translation.Translate("Interval in minutes between automatic autosaves."));
            autosaveItem.OnListChanged += (item, index) =>
            {
                var sel = item.IndexToItem(index);
                _settings.AutosaveInterval = (sel as string) == Translation.Translate("Disable") ? -1 : Convert.ToInt32(item.IndexToItem(index), CultureInfo.InvariantCulture);
                SaveSettings();
            };

            List<dynamic> possibleDrawDistances = new List<dynamic> {Translation.Translate("Default"), 50, 75};
            for (int i = 100; i <= 3000; i += 100)
            {
                possibleDrawDistances.Add(i);
            }
            int dIndex = possibleDrawDistances.IndexOf(_settings.DrawDistance);
            if (dIndex == -1)
                dIndex = 0;
            var drawDistanceItem = new UIMenuListItem(Translation.Translate("Draw Distance"), possibleDrawDistances, dIndex, Translation.Translate("Draw distance for props, vehicles and peds. Reload the map for changes to take effect."));
            drawDistanceItem.OnListChanged += (item, index) =>
            {
                var sel = item.IndexToItem(index);
                _settings.DrawDistance = (sel as string) == Translation.Translate("Default") ? -1 : Convert.ToInt32(item.IndexToItem(index), CultureInfo.InvariantCulture);
                SaveSettings();
            };

            List<dynamic> senslist = new List<dynamic>();
            for (int i = 1; i < 60; i++)
            {
                senslist.Add(i);
            }
            var gamboy = new UIMenuListItem(Translation.Translate("Mouse Camera Sensitivity"), senslist, _settings.CameraSensivity - 1);
            gamboy.OnListChanged += (item, index) =>
            {
                _settings.CameraSensivity = index + 1;
                SaveSettings();
            };
            var gampadSens = new UIMenuListItem(Translation.Translate("Gamepad Camera Sensitivity"), senslist, _settings.GamepadCameraSensitivity - 1);
            gampadSens.OnListChanged += (item, index) =>
            {
                _settings.GamepadCameraSensitivity = index + 1;
                SaveSettings();
            };

            var keymovesens = new UIMenuListItem(Translation.Translate("Keyboard Movement Sensitivity"), senslist, _settings.KeyboardMovementSensitivity - 1);
            keymovesens.OnListChanged += (item, index) =>
            {
                _settings.KeyboardMovementSensitivity = index + 1;
                SaveSettings();
            };

            var gammovesens = new UIMenuListItem(Translation.Translate("Gamepad Movement Sensitivity"), senslist, _settings.GamepadMovementSensitivity - 1);
            gammovesens.OnListChanged += (item, index) =>
            {
                _settings.GamepadMovementSensitivity = index + 1;
                SaveSettings();
            };

            var butts = new UIMenuCheckboxItem(Translation.Translate("Instructional Buttons"), _settings.InstructionalButtons);
            butts.CheckboxEvent += (i, checkd) =>
            {
                _settings.InstructionalButtons = checkd;
                SaveSettings();
            };
            var gamepadItem = new UIMenuCheckboxItem(Translation.Translate("Enable Gamepad Shortcut"), _settings.Gamepad);
            gamepadItem.CheckboxEvent += (i, checkd) =>
            {
                _settings.Gamepad = checkd;
                SaveSettings();
            };

            var counterItem = new UIMenuCheckboxItem(Translation.Translate("Entity Counter"), _settings.PropCounterDisplay);
            counterItem.CheckboxEvent += (i, checkd) =>
            {
                _settings.PropCounterDisplay = checkd;
                SaveSettings();
            };

            var snapper = new UIMenuCheckboxItem(Translation.Translate("Follow Object With Camera"), _settings.SnapCameraToSelectedObject);
            snapper.CheckboxEvent += (i, checkd) =>
            {
                _settings.SnapCameraToSelectedObject = checkd;
                SaveSettings();
            };

            var boundItem = new UIMenuCheckboxItem(Translation.Translate("Bounding Box"), _settings.BoundingBox.GetValueOrDefault(false));
            boundItem.CheckboxEvent += (i, checkd) =>
            {
                _settings.BoundingBox = checkd;
                SaveSettings();
            };

            var scriptItem = new UIMenuCheckboxItem(Translation.Translate("Execute Scripts"), _settings.LoadScripts);
            scriptItem.CheckboxEvent += (i, checkd) =>
            {
                _settings.LoadScripts = checkd;
                SaveSettings();
            };

            var validate = new UIMenuItem(Translation.Translate("Validate Object Database"),Translation.Translate(
                "This will update the current object database, removing any invalid objects. The changes will take effect after you restart the script." +
                " It will take a couple of minutes."));
            validate.Activated += (men, item) => ValidateDatabase();

            var resetGrps = new UIMenuItem(Translation.Translate("Reset Active Relationship Groups"),
                Translation.Translate("This will set all ped's relationship groups to Companion."));
            resetGrps.Activated += (men, item) =>
            {
                PropStreamer.Peds.ForEach(ped => ObjectDatabase.SetPedRelationshipGroup(new Ped(ped), "Companion"));
            };

            var objectValidationItem = new UIMenuCheckboxItem(Translation.Translate("Skip Invalid Objects"), _settings.OmitInvalidObjects);
            objectValidationItem.CheckboxEvent += (i, checkd) =>
            {
                _settings.OmitInvalidObjects = checkd;
                SaveSettings();
            };

            #if DEBUG

            var testItem = new UIMenuItem("Load Terrain");
            testItem.Activated += (sender, item) =>
            {
                if (!Game.IsWaypointActive)
                {
                    Function.Call(Hash.CLEAR_HD_AREA);
                    return;
                }
                var wpyPos = World.GetWaypointPosition();

                Function.Call(Hash.SET_HD_AREA, wpyPos.X, wpyPos.Y, wpyPos.Z, 400f);
            };
            _settingsMenu.AddItem(testItem);

            #endif

            _settingsMenu.AddItem(language);
            _settingsMenu.AddItem(gamepadItem);
            _settingsMenu.AddItem(drawDistanceItem);
            _settingsMenu.AddItem(autosaveItem);
            _settingsMenu.AddItem(checkem);
            _settingsMenu.AddItem(boundItem);
            _settingsMenu.AddItem(gamboy);
            _settingsMenu.AddItem(gampadSens);
            _settingsMenu.AddItem(keymovesens);
            _settingsMenu.AddItem(gammovesens);
            _settingsMenu.AddItem(butts);
            _settingsMenu.AddItem(counterItem);
            _settingsMenu.AddItem(snapper);
            _settingsMenu.AddItem(scriptItem);
            _settingsMenu.AddItem(objectValidationItem);
            _settingsMenu.AddItem(validate);
            _settingsMenu.AddItem(resetGrps);
            _settingsMenu.RefreshIndex();
            _settingsMenu.DisableInstructionalButtons(true);
            _menuPool.Add(_settingsMenu);

            _currentObjectsMenu = new UIMenu("Map Editor", "~b~" + Translation.Translate("CURRENT ENTITES"));
            _currentObjectsMenu.OnItemSelect += OnEntityTeleport;
            _currentObjectsMenu.DisableInstructionalButtons(true);
            _menuPool.Add(_currentObjectsMenu);

            var binder = new UIMenuItem(Translation.Translate("Settings"));
            _currentEntitiesItem = new UIMenuItem(Translation.Translate("Current Entities"));

            var binder2 = new UIMenuItem(Translation.Translate("Create Map for External Mod"));

            _mainMenu.AddItem(_currentEntitiesItem);
            _mainMenu.AddItem(binder);
            _mainMenu.AddItem(binder2);

            _mainMenu.BindMenuToItem(_settingsMenu, binder);
            _mainMenu.BindMenuToItem(_currentObjectsMenu, _currentEntitiesItem);
            _mainMenu.BindMenuToItem(ModManager.ModMenu, binder2);
            _mainMenu.RefreshIndex();
            _menuPool.Add(ModManager.ModMenu);
        }
Beispiel #28
0
        public void Manager()
        {
            if (Game.LocalPlayer.Character.IsInHelicopter)
            {
                if (_showHelpText)
                {
                    Game.DisplayHelp("~g~Wilderness Callouts:~s~ Press ~b~" + Controls.ToggleHeliCam.ToUserFriendlyName() + "~s~ to activate the helicopter camera", 6500);
                    _showHelpText = false;
                }

                if (Controls.ToggleHeliCam.IsJustPressed() && (Camera == null || !Camera.Exists()))
                {
                    Camera = new Camera(true);
                    Camera.SetRotationYaw(Game.LocalPlayer.Character.CurrentVehicle.Heading);
                    Scaleform = new Scaleform();
                    Scaleform.Load("heli_cam");
                    NativeFunction.Natives.REQUEST_STREAMED_TEXTURE_DICT("helicopterhud", true);
                    Scaleform.CallFunction("SET_CAM_LOGO", 1);//TODO check this for updated Native invocation??
                    Camera.AttachToEntity(Game.LocalPlayer.Character.CurrentVehicle, GetCameraPositionOffsetForModel(Game.LocalPlayer.Character.CurrentVehicle.Model), true);
                    Sound.RequestAmbientAudioBank("SCRIPT\\POLICE_CHOPPER_CAM");
                    NativeFunction.Natives.SET_NOISEOVERIDE(true);
                    NativeFunction.Natives.SET_NOISINESSOVERIDE(0.15f);
                }
                else if ((Controls.ToggleHeliCam.IsJustPressed() || !Game.LocalPlayer.Character.IsInHelicopter || Game.LocalPlayer.Character.CurrentVehicle.IsDead || Game.LocalPlayer.Character.IsDead) && (Camera != null && Camera.Exists()))
                {
                    NativeFunction.Natives.SET_NOISEOVERIDE(false);
                    NativeFunction.Natives.SET_NOISINESSOVERIDE(0.0f);
                    Camera.Delete();
                    Camera    = null;
                    Scaleform = null;
                    if (WildernessCallouts.Common.IsNightVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetNightVision(false);
                    }
                    if (WildernessCallouts.Common.IsThermalVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetThermalVision(false);
                    }
                }



                if (Camera != null && Camera.Exists() && Scaleform != null)
                {
                    if (BackgroundSound.HasFinished())
                    {
                        BackgroundSound.PlayFrontend("COP_HELI_CAM_BACKGROUND", null);
                    }

                    NativeFunction.Natives.HIDE_HUD_AND_RADAR_THIS_FRAME();
                    WildernessCallouts.Common.DisEnableGameControls(false, GameControl.Enter, GameControl.VehicleExit, GameControl.VehicleAim, GameControl.VehicleAttack, GameControl.VehicleAttack2, GameControl.VehicleDropProjectile, GameControl.VehicleDuck /*, GameControl.VehicleFlyAttack, GameControl.VehicleFlyAttack2*/, GameControl.VehicleFlyAttackCamera, GameControl.VehicleFlyDuck, GameControl.VehicleFlySelectNextWeapon, GameControl.VehicleFlySelectPrevWeapon, GameControl.VehicleHandbrake, GameControl.VehicleJump, GameControl.LookLeftRight, GameControl.LookUpDown, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext);

                    float FOVpercentage = -((Camera.FOV - 70 /*max FOV*/)) / 35 /*min FOV*/;
                    if (FOVpercentage > 1f)
                    {
                        FOVpercentage = 1f;
                    }
                    else if (FOVpercentage < 0f)
                    {
                        FOVpercentage = 0f;
                    }
                    Scaleform.CallFunction("SET_ALT_FOV_HEADING", Camera.Position.Z, FOVpercentage, Camera.Rotation.Yaw);
                    WildernessCallouts.Common.DrawScaleformMovieFullscreen(Scaleform, Color.FromArgb(0, 255, 255, 255));

                    float moveSpeed = (Camera.FOV / 100) * (WildernessCallouts.Common.IsUsingController() ? 3.5f : 5.25f);

                    //float upDown = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookUpDown) * moveSpeed;
                    //float leftRight = NativeFunction.CallByName<float>("GET_DISABLED_CONTROL_NORMAL", 0, (int)GameControl.LookLeftRight) * moveSpeed;

                    //Camera.Rotation = new Rotator(Camera.Rotation.Pitch - upDown, Camera.Rotation.Roll, Camera.Rotation.Yaw - leftRight);

                    float yRotMagnitude = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.LookUpDown) * moveSpeed;
                    float xRotMagnitude = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.LookLeftRight) * moveSpeed;

                    float newPitch = Camera.Rotation.Pitch - yRotMagnitude;
                    float newYaw   = Camera.Rotation.Yaw - xRotMagnitude;
                    Camera.Rotation = new Rotator((newPitch >= 25f || newPitch <= -70f) ? Camera.Rotation.Pitch : newPitch, /*_cam.Rotation.Roll*/ 0f, newYaw);


                    if (yRotMagnitude != 0f || xRotMagnitude != 0)
                    {
                        if (TurnSound.HasFinished())
                        {
                            TurnSound.PlayFrontend("COP_HELI_CAM_TURN", null);
                        }
                    }
                    else if (!TurnSound.HasFinished())
                    {
                        TurnSound.Stop();
                    }

                    //if (Camera.Rotation.Pitch <= -70f) Camera.SetRotationPitch(-69.99f);
                    //else if (Camera.Rotation.Pitch >= 25f) Camera.SetRotationPitch(24.99f);

                    if (!WildernessCallouts.Common.IsUsingController())
                    {
                        WildernessCallouts.Common.DisEnableGameControls(false, GameControl.WeaponWheelPrev, GameControl.WeaponWheelNext);
                        float wheelForwards  = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.WeaponWheelPrev) * 1.725f;
                        float wheelBackwards = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.WeaponWheelNext) * 1.725f;

                        Camera.FOV -= wheelForwards - wheelBackwards;
                        if (Camera.FOV > 70f)
                        {
                            Camera.FOV = 70f;
                        }
                        else if (Camera.FOV < 1f)
                        {
                            Camera.FOV = 1f;
                        }
                    }
                    if (Game.IsControllerButtonDownRightNow(ControllerButtons.A) /* || Game.IsKeyDownRightNow(Keys.LShiftKey)*/)
                    {
                        if (ZoomSound.HasFinished())
                        {
                            ZoomSound.PlayFrontend("COP_HELI_CAM_ZOOM", null);
                        }
                        WildernessCallouts.Common.DisEnableGameControls(false, GameControl.VehicleFlyThrottleUp, GameControl.VehicleFlyThrottleDown);
                        float up   = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.VehicleFlyThrottleUp);
                        float down = NativeFunction.Natives.GET_DISABLED_CONTROL_NORMAL <float>(0, (int)GameControl.VehicleFlyThrottleDown);

                        Camera.FOV -= up - down;
                        if (Camera.FOV > 70f)
                        {
                            Camera.FOV = 70f;
                        }
                        else if (Camera.FOV < 5f)
                        {
                            Camera.FOV = 5f;
                        }
                    }
                    else
                    {
                        if (!ZoomSound.HasFinished())
                        {
                            ZoomSound.Stop();
                        }
                    }

                    if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && !WildernessCallouts.Common.IsNightVisionActive() && !WildernessCallouts.Common.IsThermalVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_ON_MASTER", null);
                        WildernessCallouts.Common.SetNightVision(true);
                    }
                    else if (Controls.ToggleBinocularsHeliCamNightVision.IsJustPressed() && WildernessCallouts.Common.IsNightVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetNightVision(false);
                    }

                    if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && !WildernessCallouts.Common.IsThermalVisionActive() && !WildernessCallouts.Common.IsNightVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_ON_MASTER", null);
                        WildernessCallouts.Common.SetThermalVision(true);
                    }
                    else if (Controls.ToggleBinocularsHeliCamThermalVision.IsJustPressed() && WildernessCallouts.Common.IsThermalVisionActive())
                    {
                        new Sound(-1).PlayFrontend("THERMAL_VISION_GOGGLES_OFF_MASTER", null);
                        WildernessCallouts.Common.SetThermalVision(false);
                    }

#if DEBUG
                    Game.DisplayHelp(Camera.Direction.ToString());
#endif

                    Entity raycastedEntity = WildernessCallouts.Common.RaycastEntity2(Camera.Position, Camera.Direction, 2000.0f, Game.LocalPlayer.Character, Game.LocalPlayer.Character.CurrentVehicle);

                    if (_searchCounter != 0)
                    {
                        SizeF res = RAGENativeUI.UIMenu.GetScreenResolutionMantainRatio();
                        new Sprite("helicopterhud", "hud_line", new Point(((int)res.Width / 2) - ((int)res.Width / 8) /*- ((int)res.Width / 32)*/, ((int)res.Height / 2) + ((int)res.Height / 4)), new Size(5 + _searchCounter * 2, 30)).Draw();
                    }

                    if (raycastedEntity != null && raycastedEntity.Exists())
                    {
                        if (Controls.HeliCamScan.IsPressed() && (raycastedEntity.IsPed() || raycastedEntity.IsVehicle()))
                        {
                            _searchCounter++;
                            if (SearchLoopSound.HasFinished())
                            {
                                SearchLoopSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_LOOP", null);
                            }
                            Vector2 v2  = World.ConvertWorldPositionToScreenPosition(raycastedEntity.Position);
                            SizeF   res = RAGENativeUI.UIMenu.GetScreenResolutionMantainRatio();//fix: work with all res
                            new Sprite("helicopterhud", "hud_target", new Point((int)v2.X + (125 / (int)res.Width) /*- ((int)res.Width / 125)*/, (int)v2.Y + (125 / (int)res.Height) /*- ((int)res.Height / 125)*/), new Size(125, 125)).Draw();


                            if (_searchCounter > 240)
                            {
                                if (raycastedEntity.IsPed())
                                {
                                    //Game.DisplayNotification("Ped detected");
                                    if (SearchSuccessSound.HasFinished())
                                    {
                                        SearchSuccessSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_SUCCESS", null);
                                    }
                                    _canOverrideDrawInfo = true;
                                    GameFiber.StartNew(delegate { DrawPedInfo((Ped)raycastedEntity, 13000); }, "DrawPedInfo Fiber");
                                }
                                else if (raycastedEntity.IsVehicle())
                                {
                                    //Game.DisplayNotification("Vehicle detected");
                                    if (SearchSuccessSound.HasFinished())
                                    {
                                        SearchSuccessSound.PlayFrontend("COP_HELI_CAM_SCAN_PED_SUCCESS", null);
                                    }
                                    _canOverrideDrawInfo = true;
                                    GameFiber.StartNew(delegate { DrawVehicleInfo((Vehicle)raycastedEntity, 13000); }, "DrawVehicleInfo Fiber");
                                }
                                if (!SearchLoopSound.HasFinished())
                                {
                                    SearchLoopSound.Stop();
                                }

                                _searchCounter = 0;
                            }
                        }

                        if (raycastedEntity.IsVehicle())
                        {
                            DrawVehicleSpeed((Vehicle)raycastedEntity);
                        }
                    }
                    else if (_searchCounter > 0)
                    {
                        _searchCounter--;
                    }


                    if (!SearchLoopSound.HasFinished())
                    {
                        SearchLoopSound.Stop();
                    }
                }
                else
                {
                    if (!BackgroundSound.HasFinished())
                    {
                        BackgroundSound.Stop();
                    }
                    if (!ZoomSound.HasFinished())
                    {
                        ZoomSound.Stop();
                    }
                    if (!TurnSound.HasFinished())
                    {
                        TurnSound.Stop();
                    }
                    if (!SearchLoopSound.HasFinished())
                    {
                        SearchLoopSound.Stop();
                    }
                    if (!SearchSuccessSound.HasFinished())
                    {
                        SearchLoopSound.Stop();
                    }
                }
            }
            else if (!_showHelpText)
            {
                _showHelpText = true;
            }
        }
Beispiel #29
0
Datei: GUI.cs Projekt: Guad/NOOSE
        public static void DrawScaleform()
        {
            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, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.Jump, 0), "Begin Assault");
            scaleform.CallFunction("SET_DATA_SLOT", 1, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendCancel, 0), "Cancel");
            scaleform.CallFunction("SET_DATA_SLOT", 2, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneRight, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 3, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.PhoneLeft, 0), "Change Mission");
            scaleform.CallFunction("SET_DATA_SLOT", 4, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendRb, 0), "");
            scaleform.CallFunction("SET_DATA_SLOT", 5, Function.Call<string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendLb, 0), "Change Entry Point");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
        }