示例#1
0
        public static void StreamLoadKeybinds(out KeybindConfig keybinds)
        {
            _reader = new StreamReader(KeybindPath);
            var json = _reader.ReadToEnd();

            _reader.Dispose();
            keybinds = JsonConvert.DeserializeObject <KeybindConfig>(json);
        }
示例#2
0
        public static void SaveKeybinds(KeybindConfig config)
        {
            var json = JsonConvert.SerializeObject(config);

            if (!KeybindsExist())
            {
                File.Create(KeybindPath).Dispose();
            }

            File.WriteAllText(KeybindPath, json);
        }
示例#3
0
        public static void CreateKeybinds(out KeybindConfig keybinds)
        {
            keybinds = new KeybindConfig();
            keybinds.AddBind("main", KeyCode.F1);
            keybinds.AddBind("visuals", KeyCode.F2);
            keybinds.AddBind("keybinds", KeyCode.F4);
            keybinds.AddBind("aim", KeyCode.F3);
            keybinds.AddBind("changetarget", KeyCode.Backslash);
            keybinds.AddBind("toggleaimbot", KeyCode.F5);

            SaveKeybinds(keybinds);// --------------------// --------------------
        }
示例#4
0
        public static void StreamSaveKeybinds(KeybindConfig config)
        {
            var json = JsonConvert.SerializeObject(config);

            _writer = new StreamWriter(KeybindPath);

            if (!KeybindsExist())
            {
                File.Create(KeybindPath).Dispose();
            }

            _writer.Write(json);
            _writer.Dispose();
        }
