48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
|
use crate::ship::quests::{Quest, QuestList};
|
||
|
use crate::ship::ship::{QUEST_CATEGORY_MENU_ID, QUEST_SELECT_MENU_ID};
|
||
|
use libpso::packet::ship::*;
|
||
|
use libpso::utf8_to_utf16_array;
|
||
|
|
||
|
|
||
|
pub fn quest_category_list(quests: &QuestList) -> QuestCategoryList {
|
||
|
let categories = quests.iter()
|
||
|
.enumerate()
|
||
|
.map(|(i, (category, _))| {
|
||
|
QuestCategory {
|
||
|
menu_id: QUEST_CATEGORY_MENU_ID,
|
||
|
option_id: i as u32,
|
||
|
name: utf8_to_utf16_array!(category.name, 32),
|
||
|
description: utf8_to_utf16_array!(category.description, 122),
|
||
|
}
|
||
|
})
|
||
|
.collect();
|
||
|
|
||
|
QuestCategoryList {
|
||
|
quest_categories: categories,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn quest_list(category_id: u32, quests: &Vec<Quest>) -> QuestOptionList {
|
||
|
let quest_entries = quests.iter()
|
||
|
.map(|quest| {
|
||
|
QuestEntry {
|
||
|
menu_id: QUEST_SELECT_MENU_ID,
|
||
|
category_id: category_id as u16,
|
||
|
quest_id: quest.id,
|
||
|
name: utf8_to_utf16_array!(quest.name, 32),
|
||
|
description: utf8_to_utf16_array!(quest.description, 122),
|
||
|
}
|
||
|
})
|
||
|
.collect();
|
||
|
|
||
|
QuestOptionList {
|
||
|
quests: quest_entries,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn quest_detail(quest: &Quest) -> QuestDetail {
|
||
|
QuestDetail {
|
||
|
description: utf8_to_utf16_array!(quest.full_description, 288),
|
||
|
}
|
||
|
}
|