- bugfixes for clicking outside of the map co-ordinates

- show up to 5 descriptions for queued items when producing
This commit is contained in:
Mark Vejvoda 2011-04-27 22:35:45 +00:00
parent dd9b984a82
commit 0abca7fb7a
4 changed files with 116 additions and 34 deletions

View File

@ -916,11 +916,17 @@ void Game::update() {
}
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
if(errorMessageBox.getEnabled() == false) {
@ -1112,21 +1118,19 @@ void Game::mouseDownLeft(int x, int y) {
}
}
}
//display panel
else if(metrics.isInDisplay(x, y) && !gui.isSelectingPos()){
else if(metrics.isInDisplay(x, y) && !gui.isSelectingPos()) {
int xd= x - metrics.getDisplayX();
int yd= y - metrics.getDisplayY();
if(gui.mouseValid(xd, yd)){
if(gui.mouseValid(xd, yd)) {
gui.mouseDownLeftDisplay(xd, yd);
}
else{
else {
gui.mouseDownLeftGraphics(x, y, false);
}
}
//graphics panel
else{
else {
gui.mouseDownLeftGraphics(x, y, false);
}
}
@ -1159,10 +1163,17 @@ void Game::mouseDownLeft(int x, int y) {
}
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);
@ -1189,14 +1200,29 @@ void Game::mouseDownRight(int x, int y) {
gui.mouseDownRightGraphics(xCell, yCell,true);
}
}
else
gui.mouseDownRightGraphics(x, y,false);
else {
Vec2i targetPos;
Vec2i screenPos(x,y);
Renderer &renderer= Renderer::getInstance();
renderer.computePosition(screenPos, targetPos);
if(renderer.computePosition(screenPos, targetPos) == true &&
map->isInsideSurface(map->toSurfCoords(targetPos)) == true) {
gui.mouseDownRightGraphics(x, y,false);
}
}
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s] x = %d y = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what(),x,y);
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);
@ -1225,10 +1251,17 @@ void Game::mouseUpLeft(int x, int y) {
gui.mouseUpLeftGraphics(x, y);
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);
@ -1256,10 +1289,17 @@ void Game::mouseDoubleClickLeft(int x, int y) {
gui.mouseDoubleClickLeftGraphics(x, y);
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);
@ -1356,10 +1396,17 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
lastMousePos.y = mouseY;
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);
@ -1374,10 +1421,17 @@ void Game::eventMouseWheel(int x, int y, int zDelta) {
//gameCamera.setMoveY(1);
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);
@ -1544,10 +1598,17 @@ void Game::keyDown(char key) {
//throw runtime_error("Test Error!");
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);
@ -1602,10 +1663,17 @@ void Game::keyUp(char key){
}
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,szBuf);
NetworkManager &networkManager= NetworkManager::getInstance();
if(networkManager.getGameNetworkInterface() != NULL) {
GameNetworkInterface *networkInterface = NetworkManager::getInstance().getGameNetworkInterface();
networkInterface->sendTextMessage(szBuf,-1,true,"");
sleep(10);
networkManager.getGameNetworkInterface()->quitGame(true);
}
ErrorDisplayMessage(ex.what(),true);

View File

@ -203,14 +203,19 @@ void Gui::mouseMoveDisplay(int x, int y) {
void Gui::mouseDownLeftGraphics(int x, int y, bool prepared) {
if(selectingPos) {
//give standard orders
giveTwoClickOrders(x, y, prepared);
Vec2i targetPos;
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
giveTwoClickOrders(x, y, prepared);
}
resetState();
}
//set meeting point
else if(selectingMeetingPoint) {
if(selection.isCommandable()) {
Vec2i targetPos;
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos)) {
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
commander->trySetMeetingPoint(selection.getFrontUnit(), targetPos);
}
}
@ -229,10 +234,18 @@ void Gui::mouseDownRightGraphics(int x, int y , bool prepared) {
}
else if(selection.isCommandable()) {
if(prepared) {
givePreparedDefaultOrders(x, y);
Vec2i targetPos;
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
givePreparedDefaultOrders(x, y);
}
}
else {
giveDefaultOrders(x, y);
Vec2i targetPos;
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
giveDefaultOrders(x, y);
}
}
}
computeDisplay();
@ -242,8 +255,7 @@ void Gui::mouseUpLeftGraphics(int x, int y) {
if(!selectingPos && !selectingMeetingPoint) {
if(selectionQuad.isEnabled()){
selectionQuad.setPosUp(Vec2i(x, y));
if(selectionQuad.getPosUp().dist(selectionQuad.getPosDown())>minQuadSize)
{
if(selectionQuad.getPosUp().dist(selectionQuad.getPosDown()) > minQuadSize) {
computeSelected(false,true);
}
if(selection.isCommandable() && random.randRange(0, 1)==0){

View File

@ -1475,7 +1475,7 @@ string Unit::getDesc() const {
if(commands.size() > 1) {
str += "\n" + lang.get("OrdersOnQueue") + ": " + intToStr(commands.size());
Commands::const_iterator it= commands.begin();
for(unsigned int i = 0; i < min((size_t)4,commands.size()); ++i) {
for(unsigned int i = 1; i < min((size_t)6,commands.size()); ++i) {
const CommandType *ct = (*it)->getCommandType();
//str += "\n" + ct->getDesc(this->getTotalUpgrade());
str += "\n#" + intToStr(i+1) + " " + ct->getName();

View File

@ -157,7 +157,9 @@ SurfaceCell *Map::getSurfaceCell(const Vec2i &sPos) const {
SurfaceCell *Map::getSurfaceCell(int sx, int sy) const {
int arrayIndex = sy * surfaceW + sx;
if(arrayIndex < 0 || arrayIndex >= getSurfaceCellArraySize()) {
throw runtime_error("arrayIndex >= getSurfaceCellArraySize(), arrayIndex = " + intToStr(arrayIndex) + " surfaceW = " + intToStr(surfaceW) + " surfaceH = " + intToStr(surfaceH));
throw runtime_error("arrayIndex >= getSurfaceCellArraySize(), arrayIndex = " + intToStr(arrayIndex) +
" surfaceW = " + intToStr(surfaceW) + " surfaceH = " + intToStr(surfaceH) +
" sx: " + intToStr(sx) + " sy: " + intToStr(sy));
}
else if(surfaceCells == NULL) {
throw runtime_error("surfaceCells == NULL");