Commit b958217a authored by woodee's avatar woodee

Merge pull request #1648 from DailyShana/control_mode

add mouse control
parents 506c0076 a7e421df
......@@ -892,6 +892,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
irr::core::position2di pos(x, y);
if(x < 300)
break;
if(mainGame->gameConf.control_mode == 1)
mainGame->always_chain = event.MouseInput.isLeftPressed();
if(mainGame->wCmdMenu->isVisible() && !mainGame->wCmdMenu->getRelativePosition().isPointInside(pos))
mainGame->wCmdMenu->setVisible(false);
if(panel && panel->isVisible())
......@@ -1239,6 +1241,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EMIE_RMOUSE_LEFT_UP: {
if(mainGame->dInfo.isReplay)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
mainGame->ignore_chain = event.MouseInput.isRightPressed();
mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size())
break;
......@@ -1531,6 +1535,20 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_WHEEL: {
break;
}
case irr::EMIE_LMOUSE_PRESSED_DOWN: {
if(!mainGame->dInfo.isStarted)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
mainGame->always_chain = event.MouseInput.isLeftPressed();
break;
}
case irr::EMIE_RMOUSE_PRESSED_DOWN: {
if(!mainGame->dInfo.isStarted)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
mainGame->ignore_chain = event.MouseInput.isRightPressed();
break;
}
default:
break;
}
......@@ -1539,15 +1557,18 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EET_KEY_INPUT_EVENT: {
switch(event.KeyInput.Key) {
case irr::KEY_KEY_A: {
mainGame->always_chain = event.KeyInput.PressedDown;
if(mainGame->gameConf.control_mode == 0)
mainGame->always_chain = event.KeyInput.PressedDown;
break;
}
case irr::KEY_KEY_S: {
mainGame->ignore_chain = event.KeyInput.PressedDown;
if(mainGame->gameConf.control_mode == 0)
mainGame->ignore_chain = event.KeyInput.PressedDown;
break;
}
case irr::KEY_KEY_R: {
if(!event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
if(mainGame->gameConf.control_mode == 0
&& !event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->textFont->setTransparency(true);
break;
}
......@@ -1621,6 +1642,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
break;
}
case irr::KEY_F9: {
if(mainGame->gameConf.control_mode == 1
&& !event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->textFont->setTransparency(true);
break;
}
case irr::KEY_ESCAPE: {
if(!mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->device->minimizeWindow();
......
......@@ -814,6 +814,7 @@ void Game::LoadConfig() {
gameConf.chkIgnore1 = 0;
gameConf.chkIgnore2 = 0;
gameConf.chkHideSetname = 0;
gameConf.control_mode = 0;
fseek(fp, 0, SEEK_END);
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
......@@ -860,6 +861,8 @@ void Game::LoadConfig() {
gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_setname")) {
gameConf.chkHideSetname = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
......@@ -910,6 +913,8 @@ void Game::SaveConfig() {
fprintf(fp, "ignore1 = %d\n", ((mainGame->chkIgnore1->isChecked()) ? 1 : 0));
fprintf(fp, "ignore2 = %d\n", ((mainGame->chkIgnore2->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 = %d\n", gameConf.control_mode);
fclose(fp);
}
void Game::ShowCardInfo(int code) {
......
......@@ -32,6 +32,7 @@ struct Config {
int chkIgnore1;
int chkIgnore2;
int chkHideSetname;
int control_mode;
};
struct DuelInfo {
......
......@@ -18,3 +18,5 @@ waitchain = 0
ignore1 = 0
ignore2 = 0
hide_setname = 0
#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9
control_mode = 0
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