Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Implemented option to use different providers for checking item prices #42

Open
wants to merge 1 commit 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
67 changes: 53 additions & 14 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
"electron-window-manager": "^1.0.6",
"ffi": "^2.2.0",
"iohook": "^0.2.0",
"jquery": "^3.3.1",
"jquery": "^3.4.1",
"js-base64": "^2.4.9",
"poe-ninja-api-manager": "^0.7.0",
"poedata": "^1.0.0",
"promise-fs": "^1.3.0",
"request-promise-native": "^1.0.5",
"underscore": "^1.9.1",
Expand Down
11 changes: 11 additions & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ i {
padding: 5px 3px;
}

.entry .content .note-max-rolls {
padding: 5px 8px;
font-size: 11px;
text-align: left;
}

.entry .content .note-max-rolls ul {
padding: 0 0 0 16px;
margin: 0;
}

.entry .content .confidence {
position: absolute;
width: 3px !important;
Expand Down
55 changes: 55 additions & 0 deletions src/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ i {
font-size: 13px;
}

.content .note {
color: #748199;
font-size: 13px;
}

.content .option label.wrap {
margin: 5px 0px;
width: 100%;
Expand Down Expand Up @@ -206,3 +211,53 @@ i {
width: 20px;
pointer-events: none;
}

.content .option a {
color: #748199;
}

.content .option input {
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background: #303a4c;
color: #FFFFFF;
padding: 7px;
font-size: 11px;
border: 0;
width: 100%;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
}

.content .description {
font-size: 12px;
color: #748199;
display: block;
}

.content .option.row {
display: block;
border-bottom: 1px solid #303b4c;
padding-bottom: 5px;
margin-top: 5px;
}

.content .option.row::after {
clear: both;
content: '';
display: block;
}

.content .option.row .label {
float: left;
width: 40%;
padding: 8px 0px;
}

.content .option.row .wrap {
float: left;
width: 60%;
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class XenonTrade {
// Check dependencies and update poe.ninja
this.checkDependencies();
Pricecheck.updateNinja();
Pricecheck.updatePoeData();
return;
})
.catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/entries/item-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class ItemEntry extends PriceCheckEntry {
super();
this.item = item;
this.parser = parser;

this.switchable = false;
}

Expand All @@ -26,6 +25,7 @@ class ItemEntry extends PriceCheckEntry {

// Set buttons and trends
this.visualizeTrend();
super.addMaxRolls(this.parser.item);
super.setCloseable(true);
if(this.switchable) {
super.enableToggle("switch");
Expand Down
74 changes: 74 additions & 0 deletions src/modules/entries/poe-trade-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const PriceCheckEntry = require("./pricecheck-entry.js");
const CurrencyIcons = require("../../resource/icons/currencyIcons");
const BaseTypeIcons = require("../../resource/icons/baseTypeIcons");

class PoeTradeEntry extends PriceCheckEntry {
/**
* Creates a new RareItemEntry object
*
* @constructor
* @param {Object} poePrices pathofexile.com/trade result
* @param {Parser} parser Parser object
*/
constructor(poePrices, parser) {
super();
this.poePrices = poePrices;
this.parser = parser;
}

add() {
var template = templates.get("poeTrade.html");
var replacements = this._buildReplacements();

// Set template, replacements and add
super.setTemplate(template);
super.setReplacements(replacements);
super.add();

// Set buttons, links, prediction explanation and feedback elements
super.addMaxRolls(this.parser.item);
super.setCloseable(true);
super.enableExternalLinks();

// Enable autoclose if configured
if(config.get("autoclose.enabled") && config.get("autoclose.timeouts.rare.enabled")) {
if(!(config.get("autoclose.threshold.enabled")
&& (this.poePrices.price.min > config.get("autoclose.threshold.value") || this.poePrices.price.currency === "exalt"))) {
super.enableAutoClose(config.get("autoclose.timeouts.rare.value"));
}
}
}

_buildReplacements() {
var baseType = this.parser.getBaseType();
var url = this.poePrices.searchUrl;
var currencyIcon = "", currencyName = "";

if(this.poePrices.price.currency === "chaos") {
currencyName = "Chaos Orb";
} else {
currencyName = "Exalted Orb";
}

currencyIcon = CurrencyIcons[currencyName];

var replacements = [
{ find: "item-name", replace: this.parser.getName() },
{ find: "item-baseType", replace: baseType },
{ find: "item-value-min", replace: this.poePrices.price.min },
{ find: "item-value-max", replace: this.poePrices.price.max },
{ find: "currency-name", replace: currencyName },
{ find: "currency-icon", replace: currencyIcon },
{ find: "link", replace: url}
];

if(BaseTypeIcons.hasOwnProperty(baseType)) {
replacements.push({ find: "item-icon", replace: BaseTypeIcons[baseType] });
}

return replacements;
}

}

module.exports = PoeTradeEntry;
20 changes: 20 additions & 0 deletions src/modules/entries/pricecheck-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ class PriceCheckEntry extends Entry {
GUI.updateWindowHeight();
}

/**
* Add notice about max rolls on item mods
* @param mods
*/
addMaxRolls(item) {
if (item === null) {
return;
}
let mods = item.getMaxRolledMods();
if (mods.length > 0) {
let modsText = [];
for (let i = 0; i < mods.length; i++) {
modsText.push( mods[i].modBase["trade text"] );
}
$(".entry[data-id='" + this.id + "']").find(".note-max-rolls .count").text(mods.length);
$(".entry[data-id='" + this.id + "']").find(".note-max-rolls .mod-list").html("<li>"+modsText.join("</li><li>")+"</li>");
$(".entry[data-id='" + this.id + "']").find(".note-max-rolls").show();
}
}

/**
* Removes null from sparkline data and returns the trend as an array
*
Expand Down
1 change: 1 addition & 0 deletions src/modules/entries/rare-item-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class RareItemEntry extends PriceCheckEntry {
super.add();

// Set buttons, links, prediction explanation and feedback elements
super.addMaxRolls(this.parser.item);
super.setCloseable(true);
super.enableToggle("expand");
super.enableExternalLinks();
Expand Down
7 changes: 7 additions & 0 deletions src/modules/gui/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class GUI {
Pricecheck.updateNinja();
});

// Update PoeData when the the according provider is selected in the settings
windowManager.bridge.on('provider-change', function(event) {
if (event.provider == "poetrade") {
Pricecheck.updatePoeData();
}
});

// Adjust window size based on scale factor when it's changed
windowManager.bridge.on('zoomfactor-change', function(event) {
GUI.setZoomFactor(event.value);
Expand Down
Loading