Commit a3a0f8e5 authored by DailyShana's avatar DailyShana

draw field spell

parent 0e853ab9
...@@ -62,8 +62,43 @@ void Game::DrawBackGround() { ...@@ -62,8 +62,43 @@ void Game::DrawBackGround() {
// driver->setMaterial(matManager.mBackLine); // driver->setMaterial(matManager.mBackLine);
// driver->drawVertexPrimitiveList(matManager.vBackLine, 76, matManager.iBackLine, 58, irr::video::EVT_STANDARD, irr::scene::EPT_LINES); // driver->drawVertexPrimitiveList(matManager.vBackLine, 76, matManager.iBackLine, 58, irr::video::EVT_STANDARD, irr::scene::EPT_LINES);
//draw field //draw field
//draw field spell card
driver->setTransform(irr::video::ETS_WORLD, irr::core::IdentityMatrix); 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->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vField, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vField, 4, matManager.iRectangle, 2);
driver->setMaterial(matManager.mBackLine); driver->setMaterial(matManager.mBackLine);
......
...@@ -816,6 +816,7 @@ void Game::LoadConfig() { ...@@ -816,6 +816,7 @@ void Game::LoadConfig() {
gameConf.chkIgnore2 = 0; gameConf.chkIgnore2 = 0;
gameConf.chkHideSetname = 0; gameConf.chkHideSetname = 0;
gameConf.control_mode = 0; gameConf.control_mode = 0;
gameConf.draw_field_spell = 1;
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
int fsize = ftell(fp); int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
...@@ -864,6 +865,8 @@ void Game::LoadConfig() { ...@@ -864,6 +865,8 @@ void Game::LoadConfig() {
gameConf.chkHideSetname = atoi(valbuf); gameConf.chkHideSetname = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) { } else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf); gameConf.control_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_field_spell")) {
gameConf.draw_field_spell = atoi(valbuf);
} else { } else {
// options allowing multiple words // options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf); sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
...@@ -916,6 +919,7 @@ void Game::SaveConfig() { ...@@ -916,6 +919,7 @@ void Game::SaveConfig() {
fprintf(fp, "hide_setname = %d\n", ((mainGame->chkHideSetname->isChecked()) ? 1 : 0)); 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 = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9\n");
fprintf(fp, "control_mode = %d\n", gameConf.control_mode); fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell);
fclose(fp); fclose(fp);
} }
void Game::ShowCardInfo(int code) { void Game::ShowCardInfo(int code) {
......
...@@ -33,6 +33,7 @@ struct Config { ...@@ -33,6 +33,7 @@ struct Config {
int chkIgnore2; int chkIgnore2;
int chkHideSetname; int chkHideSetname;
int control_mode; int control_mode;
int draw_field_spell;
}; };
struct DuelInfo { struct DuelInfo {
......
...@@ -23,6 +23,7 @@ bool ImageManager::Initial() { ...@@ -23,6 +23,7 @@ bool ImageManager::Initial() {
tHand[2] = driver->getTexture("textures/f3.jpg"); tHand[2] = driver->getTexture("textures/f3.jpg");
tBackGround = driver->getTexture("textures/bg.jpg"); tBackGround = driver->getTexture("textures/bg.jpg");
tField = driver->getTexture("textures/field2.png"); tField = driver->getTexture("textures/field2.png");
tFieldTransparent = driver->getTexture("textures/field-transparent2.png");
return true; return true;
} }
void ImageManager::SetDevice(irr::IrrlichtDevice* dev) { void ImageManager::SetDevice(irr::IrrlichtDevice* dev) {
...@@ -91,4 +92,25 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) { ...@@ -91,4 +92,25 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
else else
return tUnknown; 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: ...@@ -15,9 +15,11 @@ public:
void RemoveTexture(int code); void RemoveTexture(int code);
irr::video::ITexture* GetTexture(int code); irr::video::ITexture* GetTexture(int code);
irr::video::ITexture* GetTextureThumb(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*> tMap;
std::unordered_map<int, irr::video::ITexture*> tThumb; std::unordered_map<int, irr::video::ITexture*> tThumb;
std::unordered_map<int, irr::video::ITexture*> tFields;
irr::IrrlichtDevice* device; irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver; irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover; irr::video::ITexture* tCover;
...@@ -36,6 +38,7 @@ public: ...@@ -36,6 +38,7 @@ public:
irr::video::ITexture* tHand[3]; irr::video::ITexture* tHand[3];
irr::video::ITexture* tBackGround; irr::video::ITexture* tBackGround;
irr::video::ITexture* tField; irr::video::ITexture* tField;
irr::video::ITexture* tFieldTransparent;
}; };
extern ImageManager imageManager; extern ImageManager imageManager;
......
...@@ -41,6 +41,18 @@ Materials::Materials() { ...@@ -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[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[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)); 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 //background grids
for (int i = 0; i < 6; ++i) { 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)); 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: ...@@ -16,6 +16,9 @@ public:
S3DVertex vChainNum[4]; S3DVertex vChainNum[4];
S3DVertex vActivate[4]; S3DVertex vActivate[4];
S3DVertex vField[4]; S3DVertex vField[4];
S3DVertex vFieldSpell[4];
S3DVertex vFieldSpell1[4];
S3DVertex vFieldSpell2[4];
S3DVertex vBackLine[76]; S3DVertex vBackLine[76];
S3DVertex vFields[136]; S3DVertex vFields[136];
S3DVertex vArrow[40]; S3DVertex vArrow[40];
......
...@@ -20,3 +20,4 @@ mute_spectators = 0 ...@@ -20,3 +20,4 @@ mute_spectators = 0
hide_setname = 0 hide_setname = 0
#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9 #control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9
control_mode = 0 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