Add editor for Camera Focus rectangles
This commit is contained in:
parent
8f790e497a
commit
9cd789cf53
30
map.cpp
30
map.cpp
@ -56,6 +56,8 @@ void ui_map() {
|
||||
e = new Textbox();
|
||||
CMD("LEVEL_TRANSITION")
|
||||
e = new LevelTransition();
|
||||
CMD("CAMERA_FOCUS")
|
||||
e = new CameraFocus();
|
||||
CMD("CUTOFF")
|
||||
cutoff = strtod(strtok(NULL, " "), NULL);
|
||||
|
||||
@ -72,22 +74,38 @@ void ui_map() {
|
||||
|
||||
Vec2 center = Vec2(ig::GetIO().DisplaySize) * 0.5 - offset;
|
||||
ig::SeparatorText("Add Entity");
|
||||
if (ig::Button("Hitbox"))
|
||||
if (ig::Button("Hitbox")) {
|
||||
entities.push_back((new Hitbox())->setpos(center));
|
||||
selected_entity = entities.back();
|
||||
}
|
||||
ig::SameLine();
|
||||
if (ig::Button("Player"))
|
||||
if (ig::Button("Player")) {
|
||||
entities.push_back((new Player())->setpos(center));
|
||||
selected_entity = entities.back();
|
||||
}
|
||||
ig::SameLine();
|
||||
if (ig::Button("Hazard Respawn"))
|
||||
if (ig::Button("Hazard Respawn")) {
|
||||
entities.push_back((new HazardRespawn())->setpos(center));
|
||||
if (ig::Button("Hazard"))
|
||||
selected_entity = entities.back();
|
||||
}
|
||||
if (ig::Button("Hazard")) {
|
||||
entities.push_back((new Hazard())->setpos(center));
|
||||
selected_entity = entities.back();
|
||||
}
|
||||
ig::SameLine();
|
||||
if (ig::Button("Textbox"))
|
||||
if (ig::Button("Textbox")) {
|
||||
entities.push_back((new Textbox())->setpos(center));
|
||||
selected_entity = entities.back();
|
||||
}
|
||||
ig::SameLine();
|
||||
if (ig::Button("Level Transition"))
|
||||
if (ig::Button("Level Transition")) {
|
||||
entities.push_back((new LevelTransition())->setpos(center));
|
||||
selected_entity = entities.back();
|
||||
}
|
||||
if (ig::Button("Camera Focus")) {
|
||||
entities.push_back((new CameraFocus())->setpos(center));
|
||||
selected_entity = entities.back();
|
||||
}
|
||||
|
||||
DragDouble("Cutoff depth", &cutoff);
|
||||
|
||||
|
@ -285,3 +285,30 @@ public:
|
||||
Box2 box;
|
||||
std::string next_level;
|
||||
};
|
||||
|
||||
|
||||
class CameraFocus: public EntityBase {
|
||||
public:
|
||||
std::string type() override { return "camera_focus"; }
|
||||
std::string to_file() override {
|
||||
snprintf(buf, sizeof(buf), "CAMERA_FOCUS %.0lf %.0lf %.0lf %.0lf\n", box.lefttop.x, box.lefttop.y, box.size.x, box.size.y);
|
||||
return buf;
|
||||
}
|
||||
void from_strtok() override {
|
||||
double a, b, c, d;
|
||||
a = TOKEN_DOUBLE;
|
||||
b = TOKEN_DOUBLE;
|
||||
c = TOKEN_DOUBLE;
|
||||
d = TOKEN_DOUBLE;
|
||||
box = Box2(a, b, c, d);
|
||||
}
|
||||
|
||||
void imgui() override { DragBox2("", &box); }
|
||||
void draw(Vec2 offset, bool selected) override { draw_box2(box.offset(offset), selected, IM_COL32(0, 255, 255, 255)); }
|
||||
EntityBase *setpos(Vec2 pos) override {
|
||||
box.lefttop = pos;
|
||||
return this;
|
||||
}
|
||||
|
||||
Box2 box;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user