mirror of
https://github.com/glest/glest-source.git
synced 2025-09-08 23:10:42 +02:00
more user friendly error handling, try to display most errors in a nice messagebox in-game
This commit is contained in:
@@ -398,11 +398,14 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const{
|
|||||||
const UnitType* unitType= world->findUnitTypeById(unit->getFaction()->getType(), networkCommand->getUnitTypeId());
|
const UnitType* unitType= world->findUnitTypeById(unit->getFaction()->getType(), networkCommand->getUnitTypeId());
|
||||||
ct= unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
ct= unit->getType()->findCommandTypeById(networkCommand->getCommandTypeId());
|
||||||
|
|
||||||
|
// debug test!
|
||||||
|
//throw runtime_error("Test missing command type!");
|
||||||
|
|
||||||
//validate command type
|
//validate command type
|
||||||
if(ct == NULL) {
|
if(ct == NULL) {
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
sprintf(szBuf,"In [%s::%s Line: %d] Can not find command type for\nnetwork command = [%s]\n%s\n in unit = %d [%s][%s].\nGame out of synch.",
|
sprintf(szBuf,"In [%s::%s Line: %d]\nCan not find command type for network command = [%s]\n%s\nfor unit = %d\n[%s]\n[%s]\nactual local factionIndex = %d.\nGame out of synch.",
|
||||||
__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str());
|
__FILE__,__FUNCTION__,__LINE__,networkCommand->toString().c_str(),unit->getType()->getCommandTypeListDesc().c_str(),unit->getId(), unit->getFullName().c_str(),unit->getDesc().c_str(),unit->getFaction()->getIndex());
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",szBuf);
|
||||||
|
|
||||||
|
@@ -376,76 +376,85 @@ void Game::simpleTask() {
|
|||||||
void Game::update(){
|
void Game::update(){
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
// a) Updates non dependent on speed
|
try {
|
||||||
|
|
||||||
//misc
|
// a) Updates non dependent on speed
|
||||||
updateFps++;
|
|
||||||
mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim;
|
|
||||||
|
|
||||||
//console
|
//misc
|
||||||
console.update();
|
updateFps++;
|
||||||
|
mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim;
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//console
|
||||||
// b) Updates depandant on speed
|
console.update();
|
||||||
|
|
||||||
int updateLoops= getUpdateLoops();
|
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
//update
|
|
||||||
for(int i=0; i<updateLoops; ++i){
|
|
||||||
Renderer &renderer= Renderer::getInstance();
|
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//AiInterface
|
// b) Updates depandant on speed
|
||||||
for(int i=0; i<world.getFactionCount(); ++i){
|
|
||||||
if(world.getFaction(i)->getCpuControl() && scriptManager.getPlayerModifiers(i)->getAiEnabled()){
|
int updateLoops= getUpdateLoops();
|
||||||
aiInterfaces[i]->update();
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
//update
|
||||||
|
for(int i=0; i<updateLoops; ++i){
|
||||||
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//AiInterface
|
||||||
|
for(int i=0; i<world.getFactionCount(); ++i){
|
||||||
|
if(world.getFaction(i)->getCpuControl() && scriptManager.getPlayerModifiers(i)->getAiEnabled()){
|
||||||
|
aiInterfaces[i]->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//World
|
||||||
|
world.update();
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
// Commander
|
||||||
|
commander.updateNetwork();
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//Gui
|
||||||
|
gui.update();
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//Particle systems
|
||||||
|
if(weatherParticleSystem != NULL){
|
||||||
|
weatherParticleSystem->setPos(gameCamera.getPos());
|
||||||
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
renderer.updateParticleManager(rsGame);
|
||||||
|
|
||||||
|
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//World
|
//call the chat manager
|
||||||
world.update();
|
chatManager.updateNetwork();
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//check for quiting status
|
||||||
// Commander
|
if(NetworkManager::getInstance().getGameNetworkInterface()->getQuit() && mainMessageBox.getEnabled() == false) {
|
||||||
commander.updateNetwork();
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
quitGame();
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
//Gui
|
|
||||||
gui.update();
|
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
//Particle systems
|
|
||||||
if(weatherParticleSystem != NULL){
|
|
||||||
weatherParticleSystem->setPos(gameCamera.getPos());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update auto test
|
||||||
|
if(Config::getInstance().getBool("AutoTest")){
|
||||||
|
AutoTest::getInstance().updateGame(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//throw runtime_error("Test!");
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
renderer.updateParticleManager(rsGame);
|
|
||||||
|
|
||||||
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
}
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
//call the chat manager
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
chatManager.updateNetwork();
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
//check for quiting status
|
|
||||||
if(NetworkManager::getInstance().getGameNetworkInterface()->getQuit() && mainMessageBox.getEnabled() == false) {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
quitGame();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//update auto test
|
|
||||||
if(Config::getInstance().getBool("AutoTest")){
|
|
||||||
AutoTest::getInstance().updateGame(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//throw runtime_error("Test!");
|
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::updateCamera(){
|
void Game::updateCamera(){
|
||||||
@@ -514,358 +523,420 @@ void Game::tick(){
|
|||||||
|
|
||||||
void Game::mouseDownLeft(int x, int y){
|
void Game::mouseDownLeft(int x, int y){
|
||||||
|
|
||||||
Map *map= world.getMap();
|
try {
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
Map *map= world.getMap();
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
bool messageBoxClick= false;
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
bool messageBoxClick= false;
|
||||||
|
|
||||||
//scrip message box, only if the exit box is not enabled
|
//scrip message box, only if the exit box is not enabled
|
||||||
if(!mainMessageBox.getEnabled() && scriptManager.getMessageBox()->getEnabled()){
|
if(!mainMessageBox.getEnabled() && scriptManager.getMessageBox()->getEnabled()){
|
||||||
int button= 1;
|
int button= 1;
|
||||||
if(scriptManager.getMessageBox()->mouseClick(x, y, button)){
|
if(scriptManager.getMessageBox()->mouseClick(x, y, button)){
|
||||||
scriptManager.onMessageBoxOk();
|
scriptManager.onMessageBoxOk();
|
||||||
messageBoxClick= true;
|
messageBoxClick= true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//minimap panel
|
//minimap panel
|
||||||
if(!messageBoxClick){
|
if(!messageBoxClick){
|
||||||
if(metrics.isInMinimap(x, y) && !gui.isSelectingPos()){
|
if(metrics.isInMinimap(x, y) && !gui.isSelectingPos()){
|
||||||
|
|
||||||
int xm= x - metrics.getMinimapX();
|
int xm= x - metrics.getMinimapX();
|
||||||
int ym= y - metrics.getMinimapY();
|
int ym= y - metrics.getMinimapY();
|
||||||
int xCell= static_cast<int>(xm * (static_cast<float>(map->getW()) / metrics.getMinimapW()));
|
int xCell= static_cast<int>(xm * (static_cast<float>(map->getW()) / metrics.getMinimapW()));
|
||||||
int yCell= static_cast<int>(map->getH() - ym * (static_cast<float>(map->getH()) / metrics.getMinimapH()));
|
int yCell= static_cast<int>(map->getH() - ym * (static_cast<float>(map->getH()) / metrics.getMinimapH()));
|
||||||
|
|
||||||
if(map->isInside(xCell, yCell)){
|
if(map->isInside(xCell, yCell)){
|
||||||
if(!gui.isSelectingPos()){
|
if(!gui.isSelectingPos()){
|
||||||
gameCamera.setPos(Vec2f(static_cast<float>(xCell), static_cast<float>(yCell)));
|
gameCamera.setPos(Vec2f(static_cast<float>(xCell), static_cast<float>(yCell)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//display panel
|
//display panel
|
||||||
else if(metrics.isInDisplay(x, y) && !gui.isSelectingPos()){
|
else if(metrics.isInDisplay(x, y) && !gui.isSelectingPos()){
|
||||||
int xd= x - metrics.getDisplayX();
|
int xd= x - metrics.getDisplayX();
|
||||||
int yd= y - metrics.getDisplayY();
|
int yd= y - metrics.getDisplayY();
|
||||||
if(gui.mouseValid(xd, yd)){
|
if(gui.mouseValid(xd, yd)){
|
||||||
gui.mouseDownLeftDisplay(xd, yd);
|
gui.mouseDownLeftDisplay(xd, yd);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
gui.mouseDownLeftGraphics(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//graphics panel
|
||||||
else{
|
else{
|
||||||
gui.mouseDownLeftGraphics(x, y);
|
gui.mouseDownLeftGraphics(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//graphics panel
|
//exit message box, has to be the last thing to do in this function
|
||||||
else{
|
if(mainMessageBox.getEnabled()){
|
||||||
gui.mouseDownLeftGraphics(x, y);
|
int button= 1;
|
||||||
|
if(mainMessageBox.mouseClick(x, y, button)) {
|
||||||
|
if(button==1) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
quitGame();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//close message box
|
||||||
|
mainMessageBox.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
//exit message box, has to be the last thing to do in this function
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(mainMessageBox.getEnabled()){
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
int button= 1;
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
if(mainMessageBox.mouseClick(x, y, button)) {
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
if(button==1) {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
networkManager.getGameNetworkInterface()->quitGame(true);
|
|
||||||
quitGame();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
//close message box
|
|
||||||
mainMessageBox.setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseDownRight(int x, int y){
|
void Game::mouseDownRight(int x, int y){
|
||||||
gui.mouseDownRightGraphics(x, y);
|
try {
|
||||||
|
gui.mouseDownRightGraphics(x, y);
|
||||||
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseUpLeft(int x, int y){
|
void Game::mouseUpLeft(int x, int y){
|
||||||
gui.mouseUpLeftGraphics(x, y);
|
try {
|
||||||
|
gui.mouseUpLeftGraphics(x, y);
|
||||||
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseDoubleClickLeft(int x, int y){
|
void Game::mouseDoubleClickLeft(int x, int y){
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
try {
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
|
||||||
//display panel
|
//display panel
|
||||||
if(metrics.isInDisplay(x, y) && !gui.isSelectingPos()){
|
if(metrics.isInDisplay(x, y) && !gui.isSelectingPos()){
|
||||||
int xd= x - metrics.getDisplayX();
|
int xd= x - metrics.getDisplayX();
|
||||||
int yd= y - metrics.getDisplayY();
|
int yd= y - metrics.getDisplayY();
|
||||||
if(gui.mouseValid(xd, yd)){
|
if(gui.mouseValid(xd, yd)){
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//graphics panel
|
//graphics panel
|
||||||
gui.mouseDoubleClickLeftGraphics(x, y);
|
gui.mouseDoubleClickLeftGraphics(x, y);
|
||||||
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseMove(int x, int y, const MouseState *ms){
|
void Game::mouseMove(int x, int y, const MouseState *ms){
|
||||||
const Metrics &metrics = Metrics::getInstance();
|
try {
|
||||||
|
const Metrics &metrics = Metrics::getInstance();
|
||||||
|
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
|
|
||||||
if (ms->get(mbCenter)) {
|
if (ms->get(mbCenter)) {
|
||||||
//if (input.isCtrlDown()) {
|
//if (input.isCtrlDown()) {
|
||||||
// float speed = input.isShiftDown() ? 1.f : 0.125f;
|
// float speed = input.isShiftDown() ? 1.f : 0.125f;
|
||||||
// float response = input.isShiftDown() ? 0.1875f : 0.0625f;
|
// float response = input.isShiftDown() ? 0.1875f : 0.0625f;
|
||||||
// gameCamera.moveForwardH((y - lastMousePos.y) * speed, response);
|
// gameCamera.moveForwardH((y - lastMousePos.y) * speed, response);
|
||||||
// gameCamera.moveSideH((x - lastMousePos.x) * speed, response);
|
// gameCamera.moveSideH((x - lastMousePos.x) * speed, response);
|
||||||
//} else
|
//} else
|
||||||
{
|
{
|
||||||
//float ymult = Config::getInstance().getCameraInvertYAxis() ? -0.2f : 0.2f;
|
//float ymult = Config::getInstance().getCameraInvertYAxis() ? -0.2f : 0.2f;
|
||||||
//float xmult = Config::getInstance().getCameraInvertXAxis() ? -0.2f : 0.2f;
|
//float xmult = Config::getInstance().getCameraInvertXAxis() ? -0.2f : 0.2f;
|
||||||
float ymult = 0.2f;
|
float ymult = 0.2f;
|
||||||
float xmult = 0.2f;
|
float xmult = 0.2f;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
gameCamera.transitionVH(-(y - lastMousePos.y) * ymult, (lastMousePos.x - x) * xmult);
|
gameCamera.transitionVH(-(y - lastMousePos.y) * ymult, (lastMousePos.x - x) * xmult);
|
||||||
mouseX=lastMousePos.x;
|
mouseX=lastMousePos.x;
|
||||||
mouseY=lastMousePos.y;
|
mouseY=lastMousePos.y;
|
||||||
Window::revertMousePos();
|
Window::revertMousePos();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
//main window
|
||||||
|
if(Window::isKeyDown() == false) {
|
||||||
|
if (y < 10) {
|
||||||
|
gameCamera.setMoveZ(-scrollSpeed);
|
||||||
|
}
|
||||||
|
else if (y > metrics.getVirtualH() - 10) {
|
||||||
|
gameCamera.setMoveZ(scrollSpeed);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gameCamera.setMoveZ(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < 10) {
|
||||||
|
gameCamera.setMoveX(-scrollSpeed);
|
||||||
|
}
|
||||||
|
else if (x > metrics.getVirtualW() - 10) {
|
||||||
|
gameCamera.setMoveX(scrollSpeed);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gameCamera.setMoveX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainMessageBox.getEnabled()) {
|
||||||
|
mainMessageBox.mouseMove(x, y);
|
||||||
|
}
|
||||||
|
if (scriptManager.getMessageBox()->getEnabled()) {
|
||||||
|
scriptManager.getMessageBox()->mouseMove(x, y);
|
||||||
|
}
|
||||||
|
//else if (saveBox) {
|
||||||
|
// saveBox->mouseMove(x, y);
|
||||||
|
//} else {
|
||||||
|
// //graphics
|
||||||
|
gui.mouseMoveGraphics(x, y);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
//display
|
||||||
|
if (metrics.isInDisplay(x, y) && !gui.isSelecting() && !gui.isSelectingPos()) {
|
||||||
|
if (!gui.isSelectingPos()) {
|
||||||
|
gui.mouseMoveDisplay(x - metrics.getDisplayX(), y - metrics.getDisplayY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastMousePos.x = mouseX;
|
||||||
|
lastMousePos.y = mouseY;
|
||||||
}
|
}
|
||||||
else {
|
catch(const exception &ex) {
|
||||||
//main window
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(Window::isKeyDown() == false) {
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
if (y < 10) {
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
gameCamera.setMoveZ(-scrollSpeed);
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
}
|
|
||||||
else if (y > metrics.getVirtualH() - 10) {
|
|
||||||
gameCamera.setMoveZ(scrollSpeed);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gameCamera.setMoveZ(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x < 10) {
|
|
||||||
gameCamera.setMoveX(-scrollSpeed);
|
|
||||||
}
|
|
||||||
else if (x > metrics.getVirtualW() - 10) {
|
|
||||||
gameCamera.setMoveX(scrollSpeed);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gameCamera.setMoveX(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mainMessageBox.getEnabled()) {
|
|
||||||
mainMessageBox.mouseMove(x, y);
|
|
||||||
}
|
|
||||||
if (scriptManager.getMessageBox()->getEnabled()) {
|
|
||||||
scriptManager.getMessageBox()->mouseMove(x, y);
|
|
||||||
}
|
|
||||||
//else if (saveBox) {
|
|
||||||
// saveBox->mouseMove(x, y);
|
|
||||||
//} else {
|
|
||||||
// //graphics
|
|
||||||
gui.mouseMoveGraphics(x, y);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//display
|
|
||||||
if (metrics.isInDisplay(x, y) && !gui.isSelecting() && !gui.isSelectingPos()) {
|
|
||||||
if (!gui.isSelectingPos()) {
|
|
||||||
gui.mouseMoveDisplay(x - metrics.getDisplayX(), y - metrics.getDisplayY());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lastMousePos.x = mouseX;
|
|
||||||
lastMousePos.y = mouseY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::eventMouseWheel(int x, int y, int zDelta) {
|
void Game::eventMouseWheel(int x, int y, int zDelta) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
try {
|
||||||
//gameCamera.transitionXYZ(0.0f, -(float)zDelta / 30.0f, 0.0f);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
gameCamera.zoom((float)zDelta / 60.0f);
|
//gameCamera.transitionXYZ(0.0f, -(float)zDelta / 30.0f, 0.0f);
|
||||||
//gameCamera.setMoveY(1);
|
gameCamera.zoom((float)zDelta / 60.0f);
|
||||||
|
//gameCamera.setMoveY(1);
|
||||||
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::keyDown(char key){
|
void Game::keyDown(char key){
|
||||||
|
try {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
|
||||||
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
|
||||||
|
|
||||||
//send key to the chat manager
|
|
||||||
chatManager.keyDown(key);
|
|
||||||
|
|
||||||
if(!chatManager.getEditEnabled()){
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||||
|
|
||||||
if(key=='N'){
|
Lang &lang= Lang::getInstance();
|
||||||
renderNetworkStatus= true;
|
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
||||||
}
|
|
||||||
else if(key=='M'){
|
|
||||||
showFullConsole= true;
|
|
||||||
}
|
|
||||||
else if(key=='E'){
|
|
||||||
for(int i=0; i<100; ++i){
|
|
||||||
string path= "screens/screen" + intToStr(i) + ".tga";
|
|
||||||
|
|
||||||
FILE *f= fopen(path.c_str(), "rb");
|
//send key to the chat manager
|
||||||
if(f==NULL){
|
chatManager.keyDown(key);
|
||||||
Renderer::getInstance().saveScreen(path);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//move camera left
|
if(!chatManager.getEditEnabled()){
|
||||||
else if(key==vkLeft){
|
|
||||||
gameCamera.setMoveX(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//move camera right
|
|
||||||
else if(key==vkRight){
|
|
||||||
gameCamera.setMoveX(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//move camera up
|
|
||||||
else if(key==vkUp){
|
|
||||||
gameCamera.setMoveZ(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//move camera down
|
|
||||||
else if(key==vkDown){
|
|
||||||
gameCamera.setMoveZ(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//change camera mode
|
|
||||||
else if(key=='F'){
|
|
||||||
gameCamera.switchState();
|
|
||||||
string stateString= gameCamera.getState()==GameCamera::sGame? lang.get("GameCamera"): lang.get("FreeCamera");
|
|
||||||
console.addLine(lang.get("CameraModeSet")+" "+ stateString);
|
|
||||||
}
|
|
||||||
|
|
||||||
//reset camera mode to normal
|
|
||||||
else if(key==' '){
|
|
||||||
gameCamera.resetPosition();
|
|
||||||
}
|
|
||||||
//pause
|
|
||||||
else if(key=='P'){
|
|
||||||
if(speedChangesAllowed){
|
|
||||||
if(paused){
|
|
||||||
console.addLine(lang.get("GameResumed"));
|
|
||||||
paused= false;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
console.addLine(lang.get("GamePaused"));
|
|
||||||
paused= true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//switch display color
|
|
||||||
else if(key=='C'){
|
|
||||||
gui.switchToNextDisplayColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
//increment speed
|
|
||||||
else if(key==vkAdd){
|
|
||||||
if(speedChangesAllowed){
|
|
||||||
incSpeed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//decrement speed
|
|
||||||
else if(key==vkSubtract){
|
|
||||||
if(speedChangesAllowed){
|
|
||||||
decSpeed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//exit
|
|
||||||
else if(key==vkEscape){
|
|
||||||
showMessageBox(lang.get("ExitGame?"), "", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//group
|
|
||||||
else if(key>='0' && key<'0'+Selection::maxGroups){
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||||
|
|
||||||
gui.groupKey(key-'0');
|
if(key=='N'){
|
||||||
}
|
renderNetworkStatus= true;
|
||||||
|
}
|
||||||
|
else if(key=='M'){
|
||||||
|
showFullConsole= true;
|
||||||
|
}
|
||||||
|
else if(key=='E'){
|
||||||
|
for(int i=0; i<100; ++i){
|
||||||
|
string path= "screens/screen" + intToStr(i) + ".tga";
|
||||||
|
|
||||||
//hotkeys
|
FILE *f= fopen(path.c_str(), "rb");
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameCamera.getState() = %d\n",__FILE__,__FUNCTION__,__LINE__,gameCamera.getState());
|
if(f==NULL){
|
||||||
|
Renderer::getInstance().saveScreen(path);
|
||||||
if(gameCamera.getState() == GameCamera::sGame){
|
break;
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
}
|
||||||
|
else{
|
||||||
gui.hotKey(key);
|
fclose(f);
|
||||||
}
|
}
|
||||||
else{
|
}
|
||||||
//rotate camera leftt
|
|
||||||
if(key=='A'){
|
|
||||||
gameCamera.setRotate(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//rotate camera right
|
//move camera left
|
||||||
else if(key=='D'){
|
else if(key==vkLeft){
|
||||||
gameCamera.setRotate(1);
|
gameCamera.setMoveX(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//camera up
|
//move camera right
|
||||||
else if(key=='S'){
|
else if(key==vkRight){
|
||||||
gameCamera.setMoveY(1);
|
gameCamera.setMoveX(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//camera down
|
//move camera up
|
||||||
else if(key=='W'){
|
else if(key==vkUp){
|
||||||
gameCamera.setMoveY(-1);
|
gameCamera.setMoveZ(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//move camera down
|
||||||
|
else if(key==vkDown){
|
||||||
|
gameCamera.setMoveZ(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//change camera mode
|
||||||
|
else if(key=='F'){
|
||||||
|
gameCamera.switchState();
|
||||||
|
string stateString= gameCamera.getState()==GameCamera::sGame? lang.get("GameCamera"): lang.get("FreeCamera");
|
||||||
|
console.addLine(lang.get("CameraModeSet")+" "+ stateString);
|
||||||
|
}
|
||||||
|
|
||||||
|
//reset camera mode to normal
|
||||||
|
else if(key==' '){
|
||||||
|
gameCamera.resetPosition();
|
||||||
|
}
|
||||||
|
//pause
|
||||||
|
else if(key=='P'){
|
||||||
|
if(speedChangesAllowed){
|
||||||
|
if(paused){
|
||||||
|
console.addLine(lang.get("GameResumed"));
|
||||||
|
paused= false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.addLine(lang.get("GamePaused"));
|
||||||
|
paused= true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//switch display color
|
||||||
|
else if(key=='C'){
|
||||||
|
gui.switchToNextDisplayColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
//increment speed
|
||||||
|
else if(key==vkAdd){
|
||||||
|
if(speedChangesAllowed){
|
||||||
|
incSpeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//decrement speed
|
||||||
|
else if(key==vkSubtract){
|
||||||
|
if(speedChangesAllowed){
|
||||||
|
decSpeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//exit
|
||||||
|
else if(key==vkEscape){
|
||||||
|
showMessageBox(lang.get("ExitGame?"), "", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//group
|
||||||
|
else if(key>='0' && key<'0'+Selection::maxGroups){
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||||
|
|
||||||
|
gui.groupKey(key-'0');
|
||||||
|
}
|
||||||
|
|
||||||
|
//hotkeys
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameCamera.getState() = %d\n",__FILE__,__FUNCTION__,__LINE__,gameCamera.getState());
|
||||||
|
|
||||||
|
if(gameCamera.getState() == GameCamera::sGame){
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||||
|
|
||||||
|
gui.hotKey(key);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//rotate camera leftt
|
||||||
|
if(key=='A'){
|
||||||
|
gameCamera.setRotate(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//rotate camera right
|
||||||
|
else if(key=='D'){
|
||||||
|
gameCamera.setRotate(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//camera up
|
||||||
|
else if(key=='S'){
|
||||||
|
gameCamera.setMoveY(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//camera down
|
||||||
|
else if(key=='W'){
|
||||||
|
gameCamera.setMoveY(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::keyUp(char key){
|
void Game::keyUp(char key){
|
||||||
|
try {
|
||||||
if(chatManager.getEditEnabled()){
|
if(chatManager.getEditEnabled()){
|
||||||
//send key to the chat manager
|
//send key to the chat manager
|
||||||
chatManager.keyUp(key);
|
chatManager.keyUp(key);
|
||||||
}
|
|
||||||
else{
|
|
||||||
switch(key){
|
|
||||||
case 'N':
|
|
||||||
renderNetworkStatus= false;
|
|
||||||
break;
|
|
||||||
case 'M':
|
|
||||||
showFullConsole= false;
|
|
||||||
break;
|
|
||||||
case 'A':
|
|
||||||
case 'D':
|
|
||||||
gameCamera.setRotate(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'W':
|
|
||||||
case 'S':
|
|
||||||
gameCamera.setMoveY(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case vkUp:
|
|
||||||
case vkDown:
|
|
||||||
gameCamera.setMoveZ(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case vkLeft:
|
|
||||||
case vkRight:
|
|
||||||
gameCamera.setMoveX(0);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
switch(key){
|
||||||
|
case 'N':
|
||||||
|
renderNetworkStatus= false;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
showFullConsole= false;
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
case 'D':
|
||||||
|
gameCamera.setRotate(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'W':
|
||||||
|
case 'S':
|
||||||
|
gameCamera.setMoveY(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case vkUp:
|
||||||
|
case vkDown:
|
||||||
|
gameCamera.setMoveZ(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case vkLeft:
|
||||||
|
case vkRight:
|
||||||
|
gameCamera.setMoveX(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(const exception &ex) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
networkManager.getGameNetworkInterface()->quitGame(true);
|
||||||
|
ErrorDisplayMessage(ex.what(),true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user