Files
thepool/source/m_editor_bitmap_file.cpp
Raimon Zamora 99d0583833 - Nous gràfics
- [FIX] text en el combobox
- [NEW] Selector de bitmap
- [NEW] Selector de color
- [NEW] Shortcuts per a esborrar (SUPR) i duplicar (CTRL+D) actors
2024-09-18 13:55:43 +02:00

55 lines
1.6 KiB
C++

#include "m_editor_bitmap_file.h"
#include "jdraw.h"
#include "jinput.h"
#include <SDL2/SDL.h>
#include "room.h"
#include "actor.h"
#include "m_game.h"
namespace modules
{
namespace editor_bitmap_file
{
std::vector<std::string> gifs = { "abad.gif", "altres.gif", "caixes.gif", "gat.gif", "gat2.gif", "objectes.gif", "obrer.gif" };
void init()
{
draw::resetViewport();
//gifs = game::getGifs();
}
bool loop()
{
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) return false;
if (input::mouseClk(1))
{
const int x = input::mouseX()/80;
const int y = input::mouseY()/80;
const int selected = x+y*6;
actor::actor_t* act = actor::getSelected();
strcpy(act->bmp, gifs[selected].c_str());
act->surface = draw::getSurface(gifs[selected]);
return false;
}
draw::cls(2);
int bx = 0;
int by = 0;
for (int i=0; i<gifs.size(); ++i)
{
draw::surface *surf = draw::getSurface(gifs[i].c_str());
draw::setSource(surf);
const float aspect = float(surf->w) / float(surf->h);
const int width = 64.0f*aspect;
draw::draw(2+80*bx, 2+by*80, surf->w, surf->h, 0, 0, 0, 64, 64);
draw::print(gifs[i].c_str(), 2+80*bx + 32 - (gifs[0].size()/2)*4, 70+by*80, LIGHT+WHITE, PAPER);
bx++; if (bx>5) { bx=0; by++; }
}
draw::render();
return true;
}
}
}