Exemplo n.º 1
0
        /// <summary>
        /// 指定した番号のファイルを保存します。
        /// </summary>
        /// <param name="index"></param>
        public void SaveCurrentSetting(int index)
        {
            if (index <= 0 || index > FileCount)
            {
                return;
            }

            SettingFileIo.SaveSetting(SpecialFilePath.GetSaveFilePath(index), SettingFileReadWriteModes.Internal);
            FocusedFileIndex = index;
        }
Exemplo n.º 2
0
        /// <summary>
        /// インデックスと、各情報(キャラとそれ以外)をロードするかどうかを指定してファイルをロードします。
        /// キャラをロードする場合、必要なら実際のロードメッセージまで実行します。
        /// </summary>
        /// <param name="index"></param>
        /// <param name="loadCharacter"></param>
        /// <param name="loadNonCharacter"></param>
        /// <param name="fromAutomation"></param>
        public void LoadSetting(int index, bool loadCharacter, bool loadNonCharacter, bool fromAutomation)
        {
            if (!CheckFileExist(index))
            {
                LogOutput.Instance.Write($"Tried to load setting, but file does not exist for {index}");
                return;
            }

            if (!loadCharacter && !loadNonCharacter)
            {
                //意味がないので何もしない
                return;
            }

            var prevVrmPath      = _setting.LastVrmLoadFilePath;
            var prevVRoidModelId = _setting.LastLoadedVRoidModelId;

            var content =
                (loadCharacter && loadNonCharacter) ? SettingFileReadContent.All :
                loadCharacter ? SettingFileReadContent.Character :
                SettingFileReadContent.NonCharacter;

            SettingFileIo.LoadSetting(SpecialFilePath.GetSaveFilePath(index), SettingFileReadWriteModes.Internal, content, fromAutomation);
            var loadedVrmPath      = _setting.LastVrmLoadFilePath;
            var loadedVRoidModelId = _setting.LastLoadedVRoidModelId;

            //NOTE: この時点ではキャラを切り替えたわけではないので、実態に合わすため元に戻してから続ける。
            _setting.LastVrmLoadFilePath    = prevVrmPath;
            _setting.LastLoadedVRoidModelId = prevVRoidModelId;

            if (content != SettingFileReadContent.NonCharacter &&
                loadedVrmPath != prevVrmPath &&
                File.Exists(loadedVrmPath)
                )
            {
                LogOutput.Instance.Write($"Load Local VRM, setting no={index}, automation={fromAutomation}, path={loadedVrmPath}");
                _sender.SendMessage(MessageFactory.Instance.OpenVrm(loadedVrmPath));
                _setting.OnLocalModelLoaded(loadedVrmPath);
            }
            else if (content != SettingFileReadContent.NonCharacter &&
                     loadedVRoidModelId != prevVRoidModelId &&
                     !string.IsNullOrEmpty(loadedVRoidModelId) &&
                     !fromAutomation
                     )
            {
                LogOutput.Instance.Write($"Load VRoid, setting no={index}, automation={fromAutomation},  id={loadedVRoidModelId}");
                VRoidModelLoadRequested?.Invoke(loadedVRoidModelId);
            }

            //NOTE: キャラだけ切り替えるのはファイルロード扱いせず、前のファイルがロードされているように見なす。
            if (loadNonCharacter)
            {
                FocusedFileIndex = index;
            }
        }
Exemplo n.º 3
0
        public MainWindowViewModel()
        {
            Model           = new RootSettingSync(MessageSender, MessageIo.Receiver);
            SettingFileIo   = new SettingFileIo(Model, MessageSender);
            SaveFileManager = new SaveFileManager(SettingFileIo, Model, MessageSender);

            WindowSetting          = new WindowSettingViewModel(Model.Window, MessageSender);
            MotionSetting          = new MotionSettingViewModel(Model.Motion, MessageSender, MessageIo.Receiver);
            GamepadSetting         = new GamepadSettingViewModel(Model.Gamepad, MessageSender);
            LayoutSetting          = new LayoutSettingViewModel(Model.Layout, Model.Gamepad, MessageSender, MessageIo.Receiver);
            LightSetting           = new LightSettingViewModel(Model.Light, MessageSender);
            WordToMotionSetting    = new WordToMotionSettingViewModel(Model.WordToMotion, MessageSender, MessageIo.Receiver);
            ExternalTrackerSetting = new ExternalTrackerViewModel(Model.ExternalTracker, Model.Motion, MessageSender, MessageIo.Receiver);
            SettingIo = new SettingIoViewModel(Model, Model.Automation, SaveFileManager, MessageSender);
            //オートメーションの配線: 1つしかないのでザツにやる。OC<T>をいじる関係でUIスレッド必須なことに注意
            Model.Automation.LoadSettingFileRequested += v =>
                                                         Application.Current.Dispatcher.BeginInvoke(new Action(
                                                                                                        () => SaveFileManager.LoadSetting(v.Index, v.LoadCharacter, v.LoadNonCharacter, true))
                                                                                                    );

            _runtimeHelper = new RuntimeHelper(MessageSender, MessageIo.Receiver, Model);

            LoadVrmCommand           = new ActionCommand(LoadVrm);
            LoadVrmByFilePathCommand = new ActionCommand <string>(LoadVrmByFilePath);
            ConnectToVRoidHubCommand = new ActionCommand(ConnectToVRoidHubAsync);

            OpenVRoidHubCommand      = new ActionCommand(() => UrlNavigate.Open("https://hub.vroid.com/"));
            AutoAdjustCommand        = new ActionCommand(() => MessageSender.SendMessage(MessageFactory.Instance.RequestAutoAdjust()));
            OpenSettingWindowCommand = new ActionCommand(() => SettingWindow.OpenOrActivateExistingWindow(this));

            ResetToDefaultCommand  = new ActionCommand(ResetToDefault);
            LoadPrevSettingCommand = new ActionCommand(LoadPrevSetting);

            TakeScreenshotCommand       = new ActionCommand(_runtimeHelper.TakeScreenshot);
            OpenScreenshotFolderCommand = new ActionCommand(_runtimeHelper.OpenScreenshotSavedFolder);

            MessageIo.Receiver.ReceivedCommand      += OnReceiveCommand;
            SaveFileManager.VRoidModelLoadRequested += id => LoadSavedVRoidModel(id, false);
        }
Exemplo n.º 4
0
 public SaveFileManager(SettingFileIo fileIo, RootSettingSync setting, IMessageSender sender)
 {
     SettingFileIo = fileIo;
     _setting      = setting;
     _sender       = sender;
 }