Skip to content

Commit 6d901bc

Browse files
committed
feat(pc): alias
1 parent 71efec1 commit 6d901bc

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Dice/CharacterCard.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
#define Text2GBK(s) (s ? (isUTF8 ? UTF8toGBK(s) :s) : "")
1111
AttrShape::AttrShape(const tinyxml2::XMLElement* node, bool isUTF8) {
12+
if (auto text{ node->Attribute("alias") }) {
13+
alias = split(Text2GBK(text), "|");
14+
}
1215
if (auto exp{ node->GetText() }) {
1316
string s{ Text2GBK(exp) };
1417
if (auto text{ node->Attribute("text") }) {
@@ -124,10 +127,7 @@ int loadCardTemp(const std::filesystem::path& fpPath, dict_ci<CardTemp>& m) {
124127
if (auto tp_name{ root->Attribute("name") }) {
125128
auto& tp{ m[Text2GBK(tp_name)] };
126129
for (auto elem = root->FirstChildElement(); elem; elem = elem->NextSiblingElement()) {
127-
if (string tag{ elem->Name()}; tag == "alias") {
128-
if (auto text{ elem->GetText() })readini(Text2GBK(text), tp.replaceName);
129-
}
130-
else if (tag == "basic") {
130+
if (string tag{ elem->Name()}; tag == "basic") {
131131
tp.vBasicList.clear();
132132
for (auto kid = elem->FirstChildElement(); kid; kid = kid->NextSiblingElement()) {
133133
if (auto text{ kid->GetText() })tp.vBasicList.push_back(getLines(Text2GBK(text)));
@@ -136,7 +136,11 @@ int loadCardTemp(const std::filesystem::path& fpPath, dict_ci<CardTemp>& m) {
136136
else if (tag == "init") {
137137
for (auto kid = elem->FirstChildElement(); kid; kid = kid->NextSiblingElement()) {
138138
if (auto name{ kid->Attribute("name") }) {
139-
tp.AttrShapes[Text2GBK(name)] = { kid,isUTF8 };
139+
string attr{ Text2GBK(name) };
140+
auto& shape{ tp.AttrShapes[attr] = { kid,isUTF8 } };
141+
if (!shape.alias.empty())for (auto& key : shape.alias) {
142+
tp.replaceName[key] = attr;
143+
}
140144
}
141145
}
142146
}

Dice/CharacterCard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class AttrShape {
5252
AttrShape(const string& s, TextType tt) :defVal(s), textType(tt){}
5353
DataType type{ DataType::Any };
5454
string title;
55+
vector<string> alias;
5556
TextType textType{ TextType::Plain };
5657
AttrVar defVal;
5758
AttrVar init(const CharaCard*);

Dice/GlobalVar.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ const dict_ci<> HelpDoc = {
551551
626:前缀匹配记录后缀
552552
624:支持mod远程安装/详细信息
553553
622:支持手动时差
554-
621:扩展代理事件及ex接口
555554
618:支持reply(Order形式)覆盖指令
556555
617:更新grade分档转义
557556
608:新增.mod指令

0 commit comments

Comments
 (0)