game works as before without a few things

This commit is contained in:
2023-11-29 05:28:54 +02:00
parent f5a2343646
commit 58f605da68
12 changed files with 136 additions and 332 deletions
+19 -19
View File
@@ -16,7 +16,7 @@ unsigned int ui_vao;
unsigned int ui_vbo;
int init_ui(const char* font_path, Size window_size) {
zephr_context.window_size = window_size;
zephr_context.window.size = window_size;
zephr_context.projection = orthographic_projection_2d(0.f, window_size.width, window_size.height, 0.f);
int res = init_fonts(font_path);
@@ -54,7 +54,7 @@ void set_x_constraint(UIConstraints *constraints, float value, UIConstraint type
constraints->x = value;
break;
case UI_CONSTRAINT_RELATIVE:
constraints->x = (value * zephr_context.window_size.width);
constraints->x = (value * zephr_context.window.size.width);
break;
}
}
@@ -68,7 +68,7 @@ void set_y_constraint(UIConstraints *constraints, float value, UIConstraint type
constraints->y = value;
break;
case UI_CONSTRAINT_RELATIVE:
constraints->y = (value * zephr_context.window_size.height);
constraints->y = (value * zephr_context.window.size.height);
break;
}
}
@@ -79,10 +79,10 @@ void set_width_constraint(UIConstraints *constraints, float value, UIConstraint
constraints->width = value;
break;
case UI_CONSTRAINT_RELATIVE:
constraints->width = (value * zephr_context.window_size.width);
constraints->width = (value * zephr_context.window.size.width);
break;
case UI_CONSTRAINT_RELATIVE_PIXELS:
constraints->width = zephr_context.window_size.width / (float)zephr_context.screen_size.width * value;
constraints->width = zephr_context.window.size.width / (float)zephr_context.screen_size.width * value;
break;
case UI_CONSTRAINT_ASPECT_RATIO:
constraints->width = constraints->height * value;
@@ -96,10 +96,10 @@ void set_height_constraint(UIConstraints *constraints, float value, UIConstraint
constraints->height = value;
break;
case UI_CONSTRAINT_RELATIVE:
constraints->height = (value * zephr_context.window_size.height);
constraints->height = (value * zephr_context.window.size.height);
break;
case UI_CONSTRAINT_RELATIVE_PIXELS:
constraints->height = zephr_context.window_size.height / (float)zephr_context.screen_size.height * value;
constraints->height = zephr_context.window.size.height / (float)zephr_context.screen_size.height * value;
break;
case UI_CONSTRAINT_ASPECT_RATIO:
constraints->height = constraints->width * value;
@@ -123,36 +123,36 @@ void apply_alignment(Alignment align, Vec2f *pos, Sizef size) {
pos->y = pos->y;
break;
case ALIGN_TOP_CENTER:
pos->x += zephr_context.window_size.width / 2.f - size.width / 2.f;
pos->x += zephr_context.window.size.width / 2.f - size.width / 2.f;
pos->y = pos->y;
break;
case ALIGN_TOP_RIGHT:
pos->x += zephr_context.window_size.width - size.width;
pos->x += zephr_context.window.size.width - size.width;
pos->y = pos->y;
break;
case ALIGN_BOTTOM_LEFT:
pos->x = pos->x;
pos->y += zephr_context.window_size.height - size.height;
pos->y += zephr_context.window.size.height - size.height;
break;
case ALIGN_BOTTOM_CENTER:
pos->x += zephr_context.window_size.width / 2.f - size.width / 2.f;
pos->y += zephr_context.window_size.height - size.height;
pos->x += zephr_context.window.size.width / 2.f - size.width / 2.f;
pos->y += zephr_context.window.size.height - size.height;
break;
case ALIGN_BOTTOM_RIGHT:
pos->x += zephr_context.window_size.width - size.width;
pos->y += zephr_context.window_size.height - size.height;
pos->x += zephr_context.window.size.width - size.width;
pos->y += zephr_context.window.size.height - size.height;
break;
case ALIGN_LEFT_CENTER:
pos->x = pos->x;
pos->y += zephr_context.window_size.height / 2.f - size.height / 2.f;
pos->y += zephr_context.window.size.height / 2.f - size.height / 2.f;
break;
case ALIGN_RIGHT_CENTER:
pos->x += zephr_context.window_size.width - size.width;
pos->y += zephr_context.window_size.height / 2.f - size.height / 2.f;
pos->x += zephr_context.window.size.width - size.width;
pos->y += zephr_context.window.size.height / 2.f - size.height / 2.f;
break;
case ALIGN_CENTER:
pos->x += zephr_context.window_size.width / 2.f - size.width / 2.f;
pos->y += zephr_context.window_size.height / 2.f - size.height / 2.f;
pos->x += zephr_context.window.size.width / 2.f - size.width / 2.f;
pos->y += zephr_context.window.size.height / 2.f - size.height / 2.f;
break;
}
}