Пример #1
0
        internal WordToMotionSettingViewModel(WordToMotionSettingSync model, IMessageSender sender, IMessageReceiver receiver) : base(sender)
        {
            _model = model;
            Items  = new ReadOnlyObservableCollection <WordToMotionItemViewModel>(_items);
            CustomMotionClipNames = new ReadOnlyObservableCollection <string>(_customMotionClipNames);
            Devices = WordToMotionDeviceItem.LoadAvailableItems();

            AddNewItemCommand = new ActionCommand(() => model.AddNewItem());
            OpenKeyAssignmentEditorCommand = new ActionCommand(() => OpenKeyAssignmentEditor());
            ResetByDefaultItemsCommand     = new ActionCommand(
                () => SettingResetUtils.ResetSingleCategoryAsync(LoadDefaultItems)
                );

            _model.SelectedDeviceType.PropertyChanged += (_, __) =>
            {
                SelectedDevice           = Devices.FirstOrDefault(d => d.Index == _model.SelectedDeviceType.Value);
                EnableWordToMotion.Value = _model.SelectedDeviceType.Value != WordToMotionSetting.DeviceTypes.None;
            };
            SelectedDevice = Devices.FirstOrDefault(d => d.Index == _model.SelectedDeviceType.Value);
            //NOTE: シリアライズ文字列はどのみち頻繁に更新せねばならない
            //(並び替えた時とかもUnityにデータ送るために更新がかかる)ので、そのタイミングを使う
            _model.MidiNoteToMotionMapReloaded += (_, __) =>
            {
                if (!_model.IsLoading)
                {
                    LoadMidiSettingItems();
                }
            };
            _model.MotionRequestsReloaded += (_, __) =>
            {
                if (!_model.IsLoading)
                {
                    LoadMotionItems();
                }
            };

            _model.Loaded += (_, __) =>
            {
                LoadMidiSettingItems();
                LoadMotionItems();
            };

            _model.PreviewDataSender.PrepareDataSend +=
                (_, __) => _dialogItem?.WriteToModel(_model.PreviewDataSender.MotionRequest);
            receiver.ReceivedCommand += OnReceiveCommand;

            LoadDefaultItemsIfInitialStart();

            LoadMotionItems();
            LoadMidiSettingItems();
        }
        public RootSettingSync(IMessageSender sender, IMessageReceiver receiver)
        {
            AvailableLanguageNames = new ReadOnlyObservableCollection <string>(_availableLanguageNames);

            _sender = sender;

            Window          = new WindowSettingSync(sender);
            Motion          = new MotionSettingSync(sender);
            Layout          = new LayoutSettingSync(sender);
            Gamepad         = new GamepadSettingSync(sender);
            Light           = new LightSettingSync(sender);
            WordToMotion    = new WordToMotionSettingSync(sender, receiver);
            ExternalTracker = new ExternalTrackerSettingSync(sender);
            Automation      = new AutomationSettingSync(sender);

            //NOTE; LanguageSelectorとの二重管理っぽくて若干アレだがこのままで行く
            //初期値Defaultを入れることで、起動直後にPCのカルチャベースで言語を指定しなきゃダメかどうか判別する
            LanguageName = new RProperty <string>("Default", s =>
            {
                LanguageSelector.Instance.LanguageName = s;
            });
        }