Commit 6ef54eb8 authored by fallenstardust's avatar fallenstardust

update gframe

parent 73c1baf2
...@@ -269,7 +269,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia ...@@ -269,7 +269,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
// Log. // Log.
if (logger) 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. // Grab the face.
SGUITTFace* face = 0; SGUITTFace* face = 0;
...@@ -304,15 +304,12 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia ...@@ -304,15 +304,12 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
return false; return false;
} }
} else { } else {
core::ustring converter(filename); if (logger) logger->log(L"CGUITTFont", L"FT_New_Face failed.", irr::ELL_INFORMATION);
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); c_faces.remove(filename);
delete face; delete face;
face = 0; face = 0;
return false; return false;
}
} }
} else { } else {
// Using another instance of this face. // Using another instance of this face.
...@@ -491,6 +488,12 @@ void CGUITTFont::setFontHinting(const bool enable, const bool enable_auto_hintin ...@@ -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) { 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) if (!Driver)
return; return;
...@@ -506,7 +509,7 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position ...@@ -506,7 +509,7 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
// Determine offset positions. // Determine offset positions.
if (hcenter || vcenter) { if (hcenter || vcenter) {
textDimension = getDimension(text.c_str()); textDimension = getDimension(utext);
if (hcenter) if (hcenter)
offset.X = ((position.getWidth() - textDimension.Width) >> 1) + offset.X; 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 ...@@ -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; offset.Y = ((position.getHeight() - textDimension.Height) >> 1) + offset.Y;
} }
// Convert to a unicode string.
core::ustring utext(text);
// Set up our render map. // Set up our render map.
core::map<u32, CGUITTGlyphPage*> Render_Map; core::map<u32, CGUITTGlyphPage*> Render_Map;
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
//! Structure representing a single TrueType glyph. //! Structure representing a single TrueType glyph.
struct SGUITTGlyph { struct SGUITTGlyph {
//! Constructor. //! Constructor.
SGUITTGlyph() : isLoaded(false), glyph_page(0), surface(0), parent(0) {} SGUITTGlyph() : isLoaded(false), glyph_page(0), advance({}), surface(0), parent(0) {}
//! Destructor. //! Destructor.
~SGUITTGlyph() { ~SGUITTGlyph() {
...@@ -207,96 +207,96 @@ public: ...@@ -207,96 +207,96 @@ public:
static CGUITTFont* create(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true); static CGUITTFont* create(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true);
//! Destructor //! Destructor
virtual ~CGUITTFont(); ~CGUITTFont() override;
//! Sets the amount of glyphs to batch load. //! Sets the amount of glyphs to batch load.
virtual void setBatchLoadSize(u32 batch_size) { void setBatchLoadSize(u32 batch_size) {
batch_load_size = batch_size; batch_load_size = batch_size;
} }
//! Sets the maximum texture size for a page of glyphs. //! Sets the maximum texture size for a page of glyphs.
virtual void setMaxPageTextureSize(const core::dimension2du& texture_size) { void setMaxPageTextureSize(const core::dimension2du& texture_size) {
max_page_texture_size = texture_size; max_page_texture_size = texture_size;
} }
//! Set the font size.
virtual void setFontSize(u32 new_size) {
size = new_size;
}
//! Get the font size. //! Get the font size.
virtual u32 getFontSize() const { u32 getFontSize() const {
return size; return size;
} }
//! Check the font's transparency. //! Check the font's transparency.
virtual bool isTransparent() const { bool isTransparent() const {
return use_transparency; return use_transparency;
} }
//! Check if the font auto-hinting is enabled. //! Check if the font auto-hinting is enabled.
//! Auto-hinting is FreeType's built-in font hinting engine. //! Auto-hinting is FreeType's built-in font hinting engine.
virtual bool useAutoHinting() const { bool useAutoHinting() const {
return use_auto_hinting; return use_auto_hinting;
} }
//! Check if the font hinting is enabled. //! Check if the font hinting is enabled.
virtual bool useHinting() const { bool useHinting() const {
return use_hinting; return use_hinting;
} }
//! Check if the font is being loaded as a monochrome font. //! Check if the font is being loaded as a monochrome font.
//! The font can either be a 256 color grayscale font, or a 2 color monochrome font. //! The font can either be a 256 color grayscale font, or a 2 color monochrome font.
virtual bool useMonochrome() const { bool useMonochrome() const {
return use_monochrome; return use_monochrome;
} }
//! Tells the font to allow transparency when rendering. //! Tells the font to allow transparency when rendering.
//! Default: true. //! Default: true.
//! \param flag If true, the font draws using transparency. //! \param flag If true, the font draws using transparency.
virtual void setTransparency(const bool flag); void setTransparency(const bool flag);
//! Tells the font to use monochrome rendering. //! Tells the font to use monochrome rendering.
//! Default: false. //! Default: false.
//! \param flag If true, the font draws using a monochrome image. If false, the font uses a grayscale image. //! \param flag If true, the font draws using a monochrome image. If false, the font uses a grayscale image.
virtual void setMonochrome(const bool flag); void setMonochrome(const bool flag);
//! Enables or disables font hinting. //! Enables or disables font hinting.
//! Default: Hinting and auto-hinting true. //! Default: Hinting and auto-hinting true.
//! \param enable If false, font hinting is turned off. If true, font hinting is turned on. //! \param enable If false, font hinting is turned off. If true, font hinting is turned on.
//! \param enable_auto_hinting If true, FreeType uses its own auto-hinting algorithm. If false, it tries to use the algorithm specified by the font. //! \param enable_auto_hinting If true, FreeType uses its own auto-hinting algorithm. If false, it tries to use the algorithm specified by the font.
virtual void setFontHinting(const bool enable, const bool enable_auto_hinting = true); void setFontHinting(const bool enable, const bool enable_auto_hinting = true);
//! Draws some text and clips it to the specified rectangle if wanted. //! 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, video::SColor color, bool hcenter = false, bool vcenter = false,
const core::rect<s32>* clip = 0); 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);
//! Returns the dimension of a character produced by this font. //! Returns the dimension of a character produced by this font.
virtual core::dimension2d<u32> getCharDimension(const wchar_t ch) const; core::dimension2d<u32> getCharDimension(const wchar_t ch) const;
//! Returns the dimension of a text string. //! Returns the dimension of a text string.
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const; core::dimension2d<u32> getDimension(const wchar_t* text) const override;
virtual core::dimension2d<u32> getDimension(const core::ustring& text) const; core::dimension2d<u32> getDimension(const core::ustring& text) const;
//! Calculates the index of the character in the text which is on a specific position. //! Calculates the index of the character in the text which is on a specific position.
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const; s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const override;
virtual s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const; s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const;
//! Sets global kerning width for the font. //! Sets global kerning width for the font.
virtual void setKerningWidth(s32 kerning); void setKerningWidth(s32 kerning) override;
//! Sets global kerning height for the font. //! Sets global kerning height for the font.
virtual void setKerningHeight(s32 kerning); void setKerningHeight(s32 kerning) override;
//! Gets kerning values (distance between letters) for the font. If no parameters are provided, //! Gets kerning values (distance between letters) for the font. If no parameters are provided,
virtual s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const; s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const override;
virtual s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const; s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const;
//! Returns the distance between letters //! Returns the distance between letters
virtual s32 getKerningHeight() const; s32 getKerningHeight() const override;
//! Define which characters should not be drawn by the font. //! Define which characters should not be drawn by the font.
virtual void setInvisibleCharacters(const wchar_t *s); void setInvisibleCharacters(const wchar_t *s) override;
virtual void setInvisibleCharacters(const core::ustring& s); void setInvisibleCharacters(const core::ustring& s);
//! Get the last glyph page if there's still available slots. //! Get the last glyph page if there's still available slots.
//! If not, it will return zero. //! If not, it will return zero.
...@@ -315,14 +315,14 @@ public: ...@@ -315,14 +315,14 @@ public:
//! Create corresponding character's software image copy from the font, //! Create corresponding character's software image copy from the font,
//! so you can use this data just like any ordinary video::IImage. //! so you can use this data just like any ordinary video::IImage.
//! \param ch The character you need //! \param ch The character you need
virtual video::IImage* createTextureFromChar(const uchar32_t& ch); video::IImage* createTextureFromChar(const uchar32_t& ch);
//! This function is for debugging mostly. If the page doesn't exist it returns zero. //! This function is for debugging mostly. If the page doesn't exist it returns zero.
//! \param page_index Simply return the texture handle of a given page index. //! \param page_index Simply return the texture handle of a given page index.
virtual video::ITexture* getPageTextureByIndex(const u32& page_index) const; video::ITexture* getPageTextureByIndex(const u32& page_index) const;
//! Add a list of scene nodes generated by putting font textures on the 3D planes. //! Add a list of scene nodes generated by putting font textures on the 3D planes.
virtual core::array<scene::ISceneNode*> addTextSceneNode core::array<scene::ISceneNode*> addTextSceneNode
(const wchar_t* text, scene::ISceneManager* smgr, scene::ISceneNode* parent = 0, (const wchar_t* text, scene::ISceneManager* smgr, scene::ISceneNode* parent = 0,
const video::SColor& color = video::SColor(255, 0, 0, 0), bool center = false ); const video::SColor& color = video::SColor(255, 0, 0, 0), bool center = false );
...@@ -343,7 +343,7 @@ private: ...@@ -343,7 +343,7 @@ private:
static scene::IMesh* shared_plane_ptr_; static scene::IMesh* shared_plane_ptr_;
static scene::SMesh shared_plane_; static scene::SMesh shared_plane_;
CGUITTFont(IGUIEnvironment *env); explicit CGUITTFont(IGUIEnvironment *env);
bool load(const io::path& filename, const u32 size, const bool antialias, const bool transparency); bool load(const io::path& filename, const u32 size, const bool antialias, const bool transparency);
void reset_images(); void reset_images();
void update_glyph_pages() const; void update_glyph_pages() const;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define BUFFERIO_H #define BUFFERIO_H
#include <cstdint> #include <cstdint>
#include <cwchar>
#include "../ocgcore/buffer.h" #include "../ocgcore/buffer.h"
class BufferIO { class BufferIO {
...@@ -49,6 +50,16 @@ public: ...@@ -49,6 +50,16 @@ public:
*pstr = 0; *pstr = 0;
return l; return l;
} }
template<size_t N>
static void CopyString(const char* src, wchar_t(&dst)[N]) {
dst[0] = 0;
std::strncat(dst, src, N - 1);
}
template<size_t N>
static void CopyWideString(const wchar_t* src, wchar_t(&dst)[N]) {
dst[0] = 0;
std::wcsncat(dst, src, N - 1);
}
template<typename T> template<typename T>
static bool CheckUTF8Byte(const T* str, int len) { static bool CheckUTF8Byte(const T* str, int len) {
for (int i = 1; i < len; ++i) { for (int i = 1; i < len; ++i) {
......
...@@ -112,8 +112,6 @@ bool DataManager::LoadStrings(const char* file) { ...@@ -112,8 +112,6 @@ bool DataManager::LoadStrings(const char* file) {
ReadStringConfLine(linebuf); ReadStringConfLine(linebuf);
} }
fclose(fp); fclose(fp);
for(int i = 0; i < 301; ++i)
myswprintf(numStrings[i], L"%d", i);
return true; return true;
} }
bool DataManager::LoadStrings(IReadFile* reader) { bool DataManager::LoadStrings(IReadFile* reader) {
...@@ -278,14 +276,12 @@ std::vector<unsigned int> DataManager::GetSetCodes(std::wstring setname) const { ...@@ -278,14 +276,12 @@ std::vector<unsigned int> DataManager::GetSetCodes(std::wstring setname) const {
} }
return matchingCodes; return matchingCodes;
} }
const wchar_t* DataManager::GetNumString(int num, bool bracket) { std::wstring DataManager::GetNumString(int num, bool bracket) const {
if(!bracket) if(!bracket)
return numStrings[num]; return std::to_wstring(num);
wchar_t* p = numBuffer; std::wstring numBuffer{ L"(" };
*p++ = L'('; numBuffer.append(std::to_wstring(num));
BufferIO::CopyWStrRef(numStrings[num], p, 4); numBuffer.push_back(L')');
*p = L')';
*++p = 0;
return numBuffer; return numBuffer;
} }
const wchar_t* DataManager::FormatLocation(int location, int sequence) const { const wchar_t* DataManager::FormatLocation(int location, int sequence) const {
...@@ -310,95 +306,81 @@ const wchar_t* DataManager::FormatLocation(int location, int sequence) const { ...@@ -310,95 +306,81 @@ const wchar_t* DataManager::FormatLocation(int location, int sequence) const {
else else
return unknown_string; return unknown_string;
} }
const wchar_t* DataManager::FormatAttribute(int attribute) { std::wstring DataManager::FormatAttribute(unsigned int attribute) const {
wchar_t* p = attBuffer; std::wstring buffer;
unsigned filter = 1; for (int i = 0; i < ATTRIBUTES_COUNT; ++i) {
int i = 1010; if (attribute & (0x1U << i)) {
for(; filter != 0x80; filter <<= 1, ++i) { if (!buffer.empty())
if(attribute & filter) { buffer.push_back(L'|');
BufferIO::CopyWStrRef(GetSysString(i), p, 16); buffer.append(GetSysString(1010 + i));
*p = L'|';
*++p = 0;
} }
} }
if(p != attBuffer) if (buffer.empty())
*(p - 1) = 0; return std::wstring(unknown_string);
else return buffer;
return unknown_string; }
return attBuffer; std::wstring DataManager::FormatRace(unsigned int race) const {
} std::wstring buffer;
const wchar_t* DataManager::FormatRace(int race) { for(int i = 0; i < RACES_COUNT; ++i) {
wchar_t* p = racBuffer; if(race & (0x1U << i)) {
unsigned filter = 1; if (!buffer.empty())
int i = 1020; buffer.push_back(L'|');
for(; filter < (1 << RACES_COUNT); filter <<= 1, ++i) { buffer.append(GetSysString(1020 + i));
if(race & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16);
*p = L'|';
*++p = 0;
} }
} }
if(p != racBuffer) if (buffer.empty())
*(p - 1) = 0; return std::wstring(unknown_string);
else return buffer;
return unknown_string;
return racBuffer;
} }
const wchar_t* DataManager::FormatType(int type) { std::wstring DataManager::FormatType(unsigned int type) const {
wchar_t* p = tpBuffer; std::wstring buffer;
unsigned filter = 1;
int i = 1050; int i = 1050;
for(; filter != 0x8000000; filter <<= 1, ++i) { for (unsigned filter = TYPE_MONSTER; filter <= TYPE_LINK; filter <<= 1, ++i) {
if(type & filter) { if (type & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16); if (!buffer.empty())
*p = L'|'; buffer.push_back(L'|');
*++p = 0; buffer.append(GetSysString(i));
} }
} }
if(p != tpBuffer) if (buffer.empty())
*(p - 1) = 0; return std::wstring(unknown_string);
else return buffer;
return unknown_string;
return tpBuffer;
} }
const wchar_t* DataManager::FormatSetName(const uint16_t setcode[]) { std::wstring DataManager::FormatSetName(const uint16_t setcode[]) const {
wchar_t* p = scBuffer; std::wstring buffer;
for(int i = 0; i < 10; ++i) { for(int i = 0; i < 10; ++i) {
if (!setcode[i]) if (!setcode[i])
break; break;
const wchar_t* setname = GetSetName(setcode[i]); const wchar_t* setname = GetSetName(setcode[i]);
if(setname) { if(setname) {
BufferIO::CopyWStrRef(setname, p, 32); if (!buffer.empty())
*p = L'|'; buffer.push_back(L'|');
*++p = 0; buffer.append(setname);
} }
} }
if(p != scBuffer) if (buffer.empty())
*(p - 1) = 0; return std::wstring(unknown_string);
else return buffer;
return unknown_string; }
return scBuffer; std::wstring DataManager::FormatLinkMarker(unsigned int link_marker) const {
} std::wstring buffer;
const wchar_t* DataManager::FormatLinkMarker(int link_marker) { if (link_marker & LINK_MARKER_TOP_LEFT)
wchar_t* p = lmBuffer; buffer.append(L"[\u2196]");
*p = 0; if (link_marker & LINK_MARKER_TOP)
if(link_marker & LINK_MARKER_TOP_LEFT) buffer.append(L"[\u2191]");
BufferIO::CopyWStrRef(L"[\u2196]", p, 4); if (link_marker & LINK_MARKER_TOP_RIGHT)
if(link_marker & LINK_MARKER_TOP) buffer.append(L"[\u2197]");
BufferIO::CopyWStrRef(L"[\u2191]", p, 4); if (link_marker & LINK_MARKER_LEFT)
if(link_marker & LINK_MARKER_TOP_RIGHT) buffer.append(L"[\u2190]");
BufferIO::CopyWStrRef(L"[\u2197]", p, 4); if (link_marker & LINK_MARKER_RIGHT)
if(link_marker & LINK_MARKER_LEFT) buffer.append(L"[\u2192]");
BufferIO::CopyWStrRef(L"[\u2190]", p, 4); if (link_marker & LINK_MARKER_BOTTOM_LEFT)
if(link_marker & LINK_MARKER_RIGHT) buffer.append(L"[\u2199]");
BufferIO::CopyWStrRef(L"[\u2192]", p, 4); if (link_marker & LINK_MARKER_BOTTOM)
if(link_marker & LINK_MARKER_BOTTOM_LEFT) buffer.append(L"[\u2193]");
BufferIO::CopyWStrRef(L"[\u2199]", p, 4); if (link_marker & LINK_MARKER_BOTTOM_RIGHT)
if(link_marker & LINK_MARKER_BOTTOM) buffer.append(L"[\u2198]");
BufferIO::CopyWStrRef(L"[\u2193]", p, 4); return buffer;
if(link_marker & LINK_MARKER_BOTTOM_RIGHT)
BufferIO::CopyWStrRef(L"[\u2198]", p, 4);
return lmBuffer;
} }
uint32 DataManager::CardReader(uint32 code, card_data* pData) { uint32 DataManager::CardReader(uint32 code, card_data* pData) {
if (!dataManager.GetData(code, pData)) if (!dataManager.GetData(code, pData))
......
...@@ -3,14 +3,8 @@ ...@@ -3,14 +3,8 @@
#include "config.h" #include "config.h"
#include <unordered_map> #include <unordered_map>
#ifdef _IRR_ANDROID_PLATFORM_
#include <sqlite3.h> #include <sqlite3.h>
#else
#include "sqlite3.h"
#endif
#include "spmemvfs/spmemvfs.h"
#include "client_card.h" #include "client_card.h"
#include <unordered_map>
namespace ygo { namespace ygo {
constexpr int MAX_STRING_ID = 0x7ff; constexpr int MAX_STRING_ID = 0x7ff;
...@@ -42,13 +36,13 @@ public: ...@@ -42,13 +36,13 @@ public:
const wchar_t* GetCounterName(int code) const; const wchar_t* GetCounterName(int code) const;
const wchar_t* GetSetName(int code) const; const wchar_t* GetSetName(int code) const;
std::vector<unsigned int> GetSetCodes(std::wstring setname) 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* FormatLocation(int location, int sequence) const;
const wchar_t* FormatAttribute(int attribute); std::wstring FormatAttribute(unsigned int attribute) const;
const wchar_t* FormatRace(int race); std::wstring FormatRace(unsigned int race) const;
const wchar_t* FormatType(int type); std::wstring FormatType(unsigned int type) const;
const wchar_t* FormatSetName(const uint16_t setcode[]); std::wstring FormatSetName(const uint16_t setcode[]) const;
const wchar_t* FormatLinkMarker(int link_marker); std::wstring FormatLinkMarker(unsigned int link_marker) const;
std::unordered_map<unsigned int, std::wstring> _counterStrings; std::unordered_map<unsigned int, std::wstring> _counterStrings;
std::unordered_map<unsigned int, std::wstring> _victoryStrings; std::unordered_map<unsigned int, std::wstring> _victoryStrings;
...@@ -56,14 +50,6 @@ public: ...@@ -56,14 +50,6 @@ public:
std::unordered_map<unsigned int, std::wstring> _sysStrings; std::unordered_map<unsigned int, std::wstring> _sysStrings;
char errmsg[512]{}; char errmsg[512]{};
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 byte scriptBuffer[0x20000];
static const wchar_t* unknown_string; static const wchar_t* unknown_string;
static uint32 CardReader(uint32, card_data*); static uint32 CardReader(uint32, card_data*);
......
...@@ -187,7 +187,7 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p ...@@ -187,7 +187,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 DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_packlist) {
int ct = 0, mainc = 0, sidec = 0, code = 0; int ct = 0, mainc = 0, sidec = 0, code = 0;
int cardlist[300]{}; int cardlist[PACK_MAX_SIZE]{};
bool is_side = false; bool is_side = false;
std::string linebuf; std::string linebuf;
while (std::getline(deckStream, linebuf, '\n') && ct < (int)(sizeof cardlist / sizeof cardlist[0])) { while (std::getline(deckStream, linebuf, '\n') && ct < (int)(sizeof cardlist / sizeof cardlist[0])) {
......
...@@ -12,6 +12,7 @@ namespace ygo { ...@@ -12,6 +12,7 @@ namespace ygo {
constexpr int DECK_MIN_SIZE = 40; constexpr int DECK_MIN_SIZE = 40;
constexpr int EXTRA_MAX_SIZE = 15; constexpr int EXTRA_MAX_SIZE = 15;
constexpr int SIDE_MAX_SIZE = 15; constexpr int SIDE_MAX_SIZE = 15;
constexpr int PACK_MAX_SIZE = 1000;
struct LFList { struct LFList {
unsigned int hash{}; unsigned int hash{};
......
This diff is collapsed.
...@@ -1132,7 +1132,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -1132,7 +1132,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
break; break;
} }
case HINT_RACE: { 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->AddLog(textBuffer);
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310 * mainGame->xScale, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stACMessage, 310 * mainGame->xScale, mainGame->guiFont, textBuffer);
...@@ -1142,7 +1142,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -1142,7 +1142,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
break; break;
} }
case HINT_ATTRIB: { 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->AddLog(textBuffer);
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310 * mainGame->xScale, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stACMessage, 310 * mainGame->xScale, mainGame->guiFont, textBuffer);
...@@ -1229,7 +1229,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -1229,7 +1229,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
int type = BufferIO::ReadUInt8(pbuf); int type = BufferIO::ReadUInt8(pbuf);
mainGame->showcarddif = 110; mainGame->showcarddif = 110;
mainGame->showcardp = 0; mainGame->showcardp = 0;
mainGame->dInfo.vic_string = 0; mainGame->dInfo.vic_string = L"";
wchar_t vic_buf[256]; wchar_t vic_buf[256];
if(player == 2) if(player == 2)
mainGame->showcardcode = 3; mainGame->showcardcode = 3;
...@@ -1255,7 +1255,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -1255,7 +1255,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
} }
mainGame->showcard = 101; mainGame->showcard = 101;
mainGame->WaitFrameSignal(120); mainGame->WaitFrameSignal(120);
mainGame->dInfo.vic_string = 0; mainGame->dInfo.vic_string = L"";
mainGame->showcard = 0; mainGame->showcard = 0;
break; break;
} }
...@@ -3234,7 +3234,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -3234,7 +3234,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30); mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10; mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0; mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final; mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock(); mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
...@@ -3263,7 +3263,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -3263,7 +3263,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30); mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10; mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0; mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final; mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock(); mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
...@@ -3415,7 +3415,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) { ...@@ -3415,7 +3415,7 @@ int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
mainGame->WaitFrameSignal(30); mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10; mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0; mainGame->lpcstring = L"";
mainGame->dInfo.lp[player] = final; mainGame->dInfo.lp[player] = final;
mainGame->gMutex.lock(); mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
......
...@@ -1680,7 +1680,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1680,7 +1680,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
myswprintf(formatBuffer, L"\nLINK-%d", mcard->link); myswprintf(formatBuffer, L"\nLINK-%d", mcard->link);
str.append(formatBuffer); 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); str.append(formatBuffer);
if(mcard->location == LOCATION_HAND && (mcard->type & TYPE_PENDULUM)) { if(mcard->location == LOCATION_HAND && (mcard->type & TYPE_PENDULUM)) {
myswprintf(formatBuffer, L"\n%d/%d", mcard->lscale, mcard->rscale); myswprintf(formatBuffer, L"\n%d/%d", mcard->lscale, mcard->rscale);
...@@ -1706,9 +1706,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1706,9 +1706,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
else if(mcard->cHint == CHINT_CARD) else if(mcard->cHint == CHINT_CARD)
myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(212), dataManager.GetName(mcard->chValue)); myswprintf(formatBuffer, L"\n%ls%ls", dataManager.GetSysString(212), dataManager.GetName(mcard->chValue));
else if(mcard->cHint == CHINT_RACE) 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) 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) else if(mcard->cHint == CHINT_NUMBER)
myswprintf(formatBuffer, L"\n%ls%d", dataManager.GetSysString(215), mcard->chValue); myswprintf(formatBuffer, L"\n%ls%d", dataManager.GetSysString(215), mcard->chValue);
str.append(formatBuffer); str.append(formatBuffer);
......
...@@ -52,7 +52,6 @@ void DuelInfo::Clear() { ...@@ -52,7 +52,6 @@ void DuelInfo::Clear() {
clientname_tag[0] = 0; clientname_tag[0] = 0;
strLP[0][0] = 0; strLP[0][0] = 0;
strLP[1][0] = 0; strLP[1][0] = 0;
vic_string = 0;
player_type = 0; player_type = 0;
time_player = 0; time_player = 0;
time_limit = 0; time_limit = 0;
...@@ -60,6 +59,15 @@ void DuelInfo::Clear() { ...@@ -60,6 +59,15 @@ void DuelInfo::Clear() {
time_left[1] = 0; time_left[1] = 0;
} }
bool IsExtension(const wchar_t* filename, const wchar_t* extension) {
int flen = std::wcslen(filename);
int elen = std::wcslen(extension);
if (!flen || !elen || flen < elen)
return false;
auto fend = filename + flen;
return !wcsncasecmp(fend - elen, extension, elen);
}
void Game::process(irr::SEvent &event) { void Game::process(irr::SEvent &event) {
if (event.EventType == EET_MOUSE_INPUT_EVENT) { if (event.EventType == EET_MOUSE_INPUT_EVENT) {
s32 x = event.MouseInput.X; s32 x = event.MouseInput.X;
...@@ -207,7 +215,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -207,7 +215,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
showcard = 0; showcard = 0;
is_attacking = false; is_attacking = false;
lpframe = 0; lpframe = 0;
lpcstring = 0;
always_chain = false; always_chain = false;
ignore_chain = false; ignore_chain = false;
chain_when_avail = false; chain_when_avail = false;
...@@ -239,8 +246,10 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -239,8 +246,10 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
imageManager.SetDevice(device); imageManager.SetDevice(device);
imageManager.ClearTexture(); imageManager.ClearTexture();
if(!imageManager.Initial(workingDir)) if(!imageManager.Initial(workingDir)) {
ErrorLog("Failed to load textures!");
return false; return false;
}
// LoadExpansions only load zips, the other cdb databases are still loaded by getDBFiles // LoadExpansions only load zips, the other cdb databases are still loaded by getDBFiles
io::path* cdbs = options->getDBFiles(); io::path* cdbs = options->getDBFiles();
len = options->getDbCount(); len = options->getDbCount();
...@@ -260,8 +269,10 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -260,8 +269,10 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
if(dataManager.LoadStrings((workingDir + path("/expansions/strings.conf")).c_str())){ if(dataManager.LoadStrings((workingDir + path("/expansions/strings.conf")).c_str())){
ALOGD("loadStrings expansions/strings.conf"); ALOGD("loadStrings expansions/strings.conf");
} }
if(!dataManager.LoadStrings((workingDir + path("/strings.conf")).c_str())) if(!dataManager.LoadStrings((workingDir + path("/strings.conf")).c_str())) {
ErrorLog("Failed to load strings!");
return false; return false;
}
LoadExpansions(); LoadExpansions();
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
bool isAntialias = options->isFontAntiAliasEnabled(); bool isAntialias = options->isFontAntiAliasEnabled();
...@@ -837,7 +848,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -837,7 +848,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
stANAttribute->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); stANAttribute->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
for(int filter = 0x1, i = 0; i < 7; filter <<= 1, ++i) for(int filter = 0x1, i = 0; i < 7; filter <<= 1, ++i)
chkAttribute[i] = env->addCheckBox(false, rect<s32>((50 + (i % 4) * 80) * xScale, (60 + (i / 4) * 55) * yScale, (130 + (i % 4) * 80) * xScale, (90 + (i / 4) * 55) * yScale), chkAttribute[i] = env->addCheckBox(false, rect<s32>((50 + (i % 4) * 80) * xScale, (60 + (i / 4) * 55) * yScale, (130 + (i % 4) * 80) * xScale, (90 + (i / 4) * 55) * yScale),
wANAttribute, CHECK_ATTRIBUTE, dataManager.FormatAttribute(filter)); wANAttribute, CHECK_ATTRIBUTE, dataManager.FormatAttribute(filter).c_str());
//announce race //announce race
wANRace = env->addWindow(rect<s32>(500 * xScale, 40 * yScale, 800 * xScale, 560 * yScale), false, dataManager.GetSysString(563)); wANRace = env->addWindow(rect<s32>(500 * xScale, 40 * yScale, 800 * xScale, 560 * yScale), false, dataManager.GetSysString(563));
wANRace->getCloseButton()->setVisible(false); wANRace->getCloseButton()->setVisible(false);
...@@ -847,7 +858,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -847,7 +858,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
stANRace->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); stANRace->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
for(int filter = 0x1, i = 0; i < RACES_COUNT; filter <<= 1, ++i) for(int filter = 0x1, i = 0; i < RACES_COUNT; filter <<= 1, ++i)
chkRace[i] = env->addCheckBox(false, rect<s32>((30 + (i % 3) * 90) * xScale, (60 + (i / 3) * 50) * yScale, (100 + (i % 3) * 90) * xScale, (110 + (i / 3) * 50) * yScale), chkRace[i] = env->addCheckBox(false, rect<s32>((30 + (i % 3) * 90) * xScale, (60 + (i / 3) * 50) * yScale, (100 + (i % 3) * 90) * xScale, (110 + (i / 3) * 50) * yScale),
wANRace, CHECK_RACE, dataManager.FormatRace(filter)); wANRace, CHECK_RACE, dataManager.FormatRace(filter).c_str());
//selection hint //selection hint
stHintMsg = env->addStaticText(L"", rect<s32>(500 * xScale, 90 * yScale, 820 * xScale, 120 * yScale), true, false, 0, -1, false); stHintMsg = env->addStaticText(L"", rect<s32>(500 * xScale, 90 * yScale, 820 * xScale, 120 * yScale), true, false, 0, -1, false);
stHintMsg->setBackgroundColor(0xee11113d); stHintMsg->setBackgroundColor(0xee11113d);
...@@ -1017,13 +1028,13 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -1017,13 +1028,13 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
cbAttribute->setMaxSelectionRows(10); cbAttribute->setMaxSelectionRows(10);
cbAttribute->addItem(dataManager.GetSysString(1310), 0); cbAttribute->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter != 0x80; filter <<= 1) for(int filter = 0x1; filter != 0x80; filter <<= 1)
cbAttribute->addItem(dataManager.FormatAttribute(filter), filter); cbAttribute->addItem(dataManager.FormatAttribute(filter).c_str(), filter);
env->addStaticText(dataManager.GetSysString(1321), rect<s32>(10 * xScale, 51 * yScale, 70 * xScale, 71 * yScale), false, false, wFilter); env->addStaticText(dataManager.GetSysString(1321), rect<s32>(10 * xScale, 51 * yScale, 70 * xScale, 71 * yScale), false, false, wFilter);
cbRace = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(60 * xScale, (40 + 75 / 6) * yScale, 190 * xScale, (60 + 75 / 6) * yScale), wFilter, COMBOBOX_RACE); cbRace = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(60 * xScale, (40 + 75 / 6) * yScale, 190 * xScale, (60 + 75 / 6) * yScale), wFilter, COMBOBOX_RACE);
cbRace->setMaxSelectionRows(10); cbRace->setMaxSelectionRows(10);
cbRace->addItem(dataManager.GetSysString(1310), 0); cbRace->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter < (1 << RACES_COUNT); filter <<= 1) for(int filter = 0x1; filter < (1 << RACES_COUNT); filter <<= 1)
cbRace->addItem(dataManager.FormatRace(filter), filter); cbRace->addItem(dataManager.FormatRace(filter).c_str(), filter);
env->addStaticText(dataManager.GetSysString(1322), rect<s32>(205 * xScale, 28 * yScale, 280 * xScale, 48 * yScale), false, false, wFilter); env->addStaticText(dataManager.GetSysString(1322), rect<s32>(205 * xScale, 28 * yScale, 280 * xScale, 48 * yScale), false, false, wFilter);
ebAttack = CAndroidGUIEditBox::addAndroidEditBox(L"", true, env, rect<s32>(260 * xScale, 26 * yScale, 340 * xScale, 46 * yScale), wFilter, EDITBOX_INPUTS); ebAttack = CAndroidGUIEditBox::addAndroidEditBox(L"", true, env, rect<s32>(260 * xScale, 26 * yScale, 340 * xScale, 46 * yScale), wFilter, EDITBOX_INPUTS);
ebAttack->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); ebAttack->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
...@@ -1898,7 +1909,7 @@ void Game::ShowCardInfo(int code) { ...@@ -1898,7 +1909,7 @@ void Game::ShowCardInfo(int code) {
} }
if (target->second.setcode[0]) { if (target->second.setcode[0]) {
offset = 23;// *yScale; 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); stSetName->setText(formatBuffer);
} }
else else
...@@ -1909,13 +1920,14 @@ void Game::ShowCardInfo(int code) { ...@@ -1909,13 +1920,14 @@ void Game::ShowCardInfo(int code) {
} }
if(is_valid && cit->second.type & TYPE_MONSTER) { if(is_valid && cit->second.type & TYPE_MONSTER) {
auto& cd = cit->second; 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); stInfo->setText(formatBuffer);
const wchar_t* form = L"\u2605";
wchar_t adBuffer[64]{};
wchar_t scaleBuffer[16]{};
if(!(cd.type & TYPE_LINK)) { if(!(cd.type & TYPE_LINK)) {
const wchar_t* form = L"\u2605"; if(cd.type & TYPE_XYZ)
if(cd.type & TYPE_XYZ) form = L"\u2606"; form = L"\u2606";
myswprintf(formatBuffer, L"[%ls%d] ", form, cd.level);
wchar_t adBuffer[16];
if(cd.attack < 0 && cd.defense < 0) if(cd.attack < 0 && cd.defense < 0)
myswprintf(adBuffer, L"?/?"); myswprintf(adBuffer, L"?/?");
else if(cd.attack < 0) else if(cd.attack < 0)
...@@ -1924,22 +1936,17 @@ void Game::ShowCardInfo(int code) { ...@@ -1924,22 +1936,17 @@ void Game::ShowCardInfo(int code) {
myswprintf(adBuffer, L"%d/?", cd.attack); myswprintf(adBuffer, L"%d/?", cd.attack);
else else
myswprintf(adBuffer, L"%d/%d", cd.attack, cd.defense); myswprintf(adBuffer, L"%d/%d", cd.attack, cd.defense);
wcscat(formatBuffer, adBuffer);
} else { } else {
myswprintf(formatBuffer, L"[LINK-%d] ", cd.level); form = L"LINK-";
wchar_t adBuffer[16];
if(cd.attack < 0) if(cd.attack < 0)
myswprintf(adBuffer, L"?/- "); myswprintf(adBuffer, L"?/- %ls", dataManager.FormatLinkMarker(cd.link_marker).c_str());
else else
myswprintf(adBuffer, L"%d/- ", cd.attack); myswprintf(adBuffer, L"%d/- %ls", cd.attack, dataManager.FormatLinkMarker(cd.link_marker).c_str());
wcscat(formatBuffer, adBuffer);
wcscat(formatBuffer, dataManager.FormatLinkMarker(cd.link_marker));
} }
if(cd.type & TYPE_PENDULUM) { if(cd.type & TYPE_PENDULUM) {
wchar_t scaleBuffer[16];
myswprintf(scaleBuffer, L" %d/%d", cd.lscale, cd.rscale); myswprintf(scaleBuffer, L" %d/%d", cd.lscale, cd.rscale);
wcscat(formatBuffer, scaleBuffer);
} }
myswprintf(formatBuffer, L"[%ls%d] %ls%ls", form, cd.level, adBuffer, scaleBuffer);
stDataInfo->setText(formatBuffer); stDataInfo->setText(formatBuffer);
stSetName->setRelativePosition(rect<s32>(10 * xScale, 83 * yScale, 250 * xScale, 106 * yScale)); stSetName->setRelativePosition(rect<s32>(10 * xScale, 83 * yScale, 250 * xScale, 106 * yScale));
stText->setRelativePosition(rect<s32>(10 * xScale, (83 + offset) * yScale, 251 * xScale, 340 * yScale)); stText->setRelativePosition(rect<s32>(10 * xScale, (83 + offset) * yScale, 251 * xScale, 340 * yScale));
...@@ -1947,9 +1954,9 @@ void Game::ShowCardInfo(int code) { ...@@ -1947,9 +1954,9 @@ void Game::ShowCardInfo(int code) {
} }
else { else {
if (is_valid) if (is_valid)
myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(cit->second.type)); myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(cit->second.type).c_str());
else else
myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(0)); myswprintf(formatBuffer, L"[%ls]", dataManager.unknown_string);
stInfo->setText(formatBuffer); stInfo->setText(formatBuffer);
stDataInfo->setText(L""); stDataInfo->setText(L"");
stSetName->setRelativePosition(rect<s32>(10 * xScale, 60 * yScale, 250 * xScale, 106 * yScale)); stSetName->setRelativePosition(rect<s32>(10 * xScale, 60 * yScale, 250 * xScale, 106 * yScale));
......
...@@ -21,10 +21,13 @@ ...@@ -21,10 +21,13 @@
#include <functional> #include <functional>
#include "sound_manager.h" #include "sound_manager.h"
#define DEFAULT_DUEL_RULE 5 constexpr int DEFAULT_DUEL_RULE = 5;
constexpr int CONFIG_LINE_SIZE = 1024;
namespace ygo { namespace ygo {
bool IsExtension(const wchar_t* filename, const wchar_t* extension);
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
#define LOG_TAG "ygo-jni" #define LOG_TAG "ygo-jni"
#define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG ,__VA_ARGS__) #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG ,__VA_ARGS__)
...@@ -43,12 +46,13 @@ struct Config { ...@@ -43,12 +46,13 @@ struct Config {
wchar_t lastport[10]{}; wchar_t lastport[10]{};
wchar_t nickname[20]{}; wchar_t nickname[20]{};
wchar_t gamename[20]{}; wchar_t gamename[20]{};
wchar_t lastcategory[64]{}; wchar_t roompass[20]{};
wchar_t lastdeck[64]{}; //path
wchar_t lastcategory[256]{};
wchar_t lastdeck[256]{};
wchar_t textfont[256]{}; wchar_t textfont[256]{};
wchar_t numfont[256]{}; wchar_t numfont[256]{};
wchar_t roompass[20]{}; wchar_t bot_deck_path[256]{};
wchar_t bot_deck_path[64]{};
//settings //settings
int chkMAutoPos{ 0 }; int chkMAutoPos{ 0 };
int chkSTAutoPos{ 0 }; int chkSTAutoPos{ 0 };
...@@ -106,14 +110,14 @@ struct DuelInfo { ...@@ -106,14 +110,14 @@ struct DuelInfo {
wchar_t hostname_tag[20]{}; wchar_t hostname_tag[20]{};
wchar_t clientname_tag[20]{}; wchar_t clientname_tag[20]{};
wchar_t strLP[2][16]{}; wchar_t strLP[2][16]{};
wchar_t* vic_string{ nullptr }; std::wstring vic_string;
unsigned char player_type{ 0 }; unsigned char player_type{ 0 };
unsigned char time_player{ 0 }; unsigned char time_player{ 0 };
unsigned short time_limit{ 0 }; unsigned short time_limit{ 0 };
unsigned short time_left[2]{}; unsigned short time_left[2]{};
void Clear(); void Clear();
int card_count[2]; int card_count[2];
int total_attack[2]; int total_attack[2];
wchar_t str_time_left[2][16]; wchar_t str_time_left[2][16];
...@@ -174,7 +178,6 @@ public: ...@@ -174,7 +178,6 @@ public:
void CheckMutual(ClientCard* pcard, int mark); void CheckMutual(ClientCard* pcard, int mark);
void DrawCards(); void DrawCards();
void DrawCard(ClientCard* pcard); 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 DrawMisc();
void DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2); void DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2);
void DrawGUI(); void DrawGUI();
...@@ -224,8 +227,10 @@ public: ...@@ -224,8 +227,10 @@ public:
void ResizeChatInputWindow(); void ResizeChatInputWindow();
template<typename T> template<typename T>
static std::vector<T> TokenizeString(T input, const T& token); static std::vector<T> TokenizeString(T input, const T& token);
template<typename T>
static 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);
// don't merge
std::unique_ptr<SoundManager> soundManager; std::unique_ptr<SoundManager> soundManager;
std::mutex gMutex; std::mutex gMutex;
Signal frameSignal; Signal frameSignal;
...@@ -265,7 +270,7 @@ public: ...@@ -265,7 +270,7 @@ public:
int lpd; int lpd;
int lpplayer; int lpplayer;
int lpccolor; int lpccolor;
wchar_t* lpcstring; std::wstring lpcstring;
bool always_chain; bool always_chain;
bool ignore_chain; bool ignore_chain;
bool chain_when_avail; bool chain_when_avail;
...@@ -710,21 +715,22 @@ private: ...@@ -710,21 +715,22 @@ private:
}; };
extern Game* mainGame; extern Game* mainGame;
template<typename T> template<typename T>
inline std::vector<T> Game::TokenizeString(T input, const T & token) { inline std::vector<T> Game::TokenizeString(T input, const T & token) {
std::vector<T> res; std::vector<T> res;
std::size_t pos; std::size_t pos;
while((pos = input.find(token)) != T::npos) { while((pos = input.find(token)) != T::npos) {
if(pos != 0) if(pos != 0)
res.push_back(input.substr(0, pos)); res.push_back(input.substr(0, pos));
input = input.substr(pos + 1); input = input.substr(pos + 1);
}
if(input.size())
res.push_back(input);
return res;
} }
if(input.size())
res.push_back(input);
return res;
}
} }
#define SIZE_QUERY_BUFFER 0x4000 #define SIZE_QUERY_BUFFER 0x4000
#define CARD_IMG_WIDTH 200 #define CARD_IMG_WIDTH 200
......
This diff is collapsed.
#ifndef FILESYSTEM_H #ifndef FILESYSTEM_H
#define FILESYSTEM_H #define FILESYSTEM_H
#include <string.h> #include <cstdio>
#include <functional> #include <functional>
#include "bufferio.h" #include "bufferio.h"
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
class FileSystem { class FileSystem {
public: public:
static void SafeFileName(wchar_t* wfile) { static void SafeFileName(wchar_t* wfile) {
while((wfile = wcspbrk(wfile, L"<>:\"/\\|?*")) != NULL) while((wfile = std::wcspbrk(wfile, L"<>:\"/\\|?*")) != nullptr)
*wfile++ = '_'; *wfile++ = '_';
} }
...@@ -70,8 +70,8 @@ public: ...@@ -70,8 +70,8 @@ public:
static bool DeleteDir(const wchar_t* wdir) { static bool DeleteDir(const wchar_t* wdir) {
wchar_t pdir[256]; wchar_t pdir[256];
BufferIO::CopyWStr(wdir, pdir, 256); int len = BufferIO::CopyWStr(wdir, pdir, sizeof pdir / sizeof pdir[0]);
pdir[wcslen(wdir) + 1] = 0; pdir[len + 1] = 0;
SHFILEOPSTRUCTW lpFileOp; SHFILEOPSTRUCTW lpFileOp;
lpFileOp.hwnd = NULL; lpFileOp.hwnd = NULL;
lpFileOp.wFunc = FO_DELETE; lpFileOp.wFunc = FO_DELETE;
...@@ -89,8 +89,7 @@ public: ...@@ -89,8 +89,7 @@ public:
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) { static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
wchar_t findstr[1024]; wchar_t findstr[1024];
wcscpy(findstr, wpath); std::swprintf(findstr, sizeof findstr / sizeof findstr[0], L"%s/*", wpath);
wcscat(findstr, L"/*");
WIN32_FIND_DATAW fdataw; WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(findstr, &fdataw); HANDLE fh = FindFirstFileW(findstr, &fdataw);
if(fh == INVALID_HANDLE_VALUE) if(fh == INVALID_HANDLE_VALUE)
...@@ -118,7 +117,7 @@ public: ...@@ -118,7 +117,7 @@ public:
class FileSystem { class FileSystem {
public: public:
static void SafeFileName(wchar_t* wfile) { static void SafeFileName(wchar_t* wfile) {
while((wfile = wcspbrk(wfile, L"/")) != NULL) while((wfile = std::wcspbrk(wfile, L"/")) != nullptr)
*wfile++ = '_'; *wfile++ = '_';
} }
...@@ -208,9 +207,7 @@ public: ...@@ -208,9 +207,7 @@ public:
while((dirp = readdir(dir)) != nullptr) { while((dirp = readdir(dir)) != nullptr) {
file_unit funit; file_unit funit;
char fname[1024]; char fname[1024];
strcpy(fname, path); std::snprintf(fname, sizeof fname, "%s/%s", path, dirp->d_name);
strcat(fname, "/");
strcat(fname, dirp->d_name);
stat(fname, &fileStat); stat(fname, &fileStat);
funit.filename = std::string(dirp->d_name); funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode); funit.is_dir = S_ISDIR(fileStat.st_mode);
......
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