Commit bb84dbc3 authored by edo9300's avatar edo9300

Merge remote-tracking branch 'refs/remotes/Fluorohydride/master'

# Conflicts:
#	gframe/client_field.cpp
#	gframe/deck_con.cpp
#	gframe/drawing.cpp
#	gframe/duelclient.cpp
#	gframe/event_handler.cpp
#	gframe/game.cpp
#	gframe/game.h
#	gframe/menu_handler.cpp
#	gframe/premake4.lua
#	gframe/replay_mode.cpp
#	ocgcore
#	script
#	strings.conf
#	system.conf
parents 03a3fad4 78772f2d
...@@ -1100,9 +1100,8 @@ bool ClientField::ShowSelectSum(bool panelmode) { ...@@ -1100,9 +1100,8 @@ bool ClientField::ShowSelectSum(bool panelmode) {
select_ready = false; select_ready = false;
} }
if (select_ready) { if (select_ready) {
ShowCancelOrFinishButton(1); ShowCancelOrFinishButton(2);
} } else {
else {
ShowCancelOrFinishButton(0); ShowCancelOrFinishButton(0);
} }
return false; return false;
......
...@@ -55,8 +55,8 @@ public: ...@@ -55,8 +55,8 @@ public:
int select_max; int select_max;
int must_select_count; int must_select_count;
int select_sumval; int select_sumval;
int select_cancelable;
int select_mode; int select_mode;
bool select_cancelable;
bool select_panalmode; bool select_panalmode;
bool select_ready; bool select_ready;
int announce_count; int announce_count;
......
...@@ -346,7 +346,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -346,7 +346,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
} }
case COMBOBOX_DBDECKS: { case COMBOBOX_DBDECKS: {
int sel = mainGame->cbDBDecks->getSelected(); int sel = mainGame->cbDBDecks->getSelected();
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel)); if(sel >= 0)
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
prev_deck = sel; prev_deck = sel;
break; break;
} }
......
...@@ -11,8 +11,44 @@ DeckManager deckManager; ...@@ -11,8 +11,44 @@ DeckManager deckManager;
void DeckManager::LoadLFList() { void DeckManager::LoadLFList() {
LFList* cur = NULL; LFList* cur = NULL;
FILE* fp = fopen("lflist.conf", "r"); FILE* fp = fopen("lflist.conf", "r");
FILE* fp_custom = fopen("expansions/lflist.conf", "r");
char linebuf[256]; char linebuf[256];
wchar_t strBuffer[256]; wchar_t strBuffer[256];
if(fp_custom) {
while(fgets(linebuf, 256, fp_custom)) {
if(linebuf[0] == '#')
continue;
int p = 0, sa = 0, code, count;
if(linebuf[0] == '!') {
sa = BufferIO::DecodeUTF8((const char*)(&linebuf[1]), strBuffer);
while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' ) sa--;
LFList newlist;
_lfList.push_back(newlist);
cur = &_lfList[_lfList.size() - 1];
memcpy(cur->listName, (const void*)strBuffer, 40);
cur->listName[sa] = 0;
cur->content = new std::unordered_map<int, int>;
cur->hash = 0x7dfcee6a;
continue;
}
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
if(linebuf[p] == 0)
continue;
linebuf[p++] = 0;
sa = p;
code = atoi(linebuf);
if(code == 0)
continue;
while(linebuf[p] == ' ' || linebuf[p] == '\t') p++;
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
linebuf[p] = 0;
count = atoi(&linebuf[sa]);
if(cur == NULL) continue;
(*cur->content)[code] = count;
cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count)));
}
fclose(fp_custom);
}
if(fp) { if(fp) {
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#') if(linebuf[0] == '#')
......
...@@ -11,7 +11,7 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -11,7 +11,7 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
if(!gameConf.use_d3d) { if(!gameConf.use_d3d) {
float origin[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float origin[4] = {1.0f, 1.0f, 1.0f, 1.0f};
glLineWidth(width); glLineWidth(width);
glLineStipple(1, linePattern); glLineStipple(1, linePatternGL);
if(strip) if(strip)
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
...@@ -28,16 +28,16 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -28,16 +28,16 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
} else { } else {
driver->setMaterial(matManager.mOutLine); driver->setMaterial(matManager.mOutLine);
if(strip) { if(strip) {
if(linePattern < 15) { if(linePatternD3D < 15) {
driver->draw3DLine(vec[0].Pos, vec[0].Pos + (vec[1].Pos - vec[0].Pos) * (linePattern + 1) / 15.0); driver->draw3DLine(vec[0].Pos, vec[0].Pos + (vec[1].Pos - vec[0].Pos) * (linePatternD3D + 1) / 15.0);
driver->draw3DLine(vec[1].Pos, vec[1].Pos + (vec[3].Pos - vec[1].Pos) * (linePattern + 1) / 15.0); driver->draw3DLine(vec[1].Pos, vec[1].Pos + (vec[3].Pos - vec[1].Pos) * (linePatternD3D + 1) / 15.0);
driver->draw3DLine(vec[3].Pos, vec[3].Pos + (vec[2].Pos - vec[3].Pos) * (linePattern + 1) / 15.0); driver->draw3DLine(vec[3].Pos, vec[3].Pos + (vec[2].Pos - vec[3].Pos) * (linePatternD3D + 1) / 15.0);
driver->draw3DLine(vec[2].Pos, vec[2].Pos + (vec[0].Pos - vec[2].Pos) * (linePattern + 1) / 15.0); driver->draw3DLine(vec[2].Pos, vec[2].Pos + (vec[0].Pos - vec[2].Pos) * (linePatternD3D + 1) / 15.0);
} else { } else {
driver->draw3DLine(vec[0].Pos + (vec[1].Pos - vec[0].Pos) * (linePattern - 14) / 15.0, vec[1].Pos); driver->draw3DLine(vec[0].Pos + (vec[1].Pos - vec[0].Pos) * (linePatternD3D - 14) / 15.0, vec[1].Pos);
driver->draw3DLine(vec[1].Pos + (vec[3].Pos - vec[1].Pos) * (linePattern - 14) / 15.0, vec[3].Pos); driver->draw3DLine(vec[1].Pos + (vec[3].Pos - vec[1].Pos) * (linePatternD3D - 14) / 15.0, vec[3].Pos);
driver->draw3DLine(vec[3].Pos + (vec[2].Pos - vec[3].Pos) * (linePattern - 14) / 15.0, vec[2].Pos); driver->draw3DLine(vec[3].Pos + (vec[2].Pos - vec[3].Pos) * (linePatternD3D - 14) / 15.0, vec[2].Pos);
driver->draw3DLine(vec[2].Pos + (vec[0].Pos - vec[2].Pos) * (linePattern - 14) / 15.0, vec[0].Pos); driver->draw3DLine(vec[2].Pos + (vec[0].Pos - vec[2].Pos) * (linePatternD3D - 14) / 15.0, vec[0].Pos);
} }
} else { } else {
driver->draw3DLine(vec[0].Pos, vec[1].Pos); driver->draw3DLine(vec[0].Pos, vec[1].Pos);
...@@ -47,6 +47,26 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -47,6 +47,26 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
} }
} }
} }
void Game::DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color) {
recti pos = element->getAbsolutePosition();
float x1 = pos.UpperLeftCorner.X;
float x2 = pos.LowerRightCorner.X;
float y1 = pos.UpperLeftCorner.Y;
float y2 = pos.LowerRightCorner.Y;
float w = pos.getWidth();
float h = pos.getHeight();
if(linePatternD3D < 15) {
driver->draw2DRectangle(color, recti(x1 - 1 - width, y1 - 1 - width, x1 + (w * (linePatternD3D + 1) / 15.0) + 1 + width, y1 - 1));
driver->draw2DRectangle(color, recti(x2 - (w * (linePatternD3D + 1) / 15.0) - 1 - width, y2 + 1, x2 + 1 + width, y2 + 1 + width));
driver->draw2DRectangle(color, recti(x1 - 1 - width, y1 - 1 - width, x1 - 1, y2 - (h * (linePatternD3D + 1) / 15.0) + 1 + width));
driver->draw2DRectangle(color, recti(x2 + 1, y1 + (h * (linePatternD3D + 1) / 15.0) - 1 - width, x2 + 1 + width, y2 + 1 + width));
} else {
driver->draw2DRectangle(color, recti(x1 - 1 - width + (w * (linePatternD3D - 14) / 15.0), y1 - 1 - width, x2 + 1 + width, y1 - 1));
driver->draw2DRectangle(color, recti(x1 - 1 - width, y2 + 1, x2 - (w * (linePatternD3D - 14) / 15.0) + 1 + width, y2 + 1 + width));
driver->draw2DRectangle(color, recti(x1 - 1 - width, y2 - (h * (linePatternD3D - 14) / 15.0) - 1 - width, x1 - 1, y2 + 1 + width));
driver->draw2DRectangle(color, recti(x2 + 1, y1 - 1 - width, x2 + 1 + width, y1 + (h * (linePatternD3D - 14) / 15.0) + 1 + width));
}
}
void Game::DrawBackGround() { void Game::DrawBackGround() {
static int selFieldAlpha = 255; static int selFieldAlpha = 255;
static int selFieldDAlpha = -10; static int selFieldDAlpha = -10;
...@@ -911,12 +931,13 @@ void Game::DrawSpec() { ...@@ -911,12 +931,13 @@ void Game::DrawSpec() {
showChat = false; showChat = false;
hideChatTimer--; hideChatTimer--;
} }
int maxChatLines = dInfo.isStarted ? 5 : 8; for(int i = 0; i < 8; ++i) {
for(int i = 0; i < maxChatLines; ++i) {
static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040, static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040,
0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040}; 0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040};
if(chatTiming[i]) { if(chatTiming[i]) {
chatTiming[i]--; chatTiming[i]--;
if(mainGame->dInfo.isStarted && i >= 5)
continue;
if(!showChat && i > 2) if(!showChat && i > 2)
continue; continue;
int w = textFont->getDimension(chatMsg[i].c_str()).Width; int w = textFont->getDimension(chatMsg[i].c_str()).Width;
......
...@@ -337,7 +337,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -337,7 +337,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
event_base_loopbreak(client_base); event_base_loopbreak(client_base);
temp_ver = pkt->code; temp_ver = pkt->code;
try_needed = true; try_needed = true;
} }
break; break;
} }
} }
...@@ -973,8 +973,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -973,8 +973,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
if(state < 8) { if(state < 8) {
mainGame->PlaySoundEffect("./sound/playerenter.wav"); mainGame->PlaySoundEffect("./sound/playerenter.wav");
wchar_t prename[20]; wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText();
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[pos]->getText(), prename, 20);
mainGame->stHostPrepDuelist[state]->setText(prename); mainGame->stHostPrepDuelist[state]->setText(prename);
mainGame->stHostPrepDuelist[pos]->setText(L""); mainGame->stHostPrepDuelist[pos]->setText(L"");
mainGame->chkHostPrepReady[pos]->setChecked(false); mainGame->chkHostPrepReady[pos]->setChecked(false);
...@@ -1586,7 +1585,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1586,7 +1585,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
case MSG_SELECT_CARD: { case MSG_SELECT_CARD: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf); /*int selecting_player = */BufferIO::ReadInt8(pbuf);
mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf); mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf) != 0;
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf); mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt8(pbuf); mainGame->dField.select_max = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf); int count = BufferIO::ReadInt8(pbuf);
...@@ -1647,8 +1646,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1647,8 +1646,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
case MSG_SELECT_UNSELECT_CARD: { case MSG_SELECT_UNSELECT_CARD: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf); /*int selecting_player = */BufferIO::ReadInt8(pbuf);
bool buttonok = BufferIO::ReadInt8(pbuf); bool finishable = BufferIO::ReadInt8(pbuf) != 0;
mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf); bool cancelable = BufferIO::ReadInt8(pbuf) != 0;
mainGame->dField.select_cancelable = finishable || cancelable;
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf); mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt8(pbuf); mainGame->dField.select_max = BufferIO::ReadInt8(pbuf);
int count1 = BufferIO::ReadInt8(pbuf); int count1 = BufferIO::ReadInt8(pbuf);
...@@ -1715,17 +1715,20 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1715,17 +1715,20 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
if (panelmode) { if (panelmode) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->wCardSelect->setText(textBuffer); mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard(buttonok); mainGame->dField.ShowSelectCard(mainGame->dField.select_cancelable);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
} else { } else {
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
} }
if (mainGame->dField.select_cancelable) { if (mainGame->dField.select_cancelable) {
if (count2 == 0) if(finishable) {
mainGame->dField.ShowCancelOrFinishButton(1); mainGame->dField.select_ready = true;
else
mainGame->dField.ShowCancelOrFinishButton(2); mainGame->dField.ShowCancelOrFinishButton(2);
}
else {
mainGame->dField.ShowCancelOrFinishButton(1);
}
} }
else else
mainGame->dField.ShowCancelOrFinishButton(0); mainGame->dField.ShowCancelOrFinishButton(0);
...@@ -1945,7 +1948,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1945,7 +1948,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
case MSG_SELECT_TRIBUTE: { case MSG_SELECT_TRIBUTE: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf); /*int selecting_player = */BufferIO::ReadInt8(pbuf);
mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf) ? true : false; mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf) != 0;
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf); mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt8(pbuf); mainGame->dField.select_max = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf); int count = BufferIO::ReadInt8(pbuf);
...@@ -2358,12 +2361,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2358,12 +2361,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true; return true;
} }
case MSG_SHUFFLE_EXTRA: { case MSG_SHUFFLE_EXTRA: {
mainGame->PlaySoundEffect("./sound/shuffle.wav");
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
/*int count = */BufferIO::ReadInt8(pbuf); int count = BufferIO::ReadInt8(pbuf);
if((mainGame->dField.extra[player].size() - mainGame->dField.extra_p_count[player]) < 2) if((mainGame->dField.extra[player].size() - mainGame->dField.extra_p_count[player]) < 2)
return true; return true;
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
if(count > 1)
mainGame->PlaySoundEffect("./sound/shuffle.wav");
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) { for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) {
if(!((*cit)->position & POS_FACEUP)) { if(!((*cit)->position & POS_FACEUP)) {
......
...@@ -442,6 +442,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -442,6 +442,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
list_command = COMMAND_SPSUMMON; list_command = COMMAND_SPSUMMON;
mainGame->wCardSelect->setText(dataManager.GetSysString(509)); mainGame->wCardSelect->setText(dataManager.GetSysString(509));
ShowSelectCard(); ShowSelectCard();
select_ready = false;
ShowCancelOrFinishButton(1); ShowCancelOrFinishButton(1);
} }
break; break;
...@@ -944,30 +945,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -944,30 +945,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
UpdateDeclarableCode(true); UpdateDeclarableCode(true);
break; break;
} }
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
if(mainGame->dInfo.isStarted) {
if(mainGame->dInfo.player_type < 7) {
if (mainGame->dInfo.isRelay)
mainGame->AddChatMsg((wchar_t*)input, (mainGame->dInfo.player_type % 3) * 2);
else if(mainGame->dInfo.isTag)
mainGame->AddChatMsg((wchar_t*)input, (mainGame->dInfo.player_type % 2) * 2);
else
mainGame->AddChatMsg((wchar_t*)input, 0);
} else
mainGame->AddChatMsg((wchar_t*)input, 10);
} else
mainGame->AddChatMsg((wchar_t*)input, 7);
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
}
break;
}
} }
break; break;
} }
...@@ -1761,7 +1738,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1761,7 +1738,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
} }
case irr::gui::EGET_ELEMENT_LEFT: { case irr::gui::EGET_ELEMENT_LEFT: {
// Set cursor to normal if left an edit box // Set cursor to normal if left an edit box
if (event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX && event.GUIEvent.Caller->isEnabled()) if (event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
{ {
utils.changeCursor(ECI_NORMAL); utils.changeCursor(ECI_NORMAL);
} }
...@@ -1836,6 +1813,24 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1836,6 +1813,24 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
} }
break; break;
} }
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
return true;
}
break;
}
}
break;
}
default: break; default: break;
} }
break; break;
...@@ -2239,7 +2234,8 @@ void ClientField::CancelOrFinish() { ...@@ -2239,7 +2234,8 @@ void ClientField::CancelOrFinish() {
mainGame->HideElement(mainGame->wQuery, true); mainGame->HideElement(mainGame->wQuery, true);
break; break;
} }
case MSG_SELECT_CARD: { case MSG_SELECT_CARD:
case MSG_SELECT_UNSELECT_CARD: {
if (selected_cards.size() == 0) { if (selected_cards.size() == 0) {
if (select_cancelable) { if (select_cancelable) {
DuelClient::SetResponseI(-1); DuelClient::SetResponseI(-1);
...@@ -2266,15 +2262,6 @@ void ClientField::CancelOrFinish() { ...@@ -2266,15 +2262,6 @@ void ClientField::CancelOrFinish() {
} }
break; break;
} }
case MSG_SELECT_UNSELECT_CARD: {
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
if (mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true);
else
DuelClient::SendResponse();
break;
}
case MSG_SELECT_TRIBUTE: { case MSG_SELECT_TRIBUTE: {
if (selected_cards.size() == 0) { if (selected_cards.size() == 0) {
if (select_cancelable) { if (select_cancelable) {
......
...@@ -42,7 +42,6 @@ bool Game::Initialize() { ...@@ -42,7 +42,6 @@ bool Game::Initialize() {
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device)
return false; return false;
// Apply skin // Apply skin
if (gameConf.skin_index >= 0) if (gameConf.skin_index >= 0)
{ {
...@@ -54,8 +53,8 @@ bool Game::Initialize() { ...@@ -54,8 +53,8 @@ bool Game::Initialize() {
skinSystem->applySkin(skins[index].c_str()); skinSystem->applySkin(skins[index].c_str());
} }
} }
linePatternD3D = 0;
linePattern = 0x0f0f; linePatternGL = 0x0f0f;
waitFrame = 0; waitFrame = 0;
signalFrame = 0; signalFrame = 0;
showcard = 0; showcard = 0;
...@@ -729,10 +728,8 @@ void Game::MainLoop() { ...@@ -729,10 +728,8 @@ void Game::MainLoop() {
window_size = size; window_size = size;
OnResize(); OnResize();
} }
if(gameConf.use_d3d) linePatternD3D = (linePatternD3D + 1) % 30;
linePattern = (linePattern + 1) % 30; linePatternGL = (linePatternGL << 1) | (linePatternGL >> 15);
else
linePattern = (linePattern << 1) | (linePattern >> 15);
atkframe += 0.1f; atkframe += 0.1f;
atkdy = (float)sin(atkframe); atkdy = (float)sin(atkframe);
driver->beginScene(true, true, SColor(0, 0, 0, 0)); driver->beginScene(true, true, SColor(0, 0, 0, 0));
...@@ -1410,6 +1407,11 @@ void Game::AddChatMsg(wchar_t* msg, int player) { ...@@ -1410,6 +1407,11 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
} }
chatMsg[0].append(msg); chatMsg[0].append(msg);
} }
void Game::ClearChatMsg() {
for(int i = 7; i >= 0; --i) {
chatTiming[i] = 0;
}
}
void Game::AddDebugMsg(char* msg) void Game::AddDebugMsg(char* msg)
{ {
if (enable_log & 0x1) { if (enable_log & 0x1) {
......
...@@ -104,6 +104,7 @@ public: ...@@ -104,6 +104,7 @@ public:
void RefreshSingleplay(); void RefreshSingleplay();
void RefreshBGMList(); void RefreshBGMList();
void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv); void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv);
void DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color);
void DrawBackGround(); void DrawBackGround();
void DrawLinkedZones(ClientCard* pcard); void DrawLinkedZones(ClientCard* pcard);
void CheckMutual(ClientCard* pcard, int mark); void CheckMutual(ClientCard* pcard, int mark);
...@@ -128,6 +129,7 @@ public: ...@@ -128,6 +129,7 @@ public:
void SaveConfig(); void SaveConfig();
void ShowCardInfo(int code, bool resize = false); void ShowCardInfo(int code, bool resize = false);
void AddChatMsg(wchar_t* msg, int player); void AddChatMsg(wchar_t* msg, int player);
void ClearChatMsg();
void AddDebugMsg(char* msgbuf); void AddDebugMsg(char* msgbuf);
void ClearTextures(); void ClearTextures();
void CloseDuelWindow(); void CloseDuelWindow();
...@@ -176,7 +178,8 @@ public: ...@@ -176,7 +178,8 @@ public:
bool hideChat; bool hideChat;
int chatTiming[8]; int chatTiming[8];
int chatType[8]; int chatType[8];
unsigned short linePattern; unsigned short linePatternD3D;
unsigned short linePatternGL;
int waitFrame; int waitFrame;
int signalFrame; int signalFrame;
int saveReplay; int saveReplay;
...@@ -240,6 +243,9 @@ public: ...@@ -240,6 +243,9 @@ public:
irr::gui::IGUIStaticText* stText; irr::gui::IGUIStaticText* stText;
irr::gui::IGUIStaticText* stVolume; irr::gui::IGUIStaticText* stVolume;
irr::gui::IGUIScrollBar* scrCardText; irr::gui::IGUIScrollBar* scrCardText;
irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog;
irr::gui::IGUICheckBox* chkMAutoPos; irr::gui::IGUICheckBox* chkMAutoPos;
irr::gui::IGUICheckBox* chkSTAutoPos; irr::gui::IGUICheckBox* chkSTAutoPos;
irr::gui::IGUICheckBox* chkRandomPos; irr::gui::IGUICheckBox* chkRandomPos;
...@@ -249,9 +255,6 @@ public: ...@@ -249,9 +255,6 @@ public:
irr::gui::IGUICheckBox* chkHideHintButton; irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkEnableSound; irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUICheckBox* chkEnableMusic; irr::gui::IGUICheckBox* chkEnableMusic;
irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog;
irr::gui::IGUIScrollBar* srcVolume; irr::gui::IGUIScrollBar* srcVolume;
//main menu //main menu
irr::gui::IGUIWindow* wMainMenu; irr::gui::IGUIWindow* wMainMenu;
......
...@@ -28,6 +28,8 @@ void UpdateDeck() { ...@@ -28,6 +28,8 @@ void UpdateDeck() {
DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf); DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf);
} }
bool MenuHandler::OnEvent(const irr::SEvent& event) { bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(mainGame->dField.OnCommonEvent(event))
return false;
switch(event.EventType) { switch(event.EventType) {
case irr::EET_GUI_EVENT: { case irr::EET_GUI_EVENT: {
irr::gui::IGUIElement* caller = event.GUIEvent.Caller; irr::gui::IGUIElement* caller = event.GUIEvent.Caller;
......
...@@ -29,17 +29,10 @@ void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) { ...@@ -29,17 +29,10 @@ void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
scc.player = dp->type; scc.player = dp->type;
unsigned short* msg = (unsigned short*)pdata; unsigned short* msg = (unsigned short*)pdata;
int msglen = BufferIO::CopyWStr(msg, scc.msg, 256); int msglen = BufferIO::CopyWStr(msg, scc.msg, 256);
if(dp->type > 1) { NetServer::SendBufferToPlayer(players[0], STOC_CHAT, &scc, 4 + msglen * 2);
NetServer::SendBufferToPlayer(players[0], STOC_CHAT, &scc, 4 + msglen * 2); NetServer::ReSendToPlayer(players[1]);
NetServer::ReSendToPlayer(players[1]); for(auto pit = observers.begin(); pit != observers.end(); ++pit)
for(auto pit = observers.begin(); pit != observers.end(); ++pit) NetServer::ReSendToPlayer(*pit);
if((*pit) != dp)
NetServer::ReSendToPlayer(*pit);
} else {
NetServer::SendBufferToPlayer(players[1 - dp->type], STOC_CHAT, &scc, 4 + msglen * 2);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
} }
void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) { void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
if(!is_creater) { if(!is_creater) {
......
#include "sound_manager.h"
#ifndef _WIN32
#include <dirent.h>
#endif
#ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h"
#endif
namespace ygo {
SoundManager soundManager;
bool SoundManager::Init() {
#ifdef YGOPRO_USE_IRRKLANG
bgm_scene = -1;
RefreshBGMList();
engineSound = irrklang::createIrrKlangDevice();
engineMusic = irrklang::createIrrKlangDevice();
if(!engineSound || !engineMusic) {
return false;
} else {
#ifdef IRRKLANG_STATIC
irrklang::ikpMP3Init(engineMusic);
#endif
return true;
}
#endif // YGOPRO_USE_IRRKLANG
// TODO: Implement other sound engines
return false;
}
void SoundManager::RefreshBGMList() {
RefershBGMDir(L"", BGM_DUEL);
RefershBGMDir(L"duel/", BGM_DUEL);
RefershBGMDir(L"menu/", BGM_MENU);
RefershBGMDir(L"deck/", BGM_DECK);
RefershBGMDir(L"advantage/", BGM_ADVANTAGE);
RefershBGMDir(L"disadvantage/", BGM_DISADVANTAGE);
RefershBGMDir(L"win/", BGM_WIN);
RefershBGMDir(L"lose/", BGM_LOSE);
}
void SoundManager::RefershBGMDir(std::wstring path, int scene) {
#ifdef _WIN32
WIN32_FIND_DATAW fdataw;
std::wstring search = L"./sound/BGM/" + path + L"*.*";
HANDLE fh = FindFirstFileW(search.c_str(), &fdataw);
if(fh == INVALID_HANDLE_VALUE)
return;
do {
size_t len = wcslen(fdataw.cFileName);
if((fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || len < 5
|| !(_wcsicmp(fdataw.cFileName + len - 4, L".mp3") == 0 || _wcsicmp(fdataw.cFileName + len - 4, L".ogg") == 0))
continue;
std::wstring filename = path + (std::wstring)fdataw.cFileName;
BGMList[BGM_ALL].push_back(filename);
BGMList[scene].push_back(filename);
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
#else
DIR * dir;
struct dirent * dirp;
std::wstring wsearchpath = L"./sound/BGM/" + path;
char searchpath[256];
BufferIO::EncodeUTF8(wsearchpath.c_str(), searchpath);
if((dir = opendir(searchpath)) == NULL)
return;
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || !(strcasecmp(dirp->d_name + len - 4, ".mp3") == 0 || strcasecmp(dirp->d_name + len - 4, ".ogg")))
continue;
wchar_t wname[256];
BufferIO::DecodeUTF8(dirp->d_name, wname);
std::wstring filename = path + (std::wstring)wname;
BGMList[BGM_ALL].push_back(filename);
BGMList[scene].push_back(filename);
}
closedir(dir);
#endif
}
void SoundManager::PlaySoundEffect(int sound) {
#ifdef YGOPRO_USE_IRRKLANG
if(!mainGame->chkEnableSound->isChecked())
return;
switch(sound) {
case SOUND_SUMMON: {
engineSound->play2D("./sound/summon.wav");
break;
}
case SOUND_SPECIAL_SUMMON: {
engineSound->play2D("./sound/specialsummon.wav");
break;
}
case SOUND_ACTIVATE: {
engineSound->play2D("./sound/activate.wav");
break;
}
case SOUND_SET: {
engineSound->play2D("./sound/set.wav");
break;
}
case SOUND_FILP: {
engineSound->play2D("./sound/flip.wav");
break;
}
case SOUND_REVEAL: {
engineSound->play2D("./sound/reveal.wav");
break;
}
case SOUND_EQUIP: {
engineSound->play2D("./sound/equip.wav");
break;
}
case SOUND_DESTROYED: {
engineSound->play2D("./sound/destroyed.wav");
break;
}
case SOUND_BANISHED: {
engineSound->play2D("./sound/banished.wav");
break;
}
case SOUND_TOKEN: {
engineSound->play2D("./sound/token.wav");
break;
}
case SOUND_ATTACK: {
engineSound->play2D("./sound/attack.wav");
break;
}
case SOUND_DIRECT_ATTACK: {
engineSound->play2D("./sound/directattack.wav");
break;
}
case SOUND_DRAW: {
engineSound->play2D("./sound/draw.wav");
break;
}
case SOUND_SHUFFLE: {
engineSound->play2D("./sound/shuffle.wav");
break;
}
case SOUND_DAMAGE: {
engineSound->play2D("./sound/damage.wav");
break;
}
case SOUND_RECOVER: {
engineSound->play2D("./sound/gainlp.wav");
break;
}
case SOUND_COUNTER_ADD: {
engineSound->play2D("./sound/addcounter.wav");
break;
}
case SOUND_COUNTER_REMOVE: {
engineSound->play2D("./sound/removecounter.wav");
break;
}
case SOUND_COIN: {
engineSound->play2D("./sound/coinflip.wav");
break;
}
case SOUND_DICE: {
engineSound->play2D("./sound/diceroll.wav");
break;
}
case SOUND_NEXT_TURN: {
engineSound->play2D("./sound/nextturn.wav");
break;
}
case SOUND_PHASE: {
engineSound->play2D("./sound/phase.wav");
break;
}
case SOUND_MENU: {
engineSound->play2D("./sound/menu.wav");
break;
}
case SOUND_BUTTON: {
engineSound->play2D("./sound/button.wav");
break;
}
case SOUND_INFO: {
engineSound->play2D("./sound/info.wav");
break;
}
case SOUND_QUESTION: {
engineSound->play2D("./sound/question.wav");
break;
}
case SOUND_CARD_PICK: {
engineSound->play2D("./sound/cardpick.wav");
break;
}
case SOUND_CARD_DROP: {
engineSound->play2D("./sound/carddrop.wav");
break;
}
case SOUND_PLAYER_ENTER: {
engineSound->play2D("./sound/playerenter.wav");
break;
}
case SOUND_CHAT: {
engineSound->play2D("./sound/chatmessage.wav");
break;
}
default:
break;
}
engineSound->setSoundVolume(mainGame->gameConf.sound_volume);
#endif
}
void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
if(element == mainGame->wMessage) {
PlaySoundEffect(SOUND_INFO);
} else if(element == mainGame->wQuery) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wOptions) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANAttribute) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANCard) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANNumber) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANRace) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wReplaySave) {
PlaySoundEffect(SOUND_QUESTION);
}
}
void SoundManager::PlayMusic(char* song, bool loop) {
#ifdef YGOPRO_USE_IRRKLANG
if(!mainGame->chkEnableMusic->isChecked())
return;
if(!engineMusic->isCurrentlyPlaying(song)) {
engineMusic->stopAllSounds();
soundBGM = engineMusic->play2D(song, loop, false, true);
engineMusic->setSoundVolume(mainGame->gameConf.music_volume);
}
#endif
}
void SoundManager::PlayBGM(int scene) {
#ifdef YGOPRO_USE_IRRKLANG
if(!mainGame->chkEnableMusic->isChecked())
return;
if(!mainGame->chkMusicMode->isChecked())
scene = BGM_ALL;
char BGMName[1024];
if(scene != bgm_scene || (soundBGM && soundBGM->isFinished())) {
int count = BGMList[scene].size();
if(count <= 0)
return;
bgm_scene = scene;
int bgm = rand() % count;
auto name = BGMList[scene][bgm].c_str();
wchar_t fname[1024];
myswprintf(fname, L"./sound/BGM/%ls", name);
BufferIO::EncodeUTF8(fname, BGMName);
PlayMusic(BGMName, false);
}
#endif
}
void SoundManager::StopBGM() {
#ifdef YGOPRO_USE_IRRKLANG
engineMusic->stopAllSounds();
#endif
}
void SoundManager::SetSoundVolume(double volume) {
#ifdef YGOPRO_USE_IRRKLANG
engineSound->setSoundVolume(volume);
#endif
}
void SoundManager::SetMusicVolume(double volume) {
#ifdef YGOPRO_USE_IRRKLANG
engineMusic->setSoundVolume(volume);
#endif
}
}
#ifndef SOUNDMANAGER_H
#define SOUNDMANAGER_H
#include "game.h"
#ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h>
#endif
namespace ygo {
class SoundManager {
private:
std::vector<std::wstring> BGMList[8];
int bgm_scene;
#ifdef YGOPRO_USE_IRRKLANG
irrklang::ISoundEngine* engineSound;
irrklang::ISoundEngine* engineMusic;
irrklang::ISound* soundBGM;
#endif
void RefershBGMDir(std::wstring path, int scene);
public:
bool Init();
void RefreshBGMList();
void PlaySoundEffect(int sound);
void PlayDialogSound(irr::gui::IGUIElement * element);
void PlayMusic(char* song, bool loop);
void PlayBGM(int scene);
void StopBGM();
void SetSoundVolume(double volume);
void SetMusicVolume(double volume);
};
extern SoundManager soundManager;
#define SOUND_SUMMON 101
#define SOUND_SPECIAL_SUMMON 102
#define SOUND_ACTIVATE 103
#define SOUND_SET 104
#define SOUND_FILP 105
#define SOUND_REVEAL 106
#define SOUND_EQUIP 107
#define SOUND_DESTROYED 108
#define SOUND_BANISHED 109
#define SOUND_TOKEN 110
#define SOUND_ATTACK 201
#define SOUND_DIRECT_ATTACK 202
#define SOUND_DRAW 203
#define SOUND_SHUFFLE 204
#define SOUND_DAMAGE 205
#define SOUND_RECOVER 206
#define SOUND_COUNTER_ADD 207
#define SOUND_COUNTER_REMOVE 208
#define SOUND_COIN 209
#define SOUND_DICE 210
#define SOUND_NEXT_TURN 211
#define SOUND_PHASE 212
#define SOUND_MENU 301
#define SOUND_BUTTON 302
#define SOUND_INFO 303
#define SOUND_QUESTION 304
#define SOUND_CARD_PICK 305
#define SOUND_CARD_DROP 306
#define SOUND_PLAYER_ENTER 307
#define SOUND_CHAT 308
#define BGM_ALL 0
#define BGM_DUEL 1
#define BGM_MENU 2
#define BGM_DECK 3
#define BGM_ADVANTAGE 4
#define BGM_DISADVANTAGE 5
#define BGM_WIN 6
#define BGM_LOSE 7
}
#endif //SOUNDMANAGER_H
...@@ -26,8 +26,9 @@ void TagDuel::Chat(DuelPlayer* dp, void* pdata, int len) { ...@@ -26,8 +26,9 @@ void TagDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
unsigned short* msg = (unsigned short*)pdata; unsigned short* msg = (unsigned short*)pdata;
int msglen = BufferIO::CopyWStr(msg, scc.msg, 256); int msglen = BufferIO::CopyWStr(msg, scc.msg, 256);
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
if(players[i] != dp) NetServer::SendBufferToPlayer(players[i], STOC_CHAT, &scc, 4 + msglen * 2);
NetServer::SendBufferToPlayer(players[i], STOC_CHAT, &scc, 4 + msglen * 2); for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
} }
void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) { void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
if(!is_creater) { if(!is_creater) {
......
summon.wav
specialsummon.wav
activate.wav
set.wav
flip.wav
reveal.wav
equip.wav
destroyed.wav
banished.wav
token.wav
attack.wav
directattack.wav
draw.wav
shuffle.wav
damage.wav
gainlp.wav
addcounter.wav
removecounter.wav
coinflip.wav
diceroll.wav
nextturn.wav
phase.wav
menu.wav
button.wav
info.wav
question.wav
cardpick.wav
carddrop.wav
playerenter.wav
chatmessage.wav
BGM/*.mp3
BGM/duel/*.mp3
BGM/menu/*.mp3
BGM/deck/*.mp3
BGM/advantage/*.mp3
BGM/disadvantage/*.mp3
BGM/win/*.mp3
BGM/lose/*.mp3
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