poi-plugin-kca-next 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +340 -101
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -873,7 +873,9 @@ function createDefaultSettings() {
|
|
|
873
873
|
minLevel: 0,
|
|
874
874
|
reservedDocks: 1,
|
|
875
875
|
sortOrder: "shortest",
|
|
876
|
-
batchAllFreeDocks: true
|
|
876
|
+
batchAllFreeDocks: true,
|
|
877
|
+
damageThreshold: "light",
|
|
878
|
+
avoidSortieConflict: true
|
|
877
879
|
},
|
|
878
880
|
develop: {
|
|
879
881
|
remainingCount: 0,
|
|
@@ -4313,42 +4315,98 @@ async function executeRepair(bridge, actions, logger, shipIds, bucketThresholdSe
|
|
|
4313
4315
|
);
|
|
4314
4316
|
return repairedCount;
|
|
4315
4317
|
}
|
|
4318
|
+
function planAutoRepair(state, settings, ctx) {
|
|
4319
|
+
const cfg = settings.repair;
|
|
4320
|
+
const avoidConflict = cfg.avoidSortieConflict !== false;
|
|
4321
|
+
const damageThreshold = cfg.damageThreshold ?? "light";
|
|
4322
|
+
const freeDocks = getFreeRepairDocks(state, settings.general.operationAdvanceSec);
|
|
4323
|
+
const effectiveReservedDocks = avoidConflict && ctx.isSortieEnabled ? Math.max(cfg.reservedDocks, 1) : cfg.reservedDocks;
|
|
4324
|
+
const usableCount = Math.max(0, freeDocks.length - effectiveReservedDocks);
|
|
4325
|
+
const excludedShipIds = /* @__PURE__ */ new Set();
|
|
4326
|
+
for (const f of Object.values(state.fleets)) {
|
|
4327
|
+
for (const sid of f.shipIds) excludedShipIds.add(sid);
|
|
4328
|
+
}
|
|
4329
|
+
if (avoidConflict && ctx.isSortieEnabled) {
|
|
4330
|
+
const activeProfile = settings.sortie.profiles.find((p) => p.id === settings.sortie.activeProfileId) ?? settings.sortie.profiles[0];
|
|
4331
|
+
if (activeProfile?.autoChangeShip) {
|
|
4332
|
+
for (const slotList of activeProfile.candidateShips) {
|
|
4333
|
+
for (const sid of slotList ?? []) {
|
|
4334
|
+
if (sid > 0) excludedShipIds.add(sid);
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
const candidates = Object.values(state.ships).filter(
|
|
4340
|
+
(s) => s.hp < s.maxHp && matchesDamageThreshold(s, damageThreshold) && !s.isRepairing && s.level >= cfg.minLevel && !excludedShipIds.has(s.id) && !ctx.isShipReservedByKira(s.id)
|
|
4341
|
+
).sort(
|
|
4342
|
+
(a, b) => cfg.sortOrder === "shortest" ? a.repairTimeMs - b.repairTimeMs : b.repairTimeMs - a.repairTimeMs
|
|
4343
|
+
);
|
|
4344
|
+
return {
|
|
4345
|
+
usableCount,
|
|
4346
|
+
effectiveReservedDocks,
|
|
4347
|
+
freeDockCount: freeDocks.length,
|
|
4348
|
+
candidates
|
|
4349
|
+
};
|
|
4350
|
+
}
|
|
4351
|
+
var REPAIR_ERROR_BACKOFF_MS = 6e4;
|
|
4316
4352
|
var AutoRepairModule = class extends AutomationModule {
|
|
4317
|
-
constructor(runtime,
|
|
4353
|
+
constructor(runtime, hooks) {
|
|
4318
4354
|
super(runtime);
|
|
4319
|
-
this.
|
|
4355
|
+
this.hooks = hooks;
|
|
4320
4356
|
}
|
|
4321
4357
|
id = "repair";
|
|
4322
4358
|
category = "repair";
|
|
4323
4359
|
displayName = "\u81EA\u52A8\u5165\u6E20";
|
|
4360
|
+
backoffUntilMs = 0;
|
|
4361
|
+
onEnabled() {
|
|
4362
|
+
this.backoffUntilMs = 0;
|
|
4363
|
+
}
|
|
4364
|
+
/**
|
|
4365
|
+
* Returns true when AutoRepair has both spare docks (beyond sortie reserve) and eligible
|
|
4366
|
+
* damaged standby ships ready to dock at Homeport. Used by AutoSortie to yield cleanly
|
|
4367
|
+
* between sorties so both modules work side-by-side without conflict.
|
|
4368
|
+
*/
|
|
4369
|
+
needsAction() {
|
|
4370
|
+
if (!this.enabled) return false;
|
|
4371
|
+
if (Date.now() < this.backoffUntilMs) return false;
|
|
4372
|
+
const state = this.runtime.bridge.getState();
|
|
4373
|
+
if (!state.loaded || state.inSortie) return false;
|
|
4374
|
+
if (this.runtime.scheduler.isSortieClickLockActive) return false;
|
|
4375
|
+
if (this.hooks.hasHigherPriorityWork?.()) return false;
|
|
4376
|
+
const settings = this.runtime.getSettings();
|
|
4377
|
+
const plan = planAutoRepair(state, settings, {
|
|
4378
|
+
isSortieEnabled: this.runtime.isModuleEnabled("sortie"),
|
|
4379
|
+
isShipReservedByKira: this.hooks.isShipReservedByKira
|
|
4380
|
+
});
|
|
4381
|
+
return plan.usableCount > 0 && plan.candidates.length > 0;
|
|
4382
|
+
}
|
|
4324
4383
|
async tick() {
|
|
4325
4384
|
if (!this.enabled || !this.runtime.scheduler.canAcquire(this.id)) return;
|
|
4385
|
+
if (Date.now() < this.backoffUntilMs) return;
|
|
4326
4386
|
const state = this.runtime.bridge.getState();
|
|
4327
4387
|
if (!state.loaded || state.inSortie) return;
|
|
4388
|
+
if (this.runtime.scheduler.isSortieClickLockActive) return;
|
|
4389
|
+
if (this.hooks.hasHigherPriorityWork?.()) return;
|
|
4328
4390
|
const settings = this.runtime.getSettings();
|
|
4329
4391
|
const cfg = settings.repair;
|
|
4330
|
-
const
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4392
|
+
const plan = planAutoRepair(state, settings, {
|
|
4393
|
+
isSortieEnabled: this.runtime.isModuleEnabled("sortie"),
|
|
4394
|
+
isShipReservedByKira: this.hooks.isShipReservedByKira
|
|
4395
|
+
});
|
|
4396
|
+
if (plan.usableCount <= 0) {
|
|
4397
|
+
this.setStatus(
|
|
4398
|
+
`\u7B49\u5F85\u7A7A\u6E20\u4F4D (\u7A7A\u95F2 ${plan.freeDockCount} / \u4FDD\u7559 ${plan.effectiveReservedDocks})`,
|
|
4399
|
+
"idle"
|
|
4400
|
+
);
|
|
4334
4401
|
return;
|
|
4335
4402
|
}
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
for (const sid of f.shipIds) inFleetIds.add(sid);
|
|
4339
|
-
}
|
|
4340
|
-
const candidates = Object.values(state.ships).filter(
|
|
4341
|
-
(s) => s.hp < s.maxHp && !s.isRepairing && s.level >= cfg.minLevel && !inFleetIds.has(s.id) && !this.isShipReservedByKira(s.id)
|
|
4342
|
-
).sort(
|
|
4343
|
-
(a, b) => cfg.sortOrder === "shortest" ? a.repairTimeMs - b.repairTimeMs : b.repairTimeMs - a.repairTimeMs
|
|
4344
|
-
);
|
|
4345
|
-
if (candidates.length === 0) {
|
|
4346
|
-
this.setStatus("\u6682\u65E0\u9700\u8981\u4FEE\u7406\u7684\u5F85\u547D\u8230\u5A18", "idle");
|
|
4403
|
+
if (plan.candidates.length === 0) {
|
|
4404
|
+
this.setStatus("\u6682\u65E0\u7B26\u5408\u635F\u4F24\u6761\u4EF6\u7684\u5F85\u547D\u8230\u5A18", "idle");
|
|
4347
4405
|
return;
|
|
4348
4406
|
}
|
|
4349
|
-
const batchSize = cfg.batchAllFreeDocks ? usableCount : 1;
|
|
4350
|
-
const shipIds = candidates.slice(0, batchSize).map((s) => s.id);
|
|
4351
|
-
await this.runLocked(async (ctx) => {
|
|
4407
|
+
const batchSize = cfg.batchAllFreeDocks ? plan.usableCount : 1;
|
|
4408
|
+
const shipIds = plan.candidates.slice(0, batchSize).map((s) => s.id);
|
|
4409
|
+
const ok = await this.runLocked(async (ctx) => {
|
|
4352
4410
|
this.setStatus(`\u6B63\u5728\u5B89\u6392\u5165\u6E20 (${shipIds.length} \u8258)`);
|
|
4353
4411
|
await executeRepair(
|
|
4354
4412
|
this.runtime.bridge,
|
|
@@ -4361,6 +4419,9 @@ var AutoRepairModule = class extends AutomationModule {
|
|
|
4361
4419
|
);
|
|
4362
4420
|
this.setStatus("\u5165\u6E20\u5B8C\u6210", "idle");
|
|
4363
4421
|
});
|
|
4422
|
+
if (!ok && this.lastError) {
|
|
4423
|
+
this.backoffUntilMs = Date.now() + REPAIR_ERROR_BACKOFF_MS;
|
|
4424
|
+
}
|
|
4364
4425
|
}
|
|
4365
4426
|
};
|
|
4366
4427
|
|
|
@@ -8875,6 +8936,9 @@ var AutoSortieModule = class extends AutomationModule {
|
|
|
8875
8936
|
return;
|
|
8876
8937
|
}
|
|
8877
8938
|
}
|
|
8939
|
+
if (this.hooks.repairNeedsAction?.()) {
|
|
8940
|
+
return;
|
|
8941
|
+
}
|
|
8878
8942
|
if (profile.limitType !== "none" && profile.limitRemaining <= 0) {
|
|
8879
8943
|
this.runtime.logger.success("sortie", `\u51FA\u51FB\u914D\u7F6E [${profile.name}] \u5DF2\u8FBE\u6210\u6B21\u6570/\u76EE\u6807\u9650\u5236\uFF0C\u81EA\u52A8\u505C\u6B62`);
|
|
8880
8944
|
this.setEnabled(false);
|
|
@@ -9705,17 +9769,21 @@ var KcaAssistantCoordinator = class {
|
|
|
9705
9769
|
}
|
|
9706
9770
|
);
|
|
9707
9771
|
this.organization = new AutoOrganizationModule(runtime, () => this.practice.needsAction());
|
|
9772
|
+
this.repair = new AutoRepairModule(runtime, {
|
|
9773
|
+
isShipReservedByKira: (id) => this.kira.isShipReserved(id),
|
|
9774
|
+
hasHigherPriorityWork: () => this.practice.needsAction() || this.expedition.needsAction() || this.kira.needsAction()
|
|
9775
|
+
});
|
|
9708
9776
|
this.sortie = new AutoSortieModule(runtime, {
|
|
9709
9777
|
practiceNeedsAction: () => this.practice.needsAction(),
|
|
9710
9778
|
expeditionNeedsAction: () => this.expedition.needsAction(),
|
|
9711
9779
|
kiraNeedsAction: () => this.kira.needsAction(),
|
|
9780
|
+
repairNeedsAction: () => this.repair.needsAction(),
|
|
9712
9781
|
isShipReservedByKira: (id) => this.kira.isShipReserved(id),
|
|
9713
9782
|
getPendingSupportExpeditions: () => this.expedition.getPendingSupportDispatches(),
|
|
9714
9783
|
clearPendingSupportExpeditions: () => this.expedition.clearPendingSupportDispatches(),
|
|
9715
9784
|
onBattleResultForQuests: (params) => this.quests.onBattleResult(params),
|
|
9716
9785
|
onSortieCompletedForQuests: () => this.quests.onSortieCompleted()
|
|
9717
9786
|
});
|
|
9718
|
-
this.repair = new AutoRepairModule(runtime, (id) => this.kira.isShipReserved(id));
|
|
9719
9787
|
this.develop = new AutoDevelopModule(runtime);
|
|
9720
9788
|
this.plan = new AutoPlanModule(runtime, {
|
|
9721
9789
|
isAnyFleetInSortie: () => this.bridge.getState().inSortie,
|
|
@@ -10102,6 +10170,7 @@ function buildCoordOverlayScript(config) {
|
|
|
10102
10170
|
const payload = JSON.stringify({
|
|
10103
10171
|
visible: Boolean(config.visible),
|
|
10104
10172
|
pickMode: Boolean(config.pickMode),
|
|
10173
|
+
pickToken: String(config.pickToken ?? ""),
|
|
10105
10174
|
pickLabel: String(config.pickLabel ?? ""),
|
|
10106
10175
|
markers: (config.markers ?? []).filter((m) => m && Number.isFinite(m.x) && Number.isFinite(m.y) && (m.x > 0 || m.y > 0)).map((m) => ({
|
|
10107
10176
|
id: String(m.id),
|
|
@@ -10128,21 +10197,35 @@ function buildCoordOverlayScript(config) {
|
|
|
10128
10197
|
};
|
|
10129
10198
|
|
|
10130
10199
|
let ctl = window[KEY];
|
|
10200
|
+
if (!cfg.visible && !cfg.pickMode) {
|
|
10201
|
+
if (ctl && typeof ctl.teardown === 'function') ctl.teardown();
|
|
10202
|
+
const stray = document.getElementById(DOM_ID);
|
|
10203
|
+
if (stray && stray.parentNode) stray.parentNode.removeChild(stray);
|
|
10204
|
+
return { active: false, pickMode: false, pickToken: '', hover: null, picked: null, cancelledToken: '' };
|
|
10205
|
+
}
|
|
10206
|
+
|
|
10207
|
+
if (!findGameCanvas()) {
|
|
10208
|
+
return null;
|
|
10209
|
+
}
|
|
10210
|
+
|
|
10131
10211
|
if (!ctl) {
|
|
10132
10212
|
ctl = {
|
|
10133
10213
|
active: false,
|
|
10134
10214
|
pickMode: false,
|
|
10215
|
+
pickToken: '',
|
|
10135
10216
|
pickLabel: '',
|
|
10136
10217
|
markers: [],
|
|
10137
10218
|
hover: null,
|
|
10138
10219
|
picked: null,
|
|
10139
|
-
|
|
10140
|
-
cancelledSeq: 0,
|
|
10220
|
+
cancelledToken: '',
|
|
10141
10221
|
swallowingUntil: 0,
|
|
10142
10222
|
swallowTimer: null,
|
|
10223
|
+
teardownTimer: null,
|
|
10143
10224
|
root: null,
|
|
10144
10225
|
hud: null,
|
|
10145
10226
|
banner: null,
|
|
10227
|
+
bannerText: null,
|
|
10228
|
+
bannerCancel: null,
|
|
10146
10229
|
crossX: null,
|
|
10147
10230
|
crossY: null,
|
|
10148
10231
|
cursorTag: null,
|
|
@@ -10151,6 +10234,7 @@ function buildCoordOverlayScript(config) {
|
|
|
10151
10234
|
renderPins: null,
|
|
10152
10235
|
applyMode: null,
|
|
10153
10236
|
teardown: null,
|
|
10237
|
+
getStatus: null,
|
|
10154
10238
|
};
|
|
10155
10239
|
|
|
10156
10240
|
const root = document.createElement('div');
|
|
@@ -10198,18 +10282,36 @@ function buildCoordOverlayScript(config) {
|
|
|
10198
10282
|
'left:50%',
|
|
10199
10283
|
'top:8px',
|
|
10200
10284
|
'transform:translateX(-50%)',
|
|
10201
|
-
'padding:
|
|
10285
|
+
'padding:4px 10px',
|
|
10202
10286
|
'border-radius:6px',
|
|
10203
|
-
'background:rgba(30,58,138,0.
|
|
10287
|
+
'background:rgba(30,58,138,0.94)',
|
|
10204
10288
|
'border:1px solid rgba(96,165,250,0.95)',
|
|
10205
10289
|
'color:#ffffff',
|
|
10206
10290
|
'font-size:12px',
|
|
10207
10291
|
'font-weight:700',
|
|
10208
10292
|
'box-shadow:0 2px 10px rgba(0,0,0,0.55)',
|
|
10209
|
-
'pointer-events:none',
|
|
10210
10293
|
'display:none',
|
|
10294
|
+
'align-items:center',
|
|
10295
|
+
'gap:8px',
|
|
10211
10296
|
'white-space:nowrap',
|
|
10297
|
+
'pointer-events:auto',
|
|
10298
|
+
].join(';');
|
|
10299
|
+
const bannerText = document.createElement('span');
|
|
10300
|
+
const bannerCancel = document.createElement('button');
|
|
10301
|
+
bannerCancel.type = 'button';
|
|
10302
|
+
bannerCancel.textContent = '\u2715 \u53D6\u6D88';
|
|
10303
|
+
bannerCancel.style.cssText = [
|
|
10304
|
+
'border:1px solid rgba(248,113,113,0.9)',
|
|
10305
|
+
'background:rgba(153,27,27,0.92)',
|
|
10306
|
+
'color:#ffffff',
|
|
10307
|
+
'border-radius:4px',
|
|
10308
|
+
'padding:1px 7px',
|
|
10309
|
+
'font-size:11px',
|
|
10310
|
+
'font-weight:700',
|
|
10311
|
+
'cursor:pointer',
|
|
10212
10312
|
].join(';');
|
|
10313
|
+
banner.appendChild(bannerText);
|
|
10314
|
+
banner.appendChild(bannerCancel);
|
|
10213
10315
|
|
|
10214
10316
|
const cursorTag = document.createElement('div');
|
|
10215
10317
|
cursorTag.style.cssText = [
|
|
@@ -10239,6 +10341,8 @@ function buildCoordOverlayScript(config) {
|
|
|
10239
10341
|
ctl.root = root;
|
|
10240
10342
|
ctl.hud = hud;
|
|
10241
10343
|
ctl.banner = banner;
|
|
10344
|
+
ctl.bannerText = bannerText;
|
|
10345
|
+
ctl.bannerCancel = bannerCancel;
|
|
10242
10346
|
ctl.crossX = crossX;
|
|
10243
10347
|
ctl.crossY = crossY;
|
|
10244
10348
|
ctl.cursorTag = cursorTag;
|
|
@@ -10260,12 +10364,16 @@ function buildCoordOverlayScript(config) {
|
|
|
10260
10364
|
};
|
|
10261
10365
|
ctl.syncRect = syncRect;
|
|
10262
10366
|
|
|
10263
|
-
const mapPointer = (e) => {
|
|
10367
|
+
const mapPointer = (e, clampInside) => {
|
|
10264
10368
|
const r = syncRect();
|
|
10265
10369
|
if (!r || r.width <= 0 || r.height <= 0) return null;
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
if (relX < 0 || relY < 0 || relX > r.width || relY > r.height)
|
|
10370
|
+
let relX = e.clientX - r.left;
|
|
10371
|
+
let relY = e.clientY - r.top;
|
|
10372
|
+
if (!clampInside && (relX < 0 || relY < 0 || relX > r.width || relY > r.height)) {
|
|
10373
|
+
return null;
|
|
10374
|
+
}
|
|
10375
|
+
relX = Math.max(0, Math.min(r.width, relX));
|
|
10376
|
+
relY = Math.max(0, Math.min(r.height, relY));
|
|
10269
10377
|
const x = Math.max(0, Math.min(W, Math.round((relX / r.width) * W)));
|
|
10270
10378
|
const y = Math.max(0, Math.min(H, Math.round((relY / r.height) * H)));
|
|
10271
10379
|
return { x, y, relX, relY, r };
|
|
@@ -10332,6 +10440,8 @@ function buildCoordOverlayScript(config) {
|
|
|
10332
10440
|
|
|
10333
10441
|
const applyMode = () => {
|
|
10334
10442
|
syncRect();
|
|
10443
|
+
hud.style.display = 'block';
|
|
10444
|
+
pinsLayer.style.display = 'block';
|
|
10335
10445
|
if (ctl.pickMode) {
|
|
10336
10446
|
if (ctl.swallowTimer) {
|
|
10337
10447
|
clearTimeout(ctl.swallowTimer);
|
|
@@ -10343,8 +10453,8 @@ function buildCoordOverlayScript(config) {
|
|
|
10343
10453
|
root.style.outline = '2px solid rgba(56,189,248,0.9)';
|
|
10344
10454
|
root.style.outlineOffset = '-2px';
|
|
10345
10455
|
root.style.background = 'rgba(15,23,42,0.10)';
|
|
10346
|
-
banner.style.display = '
|
|
10347
|
-
|
|
10456
|
+
banner.style.display = 'flex';
|
|
10457
|
+
bannerText.textContent = '\u{1F3AF} \u53D6\u70B9 [' + (ctl.pickLabel || '\u5750\u6807') + ']\uFF1A\u5DE6\u952E\u70B9\u51FB\u76EE\u6807\u70B9\u586B\u5165\uFF0C\u53F3\u952E\u6216 Esc \u53D6\u6D88';
|
|
10348
10458
|
} else {
|
|
10349
10459
|
const keepShield = ctl.swallowingUntil > Date.now();
|
|
10350
10460
|
root.style.pointerEvents = keepShield ? 'auto' : 'none';
|
|
@@ -10367,7 +10477,7 @@ function buildCoordOverlayScript(config) {
|
|
|
10367
10477
|
|
|
10368
10478
|
const onPointerMove = (e) => {
|
|
10369
10479
|
if (!ctl.active) return;
|
|
10370
|
-
const pt = mapPointer(e);
|
|
10480
|
+
const pt = mapPointer(e, false);
|
|
10371
10481
|
if (!pt) {
|
|
10372
10482
|
crossX.style.display = 'none';
|
|
10373
10483
|
crossY.style.display = 'none';
|
|
@@ -10399,45 +10509,51 @@ function buildCoordOverlayScript(config) {
|
|
|
10399
10509
|
|
|
10400
10510
|
const finishPickWithShield = () => {
|
|
10401
10511
|
ctl.pickMode = false;
|
|
10402
|
-
ctl.swallowingUntil = Date.now() +
|
|
10512
|
+
ctl.swallowingUntil = Date.now() + 260;
|
|
10403
10513
|
applyMode();
|
|
10404
10514
|
};
|
|
10405
10515
|
|
|
10516
|
+
const cancelCurrentPick = (e) => {
|
|
10517
|
+
if (e) swallowEvent(e);
|
|
10518
|
+
if (!ctl.pickMode) return;
|
|
10519
|
+
ctl.cancelledToken = ctl.pickToken || ('cancel-' + Date.now());
|
|
10520
|
+
finishPickWithShield();
|
|
10521
|
+
};
|
|
10522
|
+
|
|
10406
10523
|
const onPickDown = (e) => {
|
|
10407
10524
|
if (!ctl.pickMode) {
|
|
10408
10525
|
swallowEvent(e);
|
|
10409
10526
|
return;
|
|
10410
10527
|
}
|
|
10528
|
+
if (e.target === bannerCancel || bannerCancel.contains(e.target)) {
|
|
10529
|
+
cancelCurrentPick(e);
|
|
10530
|
+
return;
|
|
10531
|
+
}
|
|
10411
10532
|
swallowEvent(e);
|
|
10412
10533
|
if (e.button === 2) {
|
|
10413
|
-
|
|
10414
|
-
finishPickWithShield();
|
|
10534
|
+
cancelCurrentPick();
|
|
10415
10535
|
return;
|
|
10416
10536
|
}
|
|
10417
10537
|
if (e.button !== 0) return;
|
|
10418
|
-
const pt = mapPointer(e);
|
|
10538
|
+
const pt = mapPointer(e, true);
|
|
10419
10539
|
if (!pt) return;
|
|
10420
|
-
ctl.
|
|
10421
|
-
ctl.picked = { x: pt.x, y: pt.y, seq: ctl.pickSeq };
|
|
10540
|
+
ctl.picked = { x: pt.x, y: pt.y, token: ctl.pickToken || ('pick-' + Date.now()) };
|
|
10422
10541
|
finishPickWithShield();
|
|
10423
10542
|
};
|
|
10424
10543
|
|
|
10425
10544
|
const onContextMenu = (e) => {
|
|
10426
10545
|
if (!ctl.pickMode && ctl.swallowingUntil <= Date.now()) return;
|
|
10427
|
-
swallowEvent(e);
|
|
10428
10546
|
if (ctl.pickMode) {
|
|
10429
|
-
|
|
10430
|
-
|
|
10547
|
+
cancelCurrentPick(e);
|
|
10548
|
+
} else {
|
|
10549
|
+
swallowEvent(e);
|
|
10431
10550
|
}
|
|
10432
10551
|
};
|
|
10433
10552
|
|
|
10434
10553
|
const onKeyDown = (e) => {
|
|
10435
10554
|
if (!ctl.pickMode) return;
|
|
10436
10555
|
if (e.key === 'Escape') {
|
|
10437
|
-
|
|
10438
|
-
ctl.pickMode = false;
|
|
10439
|
-
ctl.cancelledSeq++;
|
|
10440
|
-
applyMode();
|
|
10556
|
+
cancelCurrentPick(e);
|
|
10441
10557
|
}
|
|
10442
10558
|
};
|
|
10443
10559
|
|
|
@@ -10463,6 +10579,10 @@ function buildCoordOverlayScript(config) {
|
|
|
10463
10579
|
clearTimeout(ctl.swallowTimer);
|
|
10464
10580
|
ctl.swallowTimer = null;
|
|
10465
10581
|
}
|
|
10582
|
+
if (ctl.teardownTimer) {
|
|
10583
|
+
clearTimeout(ctl.teardownTimer);
|
|
10584
|
+
ctl.teardownTimer = null;
|
|
10585
|
+
}
|
|
10466
10586
|
window.removeEventListener('pointermove', onPointerMove, true);
|
|
10467
10587
|
window.removeEventListener('mousemove', onPointerMove, true);
|
|
10468
10588
|
window.removeEventListener('keydown', onKeyDown, true);
|
|
@@ -10479,21 +10599,19 @@ function buildCoordOverlayScript(config) {
|
|
|
10479
10599
|
ctl.getStatus = () => ({
|
|
10480
10600
|
active: Boolean(ctl.active),
|
|
10481
10601
|
pickMode: Boolean(ctl.pickMode),
|
|
10602
|
+
pickToken: String(ctl.pickToken || ''),
|
|
10482
10603
|
hover: ctl.hover,
|
|
10483
10604
|
picked: ctl.picked,
|
|
10484
|
-
|
|
10605
|
+
cancelledToken: String(ctl.cancelledToken || ''),
|
|
10485
10606
|
});
|
|
10486
10607
|
|
|
10487
10608
|
window[KEY] = ctl;
|
|
10488
10609
|
}
|
|
10489
10610
|
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
if (!findGameCanvas()) {
|
|
10496
|
-
return null;
|
|
10611
|
+
// Cancel any deferred teardown from a previous pick before re-activating!
|
|
10612
|
+
if (ctl.teardownTimer) {
|
|
10613
|
+
clearTimeout(ctl.teardownTimer);
|
|
10614
|
+
ctl.teardownTimer = null;
|
|
10497
10615
|
}
|
|
10498
10616
|
|
|
10499
10617
|
if (!document.getElementById(DOM_ID)) {
|
|
@@ -10502,6 +10620,13 @@ function buildCoordOverlayScript(config) {
|
|
|
10502
10620
|
|
|
10503
10621
|
ctl.active = true;
|
|
10504
10622
|
ctl.pickMode = Boolean(cfg.pickMode);
|
|
10623
|
+
if (cfg.pickMode && cfg.pickToken) {
|
|
10624
|
+
ctl.pickToken = cfg.pickToken;
|
|
10625
|
+
if (ctl.picked && ctl.picked.token !== cfg.pickToken) ctl.picked = null;
|
|
10626
|
+
if (ctl.cancelledToken === cfg.pickToken) ctl.cancelledToken = '';
|
|
10627
|
+
} else if (!cfg.pickMode) {
|
|
10628
|
+
ctl.pickToken = '';
|
|
10629
|
+
}
|
|
10505
10630
|
ctl.pickLabel = cfg.pickLabel;
|
|
10506
10631
|
ctl.markers = cfg.markers;
|
|
10507
10632
|
ctl.renderPins();
|
|
@@ -10517,7 +10642,7 @@ function buildPollCoordOverlayScript() {
|
|
|
10517
10642
|
try {
|
|
10518
10643
|
const ctl = window.__kcaNextCoordOverlayV1;
|
|
10519
10644
|
if (!ctl || typeof ctl.getStatus !== 'function') {
|
|
10520
|
-
return
|
|
10645
|
+
return null;
|
|
10521
10646
|
}
|
|
10522
10647
|
return ctl.getStatus();
|
|
10523
10648
|
} catch {
|
|
@@ -10528,18 +10653,22 @@ function buildPollCoordOverlayScript() {
|
|
|
10528
10653
|
function buildRemoveCoordOverlayScript() {
|
|
10529
10654
|
return `(() => {
|
|
10530
10655
|
try {
|
|
10656
|
+
let removed = false;
|
|
10531
10657
|
const ctl = window.__kcaNextCoordOverlayV1;
|
|
10532
10658
|
if (ctl && typeof ctl.teardown === 'function') {
|
|
10659
|
+
removed = true;
|
|
10533
10660
|
const remain = (ctl.swallowingUntil || 0) - Date.now();
|
|
10534
10661
|
if (remain > 0) {
|
|
10535
10662
|
ctl.pickMode = false;
|
|
10663
|
+
ctl.pickToken = '';
|
|
10536
10664
|
if (ctl.banner) ctl.banner.style.display = 'none';
|
|
10537
10665
|
if (ctl.hud) ctl.hud.style.display = 'none';
|
|
10538
10666
|
if (ctl.pinsLayer) ctl.pinsLayer.style.display = 'none';
|
|
10539
10667
|
if (ctl.crossX) ctl.crossX.style.display = 'none';
|
|
10540
10668
|
if (ctl.crossY) ctl.crossY.style.display = 'none';
|
|
10541
10669
|
if (ctl.cursorTag) ctl.cursorTag.style.display = 'none';
|
|
10542
|
-
|
|
10670
|
+
if (ctl.teardownTimer) clearTimeout(ctl.teardownTimer);
|
|
10671
|
+
ctl.teardownTimer = setTimeout(() => {
|
|
10543
10672
|
try {
|
|
10544
10673
|
const cur = window.__kcaNextCoordOverlayV1;
|
|
10545
10674
|
if (cur && !cur.pickMode && typeof cur.teardown === 'function') cur.teardown();
|
|
@@ -10550,8 +10679,11 @@ function buildRemoveCoordOverlayScript() {
|
|
|
10550
10679
|
ctl.teardown();
|
|
10551
10680
|
}
|
|
10552
10681
|
const el = document.getElementById('__kca_next_coord_overlay__');
|
|
10553
|
-
if (el && el.parentNode)
|
|
10554
|
-
|
|
10682
|
+
if (el && el.parentNode) {
|
|
10683
|
+
el.parentNode.removeChild(el);
|
|
10684
|
+
removed = true;
|
|
10685
|
+
}
|
|
10686
|
+
return removed;
|
|
10555
10687
|
} catch {
|
|
10556
10688
|
return false;
|
|
10557
10689
|
}
|
|
@@ -12447,10 +12579,40 @@ var PoiGameBridge = class {
|
|
|
12447
12579
|
async inspectShipPicker() {
|
|
12448
12580
|
return this.runInKcs2Frame(buildNativeShipInspectorSource());
|
|
12449
12581
|
}
|
|
12582
|
+
async runInAllFrames(script, timeoutMs = 800) {
|
|
12583
|
+
const contents = this.getGameWebContents();
|
|
12584
|
+
if (!isContentsAlive(contents)) return;
|
|
12585
|
+
let frames = [];
|
|
12586
|
+
try {
|
|
12587
|
+
const root = contents.mainFrame;
|
|
12588
|
+
if (root) {
|
|
12589
|
+
frames = Array.from(root.framesInSubtree || [root]);
|
|
12590
|
+
}
|
|
12591
|
+
} catch {
|
|
12592
|
+
frames = [];
|
|
12593
|
+
}
|
|
12594
|
+
const targets = frames.length > 0 ? frames : [contents];
|
|
12595
|
+
await Promise.all(
|
|
12596
|
+
targets.slice(0, 12).map((frame) => {
|
|
12597
|
+
if (!frame || typeof frame.executeJavaScript !== "function") return Promise.resolve();
|
|
12598
|
+
return Promise.race([
|
|
12599
|
+
frame.executeJavaScript(script).catch(() => void 0),
|
|
12600
|
+
new Promise((r) => setTimeout(r, timeoutMs))
|
|
12601
|
+
]);
|
|
12602
|
+
})
|
|
12603
|
+
);
|
|
12604
|
+
}
|
|
12450
12605
|
async syncCoordOverlay(config) {
|
|
12451
12606
|
if (!config.visible && !config.pickMode) {
|
|
12452
|
-
await this.
|
|
12453
|
-
return {
|
|
12607
|
+
await this.runInAllFrames(buildRemoveCoordOverlayScript(), 800);
|
|
12608
|
+
return {
|
|
12609
|
+
active: false,
|
|
12610
|
+
pickMode: false,
|
|
12611
|
+
pickToken: "",
|
|
12612
|
+
hover: null,
|
|
12613
|
+
picked: null,
|
|
12614
|
+
cancelledToken: ""
|
|
12615
|
+
};
|
|
12454
12616
|
}
|
|
12455
12617
|
return this.runInKcs2Frame(buildCoordOverlayScript(config), 1200);
|
|
12456
12618
|
}
|
|
@@ -12478,7 +12640,7 @@ var PoiGameBridge = class {
|
|
|
12478
12640
|
}
|
|
12479
12641
|
}
|
|
12480
12642
|
dispose() {
|
|
12481
|
-
void this.
|
|
12643
|
+
void this.runInAllFrames(buildRemoveCoordOverlayScript(), 500).catch(() => void 0);
|
|
12482
12644
|
this.start2Cache.dispose();
|
|
12483
12645
|
this.releaseBackgroundLease();
|
|
12484
12646
|
if (typeof window !== "undefined") {
|
|
@@ -13702,6 +13864,12 @@ var PERIOD_LABELS = {
|
|
|
13702
13864
|
monthly: "\u6708\u5E38",
|
|
13703
13865
|
other: "\u5176\u4ED6"
|
|
13704
13866
|
};
|
|
13867
|
+
var REPAIR_DAMAGE_LABELS = {
|
|
13868
|
+
light: "\u5C0F\u7834\u53CA\u4EE5\u4E0A",
|
|
13869
|
+
moderate: "\u4E2D\u7834\u53CA\u4EE5\u4E0A",
|
|
13870
|
+
heavy: "\u4EC5\u5927\u7834",
|
|
13871
|
+
scratch: "\u5168\u90E8\u635F\u4F24(\u542B\u64E6\u4F24)"
|
|
13872
|
+
};
|
|
13705
13873
|
var OrgPracticeQuestsTab = ({ coordinator, settings }) => {
|
|
13706
13874
|
const [recordFleet, setRecordFleet] = (0, import_react4.useState)(1);
|
|
13707
13875
|
const [recordName, setRecordName] = (0, import_react4.useState)("");
|
|
@@ -14184,8 +14352,22 @@ var OrgPracticeQuestsTab = ({ coordinator, settings }) => {
|
|
|
14184
14352
|
storageKey: "modules.repair",
|
|
14185
14353
|
title: "\u81EA\u52A8\u5165\u6E20 (\u5F85\u547D\u8230\u5A18)",
|
|
14186
14354
|
defaultOpen: true,
|
|
14187
|
-
summary: /* @__PURE__ */ import_react4.default.createElement("span", null, "Lv\u2265", rep.minLevel, " \xB7 \u7559", rep.reservedDocks, "\u6E20
|
|
14355
|
+
summary: /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement("span", null, REPAIR_DAMAGE_LABELS[rep.damageThreshold ?? "light"], " \xB7 Lv\u2265", rep.minLevel, " \xB7 \u7559", rep.reservedDocks, "\u6E20"), rep.avoidSortieConflict !== false && /* @__PURE__ */ import_react4.default.createElement("span", { className: "kca-badge kca-badge-ok" }, "\u9632\u51FA\u51FB\u51B2\u7A81"))
|
|
14188
14356
|
},
|
|
14357
|
+
/* @__PURE__ */ import_react4.default.createElement("div", { className: "kca-row" }, /* @__PURE__ */ import_react4.default.createElement("span", null, "\u635F\u4F24\u6761\u4EF6"), /* @__PURE__ */ import_react4.default.createElement(
|
|
14358
|
+
"select",
|
|
14359
|
+
{
|
|
14360
|
+
className: "kca-select",
|
|
14361
|
+
value: rep.damageThreshold ?? "light",
|
|
14362
|
+
onChange: (e) => coordinator.updateSettings((s) => {
|
|
14363
|
+
s.repair.damageThreshold = e.target.value;
|
|
14364
|
+
})
|
|
14365
|
+
},
|
|
14366
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "light" }, "\u5C0F\u7834\u53CA\u4EE5\u4E0A (\u5C0F\u7834/\u4E2D\u7834/\u5927\u7834\uFF0C\u8DF3\u8FC7\u64E6\u4F24)"),
|
|
14367
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "moderate" }, "\u4E2D\u7834\u53CA\u4EE5\u4E0A (\u4E2D\u7834/\u5927\u7834)"),
|
|
14368
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "heavy" }, "\u4EC5\u5927\u7834 (HP \u2264 25%)"),
|
|
14369
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "scratch" }, "\u5168\u90E8\u635F\u4F24 (\u542B\u64E6\u4F24)")
|
|
14370
|
+
)),
|
|
14189
14371
|
/* @__PURE__ */ import_react4.default.createElement("div", { className: "kca-row" }, /* @__PURE__ */ import_react4.default.createElement("span", null, "\u6700\u4F4E\u7B49\u7EA7"), /* @__PURE__ */ import_react4.default.createElement(
|
|
14190
14372
|
"input",
|
|
14191
14373
|
{
|
|
@@ -14219,6 +14401,24 @@ var OrgPracticeQuestsTab = ({ coordinator, settings }) => {
|
|
|
14219
14401
|
/* @__PURE__ */ import_react4.default.createElement("option", { value: "shortest" }, "\u77ED\u65F6\u4F18\u5148"),
|
|
14220
14402
|
/* @__PURE__ */ import_react4.default.createElement("option", { value: "longest" }, "\u957F\u65F6\u4F18\u5148")
|
|
14221
14403
|
)),
|
|
14404
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
14405
|
+
"label",
|
|
14406
|
+
{
|
|
14407
|
+
className: "kca-switch",
|
|
14408
|
+
title: "\u5F00\u542F\u540E\uFF1A1) \u8DF3\u8FC7\u5F53\u524D\u6FC0\u6D3B\u51FA\u51FB\u65B9\u6848\u5019\u9009\u6C60\u4E2D\u7684\u8F6E\u6362\u8230\u5A18\uFF1B2) \u81EA\u52A8\u51FA\u51FB\u5F00\u542F\u65F6\u81F3\u5C11\u4FDD\u7559 1 \u4E2A\u7A7A\u6E20\u7ED9\u51FA\u51FB\u4FEE\u8239/\u6CFC\u6876\uFF1B3) \u51FA\u51FB\u95F4\u6B47\u5728\u6BCD\u6E2F\u5B89\u5168\u534F\u540C\u5165\u6E20\uFF0C\u4E0D\u62A2\u5360\u6218\u6597\u6216\u51FA\u51FB\u524D\u4FEE\u8239"
|
|
14409
|
+
},
|
|
14410
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
14411
|
+
"input",
|
|
14412
|
+
{
|
|
14413
|
+
type: "checkbox",
|
|
14414
|
+
checked: rep.avoidSortieConflict !== false,
|
|
14415
|
+
onChange: (e) => coordinator.updateSettings((s) => {
|
|
14416
|
+
s.repair.avoidSortieConflict = e.target.checked;
|
|
14417
|
+
})
|
|
14418
|
+
}
|
|
14419
|
+
),
|
|
14420
|
+
/* @__PURE__ */ import_react4.default.createElement("strong", null, "\u4E0E\u81EA\u52A8\u51FA\u51FB\u9632\u51B2\u7A81 (\u907F\u5F00\u51FA\u51FB\u5019\u9009\u8239 \xB7 \u81EA\u52A8\u7559\u22651\u7A7A\u6E20)")
|
|
14421
|
+
),
|
|
14222
14422
|
/* @__PURE__ */ import_react4.default.createElement("label", { className: "kca-switch" }, /* @__PURE__ */ import_react4.default.createElement(
|
|
14223
14423
|
"input",
|
|
14224
14424
|
{
|
|
@@ -15537,10 +15737,23 @@ var CoordPickerPanel = ({
|
|
|
15537
15737
|
const [liveGameHover, setLiveGameHover] = (0, import_react8.useState)(null);
|
|
15538
15738
|
const [lastFeedback, setLastFeedback] = (0, import_react8.useState)("");
|
|
15539
15739
|
const canvasBoxRef = (0, import_react8.useRef)(null);
|
|
15540
|
-
const
|
|
15541
|
-
const
|
|
15740
|
+
const pickSeqCounterRef = (0, import_react8.useRef)(0);
|
|
15741
|
+
const consumedTokenRef = (0, import_react8.useRef)("");
|
|
15742
|
+
const activePickToken = (0, import_react8.useMemo)(() => {
|
|
15743
|
+
if (!livePickTargetId) return "";
|
|
15744
|
+
pickSeqCounterRef.current += 1;
|
|
15745
|
+
return `pick-${Date.now().toString(36)}-${pickSeqCounterRef.current}`;
|
|
15746
|
+
}, [livePickTargetId]);
|
|
15747
|
+
const activePickTokenRef = (0, import_react8.useRef)(activePickToken);
|
|
15748
|
+
activePickTokenRef.current = activePickToken;
|
|
15542
15749
|
const livePickTargetRef = (0, import_react8.useRef)(livePickTargetId);
|
|
15543
15750
|
livePickTargetRef.current = livePickTargetId;
|
|
15751
|
+
const targetsRef = (0, import_react8.useRef)(targets);
|
|
15752
|
+
targetsRef.current = targets;
|
|
15753
|
+
const onPickCoordRef = (0, import_react8.useRef)(onPickCoord);
|
|
15754
|
+
onPickCoordRef.current = onPickCoord;
|
|
15755
|
+
const onCancelLivePickRef = (0, import_react8.useRef)(onCancelLivePick);
|
|
15756
|
+
onCancelLivePickRef.current = onCancelLivePick;
|
|
15544
15757
|
const selectedTarget = targets.find((t) => t.id === selectedTargetId) ?? targets[0];
|
|
15545
15758
|
const livePickTarget = livePickTargetId ? targets.find((t) => t.id === livePickTargetId) ?? null : null;
|
|
15546
15759
|
const allMarkers = [
|
|
@@ -15557,16 +15770,37 @@ var CoordPickerPanel = ({
|
|
|
15557
15770
|
const advanceTarget = (0, import_react8.useCallback)(
|
|
15558
15771
|
(justPickedId) => {
|
|
15559
15772
|
if (!autoAdvance) return;
|
|
15560
|
-
const
|
|
15773
|
+
const curTargets = targetsRef.current;
|
|
15774
|
+
const idx = curTargets.findIndex((t) => t.id === justPickedId);
|
|
15561
15775
|
if (idx < 0) return;
|
|
15562
|
-
const cur =
|
|
15563
|
-
const next =
|
|
15776
|
+
const cur = curTargets[idx];
|
|
15777
|
+
const next = curTargets[idx + 1];
|
|
15564
15778
|
if (next && next.group === cur.group) {
|
|
15565
15779
|
onSelectTarget(next.id);
|
|
15566
15780
|
}
|
|
15567
15781
|
},
|
|
15568
|
-
[autoAdvance,
|
|
15782
|
+
[autoAdvance, onSelectTarget]
|
|
15569
15783
|
);
|
|
15784
|
+
const advanceTargetRef = (0, import_react8.useRef)(advanceTarget);
|
|
15785
|
+
advanceTargetRef.current = advanceTarget;
|
|
15786
|
+
(0, import_react8.useEffect)(() => {
|
|
15787
|
+
if (!lastFeedback) return;
|
|
15788
|
+
const timer = setTimeout(() => {
|
|
15789
|
+
setLastFeedback("");
|
|
15790
|
+
}, 4500);
|
|
15791
|
+
return () => clearTimeout(timer);
|
|
15792
|
+
}, [lastFeedback]);
|
|
15793
|
+
(0, import_react8.useEffect)(() => {
|
|
15794
|
+
if (!livePickTargetId || typeof window === "undefined") return;
|
|
15795
|
+
const onKeyDown = (e) => {
|
|
15796
|
+
if (e.key === "Escape") {
|
|
15797
|
+
setLastFeedback("\u5DF2\u53D6\u6D88\u6E38\u620F\u753B\u9762\u53D6\u70B9");
|
|
15798
|
+
onCancelLivePickRef.current();
|
|
15799
|
+
}
|
|
15800
|
+
};
|
|
15801
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
15802
|
+
return () => window.removeEventListener("keydown", onKeyDown, true);
|
|
15803
|
+
}, [livePickTargetId]);
|
|
15570
15804
|
const captureScreenshot = (0, import_react8.useCallback)(async () => {
|
|
15571
15805
|
const fn = coordinator.bridge.captureGameDataUrl;
|
|
15572
15806
|
if (typeof fn !== "function") {
|
|
@@ -15601,6 +15835,7 @@ var CoordPickerPanel = ({
|
|
|
15601
15835
|
void syncFn.call(coordinator.bridge, {
|
|
15602
15836
|
visible: active,
|
|
15603
15837
|
pickMode: Boolean(livePickTargetId),
|
|
15838
|
+
pickToken: activePickToken,
|
|
15604
15839
|
pickLabel: livePickTarget?.label ?? "",
|
|
15605
15840
|
markers: allMarkers
|
|
15606
15841
|
}).then((status) => {
|
|
@@ -15608,22 +15843,16 @@ var CoordPickerPanel = ({
|
|
|
15608
15843
|
if (!status) {
|
|
15609
15844
|
if (livePickTargetId) {
|
|
15610
15845
|
setCaptureError("\u672A\u80FD\u8FDE\u63A5\u5230\u6E38\u620F\u753B\u9762\uFF08\u8BF7\u786E\u8BA4\u6E38\u620F\u5DF2\u8FDB\u5165\u753B\u5E03\uFF09\uFF0C\u5DF2\u53EF\u6539\u7528\u300C\u{1F4F8} \u622A\u56FE\u53EF\u89C6\u5316\u9009\u70B9\u300D\u3002");
|
|
15611
|
-
|
|
15846
|
+
onCancelLivePickRef.current();
|
|
15612
15847
|
}
|
|
15613
15848
|
return;
|
|
15614
15849
|
}
|
|
15615
|
-
if (status.picked && status.picked.seq > lastPickSeqRef.current) {
|
|
15616
|
-
lastPickSeqRef.current = status.picked.seq;
|
|
15617
|
-
}
|
|
15618
|
-
if (status.cancelledSeq > lastCancelSeqRef.current) {
|
|
15619
|
-
lastCancelSeqRef.current = status.cancelledSeq;
|
|
15620
|
-
}
|
|
15621
15850
|
setLiveGameHover(status.hover);
|
|
15622
15851
|
}).catch(() => void 0);
|
|
15623
15852
|
return () => {
|
|
15624
15853
|
cancelled = true;
|
|
15625
15854
|
};
|
|
15626
|
-
}, [coordinator.bridge, gameHudVisible, livePickTargetId, livePickTarget?.label, markersKey]);
|
|
15855
|
+
}, [coordinator.bridge, gameHudVisible, livePickTargetId, activePickToken, livePickTarget?.label, markersKey]);
|
|
15627
15856
|
(0, import_react8.useEffect)(() => {
|
|
15628
15857
|
const pollFn = coordinator.bridge.pollCoordOverlay;
|
|
15629
15858
|
if (typeof pollFn !== "function") return;
|
|
@@ -15633,40 +15862,39 @@ var CoordPickerPanel = ({
|
|
|
15633
15862
|
return;
|
|
15634
15863
|
}
|
|
15635
15864
|
let alive = true;
|
|
15636
|
-
|
|
15865
|
+
let inFlight = false;
|
|
15866
|
+
const intervalMs = livePickTargetId ? 140 : 280;
|
|
15637
15867
|
const timer = setInterval(() => {
|
|
15868
|
+
if (inFlight) return;
|
|
15869
|
+
inFlight = true;
|
|
15638
15870
|
void pollFn.call(coordinator.bridge).then((status) => {
|
|
15639
15871
|
if (!alive || !status) return;
|
|
15640
15872
|
setLiveGameHover(status.hover);
|
|
15641
15873
|
const pendingId = livePickTargetRef.current;
|
|
15642
|
-
|
|
15643
|
-
|
|
15874
|
+
const expectedToken = activePickTokenRef.current;
|
|
15875
|
+
if (!pendingId || !expectedToken || consumedTokenRef.current === expectedToken) return;
|
|
15876
|
+
if (status.picked && status.picked.token === expectedToken) {
|
|
15877
|
+
consumedTokenRef.current = expectedToken;
|
|
15644
15878
|
const { x, y } = status.picked;
|
|
15645
|
-
const lbl =
|
|
15646
|
-
|
|
15647
|
-
setLastFeedback(`\u5DF2\
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
} else if (
|
|
15651
|
-
|
|
15879
|
+
const lbl = targetsRef.current.find((t) => t.id === pendingId)?.label ?? pendingId;
|
|
15880
|
+
onPickCoordRef.current(pendingId, x, y);
|
|
15881
|
+
setLastFeedback(`\u5DF2\u586B\u5165 [${lbl}] \u2192 (${x}, ${y})`);
|
|
15882
|
+
onCancelLivePickRef.current();
|
|
15883
|
+
advanceTargetRef.current(pendingId);
|
|
15884
|
+
} else if (status.cancelledToken && status.cancelledToken === expectedToken) {
|
|
15885
|
+
consumedTokenRef.current = expectedToken;
|
|
15652
15886
|
setLastFeedback("\u5DF2\u53D6\u6D88\u6E38\u620F\u753B\u9762\u53D6\u70B9");
|
|
15653
|
-
|
|
15887
|
+
onCancelLivePickRef.current();
|
|
15654
15888
|
}
|
|
15655
|
-
}).catch(() => void 0)
|
|
15889
|
+
}).catch(() => void 0).finally(() => {
|
|
15890
|
+
inFlight = false;
|
|
15891
|
+
});
|
|
15656
15892
|
}, intervalMs);
|
|
15657
15893
|
return () => {
|
|
15658
15894
|
alive = false;
|
|
15659
15895
|
clearInterval(timer);
|
|
15660
15896
|
};
|
|
15661
|
-
}, [
|
|
15662
|
-
coordinator.bridge,
|
|
15663
|
-
gameHudVisible,
|
|
15664
|
-
livePickTargetId,
|
|
15665
|
-
targets,
|
|
15666
|
-
onPickCoord,
|
|
15667
|
-
onCancelLivePick,
|
|
15668
|
-
advanceTarget
|
|
15669
|
-
]);
|
|
15897
|
+
}, [coordinator.bridge, gameHudVisible, livePickTargetId]);
|
|
15670
15898
|
(0, import_react8.useEffect)(() => {
|
|
15671
15899
|
return () => {
|
|
15672
15900
|
const syncFn = coordinator.bridge.syncCoordOverlay;
|
|
@@ -15690,10 +15918,10 @@ var CoordPickerPanel = ({
|
|
|
15690
15918
|
setLastFeedback(`\u5DF2\u5728\u622A\u56FE\u586B\u5165 [${selectedTarget.label}] \u2192 (${pt.x}, ${pt.y})`);
|
|
15691
15919
|
advanceTarget(selectedTarget.id);
|
|
15692
15920
|
};
|
|
15693
|
-
if (!screenshotOpen && !gameHudVisible && !livePickTargetId && !lastFeedback) {
|
|
15921
|
+
if (!screenshotOpen && !gameHudVisible && !livePickTargetId && !lastFeedback && !captureError) {
|
|
15694
15922
|
return null;
|
|
15695
15923
|
}
|
|
15696
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-coord-studio" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { justifyContent: "space-between" } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { gap: 6 } }, /* @__PURE__ */ import_react8.default.createElement("strong", { style: { color: "#7dd3fc" } }, "\u{1F3AF} \u53EF\u89C6\u5316\u5750\u6807\u62FE\u53D6\u5668 (1200\xD7720)"), liveGameHover && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-run" }, "\u6E38\u620F\u5B9E\u65F6\u9F20\u6807: X ", liveGameHover.x, ", Y ", liveGameHover.y), livePickTarget && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-warn" }, "\u53D6\u70B9\u4E2D [", livePickTarget.label, "] \u2014 \
|
|
15924
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-coord-studio" }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { justifyContent: "space-between" } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { gap: 6 } }, /* @__PURE__ */ import_react8.default.createElement("strong", { style: { color: "#7dd3fc" } }, "\u{1F3AF} \u53EF\u89C6\u5316\u5750\u6807\u62FE\u53D6\u5668 (1200\xD7720)"), liveGameHover && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-run" }, "\u6E38\u620F\u5B9E\u65F6\u9F20\u6807: X ", liveGameHover.x, ", Y ", liveGameHover.y), livePickTarget && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-warn" }, "\u53D6\u70B9\u4E2D [", livePickTarget.label, "] \u2014 \u5DE6\u952E\u70B9\u6E38\u620F\u753B\u9762\u586B\u5165\uFF08\u53F3\u952E / Esc / \u53D6\u6D88\uFF09"), !livePickTarget && lastFeedback && /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-badge kca-badge-ok" }, lastFeedback)), /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { gap: 5 } }, livePickTarget && /* @__PURE__ */ import_react8.default.createElement("button", { className: "kca-btn kca-btn-sm kca-btn-danger", onClick: onCancelLivePick }, "\u53D6\u6D88\u53D6\u70B9"), /* @__PURE__ */ import_react8.default.createElement(
|
|
15697
15925
|
"button",
|
|
15698
15926
|
{
|
|
15699
15927
|
className: `kca-btn kca-btn-sm ${gameHudVisible ? "kca-btn-primary" : ""}`,
|
|
@@ -15701,7 +15929,18 @@ var CoordPickerPanel = ({
|
|
|
15701
15929
|
title: "\u5728\u8230\u5A18\u6E38\u620F\u753B\u9762\u4E0A\u5B9E\u65F6\u663E\u793A\u9F20\u6807\u5750\u6807\u4E0E\u5168\u90E8\u5DF2\u914D\u7F6E\u7684\u5206\u6B67/\u9646\u822A/\u8DEF\u5F84\u6807\u8BB0\uFF08\u9F20\u6807\u7A7F\u900F\uFF0C\u4E0D\u5F71\u54CD\u6E38\u73A9\uFF09"
|
|
15702
15930
|
},
|
|
15703
15931
|
gameHudVisible ? "\u{1F441}\uFE0F \u5173\u95ED\u6E38\u620F\u5750\u6807\u663E\u793A" : "\u{1F441}\uFE0F \u6E38\u620F\u53E0\u52A0\u5B9E\u65F6\u5750\u6807"
|
|
15704
|
-
), screenshotOpen && /* @__PURE__ */ import_react8.default.createElement("button", { className: "kca-btn kca-btn-sm", onClick: onCloseScreenshot }, "\u6536\u8D77\u622A\u56FE\u9762\u677F")
|
|
15932
|
+
), screenshotOpen && /* @__PURE__ */ import_react8.default.createElement("button", { className: "kca-btn kca-btn-sm", onClick: onCloseScreenshot }, "\u6536\u8D77\u622A\u56FE\u9762\u677F"), !screenshotOpen && !gameHudVisible && !livePickTargetId && /* @__PURE__ */ import_react8.default.createElement(
|
|
15933
|
+
"button",
|
|
15934
|
+
{
|
|
15935
|
+
className: "kca-btn kca-btn-sm",
|
|
15936
|
+
title: "\u5173\u95ED\u6B64\u63D0\u793A",
|
|
15937
|
+
onClick: () => {
|
|
15938
|
+
setLastFeedback("");
|
|
15939
|
+
setCaptureError("");
|
|
15940
|
+
}
|
|
15941
|
+
},
|
|
15942
|
+
"\u2715 \u5173\u95ED"
|
|
15943
|
+
))), !screenshotOpen && captureError && /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-import-banner kca-import-banner-err" }, captureError), screenshotOpen && /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-row", style: { justifyContent: "space-between", gap: 6 } }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "kca-chip-list" }, /* @__PURE__ */ import_react8.default.createElement("span", { className: "kca-muted" }, "\u70B9\u51FB\u76EE\u6807\uFF1A"), targets.map((t) => {
|
|
15705
15944
|
const active = selectedTarget?.id === t.id;
|
|
15706
15945
|
const configured = t.x > 0 || t.y > 0;
|
|
15707
15946
|
return /* @__PURE__ */ import_react8.default.createElement(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poi-plugin-kca-next",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "High-performance native poi KanColle automation replacement for (非)提助手 — zero DRM, zero extra browser, event-driven in-process engine",
|
|
5
5
|
"author": "machilus",
|
|
6
6
|
"main": "dist/index.js",
|