refactor viewport
This commit is contained in:
36
types.h
36
types.h
@@ -60,11 +60,11 @@ enum ItemType {
|
||||
ITEM_TYPE_COUNT
|
||||
};
|
||||
|
||||
template <>
|
||||
template<>
|
||||
struct std::formatter<ItemType> : std::formatter<string_view> {
|
||||
bool title_case = false;
|
||||
|
||||
constexpr auto parse(std::format_parse_context& ctx) {
|
||||
constexpr auto parse(std::format_parse_context &ctx) {
|
||||
auto it = ctx.begin();
|
||||
if (it == ctx.end()) return it;
|
||||
|
||||
@@ -76,7 +76,7 @@ struct std::formatter<ItemType> : std::formatter<string_view> {
|
||||
return it;
|
||||
}
|
||||
|
||||
auto format(const ItemType& item_type, std::format_context& ctx) const {
|
||||
auto format(const ItemType &item_type, std::format_context &ctx) const {
|
||||
std::string_view item_type_str;
|
||||
switch (item_type) {
|
||||
case TEARS_UP:
|
||||
@@ -122,3 +122,33 @@ struct Item {
|
||||
assert(0 && "Unreachable.");
|
||||
}
|
||||
};
|
||||
|
||||
struct Viewport {
|
||||
Viewport() = default;
|
||||
|
||||
Viewport(const float screen_width, const float screen_height)
|
||||
: screen_width(screen_width),
|
||||
screen_height(screen_height),
|
||||
padding(50),
|
||||
level_width(screen_width - padding * 2),
|
||||
level_height(screen_height - padding * 2),
|
||||
level_left(padding),
|
||||
level_top(padding),
|
||||
level_right(level_width + padding),
|
||||
level_bottom(level_height + padding) {
|
||||
}
|
||||
|
||||
Viewport& operator=(const Viewport &other) = default;
|
||||
|
||||
float screen_width;
|
||||
float screen_height;
|
||||
|
||||
float padding;
|
||||
|
||||
float level_width;
|
||||
float level_height;
|
||||
float level_left;
|
||||
float level_top;
|
||||
float level_right;
|
||||
float level_bottom;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user