Skip to content

Commit

Permalink
Fixed price info for arrows.
Browse files Browse the repository at this point in the history
Fixed compatibility issue third party packages.
Improved logging for price requests.
Updated third party packages.
  • Loading branch information
josdemmers committed Dec 11, 2022
1 parent 9b2b712 commit a3a3c9f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 36 deletions.
6 changes: 3 additions & 3 deletions NewWorldCompanion.Helpers/NewWorldCompanion.Helpers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PInvoke.DwmApi" Version="0.7.104" />
<PackageReference Include="PInvoke.Gdi32" Version="0.7.104" />
<PackageReference Include="PInvoke.User32" Version="0.7.104" />
<PackageReference Include="PInvoke.DwmApi" Version="0.7.124" />
<PackageReference Include="PInvoke.Gdi32" Version="0.7.124" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions NewWorldCompanion.Helpers/ScreenCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public Bitmap GetScreenCapture(IntPtr windowHandle)
region.right - region.left, region.bottom - region.top);
var bitmapOldHandle = PInvoke.Gdi32.SelectObject(memoryDCHandle, bitmapHandle);

bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle.DangerousGetHandle(), 0, 0,
bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle, 0, 0,
region.right - region.left, region.bottom - region.top,
windowDCHandle.DangerousGetHandle(), region.left, region.top, SRCCOPY | CAPTUREBLT);
windowDCHandle, region.left, region.top, SRCCOPY | CAPTUREBLT);

try
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public Bitmap GetScreenCapture(IntPtr windowHandle)

xPos = Math.Min(Math.Max(xPos - width / 2, region.left), region.right - width);
yPos = Math.Min(Math.Max(yPos - height / 2, region.top), region.bottom - height);
bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle.DangerousGetHandle(), 0, 0, width, height, windowDCHandle.DangerousGetHandle(), xPos, yPos, SRCCOPY | CAPTUREBLT);
bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle, 0, 0, width, height, windowDCHandle, xPos, yPos, SRCCOPY | CAPTUREBLT);

offsetX = xPos;
offsetY = yPos;
Expand Down Expand Up @@ -118,7 +118,7 @@ public Bitmap GetScreenCapture(IntPtr windowHandle)

xPos = Math.Min(Math.Max(xPos - width / 2, region.left), region.right - width);
yPos = Math.Min(Math.Max(yPos, region.top), region.bottom - height);
bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle.DangerousGetHandle(), 0, 0, width, height, windowDCHandle.DangerousGetHandle(), xPos, yPos, SRCCOPY | CAPTUREBLT);
bool status = PInvoke.Gdi32.BitBlt(memoryDCHandle, 0, 0, width, height, windowDCHandle, xPos, yPos, SRCCOPY | CAPTUREBLT);

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 16 additions & 4 deletions NewWorldCompanion.Services/HttpClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,27 @@ public HttpClientHandler(IEventAggregator eventAggregator, ILogger<HttpClientHan

public async Task<string> GetRequest(string uri)
{
HttpResponseMessage? response = null;
string responseAsString = string.Empty;
try
{
return await _client.GetStringAsync(uri);
response = await _client.GetAsync(uri);
responseAsString = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
return responseAsString;
}
catch (Exception ex)
{
_logger.LogError(ex, $"GetRequest({uri})");

return string.Empty;
if (response != null)
{
_logger.LogError(ex, $"GetRequest({uri}). Response: {responseAsString}");
}
else
{
_logger.LogError(ex, $"GetRequest({uri}).");
}

return responseAsString;
}
}

Expand Down
12 changes: 6 additions & 6 deletions NewWorldCompanion.Services/NewWorldCompanion.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Emgu.CV" Version="4.5.5.4823" />
<PackageReference Include="Emgu.CV.Bitmap" Version="4.5.5.4823" />
<PackageReference Include="Emgu.CV" Version="4.6.0.5131" />
<PackageReference Include="Emgu.CV.Bitmap" Version="4.6.0.5131" />
<PackageReference Include="GameOverlay.Net" Version="4.3.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Prism.Core" Version="8.1.97" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="TesserNet" Version="0.6.0" />
<PackageReference Include="TesserNet.System.Drawing" Version="0.6.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="TesserNet" Version="0.8.0" />
<PackageReference Include="TesserNet.System.Drawing" Version="0.8.0" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion NewWorldCompanion.Services/NewWorldDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void UpdateStoreData()
}
}

