/// <summary> /// 初始化启动器 /// </summary> /// <param name="javaPath"></param> /// <param name="javaXmx"></param> /// <param name="userName"></param> /// <param name="name"></param> /// <param name="info"></param> /// <param name="extarg"></param> /// <param name="li"></param> public Launcher(string javaPath, string javaXmx, string userName, string name, gameinfo info, string[] extarg, LoginInfo li) { OnStateChangeEvent(LangManager.GetLangFromResource("LauncherCheckJava")); if (!File.Exists(javaPath)) { BMCLV2.Logger.log("找不到java",BMCLV2.Logger.LogType.Error); throw new NoJavaException(); } OnStateChangeEvent(LangManager.GetLangFromResource("LauncherCheckMem")); _javaxmx = javaXmx; _username = userName; _version = info.id; this._name = name; _game.StartInfo.FileName = javaPath; if (BMCLV2.Logger.debug) { _game.StartInfo.CreateNoWindow = true; _game.StartInfo.RedirectStandardOutput = true; _game.StartInfo.RedirectStandardError = true; } _info = info; this._li = li; this.Extarg = extarg; this._info = info; }
protected void OnLoginFinishEvent(LoginInfo logininfo) { LoginFinishEventHandler handler = LoginFinishEvent; if (handler != null) BmclCore.Invoke(new Action(() => handler(logininfo))); }
private void LoginThreadOnLoginFinishEvent(LoginInfo loginInfo) { if (loginInfo.Suc) { GridConfig.SaveConfig(); var username = loginInfo.UN; try { var javaPath = GridConfig.txtJavaPath.Text; var javaXmx = GridConfig.txtJavaXmx.Text; var selectVer = GridGame.listVer.SelectedItem.ToString(); var extArg = GridConfig.txtExtJArg.Text; BmclCore.Game = new Launcher.Launcher(javaPath, javaXmx, username, selectVer, BmclCore.GameInfo, extArg, loginInfo); BmclCore.Game.StateChangeEvent += Game_StateChangeEvent; BmclCore.Game.Gameexit += launcher_gameexit; BmclCore.Game.GameStartUp += Game_GameStartUp; } catch (Exception ex) { _starter.Topmost = false; _starter.Close(); MessageBox.Show("启动失败:" + ex.Message); Logger.log(ex); BmclCore.GameRunning = false; return; } } else { _starter.Topmost = false; MessageBox.Show("登录失败:" + loginInfo.Errinfo); Logger.log("登录失败" + loginInfo.Errinfo, Logger.LogType.Error); BmclCore.GameRunning = false; } if (BmclCore.Game == null) { _starter.Topmost = false; Logger.log("启动器初始化失败,放弃启动", Logger.LogType.Crash); BmclCore.GameRunning = false; } else { BmclCore.Game.Start(); this.Hide(); } }