Ejemplo n.º 1
0
        private void ReSetLog()
        {
            // Get a IController that only contains buttons in key.
            string[]             keys = _inputKey.Split('|');
            ControllerDefinition d    = new ControllerDefinition();

            for (int i = 0; i < keys.Length; i++)
            {
                if (Global.Emulator.ControllerDefinition.BoolButtons.Contains(keys[i]))
                {
                    d.BoolButtons.Add(keys[i]);
                }
                else
                {
                    d.FloatControls.Add(keys[i]);
                }
            }
            Bk2ControllerAdapter newController = new Bk2ControllerAdapter()
            {
                Type = d
            };

            Bk2LogEntryGenerator logGenerator = new Bk2LogEntryGenerator("");

            logGenerator.SetSource(newController);
            logGenerator.GenerateLogEntry();             // Reference and create all buttons.
            // Reset all buttons in targetController (it may still have buttons that aren't being set here set true)
            Bk2LogEntryGenerator tC = new Bk2LogEntryGenerator("");

            tC.SetSource(targetController);
            targetController.SetControllersAsMnemonic(tC.EmptyEntry);
            for (int i = 0; i < Length; i++)
            {
                controller.SetControllersAsMnemonic(_log[i]);
                LatchFromSourceButtons(targetController, controller);
                newController.LatchFromSource(targetController);
                _log[i] = logGenerator.GenerateLogEntry();
            }

            controller = newController;
        }
Ejemplo n.º 2
0
        public MovieZone(IMovie movie, int start, int length, string key = "")
        {
            Bk2LogEntryGenerator lg = Global.MovieSession.LogGeneratorInstance() as Bk2LogEntryGenerator;

            lg.SetSource(Global.MovieSession.MovieControllerAdapter);
            targetController      = new Bk2ControllerAdapter();
            targetController.Type = Global.Emulator.ControllerDefinition;
            targetController.LatchFromSource(targetController);             // Reference and create all buttons

            if (key == "")
            {
                key = lg.GenerateLogKey();
            }
            key = key.Replace("LogKey:", "").Replace("#", "");
            key = key.Substring(0, key.Length - 1);

            _inputKey = key;
            Length    = length;
            _log      = new string[length];

            // Get a IController that only contains buttons in key.
            string[]             keys = key.Split('|');
            ControllerDefinition d    = new ControllerDefinition();

            for (int i = 0; i < keys.Length; i++)
            {
                if (Global.Emulator.ControllerDefinition.BoolButtons.Contains(keys[i]))
                {
                    d.BoolButtons.Add(keys[i]);
                }
                else
                {
                    d.FloatControls.Add(keys[i]);
                }
            }

            controller = new Bk2ControllerAdapter()
            {
                Type = d
            };
            Bk2LogEntryGenerator logGenerator = new Bk2LogEntryGenerator("");

            logGenerator.SetSource(controller);
            logGenerator.GenerateLogEntry();             // Reference and create all buttons.

            string movieKey = logGenerator.GenerateLogKey().Replace("LogKey:", "").Replace("#", "");

            movieKey = movieKey.Substring(0, movieKey.Length - 1);
            if (key == movieKey)
            {
                for (int i = 0; i < length; i++)
                {
                    _log[i] = movie.GetInputLogEntry(i + start);
                }
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    controller.LatchFromSource(movie.GetInputState(i + start));
                    _log[i] = logGenerator.GenerateLogEntry();
                }
            }
        }
Ejemplo n.º 3
0
        public MovieZone(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return;
            }

            string[] readText = File.ReadAllLines(fileName);
            // If the LogKey contains buttons/controls not accepted by the emulator,
            //	tell the user and display the macro's controller name and player count
            _inputKey = readText[0];
            Bk2LogEntryGenerator lg = Global.MovieSession.LogGeneratorInstance() as Bk2LogEntryGenerator;

            lg.SetSource(Global.MovieSession.MovieControllerAdapter);
            string key = lg.GenerateLogKey();

            key = key.Replace("LogKey:", "").Replace("#", "");
            key = key.Substring(0, key.Length - 1);
            string[] emuKeys   = key.Split('|');
            string[] macroKeys = _inputKey.Split('|');
            for (int i = 0; i < macroKeys.Length; i++)
            {
                if (!emuKeys.Contains(macroKeys[i]))
                {
                    System.Windows.Forms.MessageBox.Show("The selected macro is not compatible with the current emulator core." +
                                                         "\nMacro controller: " + readText[1] + "\nMacro player count: " + readText[2], "Error");
                    return;
                }
            }

            // Settings
            string[] settings = readText[3].Split(',');
            Overlay = Convert.ToBoolean(settings[0]);
            Replace = Convert.ToBoolean(settings[1]);

            _log = new string[readText.Length - 4];
            readText.ToList().CopyTo(4, _log, 0, _log.Length);
            Length = _log.Length;
            Start  = 0;

            Name = Path.GetFileNameWithoutExtension(fileName);

            // Adapters
            targetController      = new Bk2ControllerAdapter();
            targetController.Type = Global.Emulator.ControllerDefinition;
            targetController.LatchFromSource(targetController);             // Reference and create all buttons
            string[]             keys = _inputKey.Split('|');
            ControllerDefinition d    = new ControllerDefinition();

            for (int i = 0; i < keys.Length; i++)
            {
                if (Global.Emulator.ControllerDefinition.BoolButtons.Contains(keys[i]))
                {
                    d.BoolButtons.Add(keys[i]);
                }
                else
                {
                    d.FloatControls.Add(keys[i]);
                }
            }
            controller = new Bk2ControllerAdapter()
            {
                Type = d
            };
        }
Ejemplo n.º 4
0
        public MovieZone(IMovie movie, IEmulator emulator, ToolManager tools, int start, int length, string key = "")
        {
            _emulator = emulator;
            _tools    = tools;
            var lg = (Bk2LogEntryGenerator)movie.LogGeneratorInstance();

            lg.SetSource(Global.MovieSession.MovieControllerAdapter);
            _targetController = new Bk2ControllerAdapter {
                Definition = _emulator.ControllerDefinition
            };
            _targetController.LatchFromSource(_targetController);             // Reference and create all buttons

            if (key == "")
            {
                key = lg.GenerateLogKey();
            }

            key = key.Replace("LogKey:", "").Replace("#", "");
            key = key.Substring(0, key.Length - 1);

            _inputKey = key;
            Length    = length;
            _log      = new string[length];

            // Get a IController that only contains buttons in key.
            string[] keys = key.Split('|');
            var      d    = new ControllerDefinition();

            foreach (var k in keys)
            {
                if (_emulator.ControllerDefinition.BoolButtons.Contains(k))
                {
                    d.BoolButtons.Add(k);
                }
                else
                {
                    d.FloatControls.Add(k);
                }
            }

            _controller = new Bk2ControllerAdapter {
                Definition = d
            };
            var logGenerator = new Bk2LogEntryGenerator("");

            logGenerator.SetSource(_controller);
            logGenerator.GenerateLogEntry();             // Reference and create all buttons.

            string movieKey = logGenerator.GenerateLogKey().Replace("LogKey:", "").Replace("#", "");

            movieKey = movieKey.Substring(0, movieKey.Length - 1);
            if (key == movieKey)
            {
                for (int i = 0; i < length; i++)
                {
                    _log[i] = movie.GetInputLogEntry(i + start);
                }
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    _controller.LatchFromSource(movie.GetInputState(i + start));
                    _log[i] = logGenerator.GenerateLogEntry();
                }
            }
        }