Commit a13c7eb7 authored by edo9300's avatar edo9300

Re-added ShowCancelOrFinishButton, various fixes

parent 6afd27b1
......@@ -1138,6 +1138,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
if(CheckSelectSum()) {
if(selectsum_cards.size() == 0 || selectable_cards.size() == 0) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else {
......@@ -1163,6 +1164,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
if(CheckSelectSum()) {
if(selectsum_cards.size() == 0 || selectable_cards.size() == 0) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
DuelClient::SendResponse();
return true;
} else {
......@@ -1177,6 +1179,12 @@ bool ClientField::ShowSelectSum(bool panelmode) {
} else
select_ready = false;
}
if (select_ready) {
ShowCancelOrFinishButton(1);
}
else {
ShowCancelOrFinishButton(0);
}
return false;
}
bool ClientField::CheckSelectSum() {
......
......@@ -131,6 +131,7 @@ public:
void GetHoverField(int x, int y);
void ShowMenu(int flag, int x, int y);
void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp);
void SetResponseSelectedCards() const;
};
......
......@@ -815,9 +815,9 @@ void Game::DrawSpec() {
continue;
int w = textFont->getDimension(chatMsg[i].c_str()).Width;
recti rectloc(305, mainGame->window_size.Height - 45, 307 + w, mainGame->window_size.Height - 25);
recti rectloc(mainGame->wChat->getRelativePosition().UpperLeftCorner.X, mainGame->window_size.Height - 45, mainGame->wChat->getRelativePosition().UpperLeftCorner.X + 2 + w, mainGame->window_size.Height - 25);
rectloc -= position2di(0, i * 20);
recti msgloc(305, mainGame->window_size.Height - 45, mainGame->window_size.Width - 4, mainGame->window_size.Height - 25);
recti msgloc(mainGame->wChat->getRelativePosition().UpperLeftCorner.X, mainGame->window_size.Height - 45, mainGame->wChat->getRelativePosition().UpperLeftCorner.X - 4, mainGame->window_size.Height - 25);
msgloc -= position2di(0, i * 20);
recti shadowloc = msgloc + position2di(1, 1);
......
......@@ -310,6 +310,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear();
......@@ -607,6 +608,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
......@@ -637,6 +639,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
char timebuf[40];
......@@ -1283,6 +1286,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
}
if (mainGame->dField.select_cancelable) {
mainGame->dField.ShowCancelOrFinishButton(1);
} else {
mainGame->dField.ShowCancelOrFinishButton(0);
}
return false;
}
case MSG_SELECT_CHAIN: {
......@@ -1537,6 +1545,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
if (mainGame->dField.select_cancelable) {
mainGame->dField.ShowCancelOrFinishButton(1);
}
mainGame->gMutex.Unlock();
return false;
}
......@@ -1980,6 +1991,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
}
}
if(mainGame->dInfo.isTag && mainGame->dInfo.turn != 1) {
......
This diff is collapsed.
......@@ -286,9 +286,9 @@ bool Game::Initialize() {
chkIgnore1->setChecked(gameConf.chkIgnore1 != 0);
chkIgnore2 = env->addCheckBox(false, rect<s32>(20, 200, 280, 225), tabSystem, -1, dataManager.GetSysString(1291));
chkIgnore2->setChecked(gameConf.chkIgnore2 != 0);
chkEnableSound = env->addCheckBox(gameConf.enablesound, rect<s32>(20, 230, 280, 255), tabSystem, -1, dataManager.GetSysString(1295));
chkEnableSound = env->addCheckBox(gameConf.enablesound, rect<s32>(20, 230, 280, 255), tabSystem, -1, dataManager.GetSysString(2046));
chkEnableSound->setChecked(gameConf.enablesound);
chkEnableMusic = env->addCheckBox(gameConf.enablemusic, rect<s32>(20, 260, 280, 285), tabSystem, CHECKBOX_ENABLE_MUSIC, dataManager.GetSysString(1296));
chkEnableMusic = env->addCheckBox(gameConf.enablemusic, rect<s32>(20, 260, 280, 285), tabSystem, CHECKBOX_ENABLE_MUSIC, dataManager.GetSysString(2047));
chkEnableMusic->setChecked(gameConf.enablemusic);
stVolume = env->addStaticText(L"Volume", rect<s32>(20, 290, 80, 310), false, true, tabSystem, -1, false);
srcVolume = env->addScrollBar(true, rect<s32>(85, 295, 280, 310), tabSystem, SCROLL_VOLUME);
......@@ -591,6 +591,9 @@ bool Game::Initialize() {
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
//cancel or finish
btnCancelOrFinish = env->addButton(rect<s32>(205, 230, 295, 265), 0, BUTTON_CANCEL_OR_FINISH, dataManager.GetSysString(1295));
btnCancelOrFinish->setVisible(false);
//leave/surrender/exit
btnLeaveGame = env->addButton(rect<s32>(205, 5, 295, 80), 0, BUTTON_LEAVE_GAME, L"");
btnLeaveGame->setVisible(false);
......@@ -983,7 +986,6 @@ void Game::LoadConfig() {
gameConf.enablesound = true;
gameConf.volume = 1.0;
gameConf.enablemusic = true;
gameConf.BGM_index = -1;
fseek(fp, 0, SEEK_END);
gameConf.draw_field_spell = 1;
gameConf.separate_clear_button = 1;
......@@ -1047,8 +1049,6 @@ void Game::LoadConfig() {
gameConf.volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "enable_music")) {
gameConf.enablemusic = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "BGM_index")) {
gameConf.BGM_index = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
......@@ -1107,8 +1107,6 @@ void Game::SaveConfig() {
int vol = gameConf.volume * 100;
if (vol < 0) vol = 0; else if (vol > 100) vol = 100;
fprintf(fp, "volume = %d\n", vol);
fprintf(fp, "#playing the music corresponding to the sequence(start from 0) under folder /BGM\n#-1 means playing one of them randomly\n");
fprintf(fp, "BGM_index = %d\n", gameConf.BGM_index);
fclose(fp);
}
void Game::PlaySoundEffect(char* sound) {
......@@ -1134,7 +1132,7 @@ void Game::PlayBGM() {
is_playing = false;
if(!is_playing) {
int count = BGMList.size();
int bgm = (gameConf.BGM_index >= 0) ? gameConf.BGM_index : rand() % count;
int bgm = rand() % count;
auto name = BGMList[bgm].c_str();
wchar_t fname[256];
myswprintf(fname, L"./sound/BGM/%ls", name);
......@@ -1300,6 +1298,7 @@ void Game::CloseDuelWindow() {
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
btnCancelOrFinish->setVisible(false);
wChat->setVisible(false);
lstLog->clear();
logParam.clear();
......@@ -1418,6 +1417,7 @@ void Game::OnResize()
btnChainAlways->setRelativePosition(Resize(205, 140, 295, 175));
btnChainIgnore->setRelativePosition(Resize(205, 100, 295, 135));
btnChainWhenAvail->setRelativePosition(Resize(205, 180, 295, 215));
btnCancelOrFinish->setRelativePosition(Resize(205, 230, 295, 265));
}
recti Game::Resize(s32 x, s32 y, s32 x2, s32 y2)
{
......
......@@ -40,7 +40,6 @@ struct Config {
bool enablesound;
double volume;
bool enablemusic;
int BGM_index;
int skin_index;
};
......@@ -445,6 +444,9 @@ public:
irr::gui::IGUIButton* btnChainIgnore;
irr::gui::IGUIButton* btnChainAlways;
irr::gui::IGUIButton* btnChainWhenAvail;
//cancel or finish
irr::gui::IGUIButton* btnCancelOrFinish;
};
extern Game* mainGame;
......
......@@ -62,6 +62,10 @@ irr::video::ITexture* ImageManager::GetTexture(int code) {
sprintf(file, "expansions/pics/%d.jpg", code);
irr::video::ITexture* img = driver->getTexture(file);
if(img == NULL) {
sprintf(file, "pics/%d.png", code);
img = driver->getTexture(file);
}
if (img == NULL) {
sprintf(file, "pics/%d.jpg", code);
img = driver->getTexture(file);
}
......
......@@ -11,7 +11,7 @@ long SingleMode::pduel = 0;
bool SingleMode::is_closing = false;
bool SingleMode::is_continuing = false;
byte buffer[0x10000];
byte buffer[0x1000000];
bool SingleMode::StartPlay() {
Thread::NewThread(SinglePlayThread, 0);
......@@ -814,7 +814,7 @@ byte* SingleMode::ScriptReader(const char* script_name, int* slen) {
return 0;
fseek(fp, 0, SEEK_END);
unsigned int len = ftell(fp);
if(len > 0x10000) {
if(len > 0x1000000) {
fclose(fp);
return 0;
}
......
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