1 /* 2 Copyright (c) 2013 yvt 3 4 This file is part of OpenSpades. 5 6 OpenSpades is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 OpenSpades is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with OpenSpades. If not, see <http://www.gnu.org/licenses/>. 18 19 */ 20 21 #pragma once 22 23 #include "View.h" 24 #include <Client/IAudioDevice.h> 25 #include <Client/IRenderer.h> 26 #include <Core/RefCountedObject.h> 27 #include <Core/ServerAddress.h> 28 #include <ScriptBindings/ScriptManager.h> 29 30 namespace spades { 31 namespace client { 32 class FontManager; 33 } 34 namespace gui { 35 class MainScreenHelper; 36 class MainScreen : public View { 37 friend class MainScreenHelper; 38 Handle<client::IRenderer> renderer; 39 Handle<client::IAudioDevice> audioDevice; 40 Handle<View> subview; 41 Handle<client::FontManager> fontManager; 42 float timeToStartInitialization; 43 44 Handle<MainScreenHelper> helper; 45 Handle<asIScriptObject> ui; 46 47 void DrawStartupScreen(); 48 void DoInit(); 49 50 void RestoreRenderer(); 51 52 std::string Connect(const ServerAddress &host); 53 54 protected: 55 ~MainScreen(); 56 57 public: 58 MainScreen(client::IRenderer *, client::IAudioDevice *, client::FontManager *); 59 GetRenderer()60 client::IRenderer *GetRenderer() { return &*renderer; } GetAudioDevice()61 client::IAudioDevice *GetAudioDevice() { return &*audioDevice; } 62 63 void MouseEvent(float x, float y) override; 64 void KeyEvent(const std::string &, bool down) override; 65 void TextInputEvent(const std::string &) override; 66 void TextEditingEvent(const std::string &, int start, int len) override; 67 bool AcceptsTextInput() override; 68 AABB2 GetTextInputRect() override; 69 void WheelEvent(float x, float y) override; 70 bool NeedsAbsoluteMouseCoordinate() override; 71 72 void RunFrame(float dt) override; 73 74 void Closing() override; 75 76 bool WantsToBeClosed() override; 77 }; 78 ; 79 } 80 } 81