mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-29 03:46:50 +01:00
Plugins register modes (card, replaces, order, flag, players) and publish documents through reskate.throwdowns.ui: the setup page, the waiting card, HUD slots themed on the game's HUD_<theme>_* widgets, the match panel, flags and match restrictions. SmokeyDawg58's native plumbing (throwdown_menu.cpp and its .inl files) renders them and posts throwdown_ui events back. kit::flag is the one native flag registration. General services added for it: reskate.files, reskate.ui.dialog, reskate.skater push/hold/bone_cam, reskate.camera.pad_flight, reskate.physics competition, reskate.session.world, reskate.tricks feed/gesture, and world entities. His ten modes are now Lua in his plugin: the rules, referee and wire (td/rules, referee, wire), and every page and HUD document (td/ui*.lua). Extension/Modes and reskate.modes are gone, along with every race and 1-UP branch in the SDK. The plugin test drives each mode through kit events. A native setup page is never written to while it closes into flag placement: its rows are not republished, the stock page is put back once the exit is over, and the stock Players slider is left alone while a plugin flag is out. This fixes the crashes on the Deathrace button and on 1-UP's Confirm.
54 lines
2.2 KiB
C++
54 lines
2.2 KiB
C++
#pragma once
|
|
#include <cstdint>
|
|
#include <span>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
// The Throwdowns page's cards: the game's three stock throwdowns and every plugin mode
|
|
// (custom_modes.h), in SmokeyDawg58's logo grid. Built from the plugins' modes; nothing here knows
|
|
// a particular mode.
|
|
namespace dingosdk::throwdowns {
|
|
enum class Adapter : std::uint8_t { native_skate, native_spot, native_jam, plugin };
|
|
struct Palette {
|
|
std::uint32_t primary{}, secondary{}, accent{}, background=0xff171717U, text=0xffffffffU;
|
|
bool operator==(const Palette&) const = default;
|
|
};
|
|
struct Definition {
|
|
// A plugin mode's id is its custom_modes key ("<plugin>/<id>"); the stock ones are
|
|
// "native.skate", "native.spot" and "native.jam".
|
|
std::string id, name, description, logo;
|
|
std::string plugin; // empty for the stock throwdowns
|
|
std::string flag; // the mode's placement-preview prefab (custom_modes Mode::flag)
|
|
Adapter adapter{};
|
|
unsigned donor=1; // the stock card it is cloned from: 0 S.K.A.T.E., 1 Spot Battle, 2 Skate Jam
|
|
std::string replaces; // "skate" | "spot" | "jam": the stock tile whose place it takes
|
|
int order{}; // the grid order among plugin modes
|
|
Palette palette;
|
|
int min_players=1, max_players=6, players=4;
|
|
float cursor_height{}; // > 0: its flag's placement cursor may rise this far (custom_modes Mode::cursor_height)
|
|
bool operator==(const Definition&) const = default;
|
|
};
|
|
struct Registration {
|
|
bool accepted{}, inserted{};
|
|
std::string error;
|
|
};
|
|
class Registry {
|
|
std::vector<Definition> definitions_;
|
|
std::uint64_t revision_{};
|
|
public:
|
|
Registration add(Definition definition);
|
|
const Definition* find(std::string_view id) const noexcept;
|
|
std::span<const Definition> definitions() const noexcept { return definitions_; }
|
|
std::uint64_t revision() const noexcept { return revision_; }
|
|
// Empties it for a rebuild; the revision still only grows, so a reader sees the change.
|
|
void clear() noexcept {
|
|
definitions_.clear();
|
|
++revision_;
|
|
}
|
|
};
|
|
Palette palette_for(std::string_view stable_id) noexcept;
|
|
// Rebuilt when the plugins' modes change; read on the UI thread.
|
|
Registry& registry();
|
|
}
|