{"record":{"id":"ea0d19056a120002","repo":"babalae/better-genshin-impact","slug":"error-ea0d19","errorCode":null,"errorMessage":"请先打开合成界面。","messagePattern":"请先打开合成界面。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs","lineNumber":255,"sourceCode":"            var header = headers[i]?.Trim();\n            if (candidates.Any(candidate => string.Equals(header, candidate, StringComparison.OrdinalIgnoreCase)))\n            {\n                return i;\n            }\n        }\n\n        return -1;\n    }\n\n    /// <summary>\n    /// 确认当前界面是合成界面。\n    /// </summary>\n    /// <exception cref=\"InvalidOperationException\">当前不在合成界面时抛出。</exception>\n    private void EnsureInCraftingUi()\n    {\n        if (!IsInCraftingUi())\n        {\n            throw new InvalidOperationException(\"请先打开合成界面。\");\n        }\n    }\n\n    /// <summary>\n    /// 判断当前是否处于合成界面。\n    /// </summary>\n    /// <returns>处于合成界面时返回 true。</returns>\n    private bool IsInCraftingUi()\n    {\n        return ContainsText(Rect1080(40, 960, 720, 105), \"筛选\")\n               && ContainsText(Rect1080(0, 0, 260, 95), \"合成\");\n    }\n\n    /// <summary>\n    /// 选择材料筛选类型，失败时抛出异常。\n    /// </summary>\n    /// <param name=\"materialType\">材料筛选类型。</param>\n    /// <returns>异步任务。</returns>","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs#L237-L273","documentation":"Thrown as InvalidOperationException by CraftMaterialTask.EnsureInCraftingUi when IsInCraftingUi() returns false. The method checks two OCR text regions ('筛选' at bottom and '合成' at top-left) to confirm the game is on the crafting (alchemy) bench screen. If either text is missing, the task aborts before attempting any clicks.","triggerScenarios":"Calling Start(ct) when the game is on a different screen (inventory, map, Paimon menu). The crafting bench was not opened, or it was closed between navigation and task start. The screenshot resolution is non-1080p and the Rect1080 scaling mis-crops the text regions.","commonSituations":"The user started the task from outside the crafting screen. A timing issue where the crafting UI was still loading. The game window resolution or scale differs from expected, causing OCR to miss the anchor text. Game UI language is not Chinese so '合成'/'筛选' are not found.","solutions":["Navigate the character to an alchemy bench and open the crafting screen before starting the task.","Add a wait/retry loop to let the crafting UI fully render before calling Start.","Ensure the game language is set to Chinese and the resolution is 1080p or scales correctly."],"exampleFix":"// before\nvar task = new CraftMaterialTask(\"树脂\", 5);\nawait task.Start(ct); // throws if not on crafting screen\n\n// after\n// ensure crafting screen is open first, optionally with a retry loop\nawait WaitForCraftingUiAsync(ct);\nvar task = new CraftMaterialTask(\"树脂\", 5);\nawait task.Start(ct);","handlingStrategy":"validation","validationCode":"// Before starting, confirm crafting UI via OCR\nif (!ContainsText(craftingFilterRect, \"筛选\") || !ContainsText(craftingTitleRect, \"合成\"))\n{\n    // open crafting bench first\n}","typeGuard":"null","tryCatchPattern":"try { await task.Start(ct); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"合成界面\")) { /* navigate to alchemy bench, retry */ }","preventionTips":["Always navigate to and open the crafting bench before starting the task.","Add a wait for the crafting UI to fully render."],"tags":["crafting","ui-state","ocr","precondition"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}