Commit 475bddc9 authored by VanillaSalt's avatar VanillaSalt

show chain target

parent 862e5463
...@@ -16,6 +16,7 @@ ClientCard::ClientCard() { ...@@ -16,6 +16,7 @@ ClientCard::ClientCard() {
is_selected = false; is_selected = false;
is_showequip = false; is_showequip = false;
is_showtarget = false; is_showtarget = false;
is_showchaintarget = false;
is_highlighting = false; is_highlighting = false;
is_disabled = false; is_disabled = false;
is_reversed = false; is_reversed = false;
......
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
bool is_selected; bool is_selected;
bool is_showequip; bool is_showequip;
bool is_showtarget; bool is_showtarget;
bool is_showchaintarget;
bool is_highlighting; bool is_highlighting;
bool is_reversed; bool is_reversed;
u32 code; u32 code;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set>
namespace ygo { namespace ygo {
...@@ -17,6 +18,7 @@ struct ChainInfo { ...@@ -17,6 +18,7 @@ struct ChainInfo {
int location; int location;
int sequence; int sequence;
bool solved; bool solved;
std::set<ClientCard*> target;
}; };
class ClientField: public irr::IEventReceiver { class ClientField: public irr::IEventReceiver {
...@@ -79,7 +81,7 @@ public: ...@@ -79,7 +81,7 @@ public:
bool last_chain; bool last_chain;
bool deck_reversed; bool deck_reversed;
bool conti_selecting; bool conti_selecting;
ClientField(); ClientField();
void Clear(); void Clear();
void Initial(int player, int deckc, int extrac); void Initial(int player, int deckc, int extrac);
...@@ -96,7 +98,7 @@ public: ...@@ -96,7 +98,7 @@ public:
void ShowLocationCard(); void ShowLocationCard();
void ReplaySwap(); void ReplaySwap();
void RefreshAllCards(); void RefreshAllCards();
void GetChainLocation(int controler, int location, int sequence, irr::core::vector3df* t); void GetChainLocation(int controler, int location, int sequence, irr::core::vector3df* t);
void GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, irr::core::vector3df* r, bool setTrans = false); void GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, irr::core::vector3df* r, bool setTrans = false);
void MoveCard(ClientCard* pcard, int frame); void MoveCard(ClientCard* pcard, int frame);
...@@ -132,6 +134,7 @@ public: ...@@ -132,6 +134,7 @@ public:
void ShowMenu(int flag, int x, int y); void ShowMenu(int flag, int x, int y);
void UpdateChainButtons(); void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp); void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable);
void SetResponseSelectedCards() const; void SetResponseSelectedCards() const;
}; };
......
...@@ -50,9 +50,9 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, ...@@ -50,9 +50,9 @@ void Game::DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width,
void Game::DrawBackGround() { void Game::DrawBackGround() {
static int selFieldAlpha = 255; static int selFieldAlpha = 255;
static int selFieldDAlpha = -10; static int selFieldDAlpha = -10;
matrix4 im = irr::core::IdentityMatrix; // matrix4 im = irr::core::IdentityMatrix;
im.setTranslation(vector3df(0, 0, -0.01f)); // im.setTranslation(vector3df(0, 0, -0.01f));
driver->setTransform(irr::video::ETS_WORLD, im); // driver->setTransform(irr::video::ETS_WORLD, im);
//dark shade //dark shade
// matManager.mSelField.AmbientColor = 0xff000000; // matManager.mSelField.AmbientColor = 0xff000000;
// matManager.mSelField.DiffuseColor = 0xa0000000; // matManager.mSelField.DiffuseColor = 0xa0000000;
...@@ -268,17 +268,22 @@ void Game::DrawCard(ClientCard* pcard) { ...@@ -268,17 +268,22 @@ void Game::DrawCard(ClientCard* pcard) {
matManager.mCard.AmbientColor = 0xffffffff; matManager.mCard.AmbientColor = 0xffffffff;
matManager.mCard.DiffuseColor = (pcard->curAlpha << 24) | 0xffffff; matManager.mCard.DiffuseColor = (pcard->curAlpha << 24) | 0xffffff;
driver->setTransform(irr::video::ETS_WORLD, pcard->mTransform); driver->setTransform(irr::video::ETS_WORLD, pcard->mTransform);
auto cosy = std::cos(pcard->curRot.Y); auto m22 = pcard->mTransform(2, 2);
if(cosy > -0.99f) { if(m22 > -0.99 || pcard->is_moving) {
matManager.mCard.setTexture(0, imageManager.GetTexture(pcard->code)); matManager.mCard.setTexture(0, imageManager.GetTexture(pcard->code));
driver->setMaterial(matManager.mCard); driver->setMaterial(matManager.mCard);
driver->drawVertexPrimitiveList(matManager.vCardFront, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vCardFront, 4, matManager.iRectangle, 2);
} }
if(cosy < 0.99f) { if(m22 < 0.99 || pcard->is_moving) {
matManager.mCard.setTexture(0, imageManager.tCover[pcard->controler]); matManager.mCard.setTexture(0, imageManager.tCover[pcard->controler]);
driver->setMaterial(matManager.mCard); driver->setMaterial(matManager.mCard);
driver->drawVertexPrimitiveList(matManager.vCardBack, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vCardBack, 4, matManager.iRectangle, 2);
} }
if(pcard->is_moving)
return;
irr::core::matrix4 im;
im.setTranslation(pcard->curPos);
driver->setTransform(irr::video::ETS_WORLD, im);
if(pcard->is_showequip) { if(pcard->is_showequip) {
matManager.mTexture.setTexture(0, imageManager.tEquip); matManager.mTexture.setTexture(0, imageManager.tEquip);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
...@@ -287,6 +292,10 @@ void Game::DrawCard(ClientCard* pcard) { ...@@ -287,6 +292,10 @@ void Game::DrawCard(ClientCard* pcard) {
matManager.mTexture.setTexture(0, imageManager.tTarget); matManager.mTexture.setTexture(0, imageManager.tTarget);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
} else if(pcard->is_showchaintarget) {
matManager.mTexture.setTexture(0, imageManager.tChainTarget);
driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
} else if(pcard->is_disabled && (pcard->location & LOCATION_ONFIELD) && (pcard->position & POS_FACEUP)) { } else if(pcard->is_disabled && (pcard->location & LOCATION_ONFIELD) && (pcard->position & POS_FACEUP)) {
matManager.mTexture.setTexture(0, imageManager.tNegated); matManager.mTexture.setTexture(0, imageManager.tNegated);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
......
...@@ -2049,8 +2049,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2049,8 +2049,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->equipTarget = 0; pcard->equipTarget = 0;
} }
} }
pcard->is_hovered = false;
pcard->is_showequip = false; pcard->is_showequip = false;
pcard->is_showtarget = false; pcard->is_showtarget = false;
pcard->is_showchaintarget = false;
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) { if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) {
mainGame->dField.RemoveCard(pc, pl, ps); mainGame->dField.RemoveCard(pc, pl, ps);
pcard->position = cp; pcard->position = cp;
...@@ -2101,6 +2103,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2101,6 +2103,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->counters.clear(); pcard->counters.clear();
pcard->ClearTarget(); pcard->ClearTarget();
pcard->is_showtarget = false; pcard->is_showtarget = false;
pcard->is_showchaintarget = false;
ClientCard* olcard = mainGame->dField.GetCard(cc, cl & 0x7f, cs); ClientCard* olcard = mainGame->dField.GetCard(cc, cl & 0x7f, cs);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) { if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) {
mainGame->dField.RemoveCard(pc, pl, ps); mainGame->dField.RemoveCard(pc, pl, ps);
...@@ -2365,6 +2368,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2365,6 +2368,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.current_chain.sequence = cs; mainGame->dField.current_chain.sequence = cs;
mainGame->dField.GetChainLocation(cc, cl, cs, &mainGame->dField.current_chain.chain_pos); mainGame->dField.GetChainLocation(cc, cl, cs, &mainGame->dField.current_chain.chain_pos);
mainGame->dField.current_chain.solved = false; mainGame->dField.current_chain.solved = false;
mainGame->dField.current_chain.target.clear();
int chc = 0; int chc = 0;
for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) { for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) {
if (cl == 0x10 || cl == 0x20) { if (cl == 0x10 || cl == 0x20) {
...@@ -2464,14 +2468,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2464,14 +2468,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pbuf += count * 4; pbuf += count * 4;
return true; return true;
} }
ClientCard* pcard;
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf); int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf); int s = BufferIO::ReadInt8(pbuf);
/*int ss = */BufferIO::ReadInt8(pbuf); /*int ss = */BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s); ClientCard* pcard = mainGame->dField.GetCard(c, l, s);
pcard->is_highlighting = true; pcard->is_highlighting = true;
mainGame->dField.current_chain.target.insert(pcard);
if(pcard->location & LOCATION_ONFIELD) { if(pcard->location & LOCATION_ONFIELD) {
for (int j = 0; j < 3; ++j) { for (int j = 0; j < 3; ++j) {
mainGame->dField.FadeCard(pcard, 5, 5); mainGame->dField.FadeCard(pcard, 5, 5);
......
...@@ -1691,7 +1691,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1691,7 +1691,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mplayer = 1; mplayer = 1;
} }
} }
if(hovered_location == LOCATION_HAND && (mainGame->dInfo.is_shuffling || mainGame->dInfo.curMsg == MSG_SHUFFLE_HAND)) if(hovered_location == LOCATION_HAND && (mainGame->dInfo.is_shuffling || mainGame->dInfo.curMsg == MSG_SHUFFLE_HAND))
mcard = 0; mcard = 0;
if(mcard == 0 && mplayer < 0) if(mcard == 0 && mplayer < 0)
...@@ -1711,17 +1710,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1711,17 +1710,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(hovered_controler == 0) if(hovered_controler == 0)
mainGame->hideChat = false; mainGame->hideChat = false;
} }
if(hovered_card->equipTarget) SetShowMark(hovered_card, false);
hovered_card->equipTarget->is_showequip = false;
if(hovered_card->equipped.size())
for(auto cit = hovered_card->equipped.begin(); cit != hovered_card->equipped.end(); ++cit)
(*cit)->is_showequip = false;
if(hovered_card->cardTarget.size())
for(auto cit = hovered_card->cardTarget.begin(); cit != hovered_card->cardTarget.end(); ++cit)
(*cit)->is_showtarget = false;
if(hovered_card->ownerTarget.size())
for(auto cit = hovered_card->ownerTarget.begin(); cit != hovered_card->ownerTarget.end(); ++cit)
(*cit)->is_showtarget = false;
} }
if(mcard) { if(mcard) {
if(mcard != clicked_card) if(mcard != clicked_card)
...@@ -1732,14 +1721,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1732,14 +1721,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(hovered_controler == 0) if(hovered_controler == 0)
mainGame->hideChat = true; mainGame->hideChat = true;
} }
if(mcard->equipTarget) SetShowMark(mcard, true);
mcard->equipTarget->is_showequip = true;
for(auto cit = mcard->equipped.begin(); cit != mcard->equipped.end(); ++cit)
(*cit)->is_showequip = true;
for(auto cit = mcard->cardTarget.begin(); cit != mcard->cardTarget.end(); ++cit)
(*cit)->is_showtarget = true;
for(auto cit = mcard->ownerTarget.begin(); cit != mcard->ownerTarget.end(); ++cit)
(*cit)->is_showtarget = true;
if(mcard->code) { if(mcard->code) {
mainGame->ShowCardInfo(mcard->code); mainGame->ShowCardInfo(mcard->code);
if(mcard->location & 0xe) { if(mcard->location & 0xe) {
...@@ -2293,6 +2275,24 @@ void ClientField::ShowCancelOrFinishButton(int buttonOp) { ...@@ -2293,6 +2275,24 @@ void ClientField::ShowCancelOrFinishButton(int buttonOp) {
mainGame->btnCancelOrFinish->setVisible(false); mainGame->btnCancelOrFinish->setVisible(false);
} }
} }
void ClientField::SetShowMark(ClientCard* pcard, bool enable) {
if(pcard->equipTarget)
pcard->equipTarget->is_showequip = enable;
for(auto cit = pcard->equipped.begin(); cit != pcard->equipped.end(); ++cit)
(*cit)->is_showequip = enable;
for(auto cit = pcard->cardTarget.begin(); cit != pcard->cardTarget.end(); ++cit)
(*cit)->is_showtarget = enable;
for(auto cit = pcard->ownerTarget.begin(); cit != pcard->ownerTarget.end(); ++cit)
(*cit)->is_showtarget = enable;
for(auto chit = chains.begin(); chit != chains.end(); ++chit) {
if(pcard == chit->chain_card) {
for(auto tgit = chit->target.begin(); tgit != chit->target.end(); ++tgit)
(*tgit)->is_showchaintarget = enable;
}
if(chit->target.find(pcard) != chit->target.end())
chit->chain_card->is_showchaintarget = enable;
}
}
void ClientField::SetResponseSelectedCards() const { void ClientField::SetResponseSelectedCards() const {
unsigned char respbuf[64]; unsigned char respbuf[64];
respbuf[0] = selected_cards.size(); respbuf[0] = selected_cards.size();
......
...@@ -20,6 +20,7 @@ bool ImageManager::Initial() { ...@@ -20,6 +20,7 @@ bool ImageManager::Initial() {
tMask = driver->getTexture("textures/mask.png"); tMask = driver->getTexture("textures/mask.png");
tEquip = driver->getTexture("textures/equip.png"); tEquip = driver->getTexture("textures/equip.png");
tTarget = driver->getTexture("textures/target.png"); tTarget = driver->getTexture("textures/target.png");
tChainTarget = driver->getTexture("textures/chaintarget.png");
tLim = driver->getTexture("textures/lim.png"); tLim = driver->getTexture("textures/lim.png");
tOT = driver->getTexture("textures/ot.png"); tOT = driver->getTexture("textures/ot.png");
tHand[0] = driver->getTexture("textures/f1.jpg"); tHand[0] = driver->getTexture("textures/f1.jpg");
......
...@@ -34,6 +34,7 @@ public: ...@@ -34,6 +34,7 @@ public:
irr::video::ITexture* tMask; irr::video::ITexture* tMask;
irr::video::ITexture* tEquip; irr::video::ITexture* tEquip;
irr::video::ITexture* tTarget; irr::video::ITexture* tTarget;
irr::video::ITexture* tChainTarget;
irr::video::ITexture* tLim; irr::video::ITexture* tLim;
irr::video::ITexture* tOT; irr::video::ITexture* tOT;
irr::video::ITexture* tHand[3]; irr::video::ITexture* tHand[3];
......
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