Commit 23c0d38d authored by mercury233's avatar mercury233

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

parents 1a1827e3 4c297b63
......@@ -420,26 +420,30 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
selectable_cards[i]->sequence + 1);
mainGame->stCardPos[i]->setText(formatBuffer);
// color
if(conti_selecting)
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
if (selectable_cards[i]->is_selected)
mainGame->stCardPos[i]->setBackgroundColor(0xffffff00);
else {
if(conti_selecting)
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 {
if(sort_list[i]) {
......
......@@ -3,6 +3,7 @@
#include "data_manager.h"
#include "deck_manager.h"
#include "image_manager.h"
#include "sound_manager.h"
#include "game.h"
#include "duelclient.h"
#include <algorithm>
......@@ -122,6 +123,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(id) {
case BUTTON_CLEAR_DECK: {
mainGame->gMutex.Lock();
......@@ -220,6 +222,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
for(int i = 0; i < 32; ++i, filter <<= 1)
if(mainGame->chkCategory[i]->isChecked())
filter_effect |= filter;
mainGame->btnEffectFilter->setPressed(filter_effect > 0);
mainGame->HideElement(mainGame->wCategories);
InstantSearch();
break;
......@@ -227,6 +230,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case BUTTON_SIDE_OK: {
if(deckManager.current_deck.main.size() != pre_mainc || deckManager.current_deck.extra.size() != pre_extrac
|| deckManager.current_deck.side.size() != pre_sidec) {
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410));
break;
}
......@@ -319,6 +323,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if (mainGame->btnMark[7]->isPressed())
filter_marks |= 0004;
mainGame->HideElement(mainGame->wLinkMarks);
mainGame->btnMarksFilter->setPressed(filter_marks > 0);
InstantSearch();
break;
}
......@@ -514,6 +519,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
is_starting_dragging = false;
if(!is_draging)
break;
soundManager.PlaySoundEffect(SOUND_CARD_DROP);
bool pushed = false;
if(hovered_pos == 1)
pushed = push_main(draging_pointer, hovered_seq);
......@@ -543,6 +549,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto pointer = dataManager.GetCodePointer(hovered_code);
if(pointer == dataManager._datas.end())
break;
soundManager.PlaySoundEffect(SOUND_CARD_DROP);
if(hovered_pos == 1) {
if(push_side(pointer))
pop_main(hovered_seq);
......@@ -560,6 +567,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if(!is_draging) {
if(hovered_pos == 0 || hovered_seq == -1)
break;
soundManager.PlaySoundEffect(SOUND_CARD_DROP);
if(hovered_pos == 1) {
pop_main(hovered_seq);
} else if(hovered_pos == 2) {
......@@ -576,6 +584,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
push_side(pointer);
}
} else {
soundManager.PlaySoundEffect(SOUND_CARD_PICK);
if(click_pos == 1) {
push_side(draging_pointer);
} else if(click_pos == 2) {
......@@ -602,6 +611,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
auto pointer = dataManager.GetCodePointer(hovered_code);
if(!check_limit(pointer))
break;
soundManager.PlaySoundEffect(SOUND_CARD_PICK);
if (hovered_pos == 1) {
if(!push_main(pointer))
push_side(pointer);
......@@ -620,6 +630,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_MOVED: {
if(is_starting_dragging) {
is_draging = true;
soundManager.PlaySoundEffect(SOUND_CARD_PICK);
if(hovered_pos == 1)
pop_main(hovered_seq);
else if(hovered_pos == 2)
......@@ -635,6 +646,11 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_WHEEL: {
if(!mainGame->scrFilter->isVisible())
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(mainGame->scrFilter->getPos() < mainGame->scrFilter->getMax())
mainGame->scrFilter->setPos(mainGame->scrFilter->getPos() + 1);
......@@ -904,6 +920,8 @@ void DeckBuilder::ClearFilter() {
filter_marks = 0;
for(int i = 0; i < 8; i++)
mainGame->btnMark[i]->setPressed(false);
mainGame->btnEffectFilter->setPressed(false);
mainGame->btnMarksFilter->setPressed(false);
}
void DeckBuilder::SortList() {
auto left = results.begin();
......
......@@ -2,6 +2,7 @@
#include "materials.h"
#include "image_manager.h"
#include "deck_manager.h"
#include "sound_manager.h"
#include "duelclient.h"
#include "../ocgcore/field.h"
......@@ -11,7 +12,7 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
if(!gameConf.use_d3d) {
float origin[4] = {1.0f, 1.0f, 1.0f, 1.0f};
glLineWidth(width);
glLineStipple(1, linePattern);
glLineStipple(1, linePatternGL);
if(strip)
glEnable(GL_LINE_STIPPLE);
glDisable(GL_TEXTURE_2D);
......@@ -28,16 +29,16 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
} else {
driver->setMaterial(matManager.mOutLine);
if(strip) {
if(linePattern < 15) {
driver->draw3DLine(vec[0].Pos, vec[0].Pos + (vec[1].Pos - vec[0].Pos) * (linePattern + 1) / 15.0);
driver->draw3DLine(vec[1].Pos, vec[1].Pos + (vec[3].Pos - vec[1].Pos) * (linePattern + 1) / 15.0);
driver->draw3DLine(vec[3].Pos, vec[3].Pos + (vec[2].Pos - vec[3].Pos) * (linePattern + 1) / 15.0);
driver->draw3DLine(vec[2].Pos, vec[2].Pos + (vec[0].Pos - vec[2].Pos) * (linePattern + 1) / 15.0);
if(linePatternD3D < 15) {
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) * (linePatternD3D + 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) * (linePatternD3D + 1) / 15.0);
} else {
driver->draw3DLine(vec[0].Pos + (vec[1].Pos - vec[0].Pos) * (linePattern - 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[3].Pos + (vec[2].Pos - vec[3].Pos) * (linePattern - 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[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) * (linePatternD3D - 14) / 15.0, vec[3].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) * (linePatternD3D - 14) / 15.0, vec[0].Pos);
}
} else {
driver->draw3DLine(vec[0].Pos, vec[1].Pos);
......@@ -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() {
static int selFieldAlpha = 255;
static int selFieldDAlpha = -10;
......@@ -450,6 +471,9 @@ void Game::DrawMisc() {
driver->drawVertexPrimitiveList(matManager.vChainNum, 4, matManager.iRectangle, 2);
}
}
//finish button
if(btnCancelOrFinish->isVisible() && dField.select_ready)
DrawSelectionLine(btnCancelOrFinish, 2, 0xffffff00);
//lp bar
if((dInfo.turn % 2 && dInfo.isFirst) || (!(dInfo.turn % 2) && !dInfo.isFirst)) {
driver->draw2DRectangle(0xa0000000, recti(327, 8, 630, 51));
......@@ -1008,6 +1032,7 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
fadingList.push_back(fu);
}
void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) {
soundManager.PlayDialogSound(element);
element->getParent()->bringToFront(element);
if(!mainGame->is_building)
dField.panel = element;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -47,10 +47,16 @@ struct Config {
int chkIgnoreDeckChanges;
int defaultOT;
int enable_bot_mode;
bool enable_sound;
bool enable_music;
double sound_volume;
double music_volume;
int music_mode;
};
struct DuelInfo {
bool isStarted;
bool isFinished;
bool isReplay;
bool isReplaySkiping;
bool isFirst;
......@@ -115,6 +121,7 @@ public:
void RefreshSingleplay();
void RefreshBot();
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 DrawLinkedZones(ClientCard* pcard);
void CheckMutual(ClientCard* pcard, int mark);
......@@ -149,6 +156,7 @@ public:
void SetWindowsIcon();
void FlashWindow();
void SetCursor(ECURSOR_ICON icon);
Mutex gMutex;
Mutex gBuffer;
......@@ -170,7 +178,8 @@ public:
bool hideChat;
int chatTiming[8];
int chatType[8];
unsigned short linePattern;
unsigned short linePatternD3D;
unsigned short linePatternGL;
int waitFrame;
int signalFrame;
int actionParam;
......@@ -230,6 +239,9 @@ public:
irr::gui::IGUIStaticText* stSetName;
irr::gui::IGUIStaticText* stText;
irr::gui::IGUIScrollBar* scrCardText;
irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog;
irr::gui::IGUICheckBox* chkMAutoPos;
irr::gui::IGUICheckBox* chkSTAutoPos;
irr::gui::IGUICheckBox* chkRandomPos;
......@@ -239,9 +251,11 @@ public:
irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkIgnoreDeckChanges;
irr::gui::IGUICheckBox* chkAutoSearch;
irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog;
irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUICheckBox* chkEnableMusic;
irr::gui::IGUIScrollBar* scrSoundVolume;
irr::gui::IGUIScrollBar* scrMusicVolume;
irr::gui::IGUICheckBox* chkMusicMode;
//main menu
irr::gui::IGUIWindow* wMainMenu;
irr::gui::IGUIButton* btnLanMode;
......@@ -613,6 +627,10 @@ extern HostInfo game_info;
#define BUTTON_LOAD_SINGLEPLAY 351
#define BUTTON_CANCEL_SINGLEPLAY 352
#define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_ENABLE_SOUND 361
#define CHECKBOX_ENABLE_MUSIC 362
#define SCROLL_VOLUME 363
#define COMBOBOX_SORTTYPE 370
#define COMBOBOX_LIMIT 371
......
......@@ -6,6 +6,7 @@
#include "replay_mode.h"
#include "single_mode.h"
#include "image_manager.h"
#include "sound_manager.h"
#include "game.h"
namespace ygo {
......@@ -39,7 +40,21 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
}
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);
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
mainGame->SetCursor(ECI_NORMAL);
break;
}
case irr::gui::EGET_BUTTON_CLICKED: {
if(id < 110)
soundManager.PlaySoundEffect(SOUND_MENU);
else
soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(id) {
case BUTTON_MODE_EXIT: {
mainGame->device->closeDevice();
......@@ -74,6 +89,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int status = evutil_getaddrinfo(hostname, port, &hints, &answer);
if(status != 0) {
mainGame->gMutex.Lock();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.Unlock();
break;
......
......@@ -24,5 +24,5 @@ project "ygopro"
configuration "not vs*"
buildoptions { "-std=gnu++0x", "-fno-rtti" }
configuration "not windows"
includedirs { "/usr/include/lua", "/usr/include/lua5.2", "/usr/include/lua/5.2" }
includedirs { "/usr/include/lua", "/usr/include/lua5.3", "/usr/include/lua/5.3" }
links { "event_pthreads", "dl", "pthread" }
......@@ -78,6 +78,7 @@ int ReplayMode::ReplayThread(void* param) {
return 0;
}
mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplay = true;
mainGame->dInfo.isReplaySkiping = (skip_turn > 0);
char engineBuffer[0x1000];
......@@ -122,6 +123,7 @@ int ReplayMode::ReplayThread(void* param) {
if(step == 0) {
Pause(true, false);
mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
......@@ -236,6 +238,7 @@ void ReplayMode::EndDuel() {
mainGame->actionSignal.Wait();
mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.isReplay = false;
mainGame->gMutex.Unlock();
mainGame->closeDoneSignal.Reset();
......@@ -253,6 +256,7 @@ void ReplayMode::EndDuel() {
void ReplayMode::Restart(bool refresh) {
end_duel(pduel);
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dField.Clear();
//mainGame->device->setEventReceiver(&mainGame->dField);
cur_replay.Rewind();
......@@ -265,6 +269,7 @@ void ReplayMode::Restart(bool refresh) {
if(refresh) {
mainGame->dField.RefreshAllCards();
mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
//mainGame->dInfo.isReplay = true;
}
skip_turn = 0;
......@@ -378,6 +383,15 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
pbuf += count * 8;
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: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
......@@ -833,6 +847,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(skip_step == 0) {
Pause(true, false);
mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
......
......@@ -34,25 +34,14 @@ void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
scc.player = dp->type;
unsigned short* msg = (unsigned short*)pdata;
int msglen = BufferIO::CopyWStr(msg, scc.msg, 256);
if(dp->type > 1) {
NetServer::SendBufferToPlayer(players[0], STOC_CHAT, &scc, 4 + msglen * 2);
NetServer::ReSendToPlayer(players[1]);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
if((*pit) != dp)
NetServer::ReSendToPlayer(*pit);
#ifdef YGOPRO_SERVER_MODE
if(cache_recorder)
NetServer::ReSendToPlayer(cache_recorder);
#endif
} 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);
NetServer::SendBufferToPlayer(players[0], STOC_CHAT, &scc, 4 + msglen * 2);
NetServer::ReSendToPlayer(players[1]);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
#ifdef YGOPRO_SERVER_MODE
if(cache_recorder)
NetServer::ReSendToPlayer(cache_recorder);
if(cache_recorder)
NetServer::ReSendToPlayer(cache_recorder);
#endif
}
}
void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
#ifdef YGOPRO_SERVER_MODE
......@@ -855,6 +844,34 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
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: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
......
......@@ -97,6 +97,7 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->dField.Clear();
mainGame->dInfo.isFirst = true;
mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isSingleMode = true;
mainGame->device->setEventReceiver(&mainGame->dField);
mainGame->gMutex.Unlock();
......@@ -150,6 +151,7 @@ int SingleMode::SinglePlayThread(void* param) {
if(!is_closing) {
mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.isSingleMode = false;
mainGame->gMutex.Unlock();
mainGame->closeDoneSignal.Reset();
......@@ -271,6 +273,19 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
}
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: {
player = 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
......@@ -31,8 +31,13 @@ void TagDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
unsigned short* msg = (unsigned short*)pdata;
int msglen = BufferIO::CopyWStr(msg, scc.msg, 256);
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);
#ifdef YGOPRO_SERVER_MODE
if(cache_recorder)
NetServer::ReSendToPlayer(cache_recorder);
#endif
}
void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
#ifdef YGOPRO_SERVER_MODE
......@@ -764,6 +769,34 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
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: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
......
Subproject commit 35463ba465a0926f22f13340bb9d0fd5e5443e85
Subproject commit 6a4d5979ebeb9be4d4996e8da30e0550e2b96234
Subproject commit 47a1517ad08adc9ef37933cc2388b57d38ab277f
Subproject commit 5f197f2d2cd3a619b48ce30d20b57a7fe5bb0d65
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,6 +302,9 @@
!system 1276 自动排列连锁顺序
!system 1277 没有可连锁的卡时延迟回应
!system 1278 自动选择魔陷卡片位置
!system 1279 开启音效
!system 1280 开启音乐
!system 1281 按场景切换音乐
!system 1290 忽略对方发言
!system 1291 忽略观战者发言
!system 1292 忽略时点
......
......@@ -30,3 +30,9 @@ auto_search_limit = -1
ignore_deck_changes = 0
default_ot = 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