mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-11 22:50:08 +00:00
moved is_current_selection_has_external_refs to SceneController
This commit is contained in:
+2
-1
@@ -57,6 +57,7 @@ pub mod world;
|
||||
|
||||
pub use fyrox;
|
||||
|
||||
use crate::scene::controller::SceneController;
|
||||
use crate::world::create::EntityCreator;
|
||||
use crate::{
|
||||
asset::{item::AssetItem, AssetBrowser},
|
||||
@@ -1345,7 +1346,7 @@ impl Editor {
|
||||
if self.settings.general.show_node_removal_dialog
|
||||
&& game_scene.is_current_selection_has_external_refs(
|
||||
&entry.selection,
|
||||
&engine.scenes[game_scene.scene].graph,
|
||||
engine,
|
||||
)
|
||||
{
|
||||
can_delete_immediately = false;
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
use crate::{
|
||||
command::{Command, CommandStack},
|
||||
fyrox::{
|
||||
core::{algebra::Vector2, math::Rect, pool::Handle},
|
||||
core::{algebra::Vector2, define_as_any_trait, math::Rect, pool::Handle},
|
||||
engine::Engine,
|
||||
gui::{
|
||||
file_browser::FileType,
|
||||
message::{KeyCode, MouseButton},
|
||||
UiNode,
|
||||
},
|
||||
@@ -34,8 +35,6 @@ use crate::{
|
||||
settings::{keys::KeyBindings, Settings},
|
||||
Message,
|
||||
};
|
||||
use fyrox::core::define_as_any_trait;
|
||||
use fyrox::gui::file_browser::FileType;
|
||||
use std::path::Path;
|
||||
|
||||
define_as_any_trait!(SceneControllerAsAny => SceneController);
|
||||
@@ -169,6 +168,13 @@ pub trait SceneController: SceneControllerAsAny {
|
||||
selection: &mut Selection,
|
||||
engine: &mut Engine,
|
||||
) -> Vec<String>;
|
||||
|
||||
/// Checks whether the current selection has references to the nodes outside of the selection.
|
||||
fn is_current_selection_has_external_refs(
|
||||
&self,
|
||||
editor_selection: &Selection,
|
||||
engine: &Engine,
|
||||
) -> bool;
|
||||
}
|
||||
|
||||
impl dyn SceneController {
|
||||
|
||||
+20
-22
@@ -17,6 +17,7 @@
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
use crate::{
|
||||
asset::item::AssetItem,
|
||||
audio::AudioBusSelection,
|
||||
@@ -26,6 +27,7 @@ use crate::{
|
||||
asset::manager::ResourceManager,
|
||||
core::{
|
||||
algebra::{Matrix4, Vector2, Vector3},
|
||||
blank_reflect_ref,
|
||||
color::Color,
|
||||
define_as_any_trait,
|
||||
futures::executor::block_on,
|
||||
@@ -34,15 +36,16 @@ use crate::{
|
||||
math::{aabb::AxisAlignedBoundingBox, plane::Plane, Rect},
|
||||
pool::{ErasedHandle, Handle},
|
||||
reflect::Reflect,
|
||||
uuid::Uuid,
|
||||
visitor::Visitor,
|
||||
},
|
||||
engine::{Engine, SerializationContext},
|
||||
engine::{Engine, GraphicsContext, SerializationContext},
|
||||
fxhash::FxHashSet,
|
||||
graph::{NodeWrapper, SceneGraph},
|
||||
gui::{
|
||||
file_browser::FileType,
|
||||
inspector::PropertyChanged,
|
||||
message::UiMessage,
|
||||
message::{KeyCode, MessageDirection, MouseButton},
|
||||
message::{KeyCode, MessageDirection, MouseButton, UiMessage},
|
||||
UiNode,
|
||||
},
|
||||
material::{
|
||||
@@ -55,16 +58,17 @@ use crate::{
|
||||
scene::{
|
||||
base::BaseBuilder,
|
||||
camera::{Camera, Projection},
|
||||
collider::BitMask,
|
||||
debug::{Line, SceneDrawingContext},
|
||||
graph::{Graph, GraphUpdateSwitches},
|
||||
light::{point::PointLight, spot::SpotLight},
|
||||
mesh::RenderPath,
|
||||
mesh::{
|
||||
surface::{SurfaceBuilder, SurfaceData, SurfaceResource},
|
||||
Mesh, MeshBuilder,
|
||||
Mesh, MeshBuilder, RenderPath,
|
||||
},
|
||||
navmesh::NavigationalMesh,
|
||||
node::Node,
|
||||
pivot::Pivot,
|
||||
pivot::PivotBuilder,
|
||||
terrain::Terrain,
|
||||
Scene, SceneContainer,
|
||||
@@ -95,12 +99,6 @@ use crate::{
|
||||
world::selection::GraphSelection,
|
||||
Message, Settings,
|
||||
};
|
||||
use fyrox::core::blank_reflect_ref;
|
||||
use fyrox::core::uuid::Uuid;
|
||||
use fyrox::engine::GraphicsContext;
|
||||
use fyrox::gui::file_browser::FileType;
|
||||
use fyrox::scene::collider::BitMask;
|
||||
use fyrox::scene::pivot::Pivot;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
fmt::Debug,
|
||||
@@ -434,17 +432,6 @@ impl GameScene {
|
||||
);
|
||||
}
|
||||
|
||||
/// Checks whether the current graph selection has references to the nodes outside of the selection.
|
||||
pub fn is_current_selection_has_external_refs(
|
||||
&self,
|
||||
editor_selection: &Selection,
|
||||
graph: &Graph,
|
||||
) -> bool {
|
||||
editor_selection
|
||||
.as_graph()
|
||||
.is_some_and(|s| !graph.external_refs(s.nodes()).is_empty())
|
||||
}
|
||||
|
||||
fn try_save_selection_as_prefab(&self, path: &Path, selection: &Selection, engine: &Engine) {
|
||||
let source_scene = &engine.scenes[self.scene];
|
||||
let mut dest_scene = Scene::new();
|
||||
@@ -1118,6 +1105,17 @@ impl SceneController for GameScene {
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn is_current_selection_has_external_refs(
|
||||
&self,
|
||||
editor_selection: &Selection,
|
||||
engine: &Engine,
|
||||
) -> bool {
|
||||
let graph = &engine.scenes[self.scene].graph;
|
||||
editor_selection
|
||||
.as_graph()
|
||||
.is_some_and(|s| !graph.external_refs(s.nodes()).is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
define_as_any_trait!(SelectionContainerAsAny => SelectionContainer);
|
||||
|
||||
@@ -273,4 +273,12 @@ impl SceneController for NullSceneController {
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn is_current_selection_has_external_refs(
|
||||
&self,
|
||||
editor_selection: &Selection,
|
||||
engine: &Engine,
|
||||
) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,4 +506,14 @@ impl SceneController for UiScene {
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn is_current_selection_has_external_refs(
|
||||
&self,
|
||||
editor_selection: &Selection,
|
||||
_engine: &Engine,
|
||||
) -> bool {
|
||||
editor_selection
|
||||
.as_ui()
|
||||
.is_some_and(|s| !self.ui.external_refs(&s.widgets).is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,10 +278,8 @@ impl SceneNodeContextMenu {
|
||||
if let Some(MenuItemMessage::Click) = message.data::<MenuItemMessage>() {
|
||||
if message.destination() == self.delete_selection {
|
||||
if settings.general.show_node_removal_dialog
|
||||
&& game_scene.is_current_selection_has_external_refs(
|
||||
editor_selection,
|
||||
&engine.scenes[game_scene.scene].graph,
|
||||
)
|
||||
&& game_scene
|
||||
.is_current_selection_has_external_refs(editor_selection, engine)
|
||||
{
|
||||
sender.send(Message::OpenNodeRemovalDialog);
|
||||
} else if let Some(command) =
|
||||
|
||||
Reference in New Issue
Block a user