summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/game.cpp b/src/game.cpp
index c54f7abe..bcfd9ac2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -96,7 +96,6 @@ Joystick *joystick = NULL;
OkDialog *weightNotice = NULL;
OkDialog *deathNotice = NULL;
QuitDialog *quitDialog = NULL;
-OkDialog *disconnectedDialog = NULL;
ChatWindow *chatWindow;
StatusWindow *statusWindow;
@@ -128,7 +127,7 @@ ChatTab *localChatTab = NULL;
*/
static void initEngines()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_ENGINESINITALIZING);
+ Event::trigger(Event::GameChannel, Event::EnginesInitializing);
actorSpriteManager = new ActorSpriteManager;
commandHandler = new CommandHandler;
@@ -138,7 +137,7 @@ static void initEngines()
particleEngine = new Particle(NULL);
particleEngine->setupEngine();
- Mana::Event::trigger(CHANNEL_GAME, EVENT_ENGINESINITALIZED);
+ Event::trigger(Event::GameChannel, Event::EnginesInitialized);
}
/**
@@ -146,7 +145,7 @@ static void initEngines()
*/
static void createGuiWindows()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSLOADING);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsLoading);
setupWindow->clearWindowsForReset();
@@ -183,7 +182,7 @@ static void createGuiWindows()
NpcDialog::setup();
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSLOADED);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsLoaded);
}
#define del_0(X) { delete X; X = 0; }
@@ -193,7 +192,7 @@ static void createGuiWindows()
*/
static void destroyGuiWindows()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSUNLOADING);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsUnloading);
del_0(localChatTab) // Need to do this first, so it can remove itself
del_0(chatWindow)
@@ -212,9 +211,9 @@ static void destroyGuiWindows()
del_0(specialsWindow)
del_0(socialWindow)
- Mana::Event::trigger(CHANNEL_NPC, EVENT_CLOSEALL); // Cleanup remaining NPC dialogs
+ Event::trigger(Event::NpcChannel, Event::CloseAll); // Cleanup remaining NPC dialogs
- Mana::Event::trigger(CHANNEL_GAME, EVENT_GUIWINDOWSUNLOADED);
+ Event::trigger(Event::GameChannel, Event::GuiWindowsUnloaded);
}
Game *Game::mInstance = 0;
@@ -226,8 +225,6 @@ Game::Game():
assert(!mInstance);
mInstance = this;
- disconnectedDialog = NULL;
-
// Create the viewport
viewport = new Viewport;
viewport->setDimension(gcn::Rectangle(0, 0, graphics->getWidth(),
@@ -266,12 +263,12 @@ Game::Game():
setupWindow->setInGame(true);
- Mana::Event::trigger(CHANNEL_GAME, EVENT_CONSTRUCTED);
+ Event::trigger(Event::GameChannel, Event::Constructed);
}
Game::~Game()
{
- Mana::Event::trigger(CHANNEL_GAME, EVENT_DESTRUCTING);
+ Event::trigger(Event::GameChannel, Event::Destructing);
delete mWindowMenu;
@@ -289,7 +286,7 @@ Game::~Game()
mInstance = 0;
- Mana::Event::trigger(CHANNEL_GAME, EVENT_DESTRUCTED);
+ Event::trigger(Event::GameChannel, Event::Destructed);
}
static bool saveScreenshot()
@@ -386,14 +383,9 @@ void Game::logic()
return; // Disconnect gets handled by STATE_ERROR
errorMessage = _("The connection to the server was lost.");
-
- if (!disconnectedDialog)
- {
- disconnectedDialog = new OkDialog(_("Network Error"),
- errorMessage);
- disconnectedDialog->addActionListener(&errorListener);
- disconnectedDialog->requestMoveToTop();
- }
+ Client::instance()->showOkDialog(_("Network Error"),
+ errorMessage,
+ STATE_CHOOSE_SERVER);
}
}
@@ -638,7 +630,7 @@ void Game::handleInput()
break;
}
if (keyboard.isEnabled() && !chatWindow->isInputFocused() &&
- !NpcDialog::isAnyInputFocused())
+ !NpcDialog::isAnyInputFocused() && !InventoryWindow::isAnyInputFocused())
{
const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
@@ -991,15 +983,15 @@ void Game::changeMap(const std::string &mapPath)
if (newMusic != oldMusic)
{
if (newMusic.empty())
- sound.stopMusic();
+ sound.fadeOutMusic();
else
- sound.playMusic(newMusic);
+ sound.fadeOutAndPlayMusic(newMusic);
}
delete mCurrentMap;
mCurrentMap = newMap;
- Mana::Event event(EVENT_MAPLOADED);
+ Event event(Event::MapLoaded);
event.setString("mapPath", mapPath);
- event.trigger(CHANNEL_GAME);
+ event.trigger(Event::GameChannel);
}