// ItemDefinitionsLocalisation
// ItemDefinitionsLocalisation - Itemdefinitions
_itemDefinitionsLocalisation.Clear();
resourcePath = "javelindata_itemdefinitions_master.loc.xml";
resourcePath = assembly.GetManifestResourceNames().Single(str => str.EndsWith(resourcePath));
Expand Down Expand Up @@ -208,6 +208,11 @@ private void UpdateStoreData()
}
}

// ItemDefinitionsLocalisation - Itemdefinitions - Cleanup duplicates
_itemDefinitionsLocalisation.Remove("ArrowBT2_MasterName".ToLower());
_itemDefinitionsLocalisation.Remove("ArrowBT4_MasterName".ToLower());
_itemDefinitionsLocalisation.Remove("ArrowBT5_MasterName".ToLower());

// ItemDefinitionsLocalisation - HouseItems
resourcePath = "javelindata_housingitems.loc.xml";
resourcePath = assembly.GetManifestResourceNames().Single(str => str.EndsWith(resourcePath));
Expand Down
8 changes: 0 additions & 8 deletions NewWorldCompanion.Services/PriceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ public void UpdatePriceData(string itemName)
last_checked = DateTime.MinValue,
};
}

//Thread.Sleep(100);
}
catch (Exception ex)
{
Expand All @@ -307,13 +305,7 @@ public void UpdatePriceData(string itemName)
_priceRequestQueue.RemoveAll(item => item.Equals(itemName));
_priceRequestQueueBusy = false;


var sw = new Stopwatch();
sw.Start();
//Task delay = Task.Delay(100);
//await delay;
Task.Delay(250).Wait();
Debug.WriteLine($"async: Running for {sw.Elapsed.TotalSeconds} seconds");

if (_priceRequestQueue.Any())
{
Expand Down
2 changes: 1 addition & 1 deletion NewWorldCompanion.Services/RelatedPriceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void SetRawResourceRecipeVisibility(string itemIDRawResource, string item
{
// RawResource exists
var rawResource = PersistableOverlayResources.FirstOrDefault(resource => resource.ItemId.Equals(itemIDRawResource));
if (rawResource.PersistableOverlayResourceRecipes.Any(resource => resource.ItemId.Equals(itemID)))
if (rawResource?.PersistableOverlayResourceRecipes.Any(resource => resource.ItemId.Equals(itemID)) ?? false)
{
// Recipe resource exists
var recipe = rawResource.PersistableOverlayResourceRecipes.FirstOrDefault(resource => resource.ItemId.Equals(itemID));
Expand Down
12 changes: 6 additions & 6 deletions NewWorldCompanion/NewWorldCompanion.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.5.5.4823" />
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.6.0.5131" />
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
<PackageReference Include="MahApps.Metro.IconPacks.Material" Version="4.11.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
<PackageReference Include="PInvoke.DwmApi" Version="0.7.104" />
<PackageReference Include="PInvoke.Gdi32" Version="0.7.104" />
<PackageReference Include="PInvoke.User32" Version="0.7.104" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.0" />
<PackageReference Include="PInvoke.DwmApi" Version="0.7.124" />
<PackageReference Include="PInvoke.Gdi32" Version="0.7.124" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
<PackageReference Include="Prism.Unity" Version="8.1.97" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="Unity.Microsoft.DependencyInjection" Version="5.11.5" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions NewWorldCompanion/common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<FileVersion>1.0.9.2</FileVersion>
<Version>1.0.9.2</Version>
<FileVersion>1.0.9.3</FileVersion>
<Version>1.0.9.3</Version>
<Copyright>Copyright © 2022</Copyright>
<TargetFramework>net6.0-windows</TargetFramework>
</PropertyGroup>
Expand Down

0 comments on commit a3a3c9f

Please sign in to comment.