/// <summary> /// GamersOne IDとパスワードを使用してゲームを起動します。 /// ゲームクライアントのアップデートがある場合にはランチャーを起動します。 /// </summary> /// <param name="id">GamersOneID</param> /// <param name="password">アカウントパスワード</param> public new static void startGame(string id, string password) { GamersOneLoginController clsLoginCon = new GamersOneLoginController(); clsLoginCon.initialize(); System.Text.Encoding enc = System.Text.Encoding.GetEncoding("UTF-8"); string url; string param = ""; HttpWebResponse res; string html; // ネットワーク接続を試みる while (!LoginController.isAliveNetwork()) { SimpleLogger.WriteLine("does not connect network."); DialogResult dgRes = MessageBox.Show("ネットワークに接続されていないため、処理を続行できません。", "Trickster Tools", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (dgRes == DialogResult.Cancel) { return; } } // パラメータ param = @"fUserID=" + ProgramController.UrlEncode(id, Encoding.GetEncoding("UTF-8")); param += "&fUserPW=" + ProgramController.UrlEncode(password, Encoding.GetEncoding("UTF-8")); param += "&send.x=1&send.y=1"; try { /* * * GamersOneトリックスタートップページに接続 * */ url = "http://www.gamers1.jp/contents/trickster/"; clsLoginCon.doRequest(url, LoginController.RequestMethod.GET, null, 60000, null); // レスポンスの取得と読み込み res = clsLoginCon.getResponse(); /* * * GamersOneにログイン * */ url = "http://www.gamers1.jp/contents/trickster/mall/process/login.php"; clsLoginCon.doRequest(url, LoginController.RequestMethod.POST, param, 5000, "http://www.gamers1.jp/contents/trickster/"); // レスポンスの取得と読み込み res = clsLoginCon.getResponse(); // set-cookieが存在するか確認 int i = 0, max = 0, chk = 0; max = res.Headers.Count; while (i < max) { if (res.Headers.Keys[i] == "Set-Cookie") { chk = 1; break; } i++; } if (chk < 1 || res.Headers["Set-Cookie"].IndexOf("loginSessionKey=") < 0) { clsLoginCon.ResponseClose(); SimpleLogger.WriteLine("could not find 'Set-Cookies' in HTTP response header."); MessageBox.Show("ログインできませんでした。", "Trickster Tools", MessageBoxButtons.OK, MessageBoxIcon.Error); clsLoginCon.ResponseClose(); clsLoginCon.initialize(); return; } /* * * GamersOneトリックスタートップページに接続 * */ url = "http://www.gamers1.jp/contents/trickster/"; clsLoginCon.doRequest(url, LoginController.RequestMethod.GET, null, 5000, "http://www.gamers1.jp/contents/trickster/"); // レスポンスの取得と読み込み res = clsLoginCon.getResponse(); chk = 0; if (res.Cookies.Count > 0) { foreach (Cookie c in res.Cookies) { if (c.Name == "loginSessionKey") { chk = 1; break; } } } if (chk < 1 || res.Cookies["loginSessionKey"].Value.Length <= 0) { SimpleLogger.WriteLine("Failed to login gamers1.jp."); MessageBox.Show("GamersOne トリックスター にログインできませんでした。", "Trickster Tools", MessageBoxButtons.OK, MessageBoxIcon.Error); clsLoginCon.ResponseClose(); clsLoginCon.initialize(); return; } /* * * GamersOneからTricksterへ起動を投げる * */ url = "http://www.gamers1.jp/contents/trickster/gameloader/gamestart.php"; clsLoginCon.doRequest(url, LoginController.RequestMethod.GET, null, 5000, "http://www.gamers1.jp/contents/trickster/"); // レスポンスの取得と読み込み res = clsLoginCon.getResponse(); html = clsLoginCon.getResponseStream(); /* * 取得したHTMLからランチャー起動用IDとキーを取得する * <html xmlns="http://www.w3.org/1999/xhtml"> * * <head> * <meta http-equiv="Content-Type" content="text/html; charset=Shift-JIS" /> * <title>トリックスター0 -ラブ-起動</title> * <script language="JScript" type="text/javascript"><!-- * function execGame() { * * * * var objActiveX = document.activeXObj * var dd = new Date(); * objActiveX.loader.UA = 'LV:0000000'; ←★ クライアント起動時のID * objActiveX.loader.PA = '0000000000'; ←★ クライアント起動時のパスワード * objActiveX.loader.DS = 'ee2d0ed0b6360caeb8c28201fbf8bcd4'; * objActiveX.loader.go(); * * * window.setTimeout("closeWin()",500); * } * * function closeWin() { * window.close(); * } * --></script> * * </head> * <body background="./img/bg.jpg" onload="execGame()"> * <br /> * * * <form name="activeXObj" action=""> * <object id="loader" width="0" height="0" * CLASSID="CLSID:D85BD1B8-0000-4C5B-80D1-04AF514D200A" * codebase="https://www.gamers1.jp/contents/trickster/trickloader.cab#Version=1,0,0,001"> * </object> * </form> * * </body> * </html> * */ int seekStart, seekEnd; string seekStartString, seekEndString; string startID; string startKey; seekStartString = "objActiveX.loader.UA = '"; seekEndString = "';"; seekStart = html.IndexOf(seekStartString) + seekStartString.Length; seekEnd = html.IndexOf(seekEndString, seekStart) - seekStart; startID = html.Substring(seekStart, seekEnd); seekStartString = "objActiveX.loader.PA = '"; seekStart = html.IndexOf(seekStartString) + seekStartString.Length; seekEnd = html.IndexOf(seekEndString, seekStart) - seekStart; startKey = html.Substring(seekStart, seekEnd); /* * * ランチャー起動 * */ clsLoginCon.runGame(startID, startKey); } catch (WebException we) { SimpleLogger.WriteLine(we.GetType().ToString() + Environment.NewLine + we.Message); //MessageBox.Show("例外エラー:" + we.GetType().ToString() + Environment.NewLine + we.Message.ToString(), "Trickster Tools", MessageBoxButtons.OK, MessageBoxIcon.Hand); throw we; } finally { clsLoginCon.ResponseClose(); clsLoginCon.initialize(); } }
private void notifyIcon_MouseClick(object sender, MouseEventArgs e) { TricksterTools.Library.Win32API.SetForegroundWindow(new System.Runtime.InteropServices.HandleRef(this, this.Handle)); Point mp = Control.MousePosition; /** ハッシュテーブルからIDを読み込む **/ // 保存元のファイル名 //string fileName = "config.txt"; //System.Collections.Hashtable accounts = Program.loadConfig(fileName); System.Collections.SortedList links = SettingController.Links; if (e.Button == MouseButtons.Left) { #region 左クリック時 this.contextMenuStrip_Left.Items.Clear(); if (AccountController.AccountData.Count == 0) { this.contextMenuStrip_Left.Items.Add("No Registered ID"); this.contextMenuStrip_Left.Enabled = false; } else { this.contextMenuStrip_Left.Enabled = true; IEnumerator ienum = AccountController.AccountData.GetEnumerator(); while (ienum.MoveNext()) { Accounts.AccountProperties acprop = (Accounts.AccountProperties)ienum.Current; string ID = acprop.ID; string Password = acprop.Password; ToolStripMenuItem items = new ToolStripMenuItem(); items.Text = ID; if (acprop.Site == Accounts.AccountProperties.LoginSite.Official) { items.Image = (Image)Properties.Resources.official.ToBitmap(); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.HanGame) { items.Image = (Image)Properties.Resources.hangame.ToBitmap(); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.AtGames) { items.Image = (Image)Properties.Resources.atgames.ToBitmap(); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.Gamers1) { //items.Image = (Image)Properties.Resources.lievo.ToBitmap(); items.Image = (Image)Properties.Resources.gamers1.ToBitmap(); } else { items.Image = (Image)Properties.Resources.official.ToBitmap(); } items.Click += delegate { if (!Common.isInstalled()) // クライアントがインストールされているか { MessageBox.Show("トリックスター クライアントがインストールされていません。" + Environment.NewLine + "クライアントプログラムをインストールして再度実行してください。", "TSLoginManager", MessageBoxButtons.OK, MessageBoxIcon.Warning); //MessageBox.Show("TRICKSTER client program is not installed in this computer." + Environment.NewLine + // "Please try to install and run.", "TSLoginManager"); } else { SimpleLogger.Write("auto login start..."); //LoginController.startGame(ID, Password); if (acprop.Site == Accounts.AccountProperties.LoginSite.Official) { SimpleLogger.WriteLine("Official"); OfficialLoginController.setPluginHost(this); OfficialLoginController.startGame(ID, Password); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.HanGame) { SimpleLogger.WriteLine("HanGame"); HanGameLoginController.setPluginHost(this); HanGameLoginController.startGame(ID, Password); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.AtGames) { SimpleLogger.WriteLine("AtGames"); AtGamesLoginController.setPluginHost(this); AtGamesLoginController.startGame(ID, Password); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.Gamers1) { SimpleLogger.WriteLine("Lievo"); //LievoLoginController.setPluginHost(this); //LievoLoginController.startGame(ID, Password); GamersOneLoginController.setPluginHost(this); GamersOneLoginController.startGame(ID, Password); } else { OfficialLoginController.setPluginHost(this); OfficialLoginController.startGame(ID, Password); } } }; this.contextMenuStrip_Left.Items.Add(items); } } //this.notifyIcon.ContextMenuStrip = this.contextMenuStrip_Left; //this.contextMenuStrip_Left.Show(mp.X - contextMenuStrip_Left.Width, mp.Y); this.contextMenuStrip_Left.Show(this, PointToClient(Cursor.Position)); #endregion } else if (e.Button == MouseButtons.Right) { #region 右クリック時 //this.ToolStripMenuItem_Right_Edit.DropDownItems.Clear(); //this.ToolStripMenuItem_Right_Edit.DisplayStyle = ToolStripItemDisplayStyle.Text; this.ToolStripMenuItem_Right_Delete.DropDownItems.Clear(); this.ToolStripMenuItem_Right_Delete.DisplayStyle = ToolStripItemDisplayStyle.Text; this.ToolStripMenuItem_Right_Plugins.DropDownItems.Clear(); this.ToolStripMenuItem_Right_Plugins.DisplayStyle = ToolStripItemDisplayStyle.Text; this.ToolStripMenuItem_Right_Links.DropDownItems.Clear(); this.ToolStripMenuItem_Right_Links.DisplayStyle = ToolStripItemDisplayStyle.Text; this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDownItems.Clear(); this.ToolStripMenuItem_Right_Tool_PluginInfo.DisplayStyle = ToolStripItemDisplayStyle.Text; #region アカウント削除用一覧 if (AccountController.AccountData.Count == 0) { //this.ToolStripMenuItem_Right_Edit.DropDownItems.Add("No Registered ID"); //this.ToolStripMenuItem_Right_Edit.Enabled = false; //this.ToolStripMenuItem_Right_Delete.DropDownItems.Add("No Registered ID"); this.ToolStripMenuItem_Right_Delete.Enabled = false; } else { //this.ToolStripMenuItem_Right_Edit.Enabled = true; //this.ToolStripMenuItem_Right_Edit.DropDown.Enabled = true; this.ToolStripMenuItem_Right_Delete.Enabled = true; this.ToolStripMenuItem_Right_Delete.DropDown.Enabled = true; this.contextMenuStrip_Left.Enabled = true; IEnumerator ienum = AccountController.AccountData.GetEnumerator(); while (ienum.MoveNext()) { //ToolStripMenuItem edit_items = new ToolStripMenuItem(); ToolStripMenuItem del_items = new ToolStripMenuItem(); Accounts.AccountProperties acprop = (Accounts.AccountProperties)ienum.Current; string ID = acprop.ID; //string Password = accounts[ID].ToString(); //edit_items.Text = ID; del_items.Text = ID; /* * edit_items.Click += delegate * { * EditForm edtFrm = new EditForm(ID); * edtFrm.Show(); // フォームの表示 * }; * this.ToolStripMenuItem_Right_Edit.DropDownItems.Add(edit_items); */ if (acprop.Site == Accounts.AccountProperties.LoginSite.Official) { del_items.Image = (Image)Properties.Resources.official.ToBitmap(); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.HanGame) { del_items.Image = (Image)Properties.Resources.hangame.ToBitmap(); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.AtGames) { del_items.Image = (Image)Properties.Resources.atgames.ToBitmap(); } else if (acprop.Site == Accounts.AccountProperties.LoginSite.Gamers1) { del_items.Image = (Image)Properties.Resources.lievo.ToBitmap(); } else { del_items.Image = (Image)Properties.Resources.official.ToBitmap(); } del_items.Click += delegate { DialogResult diagres = MessageBox.Show("ID: \" " + ID + " \" を削除しようとしています。" + Environment.NewLine + "よろしいですか?", "TSLoginManager", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); if (diagres == DialogResult.No) { return; } ProgramController.AController.delete(ID, acprop.Site); /* * この時点でもアカウント情報をファイルに保存する */ string filename = Environment.CurrentDirectory + @"\accounts.dat"; if (AccountController.isLoadedAccount && (AccountController.AccountData.Count > 0)) { ProgramController.AController.saveAccounts(filename, AccountController.MasterKey); } }; this.ToolStripMenuItem_Right_Delete.DropDownItems.Add(del_items); } } #endregion #region プラグイン一覧 if (Program.plugins.Length == 0) { //this.ToolStripMenuItem_Right_Plugins.DropDownItems.Add("No Plugin"); this.ToolStripMenuItem_Right_Plugins.Enabled = false; } else { this.ToolStripMenuItem_Right_Plugins.Enabled = true; this.ToolStripMenuItem_Right_Plugins.DropDown.Enabled = true; foreach (TricksterTools.Plugins.IPlugin plugin in Program.plugins) { ToolStripMenuItem_Plugin PluginItems = new ToolStripMenuItem_Plugin(); PluginItems.setPluginName(plugin.GetType().Name, plugin.Name); PluginItems.Click += delegate { PluginController.PluginRun(Program.plugins, PluginItems.ClassName); }; this.ToolStripMenuItem_Right_Plugins.DropDownItems.Add(PluginItems); } } #endregion #region プラグイン情報 if (Program.plugins.Length == 0) { //this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDownItems.Add("No Plugin"); this.ToolStripMenuItem_Right_Tool_PluginInfo.Enabled = false; } else { this.ToolStripMenuItem_Right_Tool_PluginInfo.Enabled = true; this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDown.Enabled = true; foreach (TricksterTools.Plugins.IPlugin plugin in Program.plugins) { ToolStripMenuItem_Plugin PluginInfoItems = new ToolStripMenuItem_Plugin(); PluginInfoItems.setPluginName(plugin.GetType().Name, plugin.Name); PluginInfoItems.Click += delegate { //PluginInfoForm pluginInfoForm = new PluginInfoForm(plugin); PluginInfoForm pluginInfoForm = new PluginInfoForm(PluginController.getPluginInfo(Program.plugins, PluginInfoItems.ClassName)); pluginInfoForm.Show(); pluginInfoForm.Owner = this; }; this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDownItems.Add(PluginInfoItems); } } #endregion #region リンク一覧 if (links.ContainsKey("__TSLM_NULL__")) { this.ToolStripMenuItem_Right_Links.DropDownItems.Add("No Links"); this.ToolStripMenuItem_Right_Links.Enabled = false; } else { this.ToolStripMenuItem_Right_Links.Enabled = true; this.ToolStripMenuItem_Right_Links.DropDown.Enabled = true; foreach (string key in links.Keys) { ToolStripMenuItem link_items = new ToolStripMenuItem(); string SiteName = key; link_items.Text = SiteName; link_items.Click += delegate { System.Diagnostics.Process.Start(links[SiteName].ToString()); }; this.ToolStripMenuItem_Right_Links.DropDownItems.Add(link_items); } } #endregion #region プラグイン情報 //this.notifyIcon.ContextMenuStrip = this.contextMenuStrip_Right; this.Activate(); this.contextMenuStrip_Right.Show(mp.X, mp.Y + 275); //this.contextMenuStrip_Right.Show(this, Cursor.Position.X - this.Location.X, Cursor.Position.X - this.Location.X); //this.contextMenuStrip_Right.Show(PointToScreen(Cursor.Position)); ToolStripDropDownMenu tsddm_r_del = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Delete.DropDown; tsddm_r_del.ShowImageMargin = true; ToolStripDropDownMenu tsddm_r_link = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Links.DropDown; tsddm_r_link.ShowImageMargin = false; ToolStripDropDownMenu tsddm_r_plugin = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Plugins.DropDown; tsddm_r_plugin.ShowImageMargin = false; ToolStripDropDownMenu tsddm_r_tool = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Tool.DropDown; tsddm_r_tool.ShowImageMargin = false; ToolStripDropDownMenu tsddm_r_tool_setting = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Tool_Settings.DropDown; tsddm_r_tool_setting.ShowImageMargin = false; ToolStripDropDownMenu tsddm_r_tool_plguininfo = (ToolStripDropDownMenu)this.ToolStripMenuItem_Right_Tool_PluginInfo.DropDown; tsddm_r_tool_plguininfo.ShowImageMargin = false; #endregion #endregion } }