|
|
|
@ -4,14 +4,11 @@ |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
#include <fmt/core.h> |
|
|
|
#include <fmt/core.h> |
|
|
|
#include <GLFW/glfw3.h> |
|
|
|
#include <GLFW/glfw3.h> |
|
|
|
|
|
|
|
#include "config.hpp" |
|
|
|
|
|
|
|
|
|
|
|
namespace guecs { |
|
|
|
namespace guecs { |
|
|
|
using std::make_shared; |
|
|
|
using std::make_shared; |
|
|
|
|
|
|
|
|
|
|
|
inline SpriteTexture load_texture(const string& name, bool is_icon) { |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Text::init(lel::Cell &cell, const std::string& font_file) { |
|
|
|
void Text::init(lel::Cell &cell, const std::string& font_file) { |
|
|
|
assert(text == nullptr && "Double init on text."); |
|
|
|
assert(text == nullptr && "Double init on text."); |
|
|
|
|
|
|
|
|
|
|
|
@ -46,16 +43,18 @@ namespace guecs { |
|
|
|
void Sprite::update(const string& new_name) { |
|
|
|
void Sprite::update(const string& new_name) { |
|
|
|
if(new_name != name) { |
|
|
|
if(new_name != name) { |
|
|
|
name = new_name; |
|
|
|
name = new_name; |
|
|
|
// CHANGE: get the image and save it
|
|
|
|
dbc::sentinel("Swapping Images Not Implemented yet!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Sprite::init(lel::Cell &cell) { |
|
|
|
void Sprite::init(lel::Cell &cell) { |
|
|
|
if(cell.center) stretch = false; |
|
|
|
if(cell.center) stretch = false; |
|
|
|
|
|
|
|
// handle is_icon
|
|
|
|
|
|
|
|
image = make_shared<::Image>(); |
|
|
|
|
|
|
|
image->load(name); |
|
|
|
|
|
|
|
|
|
|
|
auto sprite_texture = load_texture(name, is_icon); |
|
|
|
|
|
|
|
// setup the image size and such
|
|
|
|
// setup the image size and such
|
|
|
|
glm::vec2 bounds{0.0, 0.0}; // get this from the image
|
|
|
|
glm::vec2 bounds{image->width, image->height}; // get this from the image
|
|
|
|
|
|
|
|
|
|
|
|
if(stretch) { |
|
|
|
if(stretch) { |
|
|
|
// handle stretch
|
|
|
|
// handle stretch
|
|
|
|
@ -65,13 +64,23 @@ namespace guecs { |
|
|
|
float scale = std::min(box_width / float(bounds.x), box_height / float(bounds.y)); |
|
|
|
float scale = std::min(box_width / float(bounds.x), box_height / float(bounds.y)); |
|
|
|
|
|
|
|
|
|
|
|
// no stretch so scale it
|
|
|
|
// no stretch so scale it
|
|
|
|
|
|
|
|
image->scale.x = (bounds.x / float(WINDOW_WIDTH)) * scale; |
|
|
|
|
|
|
|
image->scale.y = (bounds.y / float(WINDOW_HEIGHT)) * scale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// find center point of cell since origin of image is center (for now)
|
|
|
|
|
|
|
|
image->position.x = (cell.x + box_width / 2); |
|
|
|
|
|
|
|
image->position.y = (cell.y + box_height / 2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt::println("pos: {},{} | bounds: {},{} | box: {},{} | scale: {}", |
|
|
|
|
|
|
|
image->position.x, image->position.y, bounds.x, bounds.y, box_width, box_height, scale); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// used the center helper here
|
|
|
|
// used the center helper here
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Sprite::render() { |
|
|
|
void Sprite::render() { |
|
|
|
|
|
|
|
// apply position and scale....
|
|
|
|
|
|
|
|
image->render(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Rectangle::init(lel::Cell& cell) { |
|
|
|
void Rectangle::init(lel::Cell& cell) { |
|
|
|
|