Exemplo n.º 1
0
        public void SyncControls(IEmulator emulator, IMovieSession session, Config config)
        {
            var def = emulator.ControllerDefinition;

            ActiveController   = BindToDefinition(def, config.AllTrollers, config.AllTrollersAnalog);
            AutoFireController = BindToDefinitionAF(emulator, config.AllTrollersAutoFire, config.AutofireOn, config.AutofireOff);

            // allow propagating controls that are in the current controller definition but not in the prebaked one
            // these two lines shouldn't be required anymore under the new system?
            ActiveController.ForceType(new ControllerDefinition(def));
            ClickyVirtualPadController.Definition = new ControllerDefinition(def);

            // Wire up input chain
            ControllerInputCoalescer.Definition = ActiveController.Definition;

            UdLRControllerAdapter.Source    = ActiveController.Or(AutoFireController);
            UdLRControllerAdapter.AllowUdlr = config.AllowUdlr;

            StickyXorAdapter.Source         = UdLRControllerAdapter;
            AutofireStickyXorAdapter.Source = StickyXorAdapter;

            session.MovieIn         = AutofireStickyXorAdapter;
            session.StickySource    = AutofireStickyXorAdapter;
            ControllerOutput.Source = session.MovieOut;
        }
Exemplo n.º 2
0
        public PlayMovie(
            IMainFormForTools mainForm,
            Config config,
            GameInfo game,
            IEmulator emulator,
            IMovieSession movieSession)
        {
            _mainForm     = mainForm;
            _config       = config;
            _game         = game;
            _emulator     = emulator;
            _movieSession = movieSession;
            InitializeComponent();
            Icon = Properties.Resources.TAStudioIcon;
            BrowseMovies.Image             = Properties.Resources.OpenFile;
            Scan.Image                     = Properties.Resources.Scan;
            editToolStripMenuItem.Image    = Properties.Resources.Cut;
            MovieView.RetrieveVirtualItem += MovieView_QueryItemText;
            MovieView.VirtualMode          = true;
            _sortReverse                   = false;
            _sortedCol                     = "";

            _sortDetailsReverse = false;
            _sortedDetailsCol   = "";
        }
Exemplo n.º 3
0
        public RecordMovie(
            MainForm mainForm,
            Config config,
            GameInfo game,
            IEmulator core,
            IMovieSession movieSession)
        {
            _mainForm     = mainForm;
            _config       = config;
            _game         = game;
            _emulator     = core;
            _movieSession = movieSession;
            InitializeComponent();

            if (!_emulator.HasSavestates())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "now"));
            }

            if (!_emulator.HasSaveRam())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "saveram"));
            }
        }
Exemplo n.º 4
0
        public static DialogResult DoGBLPrefsDialog(
            Config config,
            IDialogParent dialogParent,
            IGameInfo game,
            IMovieSession movieSession,
            ISettingsAdapter settable)
        {
            var s  = (GambatteLink.GambatteLinkSettings)settable.GetSettings();
            var ss = (GambatteLink.GambatteLinkSyncSettings)settable.GetSyncSettings();

            using var dlg = new GBLPrefs(dialogParent.DialogController, config, game, movieSession);
            dlg.PutSettings(s, ss);

            var result = dialogParent.ShowDialogAsChild(dlg);

            if (result == DialogResult.OK)
            {
                dlg.GetSettings(out s, out ss);
                settable.PutCoreSettings(s);
                if (dlg.SyncSettingsChanged)
                {
                    settable.PutCoreSyncSettings(ss);
                }
            }
            return(result);
        }
        public ImportResult Import(
            IDialogParent dialogParent,
            IMovieSession session,
            IEmulator emulator,
            string path,
            Config config)
        {
            _dialogParent = dialogParent;
            SourceFile    = new FileInfo(path);
            Config        = config;

            if (!SourceFile.Exists)
            {
                Result.Errors.Add($"Could not find the file {path}");
                return(Result);
            }

            var newFileName = $"{SourceFile.FullName}.{Bk2Movie.Extension}";

            Result.Movie = session.Get(newFileName);
            Result.Movie.Attach(emulator);
            RunImport();

            if (!Result.Errors.Any())
            {
                Result.Movie.Save();
            }

            return(Result);
        }
Exemplo n.º 6
0
 public OSDManager(Config config, IEmulator emulator, InputManager inputManager, IMovieSession movieSession)
 {
     _config       = config;
     _emulator     = emulator;
     _inputManager = inputManager;
     _movieSession = movieSession;
 }
Exemplo n.º 7
0
 private DGBPrefs(Config config, IGameInfo game, IMovieSession movieSession)
 {
     _config       = config;
     _game         = game;
     _movieSession = movieSession;
     InitializeComponent();
     Icon = Properties.Resources.DualIcon;
 }
        private MovieZone(IEmulator emulator, ToolManager tools, IMovieSession movieSession)
        {
            _emulator     = emulator;
            _tools        = tools;
            _movieSession = movieSession;

            _targetController = movieSession.GenerateMovieController();
            _targetController.SetFrom(_targetController);             // Reference and create all buttons
        }
