Commit 8fde847c authored by nanahira's avatar nanahira

catchup merge

parents 98ee33ab 6700122a
......@@ -303,7 +303,6 @@ void ClientField::UpdateCard(int controler, int location, int sequence, char* da
}
void ClientField::UpdateFieldCard(int controler, int location, char* data) {
std::vector<ClientCard*>* lst = 0;
std::vector<ClientCard*>::iterator cit;
switch(location) {
case LOCATION_DECK:
lst = &deck[controler];
......@@ -330,7 +329,7 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) {
if(!lst)
return;
int len;
for(cit = lst->begin(); cit != lst->end(); ++cit) {
for(auto cit = lst->begin(); cit != lst->end(); ++cit) {
len = BufferIO::ReadInt32(data);
if(len > 8)
(*cit)->UpdateInfo(data);
......@@ -338,20 +337,19 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) {
}
}
void ClientField::ClearCommandFlag() {
std::vector<ClientCard*>::iterator cit;
for(cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit)
for(auto cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit)
(*cit)->cmdFlag = 0;
for(cit = summonable_cards.begin(); cit != summonable_cards.end(); ++cit)
for(auto cit = summonable_cards.begin(); cit != summonable_cards.end(); ++cit)
(*cit)->cmdFlag = 0;
for(cit = spsummonable_cards.begin(); cit != spsummonable_cards.end(); ++cit)
for(auto cit = spsummonable_cards.begin(); cit != spsummonable_cards.end(); ++cit)
(*cit)->cmdFlag = 0;
for(cit = msetable_cards.begin(); cit != msetable_cards.end(); ++cit)
for(auto cit = msetable_cards.begin(); cit != msetable_cards.end(); ++cit)
(*cit)->cmdFlag = 0;
for(cit = ssetable_cards.begin(); cit != ssetable_cards.end(); ++cit)
for(auto cit = ssetable_cards.begin(); cit != ssetable_cards.end(); ++cit)
(*cit)->cmdFlag = 0;
for(cit = reposable_cards.begin(); cit != reposable_cards.end(); ++cit)
for(auto cit = reposable_cards.begin(); cit != reposable_cards.end(); ++cit)
(*cit)->cmdFlag = 0;
for(cit = attackable_cards.begin(); cit != attackable_cards.end(); ++cit)
for(auto cit = attackable_cards.begin(); cit != attackable_cards.end(); ++cit)
(*cit)->cmdFlag = 0;
conti_cards.clear();
deck_act = false;
......@@ -363,21 +361,20 @@ void ClientField::ClearCommandFlag() {
conti_act = false;
}
void ClientField::ClearSelect() {
std::vector<ClientCard*>::iterator cit;
for(cit = selectable_cards.begin(); cit != selectable_cards.end(); ++cit) {
for(auto cit = selectable_cards.begin(); cit != selectable_cards.end(); ++cit) {
(*cit)->is_selectable = false;
(*cit)->is_selected = false;
}
}
void ClientField::ClearChainSelect() {
std::vector<ClientCard*>::iterator cit;
for(cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit) {
for(auto cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit) {
(*cit)->cmdFlag = 0;
(*cit)->chain_code = 0;
(*cit)->is_selectable = false;
(*cit)->is_selected = false;
}
conti_cards.clear();
deck_act = false;
grave_act = false;
remove_act = false;
extra_act = false;
......@@ -1062,7 +1059,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
select_ready = false;
}
if (select_ready) {
ShowCancelOrFinishButton(1);
ShowCancelOrFinishButton(2);
} else {
ShowCancelOrFinishButton(0);
}
......
......@@ -54,8 +54,8 @@ public:
int select_max;
int must_select_count;
int select_sumval;
int select_cancelable;
int select_mode;
bool select_cancelable;
bool select_panalmode;
bool select_ready;
int announce_count;
......
......@@ -367,6 +367,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
int sel = mainGame->cbDBDecks->getSelected();
if(sel >= 0)
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
prev_deck = sel;
is_modified = false;
......
......@@ -11,8 +11,44 @@ DeckManager deckManager;
void DeckManager::LoadLFList() {
LFList* cur = NULL;
FILE* fp = fopen("lflist.conf", "r");
FILE* fp_custom = fopen("expansions/lflist.conf", "r");
char linebuf[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) {
while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#')
......
......@@ -681,8 +681,7 @@ void Game::DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2) {
}
void Game::DrawGUI() {
if(imageLoading.size()) {
std::map<irr::gui::CGUIImageButton*, int>::iterator mit;
for(mit = imageLoading.begin(); mit != imageLoading.end(); ++mit)
for(auto mit = imageLoading.begin(); mit != imageLoading.end(); ++mit)
mit->first->setImage(imageManager.GetTexture(mit->second));
imageLoading.clear();
}
......@@ -781,7 +780,7 @@ void Game::DrawSpec() {
}
case 2: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 150, 761, 404), recti(0, 0, CARD_IMG_WIDTH - showcarddif, CARD_IMG_HEIGHT), 0, 0, true);
driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 150, 751, 404), recti(0, 0, CARD_IMG_WIDTH - showcarddif, CARD_IMG_HEIGHT), 0, 0, true);
showcarddif += 15;
if(showcarddif >= CARD_IMG_WIDTH) {
showcard = 0;
......@@ -944,12 +943,13 @@ void Game::DrawSpec() {
showChat = false;
hideChatTimer--;
}
int maxChatLines = mainGame->dInfo.isStarted ? 5 : 8;
for(int i = 0; i < maxChatLines; ++i) {
for(int i = 0; i < 8; ++i) {
static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040,
0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040};
if(chatTiming[i]) {
chatTiming[i]--;
if(mainGame->dInfo.isStarted && i >= 5)
continue;
if(!showChat && i > 2)
continue;
int w = textFont->getDimension(chatMsg[i].c_str()).Width;
......
......@@ -479,6 +479,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
else if(mainGame->wSinglePlay->isVisible())
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare);
if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock();
mainGame->dInfo.duel_rule = pkt->info.duel_rule;
......@@ -588,6 +589,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->btnShuffle->setVisible(false);
if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
mainGame->device->setEventReceiver(&mainGame->dField);
if(!mainGame->dInfo.isTag) {
......@@ -1340,7 +1342,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case MSG_SELECT_CARD: {
/*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_max = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
......@@ -1397,8 +1399,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case MSG_SELECT_UNSELECT_CARD: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf);
bool buttonok = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_cancelable = 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);
......@@ -1457,19 +1460,20 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
if (panelmode) {
mainGame->gMutex.Lock();
mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard(buttonok);
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 (count2 == 0)
mainGame->dField.ShowCancelOrFinishButton(1);
else {
if(finishable) {
mainGame->dField.select_ready = true;
mainGame->dField.ShowCancelOrFinishButton(2);
}
else {
mainGame->dField.ShowCancelOrFinishButton(1);
}
}
else
mainGame->dField.ShowCancelOrFinishButton(0);
......@@ -1514,7 +1518,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->cmdFlag |= COMMAND_RESET;
else
pcard->cmdFlag |= COMMAND_ACTIVATE;
if(l == LOCATION_GRAVE)
if(pcard->location == LOCATION_DECK) {
pcard->SetCode(code);
mainGame->dField.deck_act = true;
} else if(l == LOCATION_GRAVE)
mainGame->dField.grave_act = true;
else if(l == LOCATION_REMOVED)
mainGame->dField.remove_act = true;
......@@ -1688,7 +1695,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case MSG_SELECT_TRIBUTE: {
/*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_max = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
......@@ -2202,8 +2209,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
}
case MSG_SHUFFLE_SET_CARD: {
std::vector<ClientCard*>::iterator cit;
std::vector<ClientCard*>* lst = 0;
int loc = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
if(loc == LOCATION_MZONE)
lst = mainGame->dField.mzone;
else
lst = mainGame->dField.szone;
ClientCard* mc[5];
ClientCard* swp;
int c, l, s, ps;
......@@ -2212,7 +2224,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
mc[i] = mainGame->dField.mzone[c][s];
mc[i] = lst[c][s];
mc[i]->SetCode(0);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
mc[i]->dPos = irr::core::vector3df((3.95f - mc[i]->curPos.X) / 10, 0, 0.05f);
......@@ -2230,9 +2242,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
BufferIO::ReadInt8(pbuf);
ps = mc[i]->sequence;
if (l > 0) {
swp = mainGame->dField.mzone[c][s];
mainGame->dField.mzone[c][ps] = swp;
mainGame->dField.mzone[c][s] = mc[i];
swp = lst[c][s];
lst[c][ps] = swp;
lst[c][s] = mc[i];
mc[i]->sequence = s;
swp->sequence = ps;
}
......@@ -2241,7 +2253,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
soundManager.PlaySoundEffect(SOUND_SHUFFLE);
for (int i = 0; i < count; ++i) {
mainGame->dField.MoveCard(mc[i], 10);
for (cit = mc[i]->overlayed.begin(); cit != mc[i]->overlayed.end(); ++cit)
for (auto cit = mc[i]->overlayed.begin(); cit != mc[i]->overlayed.end(); ++cit)
mainGame->dField.MoveCard(*cit, 10);
}
mainGame->WaitFrameSignal(11);
......
......@@ -143,6 +143,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->ShowElement(mainGame->wSinglePlay);
else
mainGame->ShowElement(mainGame->wLanWindow);
if(exit_on_return)
mainGame->device->closeDevice();
} else {
DuelClient::SendPacketToServer(CTOS_SURRENDER);
}
......@@ -464,6 +466,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
list_command = COMMAND_SPSUMMON;
mainGame->wCardSelect->setText(dataManager.GetSysString(509));
ShowSelectCard();
select_ready = false;
ShowCancelOrFinishButton(1);
}
break;
......@@ -956,18 +959,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
UpdateDeclarableCode(true);
break;
}
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"");
}
break;
}
}
break;
}
......@@ -1545,7 +1536,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
str.append(formatBuffer);
}
}
for(std::map<int, int>::iterator ctit = mcard->counters.begin(); ctit != mcard->counters.end(); ++ctit) {
for(auto ctit = mcard->counters.begin(); ctit != mcard->counters.end(); ++ctit) {
myswprintf(formatBuffer, L"\n[%ls]: %d", dataManager.GetCounterName(ctit->first), ctit->second);
str.append(formatBuffer);
}
......@@ -1758,13 +1749,17 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_ELEMENT_HOVERED: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
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)
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX) {
mainGame->SetCursor(ECI_NORMAL);
return true;
}
break;
}
case irr::gui::EGET_BUTTON_CLICKED: {
......@@ -1792,6 +1787,14 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
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;
}
......@@ -1844,6 +1847,24 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
return true;
}
break;
}
}
break;
}
default: break;
}
break;
......
......@@ -12,10 +12,15 @@
#ifndef _WIN32
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#else
#include <direct.h>
#include <io.h>
#endif
const unsigned short PRO_VERSION = 0x1342;
const unsigned short PRO_VERSION = 0x1344;
namespace ygo {
......@@ -23,6 +28,7 @@ Game* mainGame;
bool Game::Initialize() {
srand(time(0));
initUtils();
LoadConfig();
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
params.AntiAlias = gameConf.antialias;
......@@ -266,7 +272,7 @@ bool Game::Initialize() {
//system
irr::gui::IGUITab* tabSystem = wInfos->addTab(dataManager.GetSysString(1273));
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);
posY += 30;
chkIgnore2 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1291));
......@@ -707,7 +713,7 @@ void Game::MainLoop() {
atkdy = (float)sin(atkframe);
driver->beginScene(true, true, SColor(0, 0, 0, 0));
gMutex.Lock();
if(dInfo.isStarted || dInfo.isReplaySkiping) {
if(dInfo.isStarted) {
if(dInfo.isFinished && showcardcode == 1)
soundManager.PlayBGM(BGM_WIN);
else if(dInfo.isFinished && (showcardcode == 2 || showcardcode == 3))
......@@ -1116,6 +1122,7 @@ void Game::LoadConfig() {
gameConf.defaultOT = atoi(valbuf);
} else if(!strcmp(strbuf, "enable_bot_mode")) {
gameConf.enable_bot_mode = atoi(valbuf);
#ifdef YGOPRO_USE_IRRKLANG
} else if(!strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "sound_volume")) {
......@@ -1126,6 +1133,7 @@ void Game::LoadConfig() {
gameConf.music_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "music_mode")) {
gameConf.music_mode = atoi(valbuf);
#endif
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
......@@ -1186,6 +1194,7 @@ void Game::SaveConfig() {
fprintf(fp, "ignore_deck_changes = %d\n", (chkIgnoreDeckChanges->isChecked() ? 1 : 0));
fprintf(fp, "default_ot = %d\n", gameConf.defaultOT);
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
#ifdef YGOPRO_USE_IRRKLANG
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");
......@@ -1196,6 +1205,7 @@ void Game::SaveConfig() {
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));
#endif
fclose(fp);
}
void Game::ShowCardInfo(int code) {
......@@ -1320,6 +1330,11 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
}
chatMsg[0].append(msg);
}
void Game::ClearChatMsg() {
for(int i = 7; i >= 0; --i) {
chatTiming[i] = 0;
}
}
void Game::AddDebugMsg(char* msg)
{
if (enable_log & 0x1) {
......@@ -1339,6 +1354,54 @@ void Game::AddDebugMsg(char* msg)
fclose(fp);
}
}
bool Game::MakeDirectory(const std::string folder) {
std::string folder_builder;
std::string sub;
sub.reserve(folder.size());
for(auto it = folder.begin(); it != folder.end(); ++it) {
const char c = *it;
sub.push_back(c);
if(c == '/' || it == folder.end() - 1) {
folder_builder.append(sub);
if(access(folder_builder.c_str(), 0) != 0)
#ifdef _WIN32
if(mkdir(folder_builder.c_str()) != 0)
#else
if(mkdir(folder_builder.c_str(), 0777) != 0)
#endif
return false;
sub.clear();
}
}
return true;
}
void Game::initUtils() {
//user files
MakeDirectory("replay");
//cards from extra pack
MakeDirectory("expansions");
//files in ygopro-starter-pack
MakeDirectory("deck");
MakeDirectory("single");
//original files
MakeDirectory("script");
MakeDirectory("textures");
//sound
#ifdef YGOPRO_USE_IRRKLANG
MakeDirectory("sound");
MakeDirectory("sound/BGM");
MakeDirectory("sound/BGM/advantage");
MakeDirectory("sound/BGM/deck");
MakeDirectory("sound/BGM/disadvantage");
MakeDirectory("sound/BGM/duel");
MakeDirectory("sound/BGM/lose");
MakeDirectory("sound/BGM/menu");
MakeDirectory("sound/BGM/win");
#endif
//pics
MakeDirectory("pics");
MakeDirectory("pics/field");
}
void Game::ClearTextures() {
matManager.mCard.setTexture(0, 0);
imgCard->setImage(imageManager.tCover[0]);
......@@ -1376,6 +1439,9 @@ void Game::CloseDuelWindow() {
wReplaySave->setVisible(false);
stHintMsg->setVisible(false);
btnSideOK->setVisible(false);
btnSideShuffle->setVisible(false);
btnSideSort->setVisible(false);
btnSideReload->setVisible(false);
btnLeaveGame->setVisible(false);
btnSpectatorSwap->setVisible(false);
btnChainIgnore->setVisible(false);
......
......@@ -131,7 +131,10 @@ public:
void SaveConfig();
void ShowCardInfo(int code);
void AddChatMsg(wchar_t* msg, int player);
void ClearChatMsg();
void AddDebugMsg(char* msgbuf);
bool MakeDirectory(const std::string folder);
void initUtils();
void ClearTextures();
void CloseDuelWindow();
......@@ -613,6 +616,7 @@ extern Game* mainGame;
#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_LIMIT 371
......
......@@ -134,7 +134,7 @@ int main(int argc, char* argv[]) {
break;
} else if(!strcmp(argv[i], "-j")) { // Join host
exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnLanMode);
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnJoinHost);
break;
} else if(!strcmp(argv[i], "-r")) { // Replay
......
......@@ -27,6 +27,8 @@ void UpdateDeck() {
DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf);
}
bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(mainGame->dField.OnCommonEvent(event))
return false;
switch(event.EventType) {
case irr::EET_GUI_EVENT: {
irr::gui::IGUIElement* caller = event.GUIEvent.Caller;
......@@ -40,16 +42,6 @@ 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);
......@@ -509,49 +501,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
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;
}
break;
......
......@@ -106,6 +106,7 @@ int ReplayMode::ReplayThread(void* param) {
get_message(pduel, (byte*)engineBuffer);
is_continuing = ReplayAnalyze(engineBuffer, len);
if(is_restarting) {
mainGame->gMutex.Lock();
is_restarting = false;
int step = current_step - 1;
if(step < 0)
......@@ -280,7 +281,6 @@ void ReplayMode::Undo() {
return;
mainGame->dInfo.isReplaySkiping = true;
Restart(false);
mainGame->gMutex.Lock();
Pause(false, false);
}
bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
......@@ -497,6 +497,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
break;
}
case MSG_SHUFFLE_SET_CARD: {
pbuf++;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
DuelClient::ClientAnalyze(offset, pbuf - offset);
......
......@@ -874,14 +874,21 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
break;
}
case MSG_SHUFFLE_SET_CARD: {
int loc = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
if(loc == LOCATION_MZONE) {
RefreshMzone(0, 0x181fff, 0);
RefreshMzone(1, 0x181fff, 0);
}
else {
RefreshSzone(0, 0x181fff, 0);
RefreshSzone(1, 0x181fff, 0);
}
break;
}
case MSG_NEW_TURN: {
......
......@@ -415,6 +415,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
break;
}
case MSG_SHUFFLE_SET_CARD: {
pbuf++;
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
DuelClient::ClientAnalyze(offset, pbuf - offset);
......@@ -745,6 +746,8 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
xcard->overlayTarget = ccard;
xcard->location = 0x80;
xcard->sequence = ccard->overlayed.size() - 1;
xcard->owner = p;
xcard->controler = p;
}
}
}
......
......@@ -832,6 +832,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
break;
}
case MSG_SHUFFLE_SET_CARD: {
int loc = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
......@@ -840,8 +841,13 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayer(players[3]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
if(loc == LOCATION_MZONE) {
RefreshMzone(0, 0x181fff, 0);
RefreshMzone(1, 0x181fff, 0);
} else {
RefreshSzone(0, 0x181fff, 0);
RefreshSzone(1, 0x181fff, 0);
}
break;
}
case MSG_NEW_TURN: {
......
This diff is collapsed.
Subproject commit 9a253618906d678a5b0722b0f42e3c8f009e9c7d
Subproject commit 7da0970abec7155fe7de65e86e905a971c56db79
Subproject commit 8548beecbbb8e209a2c8c25b12e55d165533a395
Subproject commit a7ac36907a08e612671914681a808af971290bc9
......@@ -240,6 +240,9 @@
!system 1161 效果处理
!system 1162 效果重置
!system 1163 灵摆召唤
!system 1164 同调召唤
!system 1165 超量召唤
!system 1166 连接召唤
#menu
!system 1200 联机模式
!system 1201 单人模式
......@@ -305,7 +308,7 @@
!system 1279 开启音效
!system 1280 开启音乐
!system 1281 按场景切换音乐
!system 1290 忽略对方发言
!system 1290 禁用聊天功能
!system 1291 忽略观战者发言
!system 1292 忽略时点
!system 1293 显示时点
......@@ -412,6 +415,7 @@
!system 1418 额外卡组数量应不超过15张,当前卡组数量为%d张。
!system 1419 副卡组数量应不超过15张,当前卡组数量为%d张。
!system 1420 有额外卡组卡片存在于主卡组,可能是额外卡组数量超过15张。
!system 1421 宣言的卡不符合条件,或无法被主机识别。
!system 1500 决斗结束。
!system 1501 录像结束。
!system 1502 连接已断开。
......@@ -464,6 +468,8 @@
!victory 0x1a 「魂之接力」效果胜利
!victory 0x1b 「鬼计惰天使」效果胜利
!victory 0x1c 「幻煌龙的天涡」效果胜利
!victory 0x1d 「方程式运动员胜利团队」效果胜利
!victory 0x1e 「飞行象」效果胜利
!victory 0x20 由于「%ls」的效果获得比赛胜利
#counters
!counter 0x1 魔力指示物
......@@ -531,6 +537,8 @@
!counter 0x1045 鳞粉指示物
!counter 0x46 指示物(刚鬼死斗)
!counter 0x47 指示物(限制代码)
!counter 0x48 指示物(连接死亡炮塔)
!counter 0x1049 警逻指示物
#setnames, using tab for comment
!setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス
......@@ -891,3 +899,11 @@
!setname 0x114 空牙团 空牙団
!setname 0x115 闪刀 閃刀
!setname 0x1115 闪刀姬 閃刀姫
!setname 0x116 圣像骑士 パラディオン
!setname 0x117 魔神仪 魔神儀
!setname 0x118 电脑网 サイバネット
!setname 0x119 转生炎兽 サラマングレイト
!setname 0x11a 恐龙摔跤手 ダイナレスラー
!setname 0x11b 自奏圣乐 オルフェゴール
!setname 0x11c 雷龙 サンダー·ドラゴン
!setname 0x11d 禁忌的 禁じられた
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