Merge pull request #102189 from KoBeWi/frames_per_setting

Add editor setting for FPS mode and compat
This commit is contained in:
Thaddeus Crews
2025-03-11 16:54:04 -05:00
6 changed files with 33 additions and 10 deletions

View File

@@ -3894,6 +3894,7 @@ bool AnimationTrackEditor::has_keying() const {
Dictionary AnimationTrackEditor::get_state() const {
Dictionary state;
state["fps_mode"] = timeline->is_using_fps();
state["fps_compat"] = fps_compat->is_pressed();
state["zoom"] = zoom->get_value();
state["offset"] = timeline->get_value();
state["v_scroll"] = scroll->get_v_scroll_bar()->get_value();
@@ -3909,27 +3910,34 @@ void AnimationTrackEditor::set_state(const Dictionary &p_state) {
snap_mode->select(0);
}
_snap_mode_changed(snap_mode->get_selected());
} else {
snap_mode->select(0);
_snap_mode_changed(snap_mode->get_selected());
}
if (p_state.has("fps_compat")) {
fps_compat->set_pressed(p_state["fps_compat"]);
}
if (p_state.has("zoom")) {
zoom->set_value(p_state["zoom"]);
} else {
zoom->set_value(1.0);
}
if (p_state.has("offset")) {
timeline->set_value(p_state["offset"]);
} else {
timeline->set_value(0);
}
if (p_state.has("v_scroll")) {
scroll->get_v_scroll_bar()->set_value(p_state["v_scroll"]);
} else {
scroll->get_v_scroll_bar()->set_value(0);
}
}
void AnimationTrackEditor::clear() {
snap_mode->select(EDITOR_GET("editors/animation/default_fps_mode"));
_snap_mode_changed(snap_mode->get_selected());
fps_compat->set_pressed(EDITOR_GET("editors/animation/default_fps_compatibility"));
zoom->set_value(1.0);
timeline->set_value(0);
scroll->get_v_scroll_bar()->set_value(0);
}
void AnimationTrackEditor::cleanup() {
set_animation(Ref<Animation>(), read_only);
}
@@ -7704,9 +7712,9 @@ AnimationTrackEditor::AnimationTrackEditor() {
snap_mode = memnew(OptionButton);
snap_mode->add_item(TTR("Seconds"));
snap_mode->add_item(TTR("FPS"));
snap_mode->set_disabled(true);
bottom_hf->add_child(snap_mode);
snap_mode->connect(SceneStringName(item_selected), callable_mp(this, &AnimationTrackEditor::_snap_mode_changed));
snap_mode->set_disabled(true);
bottom_hf->add_child(memnew(VSeparator));