Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
spd789562 committed Oct 15, 2024
2 parents e64e71b + 4588423 commit 7383ab6
Show file tree
Hide file tree
Showing 55 changed files with 1,345 additions and 267 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## [0.4.2]
修正更多 bug,並新增一點點小東西

### 新增
- 匯出完整動畫,並會顯示進度覆蓋角色預覽視窗
- 新設定區塊「匯出設定」
- 匯出設定 - 匯出格式設定
- 匯出設定 - 匯出分鏡時填補空白
- 匯出設定 - 匯出 Gif 時自動填補黑色
- 匯出設定不選擇填補空白時,會多一個有每一個圖的 delay 及位移的 json
- 髮型臉型的編輯區塊新增頁籤,現在可以對髮臉進行稜鏡染色了

### 修改
- 修正臉飾及部分裝備未在轉到背後時隱藏
- 修正部分臉型及髮型不存在時選擇該裝備會噴錯的問題
- 修正切換角色預覽及動作預覽時會噴錯的問題
- 初始化裝備文字時同時會載入沒有文字資訊的裝備,並以 null 替代
- 修正儲存角色後,更換裝備會影響已儲存角色的預覽圖


## [0.4.1]
緊急修正一些 bug

Expand Down
13 changes: 0 additions & 13 deletions doc/questions-zh_tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,6 @@
<details open>
<summary>

#### 為什麼有時候角色預覽可以用滑鼠變動大小及拖曳,有時候不行
</summary>

只有在聚焦在預覽視窗時才可以使用滑鼠拖曳,或用滾輪變動大小,這是為了避免需要頁面捲動時誤觸角色縮放。

聚焦示意圖↓
![](https://imgur.com/trE3gKp.png)

</details>

<details open>
<summary>

#### 可以在其他平台使用這個軟體嗎
</summary>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maplecharactercreator",
"version": "0.4.1",
"version": "0.4.2",
"description": "",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "maplesalon2"
version = "0.4.1"
version = "0.4.2"
description = "MapleSalon2 - A tool for preview hair, face and item dye using MapleStory wz files."
authors = ["Leo"]
edition = "2021"
Expand Down
70 changes: 35 additions & 35 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,38 +162,38 @@ pub(crate) async fn get_childs_info<R: Runtime>(
.collect())
}

#[command]
pub(crate) async fn search_by_equip_name<R: Runtime>(
_app: AppHandle<R>,
_window: Window<R>,
state: State<'_, AppStore>,
name: String,
_category: Option<String>,
) -> Result<Vec<(String, String)>> {
let equip_node = handlers::get_equip_string(&state.node)?;

let node = equip_node
.read()
.unwrap()
.at("Eqp")
.ok_or(Error::NodeNotFound)?;

if let Ok(ref mut string_read) = state.string.write() {
if string_read.len() == 0 {
string_read.extend(handlers::resolve_equip_string(&state.node, &node, false)?);
}
}

let string_dict = state.string.read().unwrap();

Ok(string_dict
.iter()
.filter_map(|(_, id, text, _, _, _, _)| {
if text.contains(&name) {
Some((id.clone(), text.clone()))
} else {
None
}
})
.collect())
}
// #[command]
// pub(crate) async fn search_by_equip_name<R: Runtime>(
// _app: AppHandle<R>,
// _window: Window<R>,
// state: State<'_, AppStore>,
// name: String,
// _category: Option<String>,
// ) -> Result<Vec<(String, String)>> {
// let equip_node = handlers::get_equip_string(&state.node)?;

// let node = equip_node
// .read()
// .unwrap()
// .at("Eqp")
// .ok_or(Error::NodeNotFound)?;

// if let Ok(ref mut string_read) = state.string.write() {
// if string_read.len() == 0 {
// string_read.extend(handlers::resolve_equip_string(&state.node, &node, false)?);
// }
// }

// let string_dict = state.string.read().unwrap();

// Ok(string_dict
// .iter()
// .filter_map(|(_, id, text, _, _, _, _)| {
// if text.contains(&name) {
// Some((id.clone(), text.clone()))
// } else {
// None
// }
// })
// .collect())
// }
11 changes: 11 additions & 0 deletions src-tauri/src/handlers/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ pub const SMAP_PATH: &'static str = "smap.img";
pub const CHARACTER_ITEM_PATH: &'static str = "Character";
pub const EQUIP_STRING_PATH: &'static str = "String/Eqp.img";
pub const EQUIP_EFFECT_PATH: &'static str = "Effect/ItemEff.img";

// don't know why it nameing TamingMob
pub const MOUNT_PATH: &'static str = "Character/TamingMob";
pub const MOUNT_STRING_PATH: &'static str = "String/Eqp.img/Taming";

pub const CHAIR_PATH: &'static str = "Item/Install";
pub const CASH_CHAIR_PATH: &'static str = "Item/Cash/0520.img"; // should also start with 05204
pub const CHAIR_STRING_PATH: &'static str = "String/Ins.img";

pub const SKILL_PATH: &'static str = "Skill";
pub const SKILL_STRING_PATH: &'static str = "String/Skill.img";
117 changes: 75 additions & 42 deletions src-tauri/src/handlers/string.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rayon::prelude::*;
use wz_reader::{WzNodeArc, WzNodeCast};
use wz_reader::{property::WzString, WzNodeArc, WzNodeCast};

use super::item::{
get_is_cash_item, get_is_colorvar, get_is_name_tag, get_item_info_node,
Expand Down Expand Up @@ -129,21 +129,37 @@ pub fn get_equip_string(root: &WzNodeArc) -> Result<WzNodeArc> {
Ok(node)
}

pub fn get_equip_node(root: &WzNodeArc) -> Result<WzNodeArc> {
let node = root.read().unwrap();

let node = node
.at(CHARACTER_ITEM_PATH)
.ok_or(crate::Error::NodeNotFound)?;

Ok(node)
}

pub fn resolve_equip_string(
root: &WzNodeArc,
equip_node: &WzNodeArc,
string_node: &WzNodeArc,
extra_info: bool,
) -> Result<StringDictInner> {
let node = string_node.read().unwrap();
let string_node = string_node.read().unwrap();
let equip_node = equip_node.read().unwrap();

let mut result = Vec::new();

for category_node in EQUIP_CATEGORY_NEEDS.iter().filter_map(|x| node.at(x)) {
let category_node_read = category_node.read().unwrap();
for (category_string_node, category_equip_node) in EQUIP_CATEGORY_NEEDS
.iter()
.filter_map(|x| string_node.at(x).zip(equip_node.at(x)))
{
let category_node_read = category_string_node.read().unwrap();

let category_name = category_node_read.name.as_str();
let category = get_equip_category_from_str(category_name);

/* collect string nodes equipments */
let mut category_result = category_node_read
.children
.values()
Expand All @@ -154,18 +170,18 @@ pub fn resolve_equip_string(
let child_read = child.read().unwrap();
let name = child_read.name.to_string();

let text_node = if let Some(text_node) = child_read.at("name") {
text_node
} else {
let text_node = child_read.at("name");

if text_node.is_none() {
return result;
};
}

let text_node_read = text_node.read().unwrap();
let text_node = text_node.unwrap();

if let Some(string) = text_node_read.try_as_string() {
if let Ok(text) = string.get_string() {
result.push((category.clone(), name, text, false, false, false, false));
}
let text_node_read = text_node.read().unwrap();
let name_text = text_node_read.try_as_string().map(WzString::get_string);
if let Some(Ok(text)) = name_text {
result.push((category.clone(), name, text, false, false, false, false));
}

result
Expand All @@ -178,38 +194,55 @@ pub fn resolve_equip_string(
r
},
);
/* collect the thing not in string node but in equipment node */
let category_equip_node_read = category_equip_node.read().unwrap();
let empty_node_name = String::from("null");

let extra_nodes = category_equip_node_read
.children
.keys()
.par_bridge()
.filter_map(|node_name| {
if !node_name.contains(".img") {
return None;
}
let id = node_name.trim_end_matches(".img").trim_start_matches('0');
if category_node_read.children.contains_key(id) {
return None;
}
Some((
category.clone(),
id.to_string(),
empty_node_name.clone(),
false, // is cash
false, // has colorvar
false, // has effect
false, // is name tag
))
})
.collect::<Vec<_>>();

category_result.extend(extra_nodes);

if extra_info {
'extra: {
let character_category_node = root
.read()
.unwrap()
.at_path(&format!("{}/{}", CHARACTER_ITEM_PATH, category_name));
if character_category_node.is_none() {
break 'extra;
let effect_node = root
.read()
.unwrap()
.at_path(EQUIP_EFFECT_PATH)
.ok_or(Error::NodeNotFound)?;

category_result.par_iter_mut().for_each(|item| {
let item_node = get_item_node_from_category(&category_equip_node, &item.1);
if let Some(info_node) = item_node.and_then(|n| get_item_info_node(&n)) {
item.3 = get_is_cash_item(&info_node);
item.4 = get_is_colorvar(&info_node);
item.6 = get_is_name_tag(&info_node);
}
let character_category_node = character_category_node.unwrap();
let effect_node = root
.read()
.unwrap()
.at_path(EQUIP_EFFECT_PATH)
.ok_or(Error::NodeNotFound)?;

category_result.par_iter_mut().for_each(|item| {
let item_node = get_item_node_from_category(&character_category_node, &item.1);
if let Some(item_node) = item_node {
let info_node = get_item_info_node(&item_node);
if let Some(info_node) = info_node {
item.3 = get_is_cash_item(&info_node);
item.4 = get_is_colorvar(&info_node);
item.6 = get_is_name_tag(&info_node);
}
}
if effect_node.read().unwrap().at(&item.1).is_some() {
item.5 = true;
}
});
}
// item has effect
if effect_node.read().unwrap().at(&item.1).is_some() {
item.5 = true;
}
});
}

category_result.sort_by(|a, b| a.1.cmp(&b.1));
Expand Down
3 changes: 1 addition & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ fn main() {
commands::parse_node,
commands::unparse_node,
commands::get_node_info,
commands::get_childs_info,
commands::search_by_equip_name
commands::get_childs_info
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
Expand Down
10 changes: 6 additions & 4 deletions src-tauri/src/server/controller/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ pub async fn prepare_equip(
State((root, string_dict)): State<AppState>,
Query(GetEquipListParam { extra }): Query<GetEquipListParam>,
) -> Result<impl IntoResponse> {
let equip_node = handlers::get_equip_string(&root)?;
let equip_string_node = handlers::get_equip_string(&root)?;
let equip_node = handlers::get_equip_node(&root)?;
let fetch_extra_info = extra.is_some();

node_util::parse_node(&equip_node)?;
node_util::parse_node(&equip_string_node)?;

if fetch_extra_info {
let effect_node = root
Expand All @@ -30,7 +31,7 @@ pub async fn prepare_equip(
}
}

let node = equip_node
let string_node = equip_string_node
.read()
.unwrap()
.at("Eqp")
Expand All @@ -40,7 +41,8 @@ pub async fn prepare_equip(
if string_read.len() == 0 {
string_read.extend(handlers::resolve_equip_string(
&root,
&node,
&equip_node,
&string_node,
fetch_extra_info,
)?);
}
Expand Down
Loading

0 comments on commit 7383ab6

Please sign in to comment.