Commit 117aa906 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro into server

parents da47f8a6 03bd9b95
......@@ -42,6 +42,7 @@ public:
std::vector<ClientCard*> conti_cards;
std::vector<std::pair<int,int>> activatable_descs;
std::vector<int> select_options;
std::vector<int> select_options_index;
std::vector<ChainInfo> chains;
int extra_p_count[2];
......
......@@ -5,7 +5,6 @@
namespace ygo {
const wchar_t* DataManager::unknown_string = L"???";
wchar_t DataManager::strBuffer[4096];
byte DataManager::scriptBuffer[0x20000];
#ifndef YGOPRO_SERVER_MODE
IFileSystem* DataManager::FileSystem;
......@@ -14,6 +13,7 @@ DataManager dataManager;
bool DataManager::LoadDB(const wchar_t* wfile) {
char file[256];
wchar_t strBuffer[4096];
BufferIO::EncodeUTF8(wfile, file);
#ifdef YGOPRO_SERVER_MODE
sqlite3* pDB;
......@@ -146,6 +146,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);
......@@ -175,6 +176,7 @@ bool DataManager::Error(sqlite3* pDB, sqlite3_stmt* pStmt) {
}
#else
bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) {
wchar_t strBuffer[4096];
BufferIO::DecodeUTF8(sqlite3_errmsg(pDB->handle), strBuffer);
if(pStmt)
sqlite3_finalize(pStmt);
......
......@@ -58,7 +58,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*);
......
......@@ -88,9 +88,7 @@ void DeckBuilder::Initialize() {
is_starting_dragging = false;
prev_deck = mainGame->cbDBDecks->getSelected();
prev_category = mainGame->cbDBCategory->getSelected();
readonly = prev_category < 2;
mainGame->btnSaveDeck->setEnabled(!readonly);
mainGame->btnDeleteDeck->setEnabled(!readonly);
RefreshReadonly(prev_category);
prev_operation = 0;
prev_sel = -1;
is_modified = false;
......
......@@ -364,22 +364,23 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->wCmdMenu->setVisible(false);
ShowCancelOrFinishButton(0);
if(!list_command) {
int index = -1;
select_options.clear();
select_options_index.clear();
for (size_t i = 0; i < activatable_cards.size(); ++i) {
if (activatable_cards[i] == clicked_card) {
if(activatable_descs[i].second == EDESC_OPERATION)
continue;
if(activatable_descs[i].second == EDESC_RESET) {
else if(activatable_descs[i].second == EDESC_RESET) {
if(id == BUTTON_CMD_ACTIVATE) continue;
} else {
if(id == BUTTON_CMD_RESET) continue;
}
select_options.push_back(activatable_descs[i].first);
if (index == -1) index = i;
select_options_index.push_back(i);
}
}
if (select_options.size() == 1) {
int index = select_options_index[0];
if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5);
} else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
......@@ -648,9 +649,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
if(list_command == COMMAND_ACTIVATE || list_command == COMMAND_OPERATION) {
int index = -1;
command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10];
select_options.clear();
select_options_index.clear();
for (size_t i = 0; i < activatable_cards.size(); ++i) {
if (activatable_cards[i] == command_card) {
if(activatable_descs[i].second == EDESC_OPERATION) {
......@@ -659,10 +660,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(list_command == COMMAND_OPERATION) continue;
}
select_options.push_back(activatable_descs[i].first);
if (index == -1) index = i;
select_options_index.push_back(i);
}
}
if (select_options.size() == 1) {
int index = select_options_index[0];
if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5);
} else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
......@@ -2412,8 +2414,7 @@ void ClientField::SetResponseSelectedOption() const {
if(mainGame->dInfo.curMsg == MSG_SELECT_OPTION) {
DuelClient::SetResponseI(selected_option);
} else {
int index = 0;
while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++;
int index = select_options_index[selected_option];
if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5);
} else if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
......
......@@ -281,8 +281,8 @@ bool Game::Initialize() {
chkHostPrepReady[i]->setEnabled(false);
}
btnHostPrepOB = env->addButton(rect<s32>(10, 180, 110, 205), wHostPrepare, BUTTON_HP_OBSERVER, dataManager.GetSysString(1252));
myswprintf(dataManager.strBuffer, L"%ls%d", dataManager.GetSysString(1253), 0);
stHostPrepOB = env->addStaticText(dataManager.strBuffer, rect<s32>(10, 285, 270, 305), false, false, wHostPrepare);
myswprintf(strbuf, L"%ls%d", dataManager.GetSysString(1253), 0);
stHostPrepOB = env->addStaticText(strbuf, rect<s32>(10, 285, 270, 305), false, false, wHostPrepare);
stHostPrepRule = env->addStaticText(L"", rect<s32>(280, 30, 460, 230), false, true, wHostPrepare);
env->addStaticText(dataManager.GetSysString(1254), rect<s32>(10, 210, 110, 230), false, false, wHostPrepare);
cbCategorySelect = env->addComboBox(rect<s32>(10, 230, 138, 255), wHostPrepare, COMBOBOX_HP_CATEGORY);
......@@ -736,7 +736,7 @@ bool Game::Initialize() {
btnStartFilter->setRelativePosition(rect<s32>(260, 80 + 125 / 6, 390, 100 + 125 / 6));
btnClearFilter = env->addButton(rect<s32>(205, 80 + 125 / 6, 255, 100 + 125 / 6), wFilter, BUTTON_CLEAR_FILTER, dataManager.GetSysString(1304));
}
wCategories = env->addWindow(rect<s32>(600, 60, 1000, 305), false, dataManager.strBuffer);
wCategories = env->addWindow(rect<s32>(600, 60, 1000, 305), false, L"");
wCategories->getCloseButton()->setVisible(false);
wCategories->setDrawTitlebar(false);
wCategories->setDraggable(false);
......@@ -754,7 +754,7 @@ bool Game::Initialize() {
wCategories->setRelativePosition(rect<s32>(1000 - wcatewidth, 60, 1000, 305));
btnCategoryOK->setRelativePosition(recti(wcatewidth / 2 - 50, 210, wcatewidth / 2 + 50, 235));
btnMarksFilter = env->addButton(rect<s32>(60, 80 + 125 / 6, 190, 100 + 125 / 6), wFilter, BUTTON_MARKS_FILTER, dataManager.GetSysString(1374));
wLinkMarks = env->addWindow(rect<s32>(700, 30, 820, 150), false, dataManager.strBuffer);
wLinkMarks = env->addWindow(rect<s32>(700, 30, 820, 150), false, L"");
wLinkMarks->getCloseButton()->setVisible(false);
wLinkMarks->setDrawTitlebar(false);
wLinkMarks->setDraggable(false);
......@@ -1040,25 +1040,29 @@ 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-25, font, text);
format_text = SetStaticText(pControl, cWidth-25, 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;
wchar_t prev = 0;
wchar_t strBuffer[4096];
std::wstring ret;
for(size_t i = 0; text[i] != 0 && i < wcslen(text); ++i) {
wchar_t c = text[i];
u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev);
......@@ -1066,7 +1070,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
if(text[i] == L'\r') {
continue;
} else if(text[i] == L'\n') {
dataManager.strBuffer[pbuffer++] = L'\n';
strBuffer[pbuffer++] = L'\n';
_width = 0;
_height++;
prev = 0;
......@@ -1074,7 +1078,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
pbuffer = 0;
continue;
} else if(_width > 0 && _width + w > cWidth) {
dataManager.strBuffer[pbuffer++] = L'\n';
strBuffer[pbuffer++] = L'\n';
_width = 0;
_height++;
prev = 0;
......@@ -1082,10 +1086,12 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
pbuffer = 0;
}
_width += w;
dataManager.strBuffer[pbuffer++] = c;
strBuffer[pbuffer++] = c;
}
dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer);
strBuffer[pbuffer] = 0;
pControl->setText(strBuffer);
ret.assign(strBuffer);
return ret;
}
#endif //YGOPRO_SERVER_MODE
void Game::LoadExpansions() {
......
......@@ -132,7 +132,7 @@ public:
void MainLoop();
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);
......
......@@ -188,7 +188,6 @@
!2021.1
#forbidden
62472614 0 --疫病(tmp)
91869203 0 --アマゾネスの射手
20663556 0 --イレカエル
44910027 0 --ヴィクトリー・ドラゴン
......
......@@ -627,6 +627,8 @@
!counter 0x59 落魂指示物
!counter 0x5a 指示物(岩战之试炼)
!counter 0x5b 指示物(北极天熊北斗星)
!counter 0x105c 燃烧指示物
!counter 0x5d 指示物(机巧传-神使记纪图)
#setnames, using tab for comment
!setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス
......@@ -1090,3 +1092,8 @@
!setname 0x161 溟界
!setname 0x162 七音服 ドレミコード
!setname 0x163 北极天熊 ベアルクティ
!setname 0x164 死狱乡 デスピア
!setname 0x165 魔键 魔鍵
!setname 0x166 军贯 軍貫
!setname 0x1167 森之圣兽 森の聖獣
!setname 0x2167 森之圣灵 森の聖霊
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