block.material + minor refactor
This commit is contained in:
parent
8730b03a52
commit
b1a79e3a6e
Binary file not shown.
|
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 5.3 KiB |
@ -128,7 +128,7 @@ void Engine::mainloop() {
|
||||
updateHotkeys();
|
||||
audio::update(delta);
|
||||
|
||||
gui->act(delta);
|
||||
gui->act(delta, Viewport(Window::width, Window::height));
|
||||
screen->update(delta);
|
||||
|
||||
if (!Window::isIconified()) {
|
||||
|
||||
@ -72,13 +72,15 @@ void LevelScreen::saveWorldPreview() {
|
||||
logger.info() << "saving world preview";
|
||||
auto paths = engine->getPaths();
|
||||
auto player = controller->getPlayer();
|
||||
auto& settings = engine->getSettings();
|
||||
int previewSize = settings.ui.worldPreviewSize.get();
|
||||
|
||||
// camera special copy for world preview
|
||||
Camera camera = *player->camera;
|
||||
camera.setFov(glm::radians(70.0f));
|
||||
auto& settings = engine->getSettings();
|
||||
int previewSize = settings.ui.worldPreviewSize.get();
|
||||
Viewport viewport(previewSize * 1.5, previewSize);
|
||||
GfxContext ctx(nullptr, viewport, batch.get());
|
||||
|
||||
worldRenderer->draw(ctx, &camera, false, postProcessing.get());
|
||||
auto image = postProcessing->toImage();
|
||||
image->flipY();
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "../../graphics/ui/elements/Menu.hpp"
|
||||
#include "../../graphics/core/Batch2D.hpp"
|
||||
#include "../../graphics/core/Shader.hpp"
|
||||
#include "../../graphics/core/Texture.hpp"
|
||||
#include "../../window/Window.h"
|
||||
#include "../../window/Camera.h"
|
||||
#include "../../engine.h"
|
||||
@ -16,7 +17,7 @@ MenuScreen::MenuScreen(Engine* engine) : Screen(engine) {
|
||||
menu->reset();
|
||||
menu->setPage("main");
|
||||
|
||||
uicamera.reset(new Camera(glm::vec3(), Window::height));
|
||||
uicamera = std::make_unique<Camera>(glm::vec3(), Window::height);
|
||||
uicamera->perspective = false;
|
||||
uicamera->flipped = true;
|
||||
}
|
||||
@ -28,23 +29,26 @@ void MenuScreen::update(float delta) {
|
||||
}
|
||||
|
||||
void MenuScreen::draw(float delta) {
|
||||
auto assets = engine->getAssets();
|
||||
|
||||
Window::clear();
|
||||
Window::setBgColor(glm::vec3(0.2f));
|
||||
|
||||
uicamera->setFov(Window::height);
|
||||
Shader* uishader = engine->getAssets()->getShader("ui");
|
||||
Shader* uishader = assets->getShader("ui");
|
||||
uishader->use();
|
||||
uishader->uniformMatrix("u_projview", uicamera->getProjView());
|
||||
|
||||
uint width = Window::width;
|
||||
uint height = Window::height;
|
||||
|
||||
auto bg = assets->getTexture("gui/menubg");
|
||||
batch->begin();
|
||||
batch->texture(engine->getAssets()->getTexture("gui/menubg"));
|
||||
batch->texture(bg);
|
||||
batch->rect(
|
||||
0, 0,
|
||||
width, height, 0, 0, 0,
|
||||
UVRegion(0, 0, width/64, height/64),
|
||||
UVRegion(0, 0, width/bg->getWidth(), height/bg->getHeight()),
|
||||
false, false, glm::vec4(1.0f)
|
||||
);
|
||||
batch->flush();
|
||||
|
||||
@ -113,16 +113,14 @@ void GUI::actFocused() {
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Processing user input and UI logic
|
||||
/// @param delta delta time
|
||||
void GUI::act(float delta) {
|
||||
void GUI::act(float delta, const Viewport& vp) {
|
||||
while (!postRunnables.empty()) {
|
||||
runnable callback = postRunnables.back();
|
||||
postRunnables.pop();
|
||||
callback();
|
||||
}
|
||||
|
||||
container->setSize(glm::vec2(Window::width, Window::height));
|
||||
container->setSize(vp.size());
|
||||
container->act(delta);
|
||||
auto prevfocus = focus;
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
#include "../../delegates.h"
|
||||
|
||||
class Viewport;
|
||||
class GfxContext;
|
||||
class Assets;
|
||||
class Camera;
|
||||
@ -80,7 +81,8 @@ namespace gui {
|
||||
|
||||
/// @brief Main input handling and logic update method
|
||||
/// @param delta delta time
|
||||
void act(float delta);
|
||||
/// @param viewport window size
|
||||
void act(float delta, const Viewport& viewport);
|
||||
|
||||
/// @brief Draw all visible elements on main container
|
||||
/// @param pctx parent graphics context
|
||||
|
||||
@ -22,6 +22,18 @@ int l_block_name(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int l_block_material(lua_State* L) {
|
||||
auto indices = scripting::content->getIndices();
|
||||
lua::luaint id = lua_tointeger(L, 1);
|
||||
if (id < 0 || size_t(id) >= indices->countBlockDefs()) {
|
||||
return 0;
|
||||
}
|
||||
auto def = indices->getBlockDef(id);
|
||||
lua_pushstring(L, def->material.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_is_solid_at(lua_State* L) {
|
||||
lua::luaint x = lua_tointeger(L, 1);
|
||||
lua::luaint y = lua_tointeger(L, 2);
|
||||
@ -218,6 +230,7 @@ int l_is_replaceable_at(lua_State* L) {
|
||||
const luaL_Reg blocklib [] = {
|
||||
{"index", lua_wrap_errors<l_block_index>},
|
||||
{"name", lua_wrap_errors<l_block_name>},
|
||||
{"material", lua_wrap_errors<l_block_material>},
|
||||
{"defs_count", lua_wrap_errors<l_blocks_count>},
|
||||
{"is_solid_at", lua_wrap_errors<l_is_solid_at>},
|
||||
{"is_replaceable_at", lua_wrap_errors<l_is_replaceable_at>},
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
#include "../typedefs.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
|
||||
#include "./stringutil.h"
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include "../maths/util.h"
|
||||
#include "../core_defs.h"
|
||||
|
||||
// TODO: do something with long conditions + move magic numbers to constants
|
||||
// will be refactored in generators update
|
||||
|
||||
const int SEA_LEVEL = 55;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user