demo time-based: porta el patro de CCAE (multi-set, index = elapsed_s*60, % size per safe loop), substitueix demo.bin per demo1/2/3.bin
This commit is contained in:
@@ -144,8 +144,9 @@ void Resource::loadDataAsset(const std::string &bname, const std::vector<uint8_t
|
||||
lines.push_back(line);
|
||||
}
|
||||
animation_lines_[bname] = std::move(lines);
|
||||
} else if (bname == "demo.bin") {
|
||||
demo_bytes_ = bytes;
|
||||
} else if (bname.size() > 5 && bname.substr(0, 4) == "demo" && bname.substr(bname.size() - 4) == ".bin") {
|
||||
// Acumula tots els demo*.bin (demo1.bin, demo2.bin, ...) en ordre d'aparicio
|
||||
demo_bytes_.push_back(bytes);
|
||||
}
|
||||
// Menús (.men): se construyen en pass 2 porque dependen de textos y sonidos
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ class Resource {
|
||||
auto getAnimationLines(const std::string &name) -> std::vector<std::string> &;
|
||||
auto getText(const std::string &name) -> Text *; // name sin extensión: "smb2", "nokia2", ...
|
||||
auto getMenu(const std::string &name) -> Menu *; // name sin extensión: "title", "options", ...
|
||||
auto getDemoBytes() const -> const std::vector<uint8_t> & { return demo_bytes_; }
|
||||
[[nodiscard]] auto getDemoCount() const -> size_t { return demo_bytes_.size(); }
|
||||
[[nodiscard]] auto getDemoBytes(size_t index) const -> const std::vector<uint8_t> & { return demo_bytes_.at(index); }
|
||||
|
||||
private:
|
||||
explicit Resource(SDL_Renderer *renderer);
|
||||
@@ -51,7 +52,7 @@ class Resource {
|
||||
std::unordered_map<std::string, std::vector<std::string>> animation_lines_;
|
||||
std::unordered_map<std::string, Text *> texts_;
|
||||
std::unordered_map<std::string, Menu *> menus_;
|
||||
std::vector<uint8_t> demo_bytes_;
|
||||
std::vector<std::vector<uint8_t>> demo_bytes_;
|
||||
|
||||
static Resource *instance;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user