Commit 37b27f76 authored by TheNumbat's avatar TheNumbat
Browse files

add clear button

parent 6327c4a4
...@@ -697,9 +697,14 @@ void Animate::set_max(int frames) { ...@@ -697,9 +697,14 @@ void Animate::set_max(int frames) {
current_frame = std::min(current_frame, max_frame - 1); current_frame = std::min(current_frame, max_frame - 1);
} }
void Animate::set(int n_frames, int fps) { void Animate::set(int n_frames, int fps, bool replace) {
if(replace) {
max_frame = n_frames; max_frame = n_frames;
frame_rate = fps; frame_rate = fps;
} else {
max_frame = std::max(n_frames, max_frame);
frame_rate = std::min(frame_rate, fps);
}
current_frame = std::min(current_frame, max_frame - 1); current_frame = std::min(current_frame, max_frame - 1);
} }
......
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
const Anim_Camera& camera() const; const Anim_Camera& camera() const;
Anim_Camera& camera(); Anim_Camera& camera();
Camera current_camera() const; Camera current_camera() const;
void set(int n_frames, int fps); void set(int n_frames, int fps, bool replace);
void set_max(int frames); void set_max(int frames);
void invalidate(Skeleton::IK_Handle* handle); void invalidate(Skeleton::IK_Handle* handle);
void invalidate(Joint* handle); void invalidate(Joint* handle);
......
...@@ -531,7 +531,14 @@ void Manager::UIsidebar(Scene& scene, Undo& undo, float menu_height, Camera& cam ...@@ -531,7 +531,14 @@ void Manager::UIsidebar(Scene& scene, Undo& undo, float menu_height, Camera& cam
ImGui::Text("Edit Scene"); ImGui::Text("Edit Scene");
if(ImGui::Button("Open Scene")) load_scene(scene, undo, true); if(ImGui::Button("Open Scene")) load_scene(scene, undo, true);
if(wrap_button("Export Scene")) write_scene(scene); if(wrap_button("Export Scene")) write_scene(scene);
if(wrap_button("Settings")) settings_shown = true; if(wrap_button("Clear")) {
std::vector<Scene_ID> ids;
scene.for_items([&](Scene_Item& item) {
ids.push_back(item.id());
});
for(auto id : ids) undo.del_obj(id);
undo.bundle_last(ids.size());
}
if(ImGui::Button("Import Objects")) { if(ImGui::Button("Import Objects")) {
load_scene(scene, undo, false); load_scene(scene, undo, false);
...@@ -544,6 +551,7 @@ void Manager::UIsidebar(Scene& scene, Undo& undo, float menu_height, Camera& cam ...@@ -544,6 +551,7 @@ void Manager::UIsidebar(Scene& scene, Undo& undo, float menu_height, Camera& cam
new_light_window = true; new_light_window = true;
new_light_focus = true; new_light_focus = true;
} }
ImGui::Separator(); ImGui::Separator();
} }
......
...@@ -972,7 +972,8 @@ std::string Scene::load(Scene::Load_Opts loader, Undo& undo, Gui::Manager& gui, ...@@ -972,7 +972,8 @@ std::string Scene::load(Scene::Load_Opts loader, Undo& undo, Gui::Manager& gui,
if(anim->mDuration > 0.0f) { if(anim->mDuration > 0.0f) {
gui.get_animate().set((int)std::ceil(anim->mDuration), gui.get_animate().set((int)std::ceil(anim->mDuration),
(int)std::round(anim->mTicksPerSecond)); (int)std::round(anim->mTicksPerSecond), loader.new_scene);
} }
} }
gui.get_animate().refresh(*this); gui.get_animate().refresh(*this);
......
...@@ -742,6 +742,8 @@ void Undo::redo() { ...@@ -742,6 +742,8 @@ void Undo::redo() {
void Undo::bundle_last(size_t n) { void Undo::bundle_last(size_t n) {
if(!n) return;
std::vector<std::unique_ptr<Action_Base>> undo_pack; std::vector<std::unique_ptr<Action_Base>> undo_pack;
for(size_t i = 0; i < n; i++) { for(size_t i = 0; i < n; i++) {
undo_pack.push_back(std::move(undos.top())); undo_pack.push_back(std::move(undos.top()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment