public StateAPI(AppConfiguaraion appConfig, GameConfig gameConfig, ErrorFunc ef, InvokeFunction invokefunc) { this.appConfig = appConfig; this.gameConfig = gameConfig; errFunc = ef; invokeFunction = invokefunc; dropBoxFolderWatcher = null; //currentPlayer = ""; }
public AppMain(MainWindow appWindow) { this.appWindow = appWindow; log.Info("Application started"); FileInfo soundFile = new FileInfo(Environment.CurrentDirectory + "/Resources/notification.wav"); if (soundFile.Exists) { soundPlayer = new SoundPlayer(Environment.CurrentDirectory + "/Resources/notification.wav"); } else { soundPlayer = null; } gameConfig = new GameConfig(); appConfig = new AppConfiguaraion(); stateApi = new StateAPI(appConfig, gameConfig, this.VarnUser, this.appWindow.Dispatcher.Invoke); stateApi.CurrentPlayerChanged += this.currentPlayerChangedHandler; stateApi.UsersTurn += this.UsersTurnHandler; stateApi.UserPassed += this.UserPassedHandler; ReadAppConfig(); }
protected void ReadAppConfig() { log.Info("Reading Appconfig file"); if (!appConfigPath.Exists) { log.Info("Appconfig file does not exist! Creating new one"); SaveAppConfig(); } else { try { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(appConfigPath.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read); appConfig = (AppConfiguaraion)formatter.Deserialize(stream); stateApi.appConfig = this.appConfig; stream.Close(); log.Info("Appconfig read successfully"); //appWindow.Dispatcher.Invoke(() => appWindow.refreshPlayersComboBox()); } catch (Exception) { SaveAppConfig(); log.Error("Cannot deserialize AppConfig! - Created new instead"); } } CIV5Folder = appConfig.CIV5Folder; DropBoxFolder = appConfig.DropBoxFolder; PlayerName = appConfig.PlayerName; CivExePath = appConfig.CivExePath; StartWithoutPrompt = appConfig.StartWithoutPrompt; StartOnUsesTurn = appConfig.StartOnUsesTurn; UsersTurnMusic = appConfig.UsersTurnMusic; ReadGameConfig(); }