static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new MainForm()); //コマンドライン引数の処理 SettingsArgsModel ARGS = new SettingsArgsModel(); foreach (string arg in args) { string argLower = arg.ToLower(); if (argLower.Equals("/d")) { ARGS.LoggerEnable = true; ARGS.LoggerLogLevel = LogLevelKind.INFO; } if (argLower.Equals("/vd")) { ARGS.LoggerVarDumpEnable = true; } if (MiscTool.IsRegexString(argLower, "/ll:([0-4])")) { List<string> reg = MiscTool.GetRegexString(argLower, "/ll:([0-4])"); ARGS.LoggerLogLevel = (LogLevelKind)int.Parse(reg[0]); } } //POL設定 PolTool pol = new PolTool(); if (PolTool.GetPolProcess().Count < 1) { MessageBox.Show("FF11を起動してください。", MiscTool.GetAppTitle(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); System.Environment.Exit(0);//プログラム終了 } if (!pol.NewPol()) { System.Environment.Exit(0);//プログラム終了 } if (pol.FFACE.Player.GetLoginStatus != LoginStatus.LoggedIn) { MessageBox.Show("キャラクター選択後に起動してください。", MiscTool.GetAppTitle(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); System.Environment.Exit(0);//プログラム終了 } //シフトキーでテストフォーム表示 if (Control.ModifierKeys == Keys.Shift) { //テストモード FFACETestForm testForm = new FFACETestForm(pol); testForm.ShowDialog(); System.Environment.Exit(0);//プログラム終了 } //メインフォーム表示 MainForm mainForm = new MainForm(pol, ARGS); mainForm.ShowDialog(); }
/// <summary> /// コンストラクタ /// </summary> public FFACEControl(PolTool iPOL, ChatTool iChat, LoggerTool iLogger) { this.pol = iPOL; this.fface = iPOL.FFACE; this.chat = iChat; this.logger = iLogger; this.MaxLoopCount = DEFAULT_MAX_LOOP_COUNT; this.UseEnternity = DEFAULT_USE_ENTERNITY; this.BaseWait = DEFAULT_BASE_WAIT; this.ChatWait = DEFAULT_CHAT_WAIT; }
/// <summary> /// コンストラクタ /// </summary> public EliteAPIControl(PolTool iPOL, ResourceTool iResource, ChatTool iChat) { this.pol = iPOL; this.api = iPOL.EliteAPI; this.chat = iChat; this.resource = iResource; this.MaxLoopCount = DEFAULT_MAX_LOOP_COUNT; this.UseEnternity = DEFAULT_USE_ENTERNITY; this.BaseWait = DEFAULT_BASE_WAIT; this.ChatWait = DEFAULT_CHAT_WAIT; }
/// <summary> /// コンストラクタ /// </summary> /// <param name="iFFACE"></param> /// <param name="iChat"></param> /// <param name="iSettings"></param> /// <param name="iLogger"></param> public HarakiriTool(PolTool iPol, ChatTool iChat, Settings iSettings, LoggerTool iLogger) { pol = iPol; fface = iPol.FFACE; chat = iChat; settings = iSettings; logger = iLogger; fishDB = new FishDB(logger); harakiriDB = new HarakiriDB(logger); control = new FFACEControl(pol, chat, logger); control.MaxLoopCount = Constants.MAX_LOOP_COUNT; control.UseEnternity = settings.UseEnternity; control.BaseWait = settings.Global.WaitBase; control.ChatWait = settings.Global.WaitChat; this.RunningStatus = RunningStatusKind.Stop; this.HarakiriStatus = HarakiriStatusKind.Normal; }
/// <summary> /// PolTool ChangeStatusイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PolTool_ChangeStatus(object sender, PolTool.ChangeStatusEventArgs e) { if (e.PolStatus == PolTool.PolStatusKind.LoggedIn) { setMessage(string.Format("{0}でログインしました", this.PlayerName)); } else { FishingAbort(); setFishingStatus(FishingStatusKind.Error); if (e.PolStatus == PolTool.PolStatusKind.CharacterLoginScreen) { setMessage("キャラクターを選択してください"); } else if (e.PolStatus == PolTool.PolStatusKind.Unknown) { setMessage("FF11が終了しました、再起動してください"); } } }
/// <summary> /// コンストラクタ /// </summary> /// <param name="iFFACE"></param> /// <param name="iChat"></param> /// <param name="iSettings"></param> /// <param name="iLogger"></param> public FishingTool(PolTool iPol, ChatTool iChat, Settings iSettings, LoggerTool iLogger) { pol = iPol; pol.ChangeStatus += new PolTool.ChangeStatusEventHandler(this.PolTool_ChangeStatus); fface = iPol.FFACE; chat = iChat; settings = iSettings; logger = iLogger; FishDB = new FishDB(logger); fishHistoryDB = new FishHistoryDB(this.PlayerName,this.EarthDateTime, logger); FishHistoryDBModel history = fishHistoryDB.SelectDayly(this.PlayerName, this.EarthDateTime); this.TimeElapsed = history.TimeElapsed; control = new FFACEControl(pol, chat, logger); control.MaxLoopCount = Constants.MAX_LOOP_COUNT; control.UseEnternity = settings.UseEnternity; control.BaseWait = settings.Global.WaitBase; control.ChatWait = settings.Global.WaitChat; this.RunningStatus = RunningStatusKind.Stop; this.FishingStatus = FishingStatusKind.Normal; }
/// <summary> /// PolTool ChangeStatusイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PolTool_ChangeStatus(object sender, PolTool.ChangeStatusEventArgs e) { logger.Output(string.Format("POLステータスが{0}に変更された", e.PolStatus)); if (e.PolStatus == PolTool.PolStatusKind.LoggedIn) { //プレイヤーが描画されるまで待機 logger.Output(LogLevelKind.DEBUG, "プレイヤーのIsRendered待機"); while (fface.NPC.IsRendered(fface.Player.ID) == false) { Thread.Sleep(100); } Thread.Sleep(10000); //初期化 logger.Output(LogLevelKind.DEBUG, "再起動開始"); startupFlg = true; constructor(pol); initForm(); startupFlg = false; //画面ロック解除 lockControl(false); loginFlg = true; flashWindow();//画面フラッシュ } else if (e.PolStatus == PolTool.PolStatusKind.CharacterLoginScreen) { loginFlg = false; lockControl(true);//コントロールロック unload(); flashWindow();//画面フラッシュ } else if (e.PolStatus == PolTool.PolStatusKind.Unknown) { flashWindow();//画面フラッシュ MessageBox.Show("FF11が終了しました。EnjoyFishingは終了します。", MiscTool.GetAppTitle(), MessageBoxButtons.OK, MessageBoxIcon.Error); unload(); System.Environment.Exit(0);//プログラム終了 } }
private bool updatedbFlg = false; //DB更新中のフラグ #endregion Fields #region Constructors /// <summary> /// コンストラクタ /// </summary> public MainForm(PolTool iPol, SettingsArgsModel iArgs) { startupFlg = true; InitializeComponent(); args = iArgs; constructor(iPol); }
/// <summary> /// コンストラクタ処理部 /// </summary> /// <param name="iPol"></param> private void constructor(PolTool iPol) { //PolTool初期設定 pol = iPol; pol.ChangeStatus += new PolTool.ChangeStatusEventHandler(this.PolTool_ChangeStatus); //FFACE初期設定 fface = iPol.FFACE; //LoggerTool初期設定 logger = new LoggerTool(MiscTool.GetAppAssemblyName(), pol.FFACE.Player.Name); logger.Enable = args.LoggerEnable; logger.OutputLogLevel = args.LoggerLogLevel; logger.EnableVarDump = args.LoggerVarDumpEnable; logger.Output(LogLevelKind.INFO, string.Format("===== {0} {1} =====", MiscTool.GetAppAssemblyName(), MiscTool.GetAppVersion())); logger.Output(LogLevelKind.INFO, string.Format("デバッグログ:{0} ログレベル:{1} 変数出力:{2}", args.LoggerEnable, args.LoggerLogLevel, args.LoggerVarDumpEnable)); logger.Output(LogLevelKind.INFO, string.Format("プロセス({0})にアタッチしました", pol.ProcessID)); //Settings初期設定 settings = new Settings(iPol.FFACE.Player.Name); //ChatTool初期設定 chat = new ChatTool(iPol.FFACE); chat.ReceivedCommand += new ChatTool.ReceivedCommandEventHandler(this.ChatTool_ReceivedCommand); logger.Output(LogLevelKind.DEBUG, "ChatTool起動"); //FishingTool初期設定 fishing = new FishingTool(iPol, chat, settings, logger); fishing.Fished += new FishingTool.FishedEventHandler(this.FishingTool_Fished); fishing.ChangeMessage += new FishingTool.ChangeMessageEventHandler(this.FishingTool_ChangeMessage); fishing.ChangeStatus += new FishingTool.ChangeStatusEventHandler(this.FishingTool_ChangeStatus); fishing.CaughtFishesUpdate += new FishingTool.CaughtFishesUpdateEventHandler(this.FishingTool_CaughtFishesUpdate); logger.Output(LogLevelKind.DEBUG, "FishingTool起動"); //HarakiriTool初期設定 harakiri = new HarakiriTool(iPol, chat, settings, logger); harakiri.HarakiriOnce += new HarakiriTool.HarakiriOnceEventHandler(this.HarakiriTool_HarakiriOnce); harakiri.ChangeMessage += new HarakiriTool.ChangeMessageEventHandler(this.HarakiriTool_ChangeMessage); harakiri.ChangeStatus += new HarakiriTool.ChangeStatusEventHandler(this.HarakiriTool_ChangeStatus); logger.Output(LogLevelKind.DEBUG, "HarakiriTool起動"); //FFACEControl初期設定 control = new FFACEControl(pol, chat, logger); control.MaxLoopCount = Constants.MAX_LOOP_COUNT; control.UseEnternity = settings.UseEnternity; control.BaseWait = settings.Global.WaitBase; control.ChatWait = settings.Global.WaitChat; logger.Output(LogLevelKind.DEBUG, "FFACEControl起動"); //監視スレッド起動 thMonitor = new Thread(threadMonitor); thMonitor.Start(); logger.Output(LogLevelKind.DEBUG, "監視スレッド起動"); //DB fishDB = new FishDB(logger); fishHistoryDB = new FishHistoryDB(fishing.PlayerName, fishing.EarthDateTime, logger); harakiriDB = new HarakiriDB(logger); //古いデータをコンバート converter(); //DB更新 updatedb = new UpdateDBTool(settings, logger); updatedb.ReceiveMessage += new UpdateDBTool.ReceiveMessageEventHandler(this.UpdateDBTool_ReceiveMessage); updatedb.NewerVersion += new UpdateDBTool.NewerVersionEventHandler(this.UpdateDBTool_NewerVersion); }