Commit c311b21b authored by Frozen Water's avatar Frozen Water

Merge pull request #1661 from DailyShana/field-spell

draw field spell
parents c3d63025 a3a0f8e5
......@@ -62,8 +62,43 @@ void Game::DrawBackGround() {
// driver->setMaterial(matManager.mBackLine);
// driver->drawVertexPrimitiveList(matManager.vBackLine, 76, matManager.iBackLine, 58, irr::video::EVT_STANDARD, irr::scene::EPT_LINES);
//draw field
//draw field spell card
driver->setTransform(irr::video::ETS_WORLD, irr::core::IdentityMatrix);
matManager.mTexture.setTexture(0, imageManager.tField);
int fieldcode1 = -1;
int fieldcode2 = -1;
bool drawField = false;
if(mainGame->gameConf.draw_field_spell
&& mainGame->dField.szone[0][5] && mainGame->dField.szone[0][5]->position & POS_FACEUP)
fieldcode1 = mainGame->dField.szone[0][5]->code;
if(mainGame->gameConf.draw_field_spell
&& mainGame->dField.szone[1][5] && mainGame->dField.szone[1][5]->position & POS_FACEUP)
fieldcode2 = mainGame->dField.szone[1][5]->code;
int fieldcode = (fieldcode1 > 0) ? fieldcode1 : fieldcode2;
if(fieldcode1 > 0 && fieldcode2 > 0 && fieldcode1 != fieldcode2) {
ITexture* texture = imageManager.GetTextureField(fieldcode1);
if(texture) {
drawField = true;
matManager.mTexture.setTexture(0, texture);
driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vFieldSpell1, 4, matManager.iRectangle, 2);
}
texture = imageManager.GetTextureField(fieldcode2);
if(texture) {
drawField = true;
matManager.mTexture.setTexture(0, texture);
driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vFieldSpell2, 4, matManager.iRectangle, 2);
}
} else if(fieldcode > 0) {
ITexture* texture = imageManager.GetTextureField(fieldcode);
if(texture) {
drawField = true;
matManager.mTexture.setTexture(0, texture);
driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vFieldSpell, 4, matManager.iRectangle, 2);
}
}
matManager.mTexture.setTexture(0, drawField ? imageManager.tFieldTransparent : imageManager.tField);
driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vField, 4, matManager.iRectangle, 2);
driver->setMaterial(matManager.mBackLine);
......
......@@ -821,6 +821,7 @@ void Game::LoadConfig() {
gameConf.chkIgnore2 = 0;
gameConf.chkHideSetname = 0;
gameConf.control_mode = 0;
gameConf.draw_field_spell = 1;
fseek(fp, 0, SEEK_END);
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
......@@ -869,6 +870,8 @@ void Game::LoadConfig() {
gameConf.chkHideSetname = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_field_spell")) {
gameConf.draw_field_spell = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
......@@ -921,6 +924,7 @@ void Game::SaveConfig() {
fprintf(fp, "hide_setname = %d\n", ((mainGame->chkHideSetname->isChecked()) ? 1 : 0));
fprintf(fp, "#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9\n");
fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell);
fclose(fp);
}
void Game::ShowCardInfo(int code) {
......
......@@ -33,6 +33,7 @@ struct Config {
int chkIgnore2;
int chkHideSetname;
int control_mode;
int draw_field_spell;
};
struct DuelInfo {
......
......@@ -26,6 +26,7 @@ bool ImageManager::Initial() {
tBackGround_menu = driver->getTexture("textures/bg_menu.jpg");
tBackGround_deck = driver->getTexture("textures/bg_deck.jpg");
tField = driver->getTexture("textures/field2.png");
tFieldTransparent = driver->getTexture("textures/field-transparent2.png");
return true;
}
void ImageManager::SetDevice(irr::IrrlichtDevice* dev) {
......@@ -94,4 +95,25 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
else
return tUnknown;
}
irr::video::ITexture* ImageManager::GetTextureField(int code) {
if(code == 0)
return NULL;
auto tit = tFields.find(code);
if(tit == tFields.end()) {
char file[256];
sprintf(file, "pics/field/%d.png", code);
irr::video::ITexture* img = driver->getTexture(file);
if(img == NULL) {
tFields[code] = NULL;
return NULL;
} else {
tFields[code] = img;
return img;
}
}
if(tit->second)
return tit->second;
else
return NULL;
}
}
......@@ -15,9 +15,11 @@ public:
void RemoveTexture(int code);
irr::video::ITexture* GetTexture(int code);
irr::video::ITexture* GetTextureThumb(int code);
irr::video::ITexture* GetTextureField(int code);
std::unordered_map<int, irr::video::ITexture*> tMap;
std::unordered_map<int, irr::video::ITexture*> tThumb;
std::unordered_map<int, irr::video::ITexture*> tFields;
irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover[2];
......@@ -38,6 +40,7 @@ public:
irr::video::ITexture* tBackGround_menu;
irr::video::ITexture* tBackGround_deck;
irr::video::ITexture* tField;
irr::video::ITexture* tFieldTransparent;
};
extern ImageManager imageManager;
......
......@@ -41,6 +41,18 @@ Materials::Materials() {
vField[1] = S3DVertex(vector3df(9.0f, -4.0f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0));
vField[2] = S3DVertex(vector3df(-1.0f, 4.0f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 1));
vField[3] = S3DVertex(vector3df(9.0f, 4.0f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 1));
vFieldSpell[0] = S3DVertex(vector3df(1.2f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vFieldSpell[1] = S3DVertex(vector3df(6.7f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0));
vFieldSpell[2] = S3DVertex(vector3df(1.2f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 1));
vFieldSpell[3] = S3DVertex(vector3df(6.7f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 1));
vFieldSpell1[0] = S3DVertex(vector3df(1.2f, 0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vFieldSpell1[1] = S3DVertex(vector3df(6.7f, 0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0));
vFieldSpell1[2] = S3DVertex(vector3df(1.2f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 1));
vFieldSpell1[3] = S3DVertex(vector3df(6.7f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 1));
vFieldSpell2[0] = S3DVertex(vector3df(1.2f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vFieldSpell2[1] = S3DVertex(vector3df(6.7f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0));
vFieldSpell2[2] = S3DVertex(vector3df(1.2f, -0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 1));
vFieldSpell2[3] = S3DVertex(vector3df(6.7f, -0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 1));
//background grids
for (int i = 0; i < 6; ++i) {
vBackLine[i * 6 + 0] = S3DVertex(vector3df(1.2f + i * 1.1f, 0.5f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
......
......@@ -16,6 +16,9 @@ public:
S3DVertex vChainNum[4];
S3DVertex vActivate[4];
S3DVertex vField[4];
S3DVertex vFieldSpell[4];
S3DVertex vFieldSpell1[4];
S3DVertex vFieldSpell2[4];
S3DVertex vBackLine[76];
S3DVertex vFields[136];
S3DVertex vArrow[40];
......
......@@ -20,3 +20,4 @@ mute_spectators = 0
hide_setname = 0
#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9
control_mode = 0
draw_field_spell = 1
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