feat(screenshot): add screenshot viewer scene

Add SCREENSHOT scene and UI to browse screenshots from the main menu,
with localization for English and Chinese. Also allow image loading
by full path and replace scene-operation asserts with error logs.
This commit is contained in:
2026-08-07 14:34:58 +08:00
parent 607be871b1
commit ef0fc7c5c0
12 changed files with 234 additions and 13 deletions

View File

@@ -9,7 +9,8 @@ enum class SceneType {
CREDITS,
SETTINGS,
HOST_GAME,
JOIN_GAME
JOIN_GAME,
SCREENSHOT
};
class Scene {

View File

@@ -0,0 +1,29 @@
#pragma once
#include "Cubed/scene/scene.hpp"
#include "Cubed/ui/screenshot_ui.hpp"
namespace Cubed {
class SceneManager;
class ScreenshotScene : public Scene {
public:
ScreenshotScene(SceneManager& scene_manager);
~ScreenshotScene();
ScreenshotScene(const ScreenshotScene&) = delete;
ScreenshotScene(ScreenshotScene&&) = delete;
ScreenshotScene& operator=(const ScreenshotScene&) = delete;
ScreenshotScene& operator=(ScreenshotScene&&) = delete;
void update(float dt) override;
void render(Renderer& renderer) override;
bool handle_event(const Event& e) override;
void on_enter() override;
void on_leave() override;
void on_re_enter() override;
SceneManager& scene_manager();
private:
SceneManager& m_scene_manager;
ScreenshotUI m_ui;
};
} // namespace Cubed

View File

@@ -20,7 +20,8 @@ public:
const Texture* get_block_status_array() const;
const Texture* get_texture_array() const;
const Texture* get_cross_plane_array() const;
const Texture* get_image_texture(const std::string& path);
const Texture* get_image_texture(const std::string& path,
bool full_path = false);
const Texture* get_pbr_texture() const;
const ItemTextureMap& get_item_textures() const;
const Texture* get_skin() const;
@@ -49,7 +50,8 @@ private:
void load_block_texture(unsigned block_id);
void init_item_texture();
void load_cross_plane_texture(unsigned id);
const Texture* load_image_texture(const std::string& path);
const Texture* load_image_texture(const std::string& path,
bool full_path = false);
void load_pbr_texture(unsigned id);
void init_item();
void init_block();

View File

@@ -0,0 +1,23 @@
#pragma once
#include "Cubed/ui/ui_manager.hpp"
namespace Cubed {
class ScreenshotScene;
class ScreenshotUI : public UIManager {
public:
ScreenshotUI(ScreenshotScene& m_scene);
~ScreenshotUI();
ScreenshotUI(const ScreenshotUI&) = delete;
ScreenshotUI(ScreenshotUI&&) = delete;
ScreenshotUI& operator=(const ScreenshotUI&) = delete;
ScreenshotUI& operator=(ScreenshotUI&&) = delete;
void init();
void update_layout(int width, int height);
private:
ScreenshotScene& m_scene;
};
} // namespace Cubed