Commit 1b90d5a0 authored by mercury233's avatar mercury233

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

parents 5c106955 78772f2d
...@@ -420,26 +420,30 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) { ...@@ -420,26 +420,30 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
selectable_cards[i]->sequence + 1); selectable_cards[i]->sequence + 1);
mainGame->stCardPos[i]->setText(formatBuffer); mainGame->stCardPos[i]->setText(formatBuffer);
// color // color
if(conti_selecting) if (selectable_cards[i]->is_selected)
mainGame->stCardPos[i]->setBackgroundColor(0xffffffff); mainGame->stCardPos[i]->setBackgroundColor(0xffffff00);
else if(selectable_cards[i]->location == LOCATION_OVERLAY) { else {
if(selectable_cards[i]->owner != selectable_cards[i]->overlayTarget->controler) if(conti_selecting)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->overlayTarget->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xffd0d0d0);
else mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
} else if(selectable_cards[i]->location == LOCATION_DECK || selectable_cards[i]->location == LOCATION_EXTRA || selectable_cards[i]->location == LOCATION_REMOVED) {
if(selectable_cards[i]->position & POS_FACEDOWN)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xffd0d0d0);
else
mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
} else {
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xffd0d0d0);
else
mainGame->stCardPos[i]->setBackgroundColor(0xffffffff); mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
else if(selectable_cards[i]->location == LOCATION_OVERLAY) {
if(selectable_cards[i]->owner != selectable_cards[i]->overlayTarget->controler)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->overlayTarget->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xffd0d0d0);
else mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
} else if(selectable_cards[i]->location == LOCATION_DECK || selectable_cards[i]->location == LOCATION_EXTRA || selectable_cards[i]->location == LOCATION_REMOVED) {
if(selectable_cards[i]->position & POS_FACEDOWN)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff);
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xffd0d0d0);
else
mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
} else {
if(selectable_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xffd0d0d0);
else
mainGame->stCardPos[i]->setBackgroundColor(0xffffffff);
}
} }
} else { } else {
if(sort_list[i]) { if(sort_list[i]) {
...@@ -1058,7 +1062,7 @@ bool ClientField::ShowSelectSum(bool panelmode) { ...@@ -1058,7 +1062,7 @@ 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);
} }
......
...@@ -54,8 +54,8 @@ public: ...@@ -54,8 +54,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;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "data_manager.h" #include "data_manager.h"
#include "deck_manager.h" #include "deck_manager.h"
#include "image_manager.h" #include "image_manager.h"
#include "sound_manager.h"
#include "game.h" #include "game.h"
#include "duelclient.h" #include "duelclient.h"
#include <algorithm> #include <algorithm>
...@@ -122,6 +123,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -122,6 +123,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break; break;
switch(event.GUIEvent.EventType) { switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: { case irr::gui::EGET_BUTTON_CLICKED: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(id) { switch(id) {
case BUTTON_CLEAR_DECK: { case BUTTON_CLEAR_DECK: {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
...@@ -220,6 +222,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -220,6 +222,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
for(int i = 0; i < 32; ++i, filter <<= 1) for(int i = 0; i < 32; ++i, filter <<= 1)
if(mainGame->chkCategory[i]->isChecked()) if(mainGame->chkCategory[i]->isChecked())
filter_effect |= filter; filter_effect |= filter;
mainGame->btnEffectFilter->setPressed(filter_effect > 0);
mainGame->HideElement(mainGame->wCategories); mainGame->HideElement(mainGame->wCategories);
InstantSearch(); InstantSearch();
break; break;
...@@ -227,6 +230,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -227,6 +230,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case BUTTON_SIDE_OK: { case BUTTON_SIDE_OK: {
if(deckManager.current_deck.main.size() != pre_mainc || deckManager.current_deck.extra.size() != pre_extrac if(deckManager.current_deck.main.size() != pre_mainc || deckManager.current_deck.extra.size() != pre_extrac
|| deckManager.current_deck.side.size() != pre_sidec) { || deckManager.current_deck.side.size() != pre_sidec) {
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410));
break; break;
} }
...@@ -319,6 +323,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -319,6 +323,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if (mainGame->btnMark[7]->isPressed()) if (mainGame->btnMark[7]->isPressed())
filter_marks |= 0004; filter_marks |= 0004;
mainGame->HideElement(mainGame->wLinkMarks); mainGame->HideElement(mainGame->wLinkMarks);
mainGame->btnMarksFilter->setPressed(filter_marks > 0);
InstantSearch(); InstantSearch();
break; break;
} }
...@@ -362,7 +367,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -362,7 +367,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break; break;
} }
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;
is_modified = false; is_modified = false;
break; break;
...@@ -514,6 +520,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -514,6 +520,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
is_starting_dragging = false; is_starting_dragging = false;
if(!is_draging) if(!is_draging)
break; break;
soundManager.PlaySoundEffect(SOUND_CARD_DROP);
bool pushed = false; bool pushed = false;
if(hovered_pos == 1) if(hovered_pos == 1)
pushed = push_main(draging_pointer, hovered_seq); pushed = push_main(draging_pointer, hovered_seq);
...@@ -543,6 +550,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -543,6 +550,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto pointer = dataManager.GetCodePointer(hovered_code); auto pointer = dataManager.GetCodePointer(hovered_code);
if(pointer == dataManager._datas.end()) if(pointer == dataManager._datas.end())
break; break;
soundManager.PlaySoundEffect(SOUND_CARD_DROP);
if(hovered_pos == 1) { if(hovered_pos == 1) {
if(push_side(pointer)) if(push_side(pointer))
pop_main(hovered_seq); pop_main(hovered_seq);
...@@ -560,6 +568,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -560,6 +568,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if(!is_draging) { if(!is_draging) {
if(hovered_pos == 0 || hovered_seq == -1) if(hovered_pos == 0 || hovered_seq == -1)
break; break;
soundManager.PlaySoundEffect(SOUND_CARD_DROP);
if(hovered_pos == 1) { if(hovered_pos == 1) {
pop_main(hovered_seq); pop_main(hovered_seq);
} else if(hovered_pos == 2) { } else if(hovered_pos == 2) {
...@@ -576,6 +585,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -576,6 +585,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
push_side(pointer); push_side(pointer);
} }
} else { } else {
soundManager.PlaySoundEffect(SOUND_CARD_PICK);
if(click_pos == 1) { if(click_pos == 1) {
push_side(draging_pointer); push_side(draging_pointer);
} else if(click_pos == 2) { } else if(click_pos == 2) {
...@@ -602,6 +612,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -602,6 +612,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto pointer = dataManager.GetCodePointer(hovered_code); auto pointer = dataManager.GetCodePointer(hovered_code);
if(!check_limit(pointer)) if(!check_limit(pointer))
break; break;
soundManager.PlaySoundEffect(SOUND_CARD_PICK);
if (hovered_pos == 1) { if (hovered_pos == 1) {
if(!push_main(pointer)) if(!push_main(pointer))
push_side(pointer); push_side(pointer);
...@@ -620,6 +631,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -620,6 +631,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_MOVED: { case irr::EMIE_MOUSE_MOVED: {
if(is_starting_dragging) { if(is_starting_dragging) {
is_draging = true; is_draging = true;
soundManager.PlaySoundEffect(SOUND_CARD_PICK);
if(hovered_pos == 1) if(hovered_pos == 1)
pop_main(hovered_seq); pop_main(hovered_seq);
else if(hovered_pos == 2) else if(hovered_pos == 2)
...@@ -635,6 +647,11 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -635,6 +647,11 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_WHEEL: { case irr::EMIE_MOUSE_WHEEL: {
if(!mainGame->scrFilter->isVisible()) if(!mainGame->scrFilter->isVisible())
break; break;
if(mainGame->env->hasFocus(mainGame->scrFilter))
break;
irr::gui::IGUIElement* root = mainGame->env->getRootGUIElement();
if(root->getElementFromPoint(mouse_pos) != root)
break;
if(event.MouseInput.Wheel < 0) { if(event.MouseInput.Wheel < 0) {
if(mainGame->scrFilter->getPos() < mainGame->scrFilter->getMax()) if(mainGame->scrFilter->getPos() < mainGame->scrFilter->getMax())
mainGame->scrFilter->setPos(mainGame->scrFilter->getPos() + 1); mainGame->scrFilter->setPos(mainGame->scrFilter->getPos() + 1);
...@@ -904,6 +921,8 @@ void DeckBuilder::ClearFilter() { ...@@ -904,6 +921,8 @@ void DeckBuilder::ClearFilter() {
filter_marks = 0; filter_marks = 0;
for(int i = 0; i < 8; i++) for(int i = 0; i < 8; i++)
mainGame->btnMark[i]->setPressed(false); mainGame->btnMark[i]->setPressed(false);
mainGame->btnEffectFilter->setPressed(false);
mainGame->btnMarksFilter->setPressed(false);
} }
void DeckBuilder::SortList() { void DeckBuilder::SortList() {
auto left = results.begin(); auto left = results.begin();
......
...@@ -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] == '#')
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "materials.h" #include "materials.h"
#include "image_manager.h" #include "image_manager.h"
#include "deck_manager.h" #include "deck_manager.h"
#include "sound_manager.h"
#include "duelclient.h" #include "duelclient.h"
#include "../ocgcore/field.h" #include "../ocgcore/field.h"
...@@ -11,7 +12,7 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -11,7 +12,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 +29,16 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -28,16 +29,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 +48,26 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -47,6 +48,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;
...@@ -450,6 +471,9 @@ void Game::DrawMisc() { ...@@ -450,6 +471,9 @@ void Game::DrawMisc() {
driver->drawVertexPrimitiveList(matManager.vChainNum, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vChainNum, 4, matManager.iRectangle, 2);
} }
} }
//finish button
if(btnCancelOrFinish->isVisible() && dField.select_ready)
DrawSelectionLine(btnCancelOrFinish, 2, 0xffffff00);
//lp bar //lp bar
if((dInfo.turn % 2 && dInfo.isFirst) || (!(dInfo.turn % 2) && !dInfo.isFirst)) { if((dInfo.turn % 2 && dInfo.isFirst) || (!(dInfo.turn % 2) && !dInfo.isFirst)) {
driver->draw2DRectangle(0xa0000000, recti(327, 8, 630, 51)); driver->draw2DRectangle(0xa0000000, recti(327, 8, 630, 51));
...@@ -920,12 +944,13 @@ void Game::DrawSpec() { ...@@ -920,12 +944,13 @@ void Game::DrawSpec() {
showChat = false; showChat = false;
hideChatTimer--; hideChatTimer--;
} }
int maxChatLines = mainGame->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;
...@@ -1008,6 +1033,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) { ...@@ -1008,6 +1033,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
fadingList.push_back(fu); fadingList.push_back(fu);
} }
void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) { void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) {
soundManager.PlayDialogSound(element);
element->getParent()->bringToFront(element); element->getParent()->bringToFront(element);
if(!mainGame->is_building) if(!mainGame->is_building)
dField.panel = element; dField.panel = element;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "client_card.h" #include "client_card.h"
#include "materials.h" #include "materials.h"
#include "image_manager.h" #include "image_manager.h"
#include "sound_manager.h"
#include "single_mode.h" #include "single_mode.h"
#include "../ocgcore/field.h" #include "../ocgcore/field.h"
#include "../ocgcore/duel.h" #include "../ocgcore/duel.h"
...@@ -76,6 +77,7 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) { ...@@ -76,6 +77,7 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
else if(!bot_mode && !mainGame->wLanWindow->isVisible()) else if(!bot_mode && !mainGame->wLanWindow->isVisible())
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
} }
...@@ -166,6 +168,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -166,6 +168,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
else if(!bot_mode && !mainGame->wLanWindow->isVisible()) else if(!bot_mode && !mainGame->wLanWindow->isVisible())
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
} else if(connect_state == 0x7) { } else if(connect_state == 0x7) {
...@@ -182,24 +185,28 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -182,24 +185,28 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
else else
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
mainGame->wChat->setVisible(false); mainGame->wChat->setVisible(false);
soundManager.PlaySoundEffect(SOUND_INFO);
if(events & BEV_EVENT_EOF) if(events & BEV_EVENT_EOF)
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1401)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1401));
else mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402)); else mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1502)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1502));
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->stTip->setVisible(false);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set(); mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false;
mainGame->is_building = false; mainGame->is_building = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
if(bot_mode) if(bot_mode)
...@@ -240,6 +247,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -240,6 +247,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
soundManager.PlaySoundEffect(SOUND_INFO);
if(pkt->code == 0) if(pkt->code == 0)
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1403)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1403));
else if(pkt->code == 1) else if(pkt->code == 1)
...@@ -297,6 +305,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -297,6 +305,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break; break;
} }
} }
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", msgbuf); mainGame->env->addMessageBox(L"", msgbuf);
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
...@@ -304,6 +313,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -304,6 +313,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} }
case ERRMSG_SIDEERROR: { case ERRMSG_SIDEERROR: {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1408)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1408));
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
...@@ -317,6 +327,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -317,6 +327,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
wchar_t msgbuf[256]; wchar_t msgbuf[256];
myswprintf(msgbuf, dataManager.GetSysString(1411), pkt->code >> 12, (pkt->code >> 4) & 0xff, pkt->code & 0xf); myswprintf(msgbuf, dataManager.GetSysString(1411), pkt->code >> 12, (pkt->code >> 4) & 0xff, pkt->code & 0xf);
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", msgbuf); mainGame->env->addMessageBox(L"", msgbuf);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
event_base_loopbreak(client_base); event_base_loopbreak(client_base);
...@@ -468,7 +479,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -468,7 +479,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
else if(mainGame->wSinglePlay->isVisible()) else if(mainGame->wSinglePlay->isVisible())
mainGame->HideElement(mainGame->wSinglePlay); mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare); mainGame->ShowElement(mainGame->wHostPrepare);
mainGame->wChat->setVisible(true); if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->dInfo.duel_rule = pkt->info.duel_rule; mainGame->dInfo.duel_rule = pkt->info.duel_rule;
watching = 0; watching = 0;
...@@ -554,6 +566,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -554,6 +566,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.lp[0] = 0; mainGame->dInfo.lp[0] = 0;
mainGame->dInfo.lp[1] = 0; mainGame->dInfo.lp[1] = 0;
mainGame->dInfo.strLP[0][0] = 0; mainGame->dInfo.strLP[0][0] = 0;
...@@ -576,7 +589,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -576,7 +589,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnM2->setVisible(false); mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false); mainGame->btnEP->setVisible(false);
mainGame->btnShuffle->setVisible(false); mainGame->btnShuffle->setVisible(false);
mainGame->wChat->setVisible(true); if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
if(!mainGame->dInfo.isTag) { if(!mainGame->dInfo.isTag) {
if(selftype > 1) { if(selftype > 1) {
...@@ -636,6 +650,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -636,6 +650,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->is_building = false; mainGame->is_building = false;
mainGame->wDeckEdit->setVisible(false); mainGame->wDeckEdit->setVisible(false);
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
...@@ -741,6 +756,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -741,6 +756,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break; break;
} }
case STOC_HS_PLAYER_ENTER: { case STOC_HS_PLAYER_ENTER: {
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
STOC_HS_PlayerEnter* pkt = (STOC_HS_PlayerEnter*)pdata; STOC_HS_PlayerEnter* pkt = (STOC_HS_PlayerEnter*)pdata;
if(pkt->pos > 3) if(pkt->pos > 3)
break; break;
...@@ -775,6 +791,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -775,6 +791,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break; break;
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
if(state < 8) { if(state < 8) {
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText(); wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText();
mainGame->stHostPrepDuelist[state]->setText(prename); mainGame->stHostPrepDuelist[state]->setText(prename);
mainGame->stHostPrepDuelist[pos]->setText(L""); mainGame->stHostPrepDuelist[pos]->setText(L"");
...@@ -867,6 +884,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -867,6 +884,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false;
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
...@@ -981,6 +999,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -981,6 +999,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
break; break;
} }
case MSG_WIN: { case MSG_WIN: {
mainGame->dInfo.isFinished = true;
int player = BufferIO::ReadInt8(pbuf); int player = BufferIO::ReadInt8(pbuf);
int type = BufferIO::ReadInt8(pbuf); int type = BufferIO::ReadInt8(pbuf);
mainGame->showcarddif = 110; mainGame->showcarddif = 110;
...@@ -1323,7 +1342,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1323,7 +1342,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);
...@@ -1378,6 +1397,88 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1378,6 +1397,88 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
return false; return false;
} }
case MSG_SELECT_UNSELECT_CARD: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf);
bool finishable = BufferIO::ReadInt8(pbuf) != 0;
bool cancelable = BufferIO::ReadInt8(pbuf) != 0;
mainGame->dField.select_cancelable = finishable || cancelable;
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt8(pbuf);
int count1 = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_cards.clear();
mainGame->dField.selected_cards.clear();
int c, l, s, ss;
unsigned int code;
bool panelmode = false;
mainGame->dField.select_ready = false;
ClientCard* pcard;
for (int i = 0; i < count1; ++i) {
code = (unsigned int)BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
ss = BufferIO::ReadInt8(pbuf);
if ((l & LOCATION_OVERLAY) > 0)
pcard = mainGame->dField.GetCard(c, l & 0x7f, s)->overlayed[ss];
else
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->select_seq = i;
mainGame->dField.selectable_cards.push_back(pcard);
pcard->is_selectable = true;
pcard->is_selected = false;
if (l & 0xf1)
panelmode = true;
}
int count2 = BufferIO::ReadInt8(pbuf);
for (int i = count1; i < count1 + count2; ++i) {
code = (unsigned int)BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
ss = BufferIO::ReadInt8(pbuf);
if ((l & LOCATION_OVERLAY) > 0)
pcard = mainGame->dField.GetCard(c, l & 0x7f, s)->overlayed[ss];
else
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->select_seq = i;
mainGame->dField.selectable_cards.push_back(pcard);
pcard->is_selectable = true;
pcard->is_selected = true;
if (l & 0xf1)
panelmode = true;
}
std::sort(mainGame->dField.selectable_cards.begin(), mainGame->dField.selectable_cards.end(), ClientCard::client_card_sort);
if(select_hint)
myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetDesc(select_hint),
mainGame->dField.select_min, mainGame->dField.select_max);
else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(560), mainGame->dField.select_min, mainGame->dField.select_max);
select_hint = 0;
if (panelmode) {
mainGame->gMutex.Lock();
mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard(mainGame->dField.select_cancelable);
mainGame->gMutex.Unlock();
} else {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
}
if (mainGame->dField.select_cancelable) {
if(finishable) {
mainGame->dField.select_ready = true;
mainGame->dField.ShowCancelOrFinishButton(2);
}
else {
mainGame->dField.ShowCancelOrFinishButton(1);
}
}
else
mainGame->dField.ShowCancelOrFinishButton(0);
return false;
}
case MSG_SELECT_CHAIN: { case MSG_SELECT_CHAIN: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf); /*int selecting_player = */BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf); int count = BufferIO::ReadInt8(pbuf);
...@@ -1591,7 +1692,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1591,7 +1692,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);
...@@ -1758,6 +1859,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1758,6 +1859,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_REVEAL);
myswprintf(textBuffer, dataManager.GetSysString(207), count); myswprintf(textBuffer, dataManager.GetSysString(207), count);
mainGame->lstLog->addItem(textBuffer); mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0); mainGame->logParam.push_back(0);
...@@ -1797,6 +1899,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1797,6 +1899,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_REVEAL);
myswprintf(textBuffer, dataManager.GetSysString(207), count); myswprintf(textBuffer, dataManager.GetSysString(207), count);
mainGame->lstLog->addItem(textBuffer); mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0); mainGame->logParam.push_back(0);
...@@ -1831,6 +1934,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1831,6 +1934,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pbuf += count * 7; pbuf += count * 7;
return true; return true;
} }
soundManager.PlaySoundEffect(SOUND_REVEAL);
myswprintf(textBuffer, dataManager.GetSysString(208), count); myswprintf(textBuffer, dataManager.GetSysString(208), count);
mainGame->lstLog->addItem(textBuffer); mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0); mainGame->logParam.push_back(0);
...@@ -1939,6 +2043,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1939,6 +2043,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.deck[player][i]->is_reversed = false; mainGame->dField.deck[player][i]->is_reversed = false;
} }
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
soundManager.PlaySoundEffect(SOUND_SHUFFLE);
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) { for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) {
(*cit)->dPos = irr::core::vector3df(rand() * 0.4f / RAND_MAX - 0.2f, 0, 0); (*cit)->dPos = irr::core::vector3df(rand() * 0.4f / RAND_MAX - 0.2f, 0, 0);
...@@ -1961,8 +2066,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1961,8 +2066,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
case MSG_SHUFFLE_HAND: { case MSG_SHUFFLE_HAND: {
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->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
if(count > 1)
soundManager.PlaySoundEffect(SOUND_SHUFFLE);
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
if(player == 1 && !mainGame->dInfo.isReplay && !mainGame->dInfo.isSingleMode) { if(player == 1 && !mainGame->dInfo.isReplay && !mainGame->dInfo.isSingleMode) {
bool flip = false; bool flip = false;
...@@ -2000,10 +2107,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2000,10 +2107,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
case MSG_SHUFFLE_EXTRA: { case MSG_SHUFFLE_EXTRA: {
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)
soundManager.PlaySoundEffect(SOUND_SHUFFLE);
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)) {
...@@ -2133,6 +2242,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2133,6 +2242,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
} }
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
soundManager.PlaySoundEffect(SOUND_SHUFFLE);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
mainGame->dField.MoveCard(mc[i], 10); mainGame->dField.MoveCard(mc[i], 10);
for (cit = mc[i]->overlayed.begin(); cit != mc[i]->overlayed.end(); ++cit) for (cit = mc[i]->overlayed.begin(); cit != mc[i]->overlayed.end(); ++cit)
...@@ -2169,6 +2279,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2169,6 +2279,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.tag_player[1] = !mainGame->dInfo.tag_player[1]; mainGame->dInfo.tag_player[1] = !mainGame->dInfo.tag_player[1];
} }
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
soundManager.PlaySoundEffect(SOUND_NEXT_TURN);
mainGame->showcardcode = 10; mainGame->showcardcode = 10;
mainGame->showcarddif = 30; mainGame->showcarddif = 30;
mainGame->showcardp = 0; mainGame->showcardp = 0;
...@@ -2216,6 +2327,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2216,6 +2327,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnPhaseStatus->setPressed(true); mainGame->btnPhaseStatus->setPressed(true);
mainGame->btnPhaseStatus->setVisible(true); mainGame->btnPhaseStatus->setVisible(true);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
soundManager.PlaySoundEffect(SOUND_PHASE);
mainGame->showcard = 101; mainGame->showcard = 101;
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
mainGame->showcard = 0; mainGame->showcard = 0;
...@@ -2232,7 +2344,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2232,7 +2344,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int cl = BufferIO::ReadUInt8(pbuf); int cl = BufferIO::ReadUInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf); int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf); int cp = BufferIO::ReadInt8(pbuf);
/*int reason = */BufferIO::ReadInt32(pbuf); int reason = BufferIO::ReadInt32(pbuf);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
if(cl & LOCATION_REMOVED && pl != cl)
soundManager.PlaySoundEffect(SOUND_BANISHED);
else if(reason & REASON_DESTROY && pl != cl)
soundManager.PlaySoundEffect(SOUND_DESTROYED);
}
if (pl == 0) { if (pl == 0) {
ClientCard* pcard = new ClientCard(); ClientCard* pcard = new ClientCard();
pcard->position = cp; pcard->position = cp;
...@@ -2453,6 +2571,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2453,6 +2571,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
/*int cl = */BufferIO::ReadInt8(pbuf); /*int cl = */BufferIO::ReadInt8(pbuf);
/*int cs = */BufferIO::ReadInt8(pbuf); /*int cs = */BufferIO::ReadInt8(pbuf);
/*int cp = */BufferIO::ReadInt8(pbuf); /*int cp = */BufferIO::ReadInt8(pbuf);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping)
soundManager.PlaySoundEffect(SOUND_SET);
myswprintf(event_string, dataManager.GetSysString(1601)); myswprintf(event_string, dataManager.GetSysString(1601));
return true; return true;
} }
...@@ -2506,6 +2626,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2506,6 +2626,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
/*int cs = */BufferIO::ReadInt8(pbuf); /*int cs = */BufferIO::ReadInt8(pbuf);
/*int cp = */BufferIO::ReadInt8(pbuf); /*int cp = */BufferIO::ReadInt8(pbuf);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
soundManager.PlaySoundEffect(SOUND_SUMMON);
myswprintf(event_string, dataManager.GetSysString(1603), dataManager.GetName(code)); myswprintf(event_string, dataManager.GetSysString(1603), dataManager.GetName(code));
mainGame->showcardcode = code; mainGame->showcardcode = code;
mainGame->showcarddif = 0; mainGame->showcarddif = 0;
...@@ -2528,6 +2649,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2528,6 +2649,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
/*int cs = */BufferIO::ReadInt8(pbuf); /*int cs = */BufferIO::ReadInt8(pbuf);
/*int cp = */BufferIO::ReadInt8(pbuf); /*int cp = */BufferIO::ReadInt8(pbuf);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
CardData cd;
if(dataManager.GetData(code, &cd) && (cd.type & TYPE_TOKEN))
soundManager.PlaySoundEffect(SOUND_TOKEN);
else
soundManager.PlaySoundEffect(SOUND_SPECIAL_SUMMON);
myswprintf(event_string, dataManager.GetSysString(1605), dataManager.GetName(code)); myswprintf(event_string, dataManager.GetSysString(1605), dataManager.GetName(code));
mainGame->showcardcode = code; mainGame->showcardcode = code;
mainGame->showcarddif = 1; mainGame->showcarddif = 1;
...@@ -2552,6 +2678,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2552,6 +2678,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->SetCode(code); pcard->SetCode(code);
pcard->position = cp; pcard->position = cp;
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
soundManager.PlaySoundEffect(SOUND_FILP);
myswprintf(event_string, dataManager.GetSysString(1607), dataManager.GetName(code)); myswprintf(event_string, dataManager.GetSysString(1607), dataManager.GetName(code));
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
...@@ -2582,6 +2709,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2582,6 +2709,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
/*int ct = */BufferIO::ReadInt8(pbuf); /*int ct = */BufferIO::ReadInt8(pbuf);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_ACTIVATE);
ClientCard* pcard = mainGame->dField.GetCard(pcc, pcl, pcs, subs); ClientCard* pcard = mainGame->dField.GetCard(pcc, pcl, pcs, subs);
if(pcard->code != code) { if(pcard->code != code) {
pcard->code = code; pcard->code = code;
...@@ -2683,6 +2811,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2683,6 +2811,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pbuf += count * 4; pbuf += count * 4;
return true; return true;
} }
soundManager.PlaySoundEffect(SOUND_DICE);
ClientCard* pcards[10]; ClientCard* pcards[10];
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
...@@ -2701,6 +2830,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2701,6 +2830,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true; return true;
} }
case MSG_BECOME_TARGET: { case MSG_BECOME_TARGET: {
//soundManager.PlaySoundEffect(SOUND_TARGET);
int count = BufferIO::ReadInt8(pbuf); int count = BufferIO::ReadInt8(pbuf);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) { if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) {
pbuf += count * 4; pbuf += count * 4;
...@@ -2748,6 +2878,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2748,6 +2878,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
} else { } else {
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
soundManager.PlaySoundEffect(SOUND_DRAW);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
pcard = mainGame->dField.GetCard(player, LOCATION_DECK, mainGame->dField.deck[player].size() - 1); pcard = mainGame->dField.GetCard(player, LOCATION_DECK, mainGame->dField.deck[player].size() - 1);
mainGame->dField.deck[player].erase(mainGame->dField.deck[player].end() - 1); mainGame->dField.deck[player].erase(mainGame->dField.deck[player].end() - 1);
...@@ -2774,6 +2905,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2774,6 +2905,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
return true; return true;
} }
soundManager.PlaySoundEffect(SOUND_DAMAGE);
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10; mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
if (player == 0) if (player == 0)
myswprintf(event_string, dataManager.GetSysString(1613), val); myswprintf(event_string, dataManager.GetSysString(1613), val);
...@@ -2802,6 +2934,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2802,6 +2934,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
return true; return true;
} }
soundManager.PlaySoundEffect(SOUND_RECOVER);
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10; mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
if (player == 0) if (player == 0)
myswprintf(event_string, dataManager.GetSysString(1615), val); myswprintf(event_string, dataManager.GetSysString(1615), val);
...@@ -2838,6 +2971,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2838,6 +2971,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pc1->equipTarget = pc2; pc1->equipTarget = pc2;
pc2->equipped.insert(pc1); pc2->equipped.insert(pc1);
} else { } else {
soundManager.PlaySoundEffect(SOUND_EQUIP);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
if(pc1->equipTarget) { if(pc1->equipTarget) {
pc1->is_showequip = false; pc1->is_showequip = false;
...@@ -2956,6 +3090,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2956,6 +3090,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
return true; return true;
} }
soundManager.PlaySoundEffect(SOUND_DAMAGE);
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10; mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
mainGame->lpccolor = 0xff0000ff; mainGame->lpccolor = 0xff0000ff;
mainGame->lpplayer = player; mainGame->lpplayer = player;
...@@ -2983,6 +3118,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2983,6 +3118,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
else pc->counters[type] = count; else pc->counters[type] = count;
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_COUNTER_ADD);
myswprintf(textBuffer, dataManager.GetSysString(1617), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type)); myswprintf(textBuffer, dataManager.GetSysString(1617), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true; pc->is_highlighting = true;
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
...@@ -3005,6 +3141,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3005,6 +3141,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pc->counters.erase(type); pc->counters.erase(type);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_COUNTER_REMOVE);
myswprintf(textBuffer, dataManager.GetSysString(1618), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type)); myswprintf(textBuffer, dataManager.GetSysString(1618), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true; pc->is_highlighting = true;
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
...@@ -3029,6 +3166,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3029,6 +3166,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true; return true;
float sy; float sy;
if (ld != 0) { if (ld != 0) {
soundManager.PlaySoundEffect(SOUND_ATTACK);
mainGame->dField.attack_target = mainGame->dField.GetCard(cd, ld, sd); mainGame->dField.attack_target = mainGame->dField.GetCard(cd, ld, sd);
myswprintf(event_string, dataManager.GetSysString(1619), dataManager.GetName(mainGame->dField.attacker->code), myswprintf(event_string, dataManager.GetSysString(1619), dataManager.GetName(mainGame->dField.attacker->code),
dataManager.GetName(mainGame->dField.attack_target->code)); dataManager.GetName(mainGame->dField.attack_target->code));
...@@ -3043,6 +3181,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3043,6 +3181,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
else else
mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya))); mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
} else { } else {
soundManager.PlaySoundEffect(SOUND_DIRECT_ATTACK);
myswprintf(event_string, dataManager.GetSysString(1620), dataManager.GetName(mainGame->dField.attacker->code)); myswprintf(event_string, dataManager.GetSysString(1620), dataManager.GetName(mainGame->dField.attacker->code));
float xa = mainGame->dField.attacker->curPos.X; float xa = mainGame->dField.attacker->curPos.X;
float ya = mainGame->dField.attacker->curPos.Y; float ya = mainGame->dField.attacker->curPos.Y;
...@@ -3137,6 +3276,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3137,6 +3276,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
*pwbuf = 0; *pwbuf = 0;
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_COIN);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->lstLog->addItem(textBuffer); mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0); mainGame->logParam.push_back(0);
...@@ -3160,6 +3300,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3160,6 +3300,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
*pwbuf = 0; *pwbuf = 0;
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_DICE);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->lstLog->addItem(textBuffer); mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0); mainGame->logParam.push_back(0);
...@@ -3605,7 +3746,8 @@ void DuelClient::SendResponse() { ...@@ -3605,7 +3746,8 @@ void DuelClient::SendResponse() {
mainGame->btnShuffle->setVisible(false); mainGame->btnShuffle->setVisible(false);
break; break;
} }
case MSG_SELECT_CARD: { case MSG_SELECT_CARD:
case MSG_SELECT_UNSELECT_CARD: {
mainGame->dField.ClearSelect(); mainGame->dField.ClearSelect();
break; break;
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "duelclient.h" #include "duelclient.h"
#include "data_manager.h" #include "data_manager.h"
#include "image_manager.h" #include "image_manager.h"
#include "sound_manager.h"
#include "replay_mode.h" #include "replay_mode.h"
#include "single_mode.h" #include "single_mode.h"
#include "materials.h" #include "materials.h"
...@@ -40,6 +41,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -40,6 +41,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_FIRST: case BUTTON_FIRST:
case BUTTON_SECOND: { case BUTTON_SECOND: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->HideElement(mainGame->wFTSelect); mainGame->HideElement(mainGame->wFTSelect);
CTOS_TPResult cstr; CTOS_TPResult cstr;
cstr.res = BUTTON_SECOND - id; cstr.res = BUTTON_SECOND - id;
...@@ -49,6 +51,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -49,6 +51,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_START: { case BUTTON_REPLAY_START: {
if(!mainGame->dInfo.isReplay) if(!mainGame->dInfo.isReplay)
break; break;
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->btnReplayStart->setVisible(false); mainGame->btnReplayStart->setVisible(false);
mainGame->btnReplayPause->setVisible(true); mainGame->btnReplayPause->setVisible(true);
mainGame->btnReplayStep->setVisible(false); mainGame->btnReplayStep->setVisible(false);
...@@ -59,6 +62,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -59,6 +62,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_PAUSE: { case BUTTON_REPLAY_PAUSE: {
if(!mainGame->dInfo.isReplay) if(!mainGame->dInfo.isReplay)
break; break;
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->btnReplayStart->setVisible(true); mainGame->btnReplayStart->setVisible(true);
mainGame->btnReplayPause->setVisible(false); mainGame->btnReplayPause->setVisible(false);
mainGame->btnReplayStep->setVisible(true); mainGame->btnReplayStep->setVisible(true);
...@@ -69,16 +73,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -69,16 +73,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_STEP: { case BUTTON_REPLAY_STEP: {
if(!mainGame->dInfo.isReplay) if(!mainGame->dInfo.isReplay)
break; break;
soundManager.PlaySoundEffect(SOUND_BUTTON);
ReplayMode::Pause(false, true); ReplayMode::Pause(false, true);
break; break;
} }
case BUTTON_REPLAY_EXIT: { case BUTTON_REPLAY_EXIT: {
if(!mainGame->dInfo.isReplay) if(!mainGame->dInfo.isReplay)
break; break;
soundManager.PlaySoundEffect(SOUND_BUTTON);
ReplayMode::StopReplay(); ReplayMode::StopReplay();
break; break;
} }
case BUTTON_REPLAY_SWAP: { case BUTTON_REPLAY_SWAP: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
if(mainGame->dInfo.isReplay) if(mainGame->dInfo.isReplay)
ReplayMode::SwapField(); ReplayMode::SwapField();
else if (mainGame->dInfo.player_type == 7) else if (mainGame->dInfo.player_type == 7)
...@@ -88,24 +95,28 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -88,24 +95,28 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_REPLAY_UNDO: { case BUTTON_REPLAY_UNDO: {
if(!mainGame->dInfo.isReplay) if(!mainGame->dInfo.isReplay)
break; break;
soundManager.PlaySoundEffect(SOUND_BUTTON);
ReplayMode::Undo(); ReplayMode::Undo();
break; break;
} }
case BUTTON_REPLAY_SAVE: { case BUTTON_REPLAY_SAVE: {
if(mainGame->ebRSName->getText()[0] == 0) if(mainGame->ebRSName->getText()[0] == 0)
break; break;
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->actionParam = 1; mainGame->actionParam = 1;
mainGame->HideElement(mainGame->wReplaySave); mainGame->HideElement(mainGame->wReplaySave);
mainGame->replaySignal.Set(); mainGame->replaySignal.Set();
break; break;
} }
case BUTTON_REPLAY_CANCEL: { case BUTTON_REPLAY_CANCEL: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->actionParam = 0; mainGame->actionParam = 0;
mainGame->HideElement(mainGame->wReplaySave); mainGame->HideElement(mainGame->wReplaySave);
mainGame->replaySignal.Set(); mainGame->replaySignal.Set();
break; break;
} }
case BUTTON_LEAVE_GAME: { case BUTTON_LEAVE_GAME: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
if(mainGame->dInfo.isSingleMode) { if(mainGame->dInfo.isSingleMode) {
mainGame->singleSignal.SetNoWait(true); mainGame->singleSignal.SetNoWait(true);
SingleMode::StopPlay(false); SingleMode::StopPlay(false);
...@@ -114,6 +125,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -114,6 +125,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(mainGame->dInfo.player_type == 7) { if(mainGame->dInfo.player_type == 7) {
DuelClient::StopClient(); DuelClient::StopClient();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->stTip->setVisible(false); mainGame->stTip->setVisible(false);
mainGame->wCardImg->setVisible(false); mainGame->wCardImg->setVisible(false);
...@@ -137,6 +149,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -137,6 +149,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CHAIN_IGNORE: { case BUTTON_CHAIN_IGNORE: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->ignore_chain = mainGame->btnChainIgnore->isPressed(); mainGame->ignore_chain = mainGame->btnChainIgnore->isPressed();
mainGame->always_chain = false; mainGame->always_chain = false;
mainGame->chain_when_avail = false; mainGame->chain_when_avail = false;
...@@ -144,6 +157,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -144,6 +157,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CHAIN_ALWAYS: { case BUTTON_CHAIN_ALWAYS: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->always_chain = mainGame->btnChainAlways->isPressed(); mainGame->always_chain = mainGame->btnChainAlways->isPressed();
mainGame->ignore_chain = false; mainGame->ignore_chain = false;
mainGame->chain_when_avail = false; mainGame->chain_when_avail = false;
...@@ -151,6 +165,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -151,6 +165,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CHAIN_WHENAVAIL: { case BUTTON_CHAIN_WHENAVAIL: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->chain_when_avail = mainGame->btnChainWhenAvail->isPressed(); mainGame->chain_when_avail = mainGame->btnChainWhenAvail->isPressed();
mainGame->always_chain = false; mainGame->always_chain = false;
mainGame->ignore_chain = false; mainGame->ignore_chain = false;
...@@ -158,15 +173,18 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -158,15 +173,18 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_CANCEL_OR_FINISH: { case BUTTON_CANCEL_OR_FINISH: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
CancelOrFinish(); CancelOrFinish();
break; break;
} }
case BUTTON_MSG_OK: { case BUTTON_MSG_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->HideElement(mainGame->wMessage); mainGame->HideElement(mainGame->wMessage);
mainGame->actionSignal.Set(); mainGame->actionSignal.Set();
break; break;
} }
case BUTTON_YES: { case BUTTON_YES: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(mainGame->dInfo.curMsg) { switch(mainGame->dInfo.curMsg) {
case MSG_SELECT_YESNO: case MSG_SELECT_YESNO:
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
...@@ -200,6 +218,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -200,6 +218,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_NO: { case BUTTON_NO: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(mainGame->dInfo.curMsg) { switch(mainGame->dInfo.curMsg) {
case MSG_SELECT_YESNO: case MSG_SELECT_YESNO:
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
...@@ -252,6 +271,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -252,6 +271,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_OPTION_PREV: { case BUTTON_OPTION_PREV: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option--; selected_option--;
mainGame->btnOptionn->setVisible(true); mainGame->btnOptionn->setVisible(true);
if(selected_option == 0) if(selected_option == 0)
...@@ -260,6 +280,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -260,6 +280,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_OPTION_NEXT: { case BUTTON_OPTION_NEXT: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option++; selected_option++;
mainGame->btnOptionp->setVisible(true); mainGame->btnOptionp->setVisible(true);
if(selected_option == select_options.size() - 1) if(selected_option == select_options.size() - 1)
...@@ -268,6 +289,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -268,6 +289,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_OPTION_OK: { case BUTTON_OPTION_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
if (mainGame->dInfo.curMsg == MSG_SELECT_OPTION) { if (mainGame->dInfo.curMsg == MSG_SELECT_OPTION) {
DuelClient::SetResponseI(selected_option); DuelClient::SetResponseI(selected_option);
} else { } else {
...@@ -285,11 +307,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -285,11 +307,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_ANNUMBER_OK: { case BUTTON_ANNUMBER_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
DuelClient::SetResponseI(mainGame->cbANNumber->getSelected()); DuelClient::SetResponseI(mainGame->cbANNumber->getSelected());
mainGame->HideElement(mainGame->wANNumber, true); mainGame->HideElement(mainGame->wANNumber, true);
break; break;
} }
case BUTTON_ANCARD_OK: { case BUTTON_ANCARD_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
int sel = mainGame->lstANCard->getSelected(); int sel = mainGame->lstANCard->getSelected();
if(sel == -1) if(sel == -1)
break; break;
...@@ -440,6 +464,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -440,6 +464,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;
...@@ -662,6 +687,24 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -662,6 +687,24 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case MSG_SELECT_UNSELECT_CARD: {
command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10];
if (command_card->is_selected) {
command_card->is_selected = false;
if(command_card->controler)
mainGame->stCardPos[id - BUTTON_CARD_0]->setBackgroundColor(0xffd0d0d0);
else mainGame->stCardPos[id - BUTTON_CARD_0]->setBackgroundColor(0xffffffff);
} else {
command_card->is_selected = true;
mainGame->stCardPos[id - BUTTON_CARD_0]->setBackgroundColor(0xffffff00);
}
selected_cards.push_back(command_card);
if (selected_cards.size() > 0) {
SetResponseSelectedCards();
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wCardSelect, true);}
break;
}
case MSG_SELECT_SUM: { case MSG_SELECT_SUM: {
command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10]; command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10];
selected_cards.push_back(command_card); selected_cards.push_back(command_card);
...@@ -723,6 +766,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -723,6 +766,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->HideElement(mainGame->wCardSelect); mainGame->HideElement(mainGame->wCardSelect);
mainGame->actionSignal.Set(); mainGame->actionSignal.Set();
break; break;
} else if(mainGame->dInfo.curMsg == MSG_SELECT_UNSELECT_CARD){
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wCardSelect, true);
} else { } else {
mainGame->HideElement(mainGame->wCardSelect); mainGame->HideElement(mainGame->wCardSelect);
if(mainGame->dInfo.curMsg == MSG_SELECT_CHAIN && !chain_forced) if(mainGame->dInfo.curMsg == MSG_SELECT_CHAIN && !chain_forced)
...@@ -910,28 +957,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -910,28 +957,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.isTag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 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;
} }
...@@ -1317,6 +1342,22 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1317,6 +1342,22 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case MSG_SELECT_UNSELECT_CARD: {
if (!(hovered_location & 0xe) || !clicked_card || !clicked_card->is_selectable)
break;
if (clicked_card->is_selected) {
clicked_card->is_selected = false;
} else {
clicked_card->is_selected = true;
}
selected_cards.push_back(clicked_card);
if (selected_cards.size() > 0) {
ShowCancelOrFinishButton(0);
SetResponseSelectedCards();
DuelClient::SendResponse();
}
break;
}
case MSG_SELECT_COUNTER: { case MSG_SELECT_COUNTER: {
if (!clicked_card || !clicked_card->is_selectable) if (!clicked_card || !clicked_card->is_selectable)
break; break;
...@@ -1705,9 +1746,24 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1705,9 +1746,24 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
case irr::EET_GUI_EVENT: { case irr::EET_GUI_EVENT: {
s32 id = event.GUIEvent.Caller->getID(); s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType) { switch(event.GUIEvent.EventType) {
case irr::gui::EGET_ELEMENT_HOVERED: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX) {
mainGame->SetCursor(event.GUIEvent.Caller->isEnabled() ? ECI_IBEAM : ECI_NORMAL);
return true;
}
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX) {
mainGame->SetCursor(ECI_NORMAL);
return true;
}
break;
}
case irr::gui::EGET_BUTTON_CLICKED: { case irr::gui::EGET_BUTTON_CLICKED: {
switch(id) { switch(id) {
case BUTTON_CLEAR_LOG: { case BUTTON_CLEAR_LOG: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->lstLog->clear(); mainGame->lstLog->clear();
mainGame->logParam.clear(); mainGame->logParam.clear();
return true; return true;
...@@ -1723,6 +1779,20 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1723,6 +1779,20 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true; return true;
break; break;
} }
case CHECKBOX_ENABLE_MUSIC: {
if(!mainGame->chkEnableMusic->isChecked())
soundManager.StopBGM();
return true;
break;
}
case CHECKBOX_DISABLE_CHAT: {
bool show = mainGame->is_building ? false : !mainGame->chkIgnore1->isChecked();
mainGame->wChat->setVisible(show);
if(!show)
mainGame->ClearChatMsg();
return true;
break;
}
} }
break; break;
} }
...@@ -1755,11 +1825,41 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1755,11 +1825,41 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
case irr::gui::EGET_SCROLL_BAR_CHANGED: { case irr::gui::EGET_SCROLL_BAR_CHANGED: {
switch(id) { switch(id) {
case SCROLL_CARDTEXT: { case SCROLL_CARDTEXT: {
if(!mainGame->scrCardText->isVisible()) {
return true;
break;
}
u32 pos = mainGame->scrCardText->getPos(); u32 pos = mainGame->scrCardText->getPos();
mainGame->SetStaticText(mainGame->stText, mainGame->stText->getRelativePosition().getWidth() - 25, mainGame->textFont, mainGame->showingtext, pos); mainGame->SetStaticText(mainGame->stText, mainGame->stText->getRelativePosition().getWidth() - 25, mainGame->textFont, mainGame->showingtext, pos);
return true; return true;
break; break;
} }
case SCROLL_VOLUME: {
mainGame->gameConf.sound_volume = (double)mainGame->scrSoundVolume->getPos() / 100;
mainGame->gameConf.music_volume = (double)mainGame->scrMusicVolume->getPos() / 100;
soundManager.SetSoundVolume(mainGame->gameConf.sound_volume);
soundManager.SetMusicVolume(mainGame->gameConf.music_volume);
return true;
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; break;
} }
...@@ -2177,6 +2277,17 @@ void ClientField::CancelOrFinish() { ...@@ -2177,6 +2277,17 @@ void ClientField::CancelOrFinish() {
} }
break; break;
} }
case MSG_SELECT_UNSELECT_CARD: {
if (select_cancelable) {
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) {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "image_manager.h" #include "image_manager.h"
#include "data_manager.h" #include "data_manager.h"
#include "deck_manager.h" #include "deck_manager.h"
#include "sound_manager.h"
#include "replay.h" #include "replay.h"
#include "materials.h" #include "materials.h"
#include "duelclient.h" #include "duelclient.h"
...@@ -14,7 +15,7 @@ ...@@ -14,7 +15,7 @@
#include <dirent.h> #include <dirent.h>
#endif #endif
const unsigned short PRO_VERSION = 0x1342; const unsigned short PRO_VERSION = 0x1343;
namespace ygo { namespace ygo {
...@@ -33,7 +34,8 @@ bool Game::Initialize() { ...@@ -33,7 +34,8 @@ bool Game::Initialize() {
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device)
return false; return false;
linePattern = 0x0f0f; linePatternD3D = 0;
linePatternGL = 0x0f0f;
waitFrame = 0; waitFrame = 0;
signalFrame = 0; signalFrame = 0;
showcard = 0; showcard = 0;
...@@ -264,7 +266,7 @@ bool Game::Initialize() { ...@@ -264,7 +266,7 @@ bool Game::Initialize() {
//system //system
irr::gui::IGUITab* tabSystem = wInfos->addTab(dataManager.GetSysString(1273)); irr::gui::IGUITab* tabSystem = wInfos->addTab(dataManager.GetSysString(1273));
posY = 20; posY = 20;
chkIgnore1 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1290)); chkIgnore1 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_DISABLE_CHAT, dataManager.GetSysString(1290));
chkIgnore1->setChecked(gameConf.chkIgnore1 != 0); chkIgnore1->setChecked(gameConf.chkIgnore1 != 0);
posY += 30; posY += 30;
chkIgnore2 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1291)); chkIgnore2 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1291));
...@@ -281,6 +283,27 @@ bool Game::Initialize() { ...@@ -281,6 +283,27 @@ bool Game::Initialize() {
posY += 30; posY += 30;
chkAutoSearch = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_AUTO_SEARCH, dataManager.GetSysString(1358)); chkAutoSearch = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_AUTO_SEARCH, dataManager.GetSysString(1358));
chkAutoSearch->setChecked(gameConf.auto_search_limit >= 0); chkAutoSearch->setChecked(gameConf.auto_search_limit >= 0);
posY += 30;
chkEnableSound = env->addCheckBox(gameConf.enable_sound, rect<s32>(posX, posY, posX + 120, posY + 25), tabSystem, -1, dataManager.GetSysString(1279));
chkEnableSound->setChecked(gameConf.enable_sound);
scrSoundVolume = env->addScrollBar(true, rect<s32>(posX + 126, posY + 4, posX + 260, posY + 21), tabSystem, SCROLL_VOLUME);
scrSoundVolume->setMax(100);
scrSoundVolume->setMin(0);
scrSoundVolume->setPos(gameConf.sound_volume * 100);
scrSoundVolume->setLargeStep(1);
scrSoundVolume->setSmallStep(1);
posY += 30;
chkEnableMusic = env->addCheckBox(gameConf.enable_music, rect<s32>(posX, posY, posX + 120, posY + 25), tabSystem, CHECKBOX_ENABLE_MUSIC, dataManager.GetSysString(1280));
chkEnableMusic->setChecked(gameConf.enable_music);
scrMusicVolume = env->addScrollBar(true, rect<s32>(posX + 126, posY + 4, posX + 260, posY + 21), tabSystem, SCROLL_VOLUME);
scrMusicVolume->setMax(100);
scrMusicVolume->setMin(0);
scrMusicVolume->setPos(gameConf.music_volume * 100);
scrMusicVolume->setLargeStep(1);
scrMusicVolume->setSmallStep(1);
posY += 30;
chkMusicMode = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1281));
chkMusicMode->setChecked(gameConf.music_mode != 0);
// //
wHand = env->addWindow(rect<s32>(500, 450, 825, 605), false, L""); wHand = env->addWindow(rect<s32>(500, 450, 825, 605), false, L"");
wHand->getCloseButton()->setVisible(false); wHand->getCloseButton()->setVisible(false);
...@@ -511,7 +534,7 @@ bool Game::Initialize() { ...@@ -511,7 +534,7 @@ bool Game::Initialize() {
ebCardName->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); ebCardName->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
btnEffectFilter = env->addButton(rect<s32>(345, 20 + 50 / 6, 390, 60 + 75 / 6), wFilter, BUTTON_EFFECT_FILTER, dataManager.GetSysString(1326)); btnEffectFilter = env->addButton(rect<s32>(345, 20 + 50 / 6, 390, 60 + 75 / 6), wFilter, BUTTON_EFFECT_FILTER, dataManager.GetSysString(1326));
btnStartFilter = env->addButton(rect<s32>(205, 80 + 125 / 6, 390, 100 + 125 / 6), wFilter, BUTTON_START_FILTER, dataManager.GetSysString(1327)); btnStartFilter = env->addButton(rect<s32>(205, 80 + 125 / 6, 390, 100 + 125 / 6), wFilter, BUTTON_START_FILTER, dataManager.GetSysString(1327));
if(mainGame->gameConf.separate_clear_button) { if(gameConf.separate_clear_button) {
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));
} }
...@@ -639,6 +662,18 @@ bool Game::Initialize() { ...@@ -639,6 +662,18 @@ bool Game::Initialize() {
stTip->setVisible(false); stTip->setVisible(false);
device->setEventReceiver(&menuHandler); device->setEventReceiver(&menuHandler);
LoadConfig(); LoadConfig();
if(!soundManager.Init()) {
chkEnableSound->setChecked(false);
chkEnableSound->setEnabled(false);
chkEnableSound->setVisible(false);
chkEnableMusic->setChecked(false);
chkEnableMusic->setEnabled(false);
chkEnableMusic->setVisible(false);
scrSoundVolume->setVisible(false);
scrMusicVolume->setVisible(false);
chkMusicMode->setEnabled(false);
chkMusicMode->setVisible(false);
}
env->getSkin()->setFont(guiFont); env->getSkin()->setFont(guiFont);
env->setFocus(wMainMenu); env->setFocus(wMainMenu);
for (u32 i = 0; i < EGDC_COUNT; ++i) { for (u32 i = 0; i < EGDC_COUNT; ++i) {
...@@ -666,15 +701,23 @@ void Game::MainLoop() { ...@@ -666,15 +701,23 @@ void Game::MainLoop() {
int fps = 0; int fps = 0;
int cur_time = 0; int cur_time = 0;
while(device->run()) { while(device->run()) {
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));
gMutex.Lock(); gMutex.Lock();
if(dInfo.isStarted) { if(dInfo.isStarted || dInfo.isReplaySkiping) {
if(dInfo.isFinished && showcardcode == 1)
soundManager.PlayBGM(BGM_WIN);
else if(dInfo.isFinished && (showcardcode == 2 || showcardcode == 3))
soundManager.PlayBGM(BGM_LOSE);
else if(dInfo.lp[0] > 0 && dInfo.lp[0] <= dInfo.lp[1] / 2)
soundManager.PlayBGM(BGM_DISADVANTAGE);
else if(dInfo.lp[0] > 0 && dInfo.lp[0] >= dInfo.lp[1] * 2)
soundManager.PlayBGM(BGM_ADVANTAGE);
else
soundManager.PlayBGM(BGM_DUEL);
DrawBackImage(imageManager.tBackGround); DrawBackImage(imageManager.tBackGround);
DrawBackGround(); DrawBackGround();
DrawCards(); DrawCards();
...@@ -683,9 +726,11 @@ void Game::MainLoop() { ...@@ -683,9 +726,11 @@ void Game::MainLoop() {
driver->setMaterial(irr::video::IdentityMaterial); driver->setMaterial(irr::video::IdentityMaterial);
driver->clearZBuffer(); driver->clearZBuffer();
} else if(is_building) { } else if(is_building) {
soundManager.PlayBGM(BGM_DECK);
DrawBackImage(imageManager.tBackGround_deck); DrawBackImage(imageManager.tBackGround_deck);
DrawDeckBd(); DrawDeckBd();
} else { } else {
soundManager.PlayBGM(BGM_MENU);
DrawBackImage(imageManager.tBackGround_menu); DrawBackImage(imageManager.tBackGround_menu);
} }
DrawGUI(); DrawGUI();
...@@ -729,7 +774,7 @@ void Game::MainLoop() { ...@@ -729,7 +774,7 @@ void Game::MainLoop() {
} }
} }
DuelClient::StopClient(true); DuelClient::StopClient(true);
if(mainGame->dInfo.isSingleMode) if(dInfo.isSingleMode)
SingleMode::StopPlay(true); SingleMode::StopPlay(true);
#ifdef _WIN32 #ifdef _WIN32
Sleep(500); Sleep(500);
...@@ -754,6 +799,8 @@ void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cH ...@@ -754,6 +799,8 @@ void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cH
SetStaticText(pControl, cWidth, font, text); SetStaticText(pControl, cWidth, font, text);
if(font->getDimension(dataManager.strBuffer).Height <= cHeight) { if(font->getDimension(dataManager.strBuffer).Height <= cHeight) {
scrCardText->setVisible(false); scrCardText->setVisible(false);
if(env->hasFocus(scrCardText))
env->removeFocus(scrCardText);
return; return;
} }
SetStaticText(pControl, cWidth-25, font, text); SetStaticText(pControl, cWidth-25, font, text);
...@@ -1002,6 +1049,11 @@ void Game::LoadConfig() { ...@@ -1002,6 +1049,11 @@ void Game::LoadConfig() {
gameConf.chkIgnoreDeckChanges = 0; gameConf.chkIgnoreDeckChanges = 0;
gameConf.defaultOT = 1; gameConf.defaultOT = 1;
gameConf.enable_bot_mode = 0; gameConf.enable_bot_mode = 0;
gameConf.enable_sound = true;
gameConf.sound_volume = 0.5;
gameConf.enable_music = true;
gameConf.music_volume = 0.5;
gameConf.music_mode = 1;
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
sscanf(linebuf, "%s = %s", strbuf, valbuf); sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) { if(!strcmp(strbuf, "antialias")) {
...@@ -1064,6 +1116,16 @@ void Game::LoadConfig() { ...@@ -1064,6 +1116,16 @@ void Game::LoadConfig() {
gameConf.defaultOT = atoi(valbuf); gameConf.defaultOT = atoi(valbuf);
} else if(!strcmp(strbuf, "enable_bot_mode")) { } else if(!strcmp(strbuf, "enable_bot_mode")) {
gameConf.enable_bot_mode = atoi(valbuf); gameConf.enable_bot_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "sound_volume")) {
gameConf.sound_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "enable_music")) {
gameConf.enable_music = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "music_volume")) {
gameConf.music_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "music_mode")) {
gameConf.music_mode = atoi(valbuf);
} else { } else {
// options allowing multiple words // options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf); sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
...@@ -1106,24 +1168,34 @@ void Game::SaveConfig() { ...@@ -1106,24 +1168,34 @@ void Game::SaveConfig() {
BufferIO::EncodeUTF8(gameConf.lastport, linebuf); BufferIO::EncodeUTF8(gameConf.lastport, linebuf);
fprintf(fp, "lastport = %s\n", linebuf); fprintf(fp, "lastport = %s\n", linebuf);
//settings //settings
fprintf(fp, "automonsterpos = %d\n", ((mainGame->chkMAutoPos->isChecked()) ? 1 : 0)); fprintf(fp, "automonsterpos = %d\n", (chkMAutoPos->isChecked() ? 1 : 0));
fprintf(fp, "autospellpos = %d\n", ((mainGame->chkSTAutoPos->isChecked()) ? 1 : 0)); fprintf(fp, "autospellpos = %d\n", (chkSTAutoPos->isChecked() ? 1 : 0));
fprintf(fp, "randompos = %d\n", ((mainGame->chkRandomPos->isChecked()) ? 1 : 0)); fprintf(fp, "randompos = %d\n", (chkRandomPos->isChecked() ? 1 : 0));
fprintf(fp, "autochain = %d\n", ((mainGame->chkAutoChain->isChecked()) ? 1 : 0)); fprintf(fp, "autochain = %d\n", (chkAutoChain->isChecked() ? 1 : 0));
fprintf(fp, "waitchain = %d\n", ((mainGame->chkWaitChain->isChecked()) ? 1 : 0)); fprintf(fp, "waitchain = %d\n", (chkWaitChain->isChecked() ? 1 : 0));
fprintf(fp, "mute_opponent = %d\n", ((mainGame->chkIgnore1->isChecked()) ? 1 : 0)); fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0));
fprintf(fp, "mute_spectators = %d\n", ((mainGame->chkIgnore2->isChecked()) ? 1 : 0)); fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0));
fprintf(fp, "hide_setname = %d\n", ((mainGame->chkHideSetname->isChecked()) ? 1 : 0)); fprintf(fp, "hide_setname = %d\n", (chkHideSetname->isChecked() ? 1 : 0));
fprintf(fp, "hide_hint_button = %d\n", ((mainGame->chkHideHintButton->isChecked()) ? 1 : 0)); fprintf(fp, "hide_hint_button = %d\n", (chkHideHintButton->isChecked() ? 1 : 0));
fprintf(fp, "#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons\n"); fprintf(fp, "#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons\n");
fprintf(fp, "control_mode = %d\n", gameConf.control_mode); fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell); fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell);
fprintf(fp, "separate_clear_button = %d\n", gameConf.separate_clear_button); fprintf(fp, "separate_clear_button = %d\n", gameConf.separate_clear_button);
fprintf(fp, "#auto_search_limit >= 0: Start search automatically when the user enters N chars\n"); fprintf(fp, "#auto_search_limit >= 0: Start search automatically when the user enters N chars\n");
fprintf(fp, "auto_search_limit = %d\n", gameConf.auto_search_limit); fprintf(fp, "auto_search_limit = %d\n", gameConf.auto_search_limit);
fprintf(fp, "ignore_deck_changes = %d\n", ((mainGame->chkIgnoreDeckChanges->isChecked()) ? 1 : 0)); fprintf(fp, "ignore_deck_changes = %d\n", (chkIgnoreDeckChanges->isChecked() ? 1 : 0));
fprintf(fp, "default_ot = %d\n", gameConf.defaultOT); fprintf(fp, "default_ot = %d\n", gameConf.defaultOT);
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode); fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0));
fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0));
fprintf(fp, "#Volume of sound and music, between 0 and 100\n");
int vol = gameConf.sound_volume * 100;
if(vol < 0) vol = 0; else if(vol > 100) vol = 100;
fprintf(fp, "sound_volume = %d\n", vol);
vol = gameConf.music_volume * 100;
if(vol < 0) vol = 0; else if(vol > 100) vol = 100;
fprintf(fp, "music_volume = %d\n", vol);
fprintf(fp, "music_mode = %d\n", (chkMusicMode->isChecked() ? 1 : 0));
fclose(fp); fclose(fp);
} }
void Game::ShowCardInfo(int code) { void Game::ShowCardInfo(int code) {
...@@ -1138,7 +1210,7 @@ void Game::ShowCardInfo(int code) { ...@@ -1138,7 +1210,7 @@ void Game::ShowCardInfo(int code) {
else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code); else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code);
stName->setText(formatBuffer); stName->setText(formatBuffer);
int offset = 0; int offset = 0;
if(!mainGame->chkHideSetname->isChecked()) { if(!chkHideSetname->isChecked()) {
unsigned long long sc = cd.setcode; unsigned long long sc = cd.setcode;
if(cd.alias) { if(cd.alias) {
auto aptr = dataManager._datas.find(cd.alias); auto aptr = dataManager._datas.find(cd.alias);
...@@ -1217,22 +1289,26 @@ void Game::AddChatMsg(wchar_t* msg, int player) { ...@@ -1217,22 +1289,26 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 1: //from client case 1: //from client
soundManager.PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(dInfo.clientname); chatMsg[0].append(dInfo.clientname);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 2: //host tag case 2: //host tag
soundManager.PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(dInfo.hostname_tag); chatMsg[0].append(dInfo.hostname_tag);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 3: //client tag case 3: //client tag
soundManager.PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(dInfo.clientname_tag); chatMsg[0].append(dInfo.clientname_tag);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 7: //local name case 7: //local name
chatMsg[0].append(mainGame->ebNickName->getText()); chatMsg[0].append(ebNickName->getText());
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
break; break;
case 8: //system custom message, no prefix. case 8: //system custom message, no prefix.
soundManager.PlaySoundEffect(SOUND_CHAT);
chatMsg[0].append(L"[System]: "); chatMsg[0].append(L"[System]: ");
break; break;
case 9: //error message case 9: //error message
...@@ -1244,12 +1320,17 @@ void Game::AddChatMsg(wchar_t* msg, int player) { ...@@ -1244,12 +1320,17 @@ 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) {
wchar_t wbuf[1024]; wchar_t wbuf[1024];
BufferIO::DecodeUTF8(msg, wbuf); BufferIO::DecodeUTF8(msg, wbuf);
mainGame->AddChatMsg(wbuf, 9); AddChatMsg(wbuf, 9);
} }
if (enable_log & 0x2) { if (enable_log & 0x2) {
FILE* fp = fopen("error.log", "at"); FILE* fp = fopen("error.log", "at");
...@@ -1265,12 +1346,12 @@ void Game::AddDebugMsg(char* msg) ...@@ -1265,12 +1346,12 @@ void Game::AddDebugMsg(char* msg)
} }
void Game::ClearTextures() { void Game::ClearTextures() {
matManager.mCard.setTexture(0, 0); matManager.mCard.setTexture(0, 0);
mainGame->imgCard->setImage(imageManager.tCover[0]); imgCard->setImage(imageManager.tCover[0]);
mainGame->btnPSAU->setImage(); btnPSAU->setImage();
mainGame->btnPSDU->setImage(); btnPSDU->setImage();
for(int i=0; i<=4; ++i) { for(int i=0; i<=4; ++i) {
mainGame->btnCardSelect[i]->setImage(); btnCardSelect[i]->setImage();
mainGame->btnCardDisplay[i]->setImage(); btnCardDisplay[i]->setImage();
} }
imageManager.ClearTexture(); imageManager.ClearTexture();
} }
...@@ -1341,5 +1422,11 @@ void Game::FlashWindow() { ...@@ -1341,5 +1422,11 @@ void Game::FlashWindow() {
FlashWindowEx(&fi); FlashWindowEx(&fi);
#endif #endif
} }
void Game::SetCursor(ECURSOR_ICON icon) {
ICursorControl* cursor = mainGame->device->getCursorControl();
if(cursor->getActiveIcon() != icon) {
cursor->setActiveIcon(icon);
}
}
} }
...@@ -42,10 +42,16 @@ struct Config { ...@@ -42,10 +42,16 @@ struct Config {
int chkIgnoreDeckChanges; int chkIgnoreDeckChanges;
int defaultOT; int defaultOT;
int enable_bot_mode; int enable_bot_mode;
bool enable_sound;
bool enable_music;
double sound_volume;
double music_volume;
int music_mode;
}; };
struct DuelInfo { struct DuelInfo {
bool isStarted; bool isStarted;
bool isFinished;
bool isReplay; bool isReplay;
bool isReplaySkiping; bool isReplaySkiping;
bool isFirst; bool isFirst;
...@@ -104,6 +110,7 @@ public: ...@@ -104,6 +110,7 @@ public:
void RefreshSingleplay(); void RefreshSingleplay();
void RefreshBot(); void RefreshBot();
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);
...@@ -124,6 +131,7 @@ public: ...@@ -124,6 +131,7 @@ public:
void SaveConfig(); void SaveConfig();
void ShowCardInfo(int code); void ShowCardInfo(int code);
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();
...@@ -138,6 +146,7 @@ public: ...@@ -138,6 +146,7 @@ public:
void SetWindowsIcon(); void SetWindowsIcon();
void FlashWindow(); void FlashWindow();
void SetCursor(ECURSOR_ICON icon);
Mutex gMutex; Mutex gMutex;
Mutex gBuffer; Mutex gBuffer;
...@@ -159,7 +168,8 @@ public: ...@@ -159,7 +168,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 actionParam; int actionParam;
...@@ -219,6 +229,9 @@ public: ...@@ -219,6 +229,9 @@ public:
irr::gui::IGUIStaticText* stSetName; irr::gui::IGUIStaticText* stSetName;
irr::gui::IGUIStaticText* stText; irr::gui::IGUIStaticText* stText;
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;
...@@ -228,9 +241,11 @@ public: ...@@ -228,9 +241,11 @@ public:
irr::gui::IGUICheckBox* chkHideHintButton; irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkIgnoreDeckChanges; irr::gui::IGUICheckBox* chkIgnoreDeckChanges;
irr::gui::IGUICheckBox* chkAutoSearch; irr::gui::IGUICheckBox* chkAutoSearch;
irr::gui::IGUIListBox* lstLog; irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUIButton* btnClearLog; irr::gui::IGUICheckBox* chkEnableMusic;
irr::gui::IGUIButton* btnSaveLog; irr::gui::IGUIScrollBar* scrSoundVolume;
irr::gui::IGUIScrollBar* scrMusicVolume;
irr::gui::IGUICheckBox* chkMusicMode;
//main menu //main menu
irr::gui::IGUIWindow* wMainMenu; irr::gui::IGUIWindow* wMainMenu;
irr::gui::IGUIButton* btnLanMode; irr::gui::IGUIButton* btnLanMode;
...@@ -596,6 +611,11 @@ extern Game* mainGame; ...@@ -596,6 +611,11 @@ extern Game* mainGame;
#define BUTTON_LOAD_SINGLEPLAY 351 #define BUTTON_LOAD_SINGLEPLAY 351
#define BUTTON_CANCEL_SINGLEPLAY 352 #define BUTTON_CANCEL_SINGLEPLAY 352
#define CHECKBOX_AUTO_SEARCH 360 #define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_ENABLE_SOUND 361
#define CHECKBOX_ENABLE_MUSIC 362
#define SCROLL_VOLUME 363
#define CHECKBOX_DISABLE_CHAT 364
#define COMBOBOX_SORTTYPE 370 #define COMBOBOX_SORTTYPE 370
#define COMBOBOX_LIMIT 371 #define COMBOBOX_LIMIT 371
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "replay_mode.h" #include "replay_mode.h"
#include "single_mode.h" #include "single_mode.h"
#include "image_manager.h" #include "image_manager.h"
#include "sound_manager.h"
#include "game.h" #include "game.h"
namespace ygo { namespace ygo {
...@@ -26,6 +27,8 @@ void UpdateDeck() { ...@@ -26,6 +27,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;
...@@ -40,6 +43,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -40,6 +43,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
switch(event.GUIEvent.EventType) { switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: { case irr::gui::EGET_BUTTON_CLICKED: {
if(id < 110)
soundManager.PlaySoundEffect(SOUND_MENU);
else
soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(id) { switch(id) {
case BUTTON_MODE_EXIT: { case BUTTON_MODE_EXIT: {
mainGame->device->closeDevice(); mainGame->device->closeDevice();
...@@ -74,6 +81,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -74,6 +81,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int status = evutil_getaddrinfo(hostname, port, &hints, &answer); int status = evutil_getaddrinfo(hostname, port, &hints, &answer);
if(status != 0) { if(status != 0) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
...@@ -493,49 +501,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -493,49 +501,6 @@ bool MenuHandler::OnEvent(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];
if(mainGame->dInfo.isStarted) {
if(mainGame->dInfo.player_type < 7) {
if(mainGame->dInfo.isTag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 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;
}
default: break;
}
break;
}
case irr::EET_KEY_INPUT_EVENT: {
switch(event.KeyInput.Key) {
case irr::KEY_KEY_R: {
if(!event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->textFont->setTransparency(true);
break;
}
case irr::KEY_ESCAPE: {
if(!mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->device->minimizeWindow();
break;
}
default: break; default: break;
} }
break; break;
......
...@@ -6,18 +6,36 @@ project "ygopro" ...@@ -6,18 +6,36 @@ project "ygopro"
files { "**.cpp", "**.cc", "**.c", "**.h" } files { "**.cpp", "**.cc", "**.c", "**.h" }
excludes "lzma/**" excludes "lzma/**"
includedirs { "../ocgcore" } includedirs { "../ocgcore" }
links { "ocgcore", "clzma", "Irrlicht", "freetype", "sqlite3", "lua" , "event"} links { "ocgcore", "clzma", "Irrlicht", "freetype", "sqlite3", "lua" , "event" }
configuration "windows" configuration "windows"
files "ygopro.rc" files "ygopro.rc"
excludes "CGUIButton.cpp" excludes "CGUIButton.cpp"
includedirs { "../irrlicht/include", "../freetype/include", "../event/include", "../sqlite3" } includedirs { "../irrlicht/include", "../freetype/include", "../event/include", "../sqlite3" }
if USE_IRRKLANG then
defines { "YGOPRO_USE_IRRKLANG" }
links { "irrKlang" }
includedirs { "../irrklang/include" }
libdirs { "../irrklang/lib/Win32-visualStudio" }
if IRRKLANG_PRO then
defines { "IRRKLANG_STATIC" }
links { "ikpmp3" }
end
end
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" } links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" }
configuration {"windows", "not vs*"} configuration {"windows", "not vs*"}
includedirs { "/mingw/include/irrlicht", "/mingw/include/freetype2" } includedirs { "/mingw/include/irrlicht", "/mingw/include/freetype2" }
configuration "not vs*" configuration "not vs*"
buildoptions { "-std=gnu++0x", "-fno-rtti" } buildoptions { "-std=gnu++0x", "-fno-rtti" }
configuration "not windows" configuration "not windows"
includedirs { "/usr/include/lua", "/usr/include/lua5.2", "/usr/include/lua/5.2", "/usr/include/irrlicht", "/usr/include/freetype2" } includedirs { "/usr/include/lua", "/usr/include/lua5.3", "/usr/include/lua/5.3", "/usr/include/irrlicht", "/usr/include/freetype2" }
excludes { "COSOperator.*" } excludes { "COSOperator.*" }
links { "event_pthreads", "GL", "dl", "pthread" } links { "event_pthreads", "GL", "dl", "pthread" }
configuration "linux"
if USE_IRRKLANG then
defines { "YGOPRO_USE_IRRKLANG" }
links { "IrrKlang" }
linkoptions{ "-Wl,-rpath=./irrklang/bin/linux-gcc-64/" }
libdirs { "../irrklang/bin/linux-gcc-64" }
includedirs { "../irrklang/include" }
end
...@@ -78,6 +78,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -78,6 +78,7 @@ int ReplayMode::ReplayThread(void* param) {
return 0; return 0;
} }
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplay = true; mainGame->dInfo.isReplay = true;
mainGame->dInfo.isReplaySkiping = (skip_turn > 0); mainGame->dInfo.isReplaySkiping = (skip_turn > 0);
char engineBuffer[0x1000]; char engineBuffer[0x1000];
...@@ -122,6 +123,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -122,6 +123,7 @@ int ReplayMode::ReplayThread(void* param) {
if(step == 0) { if(step == 0) {
Pause(true, false); Pause(true, false);
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
...@@ -236,6 +238,7 @@ void ReplayMode::EndDuel() { ...@@ -236,6 +238,7 @@ void ReplayMode::EndDuel() {
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.isReplay = false; mainGame->dInfo.isReplay = false;
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
...@@ -253,6 +256,7 @@ void ReplayMode::EndDuel() { ...@@ -253,6 +256,7 @@ void ReplayMode::EndDuel() {
void ReplayMode::Restart(bool refresh) { void ReplayMode::Restart(bool refresh) {
end_duel(pduel); end_duel(pduel);
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dField.Clear(); mainGame->dField.Clear();
//mainGame->device->setEventReceiver(&mainGame->dField); //mainGame->device->setEventReceiver(&mainGame->dField);
cur_replay.Rewind(); cur_replay.Rewind();
...@@ -265,6 +269,7 @@ void ReplayMode::Restart(bool refresh) { ...@@ -265,6 +269,7 @@ void ReplayMode::Restart(bool refresh) {
if(refresh) { if(refresh) {
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
//mainGame->dInfo.isReplay = true; //mainGame->dInfo.isReplay = true;
} }
skip_turn = 0; skip_turn = 0;
...@@ -378,6 +383,15 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -378,6 +383,15 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
pbuf += count * 8; pbuf += count * 8;
return ReadReplayResponse(); return ReadReplayResponse();
} }
case MSG_SELECT_UNSELECT_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
return ReadReplayResponse();
}
case MSG_SELECT_CHAIN: { case MSG_SELECT_CHAIN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
...@@ -833,6 +847,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -833,6 +847,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(skip_step == 0) { if(skip_step == 0) {
Pause(true, false); Pause(true, false);
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
......
...@@ -27,17 +27,10 @@ void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) { ...@@ -27,17 +27,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) {
...@@ -700,6 +693,34 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -700,6 +693,34 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1; return 1;
} }
case MSG_SELECT_UNSELECT_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
count = BufferIO::ReadInt8(pbuf);
int c/*, l, s, ss, code*/;
for (int i = 0; i < count; ++i) {
pbufw = pbuf;
/*code = */BufferIO::ReadInt32(pbuf);
c = BufferIO::ReadInt8(pbuf);
/*l = */BufferIO::ReadInt8(pbuf);
/*s = */BufferIO::ReadInt8(pbuf);
/*ss = */BufferIO::ReadInt8(pbuf);
if (c != player) BufferIO::WriteInt32(pbufw, 0);
}
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
pbufw = pbuf;
/*code = */BufferIO::ReadInt32(pbuf);
c = BufferIO::ReadInt8(pbuf);
/*l = */BufferIO::ReadInt8(pbuf);
/*s = */BufferIO::ReadInt8(pbuf);
/*ss = */BufferIO::ReadInt8(pbuf);
if (c != player) BufferIO::WriteInt32(pbufw, 0);
}
WaitforResponse(player);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
}
case MSG_SELECT_CHAIN: { case MSG_SELECT_CHAIN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
......
...@@ -97,6 +97,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -97,6 +97,7 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.isFirst = true; mainGame->dInfo.isFirst = true;
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isSingleMode = true; mainGame->dInfo.isSingleMode = true;
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
...@@ -150,6 +151,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -150,6 +151,7 @@ int SingleMode::SinglePlayThread(void* param) {
if(!is_closing) { if(!is_closing) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.isSingleMode = false; mainGame->dInfo.isSingleMode = false;
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
...@@ -271,6 +273,19 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -271,6 +273,19 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
} }
break; break;
} }
case MSG_SELECT_UNSELECT_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
if(!DuelClient::ClientAnalyze(offset, pbuf - offset)) {
mainGame->singleSignal.Reset();
mainGame->singleSignal.Wait();
}
break;
}
case MSG_SELECT_CHAIN: { case MSG_SELECT_CHAIN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
......
#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
...@@ -24,8 +24,9 @@ void TagDuel::Chat(DuelPlayer* dp, void* pdata, int len) { ...@@ -24,8 +24,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) {
...@@ -630,6 +631,34 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -630,6 +631,34 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1; return 1;
} }
case MSG_SELECT_UNSELECT_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
count = BufferIO::ReadInt8(pbuf);
int c/*, l, s, ss, code*/;
for (int i = 0; i < count; ++i) {
pbufw = pbuf;
/*code = */BufferIO::ReadInt32(pbuf);
c = BufferIO::ReadInt8(pbuf);
/*l = */BufferIO::ReadInt8(pbuf);
/*s = */BufferIO::ReadInt8(pbuf);
/*ss = */BufferIO::ReadInt8(pbuf);
if (c != player) BufferIO::WriteInt32(pbufw, 0);
}
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
pbufw = pbuf;
/*code = */BufferIO::ReadInt32(pbuf);
c = BufferIO::ReadInt8(pbuf);
/*l = */BufferIO::ReadInt8(pbuf);
/*s = */BufferIO::ReadInt8(pbuf);
/*ss = */BufferIO::ReadInt8(pbuf);
if (c != player) BufferIO::WriteInt32(pbufw, 0);
}
WaitforResponse(player);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
}
case MSG_SELECT_CHAIN: { case MSG_SELECT_CHAIN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
......
Subproject commit 35463ba465a0926f22f13340bb9d0fd5e5443e85 Subproject commit 3c33920e28aee1361ddcfc805bf992247195b43d
Subproject commit 47a1517ad08adc9ef37933cc2388b57d38ab277f Subproject commit 63aa6c77dae13e742d43f92528ca7a84ec80b7d8
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
...@@ -302,7 +302,10 @@ ...@@ -302,7 +302,10 @@
!system 1276 自动排列连锁顺序 !system 1276 自动排列连锁顺序
!system 1277 没有可连锁的卡时延迟回应 !system 1277 没有可连锁的卡时延迟回应
!system 1278 自动选择魔陷卡片位置 !system 1278 自动选择魔陷卡片位置
!system 1290 忽略对方发言 !system 1279 开启音效
!system 1280 开启音乐
!system 1281 按场景切换音乐
!system 1290 禁用聊天功能
!system 1291 忽略观战者发言 !system 1291 忽略观战者发言
!system 1292 忽略时点 !system 1292 忽略时点
!system 1293 显示时点 !system 1293 显示时点
...@@ -528,6 +531,7 @@ ...@@ -528,6 +531,7 @@
!counter 0x1045 鳞粉指示物 !counter 0x1045 鳞粉指示物
!counter 0x46 指示物(刚鬼死斗) !counter 0x46 指示物(刚鬼死斗)
!counter 0x47 指示物(限制代码) !counter 0x47 指示物(限制代码)
!counter 0x48 指示物(连接死亡炮塔)
#setnames, using tab for comment #setnames, using tab for comment
!setname 0x1 正义盟军 AOJ !setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス !setname 0x2 次世代 ジェネクス
...@@ -888,3 +892,5 @@ ...@@ -888,3 +892,5 @@
!setname 0x114 空牙团 空牙団 !setname 0x114 空牙团 空牙団
!setname 0x115 闪刀 閃刀 !setname 0x115 闪刀 閃刀
!setname 0x1115 闪刀姬 閃刀姫 !setname 0x1115 闪刀姬 閃刀姫
!setname 0x116 圣像骑士 パラディオン
!setname 0x117 魔神仪 魔神儀
...@@ -29,4 +29,10 @@ separate_clear_button = 1 ...@@ -29,4 +29,10 @@ separate_clear_button = 1
auto_search_limit = -1 auto_search_limit = -1
ignore_deck_changes = 0 ignore_deck_changes = 0
default_ot = 1 default_ot = 1
enable_bot_mode = 1 enable_bot_mode = 0
enable_sound = 1
enable_music = 1
#Volume of sound and music, between 0 and 100
sound_volume = 50
music_volume = 50
music_mode = 1
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