Commit 29775a52 authored by fallenstardust's avatar fallenstardust

remove dataManager::strBuffer[]

parent cec921fb
......@@ -5,13 +5,13 @@
namespace ygo {
const wchar_t* DataManager::unknown_string = L"???";
wchar_t DataManager::strBuffer[4096];
byte DataManager::scriptBuffer[0x20000];
IFileSystem* DataManager::FileSystem;
DataManager dataManager;
bool DataManager::LoadDB(const wchar_t* wfile) {
char file[256];
wchar_t strBuffer[4096];
BufferIO::EncodeUTF8(wfile, file);
#ifdef _WIN32
IReadFile* reader = FileSystem->createAndOpenFile(wfile);
......@@ -123,6 +123,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
return;
char strbuf[256];
int value;
wchar_t strBuffer[4096];
sscanf(linebuf, "!%s", strbuf);
if(!strcmp(strbuf, "system")) {
sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf);
......@@ -143,6 +144,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
}
}
bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt, int errNo) {
wchar_t strBuffer[4096];
const char* msg = sqlite3_errmsg(pDB->handle);
BufferIO::DecodeUTF8(msg, strBuffer);
if(pStmt)
......
......@@ -55,7 +55,6 @@ public:
wchar_t scBuffer[128];
wchar_t lmBuffer[32];
static wchar_t strBuffer[4096];
static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string;
static int CardReader(int, void*);
......
......@@ -345,7 +345,7 @@ bool Game::Initialize(ANDROID_APP app) {
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));
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]->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");
......@@ -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));
ChangeToIGUIImageButton(btnHostPrepOB, imageManager.tButton_S, imageManager.tButton_S_pressed);
myswprintf(dataManager.strBuffer, 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);
myswprintf(strbuf, L"%ls%d", dataManager.GetSysString(1253), 0);
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);
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);
......@@ -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));
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->setDrawTitlebar(false);
wCategories->setDraggable(false);
......@@ -947,7 +947,7 @@ bool Game::Initialize(ANDROID_APP app) {
//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));
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->setDrawTitlebar(false);
wLinkMarks->setDraggable(false);
......@@ -1437,46 +1437,58 @@ void Game::BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32
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) {
SetStaticText(pControl, cWidth, font, text);
if(font->getDimension(dataManager.strBuffer).Height <= cHeight) {
std::wstring format_text;
format_text = SetStaticText(pControl, cWidth, font, text);
if(font->getDimension(format_text.c_str()).Height <= cHeight) {
scrCardText->setVisible(false);
if(env->hasFocus(scrCardText))
env->removeFocus(scrCardText);
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 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->setMin(0);
scrCardText->setMax(step);
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;
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) {
u32 w = font->getCharDimension(text[i]).Width;
if(text[i] == L'\n') {
dataManager.strBuffer[pbuffer++] = L'\n';
wchar_t c = text[i];
u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev);
prev = c;
if(text[i] == L'\r') {
continue;
} else if(text[i] == L'\n') {
strBuffer[pbuffer++] = L'\n';
_width = 0;
_height++;
prev = 0;
if(_height == pos)
pbuffer = 0;
continue;
} else if(_width > 0 && _width + w > cWidth) {
dataManager.strBuffer[pbuffer++] = L'\n';
strBuffer[pbuffer++] = L'\n';
_width = 0;
_height++;
prev = 0;
if(_height == pos)
pbuffer = 0;
}
_width += w;
dataManager.strBuffer[pbuffer++] = text[i];
strBuffer[pbuffer++] = c;
}
dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer);
strBuffer[pbuffer] = 0;
pControl->setText(strBuffer);
ret.assign(strBuffer);
return ret;
}
void Game::LoadExpansions() {
// TODO: get isUseExtraCards
......
......@@ -129,7 +129,7 @@ public:
void RefreshTimeDisplay();
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 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 RefreshCategoryDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck, bool selectlastused = true);
void RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
......@@ -817,6 +817,7 @@ private:
#define BUTTON_CARD_DISP_OK 296
#define BUTTON_SURRENDER_YES 297
#define BUTTON_SURRENDER_NO 298
#define BUTTON_MANAGE_DECK 300
#define COMBOBOX_DBCATEGORY 301
#define COMBOBOX_DBDECKS 302
......@@ -843,7 +844,6 @@ private:
#define BUTTON_MARKERS_OK 323
#define COMBOBOX_SORTTYPE 324
#define EDITBOX_INPUTS 325
#define WINDOW_DECK_MANAGE 330
#define BUTTON_NEW_CATEGORY 331
#define BUTTON_RENAME_CATEGORY 332
......@@ -859,6 +859,7 @@ private:
#define BUTTON_DM_CANCEL 342
#define BUTTON_CLOSE_DECKMANAGER 343
#define COMBOBOX_LFLIST 349
#define BUTTON_CLEAR_LOG 350
#define LISTBOX_LOG 351
#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