Exemplo n.º 9
0
 /// <exception cref="InvalidOperationException">loaded core does not implement <see cref="IStatable"/></exception>
 internal TasMovie(IMovieSession session, string path) : base(session, path)
 {
     Branches        = new TasBranchCollection(this);
     ChangeLog       = new TasMovieChangeLog(this);
     TasStateManager = new TasStateManager(this, session.Settings.DefaultTasStateManagerSettings);
     Header[HeaderKeys.MovieVersion] = "BizHawk v2.0 Tasproj v1.0";
     Markers = new TasMovieMarkerList(this);
     Markers.CollectionChanged += Markers_CollectionChanged;
     Markers.Add(0, "Power on");
 }
Exemplo n.º 10
0
 /// <exception cref="InvalidOperationException">loaded core does not implement <see cref="IStatable"/></exception>
 internal TasMovie(IMovieSession session, string path) : base(session, path)
 {
     Branches  = new TasBranchCollection(this);
     ChangeLog = new TasMovieChangeLog(this);
     Header[HeaderKeys.MovieVersion] = $"BizHawk v2.0 Tasproj v{CurrentVersion}";
     Markers = new TasMovieMarkerList(this);
     Markers.CollectionChanged += Markers_CollectionChanged;
     Markers.Add(0, "Power on");
     TasStateManager = new ZwinderStateManager();
 }
Exemplo n.º 11
0
 private DGBPrefs(IDialogController dialogController, Config config, IGameInfo game, IMovieSession movieSession)
 {
     _config          = config;
     _game            = game;
     _movieSession    = movieSession;
     DialogController = dialogController;
     InitializeComponent();
     gbPrefControl1.DialogParent = this;
     gbPrefControl2.DialogParent = this;
     Icon = Properties.Resources.DualIcon;
 }
Exemplo n.º 12
0
 public void PutSettings(Config config, IGameInfo game, IMovieSession movieSession, Gameboy.GambatteSettings s, Gameboy.GambatteSyncSettings ss)
 {
     _game         = game;
     _config       = config;
     _movieSession = movieSession;
     _s            = s ?? new Gameboy.GambatteSettings();
     _ss           = ss ?? new Gameboy.GambatteSyncSettings();
     propertyGrid1.SelectedObject = _ss;
     propertyGrid1.Enabled        = movieSession.Movie.NotActive();
     checkBoxMuted.Checked        = _s.Muted;
 }
Exemplo n.º 13
0
        public Bk2Movie(IMovieSession session, string filename)
        {
            if (string.IsNullOrWhiteSpace(filename))
            {
                throw new ArgumentNullException($"{nameof(filename)} can not be null.");
            }

            Session  = session;
            Filename = filename;
            Header[HeaderKeys.MovieVersion] = "BizHawk v2.0.0";
        }
Exemplo n.º 14
0
 /// <exception cref="InvalidOperationException">loaded core does not implement <see cref="IStatable"/></exception>
 internal TasMovie(IMovieSession session, string path) : base(session, path)
 {
     Branches  = new TasBranchCollection(this);
     ChangeLog = new TasMovieChangeLog(this);
     Header[HeaderKeys.MovieVersion] = $"BizHawk v2.0 Tasproj v{CurrentVersion.ToString(CultureInfo.InvariantCulture)}";
     Markers = new TasMovieMarkerList(this);
     Markers.CollectionChanged += Markers_CollectionChanged;
     Markers.Add(0, "Power on");
     TasStateManager = new ZwinderStateManager(
         session.Settings.DefaultTasStateManagerSettings,
         IsReserved);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolManager"/> class.
 /// </summary>
 public ToolManager(
     MainForm owner,
     Config config,
     IEmulator emulator,
     IMovieSession movieSession)
 {
     _owner        = owner;
     _config       = config;
     _emulator     = emulator;
     _movieSession = movieSession;
     _apiProvider  = ApiManager.Restart(_emulator.ServiceProvider);
 }
Exemplo n.º 16
0
        public virtual void Attach(IMovieSession session, IEmulator emulator)
        {
            // TODO: this check would ideally happen
            // but is disabled for now because restarting a movie doesn't new one up
            // so the old one hangs around with old emulator until this point
            // maybe we should new it up, or have a detach method
            //if (!Emulator.IsNull())
            //{
            //	throw new InvalidOperationException("A core has already been attached!");
            //}

            Emulator = emulator;
            Session  = session;
        }
Exemplo n.º 17
0
        public RecordMovie(
            IMainFormForTools mainForm,
            Config config,
            GameInfo game,
            IEmulator core,
            IMovieSession movieSession,
            FirmwareManager firmwareManager)
        {
            _mainForm        = mainForm;
            _config          = config;
            _game            = game;
            _emulator        = core;
            _movieSession    = movieSession;
            _firmwareManager = firmwareManager;
            InitializeComponent();
            Icon            = Properties.Resources.TAStudioIcon;
            BrowseBtn.Image = Properties.Resources.OpenFile;
            if (OSTailoredCode.IsUnixHost)
            {
                Load += (_, _) =>
                {
                    //HACK to make this usable on Linux. No clue why this Form in particular is so much worse, maybe the GroupBox? --yoshi
                    groupBox1.Height -= 24;
                    DefaultAuthorCheckBox.Location += new Size(0, 32);
                    var s = new Size(0, 40);
                    OK.Location     += s;
                    Cancel.Location += s;
                }
            }
            ;

            if (!_emulator.HasSavestates())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "now"));
            }

            if (!_emulator.HasSaveRam())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "saveram"));
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolManager"/> class.
 /// </summary>
 public ToolManager(
     MainForm owner,
     Config config,
     InputManager inputManager,
     IEmulator emulator,
     IMovieSession movieSession,
     IGameInfo game)
 {
     _owner        = owner;
     _config       = config;
     _inputManager = inputManager;
     _emulator     = emulator;
     _movieSession = movieSession;
     _game         = game;
     _apiProvider  = ApiManager.Restart(_owner, _emulator.ServiceProvider);
 }
