public MenuUtility(IResourceUtility resource)
 {
     _resources     = resource;
     WindowLocation = new Rect
                      (
         Screen.width - (DEFAULT_WIDTH * 2),
         (Screen.height / 2) - (DEFAULT_HEIGHT / 2),
         DEFAULT_WIDTH,
         DEFAULT_HEIGHT
                      );
 }
        public MainPageViewModel(IResourceUtility htmlLoader)
        {
            _resourceUtility       = htmlLoader;
            _localHtmlFileRootPath = _resourceUtility.GetHtmlFileRootPath();

            ChangeBackgroundMatrixCommand = new DelegateCommand(() => {
                Url = _localHtmlFileRootPath + "Background_Matrix.html";
            });

            ChangeBackgroundTransmissionCommand = new DelegateCommand(() =>
            {
                Url = _localHtmlFileRootPath + "Background_Transmission.html";
            });

            ChangeBackgroundBlankCommand = new DelegateCommand(() =>
            {
                Url = _localHtmlFileRootPath + "Background_Blank.html";
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// iBeacon発信処理メイン画面のコンストラクタ
        /// </summary>
        /// <param name="ibeaconTransmitService">iBeacon発信処理を持つモデル</param>
        public MainPageViewModel(IiBeaconTransmitService ibeaconTransmitService,
                                 IPageDialogService pageDialogService,
                                 IResourceUtility resourceUtility)
        {
            // ダイアログ表示処理を扱うサービスをViewModelのクラスに保持する。
            _pageDialogService = pageDialogService;

            // iBeacon発信処理を持つモデルをViewModelのクラスに保持する。
            _iBeaconTransmitService = ibeaconTransmitService;

            // リソース情報取得用
            _resourceUtility = resourceUtility;

            // TransmitStartStopCommandコマンドの実処理をchangeTransmitStatusメソッドに設定する。
            //TransmitStartStopCommand = new DelegateCommand(changeTransmitStatus);

            // TransmitStartStopCommandコマンドの実処理をchangeTransmitStatusメソッドに設定しつつ、
            // 実行可否をcanExecuteTransmitStartStopCommandで制御する。
            // canExecuteTransmitStartStopCommandの戻り値がfalseの場合はコマンド実行不可。
            TransmitStartStopCommand =
                new DelegateCommand(changeTransmitStatus, canExecuteTransmitStartStopCommand);
        }
Ejemplo n.º 4
0
        public void InitializeMods()
        {
            try
            {
                _config    = new ConfigReader();
                _loader    = new ModLoader(_logger, _config);
                _game      = new UnderMineGame(Game.Instance, _logger);
                _player    = new PlayerWrapper(_game);
                _events    = new Events(_game, _logger, _patcher);
                _resources = new ResourceUtility();

                var mods = _loader?.LoadMods();
                if (mods == null)
                {
                    _logger.Warn("No mods were found!");
                    return;
                }

                foreach (var modParent in mods)
                {
                    if (modParent == null)
                    {
                        _logger.Warn("Mod Parent missing.");
                        continue;
                    }

                    if (modParent.Mods == null)
                    {
                        _logger.Warn("Mod Parent Mods are missing.");
                        continue;
                    }

                    foreach (var assembly in modParent?.Mods)
                    {
                        foreach (var mod in assembly.Value)
                        {
                            if (mod == null)
                            {
                                _logger.Warn("Mod is null.");
                                continue;
                            }

                            try
                            {
                                mod.Events       = _events;
                                mod.GameInstance = _game;
                                mod.Logger       = _logger;
                                mod.Patcher      = _patcher;
                                mod.Player       = _player;
                                mod.Resources    = _resources;
                                mod.MenuRenderer = new MenuUtility(_resources);

                                mod.Initialize();
                                _loadedMods.Add(mod);
                                _modCount += 1;
                            }
                            catch (Exception ex)
                            {
                                _logger.Error($"Error running mod: {mod.ModData.Data.Name}\r\n{ex}");
                            }
                        }
                    }
                }

                ((Events)_events).Patch();
                _logger.Debug("Events have been patched");
            }
            catch (Exception ex)
            {
                _logger.Error($"Error while setting up mods: \r\n{ex}");
            }
        }