mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
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:
@@ -9,7 +9,8 @@ enum class SceneType {
|
||||
CREDITS,
|
||||
SETTINGS,
|
||||
HOST_GAME,
|
||||
JOIN_GAME
|
||||
JOIN_GAME,
|
||||
SCREENSHOT
|
||||
};
|
||||
|
||||
class Scene {
|
||||
|
||||
29
include/Cubed/scene/screenshot_scene.hpp
Normal file
29
include/Cubed/scene/screenshot_scene.hpp
Normal 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
|
||||
@@ -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();
|
||||
|
||||
23
include/Cubed/ui/screenshot_ui.hpp
Normal file
23
include/Cubed/ui/screenshot_ui.hpp
Normal 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
|
||||
Reference in New Issue
Block a user