Exemplo n.º 1
0
        public bool ConvertTable(VisualPinballTable VP)
        {
            //Get existing table inclination...

            BIFFFile F = VP.GetGameDataFile();

            if (F == null)
            {
                return(false);
            }

            byte[] buf = F.GetChunk("INCL");
            if (buf != null)
            {
                float f = BitConverter.ToSingle(buf, 0);
                Log.Add("Table Incline: " + f);
                if (Math.Abs(f) < 0.1)
                {
                    Log.Add("Table is ALREADY Full-Screen!");
                    return(false);
                }
            }

            buf = BitConverter.GetBytes((float)270);
            F.SetChunk("ROTA", buf);

            buf = BitConverter.GetBytes((float)11);
            F.SetChunk("INCL", buf);

            buf = BitConverter.GetBytes((float)50);
            F.SetChunk("FOVX", buf);

            buf = BitConverter.GetBytes((float)70);
            F.SetChunk("LAYB", buf);

            buf = BitConverter.GetBytes((float)1.3);
            F.SetChunk("SCLX", buf);

            buf = BitConverter.GetBytes((float)1.9);
            F.SetChunk("SCLY", buf);

            buf = BitConverter.GetBytes((float)-450);
            F.SetChunk("OFFX", buf);

            buf = BitConverter.GetBytes((float)230);
            F.SetChunk("OFFY", buf);

            Log.Add("Set Rotation, Incline and FOV");

            float Width  = BitConverter.ToSingle(F.GetChunk("RGHT"), 0);
            float Height = BitConverter.ToSingle(F.GetChunk("BOTM"), 0);

            Log.Add("Table Width / Height = " + Width + " x " + Height);

            VP.WriteFile(F.Buffer, "GameData");

            //OK - find me a GO.

            GameItemCollection GIC = VP.GetGameItems();
            BIFFFile           B   = GIC.GameItems["ScoreText"].GetFile();

            byte[] bxa = B.GetChunk("VER1");
            float  V1A = BitConverter.ToSingle(bxa, 0);
            float  V2A = BitConverter.ToSingle(bxa, 4);

            byte[] bxb = B.GetChunk("VER2");
            float  V1B = BitConverter.ToSingle(bxb, 0);
            float  V2B = BitConverter.ToSingle(bxb, 4);

            B.SetChunk("VER2", bxa);

            Log.Add("Feature Not Complete");

            return(true);
        }
Exemplo n.º 2
0
        private void MainThread()
        {
            int indx = 0;

            object[] args   = new object[2];
            object[] logger = new object[1];

            foreach (string S in Settings.FilesToProcess)
            {
                VisualPinballTable VPT = new VisualPinballTable();
                VPT.Load(S);

                args[0] = "Loaded " + VPT.Name;
                args[1] = indx;
                Invoke(new UpdateProgress(Progress), args);

                Toolbox T = new Toolbox(VPT);

                if (Settings.B2S.Checked == true)
                {
                    T.EnableB2S();
                }

                if (Settings.DMDAction == MainForm.DMDAct.all)
                {
                    T.ClearDMDSettings();
                }

                if (Settings.DMDAction == MainForm.DMDAct.rotation)
                {
                    T.ClearDMDRotation();
                }

                if (Settings.ScriptClean.Checked == true)
                {
                    T.ControllerExit();
                }

                if (Settings.FS.Checked == true)
                {
                    FullScreenConversion FSC = new FullScreenConversion();
                    if (FSC.ConvertTable(VPT) == true)
                    {
                    }
                    logger[0] = "Full Screen Conversion on " + VPT.Name;
                    Invoke(new UpdateLog(Log), logger);

                    foreach (string Sq in FSC.Log)
                    {
                        logger[0] = "  " + Sq;
                        Invoke(new UpdateLog(Log), logger);
                    }
                }

                foreach (string Sx in T.Log)
                {
                    logger[0] = Sx + " on " + VPT.Name;
                    Invoke(new UpdateLog(Log), logger);
                }


                if (T.ChangesMade == true)
                {
                    string bf = S.Replace(".vpt", ".bak");
                    if (!File.Exists(bf))
                    {
                        File.Copy(S, bf);
                    }
                    bf = S.Replace(".vpt", "_new.vpt");
                    VPT.Save(bf);
                    File.Delete(S);
                    File.Move(bf, S);
                }
                indx++;
            }

            args[0] = "Complete";
            args[1] = indx;
            Invoke(new UpdateProgress(Progress), args);
        }
