Commit fc43ebb3 authored by woodee's avatar woodee

Merge pull request #1514 from DailyShana/setname

display and search setname
parents 84597221 aa825400
...@@ -102,6 +102,12 @@ bool DataManager::LoadStrings(const char* file) { ...@@ -102,6 +102,12 @@ bool DataManager::LoadStrings(const char* file) {
wchar_t* pbuf = new wchar_t[len + 1]; wchar_t* pbuf = new wchar_t[len + 1];
wcscpy(pbuf, strBuffer); wcscpy(pbuf, strBuffer);
_counterStrings[value] = pbuf; _counterStrings[value] = pbuf;
} else if(!strcmp(strbuf, "setname")) {
sscanf(&linebuf[8], "%x %240[^\t^\n]", &value, strbuf);//using tab for comment
int len = BufferIO::DecodeUTF8(strbuf, strBuffer);
wchar_t* pbuf = new wchar_t[len + 1];
wcscpy(pbuf, strBuffer);
_setnameStrings[value] = pbuf;
} }
} }
fclose(fp); fclose(fp);
...@@ -182,6 +188,18 @@ const wchar_t* DataManager::GetCounterName(int code) { ...@@ -182,6 +188,18 @@ const wchar_t* DataManager::GetCounterName(int code) {
return unknown_string; return unknown_string;
return csit->second; return csit->second;
} }
const wchar_t* DataManager::GetSetName(int code) {
auto csit = _setnameStrings.find(code);
if(csit == _setnameStrings.end())
return L"";
return csit->second;
}
unsigned int DataManager::GetSetCode(const wchar_t* setname) {
for(auto csit = _setnameStrings.begin(); csit != _setnameStrings.end(); csit++)
if(wcscmp(csit->second, setname) == 0)
return csit->first;
return 0;
}
const wchar_t* DataManager::GetNumString(int num, bool bracket) { const wchar_t* DataManager::GetNumString(int num, bool bracket) {
if(!bracket) if(!bracket)
return numStrings[num]; return numStrings[num];
...@@ -259,6 +277,22 @@ const wchar_t* DataManager::FormatType(int type) { ...@@ -259,6 +277,22 @@ const wchar_t* DataManager::FormatType(int type) {
return unknown_string; return unknown_string;
return tpBuffer; return tpBuffer;
} }
const wchar_t* DataManager::FormatSetName(unsigned long long setcode) {
wchar_t* p = scBuffer;
for(int i = 0; i < 4; ++i) {
const wchar_t* setname = GetSetName((setcode >> i * 16) & 0xffff);
if(setname != L"") {
BufferIO::CopyWStrRef(setname, p, 16);
*p = L'|';
*++p = 0;
}
}
if(p != scBuffer)
*(p - 1) = 0;
else
return unknown_string;
return scBuffer;
}
int DataManager::CardReader(int code, void* pData) { int DataManager::CardReader(int code, void* pData) {
if(!dataManager.GetData(code, (CardData*)pData)) if(!dataManager.GetData(code, (CardData*)pData))
memset(pData, 0, sizeof(CardData)); memset(pData, 0, sizeof(CardData));
......
...@@ -23,16 +23,20 @@ public: ...@@ -23,16 +23,20 @@ public:
const wchar_t* GetSysString(int code); const wchar_t* GetSysString(int code);
const wchar_t* GetVictoryString(int code); const wchar_t* GetVictoryString(int code);
const wchar_t* GetCounterName(int code); const wchar_t* GetCounterName(int code);
const wchar_t* GetSetName(int code);
unsigned int GetSetCode(const wchar_t* setname);
const wchar_t* GetNumString(int num, bool bracket = false); const wchar_t* GetNumString(int num, bool bracket = false);
const wchar_t* FormatLocation(int location, int sequence); const wchar_t* FormatLocation(int location, int sequence);
const wchar_t* FormatAttribute(int attribute); const wchar_t* FormatAttribute(int attribute);
const wchar_t* FormatRace(int race); const wchar_t* FormatRace(int race);
const wchar_t* FormatType(int type); const wchar_t* FormatType(int type);
const wchar_t* FormatSetName(unsigned long long setcode);
std::unordered_map<unsigned int, CardDataC> _datas; std::unordered_map<unsigned int, CardDataC> _datas;
std::unordered_map<unsigned int, CardString> _strings; std::unordered_map<unsigned int, CardString> _strings;
std::unordered_map<unsigned int, wchar_t*> _counterStrings; std::unordered_map<unsigned int, wchar_t*> _counterStrings;
std::unordered_map<unsigned int, wchar_t*> _victoryStrings; std::unordered_map<unsigned int, wchar_t*> _victoryStrings;
std::unordered_map<unsigned int, wchar_t*> _setnameStrings;
wchar_t* _sysStrings[2048]; wchar_t* _sysStrings[2048];
wchar_t numStrings[256][4]; wchar_t numStrings[256][4];
...@@ -40,6 +44,7 @@ public: ...@@ -40,6 +44,7 @@ public:
wchar_t attBuffer[128]; wchar_t attBuffer[128];
wchar_t racBuffer[128]; wchar_t racBuffer[128];
wchar_t tpBuffer[128]; wchar_t tpBuffer[128];
wchar_t scBuffer[128];
static wchar_t strBuffer[2048]; static wchar_t strBuffer[2048];
static const wchar_t* unknown_string; static const wchar_t* unknown_string;
......
...@@ -657,7 +657,10 @@ void DeckBuilder::FilterCards() { ...@@ -657,7 +657,10 @@ void DeckBuilder::FilterCards() {
myswprintf(result_string, L"%d", results.size()); myswprintf(result_string, L"%d", results.size());
return; return;
} }
if(pstr[0] == 0 || (pstr[0] == L'$' && pstr[1] == 0)) unsigned int set_code = 0;
if(pstr[0] == L'#')
set_code = dataManager.GetSetCode(&pstr[1]);
if(pstr[0] == 0 || (pstr[0] == L'$' && pstr[1] == 0) || (pstr[0] == L'#' && pstr[1] == 0))
pstr = 0; pstr = 0;
auto strpointer = dataManager._strings.begin(); auto strpointer = dataManager._strings.begin();
for(code_pointer ptr = dataManager._datas.begin(); ptr != dataManager._datas.end(); ++ptr, ++strpointer) { for(code_pointer ptr = dataManager._datas.begin(); ptr != dataManager._datas.end(); ++ptr, ++strpointer) {
...@@ -723,8 +726,23 @@ void DeckBuilder::FilterCards() { ...@@ -723,8 +726,23 @@ void DeckBuilder::FilterCards() {
if(pstr[0] == L'$') { if(pstr[0] == L'$') {
if(wcsstr(text.name, &pstr[1]) == 0) if(wcsstr(text.name, &pstr[1]) == 0)
continue; continue;
} } else if(pstr[0] == L'#' && set_code) {
else { unsigned long long sc = data.setcode;
if(data.alias) {
auto aptr = dataManager._datas.find(data.alias);
if(aptr != dataManager._datas.end())
sc = aptr->second.setcode;
}
bool res = false;
int settype = set_code & 0xfff;
int setsubtype = set_code & 0xf000;
while(sc) {
if ((sc & 0xfff) == settype && (sc & 0xf000 & setsubtype) == setsubtype)
res = true;
sc = sc >> 16;
}
if(!res) continue;
} else {
if(wcsstr(text.name, pstr) == 0 && wcsstr(text.text, pstr) == 0) if(wcsstr(text.name, pstr) == 0 && wcsstr(text.text, pstr) == 0)
continue; continue;
} }
......
...@@ -917,6 +917,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -917,6 +917,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->stName->setText(L""); mainGame->stName->setText(L"");
mainGame->stInfo->setText(L""); mainGame->stInfo->setText(L"");
mainGame->stDataInfo->setText(L""); mainGame->stDataInfo->setText(L"");
mainGame->stSetName->setText(L"");
mainGame->stText->setText(L""); mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false); mainGame->scrCardText->setVisible(false);
} }
...@@ -931,6 +932,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -931,6 +932,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->stName->setText(L""); mainGame->stName->setText(L"");
mainGame->stInfo->setText(L""); mainGame->stInfo->setText(L"");
mainGame->stDataInfo->setText(L""); mainGame->stDataInfo->setText(L"");
mainGame->stSetName->setText(L"");
mainGame->stText->setText(L""); mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false); mainGame->scrCardText->setVisible(false);
} }
...@@ -1603,6 +1605,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1603,6 +1605,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->stName->setText(L""); mainGame->stName->setText(L"");
mainGame->stInfo->setText(L""); mainGame->stInfo->setText(L"");
mainGame->stDataInfo->setText(L""); mainGame->stDataInfo->setText(L"");
mainGame->stSetName->setText(L"");
mainGame->stText->setText(L""); mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false); mainGame->scrCardText->setVisible(false);
} }
......
...@@ -244,8 +244,10 @@ bool Game::Initialize() { ...@@ -244,8 +244,10 @@ bool Game::Initialize() {
stInfo->setOverrideColor(SColor(255, 0, 0, 255)); stInfo->setOverrideColor(SColor(255, 0, 0, 255));
stDataInfo = env->addStaticText(L"", rect<s32>(15, 60, 296, 83), false, true, tabInfo, -1, false); stDataInfo = env->addStaticText(L"", rect<s32>(15, 60, 296, 83), false, true, tabInfo, -1, false);
stDataInfo->setOverrideColor(SColor(255, 0, 0, 255)); stDataInfo->setOverrideColor(SColor(255, 0, 0, 255));
stText = env->addStaticText(L"", rect<s32>(15, 83, 287, 324), false, true, tabInfo, -1, false); stSetName = env->addStaticText(L"", rect<s32>(15, 83, 296, 106), false, true, tabInfo, -1, false);
scrCardText = env->addScrollBar(false, rect<s32>(267, 83, 287, 324), tabInfo, SCROLL_CARDTEXT); stSetName->setOverrideColor(SColor(255, 0, 0, 255));
stText = env->addStaticText(L"", rect<s32>(15, 106, 287, 324), false, true, tabInfo, -1, false);
scrCardText = env->addScrollBar(false, rect<s32>(267, 106, 287, 324), tabInfo, SCROLL_CARDTEXT);
scrCardText->setLargeStep(1); scrCardText->setLargeStep(1);
scrCardText->setSmallStep(1); scrCardText->setSmallStep(1);
scrCardText->setVisible(false); scrCardText->setVisible(false);
...@@ -885,6 +887,19 @@ void Game::ShowCardInfo(int code) { ...@@ -885,6 +887,19 @@ void Game::ShowCardInfo(int code) {
myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias); myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias);
else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code); else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code);
stName->setText(formatBuffer); stName->setText(formatBuffer);
int offset = 0;
unsigned long long sc = cd.setcode;
if(cd.alias) {
auto aptr = dataManager._datas.find(cd.alias);
if(aptr != dataManager._datas.end())
sc = aptr->second.setcode;
}
if(sc) {
offset = 23;
myswprintf(formatBuffer, L"%ls%ls", dataManager.GetSysString(1329), dataManager.FormatSetName(sc));
stSetName->setText(formatBuffer);
} else
stSetName->setText(L"");
if(cd.type & TYPE_MONSTER) { if(cd.type & TYPE_MONSTER) {
myswprintf(formatBuffer, L"[%ls] %ls/%ls", dataManager.FormatType(cd.type), dataManager.FormatRace(cd.race), dataManager.FormatAttribute(cd.attribute)); myswprintf(formatBuffer, L"[%ls] %ls/%ls", dataManager.FormatType(cd.type), dataManager.FormatRace(cd.race), dataManager.FormatAttribute(cd.attribute));
stInfo->setText(formatBuffer); stInfo->setText(formatBuffer);
...@@ -907,14 +922,16 @@ void Game::ShowCardInfo(int code) { ...@@ -907,14 +922,16 @@ void Game::ShowCardInfo(int code) {
wcscat(formatBuffer, scaleBuffer); wcscat(formatBuffer, scaleBuffer);
} }
stDataInfo->setText(formatBuffer); stDataInfo->setText(formatBuffer);
stText->setRelativePosition(rect<s32>(15, 83, 287, 324)); stSetName->setRelativePosition(rect<s32>(15, 83, 296, 106));
scrCardText->setRelativePosition(rect<s32>(267, 83, 287, 324)); stText->setRelativePosition(rect<s32>(15, 83 + offset, 287, 324));
scrCardText->setRelativePosition(rect<s32>(267, 83 + offset, 287, 324));
} else { } else {
myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(cd.type)); myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(cd.type));
stInfo->setText(formatBuffer); stInfo->setText(formatBuffer);
stDataInfo->setText(L""); stDataInfo->setText(L"");
stText->setRelativePosition(rect<s32>(15, 60, 287, 324)); stSetName->setRelativePosition(rect<s32>(15, 60, 296, 83));
scrCardText->setRelativePosition(rect<s32>(267, 60, 287, 324)); stText->setRelativePosition(rect<s32>(15, 60 + offset, 287, 324));
scrCardText->setRelativePosition(rect<s32>(267, 60 + offset, 287, 324));
} }
showingtext = dataManager.GetText(code); showingtext = dataManager.GetText(code);
const auto& tsize = stText->getRelativePosition(); const auto& tsize = stText->getRelativePosition();
......
...@@ -172,6 +172,7 @@ public: ...@@ -172,6 +172,7 @@ public:
irr::gui::IGUIStaticText* stName; irr::gui::IGUIStaticText* stName;
irr::gui::IGUIStaticText* stInfo; irr::gui::IGUIStaticText* stInfo;
irr::gui::IGUIStaticText* stDataInfo; irr::gui::IGUIStaticText* stDataInfo;
irr::gui::IGUIStaticText* stSetName;
irr::gui::IGUIStaticText* stText; irr::gui::IGUIStaticText* stText;
irr::gui::IGUIScrollBar* scrCardText; irr::gui::IGUIScrollBar* scrCardText;
irr::gui::IGUICheckBox* chkAutoPos; irr::gui::IGUICheckBox* chkAutoPos;
......
...@@ -171,6 +171,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -171,6 +171,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->stName->setText(L""); mainGame->stName->setText(L"");
mainGame->stInfo->setText(L""); mainGame->stInfo->setText(L"");
mainGame->stDataInfo->setText(L""); mainGame->stDataInfo->setText(L"");
mainGame->stSetName->setText(L"");
mainGame->stText->setText(L""); mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false); mainGame->scrCardText->setVisible(false);
mainGame->wReplayControl->setVisible(true); mainGame->wReplayControl->setVisible(true);
......
...@@ -62,6 +62,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -62,6 +62,7 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->stName->setText(L""); mainGame->stName->setText(L"");
mainGame->stInfo->setText(L""); mainGame->stInfo->setText(L"");
mainGame->stDataInfo->setText(L""); mainGame->stDataInfo->setText(L"");
mainGame->stSetName->setText(L"");
mainGame->stText->setText(L""); mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false); mainGame->scrCardText->setVisible(false);
mainGame->wPhase->setVisible(true); mainGame->wPhase->setVisible(true);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment