summaryrefslogtreecommitdiff
path: root/Config.cs
blob: fb3d0a51b0115cb6818d380ff1c83db5ca465324 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#define SIMPLE_KEYBOARD_LAYER

using SharpPluginLoader.Core.Configuration;
using SharpPluginLoader.Core.IO;

namespace NewCamera
{
    internal class Config : IConfig
    {
        public String Name => "NewCamera";
        public String Version => "4.0";

        public const float DEFAULT_FOV = 60.0f;
        public const float DEFAULT_NEAR_CLIP = 16.0f;

        public struct Settings
        {
            public const float DEFAULT_SPEED = 5.35f;
            public const float DEFAULT_SPEED_MODIFIER = 0.40f;
            public const float DEFAULT_SENSITIVITY = 0.0425f;
            public const float DEFAULT_ZOOM_SPEED = 0.02f;
            public const float DEFAULT_PITCH_LIMIT = -1.0f;
            public const float MAX_PITCH_LIMIT = 89.95f;
            public const int DEFAULT_DEADZONE = 4750;
            public const float DEFAULT_ALT_NEAR_CLIP = 0.3f;

            public Settings()
            {
                Speed = DEFAULT_SPEED;
                SpeedModifier = DEFAULT_SPEED_MODIFIER;
                Sensitivity = DEFAULT_SENSITIVITY;
                ZoomSpeed = DEFAULT_ZOOM_SPEED;
                PitchLimit = DEFAULT_PITCH_LIMIT;
                StickDeadzone = DEFAULT_DEADZONE;
                AlternateNearClip = DEFAULT_ALT_NEAR_CLIP;
            }

            public float Speed { get; set; }
            public float SpeedModifier { get; set; }
            public float Sensitivity { get; set; }
            public float ZoomSpeed { get; set; }
            public float PitchLimit { get; set; }
            public int StickDeadzone { get; set; }
            public float AlternateNearClip { get; set; }

            public struct Binds
            {
                public Binds()
                {
                    EnableCombo = true;
                    FreeCameraCombo = "RStick,LT";
                    DisableComboButton1UnlessButton2Held = false;
#if SIMPLE_KEYBOARD_LAYER
                    EnableMouse = true;
                    MouseSensitivity = 0.0225f;
                    EnableKeyboard = true;
                    KeyboardLookSensitivity = 19750;
#endif
                }

                public bool EnableCombo { get; set; }
                public String FreeCameraCombo { get; set; }
                public bool DisableComboButton1UnlessButton2Held { get; set; }
#if SIMPLE_KEYBOARD_LAYER
                public bool EnableMouse { get; set; }
                public float MouseSensitivity { get; set; }
                public bool EnableKeyboard { get; set; }
                public int KeyboardLookSensitivity { get; set; }
#endif
            }
        }

        public struct Preset
        {
            public float FieldOfView { get; set; }
            public float Roll { get; set; }
            public float Forward { get; set; }
            public float Right { get; set; }
            public float Up { get; set; }
            public bool DisableFading { get; set; }
        }

        public static Preset DefaultPreset = new Preset()
        {
            FieldOfView = DEFAULT_FOV,
            Roll = 0.0f,
            Forward = 0.0f,
            Right = 0.0f,
            Up = 0.0f,
            DisableFading = false
        };

        public struct Position
        {
            public float FieldOfView { get; set; }
            public float Roll { get; set; }
            public float PosX { get; set; }
            public float PosY { get; set; }
            public float PosZ { get; set; }
            public float TargetX { get; set; }
            public float TargetY { get; set; }
            public float TargetZ { get; set; }
        }

        private static Dictionary<string, Button> buttonMap = new Dictionary<string, Button>
        {
            { "r1", Button.R1 }, { "rb", Button.R1 },
            { "r2", Button.R2 }, { "rt", Button.R2 },
            { "r3", Button.R3 }, { "rstick", Button.R3 },
            { "l1", Button.L1 }, { "lb", Button.L1 },
            { "l2", Button.L2 }, { "lt", Button.L2 },
            { "l3", Button.L3 }, { "lstick", Button.L3 },
            { "a", Button.Cross }, { "cross", Button.Cross },
            { "b", Button.Circle }, { "circle", Button.Circle },
            { "x", Button.Square }, { "square", Button.Square },
            { "y", Button.Triangle }, { "triangle", Button.Triangle },
            { "start", Button.Options }, { "options", Button.Options },
            { "select", Button.Share }, { "share", Button.Share },
            { "up", Button.Up },
            { "down", Button.Down },
            { "left", Button.Left },
            { "right", Button.Right }
        };

        public static Button[]? ParseCombo(String comboString)
        {
            string[] buttonStrings = comboString.Split(",");
            if (buttonStrings.Length == 2)
            {
                string b1 = buttonStrings[0].ToLower();
                string b2 = buttonStrings[1].ToLower();
                if (buttonMap.ContainsKey(b1) && buttonMap.ContainsKey(b2))
                {
                    return [ buttonMap[b1], buttonMap[b2] ];
                }
            }
            return null;
        }

        public bool DisableMod { get; set; } = false;
        public bool TuningToolInterop { get; set; } = true;
        public bool OverrideViewMode { get; set; } = false;

        public Settings Camera { get; set; } = new Settings();
        public Settings.Binds Binds { get; set; } = new Settings.Binds();

        public bool PerspectiveCameraEnabled { get; set; } = false;
        public Dictionary<String, Preset> Presets { get; set; } = new Dictionary<String, Preset>();
        public String Selected { get; set; } = "";

        public Dictionary<String, Position> Positions { get; set; } = new Dictionary<String, Position>();
    }
}