|
|
@ -2,8 +2,8 @@ use std::convert::{From, Into}; |
|
|
|
use std::collections::HashMap;
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
|
|
|
|
use libpso::packet::ship::{UpdateConfig, WriteInfoboard, KeyboardConfig};
|
|
|
|
use libpso::character::character::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU, DEFAULT_KEYBOARD_CONFIG1};
|
|
|
|
use libpso::packet::ship::{UpdateConfig, WriteInfoboard, KeyboardConfig, GamepadConfig};
|
|
|
|
use libpso::character::settings::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU, DEFAULT_KEYBOARD_CONFIG1, DEFAULT_KEYBOARD_CONFIG2, DEFAULT_KEYBOARD_CONFIG3, DEFAULT_KEYBOARD_CONFIG4, DEFAULT_GAMEPAD_CONFIG};
|
|
|
|
use crate::entity::item::tech::Technique;
|
|
|
|
use crate::entity::account::UserAccountId;
|
|
|
|
|
|
|
@ -266,25 +266,71 @@ pub struct CharacterMaterials { |
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct CharacterKeyboardConfig {
|
|
|
|
pub keyboard: [u8; 0x16C],
|
|
|
|
pub keyboard_config: [u8; 0x16C],
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CharacterKeyboardConfig {
|
|
|
|
fn new() -> CharacterKeyboardConfig {
|
|
|
|
CharacterKeyboardConfig {
|
|
|
|
keyboard: DEFAULT_KEYBOARD_CONFIG1,
|
|
|
|
fn new(preset: usize) -> CharacterKeyboardConfig {
|
|
|
|
match preset {
|
|
|
|
1 => {
|
|
|
|
CharacterKeyboardConfig {
|
|
|
|
keyboard_config: DEFAULT_KEYBOARD_CONFIG1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
2 => {
|
|
|
|
CharacterKeyboardConfig {
|
|
|
|
keyboard_config: DEFAULT_KEYBOARD_CONFIG2,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
3 => {
|
|
|
|
CharacterKeyboardConfig {
|
|
|
|
keyboard_config: DEFAULT_KEYBOARD_CONFIG3,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
4 => {
|
|
|
|
CharacterKeyboardConfig {
|
|
|
|
keyboard_config: DEFAULT_KEYBOARD_CONFIG4,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
CharacterKeyboardConfig {
|
|
|
|
keyboard_config: DEFAULT_KEYBOARD_CONFIG1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn update(&mut self, new_config: &KeyboardConfig) {
|
|
|
|
self.keyboard = new_config.keyboard_config;
|
|
|
|
self.keyboard_config = new_config.keyboard_config;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_bytes(&self) -> [u8; 0x16C] {
|
|
|
|
self.keyboard
|
|
|
|
self.keyboard_config
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct CharacterGamepadConfig {
|
|
|
|
pub gamepad_config: [u8; 56],
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for CharacterGamepadConfig {
|
|
|
|
fn default() -> CharacterGamepadConfig {
|
|
|
|
CharacterGamepadConfig {
|
|
|
|
gamepad_config: [0; 56],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CharacterGamepadConfig {
|
|
|
|
pub fn update(&mut self, new_config: &GamepadConfig) {
|
|
|
|
self.gamepad_config = new_config.gamepad_config;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_bytes(&self) -> [u8; 56] {
|
|
|
|
self.gamepad_config
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default, derive_more::Display)]
|
|
|
|
pub struct CharacterEntityId(pub u32);
|
|
|
@ -309,6 +355,8 @@ pub struct NewCharacterEntity { |
|
|
|
|
|
|
|
pub tech_menu: CharacterTechMenu,
|
|
|
|
pub option_flags: u32,
|
|
|
|
pub keyboard_config: CharacterKeyboardConfig,
|
|
|
|
pub gamepad_config: CharacterGamepadConfig,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl NewCharacterEntity {
|
|
|
@ -328,6 +376,8 @@ impl NewCharacterEntity { |
|
|
|
materials: CharacterMaterials::default(),
|
|
|
|
tech_menu: CharacterTechMenu::default(),
|
|
|
|
option_flags: 0,
|
|
|
|
keyboard_config: CharacterKeyboardConfig::new(1),
|
|
|
|
gamepad_config: CharacterGamepadConfig::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -353,4 +403,6 @@ pub struct CharacterEntity { |
|
|
|
|
|
|
|
pub tech_menu: CharacterTechMenu,
|
|
|
|
pub option_flags: u32,
|
|
|
|
pub keyboard_config: CharacterKeyboardConfig,
|
|
|
|
pub gamepad_config: CharacterGamepadConfig,
|
|
|
|
}
|