Exemplo n.º 19
0
        public override void Attach(IMovieSession session, IEmulator emulator)
        {
            if (!emulator.HasSavestates())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service");
            }

            if (!emulator.CanPollInput())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IInputPollable)} service");
            }

            _inputPollable = emulator.AsInputPollable();
            TasStateManager.Attach(emulator);

            base.Attach(session, emulator);
        }
        public SavestateFile(IEmulator emulator, IMovieSession movieSession, IDictionary <string, object> userBag)
        {
            if (!emulator.HasSavestates())
            {
                throw new InvalidOperationException("The provided core must have savestates");
            }

            _emulator = emulator;
            _statable = emulator.AsStatable();
            if (emulator.HasVideoProvider())
            {
                _videoProvider = emulator.AsVideoProvider();
            }

            _movieSession = movieSession;
            _userBag      = userBag;
        }
Exemplo n.º 21
0
        public DisplayManager(
            Config config,
            IEmulator emulator,
            InputManager inputManager,
            IMovieSession movieSession,
            IGL gl,
            PresentationPanel presentationPanel,
            Func <bool> getIsSecondaryThrottlingDisabled)
            : base(config, emulator, inputManager, movieSession, gl.DispMethodEnum(), gl, gl.CreateRenderer())
        {
            _presentationPanel = presentationPanel;
            _getIsSecondaryThrottlingDisabled = getIsSecondaryThrottlingDisabled;

            // setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
            // but is it tho? --yoshi
            // turns out it was, calling Instance getter here initialises it, and the encapsulated Activate call is necessary too --yoshi
            _crGraphicsControl = GLManager.Instance.GetContextForGraphicsControl(_graphicsControl);
        }
        public static ITasMovie ToTasMovie(this IMovie old, IMovieSession session)
        {
            string newFilename = GetNewFileName(old.Filename);
            var    tas         = (ITasMovie)MovieService.Get(newFilename);

            // TODO: this relies on the fact that the emulator core here will be the same as when it is load
            // so this specifically only works in the scenario of a running bk2 converted to tasproj in tastudio
            // need to untangle and not be so dependent on core loading behavior
            tas.Attach(session, old.Emulator);
            for (var i = 0; i < old.InputLogLength; i++)
            {
                var input = old.GetInputState(i);
                tas.AppendFrame(input);
            }

            old.Truncate(0);             // Trying to minimize ram usage

            tas.HeaderEntries.Clear();
            foreach (var kvp in old.HeaderEntries)
            {
                tas.HeaderEntries[kvp.Key] = kvp.Value;
            }

            tas.SyncSettingsJson = old.SyncSettingsJson;

            tas.Comments.Clear();
            foreach (var comment in old.Comments)
            {
                tas.Comments.Add(comment);
            }

            tas.Subtitles.Clear();
            foreach (var sub in old.Subtitles)
            {
                tas.Subtitles.Add(sub);
            }

            tas.StartsFromSavestate = old.StartsFromSavestate;
            tas.TextSavestate       = old.TextSavestate;
            tas.BinarySavestate     = old.BinarySavestate;
            tas.SaveRam             = old.SaveRam;

            return(tas);
        }
