|
@@ -28,7 +28,7 @@
|
|
|
#include "Log.h"
|
|
#include "Log.h"
|
|
|
#include "ProcessUtils.h"
|
|
#include "ProcessUtils.h"
|
|
|
#include "Random.h"
|
|
#include "Random.h"
|
|
|
-#include "Time.h"
|
|
|
|
|
|
|
+#include "Timer.h"
|
|
|
|
|
|
|
|
#include "ConsoleInput.h"
|
|
#include "ConsoleInput.h"
|
|
|
|
|
|
|
@@ -67,6 +67,9 @@ void ConsoleInput::Start()
|
|
|
// Subscribe to console commands and the frame update
|
|
// Subscribe to console commands and the frame update
|
|
|
SubscribeToEvent(E_CONSOLECOMMAND, HANDLER(ConsoleInput, HandleConsoleCommand));
|
|
SubscribeToEvent(E_CONSOLECOMMAND, HANDLER(ConsoleInput, HandleConsoleCommand));
|
|
|
SubscribeToEvent(E_UPDATE, HANDLER(ConsoleInput, HandleUpdate));
|
|
SubscribeToEvent(E_UPDATE, HANDLER(ConsoleInput, HandleUpdate));
|
|
|
|
|
+
|
|
|
|
|
+ // Subscribe key down event
|
|
|
|
|
+ SubscribeToEvent(E_KEYDOWN, HANDLER(ConsoleInput, HandleEscKeyDown));
|
|
|
|
|
|
|
|
// Hide logo to make room for the console
|
|
// Hide logo to make room for the console
|
|
|
SetLogoVisible(false);
|
|
SetLogoVisible(false);
|
|
@@ -102,6 +105,13 @@ void ConsoleInput::HandleUpdate(StringHash eventType, VariantMap& eventData)
|
|
|
HandleInput(input);
|
|
HandleInput(input);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void ConsoleInput::HandleEscKeyDown(StringHash eventType, VariantMap& eventData)
|
|
|
|
|
+{
|
|
|
|
|
+ // Unlike the other samples, exiting the engine when ESC is pressed instead of just closing the console
|
|
|
|
|
+ if (eventData[KeyDown::P_KEY].GetInt() == KEY_ESC)
|
|
|
|
|
+ engine_->Exit();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void ConsoleInput::StartGame()
|
|
void ConsoleInput::StartGame()
|
|
|
{
|
|
{
|
|
|
Print("Welcome to the Urho adventure game! You are the newest fish in the tank; your\n"
|
|
Print("Welcome to the Urho adventure game! You are the newest fish in the tank; your\n"
|
|
@@ -183,9 +193,8 @@ void ConsoleInput::HandleInput(const String& input)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (inputLower == "quit" || inputLower == "exit")
|
|
if (inputLower == "quit" || inputLower == "exit")
|
|
|
- GetSubsystem<Engine>()->Exit();
|
|
|
|
|
-
|
|
|
|
|
- if (gameOn_)
|
|
|
|
|
|
|
+ engine_->Exit();
|
|
|
|
|
+ else if (gameOn_)
|
|
|
{
|
|
{
|
|
|
// Game is on
|
|
// Game is on
|
|
|
if (inputLower == "help")
|
|
if (inputLower == "help")
|
|
@@ -245,7 +254,7 @@ void ConsoleInput::HandleInput(const String& input)
|
|
|
if (inputLower[0] == 'y')
|
|
if (inputLower[0] == 'y')
|
|
|
StartGame();
|
|
StartGame();
|
|
|
else if (inputLower[0] == 'n')
|
|
else if (inputLower[0] == 'n')
|
|
|
- GetSubsystem<Engine>()->Exit();
|
|
|
|
|
|
|
+ engine_->Exit();
|
|
|
else
|
|
else
|
|
|
Print("Please answer 'y' or 'n'.\n");
|
|
Print("Please answer 'y' or 'n'.\n");
|
|
|
}
|
|
}
|