/// <summary> /// Loads the launcher config. /// </summary> /// <returns></returns> private LauncherConfig LoadConfig() { ILauncherConfig launcherConfig = null; try { if (File.Exists(this.configPath)) { launcherConfig = LauncherConfig.LoadConfig(this.configPath); } } catch (Exception ex) { Debug.Write(ex); // ToDo add logging here. } finally { if (launcherConfig == null) { launcherConfig = new LauncherConfig(); } } return(launcherConfig as LauncherConfig); }
public LauncherTrayUI(LauncherConfig config) { this.config = config; CreateMenuStrip(); CreateTrayIcon(); CreateAutoConnector(); }
private static void verify(string expectedResult, string expectedVersion) { string testResult = File.ReadAllText(StringConstants.TestResultFullPath); Assert.AreEqual(expectedResult, testResult); var config = LauncherConfig.Load(); Assert.AreEqual(expectedVersion, config.ApplicationVersion); }
static void Main() { log.Info("Emby External Player Launcher is starting."); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (var ui = new LauncherTrayUI(LauncherConfig.ReadFromFile())) { Application.Run(); } }
private void SetFromConfig(LauncherConfig config) { textBoxPath.Text = config.PlayerPath; textBoxArgs.Text = string.IsNullOrEmpty(config.PlayerArgs) ? LauncherConfig.DefaultPlayerArgs : config.PlayerArgs; textBoxPort.Text = config.MpcHcWebPort.ToString(); textBoxTimeout.Text = config.MpcHcWebTimeout.ToString(); textBoxUser.Text = config.EmbyUser; textBoxPassword.Text = config.EmbyPass; textBoxAddress.Text = config.EmbyAddress; textBoxReconnectPeriod.Text = config.EmbyReconnectPeriod.ToString(); }
/// <summary> /// Create a new configuration file. /// </summary> /// <param name="gameDirectory">The game directory to set in the config.</param> public void Create(string gameDirectory) { Config = new LauncherConfig { GameDirectory = gameDirectory, DownloadType = DownloadType.Standard, GameLanguage = GameLanguage.English, LauncherLanguage = "English" }; Save(); }
public void loadJSON() { config = null; menu.DirectoryCheck(); //ファイルがない場合: 初期設定ファイルの生成 if (!File.Exists(jsonPath)) { config = new LauncherConfig(); makeJSON(); } //ファイルの読込を試行 try { //ファイルの内容を一括読み出し string jsonString = File.ReadAllText(jsonPath, new UTF8Encoding(false)); //設定クラスをJSONデコードして生成 config = JsonUtility.FromJson <LauncherConfig>(jsonString); //ファイルのバージョンが古い場合は、デフォルト設定にして警告(nullの可能性も考慮してtry内) if (config.jsonVer != jsonVerMaster) { menu.ShowDialogOKCancel(LanguageManager.config.jsonloaders.OLD_CONFIG_HEAD, "" + jsonPath + LanguageManager.config.jsonloaders.OLD_CONFIG_BODY, 3f, () => { //OK makeJSON(); }, () => { //キャンセル }); config = new LauncherConfig(); } } catch (System.Exception e) { //JSONデコードに失敗した場合 Debug.Log(e.ToString()); config = null; } //デコード失敗した場合は、デフォルト設定にして警告 if (config == null) { config = new LauncherConfig(); menu.ShowDialogOKCancel(LanguageManager.config.jsonloaders.CORRUPT_CONFIG_HEAD, "" + jsonPath + LanguageManager.config.jsonloaders.CORRUPT_CONFIG_BODY, 3f, () => { //OK makeJSON(); }, () => { //キャンセル }); } }
public LauncherConfigForm(LauncherConfig config) { InitializeComponent(); if (config != null) { SetFromConfig(config); } else { SetDefaultConfig(); } }
static int Main(string[] args) { string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName)) + ".cfg"; // {2} //File.WriteAllText(path, _JsonString); LauncherConfig launcherConfig = AppInfoSerializer.Read(path); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.UseShellExecute = false; startInfo.WorkingDirectory = Environment.CurrentDirectory; startInfo.FileName = launcherConfig.ExePath; string cmd = Environment.CommandLine; // Remove exe part from raw command line int firstArgIndex = 0; bool discardNextSpaces = false; foreach (char c in cmd) { if (c == '\"') { discardNextSpaces = !discardNextSpaces; } if (!discardNextSpaces && (c == ' ' || c == '\t')) { break; } firstArgIndex++; } string arguments = cmd.Substring(firstArgIndex, cmd.Length - firstArgIndex).Trim(); startInfo.Arguments = arguments; if (launcherConfig.EnvVariables != null) { foreach (EnvVariable envVariable in launcherConfig.EnvVariables) { Utils.AddOrSetEnvVariable(startInfo.EnvironmentVariables, envVariable.Key, envVariable.Value); } } Process p = Process.Start(startInfo); if (launcherConfig.Blocking) { p.WaitForExit(); } return(0); }
private bool ValidateFormSettings() { if (textBoxPath.Text == "") { MessageBox.Show("The player path cannot be empty.", "Invalid Player Path", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (textBoxUser.Text == "") { MessageBox.Show("The user name cannot be empty.", "Invalid User Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } int port; if (!int.TryParse(textBoxPort.Text, out port) || port < 1 || port > 65535) { MessageBox.Show("The port must be an integer between 1 and 65535.", "Invalid Port", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } int timeout; if (!int.TryParse(textBoxTimeout.Text, out timeout) || timeout < 1) { MessageBox.Show("The timeout must be a positive integer.", "Invalid Timeout", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } int period; if (!int.TryParse(textBoxReconnectPeriod.Text, out period) || period < 1) { MessageBox.Show("The reconnect period must be a positive integer.", "Invalid Reconnect Period", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } newConfig = new LauncherConfig { EmbyAddress = textBoxAddress.Text, EmbyPass = textBoxPassword.Text, EmbyUser = textBoxUser.Text, MpcHcWebPort = port, MpcHcWebTimeout = timeout, PlayerArgs = textBoxArgs.Text, PlayerPath = textBoxPath.Text, EmbyReconnectPeriod = period }; return(true); }
private static void initializeConfig(string applicationVersion, string skipVersion) { var config = new LauncherConfig { UpdateServerUrl = StringConstants.UpdateServerUri, ApplicationName = StringConstants.ApplicationName, ApplicationStartupPath = _testApplicationExe, ApplicationVersion = applicationVersion, CheckUpdateStrategy = CheckUpdateStrategy.Automatically, SkipVersion = skipVersion, }; config.Save(); }
public MainController(LauncherConfig config, LauncherContainer container) { this.config = config; //Dependency service = new DownloadFileServiceImpl(config); dataSource = new WebClientDataSource(config); repository = new LauncherRepositoryImpl(dataSource, service, config); //UseCases checkUpdate = new CheckUpdateImpl(repository); openLink = new OpenLinkImpl(); startGame = new StartGameImpl(repository); Container = container; }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(onError); Log.Info("", "------------------- Launcher Server -------------------", ConsoleColor.DarkRed); // Loading all configs files ConfigMgr.LoadConfigs(); Config = ConfigMgr.GetConfig <LauncherConfig>(); // Loading log level from file if (!Log.InitLog(Config.LogLevel, "LauncherServer")) { ConsoleMgr.WaitAndExit(2000); } ServerState previousState = Config.ServerState; Config.ServerState = ServerState.PATCH; LoaderMgr.Start(); Client = new RpcClient("LauncherServer", Config.RpcInfo.RpcLocalIp, 1); Config.ServerState = previousState; if (!Client.Start(Config.RpcInfo.RpcServerIp, Config.RpcInfo.RpcServerPort)) { ConsoleMgr.WaitAndExit(2000); } Info = new FileInfo("Configs/mythloginserviceconfig.xml"); if (!Info.Exists) { Log.Error("Configs/mythloginserviceconfig.xml", "Config file missing !"); ConsoleMgr.WaitAndExit(5000); } StrInfo = Info.OpenText().ReadToEnd(); if (!TCPManager.Listen <TCPServer>(Config.LauncherServerPort, "LauncherServer")) { ConsoleMgr.WaitAndExit(2000); } Server = TCPManager.GetTcp <TCPServer>("LauncherServer"); ConsoleMgr.Start(); }
private void ReadConfig() { try { string configText = _configDataProvider.Read(); _launcherConfig = _configParser.Parse(configText); } catch (FileNotFoundException) { _launcherConfig = new LauncherConfig { Accounts = new List <Account>(), LastUsedAccount = string.Empty, gameVersion = GameVersion.x32, Arguments = string.Empty }; } }
private void ConfigItem_Click(object sender, EventArgs e) { if (configFormOpen) { return; } configFormOpen = true; var configForm = new LauncherConfigForm(config); if (configForm.ShowDialog() == DialogResult.OK) { config = configForm.Config; config.SaveToFile(); connector?.Stop(); connector = null; CreateAutoConnector(); } configFormOpen = false; }
internal override void Install(Deployment deployment) { foreach (var alias in Aliases) { Utils.Log("Processing exe alias {0}", alias); string aliasPath = Path.Combine(deployment.BinPath, alias); string aliasExePath = aliasPath + ".exe"; Utils.Log("--Copying launcher to {0}", aliasExePath); Utils.CopyFile(deployment.LauncherPath, aliasExePath, true); string configPath = aliasPath + ".cfg"; Utils.Log("--Serializing config file to {0}", configPath); LauncherConfig launcherConfig = new LauncherConfig(); launcherConfig.ExePath = ToolPath; launcherConfig.Blocking = Blocking; launcherConfig.EnvVariables = EnvVariables; AppInfoSerializer.Write(configPath, launcherConfig); File.SetLastWriteTimeUtc(configPath, deployment.TimeStamp); } }
public Account(LauncherConfig launcherConfig) { this.launcherConfig = launcherConfig; SelectedAccount = null; }
public string Stringify(LauncherConfig config) { return(JsonConvert.SerializeObject(config)); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Overwriting the logfile on launch seems sensible as writes to %temp% aren't affected by copy on write if (File.Exists(_logPath)) { File.Delete(_logPath); } Process process = Process.GetCurrentProcess(); string processPath = process.MainModule.FileName; string processDirPath = Path.GetDirectoryName(processPath); Directory.SetCurrentDirectory(processDirPath); string configPath = Path.Combine(processDirPath, "llconfig.json"); if (!File.Exists(configPath)) { ExitWithError($"Could not find file at path: {configPath}", ExitCode.ConfigMissing); } WriteLog($"Reading config from path [{configPath}]"); string rawConfig = File.ReadAllText(configPath); LauncherConfig config = JsonConvert.DeserializeObject <LauncherConfig>(rawConfig); if (!HasBeenCompleted(config.ID)) { ProcessCopyOperations(config.CopyOperations); ProcessRegistryOperations(config.RegistryOperations); MarkAsCompleted(config.ID); } if (File.Exists(config.ExecutablePath)) { ProcessStartInfo startInfo = new ProcessStartInfo(config.ExecutablePath); startInfo.WorkingDirectory = string.IsNullOrEmpty(config.WorkingDirPath) ? processDirPath : config.WorkingDirPath; string arguments = config.Arguments; if (args.Length > 0) { foreach (var arg in args) { arguments += " \"" + arg + "\""; } } startInfo.Arguments = arguments; startInfo.WindowStyle = ProcessWindowStyle.Normal; var useShellExeute = config.UseShellExecute; foreach (var variable in config.EnvironmentVariables) { // When modifying environment variables, using shell execute is illegal! useShellExeute = false; var value = variable.Value .Replace("{llWorkingDirPath}", startInfo.WorkingDirectory) .Replace("{llRootPath}", processDirPath); if ((startInfo.EnvironmentVariables.ContainsKey(variable.Name)) && (variable.Action == EnvironmentVariableAction.Append)) { WriteLog($"Appending environment variable [{variable.Name}] with value [{value}]"); startInfo.EnvironmentVariables[variable.Name] += value; } else { WriteLog($"Setting environment variable [{variable.Name}] to value [{value}]"); startInfo.EnvironmentVariables[variable.Name] = value; } } if (!(useShellExeute)) { startInfo.UseShellExecute = false; WriteLog($"Start process [{startInfo.FileName}] with arguments [{startInfo.Arguments}] and working dir [{startInfo.WorkingDirectory}]"); Process p = Process.Start(startInfo); p.WaitForExit(); WriteLog($"Process exited with exit code: {p.ExitCode}"); Environment.Exit(p.ExitCode); } else { startInfo.UseShellExecute = true; WriteLog($"Start process [{startInfo.FileName}] with arguments [{startInfo.Arguments}] and working dir [{startInfo.WorkingDirectory}] using shell execute"); Process.Start(startInfo); Environment.Exit(0); } } else { ExitWithError($"Executable path does not exist: {config.ExecutablePath}", ExitCode.ExecutableMissing); } }
public DownloadFileServiceImpl(MuLauncher.app.launcher.domain.entities.LauncherConfig config) { this.config = config; }
public AutoConnector(IPlayerAdapter player, LauncherConfig config) { this.player = player; this.config = config; reconnectTimer = new Timer(CheckConnection); }
public WebClientDataSource(LauncherConfig config) { this.config = config; }
/// <summary> /// Initializes a new instance of the <see cref="App" /> class. /// </summary> public App() { AppDomain.CurrentDomain.UnhandledException += this.CurrentDomainUnhandledException; AppDomain.CurrentDomain.ProcessExit += this.CurrentDomainProcessExit; if (!this.mutex.WaitOne()) { // The application is already running. Environment.Exit(1); } this.config = this.LoadConfig(); if (!string.IsNullOrEmpty(this.config.SelectedLanguage)) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(this.config.SelectedLanguage); } else { this.config.SelectedLanguage = Thread.CurrentThread.CurrentCulture.Name; } CultureInfo fallbackCultureInfo = CultureInfo.GetCultureInfo("EN-us"); this.resourceManager = new ResourceManager(Thread.CurrentThread.CurrentCulture, fallbackCultureInfo); this.favoritesServerWatcher = new ServerWatcher(28970, 100, 1000, 2000); this.favoritesServerWatcher.Start(); // Load the saved favorites servers. try { foreach (var favoriteServer in this.config.FavoriteServers) { this.favoritesServerWatcher.AddServer(favoriteServer); } } catch (Exception) { MessageBox.Show( this.resourceManager["resErrorInvalidServerInConfig"].Value, "Invalid server address loaded", MessageBoxButton.OK, MessageBoxImage.Warning); } // Registry var registry = new RegistryConfig(); // MainWindowViewModel MainWindowViewModel mainWindowViewModel = new MainWindowViewModel( this.config, registry, new Updater.Updater(), this.resourceManager); // NewsViewModel NewsViewViewModel newsViewViewModel = new NewsViewViewModel( this.resourceManager["resNewsNotLoaded"].Value, this.resourceManager); // FavoritesViewModel FavoritesViewViewModel favoritesViewViewModel = new FavoritesViewViewModel( this.favoritesServerWatcher, new G2OStarter(registry), this.resourceManager); // Main window MainWindow window = new MainWindow(mainWindowViewModel, newsViewViewModel, favoritesViewViewModel); window.Show(); }
public LauncherRepositoryImpl(LauncherDatasource launcherDataSource, LauncherService service, LauncherConfig config) { this.datasource = launcherDataSource; this.service = service; this.config = config; }