2005-10-31 04:36:50 +01:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "MessageHandler.h"
|
|
|
|
|
|
|
|
#include "../CommandProc.h"
|
|
|
|
|
|
|
|
#include "graphics/TextureManager.h"
|
2005-11-03 04:49:57 +01:00
|
|
|
#include "graphics/TextureEntry.h"
|
2005-10-31 04:36:50 +01:00
|
|
|
|
|
|
|
#include "../Brushes.h"
|
|
|
|
|
|
|
|
namespace AtlasMessage {
|
|
|
|
|
|
|
|
QUERYHANDLER(GetTerrainGroups)
|
|
|
|
{
|
|
|
|
const CTextureManager::TerrainGroupMap &groups = g_TexMan.GetGroups();
|
|
|
|
for (CTextureManager ::TerrainGroupMap::const_iterator it = groups.begin(); it != groups.end(); ++it)
|
|
|
|
msg->groupnames.push_back(CStrW(it->first));
|
|
|
|
}
|
|
|
|
|
2005-11-03 04:49:57 +01:00
|
|
|
QUERYHANDLER(GetTerrainGroupPreviews)
|
|
|
|
{
|
2005-11-03 23:51:14 +01:00
|
|
|
CTerrainGroup* group = g_TexMan.FindGroup(CStrW(msg->groupname));
|
2005-11-03 04:49:57 +01:00
|
|
|
for (std::vector<CTextureEntry*>::const_iterator it = group->GetTerrains().begin(); it != group->GetTerrains().end(); ++it)
|
|
|
|
{
|
|
|
|
msg->previews.push_back(AtlasMessage::sTerrainGroupPreview());
|
|
|
|
msg->previews.back().name = CStrW((*it)->GetTag());
|
|
|
|
|
|
|
|
u32 c = (*it)->GetBaseColor();
|
|
|
|
unsigned char* buf = (unsigned char*)malloc(msg->imagewidth*msg->imageheight*3);
|
|
|
|
|
|
|
|
// TODO: An actual preview of the texture. (There's no need to shrink
|
|
|
|
// the entire texture to fit, since it's the small details in the
|
|
|
|
// texture that are interesting, so we could just crop a chunk out of
|
|
|
|
// the middle.)
|
|
|
|
for (int i = 0; i < msg->imagewidth*msg->imageheight; ++i)
|
|
|
|
{
|
|
|
|
buf[i*3+0] = (c>>16) & 0xff;
|
|
|
|
buf[i*3+1] = (c>>8) & 0xff;
|
|
|
|
buf[i*3+2] = (c>>0) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg->previews.back().imagedata = buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-10-31 04:36:50 +01:00
|
|
|
}
|