protected bool HasOpenedChatLine(FastBitmapHSV bitmap, out int mode) { mode = 0; for (int posX = 0; posX < bitmap.Width; posX++) { var testPx = bitmap.GetPixel(posX, posChatBackY); bool isMatching = matchChatLineBack.IsMatching(testPx); if (!isMatching) { if (DebugLevel >= EDebugLevel.Verbose) { Console.WriteLine("{0} HasOpenedChatLine: failed match! ({1},{2})=({3}) vs filter({4})", ScannerName, posX, posChatBackY, testPx, matchChatLineBack); } return(false); } testPx = bitmap.GetPixel(posX, posNoChatBackY); isMatching = matchChatLineBack.IsMatching(testPx); if (isMatching) { if (DebugLevel >= EDebugLevel.Verbose) { Console.WriteLine("{0} HasOpenedChatLine: failed no match! ({1},{2})=({3}) vs filter({4})", ScannerName, posX, posNoChatBackY, testPx, matchChatLineBack); } return(false); } } for (int testMode = 1; testMode < posChatLineModeY.Length; testMode++) { var avgPx = ScreenshotUtilities.GetAverageColor(bitmap, new Rectangle(rectChatLine.X, posChatLineModeY[testMode], rectChatLine.Width, rectChatLine.Height)); bool isMatching = matchChatLine.IsMatching(avgPx) && !matchChatLineBack.IsMatching(avgPx); if (!isMatching) { if (DebugLevel >= EDebugLevel.Verbose) { Console.WriteLine("{0} HasOpenedChatLine: failed mode:{1}... ({2}) vs filter({3})", ScannerName, testMode, avgPx, matchChatLine); } } else { mode = testMode; return(true); } } return(false); }
protected void ScanSummonSelector(FastBitmapHSV bitmap, ScreenDataBase screenData) { var avgPx = ScreenshotUtilities.GetAverageColor(bitmap, rectSummonSelectorA); var iconFillPct = ScreenshotUtilities.CountFillPct(bitmap, rectSummonSelectorB, matchSummonIcon); var isAvgMatching = matchSummonBack.IsMatching(avgPx); var isIconMatching = (iconFillPct > 0.10f) && (iconFillPct < 0.35f); screenData.hasSummonSelection = isAvgMatching && isIconMatching; if (DebugLevel >= EDebugLevel.Simple) { Console.WriteLine("{0} ScanSummonSelector: {1}", ScannerName, screenData.hasSummonSelection); } if (DebugLevel >= EDebugLevel.Verbose) { Console.WriteLine(" avgPx: ({0}) vs ({1}) => {2}, fillIcon: {3} => {4}", avgPx, matchSummonBack, isAvgMatching, iconFillPct, isIconMatching); } }
protected bool HasOkButtonArea(FastBitmapHSV bitmap, ScreenData screenData) { FastPixelHSV[] avgPx = new FastPixelHSV[rectButtonPos.Length]; for (int idx = 1; idx < avgPx.Length; idx++) { avgPx[idx] = ScreenshotUtilities.GetAverageColor(bitmap, rectButtonPos[idx]); var scanOb = new ActionData(); scanOb.buttonColor = matchAvgRed.IsMatching(avgPx[idx]) ? EButtonColor.Red : matchAvgWhite.IsMatching(avgPx[idx]) ? EButtonColor.White : matchAvgSpec.IsMatching(avgPx[idx]) ? EButtonColor.Spec : EButtonColor.Unknown; if (scanOb.buttonColor != EButtonColor.Unknown) { float[] values = ExtractButtonData(bitmap, idx); scanOb.buttonType = (EButtonType)classifierButtons.Calculate(values, out float DummyPct); switch (scanOb.buttonColor) { case EButtonColor.Red: scanOb.isDisabled = avgPx[idx].GetValue() < 40; break; case EButtonColor.White: scanOb.isDisabled = avgPx[idx].GetValue() < 70; break; default: break; } } screenData.actions[idx] = scanOb; } if (screenData.actions[(int)EButtonPos.CombatReportOk].buttonColor == EButtonColor.Red && screenData.actions[(int)EButtonPos.CombatReportOk].buttonType == EButtonType.Ok && screenData.actions[(int)EButtonPos.CombatReportRetry].buttonColor == EButtonColor.White && (screenData.actions[(int)EButtonPos.CombatReportRetry].buttonType == EButtonType.Retry || screenData.actions[(int)EButtonPos.CombatReportRetry].buttonType == EButtonType.Next)) { screenData.mode = EMessageType.CombatReport; } else if (screenData.actions[(int)EButtonPos.CombatStart].buttonColor == EButtonColor.Red && screenData.actions[(int)EButtonPos.CombatStart].buttonType == EButtonType.Start && screenData.actions[(int)EButtonPos.CombatDetails].buttonColor == EButtonColor.Spec && (screenData.actions[(int)EButtonPos.CombatDetails].buttonType == EButtonType.Details)) { screenData.mode = EMessageType.CombatStart; } else if (screenData.actions[(int)EButtonPos.Center].buttonColor == EButtonColor.Red && screenData.actions[(int)EButtonPos.Center].buttonType == EButtonType.Ok) { screenData.mode = EMessageType.Ok; } else if (screenData.actions[(int)EButtonPos.CenterTwoLeft].buttonColor == EButtonColor.White && screenData.actions[(int)EButtonPos.CenterTwoLeft].buttonType == EButtonType.Cancel && screenData.actions[(int)EButtonPos.CenterTwoRight].buttonColor == EButtonColor.Red && screenData.actions[(int)EButtonPos.CenterTwoRight].buttonType == EButtonType.Ok) { screenData.mode = EMessageType.OkCancel; } else if (screenData.actions[(int)EButtonPos.Center].buttonColor == EButtonColor.White && screenData.actions[(int)EButtonPos.Center].buttonType == EButtonType.Close) { screenData.mode = EMessageType.Close; } if (DebugLevel >= EDebugLevel.Simple) { Console.WriteLine("{0} Mode: {1}", ScannerName, screenData.mode); } if (DebugLevel >= EDebugLevel.Verbose) { Console.WriteLine(" filterRed:({0}), filterWhite:({1}), filterSpec({2})", matchAvgRed, matchAvgWhite, matchAvgSpec); for (int idx = 1; idx < avgPx.Length; idx++) { Console.WriteLine(" [{0}]:({1}), color:{2}, class:{3}", (EButtonPos)idx, avgPx[idx], screenData.actions[idx].buttonColor, screenData.actions[idx].buttonType); } } return(screenData.mode != EMessageType.Unknown); }