Exemplo n.º 23
0
        // Attempt to import another type of movie file into a movie object.
        public static ImportResult ImportFile(IMovieSession session, IEmulator emulator, string path, Config config)
        {
            string ext          = Path.GetExtension(path) ?? "";
            var    importerType = ImporterForExtension(ext);

            if (importerType == default)
            {
                return(ImportResult.Error($"No importer found for file type {ext}"));
            }

            // Create a new instance of the importer class using the no-argument constructor
            IMovieImport importer = (IMovieImport)importerType
                                    .GetConstructor(new Type[] { })
                                    ?.Invoke(new object[] { });

            return(importer == null
                                ? ImportResult.Error($"No importer found for file type {ext}")
                                : importer.Import(session, emulator, path, config));
        }
Exemplo n.º 24
0
        public MovieZone(IEmulator emulator, ToolManager tools, IMovieSession movieSession, int start, int length, string key = "")
            : this(emulator, tools, movieSession)
        {
            var lg = movieSession.Movie.LogGeneratorInstance(movieSession.MovieController);

            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.
            InitController(_inputKey);

            var logGenerator = movieSession.Movie.LogGeneratorInstance(_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] = movieSession.Movie.GetInputLogEntry(i + start);
                }
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    _controller.SetFrom(movieSession.Movie.GetInputState(i + start));
                    _log[i] = logGenerator.GenerateLogEntry();
                }
            }
        }
Exemplo n.º 25
0
        // Attempt to import another type of movie file into a movie object.
        public static ImportResult ImportFile(
            IDialogParent dialogParent,
            IMovieSession session,
            IEmulator emulator,
            string path,
            Config config)
        {
            string ext          = Path.GetExtension(path) ?? "";
            var    importerType = ImporterForExtension(ext);

            if (importerType == default)
            {
                return(ImportResult.Error($"No importer found for file type {ext}"));
            }

            // Create a new instance of the importer class using the no-argument constructor

            return(importerType.GetConstructor(Array.Empty <Type>())?.Invoke(Array.Empty <object>()) is IMovieImport importer
                                ? importer.Import(dialogParent, session, emulator, path, config)
                                : ImportResult.Error($"No importer found for file type {ext}"));
        }
Exemplo n.º 26
0
        public PlayMovie(
            MainForm mainForm,
            Config config,
            GameInfo game,
            IEmulator emulator,
            IMovieSession movieSession)
        {
            _mainForm     = mainForm;
            _config       = config;
            _game         = game;
            _emulator     = emulator;
            _movieSession = movieSession;
            InitializeComponent();
            MovieView.RetrieveVirtualItem += MovieView_QueryItemText;
            MovieView.VirtualMode          = true;
            _sortReverse = false;
            _sortedCol   = "";

            _sortDetailsReverse = false;
            _sortedDetailsCol   = "";
        }
Exemplo n.º 27
0
        public RecordMovie(
            IMainFormForTools mainForm,
            Config config,
            GameInfo game,
            IEmulator core,
            IMovieSession movieSession,
            FirmwareManager firmwareManager)
        {
            _mainForm        = mainForm;
            _config          = config;
            _game            = game;
            _emulator        = core;
            _movieSession    = movieSession;
            _firmwareManager = firmwareManager;
            InitializeComponent();
            Icon            = Properties.Resources.TAStudio_MultiSize;
            BrowseBtn.Image = Properties.Resources.OpenFile;

            if (!_emulator.HasSavestates())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "now"));
            }

            if (!_emulator.HasSaveRam())
            {
                StartFromCombo.Items.Remove(
                    StartFromCombo.Items
                    .OfType <object>()
                    .First(i => i.ToString()
                           .ToLower() == "saveram"));
            }
        }
 public UserDataApi(IMovieSession movieSession) => _movieSession = movieSession;
Exemplo n.º 29
0
 public JoypadApi(Action <string> logCallback, InputManager inputManager, IMovieSession movieSession)
 {
     LogCallback   = logCallback;
     _inputManager = inputManager;
     _movieSession = movieSession;
 }
Exemplo n.º 30
0
        public static void DoGBPrefsDialog(IMainFormForConfig mainForm, Config config, IGameInfo game, IMovieSession movieSession, Gameboy gb)
        {
            var s  = gb.GetSettings();
            var ss = gb.GetSyncSettings();

            using var dlg = new GBPrefs(mainForm.DialogController);
            dlg.gbPrefControl1.PutSettings(config, game, movieSession, s, ss);
            dlg.gbPrefControl1.ColorGameBoy = gb.IsCGBMode() && (!gb.IsCGBDMGMode() || ss.EnableBIOS);
            if (mainForm.ShowDialogAsChild(dlg).IsOk())
            {
                dlg.gbPrefControl1.GetSettings(out s, out ss);
                gb.PutSettings(s);
                if (dlg.gbPrefControl1.SyncSettingsChanged)
                {
                    mainForm.PutCoreSyncSettings(ss);
                }
            }
        }