Skip to content

Commit 3e96b8d

Browse files
committed
1. 解决玩家城镇识别失败问题
2. 避免过多玩家可选择时长度过长
1 parent 58de77e commit 3e96b8d

5 files changed

Lines changed: 28 additions & 20 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MCTeamViewer-map-projection",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"private": true,
55
"type": "module",
66
"scripts": {

src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const DEFAULT_CONFIG = {
3939
REPORTER_CHUNK_COLOR: '',
4040
REPORTER_CHUNK_OPACITY: 0.11,
4141
AUTO_TEAM_FROM_NAME: true,
42-
FRIENDLY_TAGS: '[xxx]',
43-
ENEMY_TAGS: '[yyy]',
42+
FRIENDLY_TAGS: 'xxx',
43+
ENEMY_TAGS: 'yyy',
4444
TEAM_COLOR_FRIENDLY: '#3b82f6',
4545
TEAM_COLOR_ENEMY: '#ef4444',
4646
TEAM_COLOR_NEUTRAL: '#94a3b8',

src/index.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,16 @@ declare const unsafeWindow: Window | undefined;
117117
const displayNameRaw = String(node.displayName || '').trim();
118118
const name = String(node.name || '').trim();
119119
const parsedDisplay = parseMcDisplayName(displayNameRaw || prefixedName);
120+
const teamText = parsedDisplay.teamText || (prefixedName ? `[${prefixedName}]` : '');
120121

121122
return {
122123
name,
123-
teamText: parsedDisplay.teamText,
124+
teamText,
124125
teamColor: parsedDisplay.color,
125126
autoName: prefixedName || parsedDisplay.plain || name || null,
127+
displayNameRaw,
128+
prefixedName,
129+
matchedBy: 'uuid',
126130
};
127131
}
128132
}
@@ -668,6 +672,7 @@ declare const unsafeWindow: Window | undefined;
668672
help: '显示可用命令',
669673
summary: '查看连接状态/对象数量/最近消息',
670674
snapshot: '输出最新内存快照',
675+
playerTab: '按玩家ID查看 tab 匹配与城镇解析结果',
671676
markers: '输出当前地图 marker 统计',
672677
ws: '输出 websocket 状态',
673678
last: '输出最近一条 ws 消息元信息',
@@ -698,6 +703,22 @@ declare const unsafeWindow: Window | undefined;
698703
snapshot() {
699704
return latestSnapshot;
700705
},
706+
playerTab(playerId) {
707+
const normalizedId = String(playerId || '').trim();
708+
const playerNode = normalizedId && latestSnapshot && typeof latestSnapshot.players === 'object'
709+
? latestSnapshot.players[normalizedId]
710+
: null;
711+
const playerData = getPlayerDataNode(playerNode);
712+
const tabInfo = normalizedId ? getTabPlayerInfo(normalizedId) : null;
713+
return {
714+
playerId: normalizedId,
715+
playerData,
716+
tabInfo,
717+
renderedTownText: tabInfo && typeof tabInfo.teamText === 'string' ? tabInfo.teamText : '',
718+
showPlayerText: Boolean(CONFIG.SHOW_PLAYER_TEXT),
719+
showTownInfo: Boolean(CONFIG.SHOW_LABEL_TOWN_INFO),
720+
};
721+
},
701722
markers() {
702723
return mapProjection.getCounts();
703724
},

src/meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const USERSCRIPT_META = {
22
name: '地图玩家投影 - squaremap 版',
33
namespace: 'https://map.nodemc.cc/',
4-
version: '0.4.1',
4+
version: '0.4.2',
55
description: '将远程玩家信息投影到 squaremap 地图',
66
author: 'Prof. Chen',
77
match: [

src/ui/components/OverlaySettingsPanel.vue

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ const quickLabels = ['侦查', '重点观察', '突击组', '运输', '危险'];
122122
123123
const hasPlayers = computed(() => props.state.players.length > 0);
124124
const hasMapPlayers = computed(() => props.state.mapPlayers.length > 0);
125-
const quickPlayers = computed(() => props.state.players.slice(0, 8));
126125
const configMenuVisible = ref(false);
127126
128127
const statusToneClass = computed(() => {
@@ -397,18 +396,6 @@ function applyQuickLabel(label: string) {
397396
</option>
398397
</select>
399398
</div>
400-
<div v-if="quickPlayers.length > 0" class="n-chip-list full-width">
401-
<button
402-
v-for="item in quickPlayers"
403-
:key="item.playerId"
404-
type="button"
405-
class="n-chip-btn"
406-
:class="{ active: state.selectedPlayerId === item.playerId }"
407-
@click="selectPlayer(item.playerId)"
408-
>
409-
{{ item.playerName }}
410-
</button>
411-
</div>
412399
<div class="n-segmented full-width">
413400
<button type="button" class="n-segment-btn is-friendly" :class="{ active: state.mark.team === 'friendly' }" @click="applyTeamPreset('friendly')">友军</button>
414401
<button type="button" class="n-segment-btn is-neutral" :class="{ active: state.mark.team === 'neutral' }" @click="applyTeamPreset('neutral')">中立</button>
@@ -439,11 +426,11 @@ function applyQuickLabel(label: string) {
439426
<div class="n-subtitle">自动识别标签</div>
440427
<div class="n-row">
441428
<label>友军标签(逗号分隔,按游戏中的前缀识别)</label>
442-
<input v-model="state.form.FRIENDLY_TAGS" @input="markMainTextDirty" id="nodemc-overlay-friendly-tags" type="text" placeholder="[xxx],[队友]" />
429+
<input v-model="state.form.FRIENDLY_TAGS" @input="markMainTextDirty" id="nodemc-overlay-friendly-tags" type="text" placeholder="xxx,队友" />
443430
</div>
444431
<div class="n-row">
445432
<label>敌军标签(逗号分隔,按游戏中的前缀识别)</label>
446-
<input v-model="state.form.ENEMY_TAGS" @input="markMainTextDirty" id="nodemc-overlay-enemy-tags" type="text" placeholder="[yyy],[红队]" />
433+
<input v-model="state.form.ENEMY_TAGS" @input="markMainTextDirty" id="nodemc-overlay-enemy-tags" type="text" placeholder="yyy,红队" />
447434
</div>
448435
<label class="n-check full-width"><input v-model="state.form.AUTO_TEAM_FROM_NAME" @change="triggerAutoApply" id="nodemc-overlay-auto-team" type="checkbox" />按名字标签自动判定友敌</label>
449436
<div class="n-btns">

0 commit comments

Comments
 (0)