Commit 29775a52 authored by fallenstardust's avatar fallenstardust

remove dataManager::strBuffer[]

parent cec921fb
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
namespace ygo { namespace ygo {
const wchar_t* DataManager::unknown_string = L"???"; const wchar_t* DataManager::unknown_string = L"???";
wchar_t DataManager::strBuffer[4096];
byte DataManager::scriptBuffer[0x20000]; byte DataManager::scriptBuffer[0x20000];
IFileSystem* DataManager::FileSystem; IFileSystem* DataManager::FileSystem;
DataManager dataManager; DataManager dataManager;
bool DataManager::LoadDB(const wchar_t* wfile) { bool DataManager::LoadDB(const wchar_t* wfile) {
char file[256]; char file[256];
wchar_t strBuffer[4096];
BufferIO::EncodeUTF8(wfile, file); BufferIO::EncodeUTF8(wfile, file);
#ifdef _WIN32 #ifdef _WIN32
IReadFile* reader = FileSystem->createAndOpenFile(wfile); IReadFile* reader = FileSystem->createAndOpenFile(wfile);
...@@ -123,6 +123,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) { ...@@ -123,6 +123,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
return; return;
char strbuf[256]; char strbuf[256];
int value; int value;
wchar_t strBuffer[4096];
sscanf(linebuf, "!%s", strbuf); sscanf(linebuf, "!%s", strbuf);
if(!strcmp(strbuf, "system")) { if(!strcmp(strbuf, "system")) {
sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf); sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf);
...@@ -143,6 +144,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) { ...@@ -143,6 +144,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
} }
} }
bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt, int errNo) { bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt, int errNo) {
wchar_t strBuffer[4096];
const char* msg = sqlite3_errmsg(pDB->handle); const char* msg = sqlite3_errmsg(pDB->handle);
BufferIO::DecodeUTF8(msg, strBuffer); BufferIO::DecodeUTF8(msg, strBuffer);
if(pStmt) if(pStmt)
......
...@@ -55,7 +55,6 @@ public: ...@@ -55,7 +55,6 @@ public:
wchar_t scBuffer[128]; wchar_t scBuffer[128];
wchar_t lmBuffer[32]; wchar_t lmBuffer[32];
static wchar_t strBuffer[4096];
static byte scriptBuffer[0x20000]; static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string; static const wchar_t* unknown_string;
static int CardReader(int, void*); static int CardReader(int, void*);
......
...@@ -345,7 +345,7 @@ bool Game::Initialize(ANDROID_APP app) { ...@@ -345,7 +345,7 @@ bool Game::Initialize(ANDROID_APP app) {
ChangeToIGUIImageWindow(wHostPrepare, bgHostPrepare, imageManager.tWindow); ChangeToIGUIImageWindow(wHostPrepare, bgHostPrepare, imageManager.tWindow);
btnHostPrepDuelist = env->addButton(rect<s32>(10 * xScale, 30 * yScale, 120 * xScale, 70 * yScale), wHostPrepare, BUTTON_HP_DUELIST, dataManager.GetSysString(1251)); btnHostPrepDuelist = env->addButton(rect<s32>(10 * xScale, 30 * yScale, 120 * xScale, 70 * yScale), wHostPrepare, BUTTON_HP_DUELIST, dataManager.GetSysString(1251));
ChangeToIGUIImageButton(btnHostPrepDuelist, imageManager.tButton_S, imageManager.tButton_S_pressed); ChangeToIGUIImageButton(btnHostPrepDuelist, imageManager.tButton_S, imageManager.tButton_S_pressed);
for(int i = 0; i < 2; ++i) { for(int i = 0; i < 2; ++i) {
stHostPrepDuelist[i] = env->addStaticText(L"", rect<s32>(60 * xScale, (80 + i * 45) * yScale, 260 * xScale, (120 + i * 45) * yScale), true, false, wHostPrepare); stHostPrepDuelist[i] = env->addStaticText(L"", rect<s32>(60 * xScale, (80 + i * 45) * yScale, 260 * xScale, (120 + i * 45) * yScale), true, false, wHostPrepare);
stHostPrepDuelist[i]->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); stHostPrepDuelist[i]->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
btnHostPrepKick[i] = env->addButton(rect<s32>(10 * xScale, (80 + i * 45) * yScale, 50 * xScale, (120 + i * 45) * yScale), wHostPrepare, BUTTON_HP_KICK, L"X"); btnHostPrepKick[i] = env->addButton(rect<s32>(10 * xScale, (80 + i * 45) * yScale, 50 * xScale, (120 + i * 45) * yScale), wHostPrepare, BUTTON_HP_KICK, L"X");
...@@ -363,8 +363,8 @@ bool Game::Initialize(ANDROID_APP app) { ...@@ -363,8 +363,8 @@ bool Game::Initialize(ANDROID_APP app) {
} }
btnHostPrepOB = env->addButton(rect<s32>(10 * xScale, 175 * yScale, 120 * xScale, 215 * yScale), wHostPrepare, BUTTON_HP_OBSERVER, dataManager.GetSysString(1252)); btnHostPrepOB = env->addButton(rect<s32>(10 * xScale, 175 * yScale, 120 * xScale, 215 * yScale), wHostPrepare, BUTTON_HP_OBSERVER, dataManager.GetSysString(1252));
ChangeToIGUIImageButton(btnHostPrepOB, imageManager.tButton_S, imageManager.tButton_S_pressed); ChangeToIGUIImageButton(btnHostPrepOB, imageManager.tButton_S, imageManager.tButton_S_pressed);
myswprintf(dataManager.strBuffer, L"%ls%d", dataManager.GetSysString(1253), 0); myswprintf(strbuf, L"%ls%d", dataManager.GetSysString(1253), 0);
stHostPrepOB = env->addStaticText(dataManager.strBuffer, rect<s32>(320 * xScale, 310 * yScale, 560 * xScale, 350 * yScale), false, false, wHostPrepare); stHostPrepOB = env->addStaticText(strbuf, rect<s32>(320 * xScale, 310 * yScale, 560 * xScale, 350 * yScale), false, false, wHostPrepare);
stHostPrepRule = env->addStaticText(L"", rect<s32>(320 * xScale, 30 * yScale, 560 * xScale, 300 * yScale), false, true, wHostPrepare); stHostPrepRule = env->addStaticText(L"", rect<s32>(320 * xScale, 30 * yScale, 560 * xScale, 300 * yScale), false, true, wHostPrepare);
env->addStaticText(dataManager.GetSysString(1254), rect<s32>(10 * xScale, 320 * yScale, 110 * xScale, 350 * yScale), false, false, wHostPrepare); env->addStaticText(dataManager.GetSysString(1254), rect<s32>(10 * xScale, 320 * yScale, 110 * xScale, 350 * yScale), false, false, wHostPrepare);
cbCategorySelect = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(10 * xScale, 350 * yScale, 110 * xScale, 390 * yScale), wHostPrepare, COMBOBOX_HP_CATEGORY); cbCategorySelect = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(10 * xScale, 350 * yScale, 110 * xScale, 390 * yScale), wHostPrepare, COMBOBOX_HP_CATEGORY);
...@@ -928,7 +928,7 @@ bool Game::Initialize(ANDROID_APP app) { ...@@ -928,7 +928,7 @@ bool Game::Initialize(ANDROID_APP app) {
btnClearFilter = env->addButton(rect<s32>(205 * xScale, (80 + 125 / 6) * yScale, 255 * xScale, (100 + 125 / 6) * yScale), wFilter, BUTTON_CLEAR_FILTER, dataManager.GetSysString(1304)); btnClearFilter = env->addButton(rect<s32>(205 * xScale, (80 + 125 / 6) * yScale, 255 * xScale, (100 + 125 / 6) * yScale), wFilter, BUTTON_CLEAR_FILTER, dataManager.GetSysString(1304));
ChangeToIGUIImageButton(btnClearFilter, imageManager.tButton_S, imageManager.tButton_S_pressed); ChangeToIGUIImageButton(btnClearFilter, imageManager.tButton_S, imageManager.tButton_S_pressed);
} }
wCategories = env->addWindow(rect<s32>(630 * xScale, 60 * yScale, 1000 * xScale, 270 * yScale), false, dataManager.strBuffer); wCategories = env->addWindow(rect<s32>(630 * xScale, 60 * yScale, 1000 * xScale, 270 * yScale), false, L"");
wCategories->getCloseButton()->setVisible(false); wCategories->getCloseButton()->setVisible(false);
wCategories->setDrawTitlebar(false); wCategories->setDrawTitlebar(false);
wCategories->setDraggable(false); wCategories->setDraggable(false);
...@@ -947,7 +947,7 @@ bool Game::Initialize(ANDROID_APP app) { ...@@ -947,7 +947,7 @@ bool Game::Initialize(ANDROID_APP app) {
//LINK MARKER SEARCH //LINK MARKER SEARCH
btnMarksFilter = env->addButton(rect<s32>(60 * xScale, (80 + 125 / 6) * yScale, 190 * xScale, (100 + 125 / 6) * yScale), wFilter, BUTTON_MARKS_FILTER, dataManager.GetSysString(1374)); btnMarksFilter = env->addButton(rect<s32>(60 * xScale, (80 + 125 / 6) * yScale, 190 * xScale, (100 + 125 / 6) * yScale), wFilter, BUTTON_MARKS_FILTER, dataManager.GetSysString(1374));
ChangeToIGUIImageButton(btnMarksFilter, imageManager.tButton_L, imageManager.tButton_L_pressed); ChangeToIGUIImageButton(btnMarksFilter, imageManager.tButton_L, imageManager.tButton_L_pressed);
wLinkMarks = env->addWindow(rect<s32>(600 * xScale, 30 * yScale, 820 * xScale, 250 * yScale), false, dataManager.strBuffer); wLinkMarks = env->addWindow(rect<s32>(600 * xScale, 30 * yScale, 820 * xScale, 250 * yScale), false, L"");
wLinkMarks->getCloseButton()->setVisible(false); wLinkMarks->getCloseButton()->setVisible(false);
wLinkMarks->setDrawTitlebar(false); wLinkMarks->setDrawTitlebar(false);
wLinkMarks->setDraggable(false); wLinkMarks->setDraggable(false);
...@@ -1437,46 +1437,58 @@ void Game::BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 ...@@ -1437,46 +1437,58 @@ void Game::BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32
mProjection[14] = znear * zfar / (znear - zfar); mProjection[14] = znear * zfar / (znear - zfar);
} }
void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text) { void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text) {
SetStaticText(pControl, cWidth, font, text); std::wstring format_text;
if(font->getDimension(dataManager.strBuffer).Height <= cHeight) { format_text = SetStaticText(pControl, cWidth, font, text);
if(font->getDimension(format_text.c_str()).Height <= cHeight) {
scrCardText->setVisible(false); scrCardText->setVisible(false);
if(env->hasFocus(scrCardText)) if(env->hasFocus(scrCardText))
env->removeFocus(scrCardText); env->removeFocus(scrCardText);
return; return;
} }
SetStaticText(pControl, cWidth - int(25 * xScale), font, text); format_text = SetStaticText(pControl, cWidth - int(25 * xScale), font, text);
u32 fontheight = font->getDimension(L"A").Height + font->getKerningHeight(); u32 fontheight = font->getDimension(L"A").Height + font->getKerningHeight();
u32 step = (font->getDimension(dataManager.strBuffer).Height - cHeight) / fontheight + 1; u32 step = (font->getDimension(format_text.c_str()).Height - cHeight) / fontheight + 1;
scrCardText->setVisible(true); scrCardText->setVisible(true);
scrCardText->setMin(0); scrCardText->setMin(0);
scrCardText->setMax(step); scrCardText->setMax(step);
scrCardText->setPos(0); scrCardText->setPos(0);
} }
void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos) { std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos) {
int pbuffer = 0; int pbuffer = 0;
u32 _width = 0, _height = 0; u32 _width = 0, _height = 0;
//dont merge here wchar_t prev = 0;
wchar_t strBuffer[4096];
std::wstring ret;
for(size_t i = 0; text[i] != 0 && i < wcslen(text); ++i) { for(size_t i = 0; text[i] != 0 && i < wcslen(text); ++i) {
u32 w = font->getCharDimension(text[i]).Width; wchar_t c = text[i];
if(text[i] == L'\n') { u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev);
dataManager.strBuffer[pbuffer++] = L'\n'; prev = c;
if(text[i] == L'\r') {
continue;
} else if(text[i] == L'\n') {
strBuffer[pbuffer++] = L'\n';
_width = 0; _width = 0;
_height++; _height++;
prev = 0;
if(_height == pos) if(_height == pos)
pbuffer = 0; pbuffer = 0;
continue; continue;
} else if(_width > 0 && _width + w > cWidth) { } else if(_width > 0 && _width + w > cWidth) {
dataManager.strBuffer[pbuffer++] = L'\n'; strBuffer[pbuffer++] = L'\n';
_width = 0; _width = 0;
_height++; _height++;
prev = 0;
if(_height == pos) if(_height == pos)
pbuffer = 0; pbuffer = 0;
} }
_width += w; _width += w;
dataManager.strBuffer[pbuffer++] = text[i]; strBuffer[pbuffer++] = c;
} }
dataManager.strBuffer[pbuffer] = 0; strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer); pControl->setText(strBuffer);
ret.assign(strBuffer);
return ret;
} }
void Game::LoadExpansions() { void Game::LoadExpansions() {
// TODO: get isUseExtraCards // TODO: get isUseExtraCards
......
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
void RefreshTimeDisplay(); void RefreshTimeDisplay();
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar); void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text); void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text);
void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0); std::wstring SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0);
void LoadExpansions(); void LoadExpansions();
void RefreshCategoryDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck, bool selectlastused = true); void RefreshCategoryDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck, bool selectlastused = true);
void RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck); void RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
...@@ -817,6 +817,7 @@ private: ...@@ -817,6 +817,7 @@ private:
#define BUTTON_CARD_DISP_OK 296 #define BUTTON_CARD_DISP_OK 296
#define BUTTON_SURRENDER_YES 297 #define BUTTON_SURRENDER_YES 297
#define BUTTON_SURRENDER_NO 298 #define BUTTON_SURRENDER_NO 298
#define BUTTON_MANAGE_DECK 300 #define BUTTON_MANAGE_DECK 300
#define COMBOBOX_DBCATEGORY 301 #define COMBOBOX_DBCATEGORY 301
#define COMBOBOX_DBDECKS 302 #define COMBOBOX_DBDECKS 302
...@@ -843,7 +844,6 @@ private: ...@@ -843,7 +844,6 @@ private:
#define BUTTON_MARKERS_OK 323 #define BUTTON_MARKERS_OK 323
#define COMBOBOX_SORTTYPE 324 #define COMBOBOX_SORTTYPE 324
#define EDITBOX_INPUTS 325 #define EDITBOX_INPUTS 325
#define WINDOW_DECK_MANAGE 330 #define WINDOW_DECK_MANAGE 330
#define BUTTON_NEW_CATEGORY 331 #define BUTTON_NEW_CATEGORY 331
#define BUTTON_RENAME_CATEGORY 332 #define BUTTON_RENAME_CATEGORY 332
...@@ -859,6 +859,7 @@ private: ...@@ -859,6 +859,7 @@ private:
#define BUTTON_DM_CANCEL 342 #define BUTTON_DM_CANCEL 342
#define BUTTON_CLOSE_DECKMANAGER 343 #define BUTTON_CLOSE_DECKMANAGER 343
#define COMBOBOX_LFLIST 349 #define COMBOBOX_LFLIST 349
#define BUTTON_CLEAR_LOG 350 #define BUTTON_CLEAR_LOG 350
#define LISTBOX_LOG 351 #define LISTBOX_LOG 351
#define SCROLL_CARDTEXT 352 #define SCROLL_CARDTEXT 352
......
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