Commit c0230df1 authored by Chen Bill's avatar Chen Bill Committed by GitHub

DataManager: fix GetNumString (#2603)

* DataManager: fix FormatAttribute, FormatRace

* update FormatAttribute, FormatRace

* DataManager: fix FormatType

* update FormatType

* DataManager: fix FormatSetName

* DataManager: fix FormatLinkMarker

* merge

* DataManager: fix GetNumString

* rebuild class ustring16 from edopro version

* add stringw conversion

core::stringw in current version does not have data()

* add CGUITTFont::drawUstring

* use drawUstring

* update DrawShadowText

* fix Game::lpcstring

* fix DuelInfo::vic_string

* add PACK_MAX_SIZE
parent 8385b896
......@@ -269,7 +269,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
// Log.
if (logger)
logger->log(L"CGUITTFont", core::stringw(core::stringw(L"Creating new font: ") + core::ustring(filename).toWCHAR_s() + L" " + core::stringc(size) + L"pt " + (antialias ? L"+antialias " : L"-antialias ") + (transparency ? L"+transparency" : L"-transparency")).c_str(), irr::ELL_INFORMATION);
logger->log(L"CGUITTFont", core::stringw(core::stringw(L"Creating new font: ") + core::stringc(filename) + L" " + core::stringc(size) + L"pt " + (antialias ? L"+antialias " : L"-antialias ") + (transparency ? L"+transparency" : L"-transparency")).c_str(), irr::ELL_INFORMATION);
// Grab the face.
SGUITTFace* face = 0;
......@@ -304,8 +304,6 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
return false;
}
} else {
core::ustring converter(filename);
if (FT_New_Face(c_library, reinterpret_cast<const char*>(converter.toUTF8_s().c_str()), 0, &face->face)) {
if (logger) logger->log(L"CGUITTFont", L"FT_New_Face failed.", irr::ELL_INFORMATION);
c_faces.remove(filename);
......@@ -313,7 +311,6 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
face = 0;
return false;
}
}
} else {
// Using another instance of this face.
face = node->getValue();
......@@ -491,6 +488,12 @@ void CGUITTFont::setFontHinting(const bool enable, const bool enable_auto_hintin
}
void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position, video::SColor color, bool hcenter, bool vcenter, const core::rect<s32>* clip) {
if (!Driver)
return;
drawUstring(text, position, color, hcenter, vcenter, clip);
}
void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&position, video::SColor color, bool hcenter, bool vcenter, const core::rect<s32>*clip) {
if (!Driver)
return;
......@@ -506,7 +509,7 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
// Determine offset positions.
if (hcenter || vcenter) {
textDimension = getDimension(text.c_str());
textDimension = getDimension(utext);
if (hcenter)
offset.X = ((position.getWidth() - textDimension.Width) >> 1) + offset.X;
......@@ -515,9 +518,6 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
offset.Y = ((position.getHeight() - textDimension.Height) >> 1) + offset.Y;
}
// Convert to a unicode string.
core::ustring utext(text);
// Set up our render map.
core::map<u32, CGUITTGlyphPage*> Render_Map;
......
......@@ -263,7 +263,10 @@ public:
virtual void setFontHinting(const bool enable, const bool enable_auto_hinting = true);
//! Draws some text and clips it to the specified rectangle if wanted.
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
void draw(const core::stringw& text, const core::rect<s32>& position,
video::SColor color, bool hcenter = false, bool vcenter = false,
const core::rect<s32>* clip = 0) override;
void drawUstring(const core::ustring& text, const core::rect<s32>& position,
video::SColor color, bool hcenter = false, bool vcenter = false,
const core::rect<s32>* clip = 0);
......
......@@ -117,8 +117,6 @@ bool DataManager::LoadStrings(const char* file) {
ReadStringConfLine(linebuf);
}
fclose(fp);
for(int i = 0; i < 301; ++i)
myswprintf(numStrings[i], L"%d", i);
return true;
}
bool DataManager::LoadStrings(IReadFile* reader) {
......@@ -272,14 +270,12 @@ std::vector<unsigned int> DataManager::GetSetCodes(std::wstring setname) const {
}
return matchingCodes;
}
const wchar_t* DataManager::GetNumString(int num, bool bracket) {
std::wstring DataManager::GetNumString(int num, bool bracket) const {
if(!bracket)
return numStrings[num];
wchar_t* p = numBuffer;
*p++ = L'(';
BufferIO::CopyWStrRef(numStrings[num], p, 4);
*p = L')';
*++p = 0;
return std::to_wstring(num);
std::wstring numBuffer{ L"(" };
numBuffer.append(std::to_wstring(num));
numBuffer.push_back(L')');
return numBuffer;
}
const wchar_t* DataManager::FormatLocation(int location, int sequence) const {
......@@ -304,95 +300,81 @@ const wchar_t* DataManager::FormatLocation(int location, int sequence) const {
else
return unknown_string;
}
const wchar_t* DataManager::FormatAttribute(int attribute) {
wchar_t* p = attBuffer;
unsigned filter = 1;
int i = 1010;
for(; filter != 0x80; filter <<= 1, ++i) {
if(attribute & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16);
*p = L'|';
*++p = 0;
std::wstring DataManager::FormatAttribute(unsigned int attribute) const {
std::wstring buffer;
for (int i = 0; i < ATTRIBUTES_COUNT; ++i) {
if (attribute & (0x1U << i)) {
if (!buffer.empty())
buffer.push_back(L'|');
buffer.append(GetSysString(1010 + i));
}
}
if(p != attBuffer)
*(p - 1) = 0;
else
return unknown_string;
return attBuffer;
if (buffer.empty())
return std::wstring(unknown_string);
return buffer;
}
const wchar_t* DataManager::FormatRace(int race) {
wchar_t* p = racBuffer;
unsigned filter = 1;
int i = 1020;
for(; filter < (1 << RACES_COUNT); filter <<= 1, ++i) {
if(race & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16);
*p = L'|';
*++p = 0;
std::wstring DataManager::FormatRace(unsigned int race) const {
std::wstring buffer;
for(int i = 0; i < RACES_COUNT; ++i) {
if(race & (0x1U << i)) {
if (!buffer.empty())
buffer.push_back(L'|');
buffer.append(GetSysString(1020 + i));
}
}
if(p != racBuffer)
*(p - 1) = 0;
else
return unknown_string;
return racBuffer;
if (buffer.empty())
return std::wstring(unknown_string);
return buffer;
}
const wchar_t* DataManager::FormatType(int type) {
wchar_t* p = tpBuffer;
unsigned filter = 1;
std::wstring DataManager::FormatType(unsigned int type) const {
std::wstring buffer;
int i = 1050;
for(; filter != 0x8000000; filter <<= 1, ++i) {
if(type & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16);
*p = L'|';
*++p = 0;
for (unsigned filter = TYPE_MONSTER; filter <= TYPE_LINK; filter <<= 1, ++i) {
if (type & filter) {
if (!buffer.empty())
buffer.push_back(L'|');
buffer.append(GetSysString(i));
}
}
if(p != tpBuffer)
*(p - 1) = 0;
else
return unknown_string;
return tpBuffer;
if (buffer.empty())
return std::wstring(unknown_string);
return buffer;
}
const wchar_t* DataManager::FormatSetName(const uint16_t setcode[]) {
wchar_t* p = scBuffer;
std::wstring DataManager::FormatSetName(const uint16_t setcode[]) const {
std::wstring buffer;
for(int i = 0; i < 10; ++i) {
if (!setcode[i])
break;
const wchar_t* setname = GetSetName(setcode[i]);
if(setname) {
BufferIO::CopyWStrRef(setname, p, 32);
*p = L'|';
*++p = 0;
if (!buffer.empty())
buffer.push_back(L'|');
buffer.append(setname);
}
}
if(p != scBuffer)
*(p - 1) = 0;
else
return unknown_string;
return scBuffer;
if (buffer.empty())
return std::wstring(unknown_string);
return buffer;
}
const wchar_t* DataManager::FormatLinkMarker(int link_marker) {
wchar_t* p = lmBuffer;
*p = 0;
if(link_marker & LINK_MARKER_TOP_LEFT)
BufferIO::CopyWStrRef(L"[\u2196]", p, 4);
if(link_marker & LINK_MARKER_TOP)
BufferIO::CopyWStrRef(L"[\u2191]", p, 4);
if(link_marker & LINK_MARKER_TOP_RIGHT)
BufferIO::CopyWStrRef(L"[\u2197]", p, 4);
if(link_marker & LINK_MARKER_LEFT)
BufferIO::CopyWStrRef(L"[\u2190]", p, 4);
if(link_marker & LINK_MARKER_RIGHT)
BufferIO::CopyWStrRef(L"[\u2192]", p, 4);
if(link_marker & LINK_MARKER_BOTTOM_LEFT)
BufferIO::CopyWStrRef(L"[\u2199]", p, 4);
if(link_marker & LINK_MARKER_BOTTOM)
BufferIO::CopyWStrRef(L"[\u2193]", p, 4);
if(link_marker & LINK_MARKER_BOTTOM_RIGHT)
BufferIO::CopyWStrRef(L"[\u2198]", p, 4);
return lmBuffer;
std::wstring DataManager::FormatLinkMarker(unsigned int link_marker) const {
std::wstring buffer;
if (link_marker & LINK_MARKER_TOP_LEFT)
buffer.append(L"[\u2196]");
if (link_marker & LINK_MARKER_TOP)
buffer.append(L"[\u2191]");
if (link_marker & LINK_MARKER_TOP_RIGHT)
buffer.append(L"[\u2197]");
if (link_marker & LINK_MARKER_LEFT)
buffer.append(L"[\u2190]");
if (link_marker & LINK_MARKER_RIGHT)
buffer.append(L"[\u2192]");
if (link_marker & LINK_MARKER_BOTTOM_LEFT)
buffer.append(L"[\u2199]");
if (link_marker & LINK_MARKER_BOTTOM)
buffer.append(L"[\u2193]");
if (link_marker & LINK_MARKER_BOTTOM_RIGHT)
buffer.append(L"[\u2198]");
return buffer;
}
uint32 DataManager::CardReader(uint32 code, card_data* pData) {
if (!dataManager.GetData(code, pData))
......
......@@ -31,13 +31,13 @@ public:
const wchar_t* GetCounterName(int code) const;
const wchar_t* GetSetName(int code) const;
std::vector<unsigned int> GetSetCodes(std::wstring setname) const;
const wchar_t* GetNumString(int num, bool bracket = false);
std::wstring GetNumString(int num, bool bracket = false) const;
const wchar_t* FormatLocation(int location, int sequence) const;
const wchar_t* FormatAttribute(int attribute);
const wchar_t* FormatRace(int race);
const wchar_t* FormatType(int type);
const wchar_t* FormatSetName(const uint16_t setcode[]);
const wchar_t* FormatLinkMarker(int link_marker);
std::wstring FormatAttribute(unsigned int attribute) const;
std::wstring FormatRace(unsigned int race) const;
std::wstring FormatType(unsigned int type) const;
std::wstring FormatSetName(const uint16_t setcode[]) const;
std::wstring FormatLinkMarker(unsigned int link_marker) const;
std::unordered_map<unsigned int, std::wstring> _counterStrings;
std::unordered_map<unsigned int, std::wstring> _victoryStrings;
......@@ -48,14 +48,6 @@ public:
string_pointer strings_begin;
string_pointer strings_end;
wchar_t numStrings[301][4]{};
wchar_t numBuffer[6]{};
wchar_t attBuffer[128]{};
wchar_t racBuffer[128]{};
wchar_t tpBuffer[128]{};
wchar_t scBuffer[128]{};
wchar_t lmBuffer[32]{};
static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string;
static uint32 CardReader(uint32, card_data*);
......
......@@ -186,7 +186,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p
}
int DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_packlist) {
int ct = 0, mainc = 0, sidec = 0, code = 0;
int cardlist[300]{};
int cardlist[PACK_MAX_SIZE]{};
bool is_side = false;
std::string linebuf;
while (std::getline(deckStream, linebuf, '\n') && ct < (int)(sizeof cardlist / sizeof cardlist[0])) {
......
......@@ -12,6 +12,7 @@ namespace ygo {
constexpr int DECK_MIN_SIZE = 40;
constexpr int EXTRA_MAX_SIZE = 15;
constexpr int SIDE_MAX_SIZE = 15;
constexpr int PACK_MAX_SIZE = 1000;
struct LFList {
unsigned int hash{};
......
......@@ -411,12 +411,13 @@ void Game::DrawCard(ClientCard* pcard) {
driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
}
}
void Game::DrawShadowText(CGUITTFont * font, const core::stringw & text, const core::rect<s32>& position, const core::rect<s32>& padding,
video::SColor color, video::SColor shadowcolor, bool hcenter, bool vcenter, const core::rect<s32>* clip) {
template<typename T>
inline void DrawShadowText(irr::gui::CGUITTFont* font, const T& text, const core::rect<s32>& position, const core::rect<s32>& padding,
video::SColor color = 0xffffffff, video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const core::rect<s32>* clip = nullptr) {
core::rect<s32> shadowposition = recti(position.UpperLeftCorner.X - padding.UpperLeftCorner.X, position.UpperLeftCorner.Y - padding.UpperLeftCorner.Y,
position.LowerRightCorner.X - padding.LowerRightCorner.X, position.LowerRightCorner.Y - padding.LowerRightCorner.Y);
font->draw(text, shadowposition, shadowcolor, hcenter, vcenter, clip);
font->draw(text, position, color, hcenter, vcenter, clip);
font->drawUstring(text, shadowposition, shadowcolor, hcenter, vcenter, clip);
font->drawUstring(text, position, color, hcenter, vcenter, clip);
}
void Game::DrawMisc() {
static irr::core::vector3df act_rot(0, 0, 0);
......@@ -563,7 +564,7 @@ void Game::DrawMisc() {
lpccolor -= 0x19000000;
lpframe--;
}
if(lpcstring) {
if(lpcstring.size()) {
if(lpplayer == 0) {
DrawShadowText(lpcFont, lpcstring, Resize(400, 472, 922, 520), Resize(0, 2, 2, 0), lpccolor, lpccolor | 0x00ffffff, true, false, 0);
} else {
......@@ -583,17 +584,17 @@ void Game::DrawMisc() {
recti p1size = Resize(335, 31, 629, 50);
recti p2size = Resize(986, 31, 986, 50);
if(!dInfo.isTag || !dInfo.tag_player[0])
textFont->draw(dInfo.hostname, p1size, 0xffffffff, false, false, 0);
textFont->drawUstring(dInfo.hostname, p1size, 0xffffffff, false, false, 0);
else
textFont->draw(dInfo.hostname_tag, p1size, 0xffffffff, false, false, 0);
textFont->drawUstring(dInfo.hostname_tag, p1size, 0xffffffff, false, false, 0);
if(!dInfo.isTag || !dInfo.tag_player[1]) {
auto cld = textFont->getDimension(dInfo.clientname);
p2size.UpperLeftCorner.X -= cld.Width;
textFont->draw(dInfo.clientname, p2size, 0xffffffff, false, false, 0);
textFont->drawUstring(dInfo.clientname, p2size, 0xffffffff, false, false, 0);
} else {
auto cld = textFont->getDimension(dInfo.clientname_tag);
p2size.UpperLeftCorner.X -= cld.Width;
textFont->draw(dInfo.clientname_tag, p2size, 0xffffffff, false, false, 0);
textFont->drawUstring(dInfo.clientname_tag, p2size, 0xffffffff, false, false, 0);
}
}
driver->draw2DRectangle(Resize(632, 10, 688, 30), 0x00000000, 0x00000000, 0xffffffff, 0xffffffff);
......@@ -956,7 +957,7 @@ void Game::DrawSpec() {
DrawShadowText(lpcFont, lstr, ResizePhaseHint(660 - (9 - showcardp) * 40, 290, 960, 370, pos.Width), Resize(-1, -1, 0, 0), alpha | 0xffffff, alpha);
} else if(showcardp < showcarddif) {
DrawShadowText(lpcFont, lstr, ResizePhaseHint(660, 290, 960, 370, pos.Width), Resize(-1, -1, 0, 0), 0xffffffff);
if(dInfo.vic_string && (showcardcode == 1 || showcardcode == 2)) {
if(dInfo.vic_string.size() && (showcardcode == 1 || showcardcode == 2)) {
int w = guiFont->getDimension(dInfo.vic_string).Width;
if(w < 200)
w = 200;
......@@ -1021,8 +1022,8 @@ void Game::DrawSpec() {
recti shadowloc = msgloc + position2di(1, 1);
driver->draw2DRectangle(rectloc, 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000);
guiFont->draw(msg.c_str(), msgloc, 0xff000000, false, false);
guiFont->draw(msg.c_str(), shadowloc, chatColor[chatType[i]], false, false);
guiFont->drawUstring(msg, msgloc, 0xff000000, false, false);
guiFont->drawUstring(msg, shadowloc, chatColor[chatType[i]], false, false);
chatRectY += h;
}
......@@ -1190,7 +1191,7 @@ void Game::DrawDeckBd() {
driver->draw2DRectangle(Resize(310, 137, 410, 157), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(309, 136, 410, 157));
DrawShadowText(textFont, dataManager.GetSysString(deckBuilder.showing_pack ? 1477 : 1330), Resize(315, 137, 410, 157), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
DrawShadowText(numFont, dataManager.numStrings[mainsize], Resize(380, 138, 440, 158), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
DrawShadowText(numFont, dataManager.GetNumString(mainsize), Resize(380, 138, 440, 158), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
driver->draw2DRectangle(Resize(310, 160, 797, deckBuilder.showing_pack ? 630 : 436), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(309, 159, 797, deckBuilder.showing_pack ? 630 : 436));
int lx;
......@@ -1224,7 +1225,7 @@ void Game::DrawDeckBd() {
driver->draw2DRectangle(Resize(310, 440, 410, 460), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(309, 439, 410, 460));
DrawShadowText(textFont, dataManager.GetSysString(1331), Resize(315, 440, 410, 460), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
DrawShadowText(numFont, dataManager.numStrings[deckManager.current_deck.extra.size()], Resize(380, 441, 440, 461), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
DrawShadowText(numFont, dataManager.GetNumString(deckManager.current_deck.extra.size()), Resize(380, 441, 440, 461), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
driver->draw2DRectangle(Resize(310, 463, 797, 533), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(309, 462, 797, 533));
if(deckManager.current_deck.extra.size() <= 10)
......@@ -1239,7 +1240,7 @@ void Game::DrawDeckBd() {
driver->draw2DRectangle(Resize(310, 537, 410, 557), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(309, 536, 410, 557));
DrawShadowText(textFont, dataManager.GetSysString(1332), Resize(315, 537, 410, 557), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
DrawShadowText(numFont, dataManager.numStrings[deckManager.current_deck.side.size()], Resize(380, 538, 440, 558), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
DrawShadowText(numFont, dataManager.GetNumString(deckManager.current_deck.side.size()), Resize(380, 538, 440, 558), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
driver->draw2DRectangle(Resize(310, 560, 797, 630), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(309, 559, 797, 630));
if(deckManager.current_deck.side.size() <= 10)
......@@ -1305,7 +1306,8 @@ void Game::DrawDeckBd() {
else
myswprintf(adBuffer, L"%d/-", ptr->second.attack);
}
myswprintf(textBuffer, L"%ls/%ls %ls%d", dataManager.FormatAttribute(ptr->second.attribute), dataManager.FormatRace(ptr->second.race), form, ptr->second.level);
myswprintf(textBuffer, L"%ls/%ls %ls%d", dataManager.FormatAttribute(ptr->second.attribute).c_str(), dataManager.FormatRace(ptr->second.race).c_str(),
form, ptr->second.level);
DrawShadowText(textFont, textBuffer, Resize(860, 187 + i * 66, 955, 207 + i * 66), Resize(1, 1, 0, 0));
if(ptr->second.type & TYPE_PENDULUM) {
myswprintf(scaleBuffer, L" %d/%d", ptr->second.lscale, ptr->second.rscale);
......@@ -1315,8 +1317,8 @@ void Game::DrawDeckBd() {
} else {
myswprintf(textBuffer, L"%ls", dataManager.GetName(ptr->first));
DrawShadowText(textFont, textBuffer, Resize(860, 165 + i * 66, 955, 185 + i * 66), Resize(1, 1, 0, 0));
const wchar_t* ptype = dataManager.FormatType(ptr->second.type);
DrawShadowText(textFont, ptype, Resize(860, 187 + i * 66, 955, 207 + i * 66), Resize(1, 1, 0, 0));
myswprintf(textBuffer, L"%ls", dataManager.FormatType(ptr->second.type).c_str());
DrawShadowText(textFont, textBuffer, Resize(860, 187 + i * 66, 955, 207 + i * 66), Resize(1, 1, 0, 0));
myswprintf(textBuffer, L"%ls", availBuffer);
DrawShadowText(textFont, textBuffer, Resize(860, 209 + i * 66, 955, 229 + i * 66), Resize(1, 1, 0, 0));
}
......
......@@ -1104,7 +1104,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
break;
}
case HINT_RACE: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatRace(data));
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatRace(data).c_str());
mainGame->AddLog(textBuffer);
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
......@@ -1114,7 +1114,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
break;
}
case HINT_ATTRIB: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatAttribute(data));
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatAttribute(data).c_str());
mainGame->AddLog(textBuffer);
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
......@@ -1201,7 +1201,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
int type = BufferIO::ReadUInt8(pbuf);
mainGame->showcarddif = 110;
mainGame->showcardp = 0;
mainGame->dInfo.vic_string = 0;
mainGame->dInfo.vic_string = L"";
wchar_t vic_buf[256];
if(player == 2)
mainGame->showcardcode = 3;
......@@ -1227,7 +1227,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
}
mainGame->showcard = 101;
mainGame->WaitFrameSignal(120);
mainGame->dInfo.vic_string = 0;
mainGame->dInfo.vic_string = L"";
mainGame->showcard = 0;
break;
}
......@@ -3184,7 +3184,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0;
mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
......@@ -3213,7 +3213,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0;
mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
......@@ -3365,7 +3365,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0;
mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
......
......@@ -1600,7 +1600,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
myswprintf(formatBuffer, L"\nLINK-%d", mcard->link);
str.append(formatBuffer);
}
myswprintf(formatBuffer, L" %ls/%ls", dataManager.FormatRace(mcard->race), dataManager.FormatAttribute(mcard->attribute));
myswprintf(formatBuffer, L" %ls/%ls", dataManager.FormatRace(mcard->race).c_str(), dataManager.FormatAttribute(mcard->attribute).c_str());
str.append(formatBuffer);
if(mcard->location == LOCATION_HAND && (mcard->type & TYPE_PENDULUM)) {
myswprintf(formatBuffer, L"\n%d/%d", mcard->lscale, mcard->rscale);
......@@ -1626,9 +1626,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
else if(mcard->cHint == CHINT_CARD)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(212), dataManager.GetName(mcard->chValue));
else if(mcard->cHint == CHINT_RACE)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(213), dataManager.FormatRace(mcard->chValue));
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(213), dataManager.FormatRace(mcard->chValue).c_str());
else if(mcard->cHint == CHINT_ATTRIBUTE)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(214), dataManager.FormatAttribute(mcard->chValue));
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(214), dataManager.FormatAttribute(mcard->chValue).c_str());
else if(mcard->cHint == CHINT_NUMBER)
myswprintf(formatBuffer, L"\n%ls%d", dataManager.GetSysString(215), mcard->chValue);
str.append(formatBuffer);
......
......@@ -43,7 +43,6 @@ void DuelInfo::Clear() {
clientname_tag[0] = 0;
strLP[0][0] = 0;
strLP[1][0] = 0;
vic_string = 0;
player_type = 0;
time_player = 0;
time_limit = 0;
......@@ -77,7 +76,6 @@ bool Game::Initialize() {
showcard = 0;
is_attacking = false;
lpframe = 0;
lpcstring = 0;
always_chain = false;
ignore_chain = false;
chain_when_avail = false;
......@@ -613,14 +611,14 @@ bool Game::Initialize() {
wANAttribute->setVisible(false);
for(int filter = 0x1, i = 0; i < 7; filter <<= 1, ++i)
chkAttribute[i] = env->addCheckBox(false, rect<s32>(10 + (i % 4) * 80, 25 + (i / 4) * 25, 90 + (i % 4) * 80, 50 + (i / 4) * 25),
wANAttribute, CHECK_ATTRIBUTE, dataManager.FormatAttribute(filter));
wANAttribute, CHECK_ATTRIBUTE, dataManager.FormatAttribute(filter).c_str());
//announce race
wANRace = env->addWindow(rect<s32>(480, 200, 850, 410), false, dataManager.GetSysString(563));
wANRace->getCloseButton()->setVisible(false);
wANRace->setVisible(false);
for(int filter = 0x1, i = 0; i < RACES_COUNT; filter <<= 1, ++i)
chkRace[i] = env->addCheckBox(false, rect<s32>(10 + (i % 4) * 90, 25 + (i / 4) * 25, 100 + (i % 4) * 90, 50 + (i / 4) * 25),
wANRace, CHECK_RACE, dataManager.FormatRace(filter));
wANRace, CHECK_RACE, dataManager.FormatRace(filter).c_str());
//selection hint
stHintMsg = env->addStaticText(L"", rect<s32>(500, 60, 820, 90), true, false, 0, -1, false);
stHintMsg->setBackgroundColor(0xc0ffffff);
......@@ -750,13 +748,13 @@ bool Game::Initialize() {
cbAttribute->setMaxSelectionRows(10);
cbAttribute->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter != 0x80; filter <<= 1)
cbAttribute->addItem(dataManager.FormatAttribute(filter), filter);
cbAttribute->addItem(dataManager.FormatAttribute(filter).c_str(), filter);
stRace = env->addStaticText(dataManager.GetSysString(1321), rect<s32>(10, 42 + 75 / 6, 70, 62 + 75 / 6), false, false, wFilter);
cbRace = env->addComboBox(rect<s32>(60, 40 + 75 / 6, 195, 60 + 75 / 6), wFilter, COMBOBOX_RACE);
cbRace->setMaxSelectionRows(10);
cbRace->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter < (1 << RACES_COUNT); filter <<= 1)
cbRace->addItem(dataManager.FormatRace(filter), filter);
cbRace->addItem(dataManager.FormatRace(filter).c_str(), filter);
stAttack = env->addStaticText(dataManager.GetSysString(1322), rect<s32>(205, 22 + 50 / 6, 280, 42 + 50 / 6), false, false, wFilter);
ebAttack = env->addEditBox(L"", rect<s32>(260, 20 + 50 / 6, 340, 40 + 50 / 6), true, wFilter, EDITBOX_INPUTS);
ebAttack->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
......@@ -1552,7 +1550,7 @@ void Game::ShowCardInfo(int code, bool resize) {
}
if (target->second.setcode[0]) {
offset = 23;// *yScale;
myswprintf(formatBuffer, L"%ls%ls", dataManager.GetSysString(1329), dataManager.FormatSetName(target->second.setcode));
myswprintf(formatBuffer, L"%ls%ls", dataManager.GetSysString(1329), dataManager.FormatSetName(target->second.setcode).c_str());
stSetName->setText(formatBuffer);
}
else
......@@ -1563,7 +1561,7 @@ void Game::ShowCardInfo(int code, bool resize) {
}
if(is_valid && cit->second.type & TYPE_MONSTER) {
auto& cd = cit->second;
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).c_str(), dataManager.FormatRace(cd.race).c_str(), dataManager.FormatAttribute(cd.attribute).c_str());
stInfo->setText(formatBuffer);
int offset_info = 0;
irr::core::dimension2d<unsigned int> dtxt = guiFont->getDimension(formatBuffer);
......@@ -1586,9 +1584,9 @@ void Game::ShowCardInfo(int code, bool resize) {
} else {
form = L"LINK-";
if(cd.attack < 0)
myswprintf(adBuffer, L"?/- %ls", dataManager.FormatLinkMarker(cd.link_marker));
myswprintf(adBuffer, L"?/- %ls", dataManager.FormatLinkMarker(cd.link_marker).c_str());
else
myswprintf(adBuffer, L"%d/- %ls", cd.attack, dataManager.FormatLinkMarker(cd.link_marker));
myswprintf(adBuffer, L"%d/- %ls", cd.attack, dataManager.FormatLinkMarker(cd.link_marker).c_str());
}
if(cd.type & TYPE_PENDULUM) {
myswprintf(scaleBuffer, L" %d/%d", cd.lscale, cd.rscale);
......@@ -1607,9 +1605,9 @@ void Game::ShowCardInfo(int code, bool resize) {
}
else {
if (is_valid)
myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(cit->second.type));
myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(cit->second.type).c_str());
else
myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(0));
myswprintf(formatBuffer, L"[%ls]", dataManager.unknown_string);
stInfo->setText(formatBuffer);
stDataInfo->setText(L"");
stSetName->setRelativePosition(rect<s32>(15, 60, 296 * xScale, 60 + offset));
......
......@@ -104,7 +104,7 @@ struct DuelInfo {
wchar_t hostname_tag[20]{};
wchar_t clientname_tag[20]{};
wchar_t strLP[2][16]{};
wchar_t* vic_string{ nullptr };
std::wstring vic_string;
unsigned char player_type{ 0 };
unsigned char time_player{ 0 };
unsigned short time_limit{ 0 };
......@@ -157,7 +157,6 @@ public:
void CheckMutual(ClientCard* pcard, int mark);
void DrawCards();
void DrawCard(ClientCard* pcard);
void DrawShadowText(irr::gui::CGUITTFont* font, const core::stringw& text, const core::rect<s32>& position, const core::rect<s32>& padding, video::SColor color = 0xffffffff, video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const core::rect<s32>* clip = 0);
void DrawMisc();
void DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2);
void DrawGUI();
......@@ -258,7 +257,7 @@ public:
int lpd;
int lpplayer;
int lpccolor;
wchar_t* lpcstring;
std::wstring lpcstring;
bool always_chain;
bool ignore_chain;
bool chain_when_avail;
......
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