Skip to content

Commit

Permalink
Merge pull request #540 from taiwenlee/master
Browse files Browse the repository at this point in the history
Fixed 5.2 artifact inventory UI change bug
  • Loading branch information
Cupcak3 authored Nov 23, 2024
2 parents 36e8075 + 980b92e commit 57230ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion InventoryKamera/scraping/ArtifactScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void ScanArtifacts(int count = 0)
Navigation.Wait(1);
}
// Scroll back one to keep it from getting too crazy
if (page % 3 == 0)
if (page % 12 == 0)
{
Logger.Debug("Scrolled back one");
Navigation.sim.Mouse.VerticalScroll(1);
Expand Down
21 changes: 15 additions & 6 deletions InventoryKamera/scraping/InventoryScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,15 @@ internal string CurrentSortingMethod()
using (var brush = new SolidBrush(Color.Black))
{
// Fill Top region
g.FillRectangle(brush, 0, 0, processedScreenshot.Width, (int)(processedScreenshot.Height * 0.09));
switch (inventoryPage)
{
case InventoryPage.Artifacts:
g.FillRectangle(brush, 0, 0, processedScreenshot.Width, (int)(processedScreenshot.Height * 0.143));
break;
default:
g.FillRectangle(brush, 0, 0, processedScreenshot.Width, (int)(processedScreenshot.Height * 0.09));
break;
}

// Fill Left region
g.FillRectangle(brush, 0, 0, (int)(processedScreenshot.Width * 0.05), processedScreenshot.Height);
Expand All @@ -402,11 +410,12 @@ internal string CurrentSortingMethod()
List<Rectangle> rectangles;
int cols, rows, itemCount, counter = 0;
double weight = 0;
int itemPerPage = inventoryPage == InventoryPage.Artifacts ? 32 : 40;
do
{
(rectangles, cols, rows) = ProcessScreenshot(processedScreenshot, weight);
itemCount = rows * cols;
if (itemCount != 40 && !acceptLess)
if (itemCount != itemPerPage && !acceptLess)
{
Logger.Warn("Unable to locate full page of weapons with weight {0}", weight);
Logger.Warn("Detected {0} rows and {1} columns of items", rows, cols);
Expand All @@ -425,14 +434,14 @@ internal string CurrentSortingMethod()
}
else break;

if (itemCount <= 40)
if (itemCount <= 32)
weight += 0.125;
else
{ weight -= 0.095; ++counter; }
weight = Math.Min(weight, 1);
rectangles = null;
}
while (itemCount != 40 && weight < 1 && counter < 25);
while (itemCount != itemPerPage && weight < 1 && counter < 25);

if (Properties.Settings.Default.LogScreenshots)
{
Expand All @@ -446,7 +455,7 @@ internal string CurrentSortingMethod()

if (rectangles == null)
{
Logger.Warn("Could not find 40 items in inventory. Re-using previous item page.");
Logger.Warn("Could not find {0} items in inventory. Re-using previous item page.", itemPerPage);

return prevRect == null ?
throw new ArgumentNullException("Could not find first page of items!")
Expand Down Expand Up @@ -516,7 +525,7 @@ internal static Bitmap GetLockedBitmap(Bitmap card)
{
return GenshinProcesor.CopyBitmap(card,
new Rectangle(
x: (int)(card.Width * 0.855),
x: (int)(card.Width * 0.75),
y: (int)(card.Height * (Navigation.IsNormal ? 0.353 : 0.309)),
width: (int)(card.Width * 0.0955),
height: (int)(card.Height * (Navigation.IsNormal ? 0.055 : 0.0495))));
Expand Down

0 comments on commit 57230ad

Please sign in to comment.