Exemplo n.º 3
0
 public Toolbox(VisualPinballTable Tbl)
 {
     VP = Tbl;
 }
Exemplo n.º 4
0
        public void Run(string[] args)
        {
            bool   help    = false;
            string infile  = "";
            string outfile = "";
            string cabfile = "";

            bool enableb2s     = false;
            bool hidedmd       = false;
            bool cleardmd      = false;
            bool showdmd       = false;
            bool cleanexit     = false;
            bool cleanup       = false;
            bool verbose       = false;
            bool enableplunger = true;

            bool GIEdit = false;

            string DisplayComponents = "nr";
            Dictionary <string, string> ControllerParams = new Dictionary <string, string>();

            Dictionary <string, string> SetComponents = new Dictionary <string, string>();

            OptionSet p = new OptionSet()
                          .Add("v|verbose", delegate(string v) { verbose = true; })
                          .Add("enb2s", delegate(string v) { enableb2s = true; })
                          .Add("hidedmd", delegate(string v) { hidedmd = true; })
                          .Add("showdmd", delegate(string v) { showdmd = true; })
                          .Add("cleardmd", delegate(string v) { cleardmd = true; })
                          .Add("cleanexit", delegate(string v) { cleanexit = true; })
                          .Add("cleanup", delegate(string v) { cleardmd = true; cleanexit = true; })
                          .Add("show", delegate(string v) { DisplayComponents = v; })
                          .Add("h|?|help", delegate(string v) { help = v != null; })
                          .Add("i|in=", delegate(string v) { infile = v; })
                          .Add("c|cab=", delegate(string v) { cabfile = v; })
                          .Add("o|out=", delegate(string v) { outfile = v; })
                          .Add("plunger", delegate(string v) { enableplunger = true; })
                          .Add("setname=", delegate(string v) { SetComponents.Add("name", v); })
                          .Add("setrom=", delegate(string v) { SetComponents.Add("rom", v); });

            if (help == true)
            {
                ShowHelp();
                return;
            }

            List <string> extra = p.Parse(args);

            if (infile == "")
            {
                Console.WriteLine("You must include an input file name (-i <filename>).");
                return;
            }

            bool FileChanges = false;

            VP = new VisualPinballTable();
            VP.Load(infile);

            TBx = new Toolbox(VP);

            if (verbose == true)
            {
                Console.WriteLine("Opened VP Table '" + VP.FullName + "'");
            }

            //Display Information
            foreach (char S in DisplayComponents)
            {
                if (S == 'n')
                {
                    Console.WriteLine("Name: " + VP.Name);
                }
                if (S == 'r')
                {
                    Console.WriteLine("ROM: " + VP.ROM);
                }
            }

            //Handle all of the SETTINGS
            foreach (KeyValuePair <string, string> KV in SetComponents)
            {
                if (KV.Key == "name")
                {
                    TBx.RenameTable(KV.Value);
                }
                if (KV.Key == "rom")
                {
                    TBx.ChangeRom(KV.Value);
                }
            }

            if ((cleardmd == true) || (cleanup == true))
            {
                TBx.ClearDMDSettings();
            }

            if ((cleanexit == true) || (cleanup == true))
            {
                TBx.ControllerExit();
            }

            if (hidedmd == true)
            {
                TBx.HideDMD();
            }

            if (showdmd == true)
            {
                TBx.ShowDMD();
            }

            if (enableb2s == true)
            {
                TBx.EnableB2S();
            }

            if (enableplunger == true)
            {
                TBx.EnableMechanicalPlunger();
            }

            foreach (string S in TBx.Log)
            {
                Console.WriteLine(S);
            }

            if (TBx.ChangesMade == true)
            {
                if (outfile != "")
                {
                    VP.Save(outfile);
                }
                else
                {
                    if (!File.Exists(infile + ".bak"))
                    {
                        File.Copy(infile, infile + ".bak");
                    }
                    VP.Save(infile);
                }
            }
            VP.Close();

            //string VV = Console.ReadLine();
        }