1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Make edit mode usable; complete #11

This commit is contained in:
NGnius (Graham)
2025-03-15 11:03:35 -04:00
parent 47eb32056c
commit 6fd4d673ca
40 changed files with 5313 additions and 2162 deletions

View File

@@ -6,14 +6,18 @@ const SLOT_PARAM_KEY: u8 = 31; // int
const DATA_PARAM_KEY: u8 = 33; // byte arr
pub(super) fn garage_machine_colour_provider() -> SimpleFunc<33, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
SimpleFunc::new(|params, user: &crate::UserTy| {
let mut params = params.to_dict();
if let Some(garage_slot) = params.get(&SLOT_PARAM_KEY) {
let lock = user.read().unwrap();
let user_info = lock.user()?;
if let Some(Typed::Int(garage_slot)) = params.get(&SLOT_PARAM_KEY) {
log::debug!("Got machine colour request for slot {:?}", garage_slot);
let machine = user_info.slot_by_id(*garage_slot)?;
params.insert(DATA_PARAM_KEY, machine.colour_data);
} else {
params.insert(SLOT_PARAM_KEY, Typed::Int(0));
params.insert(SLOT_PARAM_KEY, Typed::Int(user_info.selected_garage_slot() as _));
}
params.insert(DATA_PARAM_KEY, Typed::Bytes(vec![0u8, 0u8, 0u8, 0u8].into())); // first 4 bytes are i32 for length of rest of data
Ok(params.into())
})
}