Commit 58ca41dd authored by mercury233's avatar mercury233

Merge branch 'fh' into resize

parents 4ab7f93e f24fe048
......@@ -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]) {
......
......@@ -12,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);
......@@ -29,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);
......@@ -48,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;
......@@ -458,6 +478,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, Resize(327, 8, 630, 51));
......
......@@ -1395,6 +1395,86 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
return false;
}
case MSG_SELECT_UNSELECT_CARD: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf);
bool buttonok = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf);
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(buttonok);
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 {
mainGame->dField.select_ready = true;
mainGame->dField.ShowCancelOrFinishButton(2);
}
}
else
mainGame->dField.ShowCancelOrFinishButton(0);
return false;
}
case MSG_SELECT_CHAIN: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
......@@ -3662,7 +3742,8 @@ void DuelClient::SendResponse() {
mainGame->btnShuffle->setVisible(false);
break;
}
case MSG_SELECT_CARD: {
case MSG_SELECT_CARD:
case MSG_SELECT_UNSELECT_CARD: {
mainGame->dField.ClearSelect();
break;
}
......
......@@ -686,6 +686,24 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
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: {
command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList->getPos() / 10];
selected_cards.push_back(command_card);
......@@ -747,6 +765,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->HideElement(mainGame->wCardSelect);
mainGame->actionSignal.Set();
break;
} else if(mainGame->dInfo.curMsg == MSG_SELECT_UNSELECT_CARD){
DuelClient::SetResponseI(-1);
ShowCancelOrFinishButton(0);
mainGame->HideElement(mainGame->wCardSelect, true);
} else {
mainGame->HideElement(mainGame->wCardSelect);
if(mainGame->dInfo.curMsg == MSG_SELECT_CHAIN && !chain_forced)
......@@ -1334,6 +1356,22 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
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: {
if (!clicked_card || !clicked_card->is_selectable)
break;
......@@ -2229,6 +2267,17 @@ void ClientField::CancelOrFinish() {
}
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: {
if(selected_cards.size() == 0) {
if(select_cancelable) {
......
......@@ -34,7 +34,8 @@ bool Game::Initialize() {
device = irr::createDeviceEx(params);
if(!device)
return false;
linePattern = 0x0f0f;
linePatternD3D = 0;
linePatternGL = 0x0f0f;
waitFrame = 0;
signalFrame = 0;
showcard = 0;
......@@ -711,10 +712,8 @@ void Game::MainLoop() {
yScale = window_size.Height / 640.0;
OnResize();
}
if(gameConf.use_d3d)
linePattern = (linePattern + 1) % 30;
else
linePattern = (linePattern << 1) | (linePattern >> 15);
linePatternD3D = (linePatternD3D + 1) % 30;
linePatternGL = (linePatternGL << 1) | (linePatternGL >> 15);
atkframe += 0.1f;
atkdy = (float)sin(atkframe);
driver->beginScene(true, true, SColor(0, 0, 0, 0));
......
......@@ -114,6 +114,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);
......@@ -179,7 +180,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;
......
......@@ -383,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);
......
......@@ -693,6 +693,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);
......
......@@ -273,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);
......
......@@ -631,6 +631,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 a4e17256838bf1b657238f554362d9cc9841b233
Subproject commit 9a253618906d678a5b0722b0f42e3c8f009e9c7d
Subproject commit eacd96e1bc6ed66c00947d30adacffd0157ba8e8
Subproject commit 8548beecbbb8e209a2c8c25b12e55d165533a395
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