示例#5
0
 public void SetKeybind(KeybindConfig newConfig)
 {
     currentConfig = newConfig;
     SaveConfig();
 }
        /// <summary>
        /// Creates a keybind menu item.
        /// </summary>
        /// <param name="content">The <c>ContentArea</c> to put the keybind item in.</param>
        /// <param name="name">The name of the keybind game object.</param>
        /// <param name="action">The <c>PlayerAction</c> to associate with this keybind.</param>
        /// <param name="config">The configuration options for the keybind item.</param>
        /// <param name="mappableKey">The <c>MappablKey</c> component on the created keybind item.</param>
        /// <returns></returns>
        public static ContentArea AddKeybind(
            this ContentArea content,
            string name,
            PlayerAction action,
            KeybindConfig config,
            out MappableKey mappableKey
            )
        {
            var style = config.Style ?? KeybindStyle.VanillaStyle;
            // Keybind object
            var keybind = new GameObject($"{name}");

            GameObject.DontDestroyOnLoad(keybind);
            keybind.transform.SetParent(content.ContentObject.transform, false);
            // CanvasRenderer
            keybind.AddComponent <CanvasRenderer>();
            // RectTransform
            var keybindRt = keybind.AddComponent <RectTransform>();

            new RelVector2(new Vector2(650f, 100f)).GetBaseTransformData().Apply(keybindRt);
            content.Layout.ModifyNext(keybindRt);
            // MappableKey
            var mapKey = (Patch.MappableKey)keybind.AddComponent <MappableKey>();

            mapKey.InitCustomActions(action.Owner, action);
            var mkbutton = (Patch.MenuSelectable)(MenuSelectable) mapKey;

            mkbutton.cancelAction       = (CancelAction)Patch.CancelAction.CustomCancelAction;
            mkbutton.customCancelAction = _ =>
            {
                mapKey.AbortRebind();
                config.CancelAction?.Invoke(mapKey);
            };
            content.NavGraph.AddNavigationNode(mapKey);

            // Text object
            var text = new GameObject("Text");

            GameObject.DontDestroyOnLoad(text);
            text.transform.SetParent(keybind.transform, false);
            // CanvasRenderer
            text.AddComponent <CanvasRenderer>();
            // RectTransform
            var textRt = text.AddComponent <RectTransform>();

            textRt.sizeDelta        = new Vector2(0f, 0f);
            textRt.anchorMin        = new Vector2(0f, 0f);
            textRt.anchorMax        = new Vector2(1f, 1f);
            textRt.anchoredPosition = new Vector2(0f, 0f);
            textRt.pivot            = new Vector2(0.5f, 0.5f);
            // Text
            var labelText = text.AddComponent <Text>();

            labelText.font               = MenuResources.TrajanBold;
            labelText.fontSize           = style.LabelTextSize;
            labelText.resizeTextMaxSize  = style.LabelTextSize;
            labelText.alignment          = TextAnchor.MiddleLeft;
            labelText.text               = config.Label;
            labelText.supportRichText    = true;
            labelText.verticalOverflow   = VerticalWrapMode.Overflow;
            labelText.horizontalOverflow = HorizontalWrapMode.Overflow;
            // FixVerticalAlign
            text.AddComponent <FixVerticalAlign>();

            // LeftCursor object
            var cursorL = new GameObject("CursorLeft");

            GameObject.DontDestroyOnLoad(cursorL);
            cursorL.transform.SetParent(keybind.transform, false);
            // CanvasRenderer
            cursorL.AddComponent <CanvasRenderer>();
            // RectTransform
            var cursorLRt = cursorL.AddComponent <RectTransform>();

            cursorLRt.sizeDelta        = new Vector2(154f, 112f);
            cursorLRt.pivot            = new Vector2(0.5f, 0.5f);
            cursorLRt.anchorMin        = new Vector2(0f, 0.5f);
            cursorLRt.anchorMax        = new Vector2(0f, 0.5f);
            cursorLRt.anchoredPosition = new Vector2(-52f, 0f);
            cursorLRt.localScale       = new Vector3(0.4f, 0.4f, 0.4f);
            // Animator
            var cursorLAnimator = cursorL.AddComponent <Animator>();

            cursorLAnimator.runtimeAnimatorController = MenuResources.MenuCursorAnimator;
            cursorLAnimator.updateMode      = AnimatorUpdateMode.UnscaledTime;
            cursorLAnimator.applyRootMotion = false;
            // Image
            cursorL.AddComponent <Image>();
            // Post Component Config
            mapKey.leftCursor = cursorLAnimator;

            // RightCursor object
            var cursorR = new GameObject("CursorRight");

            GameObject.DontDestroyOnLoad(cursorR);
            cursorR.transform.SetParent(keybind.transform, false);
            // CanvasRenderer
            cursorR.AddComponent <CanvasRenderer>();
            // RectTransform
            var cursorRRt = cursorR.AddComponent <RectTransform>();

            cursorRRt.sizeDelta        = new Vector2(154f, 112f);
            cursorRRt.pivot            = new Vector2(0.5f, 0.5f);
            cursorRRt.anchorMin        = new Vector2(1f, 0.5f);
            cursorRRt.anchorMax        = new Vector2(1f, 0.5f);
            cursorRRt.anchoredPosition = new Vector2(52f, 0f);
            cursorRRt.localScale       = new Vector3(-0.4f, 0.4f, 0.4f);
            // Animator
            var cursorRAnimator = cursorR.AddComponent <Animator>();

            cursorRAnimator.runtimeAnimatorController = MenuResources.MenuCursorAnimator;
            cursorRAnimator.updateMode      = AnimatorUpdateMode.UnscaledTime;
            cursorRAnimator.applyRootMotion = false;
            // Image
            cursorR.AddComponent <Image>();
            // Post Component Config
            mapKey.rightCursor = cursorRAnimator;

            // Keymap object
            var keymap = new GameObject("Keymap");

            GameObject.DontDestroyOnLoad(keymap);
            keymap.transform.SetParent(keybind.transform, false);
            // CanvasRenderer
            keymap.AddComponent <CanvasRenderer>();
            // RectTransform
            var keymapRt = keymap.AddComponent <RectTransform>();

            keymapRt.sizeDelta        = new Vector2(145.8f, 82.4f);
            keymapRt.anchorMin        = new Vector2(1f, 0.5f);
            keymapRt.anchorMax        = new Vector2(1f, 0.5f);
            keymapRt.anchoredPosition = new Vector2(0f, 0f);
            keymapRt.pivot            = new Vector2(1f, 0.5f);
            // Image
            var keymapImg = keymap.AddComponent <Image>();

            keymapImg.preserveAspect = true;
            mapKey.keymapSprite      = keymapImg;

            // Keymap Text object
            var keymapText = new GameObject("Text");

            GameObject.DontDestroyOnLoad(keymapText);
            keymapText.transform.SetParent(keymap.transform, false);
            // CanvasRenderer
            keymapText.AddComponent <CanvasRenderer>();
            // RectTransform
            var keymapTextRt = keymapText.AddComponent <RectTransform>();

            keymapTextRt.sizeDelta        = new Vector2(65f, 60f);
            keymapTextRt.anchorMin        = new Vector2(0.5f, 0.5f);
            keymapTextRt.anchorMin        = new Vector2(0.5f, 0.5f);
            keymapTextRt.anchoredPosition = new Vector2(32f, 0f);
            keymapTextRt.pivot            = new Vector2(0.5f, 0.5f);
            // Text
            var keymapTextText = keymapText.AddComponent <Text>();

            keymapTextText.font = MenuResources.Perpetua;
            mapKey.keymapText   = keymapTextText;
            // FixVerticalAlign
            keymapText.AddComponent <FixVerticalAlign>().labelFixType = FixVerticalAlign.LabelFixType.KeyMap;

            mapKey.GetBinding();
            mapKey.ShowCurrentBinding();
            mappableKey = mapKey;
            return(content);
        }
 /// <summary>
 /// Creates a keybind menu item.
 /// </summary>
 /// <param name="content">The <c>ContentArea</c> to put the keybind item in.</param>
 /// <param name="name">The name of the keybind game object.</param>
 /// <param name="action">The <c>PlayerAction</c> to associate with this keybind.</param>
 /// <param name="config">The configuration options for the keybind item.</param>
 /// <returns></returns>
 public static ContentArea AddKeybind(
     this ContentArea content,
     string name,
     PlayerAction action,
     KeybindConfig config
     ) => content.AddKeybind(name, action, config, out _);
