Esempio n. 1
0
        public override void StartClientSide(ICoreClientAPI api)
        {
            renderer = new PlacementRenderer(api);
            api.Event.RegisterRenderer(renderer, EnumRenderStage.Opaque);
            api.RegisterCommand("pconfig", "Config Placement Preview System", "[enabled|textured]", (id, args) =>
            {
                WaypointUtilConfig config = api.ModLoader.GetModSystem <WaypointUtilSystem>().Config;
                string arg   = args.PopWord();
                bool?enabled = args.PopBool();
                switch (arg)
                {
                case "enabled":
                    config.PRShow = enabled ?? !config.PRShow;
                    api.ShowChatMessage("Block preview set to " + config.PRShow);
                    break;

                case "tinted":
                    config.PRTint = enabled ?? !config.PRTint;
                    api.ShowChatMessage("Block preview tinting set to " + config.PRTint);
                    break;

                default:
                    break;
                }
                api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig();
            });
            api.Event.LevelFinalize += () => api.Shader.ReloadShaders();
        }
Esempio n. 2
0
        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 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();
        }