Add status macros and refactor overworld

This commit is contained in:
scawful
2022-08-23 13:26:06 -05:00
parent 86b36b1ba0
commit 6dd4c390fe
4 changed files with 65 additions and 41 deletions

View File

@@ -25,16 +25,43 @@
#define MENU_ITEM(w) if (ImGui::MenuItem(w))
#define MENU_ITEM2(w, v) if (ImGui::MenuItem(w, v))
#define CHECK_STATUS(w) \
if (!w.ok()) { \
return w; \
#define RETURN_IF_ERROR(expression) \
{ \
auto error = expression; \
if (!error.ok()) { \
return error; \
} \
}
#define ASSIGN_OR_RETURN(type_variable_name, expression) \
ASSIGN_OR_RETURN_IMPL(APPEND_NUMBER(error_or_value, __LINE__), \
type_variable_name, expression)
#define ASSIGN_OR_RETURN_IMPL(error_or_value, type_variable_name, expression) \
auto error_or_value = expression; \
if (!error_or_value.ok()) { \
return error_or_value.status(); \
} \
type_variable_name = std::move(*error_or_value);
#define APPEND_NUMBER(expression, number) \
APPEND_NUMBER_INNER(expression, number)
#define APPEND_NUMBER_INNER(expression, number) expression##number
using ushort = unsigned short;
using uint = unsigned int;
using uchar = unsigned char;
using Bytes = std::vector<uchar>;
using OWBlockset = std::vector<std::vector<ushort>>;
struct OWMapTiles {
OWBlockset light_world; // 64 maps
OWBlockset dark_world; // 64 maps
OWBlockset special_world; // 32 maps
};
using OWMapTiles = struct OWMapTiles;
namespace yaze {
namespace app {
namespace core {

View File

@@ -80,9 +80,9 @@ void HandleMouseMovement(int &wheel) {
bool Controller::isActive() const { return active_; }
absl::Status Controller::onEntry() {
CHECK_STATUS(CreateWindow())
CHECK_STATUS(CreateRenderer())
CHECK_STATUS(CreateGuiContext())
RETURN_IF_ERROR(CreateWindow())
RETURN_IF_ERROR(CreateRenderer())
RETURN_IF_ERROR(CreateGuiContext())
InitializeKeymap();
master_editor_.SetupScreen(renderer_);
active_ = true;