/// <summary> /// LocalGameServerを渡して、このウィンドウに貼り付けているGameScreenControlを初期化してやる。 /// </summary> /// <param name="gameServer"></param> public void Init(LocalGameServer gameServer_) { // GameScreenControlの初期化 var setting = new GameScreenControlSetting() { SetButton = SetButton, gameServer = gameServer_, UpdateMenuItems = UpdateMenuItems, }; gameScreenControl1.Setting = setting; gameScreenControl1.Init(); // エンジンの読み筋などを、検討ダイアログにリダイレクトする。 gameScreenControl1.ThinkReportChanged = ThinkReportChanged; // -- ViewModelのハンドラの設定 ViewModel.AddPropertyChangedHandler("LastFileName", _ => UpdateMenuItems()); // -- それ以外のハンドラの設定 // DockWindow関係の初期化 InitDocks(); // ToolStripのShortcutを設定する。 // これは、engineConsiderationMainControlの初期化が終わっている必要がある。 UpdateToolStripShortcut(); }
protected void BeginTest(string mapName, int playersCount, int botsCount, Action callback, int lag = 0) { Assert.DoesNotThrow(() => { string testGamePath = "TestGame"; m_testGame = UnityEngine.Object.Instantiate(Resources.Load <GameObject>(testGamePath)); TestGameInitArgs gameInitArgs = new TestGameInitArgs { MapName = mapName, PlayersCount = playersCount, BotsCount = botsCount }; Dependencies.State.SetValue("Battlehub.VoxelGame.TestGameInitArgs", gameInitArgs); LocalMatchServer localMatchServer = (LocalMatchServer)Dependencies.LocalMatchServer; localMatchServer.Lag = lag; LocalGameServer localGameServer = (LocalGameServer)Dependencies.LocalGameServer; localGameServer.Lag = lag; IVoxelGame voxelGame = Dependencies.GameState; VoxelGameStateChangedHandler started = null; started = () => { voxelGame.Started -= started; callback(); }; voxelGame.Started += started; }); }
public void Initialize( IUIController uiController, IMsgRepo msgRepo, INetworkManager network, XiaoMiManager xiaoMiManager, IAnalyticManager analyticManager, ConfigHolder configHolder, IAnySDKManager anySdkManager, IosSDK ios, IWeChatManager weChatManager, IDataRepository dataRepository, LocalGameServer localGameServer) { _uiController = uiController; _ios = ios; _network = network; _msgRepo = msgRepo; _configHolder = configHolder; _xiaoMiManager = xiaoMiManager; _weChatManager = weChatManager; _analyticManager = analyticManager; _localGameServer = localGameServer; _anySdkManager = anySdkManager; _appState = dataRepository.GetContainer <AppState>(DataKey.AppState); _versionResult = dataRepository.GetContainer <VersionResult>(DataKey.VersionResult); _pLoginResult = dataRepository.GetContainer <PLoginResult>(DataKey.PLoginResult); _billboardRead = dataRepository.GetContainer <bool>(DataKey.BillboardRead); _currentGameMode = dataRepository.GetContainer <int>(DataKey.CurrentGameMode); _vipExchangeList = dataRepository.GetContainer <VipExchangeListResult>(DataKey.VipExchangeListResult); _treasureChestData = dataRepository.GetContainer <TreasureChestData>(DataKey.TreasureChestData); _hloginResult = dataRepository.GetContainer <HLoginResult>(DataKey.HLoginResult); _friendListResult = dataRepository.GetContainer <SFriendListResult>(DataKey.SFriendListResult); }
public static LocalGameServer GetInstance() { if (_instance == null) { _instance = new LocalGameServer(); } return(_instance); }
public GameManager(LocalGameServer gameServer) { Environment = new TacticalEnvironment(); _gameServer = gameServer; var gameSession = new GameSession(_gameServer.RefreshGameSession(gameServer.SessionId)); Environment.RefreshGameSession(gameSession); }
public static LocalGameServer CreateGameServer(string sessionName) { var localServer = new LocalGameServer(); localServer.Initialization(sessionName); localServer.ResumeSession(); return(localServer); }
public static LocalGameServer CreateGameServer(string sessionName, EngineSettings settings = null) { localServer = new LocalGameServer(); if (settings == null) { settings = new EngineSettings(); } localServer.Initialization(sessionName, settings, false); //localServer.ResumeSession(1); return(localServer); }
/// <summary> /// メインの処理。 /// /// 各インスタンスを生成して、イベントのbindを行い、メインダイアログの実行を開始する。 /// </summary> private void Main() { // -- working directoryの変更 // 拡張子関連付けやショートカットなどで他のフォルダがworking directoryに設定されていることがある。 { try { var dirpath = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(Environment.GetCommandLineArgs()[0])); Directory.SetCurrentDirectory(dirpath); } catch { } } // -- global configの読み込み Config = GlobalConfig.CreateInstance(); // -- 各インスタンスの生成と、それぞれのbind作業 // -- 画像の読み込み { ImageManager = new ImageManager(); ImageManager.Update(); // ここでconfigに従い、画像が読み込まれる。 // GlobalConfigのプロパティ変更に対して、このimageManagerが呼び出されるようにbindしておく。 Config.AddPropertyChangedHandler("BoardImageVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("BoardImageColorVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("TatamiImageVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("TatamiImageColorVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("PieceTableImageVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("PieceImageVersion", ImageManager.UpdatePieceImage); Config.AddPropertyChangedHandler("PieceImageColorVersion", ImageManager.UpdatePieceImage); Config.AddPropertyChangedHandler("PieceAttackImageVersion", ImageManager.UpdatePieceAttackImage); Config.AddPropertyChangedHandler("LastMoveFromColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("LastMoveToColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("PickedMoveFromColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("PickedMoveToColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("BoardNumberImageVersion", ImageManager.UpdateBoardNumberImage); } // -- メインの対局ウィンドゥ var mainDialog = new MainDialog(); mainForm = mainDialog; // -- 対局controllerを1つ生成して、メインの対局ウィンドゥのViewModelに加える var gameServer = new LocalGameServer(); mainDialog.Init(gameServer); // -- 盤・駒が変更されたときにMainDialogのメニューの内容を修正しないといけないので更新がかかるようにしておく。 // 表示設定 Config.AddPropertyChangedHandler("BoardImageVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("BoardImageColorVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("TatamiImageVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("TatamiImageColorVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("PieceImageVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("PieceImageColorVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("PromotePieceColorType", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("FlipWhitePromoteDialog", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("PieceAttackImageVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("BoardNumberImageVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("LastMoveFromColorType", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("LastMoveToColorType", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("PickedMoveFromColorType", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("PickedMoveToColorType", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("TurnDisplay", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("MemoryLoggingEnable", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("FileLoggingEnable", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("NegateEvalWhenWhite", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("KifuWindowKifuVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("ConsiderationWindowKifuVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("DisplayNameTurnVersion", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("EnableGameEffect", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("PickedMoveDisplayStyle", mainDialog.ForceRedraw); // 棋譜・検討ウインドウの高さ・幅 Config.AddPropertyChangedHandler("KifuWindowWidthType", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("KifuWindowWidthType", mainDialog.ResizeKifuControl, mainDialog); Config.AddPropertyChangedHandler("KifuWindowWidthType", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("ConsiderationWindowHeightType", mainDialog.ForceRedraw); Config.AddPropertyChangedHandler("ConsiderationWindowHeightType", mainDialog.ResizeConsiderationControl, mainDialog); Config.AddPropertyChangedHandler("ConsiderationWindowHeightType", mainDialog.UpdateMenuItems, mainDialog); // 操作設定 Config.AddPropertyChangedHandler("KifuWindowPrevNextKey", mainDialog.UpdateToolStripShortcut); Config.AddPropertyChangedHandler("KifuWindowNextSpecialKey", mainDialog.UpdateToolStripShortcut); Config.AddPropertyChangedHandler("KifuWindowFirstLastKey", mainDialog.UpdateToolStripShortcut); Config.AddPropertyChangedHandler("ConsiderationWindowPrevNextKey", mainDialog.UpdateToolStripShortcut); // DockWindow Config.KifuWindowDockManager.AddPropertyChangedHandler("DockState", mainDialog.UpdateMenuItems, mainDialog); Config.EngineConsiderationWindowDockManager.AddPropertyChangedHandler("DockState", mainDialog.UpdateMenuItems, mainDialog); Config.MiniShogiBoardDockManager.AddPropertyChangedHandler("DockState", mainDialog.UpdateMenuItems, mainDialog); // -- ロギング用のハンドラをセット // メモリ上でのロギング Log.log1 = new MemoryLog(); var FileLoggingEnable = new PropertyChangedEventHandler((args) => { if (Config.FileLoggingEnable) { var now = DateTime.Now; Log.log2 = new FileLog($"log{now.ToString("yyyyMMddHHmm")}.txt"); } else { if (Log.log2 != null) { Log.log2.Dispose(); } Log.log2 = null; } }); Config.AddPropertyChangedHandler("FileLoggingEnable", FileLoggingEnable); // 上のハンドラを呼び出して、必要ならばロギングを開始しておいてやる。 FileLoggingEnable(null); // 初期化が終わったのでgameServerの起動を行う。 gameServer.Start(); // サウンド SoundManager = new SoundManager(); SoundManager.Start(); // 終了するときに設定ファイルに書き出すコード Application.ApplicationExit += new EventHandler((sender, e) => { // メインウィンドウのサイズを保存 SaveMainDialogSize(); // 設定ファイルの保存 SaveConfig(); // サウンドマネージャーの停止 SoundManager.Dispose(); // 起動しているGameServerすべてを明示的に終了させる必要がある。(そこにぶら下がっているエンジンを停止させるため) if (gameServer != null) { gameServer.Dispose(); } }); // -- メインダイアログを生成して、アプリの開始 Application.Run(mainDialog); }
/// <summary> /// ここが本アプリのエントリーポイント /// </summary> public void Run() { // -- 開発時のテストコード // 駒素材画像の変換 //ImageConverter.ConvertPieceImage(); //ImageConverter.ConvertBoardNumberImage(); // -- global configの読み込み config = GlobalConfig.CreateInstance(); // -- 各インスタンスの生成と、それぞれのbind作業 // -- 画像の読み込み { imageManager = new ImageManager(); imageManager.Update(); // ここでconfigに従い、画像が読み込まれる。 // GlobalConfigのプロパティ変更に対して、このimageManagerが呼び出されるようにbindしておく。 config.AddPropertyChangedHandler("BoardImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("TatamiImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("KomadaiImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("InTheBoardEdit", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("PieceImageVersion", imageManager.UpdatePieceImage); config.AddPropertyChangedHandler("PieceAttackImageVersion", imageManager.UpdatePieceAttackImage); config.AddPropertyChangedHandler("LastMoveFromColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("LastMoveToColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("PickedMoveFromColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("PickedMoveToColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("BoardNumberImageVersion", imageManager.UpdateBoardNumberImage); } // -- メインの対局ウィンドゥ var mainDialog = new MainDialog(); mainForm = mainDialog; mainDialogViewModel = new MainDialogViewModel(); mainDialog.ViewModel = mainDialogViewModel; // -- 対局controllerを1つ生成して、メインの対局ウィンドゥのViewModelに加える var gameServer = new LocalGameServer(); mainDialogViewModel.gameServer = gameServer; // LocalGameServerの対局情報と棋譜ウィンドウが更新されたときにメインウインドウの盤面・棋譜ウィンドウに // 更新がかかるようにしておく。 gameServer.AddPropertyChangedHandler("KifuList", mainDialog.gameScreen.kifuControl.OnListChanged, mainDialog); gameServer.AddPropertyChangedHandler("Position", mainDialog.gameScreen.PositionChanged); gameServer.AddPropertyChangedHandler("TurnChanged", mainDialog.gameScreen.TurnChanged, mainDialog); gameServer.AddPropertyChangedHandler("InTheGame", mainDialog.gameScreen.InTheGameChanged, mainDialog); gameServer.AddPropertyChangedHandler("InTheGame", mainDialog.UpdateMenuItems, mainDialog); gameServer.AddPropertyChangedHandler("EngineInitializing", mainDialog.gameScreen.EngineInitializingChanged, mainDialog); gameServer.AddPropertyChangedHandler("RestTimeChanged", mainDialog.gameScreen.RestTimeChanged); gameServer.AddPropertyChangedHandler("BoardReverse", mainDialog.UpdateMenuItems, mainDialog); gameServer.AddPropertyChangedHandler("GameServerStarted", mainDialog.UpdateMenuItems, mainDialog); gameServer.AddPropertyChangedHandler("SetKifuListIndex", mainDialog.gameScreen.SetKifuListIndex, mainDialog); // 盤・駒が変更されたときにMainDialogのメニューの内容を修正しないといけないので更新がかかるようにしておく。 config.AddPropertyChangedHandler("BoardImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("TatamiImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PieceImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PromotePieceColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PieceAttackImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("BoardNumberImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("LastMoveFromColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("LastMoveToColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PickedMoveFromColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PickedMoveToColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("TurnDisplay", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PieceSoundInTheGame", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("KifuReadOut", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("ReadOutSenteGoteEverytime", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("MemoryLoggingEnable", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("FileLoggingEnable", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("InTheBoardEdit", mainDialog.UpdateMenuItems, mainDialog); // 盤面編集時などに棋譜ウィンドウを消す config.AddPropertyChangedHandler("InTheBoardEdit", mainDialog.gameScreen.UpdateKifuControlVisibility, mainDialog); // -- ロギング用のハンドラをセット var MemoryLoggingEnableHandler = new PropertyChangedEventHandler((args) => { if (config.MemoryLoggingEnable) { Log.log1 = new MemoryLog(); } else { if (Log.log1 != null) { Log.log1.Dispose(); } Log.log1 = null; } }); var FileLoggingEnable = new PropertyChangedEventHandler((args) => { if (config.FileLoggingEnable) { var now = DateTime.Now; Log.log2 = new FileLog($"log{now.ToString("yyyyMMddHHmm")}.txt"); } else { if (Log.log2 != null) { Log.log2.Dispose(); } Log.log2 = null; } }); config.AddPropertyChangedHandler("MemoryLoggingEnable", MemoryLoggingEnableHandler); config.AddPropertyChangedHandler("FileLoggingEnable", FileLoggingEnable); // 上のハンドラを呼び出して、必要ならばロギングを開始しておいてやる。 MemoryLoggingEnableHandler(null); FileLoggingEnable(null); // 初期化が終わったのでgameServerの起動を行う。 gameServer.Start(); // サウンド soundManager = new SoundManager(); soundManager.Start(); // 終了するときに設定ファイルに書き出すコード Application.ApplicationExit += new EventHandler((sender, e) => { config.Save(); soundManager.Dispose(); }); Application.Run(mainDialog); }
public static GameSession GetSessionServerSide(LocalGameServer server) { return(server.RefreshGameSessionServerSide(server.SessionId)); }
/// <summary> /// ここが本アプリのエントリーポイント /// </summary> public void Run() { // -- 開発時のテストコード // 駒素材画像の変換 //ImageConverter.ConvertPieceImage(); //ImageConverter.ConvertBoardNumberImage(); // -- global configの読み込み config = GlobalConfig.CreateInstance(); // -- 各インスタンスの生成と、それぞれのbind作業 // -- 画像の読み込み { imageManager = new ImageManager(); imageManager.Update(); // ここでconfigに従い、画像が読み込まれる。 // GlobalConfigのプロパティ変更に対して、このimageManagerが呼び出されるようにbindしておく。 config.AddPropertyChangedHandler("BoardImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("TatamiImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("KomadaiImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("PieceImageVersion", imageManager.UpdatePieceImage); config.AddPropertyChangedHandler("PieceAttackImageVersion", imageManager.UpdatePieceAttackImage); config.AddPropertyChangedHandler("LastMoveFromColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("LastMoveToColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("PickedMoveFromColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("PickedMoveToColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("BoardNumberImageVersion", imageManager.UpdateBoardNumberImage); } // -- メインの対局ウィンドゥ var mainDialog = new MainDialog(); mainDialogViewModel = new MainDialogViewModel(); mainDialog.ViewModel = mainDialogViewModel; // -- 対局controllerを1つ生成して、メインの対局ウィンドゥのViewModelに加える var gameServer = new LocalGameServer(); mainDialogViewModel.gameServer = gameServer; // LocalGameServerの対局情報と棋譜ウィンドウが更新されたときにメインウインドウの盤面・棋譜ウィンドウに // 更新がかかるようにしておく。 gameServer.AddPropertyChangedHandler("KifuList", mainDialog.gameScreen.kifuControl.OnListChanged); gameServer.AddPropertyChangedHandler("Position", mainDialog.gameScreen.PositionChanged); gameServer.AddPropertyChangedHandler("TurnChanged", mainDialog.gameScreen.TurnChanged); gameServer.AddPropertyChangedHandler("InTheGame", mainDialog.gameScreen.TurnChanged); gameServer.AddPropertyChangedHandler("EngineInitializing", mainDialog.gameScreen.EngineInitializingChanged); gameServer.AddPropertyChangedHandler("RestTimeChanged", mainDialog.gameScreen.RestTimeChanged); // 盤・駒が変更されたときにMainDialogのメニューの内容を修正しないといけないので更新がかかるようにしておく。 config.AddPropertyChangedHandler("BoardReverse", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("BoardImageVersion", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("TatamiImageVersion", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("PieceImageVersion", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("PromotePieceColorType", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("PieceAttackImageVersion", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("BoardNumberImageVersion", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("LastMoveFromColorType", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("LastMoveToColorType", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("PickedMoveFromColorType", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("PickedMoveToColorType", mainDialog.UpdateMenuItems); config.AddPropertyChangedHandler("TurnDisplay", mainDialog.UpdateMenuItems); // MainDialogViewModelが変更されたときにMainDialogに変更がかからないといけないのでそのハンドラの設定。 // Notifyクラスのテスト(あとで消す) //NotifyTest.Test(); // 終了するときに設定ファイルに書き出すコード Application.ApplicationExit += new EventHandler((sender, e) => { config.Save(); }); Application.Run(mainDialog); }
/// <summary> /// メインの処理。 /// /// 各インスタンスを生成して、イベントのbindを行い、メインダイアログの実行を開始する。 /// </summary> private void Main() { // -- global configの読み込み config = GlobalConfig.CreateInstance(); // -- 各インスタンスの生成と、それぞれのbind作業 // -- 画像の読み込み { imageManager = new ImageManager(); imageManager.Update(); // ここでconfigに従い、画像が読み込まれる。 // GlobalConfigのプロパティ変更に対して、このimageManagerが呼び出されるようにbindしておく。 config.AddPropertyChangedHandler("BoardImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("TatamiImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("PieceTableImageVersion", imageManager.UpdateBoardImage); config.AddPropertyChangedHandler("PieceImageVersion", imageManager.UpdatePieceImage); config.AddPropertyChangedHandler("PieceAttackImageVersion", imageManager.UpdatePieceAttackImage); config.AddPropertyChangedHandler("LastMoveFromColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("LastMoveToColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("PickedMoveFromColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("PickedMoveToColorType", imageManager.UpdatePieceMoveImage); config.AddPropertyChangedHandler("BoardNumberImageVersion", imageManager.UpdateBoardNumberImage); } // -- メインの対局ウィンドゥ var mainDialog = new MainDialog(); mainForm = mainDialog; // -- 対局controllerを1つ生成して、メインの対局ウィンドゥのViewModelに加える var gameServer = new LocalGameServer(); mainDialog.Init(gameServer); // 盤・駒が変更されたときにMainDialogのメニューの内容を修正しないといけないので更新がかかるようにしておく。 config.AddPropertyChangedHandler("BoardImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("TatamiImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PieceImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PromotePieceColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PieceAttackImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("BoardNumberImageVersion", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("LastMoveFromColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("LastMoveToColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PickedMoveFromColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PickedMoveToColorType", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("TurnDisplay", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("PieceSoundInTheGame", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("KifuReadOut", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("ReadOutSenteGoteEverytime", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("MemoryLoggingEnable", mainDialog.UpdateMenuItems, mainDialog); config.AddPropertyChangedHandler("FileLoggingEnable", mainDialog.UpdateMenuItems, mainDialog); // -- ロギング用のハンドラをセット var MemoryLoggingEnableHandler = new PropertyChangedEventHandler((args) => { if (config.MemoryLoggingEnable) { Log.log1 = new MemoryLog(); } else { if (Log.log1 != null) { Log.log1.Dispose(); } Log.log1 = null; } }); var FileLoggingEnable = new PropertyChangedEventHandler((args) => { if (config.FileLoggingEnable) { var now = DateTime.Now; Log.log2 = new FileLog($"log{now.ToString("yyyyMMddHHmm")}.txt"); } else { if (Log.log2 != null) { Log.log2.Dispose(); } Log.log2 = null; } }); config.AddPropertyChangedHandler("MemoryLoggingEnable", MemoryLoggingEnableHandler); config.AddPropertyChangedHandler("FileLoggingEnable", FileLoggingEnable); // 上のハンドラを呼び出して、必要ならばロギングを開始しておいてやる。 MemoryLoggingEnableHandler(null); FileLoggingEnable(null); // 初期化が終わったのでgameServerの起動を行う。 gameServer.Start(); // サウンド soundManager = new SoundManager(); soundManager.Start(); // 終了するときに設定ファイルに書き出すコード Application.ApplicationExit += new EventHandler((sender, e) => { // メインウィンドウと検討ウィンドウに関して、 // 終了時のウィンドウサイズを記憶しておき、次回起動時にこのサイズでウィンドウを生成する。 if (mainDialog.ClientSize.Width >= 100 && mainDialog.ClientSize.Height >= 100) { config.MainDialogClientSize = mainDialog.ClientSize; } if (mainDialog.engineConsiderationDialog != null && mainDialog.engineConsiderationDialog.Width >= 100 && mainDialog.engineConsiderationDialog.Height >= 100) { config.ConsiderationDialogClientSize = mainDialog.engineConsiderationDialog.ClientSize; config.ConsiderationDialogClientLocation = new Point( mainDialog.engineConsiderationDialog.Location.X - mainDialog.Location.X, mainDialog.engineConsiderationDialog.Location.Y - mainDialog.Location.Y ); } config.Save(); soundManager.Dispose(); // 起動しているGameServerすべてを終了させる必要がある。(エンジンを停止させるため) if (gameServer != null) { gameServer.Dispose(); } }); Application.Run(mainDialog); }
/// <summary> /// メインの処理。 /// /// 各インスタンスを生成して、イベントのbindを行い、メインダイアログの実行を開始する。 /// </summary> private void Main() { // -- global configの読み込み Config = GlobalConfig.CreateInstance(); // -- 各インスタンスの生成と、それぞれのbind作業 // -- 画像の読み込み { ImageManager = new ImageManager(); ImageManager.Update(); // ここでconfigに従い、画像が読み込まれる。 // GlobalConfigのプロパティ変更に対して、このimageManagerが呼び出されるようにbindしておく。 Config.AddPropertyChangedHandler("BoardImageVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("TatamiImageVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("PieceTableImageVersion", ImageManager.UpdateBoardImage); Config.AddPropertyChangedHandler("PieceImageVersion", ImageManager.UpdatePieceImage); Config.AddPropertyChangedHandler("PieceAttackImageVersion", ImageManager.UpdatePieceAttackImage); Config.AddPropertyChangedHandler("LastMoveFromColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("LastMoveToColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("PickedMoveFromColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("PickedMoveToColorType", ImageManager.UpdatePieceMoveImage); Config.AddPropertyChangedHandler("BoardNumberImageVersion", ImageManager.UpdateBoardNumberImage); } // -- メインの対局ウィンドゥ var mainDialog = new MainDialog(); mainForm = mainDialog; // -- 対局controllerを1つ生成して、メインの対局ウィンドゥのViewModelに加える var gameServer = new LocalGameServer(); mainDialog.Init(gameServer); // 盤・駒が変更されたときにMainDialogのメニューの内容を修正しないといけないので更新がかかるようにしておく。 Config.AddPropertyChangedHandler("BoardImageVersion", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("TatamiImageVersion", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("PieceImageVersion", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("PromotePieceColorType", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("PieceAttackImageVersion", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("BoardNumberImageVersion", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("LastMoveFromColorType", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("LastMoveToColorType", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("PickedMoveFromColorType", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("PickedMoveToColorType", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("TurnDisplay", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("PieceSoundInTheGame", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("PieceSoundOffTheGame", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("KifuReadOut", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("ReadOutSenteGoteEverytime", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("MemoryLoggingEnable", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("FileLoggingEnable", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("NegateEvalWhenWhite", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("KifuWindowWidthType", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("ConsiderationWindowFollowMainWindow", mainDialog.UpdateMenuItems, mainDialog); Config.AddPropertyChangedHandler("ReadOutCancelWhenGameEnd", mainDialog.UpdateMenuItems, mainDialog); // -- ロギング用のハンドラをセット var MemoryLoggingEnableHandler = new PropertyChangedEventHandler((args) => { if (Config.MemoryLoggingEnable) { Log.log1 = new MemoryLog(); } else { if (Log.log1 != null) { Log.log1.Dispose(); } Log.log1 = null; } }); var FileLoggingEnable = new PropertyChangedEventHandler((args) => { if (Config.FileLoggingEnable) { var now = DateTime.Now; Log.log2 = new FileLog($"log{now.ToString("yyyyMMddHHmm")}.txt"); } else { if (Log.log2 != null) { Log.log2.Dispose(); } Log.log2 = null; } }); Config.AddPropertyChangedHandler("MemoryLoggingEnable", MemoryLoggingEnableHandler); Config.AddPropertyChangedHandler("FileLoggingEnable", FileLoggingEnable); Config.AddPropertyChangedHandler("KifuWindowWidthType", mainDialog.ResizeKifuControl, mainDialog); // 上のハンドラを呼び出して、必要ならばロギングを開始しておいてやる。 MemoryLoggingEnableHandler(null); FileLoggingEnable(null); // 初期化が終わったのでgameServerの起動を行う。 gameServer.Start(); // サウンド SoundManager = new SoundManager(); SoundManager.Start(); // 終了するときに設定ファイルに書き出すコード Application.ApplicationExit += new EventHandler((sender, e) => { // メインウィンドウのサイズを保存 SaveMainDialogSize(); // 設定ファイルの保存 SaveConfig(); // サウンドマネージャーの停止 SoundManager.Dispose(); // 起動しているGameServerすべてを明示的に終了させる必要がある。(そこにぶら下がっているエンジンを停止させるため) if (gameServer != null) { gameServer.Dispose(); } }); // -- メインダイアログを生成して、アプリの開始 Application.Run(mainDialog); }
public static void AddLocalServer(string Name, string Ip) { LocalGameServers.Add(LocalGameServer.Static(Ip, Name)); }