config saving and auto apply

This commit is contained in:
kvan7
2026-09-01 20:41:08 -05:00
parent 6430c9c787
commit ec78f316a0
7 changed files with 100 additions and 20 deletions
+7
View File
@@ -51,5 +51,12 @@
},
"overrides": {
"yauzl": "^3.3.1"
},
"allowScripts": {
"electron@40.10.2": true,
"electron-overlay-window@4.0.2": true,
"electron-winstaller@5.4.0": true,
"esbuild@0.28.0": true,
"uiohook-napi@1.5.4": true
}
}
+4 -1
View File
@@ -66,5 +66,8 @@
},
"browserslist": [
"chrome >= 101"
]
],
"allowScripts": {
"esbuild@0.21.5": true
}
}
+2 -1
View File
@@ -511,6 +511,7 @@
"armour": "Armours",
"all": "All Items",
"save": "Save",
"confirm": "Confirm"
"confirm": "Confirm",
"clear": "Clear"
}
}
+38 -1
View File
@@ -42,7 +42,8 @@ import {
} from "./advanced-mod-desc";
import { calcPropPercentile, QUALITY_STATS } from "./calc-q20";
import { AppConfig } from "@/web/Config";
import { buildEditorItems } from "./augment-builder";
import { buildEditorItems, getSavedAugments } from "./augment-builder";
import { useAugment } from "@/web/price-check/item-editor/augment";
type SectionParseResult =
| "SECTION_PARSED"
@@ -1360,6 +1361,42 @@ function applyAugmentSockets(item: ParsedItem) {
).length;
item.augmentSockets.augments = augments;
}
if (
item.augmentSockets &&
(item.augmentSockets.empty === item.augmentSockets.normal ||
(item.augmentSockets.empty === item.augmentSockets.current &&
item.augmentSockets.current > item.augmentSockets.normal))
) {
// fill sockets, if all are empty && if chosen (also maybe check setting to enable it)
const augmentBases = getSavedAugments(item);
const editorItems = augmentBases.map((base) => {
if (!base) return null;
return buildEditorItems([base], item.category ?? ItemCategory.Unknown)[0];
});
if (!editorItems.length || editorItems.every((item) => item === null)) {
return;
}
// fill the correct number of sockets
const allSameAugment = new Set(augmentBases).size === 1;
const augmentCountToApply =
itemIsModifiable(item) &&
item.augmentSockets.normal > item.augmentSockets.current
? item.augmentSockets.normal
: item.augmentSockets.current;
if (allSameAugment) {
const augmentToApply = editorItems[0];
for (let i = 0; i < augmentCountToApply; i++) {
useAugment(item, augmentToApply!, i);
}
} else {
for (let i = 0; i < augmentCountToApply; i++) {
if (!editorItems[i]) continue;
useAugment(item, editorItems[i]!, i);
}
}
}
}
function parseMirrored(section: string[], item: ParsedItem) {
+44 -3
View File
@@ -1,7 +1,9 @@
import { AugmentLineData, BaseType } from "@/assets/data";
import { ItemCategory } from "./meta";
import { AugmentLineData, BaseType, ITEM_BY_REF } from "@/assets/data";
import { ARMOUR, ItemCategory, MARTIAL_WEAPON } from "./meta";
import { replaceHashWithValues } from "./Parser";
import { EditorItem } from "./ParsedItem";
import { EditorItem, ParsedItem } from "./ParsedItem";
import { PriceCheckWidget } from "@/web/overlay/widgets";
import { AppConfig } from "@/web/Config";
export function selectAugmentEffectByItemCategory(
category: ItemCategory,
@@ -75,3 +77,42 @@ function buildEditorItem(
baseItem: augment,
};
}
export function getSavedAugments(item: ParsedItem): Array<BaseType | null> {
if (!item.augmentSockets) return [];
const lookup = AppConfig<PriceCheckWidget>("price-check")!.savedAugments;
let refNames: Array<string | null> = [];
if (item.category && lookup[item.category]?.length) {
refNames = lookup[item.category]!;
} else if (
item.category &&
MARTIAL_WEAPON.has(item.category) &&
lookup.martialWeapon?.length
) {
refNames = lookup.martialWeapon;
} else if (
(item.category === ItemCategory.Wand ||
item.category === ItemCategory.Staff) &&
lookup.casterWeapon?.length
) {
refNames = lookup.casterWeapon;
} else if (item.category === ItemCategory.Sceptre && lookup.spectre?.length) {
refNames = lookup.spectre;
} else if (
item.category &&
ARMOUR.has(item.category) &&
lookup.armour?.length
) {
refNames = lookup.armour;
} else if (lookup.all?.length) {
refNames = lookup.all;
}
const bases = refNames.map((refName) => {
if (!refName) return null;
return ITEM_BY_REF("ITEM", refName)?.at(0) ?? null;
});
return bases;
}
-6
View File
@@ -25,15 +25,9 @@ export function magicBasetype(name: string) {
ITEM_BY_REF("ITEM", name) ?? ITEM_BY_TRANSLATED("ITEM", name);
// TRADE_ITEM_BY_REF({ name }, true);
if (result) {
console.warn("REF/TRANSLATED", name);
return { name, found: result && result[0].craftable, tradeItem: false };
}
const tradeResult = TRADE_ITEM_BY_REF({ name }, true);
if (tradeResult) {
console.warn("TRADE", name);
} else {
console.warn("NOT FOUND", name);
}
return {
name,
found: tradeResult && tradeResult[0].craftable,
@@ -120,7 +120,7 @@
<div class="flex flex-row justify-between">
<div class="flex flex-row gap-1">
<div>{{ t(":save_type") }}</div>
<select v-model="saveType" class="p-1 rounded bg-gray-700 w-32">
<select v-model="saveType" class="p-1 rounded bg-gray-700 w-28">
<option value="class">
{{ item.info.craftable?.category ?? "Unknown" }}
</option>
@@ -132,10 +132,7 @@
</select>
</div>
<div class="flex flex-row gap-1">
<button
@click="handleClear"
class="btn border-red-700 border-2 active:bg-gray-900"
>
<button @click="handleClear" class="btn bg-red-800 active:bg-gray-900">
{{ t(":clear") }}
</button>
@@ -246,13 +243,13 @@ export default defineComponent({
{ immediate: true },
);
const savedConfig = computed(
() => AppConfig<PriceCheckWidget>("PriceCheckWidget")!.savedAugments,
() => AppConfig<PriceCheckWidget>("price-check")!.savedAugments,
);
function getSaveType() {
switch (saveType.value) {
case AugmentSaveType.Class:
return props.item?.info.craftable?.category ?? "Unknown";
return props.item?.category ?? "Unknown";
case AugmentSaveType.CasterWeapon:
return "casterWeapon";
case AugmentSaveType.MaritalWeapon:
@@ -264,7 +261,7 @@ export default defineComponent({
case AugmentSaveType.All:
return "all";
default:
return props.item?.info.craftable?.category ?? "Unknown";
return props.item?.category ?? "Unknown";
}
}