Commit 79f2a865 authored by mercury233's avatar mercury233

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

parents 1c052837 2cedcbb9
...@@ -15,6 +15,7 @@ ClientField::ClientField() { ...@@ -15,6 +15,7 @@ ClientField::ClientField() {
hovered_card = 0; hovered_card = 0;
clicked_card = 0; clicked_card = 0;
highlighting_card = 0; highlighting_card = 0;
menu_card = 0;
hovered_controler = 0; hovered_controler = 0;
hovered_location = 0; hovered_location = 0;
hovered_sequence = 0; hovered_sequence = 0;
...@@ -83,6 +84,7 @@ void ClientField::Clear() { ...@@ -83,6 +84,7 @@ void ClientField::Clear() {
hovered_card = 0; hovered_card = 0;
clicked_card = 0; clicked_card = 0;
highlighting_card = 0; highlighting_card = 0;
menu_card = 0;
hovered_controler = 0; hovered_controler = 0;
hovered_location = 0; hovered_location = 0;
hovered_sequence = 0; hovered_sequence = 0;
......
...@@ -42,6 +42,7 @@ public: ...@@ -42,6 +42,7 @@ public:
std::vector<ClientCard*> conti_cards; std::vector<ClientCard*> conti_cards;
std::vector<std::pair<int,int>> activatable_descs; std::vector<std::pair<int,int>> activatable_descs;
std::vector<int> select_options; std::vector<int> select_options;
std::vector<int> select_options_index;
std::vector<ChainInfo> chains; std::vector<ChainInfo> chains;
int extra_p_count[2]; int extra_p_count[2];
...@@ -131,6 +132,7 @@ public: ...@@ -131,6 +132,7 @@ public:
ClientCard* clicked_card; ClientCard* clicked_card;
ClientCard* command_card; ClientCard* command_card;
ClientCard* highlighting_card; ClientCard* highlighting_card;
ClientCard* menu_card;
int list_command; int list_command;
virtual bool OnEvent(const irr::SEvent& event); virtual bool OnEvent(const irr::SEvent& event);
......
...@@ -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);
...@@ -118,6 +118,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) { ...@@ -118,6 +118,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);
...@@ -138,6 +139,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) { ...@@ -138,6 +139,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
} }
} }
bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) { bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) {
wchar_t strBuffer[4096];
BufferIO::DecodeUTF8(sqlite3_errmsg(pDB->handle), strBuffer); BufferIO::DecodeUTF8(sqlite3_errmsg(pDB->handle), strBuffer);
if(pStmt) if(pStmt)
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
......
...@@ -51,7 +51,6 @@ public: ...@@ -51,7 +51,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*);
......
...@@ -88,9 +88,7 @@ void DeckBuilder::Initialize() { ...@@ -88,9 +88,7 @@ void DeckBuilder::Initialize() {
is_starting_dragging = false; is_starting_dragging = false;
prev_deck = mainGame->cbDBDecks->getSelected(); prev_deck = mainGame->cbDBDecks->getSelected();
prev_category = mainGame->cbDBCategory->getSelected(); prev_category = mainGame->cbDBCategory->getSelected();
readonly = prev_category < 2; RefreshReadonly(prev_category);
mainGame->btnSaveDeck->setEnabled(!readonly);
mainGame->btnDeleteDeck->setEnabled(!readonly);
prev_operation = 0; prev_operation = 0;
prev_sel = -1; prev_sel = -1;
is_modified = false; is_modified = false;
......
...@@ -306,11 +306,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -306,11 +306,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
int step = mainGame->scrOption->isVisible() ? mainGame->scrOption->getPos() : 0; int step = mainGame->scrOption->isVisible() ? mainGame->scrOption->getPos() : 0;
selected_option = id - BUTTON_OPTION_0 + step; selected_option = id - BUTTON_OPTION_0 + step;
SetResponseSelectedOption(); SetResponseSelectedOption();
ShowCancelOrFinishButton(0);
break; break;
} }
case BUTTON_OPTION_OK: { case BUTTON_OPTION_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON); soundManager.PlaySoundEffect(SOUND_BUTTON);
SetResponseSelectedOption(); SetResponseSelectedOption();
ShowCancelOrFinishButton(0);
break; break;
} }
case BUTTON_ANNUMBER_1: case BUTTON_ANNUMBER_1:
...@@ -364,22 +366,25 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -364,22 +366,25 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
ShowCancelOrFinishButton(0); ShowCancelOrFinishButton(0);
if(!list_command) { if(!list_command) {
int index = -1; if(!menu_card)
break;
select_options.clear(); select_options.clear();
select_options_index.clear();
for (size_t i = 0; i < activatable_cards.size(); ++i) { for (size_t i = 0; i < activatable_cards.size(); ++i) {
if (activatable_cards[i] == clicked_card) { if (activatable_cards[i] == menu_card) {
if(activatable_descs[i].second == EDESC_OPERATION) if(activatable_descs[i].second == EDESC_OPERATION)
continue; continue;
if(activatable_descs[i].second == EDESC_RESET) { else if(activatable_descs[i].second == EDESC_RESET) {
if(id == BUTTON_CMD_ACTIVATE) continue; if(id == BUTTON_CMD_ACTIVATE) continue;
} else { } else {
if(id == BUTTON_CMD_RESET) continue; if(id == BUTTON_CMD_RESET) continue;
} }
select_options.push_back(activatable_descs[i].first); select_options.push_back(activatable_descs[i].first);
if (index == -1) index = i; select_options_index.push_back(i);
} }
} }
if (select_options.size() == 1) { if (select_options.size() == 1) {
int index = select_options_index[0];
if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5); DuelClient::SetResponseI((index << 16) + 5);
} else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { } else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
...@@ -389,8 +394,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -389,8 +394,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
DuelClient::SendResponse(); DuelClient::SendResponse();
} else { } else {
command_card = clicked_card; command_card = menu_card;
ShowSelectOption(); ShowSelectOption();
select_ready = false;
ShowCancelOrFinishButton(1);
} }
} else { } else {
selectable_cards.clear(); selectable_cards.clear();
...@@ -443,10 +450,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -443,10 +450,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_CMD_SUMMON: { case BUTTON_CMD_SUMMON: {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(!clicked_card) if(!menu_card)
break; break;
for(size_t i = 0; i < summonable_cards.size(); ++i) { for(size_t i = 0; i < summonable_cards.size(); ++i) {
if(summonable_cards[i] == clicked_card) { if(summonable_cards[i] == menu_card) {
ClearCommandFlag(); ClearCommandFlag();
DuelClient::SetResponseI(i << 16); DuelClient::SetResponseI(i << 16);
DuelClient::SendResponse(); DuelClient::SendResponse();
...@@ -458,10 +465,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -458,10 +465,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_CMD_SPSUMMON: { case BUTTON_CMD_SPSUMMON: {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(!list_command) { if(!list_command) {
if(!clicked_card) if(!menu_card)
break; break;
for(size_t i = 0; i < spsummonable_cards.size(); ++i) { for(size_t i = 0; i < spsummonable_cards.size(); ++i) {
if(spsummonable_cards[i] == clicked_card) { if(spsummonable_cards[i] == menu_card) {
ClearCommandFlag(); ClearCommandFlag();
DuelClient::SetResponseI((i << 16) + 1); DuelClient::SetResponseI((i << 16) + 1);
DuelClient::SendResponse(); DuelClient::SendResponse();
...@@ -500,10 +507,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -500,10 +507,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_CMD_MSET: { case BUTTON_CMD_MSET: {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(!clicked_card) if(!menu_card)
break; break;
for(size_t i = 0; i < msetable_cards.size(); ++i) { for(size_t i = 0; i < msetable_cards.size(); ++i) {
if(msetable_cards[i] == clicked_card) { if(msetable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 3); DuelClient::SetResponseI((i << 16) + 3);
DuelClient::SendResponse(); DuelClient::SendResponse();
break; break;
...@@ -513,10 +520,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -513,10 +520,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_CMD_SSET: { case BUTTON_CMD_SSET: {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(!clicked_card) if(!menu_card)
break; break;
for(size_t i = 0; i < ssetable_cards.size(); ++i) { for(size_t i = 0; i < ssetable_cards.size(); ++i) {
if(ssetable_cards[i] == clicked_card) { if(ssetable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 4); DuelClient::SetResponseI((i << 16) + 4);
DuelClient::SendResponse(); DuelClient::SendResponse();
break; break;
...@@ -526,10 +533,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -526,10 +533,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_CMD_REPOS: { case BUTTON_CMD_REPOS: {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(!clicked_card) if(!menu_card)
break; break;
for(size_t i = 0; i < reposable_cards.size(); ++i) { for(size_t i = 0; i < reposable_cards.size(); ++i) {
if(reposable_cards[i] == clicked_card) { if(reposable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 2); DuelClient::SetResponseI((i << 16) + 2);
DuelClient::SendResponse(); DuelClient::SendResponse();
break; break;
...@@ -539,10 +546,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -539,10 +546,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_CMD_ATTACK: { case BUTTON_CMD_ATTACK: {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(!clicked_card) if(!menu_card)
break; break;
for(size_t i = 0; i < attackable_cards.size(); ++i) { for(size_t i = 0; i < attackable_cards.size(); ++i) {
if(attackable_cards[i] == clicked_card) { if(attackable_cards[i] == menu_card) {
DuelClient::SetResponseI((i << 16) + 1); DuelClient::SetResponseI((i << 16) + 1);
DuelClient::SendResponse(); DuelClient::SendResponse();
break; break;
...@@ -648,9 +655,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -648,9 +655,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
if(list_command == COMMAND_ACTIVATE || list_command == COMMAND_OPERATION) { if(list_command == COMMAND_ACTIVATE || list_command == COMMAND_OPERATION) {
int index = -1;
command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10]; command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10];
select_options.clear(); select_options.clear();
select_options_index.clear();
for (size_t i = 0; i < activatable_cards.size(); ++i) { for (size_t i = 0; i < activatable_cards.size(); ++i) {
if (activatable_cards[i] == command_card) { if (activatable_cards[i] == command_card) {
if(activatable_descs[i].second == EDESC_OPERATION) { if(activatable_descs[i].second == EDESC_OPERATION) {
...@@ -659,10 +666,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -659,10 +666,11 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(list_command == COMMAND_OPERATION) continue; if(list_command == COMMAND_OPERATION) continue;
} }
select_options.push_back(activatable_descs[i].first); select_options.push_back(activatable_descs[i].first);
if (index == -1) index = i; select_options_index.push_back(i);
} }
} }
if (select_options.size() == 1) { if (select_options.size() == 1) {
int index = select_options_index[0];
if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5); DuelClient::SetResponseI((index << 16) + 5);
} else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { } else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
...@@ -1554,7 +1562,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1554,7 +1562,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
SetShowMark(hovered_card, false); SetShowMark(hovered_card, false);
} }
if(mcard) { if(mcard) {
if(mcard != clicked_card) if(mcard != menu_card)
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(hovered_location == LOCATION_HAND) { if(hovered_location == LOCATION_HAND) {
mcard->is_hovered = true; mcard->is_hovered = true;
...@@ -2243,6 +2251,7 @@ void ClientField::ShowMenu(int flag, int x, int y) { ...@@ -2243,6 +2251,7 @@ void ClientField::ShowMenu(int flag, int x, int y) {
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
return; return;
} }
menu_card = clicked_card;
int height = 1; int height = 1;
int offset = mainGame->gameConf.resize_popup_menu ? ((mainGame->yScale >= 0.666) ? 21 * mainGame->yScale : 14) : 21; int offset = mainGame->gameConf.resize_popup_menu ? ((mainGame->yScale >= 0.666) ? 21 * mainGame->yScale : 14) : 21;
if(flag & COMMAND_ACTIVATE) { if(flag & COMMAND_ACTIVATE) {
...@@ -2412,8 +2421,7 @@ void ClientField::SetResponseSelectedOption() const { ...@@ -2412,8 +2421,7 @@ void ClientField::SetResponseSelectedOption() const {
if(mainGame->dInfo.curMsg == MSG_SELECT_OPTION) { if(mainGame->dInfo.curMsg == MSG_SELECT_OPTION) {
DuelClient::SetResponseI(selected_option); DuelClient::SetResponseI(selected_option);
} else { } else {
int index = 0; int index = select_options_index[selected_option];
while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++;
if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5); DuelClient::SetResponseI((index << 16) + 5);
} else if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { } else if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
......
...@@ -254,8 +254,8 @@ bool Game::Initialize() { ...@@ -254,8 +254,8 @@ bool Game::Initialize() {
chkHostPrepReady[i]->setEnabled(false); chkHostPrepReady[i]->setEnabled(false);
} }
btnHostPrepOB = env->addButton(rect<s32>(10, 180, 110, 205), wHostPrepare, BUTTON_HP_OBSERVER, dataManager.GetSysString(1252)); 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); myswprintf(strbuf, L"%ls%d", dataManager.GetSysString(1253), 0);
stHostPrepOB = env->addStaticText(dataManager.strBuffer, rect<s32>(10, 285, 270, 305), false, false, wHostPrepare); 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); 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); 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); cbCategorySelect = env->addComboBox(rect<s32>(10, 230, 138, 255), wHostPrepare, COMBOBOX_HP_CATEGORY);
...@@ -709,7 +709,7 @@ bool Game::Initialize() { ...@@ -709,7 +709,7 @@ bool Game::Initialize() {
btnStartFilter->setRelativePosition(rect<s32>(260, 80 + 125 / 6, 390, 100 + 125 / 6)); 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)); 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->getCloseButton()->setVisible(false);
wCategories->setDrawTitlebar(false); wCategories->setDrawTitlebar(false);
wCategories->setDraggable(false); wCategories->setDraggable(false);
...@@ -727,7 +727,7 @@ bool Game::Initialize() { ...@@ -727,7 +727,7 @@ bool Game::Initialize() {
wCategories->setRelativePosition(rect<s32>(1000 - wcatewidth, 60, 1000, 305)); wCategories->setRelativePosition(rect<s32>(1000 - wcatewidth, 60, 1000, 305));
btnCategoryOK->setRelativePosition(recti(wcatewidth / 2 - 50, 210, wcatewidth / 2 + 50, 235)); 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)); 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->getCloseButton()->setVisible(false);
wLinkMarks->setDrawTitlebar(false); wLinkMarks->setDrawTitlebar(false);
wLinkMarks->setDraggable(false); wLinkMarks->setDraggable(false);
...@@ -1013,25 +1013,29 @@ void Game::BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 ...@@ -1013,25 +1013,29 @@ 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-25, font, text); format_text = SetStaticText(pControl, cWidth-25, 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;
wchar_t prev = 0; 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) {
wchar_t c = text[i]; wchar_t c = text[i];
u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev); u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev);
...@@ -1039,7 +1043,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -1039,7 +1043,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
if(text[i] == L'\r') { if(text[i] == L'\r') {
continue; continue;
} else if(text[i] == L'\n') { } else if(text[i] == L'\n') {
dataManager.strBuffer[pbuffer++] = L'\n'; strBuffer[pbuffer++] = L'\n';
_width = 0; _width = 0;
_height++; _height++;
prev = 0; prev = 0;
...@@ -1047,7 +1051,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -1047,7 +1051,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
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; prev = 0;
...@@ -1055,10 +1059,12 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -1055,10 +1059,12 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
pbuffer = 0; pbuffer = 0;
} }
_width += w; _width += w;
dataManager.strBuffer[pbuffer++] = c; 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() {
FileSystem::TraversalDir(L"./expansions", [](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(L"./expansions", [](const wchar_t* name, bool isdir) {
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
void MainLoop(); void MainLoop();
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);
......
...@@ -188,7 +188,6 @@ ...@@ -188,7 +188,6 @@
!2021.1 !2021.1
#forbidden #forbidden
62472614 0 --疫病(tmp)
91869203 0 --アマゾネスの射手 91869203 0 --アマゾネスの射手
20663556 0 --イレカエル 20663556 0 --イレカエル
44910027 0 --ヴィクトリー・ドラゴン 44910027 0 --ヴィクトリー・ドラゴン
......
...@@ -627,6 +627,8 @@ ...@@ -627,6 +627,8 @@
!counter 0x59 落魂指示物 !counter 0x59 落魂指示物
!counter 0x5a 指示物(岩战之试炼) !counter 0x5a 指示物(岩战之试炼)
!counter 0x5b 指示物(北极天熊北斗星) !counter 0x5b 指示物(北极天熊北斗星)
!counter 0x105c 燃烧指示物
!counter 0x5d 指示物(机巧传-神使记纪图)
#setnames, using tab for comment #setnames, using tab for comment
!setname 0x1 正义盟军 AOJ !setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス !setname 0x2 次世代 ジェネクス
...@@ -1090,3 +1092,8 @@ ...@@ -1090,3 +1092,8 @@
!setname 0x161 溟界 !setname 0x161 溟界
!setname 0x162 七音服 ドレミコード !setname 0x162 七音服 ドレミコード
!setname 0x163 北极天熊 ベアルクティ !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