Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New System for Tile Map, Tile Set, and Brush #714

Merged
merged 51 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
36b1063
Merge branch 'FyroxEngine:master' into tiles
b-guild Nov 5, 2024
4465d42
Merge branch 'FyroxEngine:master' into tiles
b-guild Nov 6, 2024
ca3f6b6
Merge branch 'FyroxEngine:master' into tiles
b-guild Nov 8, 2024
6f97d7f
Merge branch 'FyroxEngine:master' into tiles
b-guild Nov 28, 2024
b6d6c87
Rough working version of new tile set editor.
b-guild Nov 28, 2024
8d1f106
Bringing up to date with latest changes
b-guild Nov 28, 2024
ddfd02d
Merge branch 'FyroxEngine:master' into tiles
b-guild Dec 15, 2024
7ad7a34
Updating to latest Fyrox style system.
b-guild Dec 15, 2024
a491269
Merge branch 'FyroxEngine:master' into tiles
b-guild Dec 23, 2024
ffa6469
Merge branch 'tiles' of https://github.com/b-guild/Fyrox-glTF into tiles
b-guild Dec 23, 2024
3230e49
Merge branch 'FyroxEngine:master' into tiles
b-guild Dec 23, 2024
c2fcffd
Fully functional version of TileMap with TileSet editor and Brush editor
b-guild Dec 23, 2024
d920cc0
Merge branch 'tiles' of https://github.com/b-guild/Fyrox-glTF into tiles
b-guild Dec 23, 2024
e2f8d12
Moving hotkeys to 1,2,3 to avoid conflicts and making flood fill inde…
b-guild Dec 24, 2024
579fa7a
Corrections for clippy.
b-guild Dec 24, 2024
307b6fc
More corrections for clippy.
b-guild Dec 24, 2024
486881a
Removing obsolete example documentation. Need to replace them with up…
b-guild Dec 24, 2024
c6ffac5
Conceptually simplified and improved Transform sets, plus minor fixes.
b-guild Dec 24, 2024
51bda42
Added checkboard behind tile set tiles to show transparency
b-guild Dec 24, 2024
9398a5a
Removing obsolete ResourceGrid concept that was just an early experim…
b-guild Dec 24, 2024
6b87d54
Re-organizing messing use-statements.
b-guild Dec 25, 2024
e288efc
Adding an easy way to access tile properties through a TileMap
b-guild Dec 25, 2024
c04368b
Minor fix for clippy
b-guild Dec 25, 2024
3cb7c2a
Minor fix for clippy
b-guild Dec 25, 2024
4e10bd8
Added method to get tile properties with generic typing
b-guild Dec 25, 2024
dd50cde
Adding PropertyEditorDefinition for TileDefinitionHandle
b-guild Dec 26, 2024
7ea4519
Fixing bugs in tile dragging.
b-guild Dec 26, 2024
f82bf21
Creating NineI8 struct to better represent nine-slice property values…
b-guild Dec 27, 2024
4d30174
Simplified tile set interface by creating ResourceTilePosition
b-guild Dec 28, 2024
7bf1891
Experimental addition of WidgetMessage::ReplaceChildren in order to s…
b-guild Dec 28, 2024
0177821
Add pick button to tile set editor, auto-switch out of editor draw mo…
b-guild Dec 29, 2024
e74eed7
Accidental unused import.
b-guild Dec 29, 2024
fd5792e
Make the tile set pick tool button do something when clicked.
b-guild Dec 29, 2024
05f1789
Expanding comments of tile set editor
b-guild Dec 29, 2024
fcfd38b
Fixing comment markup
b-guild Dec 29, 2024
47c15b0
More comments for tile map.
b-guild Dec 29, 2024
083f0e5
Some requested changes to tile map.
b-guild Dec 30, 2024
a93e50f
Added swap_hash_map_entries to fyrox-core
b-guild Dec 30, 2024
557f6eb
Removing TileMapEditorData and introducing TileMapEffect
b-guild Jan 1, 2025
c06381b
Comment correction
b-guild Jan 1, 2025
2d927a9
Update to new texture system and creating tile map before_effect and …
b-guild Jan 1, 2025
02bb6c1
Fixing comment.
b-guild Jan 1, 2025
1b8a848
Fixing tile map collider shape
b-guild Jan 4, 2025
1bab21d
More fixing tile map collider shape
b-guild Jan 4, 2025
c58165e
Fixes for TileMap
b-guild Jan 4, 2025
df71fa8
Fixing transform set tile move logic error
b-guild Jan 5, 2025
f8bcc4e
Typo in comment
b-guild Jan 7, 2025
1ecaaad
Requested changes
b-guild Jan 9, 2025
0770c7f
Removing `map_or(false,...) to make clippy happy.
b-guild Jan 10, 2025
e6992b5
Fixing error when deleting tile pages through palette hotkey.
b-guild Jan 10, 2025
d8d3722
Make tile map cursor disappear when mouse leaves scene preview
b-guild Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added editor/resources/die.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/resources/flip_x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/resources/flip_y.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/resources/palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/resources/turn_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/resources/turn_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 20 additions & 6 deletions editor/src/asset/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use fyrox::core::log::Log;

use crate::{
asset::open_in_explorer,
fyrox::{
Expand All @@ -41,7 +43,7 @@ use crate::{
UserInterface,
},
material::Material,
scene::tilemap::tileset::TileSet,
scene::tilemap::{brush::TileMapBrush, tileset::TileSet},
},
message::MessageSender,
Message,
Expand Down Expand Up @@ -134,19 +136,31 @@ impl AssetItem {
if self
.path
.extension()
.map_or(false, |ext| ext == "rgs" || ext == "ui")
.is_some_and(|ext| ext == "rgs" || ext == "ui")
{
sender.send(Message::LoadScene(self.path.clone()));
} else if self.path.extension().map_or(false, |ext| ext == "material") {
} else if self.path.extension().is_some_and(|ext| ext == "material") {
if let Ok(path) = make_relative_path(&self.path) {
if let Ok(material) = block_on(resource_manager.request::<Material>(path)) {
sender.send(Message::OpenMaterialEditor(material));
}
}
} else if self.path.extension().map_or(false, |ext| ext == "tileset") {
} else if self.path.extension().is_some_and(|ext| ext == "tileset") {
if let Ok(path) = make_relative_path(&self.path) {
match block_on(resource_manager.request::<TileSet>(path)) {
Ok(tile_set) => sender.send(Message::OpenTileSetEditor(tile_set)),
Err(err) => Log::err(format!("Open tileset error: {err:?}")),
}
}
} else if self
.path
.extension()
.is_some_and(|ext| ext == "tile_map_brush")
{
if let Ok(path) = make_relative_path(&self.path) {
if let Ok(tile_set) = block_on(resource_manager.request::<TileSet>(path)) {
sender.send(Message::OpenTileSetEditor(tile_set));
match block_on(resource_manager.request::<TileMapBrush>(path)) {
Ok(brush) => sender.send(Message::OpenTileMapBrushEditor(brush)),
Err(err) => Log::err(format!("Open tile_map_brush error: {err:?}")),
}
}
} else if self.path.is_dir() {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/asset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ impl AssetBrowser {
folders.push(entry_path);
} else if entry_path
.extension()
.map_or(false, |ext| is_supported_resource(ext, resource_manager))
.is_some_and(|ext| is_supported_resource(ext, resource_manager))
{
resources.push(entry_path);
}
Expand Down
27 changes: 27 additions & 0 deletions editor/src/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,33 @@ pub trait InteractionMode: BaseInteractionMode {
settings: &Settings,
);

/// Called when the mouse enters the scene viewer while this interaction mode is active.
#[allow(unused_variables)]
fn on_mouse_enter(
&mut self,
editor_selection: &Selection,
controller: &mut dyn SceneController,
engine: &mut Engine,
frame_size: Vector2<f32>,
settings: &Settings,
) {
}

/// Called when the mouse leaves the scene viewer while this interaction mode is active.
/// - `mouse_position`: The position of the mouse relative to the scene viewer, with (0,0) being the left-top corner.
/// - `editor_selection`: The currently selected object in the editor.
#[allow(unused_variables)]
fn on_mouse_leave(
&mut self,
mouse_position: Vector2<f32>,
editor_selection: &Selection,
controller: &mut dyn SceneController,
engine: &mut Engine,
frame_size: Vector2<f32>,
settings: &Settings,
) {
}

fn update(
&mut self,
#[allow(unused_variables)] editor_selection: &Selection,
Expand Down
9 changes: 4 additions & 5 deletions editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,8 @@ pub fn create_terrain_layer_material() -> MaterialResource {
pub fn make_scene_file_filter() -> Filter {
Filter::new(|p: &Path| {
p.is_dir()
|| p.extension().map_or(false, |ext| {
matches!(ext.to_string_lossy().as_ref(), "rgs" | "ui")
})
|| p.extension()
.is_some_and(|ext| matches!(ext.to_string_lossy().as_ref(), "rgs" | "ui"))
})
}

Expand Down Expand Up @@ -1812,7 +1811,7 @@ impl Editor {
|| self
.scenes
.current_scene_controller_ref()
.map_or(false, |s| s.is_interacting())
.is_some_and(|s| s.is_interacting())
|| stays_active
}

Expand Down Expand Up @@ -1858,7 +1857,7 @@ impl Editor {

fn load_scene(&mut self, scene_path: PathBuf) {
for entry in self.scenes.entries.iter() {
if entry.path.as_ref().map_or(false, |p| p == &scene_path) {
if entry.path.as_ref() == Some(&scene_path) {
self.set_current_scene(entry.id);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion editor/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::{
scene::Selection,
SaveSceneConfirmationDialogAction,
};
use fyrox::scene::tilemap::tileset::TileSetResource;
use fyrox::scene::tilemap::{brush::TileMapBrushResource, tileset::TileSetResource};
use std::sync::mpsc::channel;
use std::{path::PathBuf, sync::mpsc::Sender};

Expand Down Expand Up @@ -66,6 +66,7 @@ pub enum Message {
OpenAbsmEditor,
OpenMaterialEditor(MaterialResource),
OpenTileSetEditor(TileSetResource),
OpenTileMapBrushEditor(TileMapBrushResource),
OpenNodeRemovalDialog,
ShowInAssetBrowser(PathBuf),
LocateObject {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/plugins/absm/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl AbsmCanvas {
{
if ui
.try_get(node_handle)
.map_or(false, |n| n.has_component::<T>())
.is_some_and(|n| n.has_component::<T>())
{
return node_handle;
}
Expand Down
2 changes: 1 addition & 1 deletion editor/src/plugins/absm/state_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl StateGraphViewer {
if let Some(view_handle) = ui.node(self.canvas).children().iter().cloned().find(|c| {
ui.node(*c)
.query_component::<TransitionView>()
.map_or(false, |transition_view_ref| {
.is_some_and(|transition_view_ref| {
transition == transition_view_ref.model_handle.into()
})
}) {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/plugins/absm/state_viewer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl StateViewer {
if machine_layer
.nodes()
.try_borrow(pose_node.model_handle)
.map_or(false, |node| node.parent_state == self.state.into())
.is_some_and(|node| node.parent_state == self.state.into())
{
true
} else {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/plugins/absm/toolbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl Toolbar {
.filter(|n| {
graph
.try_get(*n)
.map_or(false, |n| !unique_nodes.contains(&n.parent()))
.is_some_and(|n| !unique_nodes.contains(&n.parent()))
})
.collect::<Vec<_>>();

Expand Down
10 changes: 5 additions & 5 deletions editor/src/plugins/animation/toolbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,12 @@ impl Toolbar {
.with_title(WindowTitle::text("Select Animation To Import")),
)
.with_filter(Filter::new(|p: &Path| {
// TODO: Here we allow importing only FBX files, but they can contain
// multiple animations and it might be good to also add animation selector
// that will be used to select a particular animation to import.
p.is_dir()
|| p.extension().map_or(false, |ext|
// TODO: Here we allow importing only FBX files, but they can contain
// multiple animations and it might be good to also add animation selector
// that will be used to select a particular animation to import.
ext.to_string_lossy().as_ref() == "fbx")
|| p.extension()
.is_some_and(|ext| ext.to_string_lossy().as_ref() == "fbx")
}))
.build(ctx);

Expand Down
37 changes: 25 additions & 12 deletions editor/src/plugins/inspector/editors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,26 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use crate::plugins::inspector::editors::{
animation::{
AnimationContainerPropertyEditorDefinition, AnimationPropertyEditorDefinition,
MachinePropertyEditorDefinition,
use fyrox::scene::tilemap::TileDefinitionHandle;

use crate::plugins::{
inspector::editors::{
animation::{
AnimationContainerPropertyEditorDefinition, AnimationPropertyEditorDefinition,
MachinePropertyEditorDefinition,
},
font::FontPropertyEditorDefinition,
handle::{EntityKind, NodeHandlePropertyEditorDefinition},
resource::ResourceFieldPropertyEditorDefinition,
script::ScriptPropertyEditorDefinition,
spritesheet::SpriteSheetFramesContainerEditorDefinition,
surface::SurfaceDataPropertyEditorDefinition,
texture::TexturePropertyEditorDefinition,
},
tilemap::{
OptionTileDefinitionHandlePropertyEditorDefinition,
TileDefinitionHandlePropertyEditorDefinition,
},
font::FontPropertyEditorDefinition,
handle::{EntityKind, NodeHandlePropertyEditorDefinition},
resource::ResourceFieldPropertyEditorDefinition,
script::ScriptPropertyEditorDefinition,
spritesheet::SpriteSheetFramesContainerEditorDefinition,
surface::SurfaceDataPropertyEditorDefinition,
texture::TexturePropertyEditorDefinition,
};
use crate::{
fyrox::{
Expand Down Expand Up @@ -106,7 +114,7 @@ use crate::{
},
terrain::{Chunk, Layer},
tilemap::brush::{TileMapBrush, TileMapBrushResource},
tilemap::tileset::TileCollider,
tilemap::TileCollider,
tilemap::{tileset::TileSet, Tile},
transform::Transform,
},
Expand Down Expand Up @@ -211,6 +219,11 @@ where
pub fn make_property_editors_container(sender: MessageSender) -> PropertyEditorDefinitionContainer {
let container = PropertyEditorDefinitionContainer::with_default_editors();

container.insert(TileDefinitionHandlePropertyEditorDefinition);
container.insert(OptionTileDefinitionHandlePropertyEditorDefinition);
container.register_inheritable_vec_collection::<TileDefinitionHandle>();
container.register_inheritable_vec_collection::<Option<TileDefinitionHandle>>();

container.insert(TexturePropertyEditorDefinition { untyped: false });
container.insert(TexturePropertyEditorDefinition { untyped: true });
container.insert(FontPropertyEditorDefinition);
Expand Down
2 changes: 1 addition & 1 deletion editor/src/plugins/path_fixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl PathFixer {
// Turn hash map into vec to be able to index it.
self.orphaned_scene_resources = scene_resources
.into_iter()
.filter(|r| !r.kind().path().map_or(false, |p| p.exists()))
.filter(|r| !r.kind().path().is_some_and(|p| p.exists()))
.collect::<Vec<_>>();

let ctx = &mut ui.build_ctx();
Expand Down
Loading
Loading