Exemple #1
0
 /// <summary>
 /// Add the menu to the menu pool and set it up correctly.
 /// Also add and bind the menu buttons.
 /// </summary>
 /// <param name="submenu"></param>
 /// <param name="menuButton"></param>
 private void AddMenu(UIMenu submenu, UIMenuItem menuButton)
 {
     Menu.AddItem(menuButton);
     Menu.BindMenuToItem(submenu, menuButton);
     Mp.Add(submenu);
     submenu.RefreshIndex();
     submenu.UpdateScaleform();
 }
        /// <summary>
        /// Main OnTick task runs every game tick and handles all the menu stuff.
        /// </summary>
        /// <returns></returns>
        private async Task OnTick()
        {
            #region FirstTick
            // Only run this the first tick.
            if (firstTick)
            {
                firstTick = false;
                // Clear all previous pause menu info/brief messages on resource start.
                ClearBrief();

                // Request the permissions data from the server.
                TriggerServerEvent("vMenu:RequestPermissions", PlayerId());
                //TriggerServerEvent("vMenu:RequestBanList", PlayerId());

                // Wait until the data is received and the player's name is loaded correctly.
                while (!PreSetupComplete || GetPlayerName(PlayerId()) == "**Invalid**" || GetPlayerName(PlayerId()) == "** Invalid **")
                {
                    await Delay(0);
                }
                if ((Cf.IsAllowed(Permission.Staff) && GetSettingsBool(Setting.vmenu_menu_staff_only)) || GetSettingsBool(Setting.vmenu_menu_staff_only) == false)
                {
                    if (GetSettingsInt(Setting.vmenu_menu_toggle_key) != -1)
                    {
                        MenuToggleKey = GetSettingsInt(Setting.vmenu_menu_toggle_key);
                    }
                    if (GetSettingsInt(Setting.vmenu_noclip_toggle_key) != -1)
                    {
                        NoClipKey = GetSettingsInt(Setting.vmenu_noclip_toggle_key);
                    }
                    // Create the main menu.
                    Menu = new UIMenu("BigFam Crew", "Main Menu", true)
                    {
                        ScaleWithSafezone       = false,
                        MouseControlsEnabled    = false,
                        MouseEdgeEnabled        = false,
                        ControlDisablingEnabled = false
                    };

                    // Add the main menu to the menu pool.
                    Mp.Add(Menu);

                    Menu.RefreshIndex();
                    Menu.UpdateScaleform();

                    // Create all (sub)menus.
                    CreateSubmenus();
                }
            }
            #endregion


            // If the setup (permissions) is done, and it's not the first tick, then do this:
            if (PreSetupComplete && !firstTick)
            {
                #region Handle Opening/Closing of the menu.
                // If menus can be opened.
                if (!DontOpenMenus && !IsPauseMenuActive())
                {
                    // If the player is using Keyboard & Mouse and they pressed the M key (interaction menu button) then...
                    if (Game.CurrentInputMode == InputMode.MouseAndKeyboard && (Game.IsControlJustPressed(0, (Control)MenuToggleKey) || Game.IsDisabledControlJustPressed(0, (Control)MenuToggleKey)))
                    {
                        // If any menu is already open: close all menus.
                        if (Mp.IsAnyMenuOpen())
                        {
                            Mp.CloseAllMenus();
                        }
                        // Otherwise: toggle the main menu (to be safe, only open it if no other menus are open.)
                        else
                        {
                            Menu.Visible = !Mp.IsAnyMenuOpen();
                        }
                    }

                    // If the player is using a controller, and no menus are currently open.
                    else if (!Mp.IsAnyMenuOpen() && Game.CurrentInputMode == InputMode.GamePad)
                    {
                        // Create a timer and set it to the current game timer value.
                        int timer = GetGameTimer();

                        // While (and only if) the player keeps using only the controller, and keeps holding down the interactionmenu button (select on controller).
                        while (Game.CurrentInputMode == InputMode.GamePad && Game.IsControlPressed(0, Control.InteractionMenu))
                        {
                            // If debugging is enabled, show the progress using a timerbar.
                            if (DebugMode)
                            {
                                bt.Draw(0);
                                float percent = ((GetGameTimer() - timer) / 350f);
                                bt.Percentage = percent;
                            }

                            // If 900ms in real time have passed.
                            if (GetGameTimer() - timer > 350)
                            {
                                Menu.Visible = !Mp.IsAnyMenuOpen();
                                // Break the loop (resetting the timer).
                                break;
                            }

                            // Wait for the next game tick.
                            await Delay(0);
                        }
                    }

                    if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
                    {
                        if (Game.IsControlJustPressed(0, (Control)NoClipKey) && Cf.IsAllowed(Permission.NoClip))
                        {
                            if (IsPedInAnyVehicle(PlayerPedId(), false))
                            {
                                if (GetPedInVehicleSeat(Cf.GetVehicle(), -1) == PlayerPedId())
                                {
                                    NoClipEnabled = !Mp.IsAnyMenuOpen();
                                }
                                else
                                {
                                    NoClipEnabled = false;
                                    Notify.Error("You need to be the driver of this vehicle to enable noclip!");
                                }
                            }
                            else
                            {
                                NoClipEnabled = !Mp.IsAnyMenuOpen();
                            }
                        }
                    }

                    // Teleport to WP when F3 is pressed
                    if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
                    {
                        if (Game.IsControlJustPressed(0, Control.SaveReplayClip))
                        {
                            Cf.TeleportToWp();
                        }
                    }
                }
                // If the pause menu is active or all menus should be closed, close all menus.
                else
                {
                    await Delay(1);

                    Mp.CloseAllMenus();
                }
                #endregion

                // Menu toggle button.
                Game.DisableControlThisFrame(0, (Control)MenuToggleKey);

                #region Disable Inputs when any menu is open.
                if (Mp.IsAnyMenuOpen())
                {
                    // Close all menus when the player dies.
                    if (Game.PlayerPed.IsDead)
                    {
                        Mp.CloseAllMenus();
                    }

                    // Disable Gamepad/Controller Specific controls:
                    if (Game.CurrentInputMode == InputMode.GamePad)
                    {
                        Game.DisableControlThisFrame(0, Control.MultiplayerInfo);
                        // when in a vehicle.
                        if (IsPedInAnyVehicle(PlayerPedId(), false))
                        {
                            Game.DisableControlThisFrame(0, Control.VehicleHeadlight);
                            Game.DisableControlThisFrame(0, Control.VehicleDuck);
                        }
                    }
                    // Disable Shared Controls

                    // Radio Inputs
                    Game.DisableControlThisFrame(0, Control.RadioWheelLeftRight);
                    Game.DisableControlThisFrame(0, Control.RadioWheelUpDown);
                    Game.DisableControlThisFrame(0, Control.VehicleNextRadio);
                    Game.DisableControlThisFrame(0, Control.VehicleRadioWheel);
                    Game.DisableControlThisFrame(0, Control.VehiclePrevRadio);

                    // Phone / Arrows Inputs
                    Game.DisableControlThisFrame(0, Control.Phone);
                    Game.DisableControlThisFrame(0, Control.PhoneCancel);
                    Game.DisableControlThisFrame(0, Control.PhoneDown);
                    Game.DisableControlThisFrame(0, Control.PhoneLeft);
                    Game.DisableControlThisFrame(0, Control.PhoneRight);

                    // Attack Controls
                    Game.DisableControlThisFrame(0, Control.Attack);
                    Game.DisableControlThisFrame(0, Control.Attack2);
                    Game.DisableControlThisFrame(0, Control.MeleeAttack1);
                    Game.DisableControlThisFrame(0, Control.MeleeAttack2);
                    Game.DisableControlThisFrame(0, Control.MeleeAttackAlternate);
                    Game.DisableControlThisFrame(0, Control.MeleeAttackHeavy);
                    Game.DisableControlThisFrame(0, Control.MeleeAttackLight);
                    Game.DisableControlThisFrame(0, Control.VehicleAttack);
                    Game.DisableControlThisFrame(0, Control.VehicleAttack2);
                    Game.DisableControlThisFrame(0, Control.VehicleFlyAttack);
                    Game.DisableControlThisFrame(0, Control.VehiclePassengerAttack);
                    Game.DisableControlThisFrame(0, Control.Aim);

                    // When in a vehicle
                    if (IsPedInAnyVehicle(PlayerPedId(), false))
                    {
                        Game.DisableControlThisFrame(0, Control.VehicleSelectNextWeapon);
                        Game.DisableControlThisFrame(0, Control.VehicleSelectPrevWeapon);
                        Game.DisableControlThisFrame(0, Control.VehicleCinCam);
                    }
                }
                #endregion

                // Process the menu. Draw it and reset the menu width offset to make sure any newly generated menus always have the right width offset.
                Mp.WidthOffset = 50;
                if (Mp.IsAnyMenuOpen())
                {
                    Mp.Draw();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Main OnTick task runs every game tick and handles all the menu stuff.
        /// </summary>
        /// <returns></returns>
        private async Task OnTick()
        {
            #region FirstTick
            // Only run this the first tick.
            if (firstTick)
            {
                firstTick = false;
                // Clear all previous pause menu info/brief messages on resource start.
                ClearBrief();

                // Request the permissions data from the server.
                TriggerServerEvent("vMenu:RequestPermissions", PlayerId());

                // Wait until the data is received.
                while (!permissionsSetupDone || !optionsSetupDone || GetPlayerName(PlayerId()) == "**Invalid**" || GetPlayerName(PlayerId()) == "** Invalid **")
                {
                    await Delay(0);
                }

                // Create the main menu.
                Menu = new UIMenu(GetPlayerName(PlayerId()), "Main Menu", true)
                {
                    ScaleWithSafezone       = false,
                    MouseControlsEnabled    = false,
                    MouseEdgeEnabled        = false,
                    ControlDisablingEnabled = false
                };

                // Add the main menu to the menu pool.
                Mp.Add(Menu);

                Menu.RefreshIndex();
                Menu.UpdateScaleform();

                // Create all (sub)menus.
                CreateSubmenus();
            }
            #endregion

            // If the setup (permissions) is done, and it's not the first tick, then do this:
            if (permissionsSetupDone && optionsSetupDone && !firstTick)
            {
                #region Handle Opening/Closing of the menu.
                // If menus can be opened.
                if (!DontOpenMenus && !IsPauseMenuActive())
                {
                    // If the player is using Keyboard & Mouse and they pressed the M key (interaction menu button) then...
                    if (Game.CurrentInputMode == InputMode.MouseAndKeyboard && (Game.IsControlJustPressed(0, (Control)MenuToggleKey) || Game.IsDisabledControlJustPressed(0, (Control)MenuToggleKey)))
                    {
                        // If any menu is already open: close all menus.
                        if (Mp.IsAnyMenuOpen())
                        {
                            Mp.CloseAllMenus();
                        }
                        // Otherwise: toggle the main menu (to be safe, only open it if no other menus are open.)
                        else
                        {
                            Menu.Visible = !Mp.IsAnyMenuOpen();
                        }
                    }

                    // If the player is using a controller, and no menus are currently open.
                    else if (!Mp.IsAnyMenuOpen() && Game.CurrentInputMode == InputMode.GamePad)
                    {
                        // Create a timer and set it to 0.
                        //float timer = 0f;
                        int timer = GetGameTimer();

                        // While (and only if) the player keeps using only the controller, and keeps holding down the interactionmenu button (select on controller).
                        while (Game.CurrentInputMode == InputMode.GamePad && Game.IsControlPressed(0, Control.InteractionMenu))
                        {
                            // If debugging is enabled, show the progress using a timerbar.
                            if (DebugMode)
                            {
                                bt.Draw(0);
                                float percent = ((GetGameTimer() - timer) / 900f);
                                bt.Percentage = percent;
                                //Subtitle.Success(percent.ToString(), 0, true, "Progress:");
                            }

                            // If 900ms in real time have passed.
                            if (GetGameTimer() - timer > 900)
                            {
                                Menu.Visible = !Mp.IsAnyMenuOpen();
                                // Break the loop (resetting the timer).
                                break;
                            }

                            // Wait for the next game tick. This will make the timer only increment once per tick, so it'll take 60 game ticks for the menu to be open (60 frames is +/- 1 sec).
                            await Delay(0);
                        }
                    }
                }
                // If the pause menu is active or all menus should be closed, close all menus.
                else
                {
                    await Delay(3);

                    Mp.CloseAllMenus();
                }
                #endregion

                #region Disable Inputs when any menu is open.
                if (Mp.IsAnyMenuOpen())
                {
                    // Close all menus when the player dies.
                    if (Game.PlayerPed.IsDead)
                    {
                        Mp.CloseAllMenus();
                    }

                    // Disable Gamepad/Controller Specific controls:
                    if (Game.CurrentInputMode == InputMode.GamePad)
                    {
                        Game.DisableControlThisFrame(0, Control.MultiplayerInfo);
                        // when in a vehicle.
                        if (IsPedInAnyVehicle(PlayerPedId(), false))
                        {
                            Game.DisableControlThisFrame(0, Control.VehicleHeadlight);
                            Game.DisableControlThisFrame(0, Control.VehicleDuck);
                        }
                    }
                    // Disable Shared Controls

                    // Radio Inputs
                    Game.DisableControlThisFrame(0, Control.RadioWheelLeftRight);
                    Game.DisableControlThisFrame(0, Control.RadioWheelUpDown);
                    Game.DisableControlThisFrame(0, Control.VehicleNextRadio);
                    Game.DisableControlThisFrame(0, Control.VehicleRadioWheel);
                    Game.DisableControlThisFrame(0, Control.VehiclePrevRadio);

                    // Phone / Arrows Inputs
                    Game.DisableControlThisFrame(0, Control.Phone);
                    Game.DisableControlThisFrame(0, Control.PhoneCancel);
                    Game.DisableControlThisFrame(0, Control.PhoneDown);
                    Game.DisableControlThisFrame(0, Control.PhoneLeft);
                    Game.DisableControlThisFrame(0, Control.PhoneRight);

                    // Attack Controls
                    Game.DisableControlThisFrame(0, Control.Attack);
                    Game.DisableControlThisFrame(0, Control.Attack2);
                    Game.DisableControlThisFrame(0, Control.MeleeAttack1);
                    Game.DisableControlThisFrame(0, Control.MeleeAttack2);
                    Game.DisableControlThisFrame(0, Control.MeleeAttackAlternate);
                    Game.DisableControlThisFrame(0, Control.MeleeAttackHeavy);
                    Game.DisableControlThisFrame(0, Control.MeleeAttackLight);
                    Game.DisableControlThisFrame(0, Control.VehicleAttack);
                    Game.DisableControlThisFrame(0, Control.VehicleAttack2);
                    Game.DisableControlThisFrame(0, Control.VehicleFlyAttack);
                    Game.DisableControlThisFrame(0, Control.VehiclePassengerAttack);
                    Game.DisableControlThisFrame(0, Control.Aim);

                    // Menu toggle button.
                    Game.DisableControlThisFrame(0, (Control)MenuToggleKey);

                    // When in a vehicle
                    //if (IsPedInAnyVehicle(PlayerPedId(), false))
                    {
                        Game.DisableControlThisFrame(0, Control.VehicleSelectNextWeapon);
                        Game.DisableControlThisFrame(0, Control.VehicleSelectPrevWeapon);
                        Game.DisableControlThisFrame(0, Control.VehicleCinCam);
                    }
                }
                #endregion

                // Process the menu. Draw it and reset the menu width offset to make sure any newly generated menus always have the right width offset.
                Mp.WidthOffset = 50;
                Mp.Draw();
            }
        }
Exemple #4
0
        public void LoadIntellisenseResults(List <Diagnostic> hc)
        {
            lock (s_obs)
            {
                if (ef == null)
                {
                    return;
                }

                ScriptControl.ScriptControl scr = null;

                VSSolution vs = null;

                string filename = "";

                if (ef != null)
                {
                    if (ef.scr != null)
                    {
                        scr = ef.scr;
                    }
                }

                ToolStripComboBox b = toolStripComboBox1;

                int i = b.SelectedIndex;

                vs = ef.GetVSSolution();

                VSProject vp = null;
                //if (vs != null)
                //    vp = vs.MainVSProject;

                //dg.SuspendLayout();

                //LI = new ArrayList();

                //if (vp != null)
                //    if (i == 2)
                //    {
                //        foreach (IntErrors e in DD)
                //        {
                //            if (vp != null)
                //                if (e.vp != vp)
                //                    continue;

                //            int rowId = dg.Rows.Add();
                //            DataGridViewRow row = dg.Rows[rowId];

                //            row.Cells[0].Value = "";
                //            row.Cells[1].Value = ve_resource.Breakall_6323;
                //            row.Cells[2].Value = "e.Code";
                //            row.Cells[3].Value = e.e.Message;
                //            row.Cells[4].Value = Path.GetFileNameWithoutExtension(e.vp.FileName);
                //            row.Cells[5].Value = Path.GetFileName(e.file);
                //            row.Cells[6].Value = e.e.Region.BeginLine.ToString();
                //            row.Cells[7].Value = "project";

                //            string message = e.e.Message;

                //            //if (message.StartsWith("UnknownIdentifier") == true)
                //            //    MessageBox.Show("Unknown identifier");

                //            //v.Checked = true;

                //            row.Tag = e;

                //            //lv.Items.Add(v);
                //        }
                //        dg.ResumeLayout();
                //        return;
                //    }

                //if (i == 3 || i == 0)
                {
                    if (hc != null)
                    {
                    }

                    //filename = d.FileName;

                    foreach (/*IntErrors e in DD*/ Diagnostic hs in hc)
                    {
                        //if (filename != "")
                        //    if (e.file != filename)
                        //        continue;

                        Diagnostic dc = hs;// hc[hs];

                        filename = dc.Location.SourceTree.FilePath;

                        AvalonDocument d = scr.FileOpened(filename, false);

                        int hash = dc.GetMessage().GetHashCode();

                        if (hcd.ContainsKey(hash))
                        {
                            continue;
                        }

                        int    line = 0;
                        string file = "";
                        if (dc.Location != Microsoft.CodeAnalysis.Location.None)
                        {
                            if (dc.Location.SourceTree != null)
                            {
                                file = dc.Location.SourceTree.FilePath;// syntaxTree.FilePath;
                                FileLinePositionSpan c = dc.Location.GetLineSpan();
                                line = c.StartLinePosition.Line;
                            }
                        }

                        int             rowId = dg.Rows.Add();
                        DataGridViewRow row   = dg.Rows[rowId];
                        row.InheritedStyle.BackColor = Color.FromKnownColor(KnownColor.Control);
                        //dg.Rows.Remove(row);
                        //dg.Rows.Insert(0, row);
                        row.Cells[0].Value = dc.Descriptor.Category;
                        if (dc.Severity.ToString() == "Error")
                        {
                            row.Cells[1].Value = new Bitmap(ve_resource.Breakall_6323, 15, 15);
                            Ep.Add(row);
                        }
                        else if (dc.Severity.ToString() == "Warning")
                        {
                            row.Cells[1].Value = new Bitmap(ve_resource.StatusWarning_16x, 15, 15);
                            Wp.Add(row);
                        }
                        else
                        {
                            row.Cells[1].Value = new Bitmap(ve_resource.StatusHelp_256x, 15, 15);
                            Mp.Add(row);
                        }

                        row.Cells[2].Value = dc.Descriptor.Id;
                        row.Cells[3].Value = dc.GetMessage();

                        if (dc.Location != Microsoft.CodeAnalysis.Location.None)
                        {
                            if (vp != null)
                            {
                                row.Cells[4].Value = Path.GetFileNameWithoutExtension(vp.FileName);
                            }
                            else if (dc.Location != Microsoft.CodeAnalysis.Location.None)
                            {
                                if (dc.Location.SourceTree != null)
                                {
                                    row.Cells[4].Value = Path.GetFileNameWithoutExtension(dc.Location.SourceTree.FilePath);
                                }
                            }
                        }
                        row.Cells[5].Value = Path.GetFileName(file);
                        if (line > 0)
                        {
                            row.Cells[6].Value = d.GetLineExtended(line) + 1;
                        }
                        row.Cells[7].Value = "project";

                        //row.Cells[0].Value = "";
                        //row.Cells[1].Value = ve_resource.Errors;
                        //row.Cells[2].Value = "e.Code";
                        //row.Cells[3].Value = e.e.Message;
                        //row.Cells[4].Value = Path.GetFileNameWithoutExtension(e.vp.FileName);
                        //row.Cells[5].Value = Path.GetFileName(e.file);
                        //row.Cells[6].Value = e.e.Region.BeginLine.ToString();
                        //row.Cells[7].Value = "project";

                        //ListViewItem v = new ListViewItem();
                        //v.Text = "";
                        //v.SubItems.Add("");
                        //v.SubItems.Add("e.Code");
                        //v.SubItems.Add(e.e.Message);
                        //v.SubItems.Add(Path.GetFileNameWithoutExtension(e.vp.FileName));
                        //v.SubItems.Add(Path.GetFileName(e.c.FileName));
                        //v.SubItems.Add(e.e.Region.BeginLine.ToString());
                        //v.SubItems.Add("project");

                        //v.Checked = true;

                        row.Tag = dc;

                        dg.Rows.Remove(row);
                        dg.Rows.Insert(0, row);

                        hcd.Add(hash, row);

                        //lv.Items.Add(v);
                    }

                    dg.ResumeLayout();

                    //ef.scr.FocusActiveDocument();
                    return;
                }

                //ArrayList F = ef.scr.GetOpenFiles();

                /*
                 * foreach (IntErrors e in DD)
                 * {
                 *  //ListViewItem v = new ListViewItem();
                 *  //v.Text = "";
                 *  //v.SubItems.Add("");
                 *  //v.SubItems.Add("e.Code");
                 *  //v.SubItems.Add(e.e.Message);
                 *  //v.SubItems.Add(Path.GetFileNameWithoutExtension(e.c.FileName));
                 *  //v.SubItems.Add(Path.GetFileName(e.c.FileName));
                 *  //v.SubItems.Add(e.e.Region.BeginLine.ToString());
                 *  //v.SubItems.Add("project");
                 *
                 *  //v.Checked = true;
                 *
                 *  int rowId = dg.Rows.Add();
                 *  DataGridViewRow row = dg.Rows[rowId];
                 *  row.InheritedStyle.BackColor = Color.FromKnownColor(KnownColor.Control);
                 *
                 *  row.Cells[0].Value = "";
                 *  row.Cells[1].Value = ve_resource.Errors;
                 *  row.Cells[2].Value = "e.Code";
                 *  row.Cells[3].Value = e.e.Message;
                 *  row.Cells[4].Value = Path.GetFileNameWithoutExtension(e.vp.FileName);
                 *  row.Cells[5].Value = Path.GetFileName(e.file);
                 *  row.Cells[6].Value = e.e.Region.BeginLine.ToString();
                 *  row.Cells[7].Value = "project";
                 *
                 *  //string message = e.e.Message;
                 *
                 *  //if (message.StartsWith("UnknownIdentifier") == true)
                 *  //{
                 *  //    // MessageBox.Show("Unknown identifier");
                 *
                 *  //    string[] cc = e.e.Message.Split(" ".ToCharArray());
                 *
                 *  //    Document d = ef.scr.FileOpened(e.c.FileName);
                 *
                 *  //    //foreach (Row r in d.Editor.Document)
                 *  //    //    foreach (Word w in r)
                 *  //    //        w.HasError = false;
                 *
                 *  //    if (d != null)
                 *  //    {
                 *  //        // MessageBox.Show("File has been found");
                 *
                 *  //        if (e.e.Region.BeginLine < 0)
                 *  //            continue;
                 *
                 *  //        d.SuspendLayout();
                 *
                 *  //        Row r = d.Editor.Document[e.e.Region.BeginLine];
                 *
                 *  //        foreach (Word w in r)
                 *  //        {
                 *  //            string[] bb = w.Text.Split(";".ToCharArray());
                 *
                 *  //            foreach (string dd in bb)
                 *
                 *  //                if (dd == cc[1])
                 *  //                {
                 *  //                    // MessageBox.Show("Identifier found");
                 *
                 *  //                    w.HasError = true;
                 *
                 *  //                    //d.Refresh();
                 *  //                }
                 *  //        }
                 *
                 *  //        d.ResumeLayout();
                 *  //    }
                 *
                 *  //}
                 *
                 *  row.Tag = e;
                 * }
                 *
                 * ef.scr.LoadErrors(DD);
                 *
                 * dg.ResumeLayout();
                 */
            }
        }