frontend/screens deleted
This commit is contained in:
parent
7415726e47
commit
61ca91b525
@ -12,7 +12,8 @@
|
||||
#include "files/files.h"
|
||||
#include "frontend/locale/langs.h"
|
||||
#include "frontend/menu.hpp"
|
||||
#include "frontend/screens.h"
|
||||
#include "frontend/screens/Screen.hpp"
|
||||
#include "frontend/screens/MenuScreen.hpp"
|
||||
#include "graphics/core/Batch2D.h"
|
||||
#include "graphics/core/GfxContext.h"
|
||||
#include "graphics/core/ImageData.h"
|
||||
|
||||
@ -43,7 +43,6 @@
|
||||
#include "InventoryView.h"
|
||||
#include "LevelFrontend.h"
|
||||
#include "menu.hpp"
|
||||
#include "screens.h"
|
||||
#include "UiDocument.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
#ifndef FRONTEND_SCREENS_H_
|
||||
#define FRONTEND_SCREENS_H_
|
||||
|
||||
#include <memory>
|
||||
#include "../settings.h"
|
||||
#include "../util/ObjectsKeeper.hpp"
|
||||
|
||||
class Assets;
|
||||
class Level;
|
||||
class WorldRenderer;
|
||||
class Hud;
|
||||
class Engine;
|
||||
class Camera;
|
||||
class Batch2D;
|
||||
class LevelFrontend;
|
||||
class LevelController;
|
||||
class TextureAnimator;
|
||||
|
||||
/// @brief Screen is a mainloop state
|
||||
class Screen : public util::ObjectsKeeper {
|
||||
protected:
|
||||
Engine* engine;
|
||||
std::unique_ptr<Batch2D> batch;
|
||||
public:
|
||||
Screen(Engine* engine);
|
||||
virtual ~Screen();
|
||||
virtual void update(float delta) = 0;
|
||||
virtual void draw(float delta) = 0;
|
||||
virtual void onEngineShutdown() {};
|
||||
};
|
||||
|
||||
class MenuScreen : public Screen {
|
||||
std::unique_ptr<Camera> uicamera;
|
||||
public:
|
||||
MenuScreen(Engine* engine);
|
||||
~MenuScreen();
|
||||
|
||||
void update(float delta) override;
|
||||
void draw(float delta) override;
|
||||
};
|
||||
|
||||
class LevelScreen : public Screen {
|
||||
std::unique_ptr<LevelFrontend> frontend;
|
||||
std::unique_ptr<Hud> hud;
|
||||
std::unique_ptr<LevelController> controller;
|
||||
std::unique_ptr<WorldRenderer> worldRenderer;
|
||||
std::unique_ptr<TextureAnimator> animator;
|
||||
|
||||
bool hudVisible = true;
|
||||
void updateHotkeys();
|
||||
public:
|
||||
LevelScreen(Engine* engine, Level* level);
|
||||
~LevelScreen();
|
||||
|
||||
void update(float delta) override;
|
||||
void draw(float delta) override;
|
||||
|
||||
void onEngineShutdown() override;
|
||||
|
||||
LevelController* getLevelController() const;
|
||||
};
|
||||
|
||||
#endif // FRONTEND_SCREENS_H_
|
||||
@ -1,90 +1,22 @@
|
||||
#include "screens.h"
|
||||
#include "LevelScreen.hpp"
|
||||
|
||||
#include "../assets/Assets.h"
|
||||
#include "../audio/audio.h"
|
||||
#include "../content/Content.h"
|
||||
#include "../core_defs.h"
|
||||
#include "../engine.h"
|
||||
#include "../graphics/core/Batch2D.h"
|
||||
#include "../graphics/core/GfxContext.h"
|
||||
#include "../graphics/core/Shader.h"
|
||||
#include "../graphics/core/TextureAnimation.h"
|
||||
#include "../graphics/render/WorldRenderer.h"
|
||||
#include "../graphics/ui/elements/Menu.hpp"
|
||||
#include "../graphics/ui/GUI.h"
|
||||
#include "../logic/ChunksController.h"
|
||||
#include "../logic/LevelController.h"
|
||||
#include "../logic/scripting/scripting_hud.h"
|
||||
#include "../logic/scripting/scripting.h"
|
||||
#include "../objects/Player.h"
|
||||
#include "../physics/Hitbox.h"
|
||||
#include "../util/stringutil.h"
|
||||
#include "../voxels/Block.h"
|
||||
#include "../voxels/Chunk.h"
|
||||
#include "../voxels/Chunks.h"
|
||||
#include "../window/Camera.h"
|
||||
#include "../window/Events.h"
|
||||
#include "../window/input.h"
|
||||
#include "../world/Level.h"
|
||||
#include "../world/World.h"
|
||||
|
||||
#include "ContentGfxCache.h"
|
||||
#include "hud.h"
|
||||
#include "LevelFrontend.h"
|
||||
#include "menu.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <glm/glm.hpp>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
Screen::Screen(Engine* engine) : engine(engine), batch(new Batch2D(1024)) {
|
||||
}
|
||||
|
||||
Screen::~Screen() {
|
||||
}
|
||||
|
||||
MenuScreen::MenuScreen(Engine* engine_) : Screen(engine_) {
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
menu->reset();
|
||||
menu->setPage("main");
|
||||
|
||||
uicamera.reset(new Camera(glm::vec3(), Window::height));
|
||||
uicamera->perspective = false;
|
||||
uicamera->flipped = true;
|
||||
}
|
||||
|
||||
MenuScreen::~MenuScreen() {
|
||||
}
|
||||
|
||||
void MenuScreen::update(float delta) {
|
||||
}
|
||||
|
||||
void MenuScreen::draw(float delta) {
|
||||
Window::clear();
|
||||
Window::setBgColor(glm::vec3(0.2f));
|
||||
|
||||
uicamera->setFov(Window::height);
|
||||
Shader* uishader = engine->getAssets()->getShader("ui");
|
||||
uishader->use();
|
||||
uishader->uniformMatrix("u_projview", uicamera->getProjView());
|
||||
|
||||
uint width = Window::width;
|
||||
uint height = Window::height;
|
||||
|
||||
batch->begin();
|
||||
batch->texture(engine->getAssets()->getTexture("gui/menubg"));
|
||||
batch->rect(
|
||||
0, 0,
|
||||
width, height, 0, 0, 0,
|
||||
UVRegion(0, 0, width/64, height/64),
|
||||
false, false, glm::vec4(1.0f)
|
||||
);
|
||||
batch->flush();
|
||||
}
|
||||
#include "../hud.h"
|
||||
#include "../LevelFrontend.h"
|
||||
#include "../../audio/audio.h"
|
||||
#include "../../graphics/core/GfxContext.h"
|
||||
#include "../../graphics/core/Viewport.h"
|
||||
#include "../../graphics/ui/GUI.h"
|
||||
#include "../../graphics/ui/elements/Menu.hpp"
|
||||
#include "../../graphics/render/WorldRenderer.h"
|
||||
#include "../../logic/LevelController.h"
|
||||
#include "../../logic/scripting/scripting_hud.h"
|
||||
#include "../../physics/Hitbox.h"
|
||||
#include "../../voxels/Chunks.h"
|
||||
#include "../../world/Level.h"
|
||||
#include "../../world/World.h"
|
||||
#include "../../window/Camera.h"
|
||||
#include "../../window/Events.h"
|
||||
#include "../../engine.h"
|
||||
|
||||
LevelScreen::LevelScreen(Engine* engine, Level* level) : Screen(engine) {
|
||||
auto& settings = engine->getSettings();
|
||||
@ -193,3 +125,4 @@ void LevelScreen::onEngineShutdown() {
|
||||
LevelController* LevelScreen::getLevelController() const {
|
||||
return controller.get();
|
||||
}
|
||||
|
||||
37
src/frontend/screens/LevelScreen.hpp
Normal file
37
src/frontend/screens/LevelScreen.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef FRONTEND_SCREENS_LEVEL_SCREEN_HPP_
|
||||
#define FRONTEND_SCREENS_LEVEL_SCREEN_HPP_
|
||||
|
||||
#include "Screen.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Engine;
|
||||
class LevelFrontend;
|
||||
class Hud;
|
||||
class LevelController;
|
||||
class WorldRenderer;
|
||||
class TextureAnimator;
|
||||
class Level;
|
||||
|
||||
class LevelScreen : public Screen {
|
||||
std::unique_ptr<LevelFrontend> frontend;
|
||||
std::unique_ptr<Hud> hud;
|
||||
std::unique_ptr<LevelController> controller;
|
||||
std::unique_ptr<WorldRenderer> worldRenderer;
|
||||
std::unique_ptr<TextureAnimator> animator;
|
||||
|
||||
bool hudVisible = true;
|
||||
void updateHotkeys();
|
||||
public:
|
||||
LevelScreen(Engine* engine, Level* level);
|
||||
~LevelScreen();
|
||||
|
||||
void update(float delta) override;
|
||||
void draw(float delta) override;
|
||||
|
||||
void onEngineShutdown() override;
|
||||
|
||||
LevelController* getLevelController() const;
|
||||
};
|
||||
|
||||
#endif // FRONTEND_SCREENS_LEVEL_SCREEN_HPP_
|
||||
48
src/frontend/screens/MenuScreen.cpp
Normal file
48
src/frontend/screens/MenuScreen.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "MenuScreen.hpp"
|
||||
|
||||
#include "../../graphics/ui/GUI.h"
|
||||
#include "../../graphics/ui/elements/Menu.hpp"
|
||||
#include "../../graphics/core/Batch2D.h"
|
||||
#include "../../graphics/core/Shader.h"
|
||||
#include "../../window/Window.h"
|
||||
#include "../../window/Camera.h"
|
||||
#include "../../engine.h"
|
||||
|
||||
MenuScreen::MenuScreen(Engine* engine_) : Screen(engine_) {
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
menu->reset();
|
||||
menu->setPage("main");
|
||||
|
||||
uicamera.reset(new Camera(glm::vec3(), Window::height));
|
||||
uicamera->perspective = false;
|
||||
uicamera->flipped = true;
|
||||
}
|
||||
|
||||
MenuScreen::~MenuScreen() {
|
||||
}
|
||||
|
||||
void MenuScreen::update(float delta) {
|
||||
}
|
||||
|
||||
void MenuScreen::draw(float delta) {
|
||||
Window::clear();
|
||||
Window::setBgColor(glm::vec3(0.2f));
|
||||
|
||||
uicamera->setFov(Window::height);
|
||||
Shader* uishader = engine->getAssets()->getShader("ui");
|
||||
uishader->use();
|
||||
uishader->uniformMatrix("u_projview", uicamera->getProjView());
|
||||
|
||||
uint width = Window::width;
|
||||
uint height = Window::height;
|
||||
|
||||
batch->begin();
|
||||
batch->texture(engine->getAssets()->getTexture("gui/menubg"));
|
||||
batch->rect(
|
||||
0, 0,
|
||||
width, height, 0, 0, 0,
|
||||
UVRegion(0, 0, width/64, height/64),
|
||||
false, false, glm::vec4(1.0f)
|
||||
);
|
||||
batch->flush();
|
||||
}
|
||||
22
src/frontend/screens/MenuScreen.hpp
Normal file
22
src/frontend/screens/MenuScreen.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef FRONTEND_SCREENS_MENU_SCREEN_HPP_
|
||||
#define FRONTEND_SCREENS_MENU_SCREEN_HPP_
|
||||
|
||||
#include "Screen.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Camera;
|
||||
class Engine;
|
||||
|
||||
class MenuScreen : public Screen {
|
||||
std::unique_ptr<Camera> uicamera;
|
||||
public:
|
||||
MenuScreen(Engine* engine);
|
||||
~MenuScreen();
|
||||
|
||||
void update(float delta) override;
|
||||
void draw(float delta) override;
|
||||
};
|
||||
|
||||
|
||||
#endif // FRONTEND_SCREENS_MENU_SCREEN_HPP_
|
||||
10
src/frontend/screens/Screen.cpp
Normal file
10
src/frontend/screens/Screen.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "Screen.hpp"
|
||||
|
||||
#include "../../graphics/core/Batch2D.h"
|
||||
#include "../../engine.h"
|
||||
|
||||
Screen::Screen(Engine* engine) : engine(engine), batch(new Batch2D(1024)) {
|
||||
}
|
||||
|
||||
Screen::~Screen() {
|
||||
}
|
||||
22
src/frontend/screens/Screen.hpp
Normal file
22
src/frontend/screens/Screen.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef FRONTEND_SCREENS_SCREEN_HPP_
|
||||
#define FRONTEND_SCREENS_SCREEN_HPP_
|
||||
|
||||
#include "../../util/ObjectsKeeper.hpp"
|
||||
|
||||
class Engine;
|
||||
class Batch2D;
|
||||
|
||||
/// @brief Screen is a mainloop state
|
||||
class Screen : public util::ObjectsKeeper {
|
||||
protected:
|
||||
Engine* engine;
|
||||
std::unique_ptr<Batch2D> batch;
|
||||
public:
|
||||
Screen(Engine* engine);
|
||||
virtual ~Screen();
|
||||
virtual void update(float delta) = 0;
|
||||
virtual void draw(float delta) = 0;
|
||||
virtual void onEngineShutdown() {};
|
||||
};
|
||||
|
||||
#endif // FRONTEND_SCREENS_SCREEN_HPP_
|
||||
@ -6,7 +6,8 @@
|
||||
#include "../files/WorldFiles.h"
|
||||
#include "../files/WorldConverter.h"
|
||||
#include "../frontend/locale/langs.h"
|
||||
#include "../frontend/screens.h"
|
||||
#include "../frontend/screens/MenuScreen.hpp"
|
||||
#include "../frontend/screens/LevelScreen.hpp"
|
||||
#include "../frontend/menu.hpp"
|
||||
#include "../graphics/ui/elements/Label.hpp"
|
||||
#include "../graphics/ui/elements/Button.hpp"
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "../../../engine.h"
|
||||
#include "../../../files/engine_paths.h"
|
||||
#include "../../../frontend/menu.hpp"
|
||||
#include "../../../frontend/screens.h"
|
||||
#include "../../../frontend/screens/MenuScreen.hpp"
|
||||
#include "../../../logic/LevelController.h"
|
||||
#include "../../../logic/EngineController.hpp"
|
||||
#include "../../../window/Events.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user