Пример #1
0
        /// <summary>f
        /// Constructor.
        /// </summary>
        public MainMenu()
        {
            // Set discord rich precense once, allowing it to be overruled by other resources once those load.
            if (DebugMode)
            {
                SetRichPresence($"Debugging vMenu {Version}!");
            }

            if (GetCurrentResourceName() != "vMenu")
            {
                Exception InvalidNameException = new Exception("\r\n\r\n[vMenu] INSTALLATION ERROR!\r\nThe name of the resource is not valid. Please change the folder name from '" + GetCurrentResourceName() + "' to 'vMenu' (case sensitive) instead!\r\n\r\n\r\n");
                try
                {
                    throw InvalidNameException;
                }
                catch (Exception e)
                {
                    Cf.Log(e.Message);
                }
                TriggerEvent("chatMessage", "^3IMPORTANT: vMenu IS NOT SETUP CORRECTLY. PLEASE CHECK THE SERVER LOG FOR MORE INFO.");
            }
            else
            {
                Tick += OnTick;
                Tick += ProcessMainButtons;
                Tick += ProcessDirectionalButtons;
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainMenu()
        {
            RegisterCommand("vmenuclient", new Action <dynamic, List <dynamic>, string>((dynamic source, List <dynamic> args, string rawCommand) =>
            {
                if (args != null)
                {
                    if (args.Count > 0)
                    {
                        if (args[0].ToString().ToLower() == "debug")
                        {
                            DebugMode = !DebugMode;
                            Notify.Custom($"Debug mode is now set to: {DebugMode}.");
                        }
                    }
                    else
                    {
                        Notify.Custom($"vMenu is currently running version: {Version}.");
                    }
                }
            }), false);

            // Set discord rich precense once, allowing it to be overruled by other resources once those load.
            if (DebugMode)
            {
                SetRichPresence($"Debugging vMenu {Version}!");
            }

            if (GetCurrentResourceName() != "vMenu")
            {
                Exception InvalidNameException = new Exception("\r\n\r\n[vMenu] INSTALLATION ERROR!\r\nThe name of the resource is not valid. Please change the folder name from '" + GetCurrentResourceName() + "' to 'vMenu' (case sensitive) instead!\r\n\r\n\r\n");
                try
                {
                    throw InvalidNameException;
                }
                catch (Exception e)
                {
                    Cf.Log(e.Message);
                }
                TriggerEvent("chatMessage", "^3IMPORTANT: vMenu IS NOT SETUP CORRECTLY. PLEASE CHECK THE SERVER LOG FOR MORE INFO.");
            }
            else
            {
                if (InitializeConfig())
                {
                    Debug.WriteLine("[vMenu] Config initialized.");
                }
                else
                {
                    Debug.WriteLine("[vMenu] Config failed to load, using defaults.");
                }
                Tick += OnTick;
                Tick += ProcessMainButtons;
                Tick += ProcessDirectionalButtons;
            }
        }
Пример #3
0
        /// <summary>
        /// Set the permissions for this client.
        /// </summary>
        /// <param name="dict"></param>
        public static void SetPermissions(dynamic dict)
        {
            // Loop through the dynamic object and get the keys and values.
            foreach (dynamic permission in dict)
            {
                // Add the new permission to the dictionary.
                PermissionsManager.SetPermission(permission.Key.ToString(), permission.Value);
            }
            Cf.Log(JsonConvert.SerializeObject(PermissionsManager.Permissions).ToString());

            permissionsSetupDone = true;
        }
Пример #4
0
        /// <summary>
        /// Sets the settings received from the server.
        /// </summary>
        /// <param name="options"></param>
        public static void SetOptions(dynamic options)
        {
            MenuOptions = new Dictionary <string, string>();
            foreach (dynamic option in options)
            {
                MenuOptions.Add(option.Key.ToString(), option.Value.ToString());
            }
            Cf.Log($"Settings loaded: {JsonConvert.SerializeObject(MenuOptions)}");

            MenuToggleKey    = int.Parse(MenuOptions["menuKey"].ToString());
            NoClipKey        = int.Parse(MenuOptions["noclipKey"].ToString());
            optionsSetupDone = true;
        }
Пример #5
0
 /// <summary>
 /// Sets the settings received from the server.
 /// </summary>
 /// <param name="options"></param>
 public static void SetOptions(dynamic options)
 {
     MenuOptions = new Dictionary <string, string>();
     foreach (dynamic option in options)
     {
         if (DebugMode)
         {
             Cf.Log($"{option.Key} == {option.Value}");
         }
         MenuOptions.Add(option.Key, option.Value);
     }
     MenuToggleKey    = int.Parse(MenuOptions["menuKey"].ToString());
     optionsSetupDone = true;
 }
Пример #6
0
 /// <summary>
 /// Set the permissions for this client.
 /// </summary>
 /// <param name="dict"></param>
 public static void SetPermissions(dynamic dict)
 {
     // Loop through the dynamic object and get the keys and values.
     foreach (dynamic permission in dict)
     {
         if (DebugMode)
         {
             Cf.Log($"{permission.Key.ToString()} = {permission.Value.ToString()}");
         }
         // Add the new permission to the dictionary.
         PermissionsManager.SetPermission(permission.Key.ToString(), permission.Value);
     }
     permissionsSetupDone = true;
 }
Пример #7
0
        /// <summary>
        /// Sets the settings received from the server.
        /// </summary>
        /// <param name="options"></param>
        public static void SetOptions(dynamic options)
        {
            MenuOptions = new Dictionary <string, string>();
            foreach (dynamic option in options)
            {
                MenuOptions.Add(option.Key.ToString(), option.Value.ToString());
            }
            Cf.Log($"Settings loaded: {JsonConvert.SerializeObject(MenuOptions)}");

            MenuToggleKey    = int.Parse(MenuOptions["menuKey"].ToString());
            NoClipKey        = int.Parse(MenuOptions["noclipKey"].ToString());
            optionsSetupDone = true;
            if (MenuOptions.ContainsKey("disableSync"))
            {
                if (MenuOptions["disableSync"] == "true")
                {
                    EventManager.enableSync = false;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Set the permissions for this client.
        /// </summary>
        /// <param name="dict"></param>
        public static void SetPermissions(dynamic dict)
        {
            // Loop through the dynamic object and get the keys and values.
            foreach (dynamic permission in dict)
            {
                // Add the new permission to the dictionary.
                PermissionsManager.SetPermission(permission.Key.ToString(), permission.Value);
            }
            Cf.Log(JsonConvert.SerializeObject(PermissionsManager.Permissions).ToString());

            //permissionsSetupDone = true;
            VehicleSpawner.allowedCategories = new List <bool>()
            {
                Cf.IsAllowed(Permission.VSCompacts),
                Cf.IsAllowed(Permission.VSSedans),
                Cf.IsAllowed(Permission.VSSUVs),
                Cf.IsAllowed(Permission.VSCoupes),
                Cf.IsAllowed(Permission.VSMuscle),
                Cf.IsAllowed(Permission.VSSportsClassic),
                Cf.IsAllowed(Permission.VSSports),
                Cf.IsAllowed(Permission.VSSuper),
                Cf.IsAllowed(Permission.VSMotorcycles),
                Cf.IsAllowed(Permission.VSOffRoad),
                Cf.IsAllowed(Permission.VSIndustrial),
                Cf.IsAllowed(Permission.VSUtility),
                Cf.IsAllowed(Permission.VSVans),
                Cf.IsAllowed(Permission.VSCycles),
                Cf.IsAllowed(Permission.VSBoats),
                Cf.IsAllowed(Permission.VSHelicopters),
                Cf.IsAllowed(Permission.VSPlanes),
                Cf.IsAllowed(Permission.VSService),
                Cf.IsAllowed(Permission.VSEmergency),
                Cf.IsAllowed(Permission.VSMilitary),
                Cf.IsAllowed(Permission.VSCommercial),
                Cf.IsAllowed(Permission.VSTrains),
            };
        }