Commit c6a5ebac authored by Fluorohydride's avatar Fluorohydride

Merge pull request #528 from matteoserva/master

improved  chat box
parents e4153e29 f489892d
...@@ -666,10 +666,31 @@ void Game::DrawSpec() { ...@@ -666,10 +666,31 @@ void Game::DrawSpec() {
if (attack_sv > 28) if (attack_sv > 28)
attack_sv = 0; attack_sv = 0;
} }
for(int i = 0; i < 5; ++i) {
static unsigned int chatColor[11] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040};
bool showChat=true;
if(hideChat)
{
showChat=false;
hideChatTimer = 10;
}
else if (hideChatTimer > 0)
{
showChat= false;
hideChatTimer--;
}
int maxChatLines = mainGame->dInfo.isStarted?5:8;
for(int i = 0; i < maxChatLines ; ++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]) { if(chatTiming[i]) {
chatTiming[i]--; chatTiming[i]--;
if(!showChat && i >2)
continue;
int w = textFont->getDimension(chatMsg[i].c_str()).Width; int w = textFont->getDimension(chatMsg[i].c_str()).Width;
driver->draw2DRectangle(recti(305, 596 - 20 * i, 307 + w, 616 - 20 * i), 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000); driver->draw2DRectangle(recti(305, 596 - 20 * i, 307 + w, 616 - 20 * i), 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000);
textFont->draw(chatMsg[i].c_str(), rect<s32>(305, 595 - 20 * i, 1020, 615 - 20 * i), 0xff000000, false, false); textFont->draw(chatMsg[i].c_str(), rect<s32>(305, 595 - 20 * i, 1020, 615 - 20 * i), 0xff000000, false, false);
......
...@@ -592,6 +592,13 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -592,6 +592,13 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->AddChatMsg(msg, 8); mainGame->AddChatMsg(msg, 8);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
} else if(pkt->player >= 11 && pkt->player<=19) { //system custom message.
BufferIO::CopyWStr(pkt->msg, msg, 256);
msg[(len - 3) / 2] = 0;
mainGame->gMutex.Lock();
mainGame->AddChatMsg(msg, pkt->player);
mainGame->gMutex.Unlock();
} else { } else {
if(mainGame->chkIgnore2->isChecked()) if(mainGame->chkIgnore2->isChecked())
break; break;
......
...@@ -1304,6 +1304,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1304,6 +1304,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(hovered_card->location == LOCATION_HAND && !mainGame->dInfo.is_shuffling && mainGame->dInfo.curMsg != MSG_SHUFFLE_HAND) { if(hovered_card->location == LOCATION_HAND && !mainGame->dInfo.is_shuffling && mainGame->dInfo.curMsg != MSG_SHUFFLE_HAND) {
hovered_card->is_hovered = false; hovered_card->is_hovered = false;
MoveCard(hovered_card, 5); MoveCard(hovered_card, 5);
if(hovered_controler== 0)
mainGame->hideChat=false;
} }
if(hovered_card->equipTarget) if(hovered_card->equipTarget)
hovered_card->equipTarget->is_showequip = false; hovered_card->equipTarget->is_showequip = false;
...@@ -1323,6 +1325,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1323,6 +1325,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(hovered_location == LOCATION_HAND) { if(hovered_location == LOCATION_HAND) {
mcard->is_hovered = true; mcard->is_hovered = true;
MoveCard(mcard, 5); MoveCard(mcard, 5);
if(hovered_controler== 0)
mainGame->hideChat=true;
} }
if(mcard->equipTarget) if(mcard->equipTarget)
mcard->equipTarget->is_showequip = true; mcard->equipTarget->is_showequip = true;
......
...@@ -222,7 +222,7 @@ bool Game::Initialize() { ...@@ -222,7 +222,7 @@ bool Game::Initialize() {
chkWaitChain = env->addCheckBox(false, rect<s32>(20, 110, 280, 135), tabSystem, -1, dataManager.GetSysString(1277)); chkWaitChain = env->addCheckBox(false, rect<s32>(20, 110, 280, 135), tabSystem, -1, dataManager.GetSysString(1277));
chkIgnore1 = env->addCheckBox(false, rect<s32>(20, 170, 280, 195), tabSystem, -1, dataManager.GetSysString(1290)); chkIgnore1 = env->addCheckBox(false, rect<s32>(20, 170, 280, 195), tabSystem, -1, dataManager.GetSysString(1290));
chkIgnore2 = env->addCheckBox(false, rect<s32>(20, 200, 280, 225), tabSystem, -1, dataManager.GetSysString(1291)); chkIgnore2 = env->addCheckBox(false, rect<s32>(20, 200, 280, 225), tabSystem, -1, dataManager.GetSysString(1291));
chkIgnore2->setChecked(true); chkIgnore2->setChecked(false);
// //
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);
...@@ -484,6 +484,8 @@ bool Game::Initialize() { ...@@ -484,6 +484,8 @@ bool Game::Initialize() {
col.setAlpha(224); col.setAlpha(224);
env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col); env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
} }
hideChat=false;
hideChatTimer=0;
return true; return true;
} }
void Game::MainLoop() { void Game::MainLoop() {
...@@ -492,7 +494,7 @@ void Game::MainLoop() { ...@@ -492,7 +494,7 @@ void Game::MainLoop() {
irr::core::matrix4 mProjection; irr::core::matrix4 mProjection;
BuildProjectionMatrix(mProjection, -0.81f, 0.44f, -0.42f, 0.42f, 1.0f, 100.0f); BuildProjectionMatrix(mProjection, -0.81f, 0.44f, -0.42f, 0.42f, 1.0f, 100.0f);
camera->setProjectionMatrix(mProjection); camera->setProjectionMatrix(mProjection);
mProjection.buildCameraLookAtMatrixLH(vector3df(3.95f, 8.0f, 7.8f), vector3df(3.95f, 0, 0), vector3df(0, 0, 1)); mProjection.buildCameraLookAtMatrixLH(vector3df(3.95f, 8.0f, 7.8f), vector3df(3.95f, 0, 0), vector3df(0, 0, 1));
camera->setViewMatrixAffector(mProjection); camera->setViewMatrixAffector(mProjection);
smgr->setAmbientLight(SColorf(1.0f, 1.0f, 1.0f)); smgr->setAmbientLight(SColorf(1.0f, 1.0f, 1.0f));
...@@ -823,7 +825,7 @@ void Game::ShowCardInfo(int code) { ...@@ -823,7 +825,7 @@ void Game::ShowCardInfo(int code) {
SetStaticText(stText, 270, textFont, (wchar_t*)dataManager.GetText(code)); SetStaticText(stText, 270, textFont, (wchar_t*)dataManager.GetText(code));
} }
void Game::AddChatMsg(wchar_t* msg, int player) { void Game::AddChatMsg(wchar_t* msg, int player) {
for(int i = 4; i > 0; --i) { for(int i = 7; i > 0; --i) {
chatMsg[i] = chatMsg[i - 1]; chatMsg[i] = chatMsg[i - 1];
chatTiming[i] = chatTiming[i - 1]; chatTiming[i] = chatTiming[i - 1];
chatType[i] = chatType[i - 1]; chatType[i] = chatType[i - 1];
...@@ -831,7 +833,7 @@ void Game::AddChatMsg(wchar_t* msg, int player) { ...@@ -831,7 +833,7 @@ void Game::AddChatMsg(wchar_t* msg, int player) {
chatMsg[0].clear(); chatMsg[0].clear();
chatTiming[0] = 1200; chatTiming[0] = 1200;
chatType[0] = player; chatType[0] = player;
switch(player) { if (player<11 || player > 19) switch(player) {
case 0: //from host case 0: //from host
chatMsg[0].append(dInfo.hostname); chatMsg[0].append(dInfo.hostname);
chatMsg[0].append(L": "); chatMsg[0].append(L": ");
......
...@@ -109,9 +109,12 @@ public: ...@@ -109,9 +109,12 @@ public:
std::list<FadingUnit> fadingList; std::list<FadingUnit> fadingList;
std::vector<int> logParam; std::vector<int> logParam;
std::wstring chatMsg[5]; std::wstring chatMsg[8];
int chatTiming[5];
int chatType[5]; int hideChatTimer;
bool hideChat;
int chatTiming[8];
int chatType[8];
unsigned short linePattern; unsigned short linePattern;
int waitFrame; int waitFrame;
int signalFrame; int signalFrame;
......
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