2013-11-22 22:50:14 +09:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 yvt
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
This file is part of OpenSpades.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
OpenSpades is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
OpenSpades is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-12-03 18:23:47 +09:00
|
|
|
*/
|
2013-11-22 22:50:14 +09:00
|
|
|
|
|
|
|
#include "MainScreen.h"
|
2013-11-23 22:13:04 +09:00
|
|
|
#include "MainScreenHelper.h"
|
2013-11-24 02:27:08 +09:00
|
|
|
#include <Client/Client.h>
|
2014-02-08 22:37:46 +09:00
|
|
|
#include <Client/Fonts.h>
|
2016-12-03 18:23:47 +09:00
|
|
|
#include <Core/Exception.h>
|
2014-02-14 16:24:10 +09:00
|
|
|
#include <Core/Strings.h>
|
2015-01-24 12:44:57 +09:00
|
|
|
#include <ScriptBindings/Config.h>
|
2016-12-03 18:23:47 +09:00
|
|
|
#include <ScriptBindings/ScriptFunction.h>
|
2013-11-24 02:27:08 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
namespace spades {
|
|
|
|
namespace gui {
|
2019-07-20 15:31:36 +09:00
|
|
|
MainScreen::MainScreen(Handle<client::IRenderer> _renderer,
|
|
|
|
Handle<client::IAudioDevice> _audioDevice,
|
|
|
|
Handle<client::FontManager> _fontManager)
|
|
|
|
: renderer(std::move(_renderer)),
|
|
|
|
audioDevice(std::move(_audioDevice)),
|
|
|
|
fontManager(std::move(_fontManager)) {
|
2013-11-23 22:13:04 +09:00
|
|
|
SPADES_MARK_FUNCTION();
|
2019-07-20 15:31:36 +09:00
|
|
|
if (!renderer) {
|
|
|
|
SPInvalidArgument("renderer");
|
|
|
|
}
|
|
|
|
if (!audioDevice) {
|
|
|
|
SPInvalidArgument("audioDevice");
|
|
|
|
}
|
|
|
|
if (!fontManager) {
|
|
|
|
SPInvalidArgument("fontManager");
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-23 22:13:04 +09:00
|
|
|
helper = new MainScreenHelper(this);
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-23 22:13:04 +09:00
|
|
|
// first call to RunFrame tends to have larger dt value.
|
|
|
|
// so this value is set in the first call.
|
|
|
|
timeToStartInitialization = 1000.f;
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
MainScreen::~MainScreen() {
|
2013-11-23 22:13:04 +09:00
|
|
|
SPADES_MARK_FUNCTION();
|
|
|
|
helper->MainScreenDestroyed();
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-24 02:27:08 +09:00
|
|
|
// Restores renderer's state (game map, fog color)
|
|
|
|
// after returning from the game client.
|
|
|
|
void MainScreen::RestoreRenderer() {
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-11-24 02:27:08 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void SetupRenderer()");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c.ExecuteChecked();
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2014-02-01 21:55:30 +09:00
|
|
|
bool MainScreen::NeedsAbsoluteMouseCoordinate() {
|
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2014-02-01 21:55:30 +09:00
|
|
|
return subview->NeedsAbsoluteMouseCoordinate();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
void MainScreen::MouseEvent(float x, float y) {
|
2013-11-23 22:13:04 +09:00
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-11-22 22:50:14 +09:00
|
|
|
subview->MouseEvent(x, y);
|
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-11-23 22:13:04 +09:00
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-11-23 22:13:04 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void MouseEvent(float, float)");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c->SetArgFloat(0, x);
|
|
|
|
c->SetArgFloat(1, y);
|
|
|
|
c.ExecuteChecked();
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-09 17:36:05 +09:00
|
|
|
void MainScreen::WheelEvent(float x, float y) {
|
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-12-09 17:36:05 +09:00
|
|
|
subview->WheelEvent(x, y);
|
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-12-09 17:36:05 +09:00
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-12-09 17:36:05 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void WheelEvent(float, float)");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c->SetArgFloat(0, x);
|
|
|
|
c->SetArgFloat(1, y);
|
|
|
|
c.ExecuteChecked();
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
void MainScreen::KeyEvent(const std::string &key, bool down) {
|
2013-11-23 22:13:04 +09:00
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-11-22 22:50:14 +09:00
|
|
|
subview->KeyEvent(key, down);
|
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-11-23 22:13:04 +09:00
|
|
|
return;
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-11-23 22:13:04 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void KeyEvent(string, bool)");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
std::string k = key;
|
|
|
|
c->SetObject(&*ui);
|
2016-12-03 18:23:47 +09:00
|
|
|
c->SetArgObject(0, reinterpret_cast<void *>(&k));
|
2013-11-23 22:13:04 +09:00
|
|
|
c->SetArgByte(1, down ? 1 : 0);
|
|
|
|
c.ExecuteChecked();
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-09 17:36:05 +09:00
|
|
|
void MainScreen::TextInputEvent(const std::string &ch) {
|
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-12-09 17:36:05 +09:00
|
|
|
subview->TextInputEvent(ch);
|
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-12-09 17:36:05 +09:00
|
|
|
return;
|
|
|
|
}
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-12-09 17:36:05 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void TextInputEvent(string)");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
std::string k = ch;
|
|
|
|
c->SetObject(&*ui);
|
2016-12-03 18:23:47 +09:00
|
|
|
c->SetArgObject(0, reinterpret_cast<void *>(&k));
|
2013-12-09 17:36:05 +09:00
|
|
|
c.ExecuteChecked();
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
void MainScreen::TextEditingEvent(const std::string &ch, int start, int len) {
|
2013-11-23 22:13:04 +09:00
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-12-09 17:36:05 +09:00
|
|
|
subview->TextEditingEvent(ch, start, len);
|
2013-11-22 22:50:14 +09:00
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-11-23 22:13:04 +09:00
|
|
|
return;
|
|
|
|
}
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-12-09 17:36:05 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void TextEditingEvent(string, int, int)");
|
2013-11-23 22:13:04 +09:00
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
std::string k = ch;
|
|
|
|
c->SetObject(&*ui);
|
2016-12-03 18:23:47 +09:00
|
|
|
c->SetArgObject(0, reinterpret_cast<void *>(&k));
|
2013-12-09 17:36:05 +09:00
|
|
|
c->SetArgDWord(1, static_cast<asDWORD>(start));
|
|
|
|
c->SetArgDWord(2, static_cast<asDWORD>(len));
|
|
|
|
c.ExecuteChecked();
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-09 17:36:05 +09:00
|
|
|
bool MainScreen::AcceptsTextInput() {
|
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-12-09 17:36:05 +09:00
|
|
|
return subview->AcceptsTextInput();
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-12-09 17:36:05 +09:00
|
|
|
return false;
|
|
|
|
}
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-12-09 17:36:05 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "bool AcceptsTextInput()");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c.ExecuteChecked();
|
|
|
|
return c->GetReturnByte() != 0;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-09 17:36:05 +09:00
|
|
|
AABB2 MainScreen::GetTextInputRect() {
|
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-12-09 17:36:05 +09:00
|
|
|
return subview->GetTextInputRect();
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-12-09 17:36:05 +09:00
|
|
|
return AABB2();
|
|
|
|
}
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-12-09 17:36:05 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "AABB2 GetTextInputRect()");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
2013-11-23 22:13:04 +09:00
|
|
|
c.ExecuteChecked();
|
2016-12-03 18:23:47 +09:00
|
|
|
return *reinterpret_cast<AABB2 *>(c->GetReturnObject());
|
2013-11-23 22:13:04 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-23 22:13:04 +09:00
|
|
|
bool MainScreen::WantsToBeClosed() {
|
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (!ui) {
|
2013-11-23 22:13:04 +09:00
|
|
|
return false;
|
|
|
|
}
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-11-23 22:13:04 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "bool WantsToBeClosed()");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c.ExecuteChecked();
|
|
|
|
return c->GetReturnByte() != 0;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-23 22:13:04 +09:00
|
|
|
void MainScreen::DrawStartupScreen() {
|
|
|
|
SPADES_MARK_FUNCTION();
|
|
|
|
Handle<client::IImage> img;
|
2016-12-03 18:23:47 +09:00
|
|
|
Vector2 scrSize = {renderer->ScreenWidth(), renderer->ScreenHeight()};
|
|
|
|
|
2013-12-09 01:00:09 +09:00
|
|
|
renderer->SetColorAlphaPremultiplied(MakeVector4(0, 0, 0, 1.));
|
2013-11-23 22:13:04 +09:00
|
|
|
img = renderer->RegisterImage("Gfx/White.tga");
|
2016-12-03 18:23:47 +09:00
|
|
|
renderer->DrawImage(img, AABB2(0, 0, scrSize.x, scrSize.y));
|
|
|
|
|
2014-02-14 16:20:42 +09:00
|
|
|
std::string str = _Tr("MainScreen", "NOW LOADING");
|
2019-07-20 15:31:36 +09:00
|
|
|
client::IFont &font = fontManager->GetGuiFont();
|
|
|
|
Vector2 size = font.Measure(str);
|
2013-11-23 22:13:04 +09:00
|
|
|
Vector2 pos = MakeVector2(scrSize.x - 16.f, scrSize.y - 16.f);
|
|
|
|
pos -= size;
|
2019-07-20 15:31:36 +09:00
|
|
|
font.DrawShadow(str, pos, 1.f, MakeVector4(1, 1, 1, 1), MakeVector4(0, 0, 0, 0.5));
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-23 22:13:04 +09:00
|
|
|
renderer->FrameDone();
|
|
|
|
renderer->Flip();
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
void MainScreen::RunFrame(float dt) {
|
2013-11-23 22:13:04 +09:00
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
|
|
|
try {
|
2013-11-24 02:27:08 +09:00
|
|
|
subview->RunFrame(dt);
|
2019-07-14 00:27:03 +09:00
|
|
|
return;
|
2016-12-03 18:23:47 +09:00
|
|
|
} catch (const std::exception &ex) {
|
2014-03-15 21:56:45 +09:00
|
|
|
SPLog("[!] Error while running a game client: %s", ex.what());
|
2013-11-24 02:27:08 +09:00
|
|
|
subview->Closing();
|
|
|
|
subview = NULL;
|
|
|
|
RestoreRenderer();
|
|
|
|
helper->errorMessage = ex.what();
|
|
|
|
}
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (timeToStartInitialization > 100.f) {
|
2013-11-23 22:13:04 +09:00
|
|
|
timeToStartInitialization = 0.2f;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
if (timeToStartInitialization > 0.f) {
|
2013-11-23 22:13:04 +09:00
|
|
|
DrawStartupScreen();
|
|
|
|
timeToStartInitialization -= dt;
|
2016-12-03 18:23:47 +09:00
|
|
|
if (timeToStartInitialization <= 0.f) {
|
2013-11-23 22:13:04 +09:00
|
|
|
// do init
|
|
|
|
DoInit();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-11-23 22:13:04 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void RunFrame(float)");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c->SetArgFloat(0, dt);
|
|
|
|
c.ExecuteChecked();
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2019-07-14 00:27:03 +09:00
|
|
|
void MainScreen::RunFrameLate(float dt) {
|
|
|
|
SPADES_MARK_FUNCTION();
|
|
|
|
if (subview) {
|
|
|
|
try {
|
|
|
|
subview->RunFrameLate(dt);
|
|
|
|
if (subview->WantsToBeClosed()) {
|
|
|
|
subview->Closing();
|
|
|
|
subview = NULL;
|
|
|
|
RestoreRenderer();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (const std::exception &ex) {
|
|
|
|
SPLog("[!] Error while running a game client: %s", ex.what());
|
|
|
|
subview->Closing();
|
|
|
|
subview = NULL;
|
|
|
|
RestoreRenderer();
|
|
|
|
helper->errorMessage = ex.what();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-14 18:32:17 +09:00
|
|
|
if (!ui) {
|
|
|
|
return;
|
|
|
|
}
|
2019-07-14 00:27:03 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
|
|
|
static ScriptFunction func("MainScreenUI", "void RunFrameLate(float)");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c->SetArgFloat(0, dt);
|
|
|
|
c.ExecuteChecked();
|
|
|
|
}
|
|
|
|
|
2013-11-23 22:13:04 +09:00
|
|
|
void MainScreen::DoInit() {
|
|
|
|
SPADES_MARK_FUNCTION();
|
|
|
|
renderer->Init();
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2016-12-03 18:23:47 +09:00
|
|
|
static ScriptFunction uiFactory("MainScreenUI@ CreateMainScreenUI(Renderer@, "
|
2016-12-16 05:05:23 +09:00
|
|
|
"AudioDevice@, FontManager@, MainScreenHelper@)");
|
2013-11-23 22:13:04 +09:00
|
|
|
{
|
|
|
|
ScriptContextHandle ctx = uiFactory.Prepare();
|
2019-07-20 15:31:36 +09:00
|
|
|
ctx->SetArgObject(0, renderer.GetPointerOrNull());
|
|
|
|
ctx->SetArgObject(1, audioDevice.GetPointerOrNull());
|
|
|
|
ctx->SetArgObject(2, fontManager.GetPointerOrNull());
|
2013-11-23 22:13:04 +09:00
|
|
|
ctx->SetArgObject(3, &*helper);
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-23 22:13:04 +09:00
|
|
|
ctx.ExecuteChecked();
|
|
|
|
ui = reinterpret_cast<asIScriptObject *>(ctx->GetReturnObject());
|
|
|
|
}
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-22 22:50:14 +09:00
|
|
|
void MainScreen::Closing() {
|
2013-11-23 22:13:04 +09:00
|
|
|
SPADES_MARK_FUNCTION();
|
2016-12-03 18:23:47 +09:00
|
|
|
if (subview) {
|
2013-11-22 22:50:14 +09:00
|
|
|
subview->Closing();
|
|
|
|
subview = NULL;
|
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
if (!ui) {
|
2013-11-23 22:13:04 +09:00
|
|
|
return;
|
|
|
|
}
|
2015-01-24 12:44:57 +09:00
|
|
|
ScopedPrivilegeEscalation privilege;
|
2013-11-23 22:13:04 +09:00
|
|
|
static ScriptFunction func("MainScreenUI", "void Closing()");
|
|
|
|
ScriptContextHandle c = func.Prepare();
|
|
|
|
c->SetObject(&*ui);
|
|
|
|
c.ExecuteChecked();
|
2013-11-22 22:50:14 +09:00
|
|
|
}
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2019-07-14 18:32:17 +09:00
|
|
|
bool MainScreen::ExecCommand(const Handle<ConsoleCommand> &cmd) {
|
|
|
|
SPADES_MARK_FUNCTION();
|
|
|
|
if (subview) {
|
|
|
|
return subview->ExecCommand(cmd);
|
|
|
|
}
|
|
|
|
return View::ExecCommand(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle<ConsoleCommandCandidateIterator>
|
|
|
|
MainScreen::AutocompleteCommandName(const std::string &name) {
|
|
|
|
SPADES_MARK_FUNCTION();
|
|
|
|
if (subview) {
|
|
|
|
return subview->AutocompleteCommandName(name);
|
|
|
|
}
|
|
|
|
return View::AutocompleteCommandName(name);
|
|
|
|
}
|
|
|
|
|
2017-01-05 03:03:39 +09:00
|
|
|
std::string MainScreen::Connect(const ServerAddress &host) {
|
2013-11-24 02:27:08 +09:00
|
|
|
try {
|
2019-07-20 17:01:04 +09:00
|
|
|
subview = Handle<client::Client>::New(&*renderer, &*audioDevice, host, fontManager)
|
|
|
|
.Cast<View>();
|
2016-12-03 18:23:47 +09:00
|
|
|
} catch (const std::exception &ex) {
|
2014-03-15 21:56:45 +09:00
|
|
|
SPLog("[!] Error while initializing a game client: %s", ex.what());
|
2013-11-24 02:27:08 +09:00
|
|
|
return ex.what();
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2019-07-14 18:32:17 +09:00
|
|
|
} // namespace gui
|
|
|
|
} // namespace spades
|