60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
#include "m_editor_templates.h"
|
|
#include "jdraw.h"
|
|
#include "jinput.h"
|
|
#include "misc.h"
|
|
#include <SDL2/SDL.h>
|
|
#include "actor.h"
|
|
#include <vector>
|
|
|
|
namespace modules
|
|
{
|
|
namespace editor_templates
|
|
{
|
|
std::vector<actor::actor_t*> templates;
|
|
|
|
void init()
|
|
{
|
|
for (int i=0; i<templates.size(); ++i) if (templates[i] != nullptr) actor::remove(templates[i]);
|
|
templates.clear();
|
|
|
|
for (int i=0; i<actor::templates::size(); ++i)
|
|
templates.push_back(actor::duplicate(actor::templates::get(i)));
|
|
draw::resetViewport();
|
|
}
|
|
|
|
bool loop()
|
|
{
|
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE) || input::keyPressed(SDL_SCANCODE_TAB)) return false;
|
|
|
|
draw::cls(2);
|
|
|
|
draw::stencil::enable();
|
|
draw::stencil::clear(255);
|
|
|
|
int x=0, y=0;
|
|
|
|
for (int i=0; i<templates.size(); ++i)
|
|
{
|
|
draw::stencil::set(i);
|
|
draw::swapcol(1, TEAL);
|
|
actor::drawAt(templates[i], x*40, y*40);
|
|
draw::print(templates[i]->name, (x*40), (y*40)+30, LIGHT+WHITE, BLACK);
|
|
x++; if (x==13) { x=0;y++; }
|
|
}
|
|
|
|
draw::render();
|
|
|
|
if (input::mouseClk(1)) {
|
|
const int clicked = draw::stencil::query(input::mouseX(), input::mouseY());
|
|
if (clicked!=255) {
|
|
//room::load(clicked);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
}
|
|
}
|