Skip to content

Commit

Permalink
tools: add .material resources preview
Browse files Browse the repository at this point in the history
Fixes: #167
  • Loading branch information
dbartolini committed Aug 14, 2024
1 parent 2eb4e57 commit 37148b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions samples/core/editors/thumbnail/thumbnail.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ function TexturePreview:render(camera)
Gui.image(Thumbnail._gui, Vector2(0, 0), Vector2(128, 128), self._material_name, Color4.white())
end

MaterialPreview = class(MaterialPreview)

function MaterialPreview:init(world, material_name)
self._unit_preview = UnitPreview(world, "core/units/primitives/sphere")
self._unit_preview._object:set_mesh(material_name, true)
end

function MaterialPreview:destroy()
self._unit_preview:destroy()
end

function MaterialPreview:render(camera)
self._unit_preview:render(camera)
end

Thumbnail = Thumbnail or {}

function Thumbnail:init()
Expand Down Expand Up @@ -97,6 +112,8 @@ function Thumbnail:update(dt)
self._object = UnitPreview(self._world, "core/units/sound")
elseif req.type == "texture" then
self._object = TexturePreview(self._world, req.name)
elseif req.type == "material" then
self._object = MaterialPreview(self._world, req.name)
else
return
end
Expand Down
2 changes: 1 addition & 1 deletion tools/level_editor/project_browser.vala
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public class ProjectIconView : Gtk.IconView
else if ((string)type == "level")
cell.set_property("pixbuf", theme.lookup_icon("text-x-generic-symbolic", ICON_SIZE, 0).load_symbolic(fg_color));
else if ((string)type == "material")
cell.set_property("pixbuf", theme.lookup_icon("text-x-generic-symbolic", ICON_SIZE, 0).load_symbolic(fg_color));
cell.set_property("pixbuf", _thumbnail_cache.get(type, name));
else if ((string)type == "mesh")
cell.set_property("pixbuf", theme.lookup_icon("text-x-generic-symbolic", ICON_SIZE, 0).load_symbolic(fg_color));
else if ((string)type == "package")
Expand Down

0 comments on commit 37148b3

Please sign in to comment.