public void Activate() { foreach (var cmd in this.consoleCommands) { ConVarManager.SetValue(cmd.Key, cmd.Value); } }
public void Activate() { this.menu = this.mainMenu.CheatsMenu; this.refresh = this.menu.CreateHoldKey("Refresh", Key.NumPad3); this.refresh.ValueChanged += this.RefreshOnPropertyChanged; this.wtf = this.menu.CreateHoldKey("Change wtf", Key.Divide); this.wtf.ValueChanged += this.WtfOnPropertyChanged; this.vision = this.menu.CreateHoldKey("Change vision", Key.Multiply); this.vision.ValueChanged += this.VisionOnPropertyChanged; this.allVisionEnabled = ConVarManager.GetInt32("dota_all_vision") == 1; this.creeps = this.menu.CreateHoldKey("Change creeps spawn", Key.NumPad0); this.creeps.ValueChanged += this.CreepsOnPropertyChanged; this.hero25Lvl = this.menu.CreateHoldKey("Hero 25lvl", Key.NumPad1); this.hero25Lvl.ValueChanged += this.Hero25LvlOnPropertyChanged; this.heroGold = this.menu.CreateHoldKey("Hero gold", Key.NumPad1); this.heroGold.ValueChanged += this.HeroGoldOnPropertyChanged; this.bot25Lvl = this.menu.CreateHoldKey("Bot 25lvl", Key.NumPad2); this.bot25Lvl.ValueChanged += this.Bot25LvlOnPropertyChanged; }
private void EnabledOnValueChange(object sender, SwitcherEventArgs e) { if (e.NewValue) { if (e.OldValue) { //todo delete if (AppDomain.CurrentDomain.GetAssemblies().Any(x => !x.GlobalAssemblyCache && x.GetName().Name.Contains("Zoomhack"))) { Hud.DisplayWarning("O9K.Hud // ZoomHack is already included in O9K.Hud"); } } foreach (var cmd in this.consoleCommands) { ConVarManager.SetValue(cmd.Key, cmd.Value); } this.zoom.ValueChange += this.ZoomOnValueChange; this.key.ValueChange += this.KeyOnValueChange; } else { this.key.ValueChange -= this.KeyOnValueChange; this.zoom.ValueChange -= this.ZoomOnValueChange; InputManager.MouseWheel -= this.OnMouseWheel; ConVarManager.SetValue("dota_camera_distance", GameData.DefaultZoom); } }
/// <summary> /// Initializes the language system. /// </summary> public static void Init() { serverLang = ConVarManager.CreateConVar(null, "ServerLang", DefaultLang, "The language key for the server").Value; serverLang.ConVar.ValueChanged += OnServerLanguageChanged; foreach (var file in coreFiles) { LoadPhrases(file); } }
public ZoomHack(RootMenu rootMenu) { var zoomHackMenu = rootMenu.CreateMenu("Zoom Hack"); ZoomKeyItem = zoomHackMenu.CreateHoldKey("Key", Key.LeftCtrl); ZoomSliderItem = zoomHackMenu.CreateSlider("Camera Distance", DefaultZoomValue, MinZoomValue, MaxZoomValue); ConVarManager.SetValue("r_farz", 18000); ZoomSliderItem.ValueChanged += OnZoomSliderValueChanged; InputManager.MouseWheel += OnInputManagerMouseWheel; GameManager.ExecuteCommand("dota_camera_disable_zoom true"); }
/// <summary> /// Initializes the chat helper. /// </summary> public static void Init() { var description = new StringBuilder() .AppendLine("Specifies how admin activity should be relayed to users. Add up the values below to get the functionality you want.") .AppendLine("1: Show admin activity to non-admins anonymously.") .AppendLine("2: If 1 is specified, admin names will be shown.") .AppendLine("4: Show admin activity to admins anonymously.") .AppendLine("8: If 4 is specified, admin names will be shown.") .AppendLine("16: Always show admin names to root users.") .AppendLine() .AppendLine("Default: 13 (1+4+8)") .ToString(); showActivity = ConVarManager.CreateConVar(null, "ShowActivity", "13", description, true, 0, true, 31).Value; }
public Minimap(IHudMenu hudMenu) { var minimapSize = new Vector2(Hud.Info.ScreenSize.X * 0.127f, Hud.Info.ScreenSize.Y * 0.226f); if (ConVarManager.GetInt32("dota_hud_extra_large_minimap") == 1) { minimapSize *= 1.145f; } var settings = hudMenu.MinimapSettingsMenu; this.debug = settings.Add(new MenuSwitcher("Debug", false)); this.debug.SetTooltip("Use this to adjust minimap position and size"); this.debug.AddTranslation(Lang.Ru, "Проверка"); this.debug.AddTooltipTranslation(Lang.Ru, "Использовать для настройки"); this.debug.AddTranslation(Lang.Cn, "调试"); this.debug.AddTooltipTranslation(Lang.Cn, "使用它来调整小地图的位置和大小"); this.debug.DisableSave(); this.xPosition = settings.Add(new MenuSlider("X coordinate", "x", 0, 0, (int)Hud.Info.ScreenSize.X)); this.xPosition.AddTranslation(Lang.Ru, "X координата"); this.xPosition.AddTranslation(Lang.Cn, "X位置"); this.yPosition = settings.Add( new MenuSlider("Y coordinate", "y", (int)(Hud.Info.ScreenSize.Y - minimapSize.Y), 0, (int)Hud.Info.ScreenSize.Y)); this.yPosition.AddTranslation(Lang.Ru, "Y координата"); this.yPosition.AddTranslation(Lang.Cn, "Y位置"); this.xSize = settings.Add(new MenuSlider("X Size", "xSize", (int)minimapSize.X, 0, 600)); this.xSize.AddTranslation(Lang.Ru, "X размер"); this.xSize.AddTranslation(Lang.Cn, "X大小"); this.ySize = settings.Add(new MenuSlider("Y Size", "ySize", (int)minimapSize.Y, 0, 600)); this.ySize.AddTranslation(Lang.Ru, "Y размер"); this.ySize.AddTranslation(Lang.Cn, "Y大小"); if (GameManager.LevelName == "maps/hero_demo_main.vpk") { this.MapLeft = -3500; this.MapBottom = -3600; this.MapRight = 3000; this.MapTop = 2700; } }
/// <summary> /// Loads the enabled plugins. /// </summary> public static void Refresh() { if (IsLocked) { throw new NotSupportedException(); } var files = Directory.GetFiles(SMPath.Plugins, "*.dll"); foreach (var file in files) { var name = Path.GetFileNameWithoutExtension(file); loadQueue.Enqueue(NameToKey(name)); } while (loadQueue.Count > 0) { Load(loadQueue.Dequeue(), true); } if (!ConVarManager.ConfigsLoaded) { ConVarManager.ExecuteConfigs(); foreach (var k in Plugins.Keys.ToArray()) { if (Plugins.TryGetValue(k, out var plugin) && plugin.LoadStatus == PluginContainer.Status.Loaded) { try { plugin.Plugin.OnConfigsExecuted(); } catch (HaltPluginException) { } catch (Exception e) { plugin.SetFailState(e); } } } } AdminManager.ReloadAdmins(); }
private void OnInputManagerMouseWheel(MouseWheelEventArgs e) { if (ZoomKeyItem) { var zoomValue = ConVarManager.GetInt32("dota_camera_distance"); if (e.Up) { zoomValue -= 50; zoomValue = Math.Max(zoomValue, MinZoomValue); } else { zoomValue += 50; zoomValue = Math.Min(zoomValue, MaxZoomValue); } ZoomSliderItem.Value = zoomValue; } }
/// <inheritdoc/> public void InitMod() { ModEvents.ChatMessage.RegisterHandler((ClientInfo cInfo, EChatType chatType, int senderEntityId, string msg, string mainName, bool localizeMain, List <int> recipientEntityIds) => this.OnChatMessage(cInfo, chatType, msg, recipientEntityIds)); ModEvents.GameAwake.RegisterHandler(this.OnGameAwake); ModEvents.GameShutdown.RegisterHandler(this.OnGameShutdown); ModEvents.GameStartDone.RegisterHandler(this.OnGameStartDone); ModEvents.PlayerDisconnected.RegisterHandler(this.OnPlayerDisconnected); ModEvents.PlayerLogin.RegisterHandler((ClientInfo cInfo, string compatibilityVersion, StringBuilder rejectReason) => this.OnPlayerLogin(cInfo, rejectReason)); ModEvents.PlayerSpawnedInWorld.RegisterHandler(this.OnPlayerSpawnedInWorld); ModEvents.PlayerSpawning.RegisterHandler((ClientInfo cInfo, int chunkViewDim, PlayerProfile playerProfile) => this.OnPlayerSpawning(cInfo)); ModEvents.SavePlayerData.RegisterHandler((ClientInfo cInfo, PlayerDataFile playerDataFile) => this.OnSavePlayerData(cInfo)); Language.Init(); ChatHelper.Init(); ChatHook.Init(); VoteManager.Init(); ConVarManager.AutoExecConfig(null, true, "Core"); PluginManager.Refresh(); }
/// <summary> /// Unloads a plugin. /// </summary> /// <param name="name">The name of the plugin.</param> public static void Unload(string name) { if (IsLocked) { throw new NotSupportedException(); } var key = NameToKey(name); if (Plugins.TryGetValue(key, out var plugin)) { plugin.LoadStatus = PluginContainer.Status.Unloaded; try { IsLocked = true; plugin.Plugin.OnUnloadPlugin(); (plugin as IDisposable)?.Dispose(); IsLocked = false; } catch (HaltPluginException) { } catch (Exception e) { plugin.SetFailState(e); } Language.UnloadPlugin(plugin.Plugin); AdminCommandManager.UnloadPlugin(plugin.Plugin); ConVarManager.UnloadPlugin(plugin.Plugin); plugin.Plugin = null; AdminManager.ReloadAdmins(); Plugins.Remove(key); } }
/// <summary> /// Unloads all plugins. /// </summary> public static void UnloadAll() { if (IsLocked) { throw new NotSupportedException(); } IsLocked = true; foreach (var key in Plugins.Keys) { if (Plugins.TryGetValue(key, out var plugin) && plugin.LoadStatus == PluginContainer.Status.Loaded) { plugin.LoadStatus = PluginContainer.Status.Unloaded; try { plugin.Plugin.OnUnloadPlugin(); (plugin as IDisposable)?.Dispose(); } catch (HaltPluginException) { } catch (Exception e) { plugin.SetFailState(e); } AdminCommandManager.UnloadPlugin(plugin.Plugin); ConVarManager.UnloadPlugin(plugin.Plugin); plugin.Plugin = null; } } Plugins.Clear(); IsLocked = false; AdminManager.ReloadAdmins(); }
private void ParticleHackItemChanged(MenuSwitcher switcher, SwitcherEventArgs e) { ConVarManager.SetValue("dota_use_particle_fow", !e.Value); }
/*public void Dispose() * { * Game.ExecuteCommand("dota_camera_disable_zoom false"); * * ZoomVar.SetValue(DefaultZoomValue); * * ZoomSliderItem.PropertyChanged -= ZoomSliderItemChanged; * InputManage.Value.MouseWheel -= InputManagerMouseWheel; * }*/ private void OnZoomSliderValueChanged(MenuSlider slider, SliderEventArgs e) { ConVarManager.SetValue("dota_camera_distance", e.NewValue); }
/// <summary> /// Initializes the voting system. /// </summary> internal static void Init() { ShowVoteProgress = ConVarManager.CreateConVar(null, "ShowVoteProgress", "True", "Show votes in chat.").Value; }
/// <summary> /// Creates a new <see cref="ConVar"/> or returns the existing one if one with the same name already exists. /// </summary> /// <param name="name">The name of the variable.</param> /// <param name="defaultValue">The default value of the variable as a string.</param> /// <param name="description">Optional description for the variable.</param> /// <param name="hasMin">Optional value indicating whether the variable has a minimum value.</param> /// <param name="min">The minimum value of the variable if <paramref name="hasMin"/> is <c>true</c>.</param> /// <param name="hasMax">Optional value indicating whether the variable has a maximum value.</param> /// <param name="max">The maximum value of the variable if <paramref name="hasMax"/> is <c>true</c>.</param> /// <returns>The <see cref="ConVar"/> object representing the console variable.</returns> protected ConVar CreateConVar(string name, string defaultValue, string description = "", bool hasMin = false, float min = 0.0f, bool hasMax = false, float max = 1.0f) { return(ConVarManager.CreateConVar(this, name, defaultValue, description, hasMin, min, hasMax, max)); }
/// <summary> /// Loads a plugin. /// </summary> /// <param name="key">The dictionary key of the plugin.</param> /// <param name="refreshing">A value indicating whether the plugin list is being refreshed.</param> private static void Load(string key, bool refreshing) { if (IsLocked) { throw new NotSupportedException(); } if (Plugins.ContainsKey(key) && Plugins[key].LoadStatus == PluginContainer.Status.Loaded) { return; } var file = $"{SMPath.Plugins}{key}.dll"; if (!File.Exists(file)) { return; } try { var dll = Assembly.Load(File.ReadAllBytes(file)); var type = dll.GetType($"SevenMod.Plugin.{key}.{key}", true, true); var container = new PluginContainer(Path.GetFileName(file)); if (type.IsSubclassOf(PluginParentType)) { try { var plugin = Activator.CreateInstance(type) as PluginAbstract; plugin.Container = container; plugin.OnLoadPlugin(); if (API.IsGameAwake) { plugin.OnGameAwake(); } if (API.IsGameStartDone) { plugin.OnGameStartDone(); } if (ConVarManager.ConfigsLoaded) { ConVarManager.ExecuteConfigs(plugin); plugin.OnConfigsExecuted(); } if (!refreshing) { AdminManager.ReloadAdmins(); } container.Plugin = plugin; container.PluginInfo = plugin.Info; container.LoadStatus = PluginContainer.Status.Loaded; } catch (HaltPluginException) { throw; } catch (Exception e) { container.LoadStatus = PluginContainer.Status.Error; container.Error = e.Message; throw; } Plugins[key] = container; } else { throw new Exception($"{type.Name} does not inherit from {PluginParentType.Name}"); } } catch (Exception e) { SMLog.Error($"Failed loading plugin {key}.dll: {e.Message}"); SMLog.Error(e); } }
/// <summary> /// Adds a configuration file to be automatically loaded. /// </summary> /// <param name="autoCreate">A value indicating whether the file should be automatically created if it does not exist.</param> /// <param name="name">The name of the configuration file without extension.</param> protected void AutoExecConfig(bool autoCreate, string name) { ConVarManager.AutoExecConfig(this, autoCreate, name); }
/// <summary> /// Find an existing console variable with the specified name. /// </summary> /// <param name="name">The name of the console variable to locate.</param> /// <returns>The <see cref="ConVar"/> object representing the console variable if found; otherwise <c>null</c>.</returns> protected ConVar FindConVar(string name) { return(ConVarManager.FindConVar(this, name)); }
private void ZoomOnValueChange(object sender, SliderEventArgs e) { ConVarManager.SetValue("dota_camera_distance", e.NewValue); }
private void FilteringItemChanged(MenuSwitcher switcher, SwitcherEventArgs e) { ConVarManager.SetValue("fow_client_nofiltering", e.Value); }
/*public void Dispose() * { * Fog.SetValue(1); * Filtering.SetValue(0); * ParticleHack.SetValue(1); * * FogItem.PropertyChanged -= FogItemChanged; * FilteringItem.PropertyChanged -= FilteringItemChanged; * ParticleHackItem.PropertyChanged -= ParticleHackItemChanged; * }*/ private void FogItemChanged(MenuSwitcher switcher, SwitcherEventArgs e) { ConVarManager.SetValue("fog_enable", !e.Value); }
/*public void Dispose() * { * Weather.SetValue(0); * * WeatherItem.PropertyChanged -= WeatherItemChanged; * }*/ private void OnWeatherValueChanged(MenuSelector selector, SelectorEventArgs e) { ConVarManager.SetValue("cl_weather", Array.IndexOf(WeatherNames, e.NewValue)); }
/// <summary> /// Initializes the chat hook system. /// </summary> internal static void Init() { publicChatTrigger = ConVarManager.CreateConVar(null, "PublicChatTrigger", "!", "Chat prefix for public commands.").Value; silentChatTrigger = ConVarManager.CreateConVar(null, "SilentChatTrigger", "/", "Chat prefix for silent commands.").Value; }