Skip to content

Commit

Permalink
feat(pc): alias
Browse files Browse the repository at this point in the history
  • Loading branch information
mystringEmpty committed Dec 21, 2023
1 parent 71efec1 commit 6d901bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions Dice/CharacterCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#define Text2GBK(s) (s ? (isUTF8 ? UTF8toGBK(s) :s) : "")
AttrShape::AttrShape(const tinyxml2::XMLElement* node, bool isUTF8) {
if (auto text{ node->Attribute("alias") }) {
alias = split(Text2GBK(text), "|");
}
if (auto exp{ node->GetText() }) {
string s{ Text2GBK(exp) };
if (auto text{ node->Attribute("text") }) {
Expand Down Expand Up @@ -124,10 +127,7 @@ int loadCardTemp(const std::filesystem::path& fpPath, dict_ci<CardTemp>& m) {
if (auto tp_name{ root->Attribute("name") }) {
auto& tp{ m[Text2GBK(tp_name)] };
for (auto elem = root->FirstChildElement(); elem; elem = elem->NextSiblingElement()) {
if (string tag{ elem->Name()}; tag == "alias") {
if (auto text{ elem->GetText() })readini(Text2GBK(text), tp.replaceName);
}
else if (tag == "basic") {
if (string tag{ elem->Name()}; tag == "basic") {
tp.vBasicList.clear();
for (auto kid = elem->FirstChildElement(); kid; kid = kid->NextSiblingElement()) {
if (auto text{ kid->GetText() })tp.vBasicList.push_back(getLines(Text2GBK(text)));
Expand All @@ -136,7 +136,11 @@ int loadCardTemp(const std::filesystem::path& fpPath, dict_ci<CardTemp>& m) {
else if (tag == "init") {
for (auto kid = elem->FirstChildElement(); kid; kid = kid->NextSiblingElement()) {
if (auto name{ kid->Attribute("name") }) {
tp.AttrShapes[Text2GBK(name)] = { kid,isUTF8 };
string attr{ Text2GBK(name) };
auto& shape{ tp.AttrShapes[attr] = { kid,isUTF8 } };
if (!shape.alias.empty())for (auto& key : shape.alias) {
tp.replaceName[key] = attr;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Dice/CharacterCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class AttrShape {
AttrShape(const string& s, TextType tt) :defVal(s), textType(tt){}
DataType type{ DataType::Any };
string title;
vector<string> alias;
TextType textType{ TextType::Plain };
AttrVar defVal;
AttrVar init(const CharaCard*);
Expand Down
1 change: 0 additions & 1 deletion Dice/GlobalVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ const dict_ci<> HelpDoc = {
626:前缀匹配记录后缀
624:支持mod远程安装/详细信息
622:支持手动时差
621:扩展代理事件及ex接口
618:支持reply(Order形式)覆盖指令
617:更新grade分档转义
608:新增.mod指令
Expand Down

0 comments on commit 6d901bc

Please sign in to comment.