QuickMenu bugfix

This commit is contained in:
YYHEggEgg 2024-08-06 17:02:49 +08:00
parent bb058b451d
commit 436e691245
2 changed files with 16 additions and 13 deletions

View file

@ -2,7 +2,7 @@ use crate::logic::{EOperator, ESystem};
use super::*; use super::*;
use data::tables::{self, QuickAccessID}; use data::tables::{self, QuickFuncID};
pub async fn on_get_tips_info( pub async fn on_get_tips_info(
_session: &NetSession, _session: &NetSession,
@ -205,13 +205,13 @@ pub async fn on_mod_quick_menu(
quick_access_data_list.push( quick_access_data_list.push(
_player _player
.lock_model .lock_model
.mod_quick_access(data.quick_access_index, QuickAccessID::new(data.btn_id)), .mod_quick_access(data.quick_access_index, QuickFuncID::new(data.btn_id)),
); );
} }
_session _session
.notify(PlayerSyncScNotify { .notify(PlayerSyncScNotify {
client_systems_sync: Some(ClientSystemsSync { client_systems_sync: Some(ClientSystemsSync {
quick_access_data_list, quick_access_data_list: _player.lock_model.quick_access_to_client(),
..Default::default() ..Default::default()
}), }),
..Default::default() ..Default::default()

View file

@ -1,12 +1,12 @@
use std::collections::{BTreeSet, HashMap}; use std::collections::{BTreeSet, HashMap};
use data::tables::{quick_access_template_tb, QuickAccessID, UnlockConfigID}; use data::tables::{quick_access_template_tb, QuickFuncID, UnlockConfigID};
use proto::{LockModelBin, QuickAccessData, QuickAccessType, UnlockData}; use proto::{LockModelBin, QuickAccessData, QuickAccessType, UnlockData};
#[derive(Default)] #[derive(Default)]
pub struct LockModel { pub struct LockModel {
unlock_list: BTreeSet<UnlockConfigID>, unlock_list: BTreeSet<UnlockConfigID>,
quick_access_list: HashMap<u32, QuickAccessID>, quick_access_list: HashMap<u32, QuickFuncID>,
} }
impl LockModel { impl LockModel {
@ -20,7 +20,7 @@ impl LockModel {
quick_access_list: bin quick_access_list: bin
.quick_access_list .quick_access_list
.into_iter() .into_iter()
.map(|(k, v)| (k, QuickAccessID::new_unchecked(v))) .map(|(k, v)| (k, QuickFuncID::new_unchecked(v)))
.collect(), .collect(),
} }
} }
@ -35,14 +35,13 @@ impl LockModel {
.collect(), .collect(),
quick_access_list: self quick_access_list: self
.quick_access_list .quick_access_list
.clone() .iter()
.into_iter() .map(|(k, v)| (k.clone(), v.value()))
.map(|(k, v)| (k, v.value()))
.collect(), .collect(),
} }
} }
pub fn to_client(&self) -> UnlockData { pub fn quick_access_to_client(&self) -> Vec<QuickAccessData> {
let mut quick_access_data_list: Vec<QuickAccessData> = vec![]; let mut quick_access_data_list: Vec<QuickAccessData> = vec![];
for quick_access in quick_access_template_tb::iter() { for quick_access in quick_access_template_tb::iter() {
quick_access_data_list.push(QuickAccessData { quick_access_data_list.push(QuickAccessData {
@ -51,7 +50,7 @@ impl LockModel {
btn_id: quick_access.quick_func_id.value(), btn_id: quick_access.quick_func_id.value(),
}); });
} }
for quick_access_index in 1..7 { for quick_access_index in 1..8 {
let mut btn_id = 0; let mut btn_id = 0;
if let Some(id) = self.quick_access_list.get(&quick_access_index) { if let Some(id) = self.quick_access_list.get(&quick_access_index) {
btn_id = id.value(); btn_id = id.value();
@ -62,6 +61,10 @@ impl LockModel {
btn_id, btn_id,
}); });
} }
quick_access_data_list
}
pub fn to_client(&self) -> UnlockData {
UnlockData { UnlockData {
unlock_id_list: self unlock_id_list: self
@ -70,7 +73,7 @@ impl LockModel {
.into_iter() .into_iter()
.map(|i| i.value()) .map(|i| i.value())
.collect(), .collect(),
quick_access_data_list, quick_access_data_list: self.quick_access_to_client(),
..Default::default() ..Default::default()
} }
} }
@ -83,7 +86,7 @@ impl LockModel {
self.unlock_list.contains(&id) self.unlock_list.contains(&id)
} }
pub fn mod_quick_access(&mut self, index: u32, id: Option<QuickAccessID>) -> QuickAccessData { pub fn mod_quick_access(&mut self, index: u32, id: Option<QuickFuncID>) -> QuickAccessData {
let btn_id = match id { let btn_id = match id {
Some(quick_access_id) => { Some(quick_access_id) => {
if self.quick_access_list.contains_key(&index) { if self.quick_access_list.contains_key(&index) {