Beispiel #1
0
        public static SteamLaunchableModSource Make(UInt32 HostAppID, string ModDir, VObject gameInfo = null)
        {
            VObject GameInfoObj = (VObject)(gameInfo.ContainsKey("GameInfo") ? gameInfo["GameInfo"] : null);
            VToken  GameObj     = GameInfoObj != null?GameInfoObj.ContainsKey("game") ? GameInfoObj["game"] : null : null;

            VToken IconObj = GameInfoObj != null?GameInfoObj.ContainsKey("icon") ? GameInfoObj["icon"] : null : null;

            SteamLaunchableModSource src = new SteamLaunchableModSource(HostAppID, ModDir, GameObj?.ToString())
            {
                ModIcon = IconObj?.ToString()
            };

            return(src);
        }
Beispiel #2
0
        public Entity(VObject ent)
        {
            connections = new List <Connection>();
            entity      = ent;

            classname = ent["classname"].ToString();

            if (classname == "func_instance")
            {
                IsInstance = true;

                if (InstancePath == null)
                {
                    Console.Write("Enter the location of instances: ");
                    InstancePath = Console.ReadLine();
                }
            }

            if (ent.ContainsKey("spawnflags"))
            {
                spawnFlags    = int.Parse(ent["spawnflags"].ToString());
                HasSpawnFlags = true;
            }


            if (ent.ContainsKey("origin"))
            {
                origin        = Array.ConvertAll(ent["origin"].ToString().Split(' '), float.Parse);
                IsPointEntity = true;
            }
            else if (ent.ContainsKey("solid"))
            {
                Solid         = new Solid(ent["solid"].ToVObject());
                IsPointEntity = false;
            }

            if (ent.ContainsKey("connections"))
            {
                foreach (var child in ent["connections"].ToVObject().Children())
                {
                    connections.Add(new Connection(child));
                }
            }

            if (ent.ContainsKey("targetname"))
            {
                FixupName = ent["targetname"].ToString();
            }
        }
Beispiel #3
0
        internal static void EditVDF(SDVMMSettings Settings)
        {
            try
            {
                var files = Directory.GetFiles(Path.Combine(Settings.SteamFolder, "userdata"), "localconfig.vdf", SearchOption.AllDirectories).ToArray();

                // find game settings

                int i = 0;
                for (i = 0; i < files.Length; i++)
                {
                    // read file
                    var fileText = File.ReadAllText(files[i]);
                    if (fileText == null)
                    {
                        continue;
                    }
                    VdfSerializerSettings ste = new VdfSerializerSettings();
                    ste.UsesEscapeSequences = true;

                    raw = VdfConvert.Deserialize(fileText, ste);
                    VObject data = (VObject)raw.Value.Software.Valve.Steam.Apps;


                    if (data.ContainsKey("413150"))
                    {
                        game = (VObject)raw.Value.Software.Valve.Steam.Apps["413150"];
                        break;
                    }
                }

                // check fail conditions
                if (game == null)
                {
                    MessageBox.Show(MainWindow.Translation.SDVInstalled, "error");
                    return;
                }
                if (game.ContainsKey("LaunchOptions"))
                {
                    MessageBox.Show(MainWindow.Translation.LaunchOptionExist, "error");
                    return;
                }
                if (File.Exists(Path.Combine(files[i], "localconfig-sdvmm.vdf.bak")))
                {
                    MessageBox.Show(MainWindow.Translation.LaunchOptionApplied, "error");
                    return;
                }
                // kill steam
                foreach (var process in Process.GetProcessesByName("Steam"))
                {
                    process.Kill();
                }


                // apply launch options
                if (!File.Exists(Path.Combine(Path.GetDirectoryName(files[i]), "localconfig-sdvmm.vdf.bak")))
                {
                    File.Copy(files[i], Path.Combine(Path.GetDirectoryName(files[i]), "localconfig-sdvmm.vdf.bak"));
                }
                //VValue launchOptions = new VValue(@String.Join(""," ","\\\"",MainWindow.SDVMMSettings.GameFolder.Replace("\\","\\\\"),"\\\\" ,"StardewModdingAPI.exe","\\\" ", "%command%"));

                string path          = Path.Combine(MainWindow.SDVMMSettings.GameFolder, "StardewModdingAPI.exe").Replace(@"\", @"\\");
                VValue launchOptions = new VValue($" \\\"{path}\\\" %command%");

                game.Add("LaunchOptions", launchOptions);
                File.WriteAllText(files[i], raw.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "error");
            }
        }