feat: enhance hidden domains serialization and UI representation
- Updated `serialize_active_domains` to include both active and inactive hidden domains, adding an `is_open` property for each domain. - Modified `StatusBar` and `StatusWidget` components to reflect the new domain state, displaying appropriate labels and colors based on the activation status. - Adjusted localization files for English and Chinese to align with the updated hidden domain features.
This commit is contained in:
@@ -173,26 +173,40 @@ manager = ConnectionManager()
|
|||||||
|
|
||||||
|
|
||||||
def serialize_active_domains(world: World) -> List[dict]:
|
def serialize_active_domains(world: World) -> List[dict]:
|
||||||
"""序列化当前开启的秘境列表"""
|
"""序列化所有秘境列表(包括开启和未开启的)"""
|
||||||
domains_data = []
|
domains_data = []
|
||||||
if not world or not world.gathering_manager:
|
if not world or not world.gathering_manager:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
# 找到 HiddenDomain 实例
|
||||||
|
hidden_domain_gathering = None
|
||||||
for gathering in world.gathering_manager.gatherings:
|
for gathering in world.gathering_manager.gatherings:
|
||||||
# Check by class name to avoid circular imports
|
|
||||||
if gathering.__class__.__name__ == "HiddenDomain":
|
if gathering.__class__.__name__ == "HiddenDomain":
|
||||||
# Accessing _active_domains safely
|
hidden_domain_gathering = gathering
|
||||||
active_domains = getattr(gathering, "_active_domains", [])
|
break
|
||||||
for d in active_domains:
|
|
||||||
domains_data.append({
|
if hidden_domain_gathering:
|
||||||
"id": d.id,
|
# 获取所有配置(假设 _load_configs 开销不大,或者已缓存)
|
||||||
"name": d.name,
|
# 这里为了确保获取最新状态,重新加载配置
|
||||||
"desc": d.desc,
|
# 注意:访问受保护方法 _load_configs
|
||||||
# Use str() to trigger Realm.__str__ which returns translated text
|
all_configs = hidden_domain_gathering._load_configs()
|
||||||
"max_realm": str(d.max_realm),
|
|
||||||
"danger_prob": d.danger_prob,
|
# 获取当前开启的 ID 集合
|
||||||
"drop_prob": d.drop_prob
|
active_ids = {d.id for d in hidden_domain_gathering._active_domains}
|
||||||
})
|
|
||||||
|
for d in all_configs:
|
||||||
|
is_open = d.id in active_ids
|
||||||
|
|
||||||
|
domains_data.append({
|
||||||
|
"id": d.id,
|
||||||
|
"name": d.name,
|
||||||
|
"desc": d.desc,
|
||||||
|
"max_realm": str(d.max_realm),
|
||||||
|
"danger_prob": d.danger_prob,
|
||||||
|
"drop_prob": d.drop_prob,
|
||||||
|
"is_open": is_open
|
||||||
|
})
|
||||||
|
|
||||||
return domains_data
|
return domains_data
|
||||||
|
|
||||||
def serialize_events_for_client(events: List[Event]) -> List[dict]:
|
def serialize_events_for_client(events: List[Event]) -> List[dict]:
|
||||||
|
|||||||
@@ -19,14 +19,13 @@ const phenomenonColor = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const domainLabel = computed(() => {
|
const domainLabel = computed(() => {
|
||||||
const count = store.activeDomains.length;
|
return t('game.status_bar.hidden_domain.label');
|
||||||
return count > 0
|
|
||||||
? t('game.status_bar.hidden_domain.label_active', { count })
|
|
||||||
: t('game.status_bar.hidden_domain.label');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const domainColor = computed(() => {
|
const domainColor = computed(() => {
|
||||||
return store.activeDomains.length > 0 ? '#fa8c16' : '#666'; // 有秘境时亮橙色,否则灰色
|
// 如果有任意一个秘境是开启状态,则亮色
|
||||||
|
const anyOpen = store.activeDomains.some(d => d.is_open);
|
||||||
|
return anyOpen ? '#fa8c16' : '#666'; // 有开启亮橙色,全关闭灰色
|
||||||
});
|
});
|
||||||
|
|
||||||
function getRarityColor(rarity: string) {
|
function getRarityColor(rarity: string) {
|
||||||
|
|||||||
@@ -52,9 +52,13 @@ const emit = defineEmits(['trigger-click'])
|
|||||||
|
|
||||||
<n-list v-if="items.length > 0" hoverable clickable>
|
<n-list v-if="items.length > 0" hoverable clickable>
|
||||||
<n-list-item v-for="item in items" :key="item.id">
|
<n-list-item v-for="item in items" :key="item.id">
|
||||||
<div class="domain-item">
|
<div class="domain-item" :class="{ 'is-closed': !item.is_open }">
|
||||||
<div class="d-header">
|
<div class="d-header">
|
||||||
<span class="d-name">{{ item.name }}</span>
|
<div class="d-title-group">
|
||||||
|
<span class="d-name">{{ item.name }}</span>
|
||||||
|
<n-tag v-if="!item.is_open" size="small" :bordered="false" class="d-status closed">未开启</n-tag>
|
||||||
|
<n-tag v-else size="small" :bordered="false" type="success" class="d-status open">开启中</n-tag>
|
||||||
|
</div>
|
||||||
<n-tag size="small" :bordered="false" type="warning" class="d-tag">
|
<n-tag size="small" :bordered="false" type="warning" class="d-tag">
|
||||||
{{ item.max_realm }}
|
{{ item.max_realm }}
|
||||||
</n-tag>
|
</n-tag>
|
||||||
@@ -92,9 +96,13 @@ const emit = defineEmits(['trigger-click'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
.domain-item { padding: 4px 0; }
|
.domain-item { padding: 4px 0; }
|
||||||
|
.domain-item.is-closed { opacity: 0.5; filter: grayscale(0.8); }
|
||||||
|
|
||||||
.d-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
|
.d-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
|
||||||
|
.d-title-group { display: flex; align-items: center; gap: 8px; }
|
||||||
.d-name { font-weight: bold; color: #fadb14; font-size: 14px; }
|
.d-name { font-weight: bold; color: #fadb14; font-size: 14px; }
|
||||||
.d-tag { font-size: 10px; height: 18px; line-height: 18px; }
|
.d-tag { font-size: 10px; height: 18px; line-height: 18px; }
|
||||||
|
.d-status { font-size: 10px; height: 18px; line-height: 18px; padding: 0 4px; }
|
||||||
.d-desc { font-size: 12px; color: #aaa; margin-bottom: 8px; line-height: 1.4; }
|
.d-desc { font-size: 12px; color: #aaa; margin-bottom: 8px; line-height: 1.4; }
|
||||||
.d-stats { display: flex; gap: 12px; font-size: 12px; color: #888; }
|
.d-stats { display: flex; gap: 12px; font-size: 12px; color: #888; }
|
||||||
.empty-state { padding: 20px; }
|
.empty-state { padding: 20px; }
|
||||||
|
|||||||
@@ -233,9 +233,8 @@
|
|||||||
"author_github": "Github",
|
"author_github": "Github",
|
||||||
"hidden_domain": {
|
"hidden_domain": {
|
||||||
"label": "[Hidden Domain]",
|
"label": "[Hidden Domain]",
|
||||||
"label_active": "[Domain Opened: {count}]",
|
"title": "Hidden Domains List",
|
||||||
"title": "Opened Hidden Domains",
|
"empty": "No hidden domains data",
|
||||||
"empty": "No hidden domains currently open",
|
|
||||||
"danger": "Danger",
|
"danger": "Danger",
|
||||||
"drop": "Fortune"
|
"drop": "Fortune"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,9 +233,8 @@
|
|||||||
"author_github": "Github仓库",
|
"author_github": "Github仓库",
|
||||||
"hidden_domain": {
|
"hidden_domain": {
|
||||||
"label": "[秘境]",
|
"label": "[秘境]",
|
||||||
"label_active": "[秘境开启: {count}]",
|
"title": "秘境列表",
|
||||||
"title": "当前开启秘境",
|
"empty": "暂无秘境数据",
|
||||||
"empty": "当前暂无秘境开启",
|
|
||||||
"danger": "凶险",
|
"danger": "凶险",
|
||||||
"drop": "机缘"
|
"drop": "机缘"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ export interface HiddenDomainInfo {
|
|||||||
max_realm: string; // 限制境界
|
max_realm: string; // 限制境界
|
||||||
danger_prob: number; // 凶险度 (0.0 - 1.0)
|
danger_prob: number; // 凶险度 (0.0 - 1.0)
|
||||||
drop_prob: number; // 机缘度 (0.0 - 1.0)
|
drop_prob: number; // 机缘度 (0.0 - 1.0)
|
||||||
|
is_open: boolean; // 是否开启
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 事件 (Events) ---
|
// --- 事件 (Events) ---
|
||||||
|
|||||||
Reference in New Issue
Block a user