avatar fixes and implementation to edit
This commit is contained in:
parent
acab2f017d
commit
c3320ddcce
11 changed files with 1417 additions and 37 deletions
|
|
@ -1968,3 +1968,127 @@ impl AvatarWithPaths {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Avatar Slot Update Models
|
||||
// =============================================================================
|
||||
|
||||
/// Request to assign an inventory item to an avatar slot.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct AssignSlotRequest {
|
||||
/// Inventory item ID to assign to the slot.
|
||||
pub inventory_item_id: Uuid,
|
||||
/// Layer type: "skin", "clothes", "accessories", or an emotion name.
|
||||
pub layer: String,
|
||||
/// Grid position (0-8).
|
||||
pub position: u8,
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
impl AssignSlotRequest {
|
||||
/// Validate the assign slot request.
|
||||
pub fn validate(&self) -> Result<(), AppError> {
|
||||
if self.position > 8 {
|
||||
return Err(AppError::Validation(
|
||||
"Position must be between 0 and 8".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
// Validate layer name
|
||||
let valid_layers = [
|
||||
"skin",
|
||||
"clothes",
|
||||
"accessories",
|
||||
"neutral",
|
||||
"happy",
|
||||
"sad",
|
||||
"angry",
|
||||
"surprised",
|
||||
"thinking",
|
||||
"laughing",
|
||||
"crying",
|
||||
"love",
|
||||
"confused",
|
||||
"sleeping",
|
||||
"wink",
|
||||
];
|
||||
if !valid_layers.contains(&self.layer.to_lowercase().as_str()) {
|
||||
return Err(AppError::Validation(format!(
|
||||
"Invalid layer: {}",
|
||||
self.layer
|
||||
)));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the database column name for this slot.
|
||||
pub fn column_name(&self) -> String {
|
||||
let layer = self.layer.to_lowercase();
|
||||
match layer.as_str() {
|
||||
"skin" => format!("l_skin_{}", self.position),
|
||||
"clothes" => format!("l_clothes_{}", self.position),
|
||||
"accessories" => format!("l_accessories_{}", self.position),
|
||||
_ => format!("e_{}_{}", layer, self.position),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Request to clear an avatar slot.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ClearSlotRequest {
|
||||
/// Layer type: "skin", "clothes", "accessories", or an emotion name.
|
||||
pub layer: String,
|
||||
/// Grid position (0-8).
|
||||
pub position: u8,
|
||||
}
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
impl ClearSlotRequest {
|
||||
/// Validate the clear slot request.
|
||||
pub fn validate(&self) -> Result<(), AppError> {
|
||||
if self.position > 8 {
|
||||
return Err(AppError::Validation(
|
||||
"Position must be between 0 and 8".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
// Validate layer name
|
||||
let valid_layers = [
|
||||
"skin",
|
||||
"clothes",
|
||||
"accessories",
|
||||
"neutral",
|
||||
"happy",
|
||||
"sad",
|
||||
"angry",
|
||||
"surprised",
|
||||
"thinking",
|
||||
"laughing",
|
||||
"crying",
|
||||
"love",
|
||||
"confused",
|
||||
"sleeping",
|
||||
"wink",
|
||||
];
|
||||
if !valid_layers.contains(&self.layer.to_lowercase().as_str()) {
|
||||
return Err(AppError::Validation(format!(
|
||||
"Invalid layer: {}",
|
||||
self.layer
|
||||
)));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the database column name for this slot.
|
||||
pub fn column_name(&self) -> String {
|
||||
let layer = self.layer.to_lowercase();
|
||||
match layer.as_str() {
|
||||
"skin" => format!("l_skin_{}", self.position),
|
||||
"clothes" => format!("l_clothes_{}", self.position),
|
||||
"accessories" => format!("l_accessories_{}", self.position),
|
||||
_ => format!("e_{}_{}", layer, self.position),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue