- [NEW] Mode d'edició flotant (amb tecla M).

- [FIX] la copa de actors (sobre tot per a templates) també copia la surface.
- [FIX] El push de reacció se li ha de passar al que espenta, no al aspentat.
- [FIX] La posició del cursor en l'editor de posició en bitmap ha de resetejar-se al soltar el botó.
- [NEW] Gràfics del cabronet.
- [NEW] Montons de objectes "templatechats" pa anar editant més apresa.
This commit is contained in:
2024-09-20 13:53:09 +02:00
parent 81b9791144
commit 66241e6a6a
13 changed files with 395 additions and 60 deletions

View File

@@ -19,6 +19,8 @@ namespace modules
std::vector<std::string> getGifs() { return gifs; }
vec2_t floating_position = {3,3};
void init()
{
actor::clear(true);
@@ -295,6 +297,31 @@ namespace modules
if (editor::isDevMode()) draw::setViewport(100,0,320,240);
room::draw();
actor::actor_t *selected = actor::getSelected();
if (editor::isDevMode() && selected && input::keyPressed(SDL_SCANCODE_M)) actor::setFloatingEditing(true);
if (editor::isDevMode() && actor::getFloatingEditing() && selected) {
draw::swapcol(1, GREEN+LIGHT);
draw::setSource(draw::getSurface("test.gif"));
const float px = draw::getLocalX(input::mouseX())-148-16;
const float py = draw::getLocalY(input::mouseY())-75;
const int x = int(py/16.0f + px/32.0f);
const int y = int(py/16.0f - px/32.0f);
//draw::print2(x, -3, 1, 6, PURPLE, FONT_ZOOM_NONE);
//draw::print2(y, -3, 1, 7, PURPLE, FONT_ZOOM_NONE);
if (x>=room::getTMin().x && y>=room::getTMin().y && x<room::getTMax().x && y<room::getTMax().y)
{
floating_position = {x, y};
selected->pos.x = floating_position.x*8;
selected->pos.y = floating_position.y*8;
}
draw::draw(148+floating_position.x*16-floating_position.y*16,75+floating_position.x*8+floating_position.y*8,32,16,160,0);
if (input::mouseClk(1)) actor::setFloatingEditing(false);
}
draw::stencil::enable();
draw::stencil::clear(255);
actor::draw(actor::getFirst());
@@ -303,7 +330,8 @@ namespace modules
draw::swapcol(1, WHITE+LIGHT);
actor::draw(actor::getPicked(), false);
if (editor::isDevMode() && input::mouseBtn(1))
// Si estem en el editor, fent click en els actors els seleccionem
if (editor::isDevMode() && input::mouseBtn(1) && !actor::getFloatingEditing())
{
const uint8_t val = draw::stencil::query(input::mouseX(), input::mouseY());
if (val != 255)
@@ -313,6 +341,7 @@ namespace modules
}
}
// Si estem jugant, o estem en el editor pero NO en mode edició, pinta els marcadors
if (!editor::isEditing())
{
const int col1 = room::getColor(1);
@@ -350,6 +379,7 @@ namespace modules
draw::stencil::disable();
// Si estem en el editor, fent click en els skills del marcador els obtenim
if (editor::isDevMode() && input::mouseClk(1))
{
const uint8_t val = draw::stencil::query(input::mouseX(), input::mouseY());
@@ -364,6 +394,8 @@ namespace modules
}
}
}
/*
print(0,0,input::mouseX());
print(0,20,input::mouseY());
@@ -371,6 +403,8 @@ namespace modules
print(0,40,input::mouseBtn(2)?1:0);
print(0,50,input::mouseBtn(3)?1:0);
*/
// Si no estem en el editor, pintem la consola (si es el cas), renderitzem i eixim
if (!editor::isDevMode())
{
console::draw();
@@ -378,6 +412,7 @@ namespace modules
return GAME_NONE;
}
// Si estem en el editor, pintem els numerets de les eixides
draw::print2(room::getExit(XN), -2, 1, 1, TEAL, FONT_ZOOM_NONE);
draw::print2(room::getExit(YN), -2, 38, 1, TEAL, FONT_ZOOM_NONE);
draw::print2(room::getExit(XP), -2, 38, 28, TEAL, FONT_ZOOM_NONE);
@@ -385,8 +420,11 @@ namespace modules
draw::print2(room::getExit(ZP), -2, 19, 1, TEAL, FONT_ZOOM_NONE);
draw::print2(room::getExit(ZN), -2, 19, 28, TEAL, FONT_ZOOM_NONE);
// ...i l'habitació actual
draw::print2(room::getCurrent(), -2, 4, 3, WHITE, FONT_ZOOM_BOTH);
// ...i fent click en els numerets de les eixides anem a l'habitació corresponent
// Es més. Si no hi ha habitació enllaçada en una eixida i li fem ctrl+click, se crea una nova habitació per eixa eixida
if (input::mouseClk(1)) {
const int mx = draw::getLocalX(input::mouseX());
const int my = draw::getLocalY(input::mouseY());
@@ -419,6 +457,8 @@ namespace modules
}
}
// Pintem tota la UI del editor
// ================================================================================
ui::start();
actor::actor_t *act = nullptr;