2016-01-07 00:40:27 +00:00
|
|
|
#include "ResourceBrowser.hpp"
|
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
namespace urde
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
|
|
|
#define BROWSER_MARGIN 8
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
bool ResourceBrowser::navigateToPath(const hecl::ProjectPath& pathIn)
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
2016-09-18 23:47:48 +00:00
|
|
|
if (pathIn.isFile())
|
2016-01-07 00:40:27 +00:00
|
|
|
m_path = pathIn.getParentPath();
|
|
|
|
else
|
|
|
|
m_path = pathIn;
|
|
|
|
|
|
|
|
m_comps = m_path.getPathComponents();
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
hecl::DirectoryEnumerator dEnum(m_path.getAbsolutePath(),
|
|
|
|
hecl::DirectoryEnumerator::Mode::DirsThenFilesSorted,
|
2016-01-07 00:40:27 +00:00
|
|
|
m_state.sortColumn==State::SortColumn::Size,
|
2016-03-05 00:03:41 +00:00
|
|
|
m_state.sortDir==specter::SortDirection::Descending &&
|
2016-03-01 03:08:25 +00:00
|
|
|
(m_state.sortColumn == State::SortColumn::Name || m_state.sortColumn == State::SortColumn::Size),
|
2016-01-07 00:40:27 +00:00
|
|
|
true);
|
2016-03-01 03:08:25 +00:00
|
|
|
m_resListingBind.updateListing(dEnum);
|
2016-01-27 00:44:22 +00:00
|
|
|
if (m_pathButtons)
|
|
|
|
m_pathButtons->setButtons(m_comps);
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2016-01-08 05:54:00 +00:00
|
|
|
if (m_view)
|
|
|
|
{
|
2016-03-01 03:08:25 +00:00
|
|
|
m_view->m_resListing.m_view->selectRow(-1);
|
|
|
|
m_view->m_resListing.m_view->updateData();
|
2016-01-08 05:54:00 +00:00
|
|
|
m_view->updateSize();
|
|
|
|
}
|
2016-01-07 00:40:27 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::pathButtonActivated(size_t idx)
|
|
|
|
{
|
|
|
|
if (idx >= m_comps.size())
|
|
|
|
return;
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
hecl::SystemString dir;
|
2016-01-07 00:40:27 +00:00
|
|
|
bool needSlash = false;
|
|
|
|
size_t i = 0;
|
2016-03-04 23:04:53 +00:00
|
|
|
for (const hecl::SystemString& d : m_comps)
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
|
|
|
if (needSlash)
|
2018-10-14 20:16:21 +00:00
|
|
|
dir += _SYS_STR('/');
|
|
|
|
if (d.compare(_SYS_STR("/")))
|
2016-01-07 00:40:27 +00:00
|
|
|
needSlash = true;
|
|
|
|
dir += d;
|
|
|
|
if (++i > idx)
|
|
|
|
break;
|
|
|
|
}
|
2016-03-04 23:04:53 +00:00
|
|
|
navigateToPath(hecl::ProjectPath(*m_vm.project(), dir));
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-27 00:44:22 +00:00
|
|
|
void ResourceBrowser::View::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2016-03-01 03:08:25 +00:00
|
|
|
m_resListing.mouseDown(coord, button, mod);
|
2016-01-27 00:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::View::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2016-03-01 03:08:25 +00:00
|
|
|
m_resListing.mouseUp(coord, button, mod);
|
2016-01-27 00:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::View::mouseMove(const boo::SWindowCoord& coord)
|
2016-01-07 00:40:27 +00:00
|
|
|
{
|
2016-03-01 03:08:25 +00:00
|
|
|
m_resListing.mouseMove(coord);
|
2016-01-27 00:44:22 +00:00
|
|
|
}
|
2016-01-07 00:40:27 +00:00
|
|
|
|
2016-01-27 00:44:22 +00:00
|
|
|
void ResourceBrowser::View::mouseLeave(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2016-03-01 03:08:25 +00:00
|
|
|
m_resListing.mouseLeave(coord);
|
2016-01-27 00:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceBrowser::View::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
specter::View::resized(root, sub);
|
2016-03-01 03:08:25 +00:00
|
|
|
m_resListing.m_view->resized(root, sub);
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
void ResourceBrowser::View::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|
|
|
{
|
2016-03-01 03:08:25 +00:00
|
|
|
m_resListing.m_view->draw(gfxQ);
|
2016-01-07 00:40:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|