From de1bf2efb4635d068e9ac8b0fee88567e7ab49c0 Mon Sep 17 00:00:00 2001 From: DSDemen <149813486+DSDemen@users.noreply.github.com> Date: Sun, 7 Jan 2024 11:57:20 +0200 Subject: [PATCH 1/6] Added Finnish language --- res/texts/fi_FI.txt | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 res/texts/fi_FI.txt diff --git a/res/texts/fi_FI.txt b/res/texts/fi_FI.txt new file mode 100644 index 00000000..dbc85649 --- /dev/null +++ b/res/texts/fi_FI.txt @@ -0,0 +1,53 @@ +# Общее +Yes=Joo +No=Ei +Ok = Kyllä +Cancel= Hylää +Back = Takaisin +Continue=Jatka + +error.pack-not-found=Pakettia ei löytynyt! + +# Меню +menu.New World = Uusi Maailma +menu.Quit=Poistu +menu.Continue=Jatka +menu.Save and Quit to Menu=Tallenna ja Takaisin valikoon +menu.missing-content=Puuttuu jotkut lisäosat! +menu.Controls=Ohjaus +menu.Back to Main Menu=Takaisin Valikoon +menu.Settings=Asetukset +menu.Content=Lisäosat +menu.Seed=Siemen +menu.Name=Nimi +menu.Create World=Luo Maailma + +world.convert-request=Indeksit vaihdettu! Lataa maailma uudeleen? + +# Настройки +settings.Load Distance=Lataus Alue +settings.Load Speed=Lataus Nopeus +settings.Fog Curve=Sumun valaistus +settings.Backlight=Valaistus +settings.V-Sync=Pystytahdistus + +settings.FOV=Näkökenttä +settings.Mouse Sensitivity=Hiiren nopeus +settings.Language=Kieli + +# Управление +movement.forward=Eteenpäin +movement.back=Taaksepäin +movement.left=Vaseemalle +movement.right=Oikealle +movement.jump=Hyppy +movement.sprint=Kiihtyvyys +movement.crouch=Istu alas +movement.cheat=Huijata +hud.inventory=Varasto +player.pick=Ottaa lohko +player.attack=Lyödä / Rikkoa +player.build=Aseta lohko +player.flight=Lento +camera.zoom=Lähentäminen +camera.mode=Vaihda Kameratila \ No newline at end of file From 4b64e1b03b77a4af092c857ff5c627ce4301719f Mon Sep 17 00:00:00 2001 From: DSDemen <149813486+DSDemen@users.noreply.github.com> Date: Sun, 7 Jan 2024 11:58:57 +0200 Subject: [PATCH 2/6] Update langs.json --- res/texts/langs.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/res/texts/langs.json b/res/texts/langs.json index 1f1c884c..2dc4aab4 100644 --- a/res/texts/langs.json +++ b/res/texts/langs.json @@ -14,6 +14,9 @@ }, "uk_UA": { "name": "Українська" + }, + "fi_FI": { + "name": "Suomi" } }, "fallback": "en_US" From d4c4c4d399b63c7aab22d8efc8030b3413197154 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 7 Jan 2024 14:25:00 +0300 Subject: [PATCH 3/6] hud refactor --- src/frontend/InventoryView.cpp | 40 +++++++++-------- src/frontend/InventoryView.h | 20 +++++---- src/frontend/hud.cpp | 79 +++++++++++++++++----------------- src/frontend/hud.h | 2 + 4 files changed, 75 insertions(+), 66 deletions(-) diff --git a/src/frontend/InventoryView.cpp b/src/frontend/InventoryView.cpp index 6685535f..1ee28db7 100644 --- a/src/frontend/InventoryView.cpp +++ b/src/frontend/InventoryView.cpp @@ -15,34 +15,36 @@ InventoryView::InventoryView( int columns, - Player* player, const Assets* assets, const ContentIndices* indices, const ContentGfxCache* cache, std::vector blocks) - : player(player), - assets(assets), + : assets(assets), indices(indices), cache(cache), blocks(blocks), - invColumns(columns) { + columns(columns) { blocksPreview = new BlocksPreview(assets->getShader("ui3d"), assets->getAtlas("blocks"), cache); } void InventoryView::setPosition(int x, int y) { - this->invX = x; - this->invY = y; + position.x = x; + position.y = y; } int InventoryView::getWidth() const { - return invColumns * iconSize + (invColumns-1) * interval + padX * 2; + return columns * iconSize + (columns-1) * interval + padding.x * 2; } int InventoryView::getHeight() const { - uint inv_rows = ceildiv(blocks.size(), invColumns); - return inv_rows * iconSize + (inv_rows-1) * interval + padY * 2; + uint inv_rows = ceildiv(blocks.size(), columns); + return inv_rows * iconSize + (inv_rows-1) * interval + padding.y * 2; +} + +void InventoryView::setSlotConsumer(slotconsumer consumer) { + this->consumer = consumer; } void InventoryView::actAndDraw(const GfxContext* ctx) { @@ -51,8 +53,8 @@ void InventoryView::actAndDraw(const GfxContext* ctx) { auto viewport = ctx->getViewport(); uint inv_w = getWidth(); uint inv_h = getHeight(); - int xs = invX + padX; - int ys = invY + padY; + int xs = position.x + padding.x; + int ys = position.y + padding.y; glm::vec4 tint (1.0f); int mx = Events::cursor.x; @@ -62,15 +64,15 @@ void InventoryView::actAndDraw(const GfxContext* ctx) { auto batch = ctx->getBatch2D(); batch->texture(nullptr); batch->color = glm::vec4(0.0f, 0.0f, 0.0f, 0.5f); - batch->rect(invX, invY, inv_w, inv_h); + batch->rect(position.x, position.y, inv_w, inv_h); batch->render(); // blocks & items if (Events::scroll) { - inventoryScroll -= Events::scroll * (iconSize+interval); + scroll -= Events::scroll * (iconSize+interval); } - inventoryScroll = std::min(inventoryScroll, int(inv_h-viewport.getHeight())); - inventoryScroll = std::max(inventoryScroll, 0); + scroll = std::min(scroll, int(inv_h-viewport.getHeight())); + scroll = std::max(scroll, 0); blocksPreview->begin(&ctx->getViewport()); { Window::clearDepth(); @@ -80,8 +82,8 @@ void InventoryView::actAndDraw(const GfxContext* ctx) { uint index = 0; for (uint i = 0; i < blocks.size(); i++) { Block* cblock = indices->getBlockDef(blocks[i]); - int x = xs + (iconSize+interval) * (index % invColumns); - int y = ys + (iconSize+interval) * (index / invColumns) - inventoryScroll; + int x = xs + (iconSize+interval) * (index % columns); + int y = ys + (iconSize+interval) * (index / columns) - scroll; if (y < -int(iconSize+interval) || y >= int(viewport.getHeight())) { index++; continue; @@ -91,7 +93,9 @@ void InventoryView::actAndDraw(const GfxContext* ctx) { tint.g *= 1.2f; tint.b *= 1.2f; if (Events::jclicked(mousecode::BUTTON_1)) { - player->chosenBlock = blocks[i]; + if (consumer) { + consumer(blocks[i]); + } } } else { tint = glm::vec4(1.0f); diff --git a/src/frontend/InventoryView.h b/src/frontend/InventoryView.h index 792fec42..fe85be22 100644 --- a/src/frontend/InventoryView.h +++ b/src/frontend/InventoryView.h @@ -2,44 +2,46 @@ #define FRONTEND_INVENTORY_VIEW_H_ #include +#include +#include #include "../typedefs.h" -class Player; class Assets; class GfxContext; class ContentIndices; class BlocksPreview; class ContentGfxCache; +typedef std::function slotconsumer; + class InventoryView { - Player* player; const Assets* assets; const ContentIndices* indices; const ContentGfxCache* const cache; std::vector blocks; BlocksPreview* blocksPreview; + slotconsumer consumer = nullptr; - int inventoryScroll = 0; - int invColumns; + int scroll = 0; + int columns; uint iconSize = 48; uint interval = 4; - int padX = interval; - int padY = interval; - int invX = 0; - int invY = 0; + glm::ivec2 padding {interval, interval}; + glm::ivec2 position {0, 0}; public: InventoryView( int columns, - Player* player, const Assets* assets, const ContentIndices* indices, const ContentGfxCache* cache, std::vector blocks); + void setPosition(int x, int y); void actAndDraw(const GfxContext* ctx); int getWidth() const; int getHeight() const; + void setSlotConsumer(slotconsumer consumer); }; #endif // FRONTEND_INVENTORY_VIEW_H_ diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 2e8b7b3c..be5004fc 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -55,39 +55,8 @@ inline Label* create_label(gui::wstringsupplier supplier) { return label; } -HudRenderer::HudRenderer(Engine* engine, - Level* level, - const ContentGfxCache* cache) - : level(level), - assets(engine->getAssets()), - gui(engine->getGUI()), - cache(cache) { - auto menu = gui->getMenu(); - blocksPreview = new BlocksPreview(assets->getShader("ui3d"), - assets->getAtlas("blocks"), - cache); - auto content = level->content; - auto indices = content->indices; - std::vector blocks; - for (blockid_t id = 1; id < indices->countBlockDefs(); id++) { - const Block* def = indices->getBlockDef(id); - if (def->hidden) - continue; - blocks.push_back(id); - } - contentAccess.reset(new InventoryView( - 8, - level->player, - assets, - indices, - cache, - blocks)); - - uicamera = new Camera(vec3(), 1); - uicamera->perspective = false; - uicamera->flipped = true; - - Panel* panel = new Panel(vec2(250, 200), vec4(5.0f), 1.0f); +void HudRenderer::createDebugPanel(Engine* engine) { + Panel* panel = new Panel(vec2(250, 200), vec4(5.0f), 1.0f); debugPanel = shared_ptr(panel); panel->listenInterval(1.0f, [this]() { fpsString = std::to_wstring(fpsMax)+L" / "+std::to_wstring(fpsMin); @@ -106,16 +75,16 @@ HudRenderer::HudRenderer(Engine* engine, bool culling = settings.graphics.frustumCulling; return L"frustum-culling: "+wstring(culling ? L"on" : L"off"); }))); - panel->add(shared_ptr