A bit more refinement.
This commit is contained in:
parent
a7991a8f06
commit
45ad16c010
2 changed files with 7 additions and 5 deletions
|
@ -11,7 +11,7 @@ namespace gui {
|
||||||
class CombatUI {
|
class CombatUI {
|
||||||
public:
|
public:
|
||||||
std::string $grid =
|
std::string $grid =
|
||||||
"[*%(200)hp | _ | *%(200)ap | _ ]"
|
"[*%(200,90)hp | _ | *%(200,90)ap | _ ]"
|
||||||
"[attack1 | attack2 | attack3 | heal]";
|
"[attack1 | attack2 | attack3 | heal]";
|
||||||
lel::Parser $layout;
|
lel::Parser $layout;
|
||||||
GameLevel $level;
|
GameLevel $level;
|
||||||
|
|
10
lel.cpp
10
lel.cpp
|
@ -26,7 +26,6 @@ namespace lel {
|
||||||
cur = {cur.col + 1, cur.row};
|
cur = {cur.col + 1, cur.row};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Parser::finalize() {
|
void Parser::finalize() {
|
||||||
dbc::check(columns > 0, "columns are 0");
|
dbc::check(columns > 0, "columns are 0");
|
||||||
dbc::check(rows > 0, "rows are 0");
|
dbc::check(rows > 0, "rows are 0");
|
||||||
|
@ -54,18 +53,21 @@ namespace lel {
|
||||||
|
|
||||||
cell.w = cell.expand ? std::min(cell.max_w, grid_w) : std::min(cell_width, cell.max_w);
|
cell.w = cell.expand ? std::min(cell.max_w, grid_w) : std::min(cell_width, cell.max_w);
|
||||||
cell.h = cell.expand ? std::min(cell.max_h, grid_h) : std::min(cell_height, cell.max_h);
|
cell.h = cell.expand ? std::min(cell.max_h, grid_h) : std::min(cell_height, cell.max_h);
|
||||||
|
|
||||||
|
dbc::check(cell.h > 0, fmt::format("invalid height cell {}", name));
|
||||||
|
dbc::check(cell.w > 0, fmt::format("invalid width cell {}", name));
|
||||||
|
|
||||||
|
// keep the midpoint since it is used a lot
|
||||||
cell.mid_x = std::midpoint(cell.x, cell.x + cell.w);
|
cell.mid_x = std::midpoint(cell.x, cell.x + cell.w);
|
||||||
cell.mid_y = std::midpoint(cell.y, cell.y + cell.h);
|
cell.mid_y = std::midpoint(cell.y, cell.y + cell.h);
|
||||||
|
|
||||||
|
// perform alignments
|
||||||
if(cell.right) cell.x += cell_width - cell.w;
|
if(cell.right) cell.x += cell_width - cell.w;
|
||||||
if(cell.bottom) cell.y += cell_height - cell.h;
|
if(cell.bottom) cell.y += cell_height - cell.h;
|
||||||
if(cell.center) {
|
if(cell.center) {
|
||||||
cell.x = cell.mid_x - cell.w / 2;
|
cell.x = cell.mid_x - cell.w / 2;
|
||||||
cell.y = cell.mid_y - cell.h / 2;
|
cell.y = cell.mid_y - cell.h / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbc::check(cell.h > 0, fmt::format("invalid height cell {}", name));
|
|
||||||
dbc::check(cell.w > 0, fmt::format("invalid width cell {}", name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue