Commit f2638474 authored by nanahira's avatar nanahira

Merge branch 'mkdir' into skin_fh

parents 011f08d4 4d50233c
......@@ -1062,7 +1062,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,7 +367,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
int sel = mainGame->cbDBDecks->getSelected();
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
if(sel >= 0)
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
prev_deck = sel;
is_modified = false;
break;
......
......@@ -944,12 +944,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,7 +479,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
else if(mainGame->wSinglePlay->isVisible())
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare);
mainGame->wChat->setVisible(true);
if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock();
mainGame->dInfo.duel_rule = pkt->info.duel_rule;
watching = 0;
......@@ -588,7 +589,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->btnShuffle->setVisible(false);
mainGame->wChat->setVisible(true);
if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
mainGame->device->setEventReceiver(&mainGame->dField);
if(!mainGame->dInfo.isTag) {
if(selftype > 1) {
......@@ -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);
......@@ -1688,7 +1692,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);
......
......@@ -464,6 +464,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 +957,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;
}
......@@ -1758,13 +1747,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 +1785,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 +1845,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;
......
......@@ -13,7 +13,12 @@
#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 = 0x1343;
......@@ -24,6 +29,7 @@ Game* mainGame;
bool Game::Initialize() {
srand(time(0));
initUtils();
LoadConfig();
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
params.AntiAlias = gameConf.antialias;
......@@ -284,7 +290,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));
......@@ -1342,6 +1348,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) {
......@@ -1361,6 +1372,52 @@ 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
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");
//pics
MakeDirectory("pics");
MakeDirectory("pics/field");
}
void Game::ClearTextures() {
matManager.mCard.setTexture(0, 0);
imgCard->setImage(imageManager.tCover[0]);
......
......@@ -133,7 +133,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();
......@@ -617,6 +620,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
......
......@@ -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;
......
Subproject commit 24dff6a9a81f3f3dae45b2e2600203a08b19a0cf
Subproject commit 92ad9db2a69bbaf4a07ef0173fe3ee03615b1f24
Subproject commit 5f197f2d2cd3a619b48ce30d20b57a7fe5bb0d65
Subproject commit f196735871f426872da35d2699c96466cbf48759
......@@ -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 显示时点
......@@ -531,6 +534,7 @@
!counter 0x1045 鳞粉指示物
!counter 0x46 指示物(刚鬼死斗)
!counter 0x47 指示物(限制代码)
!counter 0x48 指示物(连接死亡炮塔)
#setnames, using tab for comment
!setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス
......@@ -891,3 +895,5 @@
!setname 0x114 空牙团 空牙団
!setname 0x115 闪刀 閃刀
!setname 0x1115 闪刀姬 閃刀姫
!setname 0x116 圣像骑士 パラディオン
!setname 0x117 魔神仪 魔神儀
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