refactor(渲染器): 优化相机切换时的渲染批处理 feat(调试工具): 新增游戏调试UI场景和九宫格面板组件 fix(动画系统): 跳过缺失的动画资源加载并记录日志 perf(资源加载): 使用BinaryFileStreamReader优化NPK文件解析 feat(地图系统): 支持多边形可行走区域调试显示 style(代码格式): 清理多余空格和统一文件编码 docs(注释): 补充关键类和方法的文档说明 test(启动跟踪): 添加启动过程性能跟踪工具 chore(依赖): 添加SDL2_ttf库支持
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
|
|
#include <frostbite2D/2d/actor.h>
|
|
#include <frostbite2D/2d/sprite.h>
|
|
|
|
namespace frostbite2D {
|
|
|
|
/**
|
|
* @brief Composes 9 consecutive NPK frames into a resizable nine-slice panel.
|
|
*/
|
|
class NineSliceActor : public Actor {
|
|
public:
|
|
NineSliceActor();
|
|
~NineSliceActor() override = default;
|
|
|
|
static Ptr<NineSliceActor> createFromNpk(const std::string& imgPath,
|
|
size_t startIndex = 0);
|
|
|
|
bool SetSlices(const std::string& imgPath, size_t startIndex);
|
|
void SetSize(const Vec2& size);
|
|
void SetSize(float width, float height);
|
|
|
|
const std::string& GetImgPath() const { return imgPath_; }
|
|
size_t GetStartIndex() const { return startIndex_; }
|
|
|
|
private:
|
|
enum SliceIndex : size_t {
|
|
TopLeft = 0,
|
|
Top = 1,
|
|
TopRight = 2,
|
|
Left = 3,
|
|
Center = 4,
|
|
Right = 5,
|
|
BottomLeft = 6,
|
|
Bottom = 7,
|
|
BottomRight = 8,
|
|
SliceCount = 9
|
|
};
|
|
|
|
void updateLayout();
|
|
void applySliceLayout(Ptr<Sprite> sprite, const Vec2& position,
|
|
const Vec2& size);
|
|
Vec2 getNaturalSize() const;
|
|
|
|
std::string imgPath_;
|
|
size_t startIndex_ = 0;
|
|
std::array<Ptr<Sprite>, SliceCount> sliceSprites_;
|
|
std::array<Vec2, SliceCount> sliceNaturalSizes_ = {};
|
|
};
|
|
|
|
} // namespace frostbite2D
|