Example #1
0
        private static void BeginSelectingMod()
        {
            var isInitialized = false;

            GUILayout.BeginVertical(UiStyle.Style[0]);
            for (var i = 0; i < Ui.Functions.Count; i++)
            {
                if (i == 0)
                {
                    GUILayout.BeginHorizontal();
                }
                if (i == 0 || i == 3)
                {
                    GUILayout.BeginVertical();
                }

                if (!isInitialized)
                {
                    if (GUILayout.Button("I'm not a cheater!", UiStyle.Style[5]))
                    {
                        Main.SelectedMod      = 0;
                        Progress.CurrentState = Progress.States.EndSelectingMod;
                    }
                    isInitialized = true;
                }

                var isToggleAble = Directory.Exists(PathMgr.Raw(((Mods[])Enum.GetValues(typeof(Mods)))[i + 1].ToString().ToLower().Replace("_", "-")));
                if (GUILayout.Button(Ui.Functions[i], UiStyle.Style[isToggleAble ? 5 : 6]))
                {
                    if (!isToggleAble)
                    {
                        break;
                    }

                    Main.SelectedMod      = ((Mods[])Enum.GetValues(typeof(Mods)))[i + 1];
                    Progress.CurrentState = Progress.States.EndSelectingMod;
                }

                if (i == 2 || i == 6)
                {
                    GUILayout.EndVertical();
                }
                if (i == 6)
                {
                    GUILayout.EndVertical();
                }
            }
            GUILayout.EndVertical();
            GUILayout.BeginHorizontal(UiStyle.Style[0]);
            if (GUILayout.Button("Replace Skin", UiStyle.Style[Main.ReplaceSkin ? 7 : 8]))
            {
                Main.ReplaceSkin = !Main.ReplaceSkin;
                File.WriteAllText(PathMgr.WorkingDirectory("prefs"), Main.ReplaceSkin ? "1" : "0");
            }
            GUILayout.EndHorizontal();
        }
Example #2
0
        public static byte[] Initialize(TextAsset textAsset, string fileName)
        {
            if (Main.SelectedMod == 0)
            {
                return(textAsset.bytes);
            }

            if (_keys == null)
            {
                _keys = new List <string>();
            }

            AddKey("aircraft_template");
            AddKey("enemy_data_skill");
            AddKey("enemy_data_statistics");

            if (Main.ReplaceSkin)
            {
                AddKey("ship_data_statistics");
            }
            if (Main.SelectedMod.ToString().ToLower().Contains("damage"))
            {
                AddKey("weapon_property");
            }

            foreach (var key in _keys)
            {
                if (!fileName.Contains(key))
                {
                    continue;
                }

                foreach (var filePath in Directory.GetFiles(PathMgr.Raw(Main.SelectedMod.ToString().ToLower().Replace("_", "-")), "*.*", SearchOption.AllDirectories))
                {
                    if (!filePath.Contains(key))
                    {
                        continue;
                    }

                    var bytes = File.ReadAllBytes(filePath);
                    return(bytes);
                }
            }

            return(textAsset.bytes);
        }