Skip to content

Commit

Permalink
Added support for GeforceNow (Desktop client)
Browse files Browse the repository at this point in the history
Updated game data to 1.8.2
  • Loading branch information
josdemmers committed Feb 11, 2023
1 parent df8e325 commit 3bcb03e
Show file tree
Hide file tree
Showing 24 changed files with 589,207 additions and 6 deletions.
28 changes: 28 additions & 0 deletions NewWorldCompanion.Entities/NamedItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace NewWorldCompanion.Entities
{
public class NamedItem : ItemDefinition
{
/// <value>Item category. Used to categorise, filter, and sort items.</value>
public string ItemClass { get; set; } = string.Empty;
/// <value>Unique identifier for items. Nwdb uses this to identify items</value>
public string ItemID { get; set; } = string.Empty;
public string Localisation { get; set; } = string.Empty;
public string Storage { get; set; } = string.Empty;
public int Tier { get; set; } = 0;

public string Url
{
get
{
return $"https://nwdb.info/db/item/{ItemID}";
}
}
}
}
66 changes: 64 additions & 2 deletions NewWorldCompanion.Services/NewWorldDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public NewWorldDataStore(IEventAggregator eventAggregator)

public void UpdateStoreData()
{
var assembly = Assembly.GetExecutingAssembly();
string resourcePath = string.Empty;

_loadStatusItemDefinitions = $"ItemDefinitions: 0. Loading common items";
Expand Down Expand Up @@ -144,6 +143,30 @@ public void UpdateStoreData()
}
}

_loadStatusItemDefinitions = $"ItemDefinitions: {_masterItemDefinitionsJson.Count}. Loading named items";
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();

// MasterItemDefinitions Named
masterItemDefinitionsJson.Clear();
resourcePath = @".\Data\MasterItemDefinitions_Named.json";
using (FileStream? stream = File.OpenRead(resourcePath))
{
if (stream != null)
{
// create the options
var options = new JsonSerializerOptions()
{
WriteIndented = true
};
// register the converter
options.Converters.Add(new BoolConverter());
options.Converters.Add(new IntConverter());

masterItemDefinitionsJson = JsonSerializer.Deserialize<List<MasterItemDefinitionsJson>>(stream, options) ?? new List<MasterItemDefinitionsJson>();
_masterItemDefinitionsJson.AddRange(masterItemDefinitionsJson);
}
}

_loadStatusItemDefinitions = $"ItemDefinitions: {_masterItemDefinitionsJson.Count}. Loading quest items";
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();

Expand Down Expand Up @@ -335,7 +358,6 @@ public List<CraftingRecipe> GetCraftingRecipes()

public List<MasterItemDefinitionsJson> GetOverlayResources()
{
var assembly = Assembly.GetExecutingAssembly();
string resourcePath = string.Empty;

// MasterItemDefinitions Crafting
Expand Down Expand Up @@ -363,6 +385,46 @@ public List<MasterItemDefinitionsJson> GetOverlayResources()
!items.ItemClass.Contains("WeaponSchematic"));
}

public List<NamedItem> GetNamedItems()
{
string resourcePath = string.Empty;

// MasterItemDefinitions Named
var masterItemDefinitionsJson = new List<MasterItemDefinitionsJson>();
resourcePath = @".\Data\MasterItemDefinitions_Named.json";
using (FileStream? stream = File.OpenRead(resourcePath))
{
if (stream != null)
{
// create the options
var options = new JsonSerializerOptions()
{
WriteIndented = true
};
// register the converter
options.Converters.Add(new BoolConverter());
options.Converters.Add(new IntConverter());

masterItemDefinitionsJson = JsonSerializer.Deserialize<List<MasterItemDefinitionsJson>>(stream, options) ?? new List<MasterItemDefinitionsJson>();
}
}

List<NamedItem> namedItems = new List<NamedItem>();
foreach (var masterItem in masterItemDefinitionsJson.FindAll(items => items.ItemClass.Contains("Named")))
{

namedItems.Add(new NamedItem
{
ItemClass = masterItem.ItemClass,
ItemID = masterItem.ItemID,
Localisation = GetItemLocalisation(masterItem.Name),
Tier = masterItem.Tier
});
}

return namedItems;
}

public bool IsBindOnPickup(string itemName)
{
var localisationId = _itemDefinitionsLocalisation.FirstOrDefault(x => x.Value.Replace("\\n", " ").Equals(itemName, StringComparison.OrdinalIgnoreCase)).Key;
Expand Down
9 changes: 9 additions & 0 deletions NewWorldCompanion.Services/ScreenCaptureHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,19 @@ private void ScreenCapture()
{
IntPtr windowHandle = IntPtr.Zero;
Process[] processes = Process.GetProcessesByName("NewWorld");
Process[] processesGeForceNOW = Process.GetProcessesByName("GeForceNOW");
foreach (Process p in processes)
{
windowHandle = p.MainWindowHandle;
}
foreach (Process p in processesGeForceNOW)
{
windowHandle = p.MainWindowHandle;
if (p.MainWindowTitle.Contains("New World"))
{
break;
}
}

if (windowHandle.ToInt64() > 0)
{
Expand Down
4 changes: 2 additions & 2 deletions NewWorldCompanion/Data/CraftingRecipes.json
Original file line number Diff line number Diff line change
Expand Up @@ -324907,8 +324907,8 @@
"Ingredient7": "",
"Type7": "",
"Qty1": 1,
"Qty2": 4,
"Qty3": 16,
"Qty2": 3,
"Qty3": 9,
"Qty4": null,
"Qty5": null,
"Qty6": null,
Expand Down
Loading

0 comments on commit 3bcb03e

Please sign in to comment.