- Editor de posició i tamany de actor en bitmap completat
This commit is contained in:
@@ -12,6 +12,8 @@ namespace modules
|
||||
{
|
||||
int edit_mode = EDITING_BITMAP_POS;
|
||||
draw::surface *surf = nullptr;
|
||||
int lastMX, lastMY;
|
||||
bool lastMB = false;
|
||||
|
||||
void init(int editing)
|
||||
{
|
||||
@@ -23,16 +25,47 @@ namespace modules
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) return false;
|
||||
const bool ctrl = input::keyDown(SDL_SCANCODE_LCTRL);
|
||||
|
||||
actor::actor_t *sel = actor::getSelected();
|
||||
|
||||
if (input::keyDown(SDL_SCANCODE_UP)) if (!ctrl) sel->bmp_rect.y--; else sel->bmp_rect.h--;
|
||||
if (input::keyDown(SDL_SCANCODE_DOWN)) if (!ctrl) sel->bmp_rect.y++; else sel->bmp_rect.h++;
|
||||
if (input::keyDown(SDL_SCANCODE_LEFT)) if (!ctrl) sel->bmp_rect.x--; else sel->bmp_rect.w--;
|
||||
if (input::keyDown(SDL_SCANCODE_RIGHT)) if (!ctrl) sel->bmp_rect.x++; else sel->bmp_rect.w++;
|
||||
|
||||
if (input::mouseBtn(1))
|
||||
{
|
||||
int mx = input::mouseX();
|
||||
int my = input::mouseY();
|
||||
if (!lastMB) {
|
||||
lastMB = true;
|
||||
lastMX = mx;
|
||||
lastMY = my;
|
||||
} else {
|
||||
int dx = 0, dy = 0;
|
||||
if (lastMX != mx) { dx = mx - lastMX; }
|
||||
if (lastMY != my) { dy = my - lastMY; }
|
||||
lastMX = mx;
|
||||
lastMY = my;
|
||||
if (!ctrl) {
|
||||
sel->bmp_rect.x += dx;
|
||||
sel->bmp_rect.y += dy;
|
||||
} else {
|
||||
sel->bmp_rect.w += dx;
|
||||
sel->bmp_rect.h += dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
const int tx = (520-surf->w)/2;
|
||||
const int ty = (240-surf->h)/2;
|
||||
|
||||
draw::cls(PAPER);
|
||||
draw::setSource(surf);
|
||||
draw::color(BLUE);
|
||||
draw::color(100);
|
||||
draw::setViewport(tx, ty, surf->w, surf->h);
|
||||
draw::fillrect(0, 0, surf->w, surf->h);
|
||||
draw::color(BLUE+LIGHT);
|
||||
draw::color(101);
|
||||
int x=0, y=0;
|
||||
while(y*32<surf->h)
|
||||
{
|
||||
@@ -41,19 +74,25 @@ namespace modules
|
||||
}
|
||||
|
||||
draw::resetViewport();
|
||||
draw::color(WHITE);
|
||||
draw::color(LIGHT+WHITE);
|
||||
draw::rect(((520-surf->w)/2)-1, ((240-surf->h)/2)-1, surf->w+2, surf->h+2);
|
||||
draw::swapcol(1, LIGHT+WHITE);
|
||||
draw::draw((520-surf->w)/2, (240-surf->h)/2, surf->w, surf->h, 0, 0, 0);
|
||||
|
||||
draw::setViewport(tx, ty, surf->w, surf->h);
|
||||
draw::color(RED+LIGHT);
|
||||
draw::hline(0, actor::getSelected()->bmp_rect.y, surf->w);
|
||||
draw::vline(actor::getSelected()->bmp_rect.x, 0, surf->h);
|
||||
draw::hline(0, sel->bmp_rect.y, surf->w);
|
||||
draw::vline(sel->bmp_rect.x, 0, surf->h);
|
||||
draw::color(YELLOW);
|
||||
draw::hline(0, actor::getSelected()->bmp_rect.y+actor::getSelected()->bmp_rect.h, surf->w);
|
||||
draw::vline(actor::getSelected()->bmp_rect.x+actor::getSelected()->bmp_rect.w, 0, surf->h);
|
||||
draw::hline(0, sel->bmp_rect.y+sel->bmp_rect.h-1, surf->w);
|
||||
draw::vline(sel->bmp_rect.x+sel->bmp_rect.w-1, 0, surf->h);
|
||||
draw::resetViewport();
|
||||
|
||||
draw::print2(sel->bmp_rect.x, 3, 1, 4, LIGHT+WHITE, FONT_ZOOM_VERTICAL);
|
||||
draw::print2(sel->bmp_rect.y, 3, 5, 4, LIGHT+WHITE, FONT_ZOOM_VERTICAL);
|
||||
draw::print2(sel->bmp_rect.w, 3, 1, 7, LIGHT+WHITE, FONT_ZOOM_VERTICAL);
|
||||
draw::print2(sel->bmp_rect.h, 3, 5, 7, LIGHT+WHITE, FONT_ZOOM_VERTICAL);
|
||||
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace modules
|
||||
|
||||
if (editor::isDevMode())
|
||||
{
|
||||
draw::setPaletteColor(100, 0xbb, 0x80, 0x80);
|
||||
draw::setPaletteColor(101, 0xff, 0xc0, 0xc0);
|
||||
draw::stencil::init();
|
||||
|
||||
FILE* f = fopen("data/gifs.txt", "r");
|
||||
@@ -264,11 +266,13 @@ namespace modules
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE))
|
||||
{
|
||||
if (console::isEnabled())
|
||||
if (console::isEnabled()) {
|
||||
console::toggle();
|
||||
else
|
||||
} else {
|
||||
if (editor::isEditing()) room::editor::save();
|
||||
return GAME_MENU;
|
||||
}
|
||||
}
|
||||
|
||||
// WHILE EDITING...
|
||||
if (editor::isEditing())
|
||||
|
||||
Reference in New Issue
Block a user