Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: Scan Recently Obtained Artifacts #542

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions InventoryKamera/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<setting name="Slot1Key" serializeAs="String">
<value>1</value>
</setting>
<setting name="SortByObtained" serializeAs="String">
<value>0</value>
</setting>
</InventoryKamera.Properties.Settings>
</userSettings>
<runtime>
Expand Down
14 changes: 13 additions & 1 deletion InventoryKamera/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions InventoryKamera/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,8 @@
<Setting Name="Slot1Key" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="SortByObtained" Type="System.Decimal" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
10 changes: 10 additions & 0 deletions InventoryKamera/game/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,16 @@ internal static void ClearArtifactFilters()
SystemWait(Speed.Fast);
}

internal static void ChangeArtifactSortObtained()
{
var x = 0.6437 * GetWidth();
var y = (IsNormal ? 0.1278 : 0.1150) * GetHeight();

Click((int)x, (int)y);

SystemWait(Speed.Slow);
}

public enum Speed
{
Slowest,
Expand Down
30 changes: 27 additions & 3 deletions InventoryKamera/scraping/ArtifactScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ArtifactScraper()
{
inventoryPage = InventoryPage.Artifacts;
SortByLevel = Properties.Settings.Default.MinimumArtifactLevel > 0;
SortByObtained = (int) Properties.Settings.Default.SortByObtained;
}

public void ScanArtifacts(int count = 0)
Expand All @@ -27,6 +28,8 @@ public void ScanArtifacts(int count = 0)
int page = 1;
var (rectangles, cols, rows) = GetPageOfItems(page);
int fullPage = cols * rows;
// lowers the artifact count if user is scanning in recently obtained pages
artifactCount = (SortByObtained * fullPage <= artifactCount && SortByObtained > 0) ? SortByObtained * fullPage : artifactCount;
int totalRows = (int)Math.Ceiling(artifactCount / (decimal)cols);
int cardsQueued = 0;
int rowsQueued = 0;
Expand All @@ -36,7 +39,8 @@ public void ScanArtifacts(int count = 0)

Logger.Info("Found {0} for artifact count.", artifactCount);

ClearFilters();
SetSort();
ClearFilters();

//if (SortByLevel)
//{
Expand Down Expand Up @@ -132,8 +136,9 @@ public void ScanArtifacts(int count = 0)
Navigation.sim.Mouse.VerticalScroll(-1);
Navigation.Wait(1);
}
// Scroll back one to keep it from getting too crazy
if (page % 12 == 0)
// Scroll back one to keep it from getting too crazy
var rollbackPeriod = Navigation.IsNormal ? 12 : 3;
if (page % rollbackPeriod == 0)
{
Logger.Debug("Scrolled back one");
Navigation.sim.Mouse.VerticalScroll(1);
Expand Down Expand Up @@ -164,6 +169,25 @@ private void ClearFilters()
}
}

private void SetSort()
{
using (var x = Navigation.CaptureRegion(
x: (int)( 0.6250 * Navigation.GetWidth()),
y: (int)((Navigation.IsNormal ? 0.1111 : 0.1000) * Navigation.GetHeight()),
width: (int)( 0.0375 * Navigation.GetWidth()),
height: (int)(0.0347 * Navigation.GetHeight())))
{
//Navigation.DisplayBitmap(x);
Color sortObtainedTrue = Color.FromArgb(255, 224, 198, 147);
Color sortObtainedStatus = x.GetPixel((int)x.Width / 2,(int) x.Height / 2);
var sortObtained = GenshinProcesor.CompareColors(sortObtainedTrue, sortObtainedStatus);
if( SortByObtained > 0 ^ sortObtained)
{
Navigation.ChangeArtifactSortObtained();
}
}
}

public async void QueueScan(int id)
{
var card = GetItemCard();
Expand Down
14 changes: 4 additions & 10 deletions InventoryKamera/scraping/InventoryScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ internal class InventoryScraper

protected bool SortByLevel = false;

protected int SortByObtained = 0;

protected readonly List<InventoryPage> materialPages;

private List<Rectangle> prevRect;
Expand Down Expand Up @@ -386,15 +388,7 @@ internal string CurrentSortingMethod()
using (var brush = new SolidBrush(Color.Black))
{
// Fill Top region
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;
}
g.FillRectangle(brush, 0, 0, processedScreenshot.Width, (int)(processedScreenshot.Height * 0.09));

// Fill Left region
g.FillRectangle(brush, 0, 0, (int)(processedScreenshot.Width * 0.05), processedScreenshot.Height);
Expand All @@ -410,7 +404,7 @@ internal string CurrentSortingMethod()
List<Rectangle> rectangles;
int cols, rows, itemCount, counter = 0;
double weight = 0;
int itemPerPage = inventoryPage == InventoryPage.Artifacts ? 32 : 40;
int itemPerPage = (inventoryPage != InventoryPage.Artifacts || !Navigation.IsNormal) ? 40 : 32;
do
{
(rectangles, cols, rows) = ProcessScreenshot(processedScreenshot, weight);
Expand Down
33 changes: 33 additions & 0 deletions InventoryKamera/ui/main/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions InventoryKamera/ui/main/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,5 +632,15 @@ private void updateExecutablesToolStripMenuItem_Click(object sender, EventArgs e
{
new ExecutablesForm().Show();
}

private void label5_Click(object sender, EventArgs e)
{

}

private void SortByObtainedControl_ValueChanged(object sender, EventArgs e)
{

}
}
}