Move primary to prices and core currency

This commit is contained in:
kvan7
2025-10-10 07:34:06 -05:00
parent b83a2ad4ef
commit e95ebe6576
14 changed files with 85 additions and 107 deletions
+1 -1
View File
@@ -414,7 +414,7 @@
"always_show_tier": "始終顯示階級",
"remember_ratio": "記住通貨比例",
"open_editor_above": "Open rune socket selector upwards",
"primary_currency": "Primary base currency"
"core_currency": "Primary base currency"
},
"poe2_new": {
"beta_warning": "這是 POE2 的測試版,某些功能可能無法正常運作。",
+1 -1
View File
@@ -403,7 +403,7 @@
"always_show_tier": "Tier immer anzeigen",
"remember_ratio": "Währungs-Verhältnis merken",
"open_editor_above": "Open rune socket selector upwards",
"primary_currency": "Primary base currency"
"core_currency": "Primary base currency"
},
"poe2_new": {
"beta_warning": "Dies ist eine BETA für POE2, es wird nicht immer wie erwartet funktionieren.",
+1 -1
View File
@@ -431,7 +431,7 @@
"always_show_tier": "Always show tier",
"remember_ratio": "Remember currency ratio",
"open_editor_above": "Open rune socket selector upwards",
"primary_currency": "Primary base currency"
"core_currency": "Primary base currency"
},
"poe2_new": {
"beta_warning": "This is in BETA for POE2, things will not work always as expected.",
+1 -1
View File
@@ -427,7 +427,7 @@
"always_show_tier": "Always show tier",
"remember_ratio": "Remember currency ratio",
"open_editor_above": "Open rune socket selector upwards",
"primary_currency": "Primary base currency"
"core_currency": "Primary base currency"
},
"poe2_new": {
"beta_warning": "Esto está en BETA para POE2, las cosas no siempre funcionarán como se espera.",
+1 -1
View File
@@ -414,7 +414,7 @@
"always_show_tier": "Always show tier",
"remember_ratio": "Remember currency ratio",
"open_editor_above": "Open rune socket selector upwards",
"primary_currency": "Primary base currency"
"core_currency": "Primary base currency"
},
"poe2_new": {
"beta_warning": "これはPOE2のベータ版です、期待通りに動作しないことがあります。",
+1 -1
View File
@@ -407,7 +407,7 @@
"always_show_tier": "常にティアを表示",
"remember_ratio": "通貨比率を記憶する",
"open_editor_above": "Open rune socket selector upwards",
"primary_currency": "Primary base currency"
"core_currency": "Primary base currency"
},
"poe2_new": {
"beta_warning": "이 버전은 베타버전입니다. 예기치 못한 버그가 있을 수 있습니다.",
+1 -1
View File
@@ -429,7 +429,7 @@
"always_show_tier": "Always show tier",
"remember_ratio": "Remember currency ratio",
"open_editor_above": "Open rune socket selector upwards",
"primary_currency": "Primary base currency"
"core_currency": "Primary base currency"
},
"poe2_new": {
"beta_warning": "Функционал для PoE2 находится в стадии бета тестирования и не всегда работает так, как задумано.",
+1 -2
View File
@@ -23,7 +23,6 @@ export function AppConfig(type?: string) {
export function updateConfig(updates: Config) {
_config.value = deepReactive(JSON.parse(JSON.stringify(updates)));
console.log("SET CONFIG");
document.documentElement.style.fontSize = `${_config.value!.fontSize}px`;
}
@@ -599,7 +598,7 @@ function upgradeConfig(_config: Config): Config {
const priceCheck = config.widgets.find(
(w) => w.wmType === "price-check",
) as widget.PriceCheckWidget;
priceCheck.primaryCurrency = "exalted";
priceCheck.coreCurrency = "exalted";
config.configVersion = 29;
}
return config as unknown as Config;
+68 -9
View File
@@ -1,10 +1,10 @@
import { shallowRef, watch, readonly } from "vue";
import { shallowRef, watch, readonly, computed } from "vue";
import { createGlobalState } from "@vueuse/core";
import { Host } from "@/web/background/IPC";
import { useLeagues } from "./Leagues";
import { AppConfig } from "../Config";
import { PriceCheckWidget } from "../overlay/widgets";
import { usePrimaryCurrency } from "./PrimaryCurrency";
import { ITEM_BY_REF } from "@/assets/data";
interface NinjaDenseInfo {
exalted: number;
@@ -28,9 +28,56 @@ export interface CurrencyValue {
currency: "chaos" | "exalted" | "div";
}
interface CoreCurrency {
id: string;
abbrev: string;
ref: string;
text: string;
icon: string;
}
function getAvailableCoreCurrencies(): CoreCurrency[] {
return [
{
id: "exalted",
abbrev: "ex",
ref: "Exalted Orb",
text: "Exalted Orb",
icon: "/images/exa.png",
},
{
id: "chaos",
abbrev: "c",
ref: "Chaos Orb",
text: "Chaos Orb",
icon: "/images/chaos.png",
},
];
}
export const usePoeninja = createGlobalState(() => {
const leagues = useLeagues();
const primaryCurrency = usePrimaryCurrency();
const availableCoreCurrencies = shallowRef<CoreCurrency[]>([]);
const selectedCoreCurrencyId = computed<"exalted" | "chaos">({
get() {
return availableCoreCurrencies.value.length
? AppConfig<PriceCheckWidget>("price-check")!.coreCurrency
: "exalted";
},
set(id) {
AppConfig<PriceCheckWidget>("price-check")!.coreCurrency = id;
},
});
const selectedCoreCurrency = computed(() => {
const { coreCurrency } = AppConfig<PriceCheckWidget>("price-check")!;
if (!availableCoreCurrencies.value || !coreCurrency) return undefined;
const listed = availableCoreCurrencies.value.find(
(currency) => currency.id === coreCurrency,
);
return listed;
});
const xchgRate = shallowRef<number | undefined>(undefined);
const xchgRateCurrency = shallowRef<"chaos" | "exalted" | undefined>(
@@ -68,6 +115,20 @@ export const usePoeninja = createGlobalState(() => {
try {
isLoading.value = true;
downloadController = new AbortController();
availableCoreCurrencies.value = getAvailableCoreCurrencies().map(
(currency) => ({
...currency,
text: ITEM_BY_REF("ITEM", currency.ref)![0].name,
}),
);
const haveCurrency = availableCoreCurrencies.value.some(
(currency) => currency.id === selectedCoreCurrencyId.value,
);
if (!haveCurrency) {
selectedCoreCurrencyId.value = "exalted";
}
const response = await Host.proxy(
`api.exiledexchange2.dev/overviewData.json`,
{
@@ -90,7 +151,7 @@ export const usePoeninja = createGlobalState(() => {
name: "Divine Orb",
});
const preferred =
AppConfig<PriceCheckWidget>("price-check")!.primaryCurrency;
AppConfig<PriceCheckWidget>("price-check")!.coreCurrency;
if (divine && divine.exalted >= 30) {
if (preferred === "exalted") {
@@ -218,15 +279,12 @@ export const usePoeninja = createGlobalState(() => {
}, RETRY_INTERVAL_MS);
watch(leagues.selectedId, () => {
console.log(`WATCH LEAGUE RUN ${leagues.selectedId.value}`);
xchgRate.value = undefined;
PRICES_DB = [];
load(true);
});
console.log("SETTING UP PRICES");
watch(primaryCurrency.selectedId, (curr, prev) => {
console.log(`WATCH PRIMARY RUN ${curr} ${prev}`);
watch(selectedCoreCurrencyId, (curr, prev) => {
if (curr === prev) return;
xchgRateCurrency.value = curr ?? "exalted";
xchgRate.value = undefined;
@@ -236,12 +294,13 @@ export const usePoeninja = createGlobalState(() => {
return {
xchgRate: readonly(xchgRate),
xchgRateCurrency: readonly(xchgRateCurrency),
xchgRateCurrency: readonly(selectedCoreCurrency),
findPriceByQuery,
autoCurrency,
queuePricesFetch,
cachedCurrencyByQuery,
initialLoading: () => isLoading.value && !PRICES_DB.length,
availableCoreCurrencies: readonly(availableCoreCurrencies),
};
});
@@ -1,75 +0,0 @@
import { ITEM_BY_REF } from "@/assets/data";
import { createGlobalState } from "@vueuse/core";
import { computed, shallowRef, readonly } from "vue";
import { AppConfig } from "../Config";
import { PriceCheckWidget } from "../overlay/widgets";
interface PrimaryCurrency {
id: string;
abbrev: string;
ref: string;
text: string;
icon: string;
}
function getAvailableCurrencies(): PrimaryCurrency[] {
return [
{
id: "exalted",
abbrev: "ex",
ref: "Exalted Orb",
text: "Exalted Orb",
icon: "/images/exa.png",
},
{
id: "chaos",
abbrev: "c",
ref: "Chaos Orb",
text: "Chaos Orb",
icon: "/images/chaos.png",
},
];
}
export const usePrimaryCurrency = createGlobalState(() => {
const availableCurrencies = shallowRef<PrimaryCurrency[]>([]);
const selectedId = computed<"exalted" | "chaos">({
get() {
return availableCurrencies.value.length
? AppConfig<PriceCheckWidget>("price-check")!.primaryCurrency
: "exalted";
},
set(id) {
AppConfig<PriceCheckWidget>("price-check")!.primaryCurrency = id;
},
});
const selected = computed(() => {
const { primaryCurrency } = AppConfig<PriceCheckWidget>("price-check")!;
if (!availableCurrencies.value || !primaryCurrency) return undefined;
const listed = availableCurrencies.value.find(
(currency) => currency.id === primaryCurrency,
);
return listed;
});
function load() {
availableCurrencies.value = getAvailableCurrencies().map((currency) => ({
...currency,
text: ITEM_BY_REF("ITEM", currency.ref)![0].name,
}));
const haveCurrency = availableCurrencies.value.some(
(currency) => currency.id === selectedId.value,
);
if (!haveCurrency) {
selectedId.value = "exalted";
}
}
return {
selectedId,
selected,
list: readonly(availableCurrencies),
load,
};
});
@@ -74,7 +74,6 @@ import LoadingAnimation from "./LoadingAnimation.vue";
import { usePoeninja } from "@/web/background/Prices";
import { useLeagues } from "@/web/background/Leagues";
import { handleLine } from "@/web/client-log/client-log";
import { usePrimaryCurrency } from "../background/PrimaryCurrency";
type WMID = Widget["wmId"];
@@ -85,7 +84,6 @@ export default defineComponent({
setup() {
usePoeninja();
useLeagues().load();
usePrimaryCurrency().load();
const active = shallowRef(!Host.isElectron);
const gameFocused = shallowRef(false);
+1 -1
View File
@@ -56,7 +56,7 @@ export interface PriceCheckWidget extends Widget {
autoFillEmptyRuneSockets: "Iron Rune" | false;
alwaysShowTier: boolean;
openItemEditorAbove: boolean;
primaryCurrency: "exalted" | "chaos";
coreCurrency: "exalted" | "chaos";
}
export interface StopwatchWidget extends Widget {
@@ -228,7 +228,7 @@ export default defineComponent({
autoFillEmptyRuneSockets: false,
alwaysShowTier: false,
openItemEditorAbove: false,
primaryCurrency: "exalted",
coreCurrency: "exalted",
};
},
} satisfies WidgetSpec,
@@ -87,10 +87,10 @@
t(":remember_currency")
}}</ui-checkbox>
<div class="mb-4">
<div class="flex-1 mb-1">{{ t(":primary_currency") }}</div>
<select v-model="primaryCurrency" class="p-1 rounded bg-gray-700 w-24">
<div class="flex-1 mb-1">{{ t(":core_currency") }}</div>
<select v-model="coreCurrency" class="p-1 rounded bg-gray-700 w-24">
<option
v-for="currency of primaryCurrencies.list.value"
v-for="currency of availableCoreCurrencies"
:key="currency.id"
:value="currency.id"
>
@@ -209,7 +209,7 @@ import { configModelValue, configProp, findWidget } from "../settings/utils.js";
import type { PriceCheckWidget } from "@/web/overlay/interfaces";
import { useLeagues } from "../background/Leagues";
import { getRuneNameByRef } from "./filters/fill-runes.js";
import { usePrimaryCurrency } from "../background/PrimaryCurrency.js";
import { usePoeninja } from "../background/Prices.js";
export default defineComponent({
name: "price_check.name",
@@ -221,7 +221,7 @@ export default defineComponent({
);
const leagues = useLeagues();
const primaryCurrencies = usePrimaryCurrency();
const { availableCoreCurrencies } = usePoeninja();
const { t } = useI18nNs("price_check");
return {
@@ -275,10 +275,7 @@ export default defineComponent({
() => configWidget.value,
"rememberCurrency",
),
primaryCurrency: configModelValue(
() => configWidget.value,
"primaryCurrency",
),
coreCurrency: configModelValue(() => configWidget.value, "coreCurrency"),
searchStatRange: computed<number>({
get() {
return configWidget.value.searchStatRange;
@@ -309,7 +306,7 @@ export default defineComponent({
"defaultAllSelected",
),
leagues,
primaryCurrencies,
availableCoreCurrencies,
tooltipHover: configModelValue(
() => configWidget.value,
"itemHoverTooltip",