public static void LoadConfig(ICoreClientAPI capi) { if ((capi.LoadModConfig <VSHUDConfig>("vshud.json") ?? capi.LoadModConfig <VSHUDConfig>("waypointutils.json")) == null) { SaveConfig(capi); return; } Config = capi.LoadModConfig <VSHUDConfig>("vshud.json") ?? capi.LoadModConfig <VSHUDConfig>("waypointutils.json"); SaveConfig(capi); }
public override void StartClientSide(ICoreClientAPI api) { capi = api; configLoader = capi.ModLoader.GetModSystem <ConfigLoader>(); config = ConfigLoader.Config; capi.RegisterCommand("lightutil", "Light Util", "[lightlevel|type|radius|alpha|red]", new ClientChatCommandDelegate(CmdLightUtil)); capi.Event.LevelFinalize += () => { capi.InjectClientThread("LightUtil", 40, new LightUtilSystem(api.World as ClientMain, config)); }; }
public override void StartClientSide(ICoreClientAPI api) { renderer = new PlacementRenderer(api); api.Event.RegisterRenderer(renderer, EnumRenderStage.Opaque); api.Input.RegisterHotKey("placementpreviewtoggle", "Toggle Placement Preview", GlKeys.Quote); api.Input.SetHotKeyHandler("placementpreviewtoggle", (a) => { VSHUDConfig config = ConfigLoader.Config; config.PRShow = !config.PRShow; ConfigLoader.SaveConfig(api); return(true); }); api.Event.LevelFinalize += () => api.Shader.ReloadShaders(); }
public static bool LoadConfig(ICoreClientAPI capi) { try { if ((capi.LoadModConfig <VSHUDConfig>("vshud.json") ?? capi.LoadModConfig <VSHUDConfig>("waypointutils.json")) == null) { SaveConfig(capi); return(true); } Config = capi.LoadModConfig <VSHUDConfig>("vshud.json") ?? capi.LoadModConfig <VSHUDConfig>("waypointutils.json"); SaveConfig(capi); return(true); } catch (Exception) { capi.World.Logger.Notification("Error while parsing VSHUD configuration file, will use fallback settings. All changes to configuration in game will not be saved!"); capi.World.Logger.Notification("Use .vshudforcesave to fix."); return(false); } }
public LightUtilSystem(ClientMain game, VSHUDConfig config) : base(game) { this.config = config; capi = (ICoreClientAPI)game.Api; }
public override void StartClientSide(ICoreClientAPI api) { renderer = new PlacementRenderer(api); api.Event.RegisterRenderer(renderer, EnumRenderStage.Opaque); api.Input.RegisterHotKey("placementpreviewtoggle", "Toggle Placement Preview", GlKeys.Quote); api.Input.SetHotKeyHandler("placementpreviewtoggle", (a) => { VSHUDConfig config = api.ModLoader.GetModSystem <WaypointUtils>().Config; config.PRShow = !config.PRShow; api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig(); return(true); }); api.RegisterCommand("pconfig", "Config Placement Preview System", "[enabled|tinted|tintcolorhex|tintcolorrgb|tintdefault|opacity]", (id, args) => { VSHUDConfig config = api.ModLoader.GetModSystem <WaypointUtils>().Config; string arg = args.PopWord(); bool?enabled; switch (arg) { case "enabled": enabled = args.PopBool(); config.PRShow = enabled ?? !config.PRShow; api.ShowChatMessage("Block preview set to " + config.PRShow); break; case "tinted": enabled = args.PopBool(); config.PRTint = enabled ?? !config.PRTint; api.ShowChatMessage("Block preview tinting set to " + config.PRTint); break; case "tintcolorhex": string col = args.PopWord(); if (col?[0] == '#') { var color = ColorUtil.Hex2Doubles(col); config.PRTintColor = new float[] { (float)(color[0]) * 10.0f, (float)(color[1]) * 10.0f, (float)(color[2]) * 10.0f, }; } break; case "opacity": config.PROpacity = args.PopFloat() ?? config.PROpacity; break; case "opacitydefault": config.PROpacity = new VSHUDConfig().PROpacity; break; case "tintcolorrgb": config.PRTintColor[0] = args.PopFloat() ?? config.PRTintColor[0]; config.PRTintColor[1] = args.PopFloat() ?? config.PRTintColor[1]; config.PRTintColor[2] = args.PopFloat() ?? config.PRTintColor[2]; break; case "tintdefault": config.PRTintColor = new VSHUDConfig().PRTintColor; break; default: break; } api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig(); }); api.Event.LevelFinalize += () => api.Shader.ReloadShaders(); }
public override void OnOwnPlayerDataReceived() { base.OnOwnPlayerDataReceived(); config = ConfigLoader.Config; ElementBounds dialogBounds = ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 30, 0, 465, 500); ElementBounds bgBounds = ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 0, -200, 465, 100); string[] colors; List <string> c = new List <string>() { "Random" }; string[] names = Enum.GetNames(typeof(KnownColor)); for (int i = 28; i < 166; i++) { c.Add(names[i]); } colors = c.ToArray(); config.SetColorIndex = config.SetColorIndex < 0 ? 0 : config.SetColorIndex; color = colors[config.SetColorIndex]; UpdateDropDown(colors, color); SingleComposer = capi.Gui.CreateCompo("waypointfrontend", dialogBounds) .AddDialogTitleBar("Waypoint Utils", VClose, CairoFont.WhiteSmallText()) .AddDialogBG(bgBounds) .AddTextInput(ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 86.5, -200, 370, 20), OnTextChanged, null, "textinput") .AddDropDown(colors, colors, config.SetColorIndex, (newval, on) => { UpdateDropDown(colors, newval); capi.TriggerChatMessage(".wpcfg save"); ///capi.Event.RegisterCallback(dt => capi.ModLoader.GetModSystem<FloatyWaypoints>().Update(), 100); }, ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 250, -170, 125, 10), "dropdown") .AddTextToggleButtons(new string[] { "Create WP", "Purge Death Waypoints", "Toggle Floaty Waypoints", "Toggle Block Waypoints", "Toggle This Color" }, CairoFont.ButtonText().WithFontSize(10), i => { capi.Event.RegisterCallback(j => { SingleComposer.Dispose(); OnOwnPlayerDataReceived(); SingleComposer.Compose(); capi.TriggerChatMessage(".wpcfg save"); }, 100); switch (i) { case 0: CreateWaypoint(); break; case 1: capi.TriggerChatMessage(".wpcfg pdw"); break; case 2: capi.TriggerChatMessage(".wpcfg open"); break; case 3: capi.TriggerChatMessage(".wpcfg perblockwaypoints"); break; case 4: if (config.DisabledColors.Contains(intColor)) { config.DisabledColors.Remove(intColor); } else { config.DisabledColors.Add(intColor); } break; default: break; } //capi.Event.RegisterCallback(dt => capi.ModLoader.GetModSystem<FloatyWaypoints>().Update(), 100); }, new ElementBounds[] { ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 5, -200, 80, 25), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 5, -170, 80, 35), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 85, -170, 80, 35), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 165, -170, 80, 35), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 380, -170, 80, 35), }); }