add support for high res brush textures, implement mipmaps on brush
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "log.h"
|
||||
#include "node_panel_brush.h"
|
||||
#include "asset.h"
|
||||
#include "texture.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <Foundation/Foundation.h>
|
||||
@@ -44,14 +45,15 @@ void NodePanelBrush::init()
|
||||
{
|
||||
init_template("tpl-panel-brushes");
|
||||
//m_layers_container = find<NodeBorder>("layers-container");
|
||||
static auto icons = Asset::list_files("data/Icons", true, ".*\\.png$");
|
||||
static auto icons = Asset::list_files("data/thumbs", true, ".*\\.png$");
|
||||
|
||||
if ((m_container = find<NodeBorder>("brushes")))
|
||||
{
|
||||
int count = 0;
|
||||
for (auto& i : icons)
|
||||
{
|
||||
std::string path = "data/Icons/" + i;
|
||||
std::string path = "data/thumbs/" + i;
|
||||
std::string path_hi = "data/brushes/" + i;
|
||||
NodeButtonBrush* brush = new NodeButtonBrush;
|
||||
m_container->add_child(brush);
|
||||
brush->init();
|
||||
@@ -59,6 +61,8 @@ void NodePanelBrush::init()
|
||||
brush->loaded();
|
||||
brush->set_icon(path.c_str());
|
||||
brush->m_brushID = count++;
|
||||
brush->high_path = path_hi;
|
||||
brush->high_id = const_hash(path_hi.c_str());
|
||||
m_brushes.push_back(brush);
|
||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
||||
}
|
||||
@@ -79,17 +83,23 @@ void NodePanelBrush::handle_click(Node* target)
|
||||
|
||||
uint16_t NodePanelBrush::get_texture_id(int index) const
|
||||
{
|
||||
return m_brushes[index]->img->m_tex_id;
|
||||
TextureManager::load(m_brushes[index]->high_path.c_str(), true);
|
||||
return m_brushes[index]->high_id;
|
||||
}
|
||||
|
||||
int NodePanelBrush::get_brush_id(int index) const
|
||||
{
|
||||
return m_brushes[index]->m_brushID;
|
||||
}
|
||||
|
||||
// select the current brush based on the texture id
|
||||
void NodePanelBrush::set_texture_id(int texid)
|
||||
void NodePanelBrush::select_brush(int brush_id)
|
||||
{
|
||||
if (m_current)
|
||||
m_current->m_selected = false;
|
||||
for (auto b : m_brushes)
|
||||
{
|
||||
if (b->img->m_tex_id == texid)
|
||||
if (b->m_brushID == brush_id)
|
||||
{
|
||||
b->m_selected = true;
|
||||
m_current = b;
|
||||
|
||||
Reference in New Issue
Block a user