示例#8
0
        public static void LoadKeybinds(out KeybindConfig keybinds)
        {
            var raw = File.ReadAllText(KeybindPath);

            keybinds = JsonConvert.DeserializeObject <KeybindConfig>(raw);
        }
示例#9
0
        public static bool CheckIfFirstTime()
        {
            var result = File.Exists(InfoPath);

            if (result)
            {
                string str;

                using (var reader = new StreamReader(InfoPath))
                {
                    str = reader.ReadToEnd();
                    reader.Close();
                }

                if (str != WaveMaker.Version)
                {
                    using (var writer = new StreamWriter(KeybindPath))
                    {
                        var keybinds = new KeybindConfig();
                        keybinds.AddBind("main", KeyCode.F1);
                        keybinds.AddBind("visuals", KeyCode.F2);
                        keybinds.AddBind("aim", KeyCode.F3);
                        keybinds.AddBind("keybinds", KeyCode.F4);
                        keybinds.AddBind("changetarget", KeyCode.Backslash);
                        keybinds.AddBind("toggleaimbot", KeyCode.F5);


                        WaveMaker.Keybinds = keybinds;
                        var json = JsonConvert.SerializeObject(keybinds);
                        writer.WriteLine(json);
                        writer.Flush();
                        writer.Dispose();
                    }

                    using (var writer = new StreamWriter(SettingsPath))
                    {
                        var settings = new Settings();

                        settings.ColorList.Add("enemyplayer", new TsuColor(new Color(255, 45, 45)));
                        settings.ColorList.Add("friendlyplayer", new TsuColor(new Color(150, 255, 255)));
                        settings.ColorList.Add("zombie", new TsuColor(new Color(50, 150, 0)));
                        settings.ColorList.Add("item", new TsuColor(new Color(230, 230, 40)));
                        settings.ColorList.Add("interactable", new TsuColor(new Color(255, 180, 0)));
                        settings.ColorList.Add("vehicle", new TsuColor(new Color(255, 0, 230)));
                        settings.ColorList.Add("friendlyplayerbox", new TsuColor(new Color(150, 255, 255)));
                        settings.ColorList.Add("enemyplayerbox", new TsuColor(new Color(255, 45, 45)));
                        settings.ColorList.Add("zombiebox", new TsuColor(new Color(50, 150, 0)));

                        WaveMaker.Settings = settings;
                        var json = JsonConvert.SerializeObject(settings);
                        writer.WriteLine(json);
                        writer.Flush();
                        writer.Dispose();
                    }

                    using (var writer = new StreamWriter(FriendsPath))
                    {
                        var friends = new FriendsList();

                        WaveMaker.Friends = friends;
                        var json = JsonConvert.SerializeObject(friends);
                        writer.WriteLine(json);
                        writer.Flush();
                        writer.Dispose();
                    }

                    using (var writer = new StreamWriter(InfoPath))
                    {
                        writer.WriteLine(WaveMaker.Version);
                        writer.Flush();
                        writer.Dispose();
                    }
                }
            }
            else
            {
                File.WriteAllText(InfoPath, WaveMaker.Version);
            }

            return(!result);
        }