- Treballant en el editor
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
enum sections { SECTION_GENERAL, SECTION_ROOM, SECTION_ACTOR };
|
||||||
|
|
||||||
draw::surface *surf;
|
draw::surface *surf;
|
||||||
int room_w = 2;
|
int room_w = 2;
|
||||||
int room_h = 2;
|
int room_h = 2;
|
||||||
@@ -244,7 +246,7 @@ void btn_txt(const char* label, const int x, const int y, char *var)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int section = 0;
|
int section = SECTION_ROOM;
|
||||||
|
|
||||||
void editor_move_selected()
|
void editor_move_selected()
|
||||||
{
|
{
|
||||||
@@ -314,28 +316,92 @@ bool game::loop()
|
|||||||
switch (section) {
|
switch (section) {
|
||||||
case 0:
|
case 0:
|
||||||
*/
|
*/
|
||||||
bool change = false;
|
|
||||||
draw::setViewport(0,0,100,240);
|
draw::setViewport(0,0,100,240);
|
||||||
|
|
||||||
draw::color(WHITE);
|
draw::color(WHITE);
|
||||||
draw::fillrect(0, 0, 100, 240);
|
draw::fillrect(0, 0, 100, 240);
|
||||||
|
|
||||||
|
/*
|
||||||
|
bool change = false;
|
||||||
|
|
||||||
change |= btn("ROOM WIDTH:", 10, 40, room::editor::refWidth(), 0, 3);
|
change |= btn("ROOM WIDTH:", 10, 40, room::editor::refWidth(), 0, 3);
|
||||||
change |= btn("ROOM HEIGHT:", 10, 55, room::editor::refHeight(), 0, 3);
|
change |= btn("ROOM HEIGHT:", 10, 55, room::editor::refHeight(), 0, 3);
|
||||||
|
|
||||||
draw::print("DOORS:", 10, 80, 15, 0);
|
draw::print("DOORS:", 10, 80, 15, 0);
|
||||||
btn_small(32, 80, room::editor::refDoor(XN), -1, 5);
|
change |= btn_small(32, 80, room::editor::refDoor(XN), -1, 5);
|
||||||
btn_small(49, 80, room_yp, -1, 5);
|
change |= btn_small(49, 80, room::editor::refDoor(YP), -1, 5);
|
||||||
btn_small(66, 80, room_xp, -1, 5);
|
change |= btn_small(66, 80, room::editor::refDoor(XP), -1, 5);
|
||||||
btn_small(83, 80, room_yn, -1, 5);
|
change |= btn_small(83, 80, room::editor::refDoor(YN), -1, 5);
|
||||||
|
|
||||||
btn("COLOR:", 10, 140, room_color, 5, 11);
|
btn("COLOR:", 10, 140, room::editor::refColor(), 5, 11);
|
||||||
btn("FLOOR:", 10, 155, room_floor, 0, 5);
|
btn("FLOOR:", 10, 155, room::editor::refFloorTex(), 0, 5);
|
||||||
btn("WALLS:", 10, 170, room_walls, 0, 5);
|
btn("WALLS:", 10, 170, room::editor::refWallTex(), 0, 5);
|
||||||
btn("DOORS:", 10, 185, room_doors, 0, 4);
|
btn("DOORS:", 10, 185, room::editor::refDoorTex(), 0, 4);
|
||||||
btn("WDOORS:", 10, 200, room_walldoors, 0, 5);
|
btn("WDOORS:", 10, 200, room::editor::refWallDoorTex(), 0, 5);
|
||||||
|
|
||||||
if (change) room::update();
|
if (change) room::update();
|
||||||
|
*/
|
||||||
|
|
||||||
|
draw::color(LIGHT+WHITE);
|
||||||
|
draw::fillrect(2, 2, 96, 236);
|
||||||
|
draw::color(PAPER);
|
||||||
|
draw::rect(2, 2, 96, 236);
|
||||||
|
|
||||||
|
const int mx = draw::getLocalX(input::mouseX());
|
||||||
|
const int my = draw::getLocalY(input::mouseY());
|
||||||
|
const bool btnDown = input::mouseBtn(1) || input::mouseBtn(3);
|
||||||
|
|
||||||
|
int line = 0;
|
||||||
|
if (section==SECTION_GENERAL)
|
||||||
|
{
|
||||||
|
draw::color(LIGHT+BLUE);
|
||||||
|
draw::fillrect(4, 2+line*9, 92, 9);
|
||||||
|
}
|
||||||
|
if ((mx>=2) && (mx<98) && (my>=2+line*9) && (my<2+9+line*9) && btnDown) {
|
||||||
|
section = SECTION_GENERAL;
|
||||||
|
}
|
||||||
|
draw::print("-THE POOL", 6, 4+line*9, LIGHT+WHITE, BLACK);
|
||||||
|
line++;
|
||||||
|
for (int i=0;i<64;++i)
|
||||||
|
{
|
||||||
|
if (room::editor::roomExists(i))
|
||||||
|
{
|
||||||
|
if (section==SECTION_ROOM && i == room::editor::getCurrentRoom())
|
||||||
|
{
|
||||||
|
draw::color(LIGHT+BLUE);
|
||||||
|
draw::fillrect(4, 2+line*9, 92, 9);
|
||||||
|
}
|
||||||
|
if ((mx>=2) && (mx<98) && (my>=2+line*9) && (my<2+9+line*9) && btnDown) {
|
||||||
|
room::load(i);
|
||||||
|
section = SECTION_ROOM;
|
||||||
|
}
|
||||||
|
char num[] = "+ROOM 00";
|
||||||
|
num[6] = int(i/10)+48;
|
||||||
|
num[7] = (i%10)+48;
|
||||||
|
draw::print(num, 10, 4+line*9, LIGHT+WHITE, BLACK); line++;
|
||||||
|
|
||||||
|
if (i==room::editor::getCurrentRoom())
|
||||||
|
{
|
||||||
|
act = actor::getFirst();
|
||||||
|
while (act) {
|
||||||
|
if ((act->flags&FLAG_NOEDITOR)!=FLAG_NOEDITOR && (act->flags&FLAG_HERO)!=FLAG_HERO) {
|
||||||
|
if (section==SECTION_ACTOR && act==actor::getSelected()) {
|
||||||
|
draw::color(LIGHT+BLUE);
|
||||||
|
draw::fillrect(4, 2+line*9, 92, 9);
|
||||||
|
}
|
||||||
|
if ((mx>=2) && (mx<98) && (my>=2+line*9) && (my<2+9+line*9) && btnDown) {
|
||||||
|
actor::select(act);
|
||||||
|
section = SECTION_ACTOR;
|
||||||
|
}
|
||||||
|
draw::print(act->name, 14, 4+line*9, LIGHT+WHITE, BLACK);
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
act = act->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -351,6 +417,7 @@ bool game::loop()
|
|||||||
draw::color(PAPER);
|
draw::color(PAPER);
|
||||||
draw::rect(2, 0, 96, 100);
|
draw::rect(2, 0, 96, 100);
|
||||||
|
|
||||||
|
/*
|
||||||
const int mx = draw::getLocalX(input::mouseX());
|
const int mx = draw::getLocalX(input::mouseX());
|
||||||
const int my = draw::getLocalY(input::mouseY());
|
const int my = draw::getLocalY(input::mouseY());
|
||||||
const bool btnDown = input::mouseBtn(1) || input::mouseBtn(3);
|
const bool btnDown = input::mouseBtn(1) || input::mouseBtn(3);
|
||||||
@@ -372,7 +439,7 @@ bool game::loop()
|
|||||||
}
|
}
|
||||||
act = act->next;
|
act = act->next;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
act = actor::getSelected();
|
act = actor::getSelected();
|
||||||
if (act)
|
if (act)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
namespace room
|
namespace room
|
||||||
{
|
{
|
||||||
|
static int current_room = 0;
|
||||||
|
|
||||||
static int inner_w = 2;
|
static int inner_w = 2;
|
||||||
static int inner_h = 2;
|
static int inner_h = 2;
|
||||||
|
|
||||||
@@ -15,15 +17,15 @@ namespace room
|
|||||||
static vec3_t min = {0,0,0}; // primer "pixel isometric" en cada coordenada
|
static vec3_t min = {0,0,0}; // primer "pixel isometric" en cada coordenada
|
||||||
static vec3_t max = {56,56,56}; // ultim "pixel isometric" en cada coordenada
|
static vec3_t max = {56,56,56}; // ultim "pixel isometric" en cada coordenada
|
||||||
|
|
||||||
static uint8_t doors = NO_DOOR; // Portes obertes
|
static int doors = NO_DOOR; // Portes obertes
|
||||||
static uint8_t door_height[4]; // Altura de cada porta
|
static int door_height[4]; // Altura de cada porta
|
||||||
static int8_t exits[6]; // Habitació destí a la que du cada porta (piso i sostre inclosos)
|
static int exits[6]; // Habitació destí a la que du cada porta (piso i sostre inclosos)
|
||||||
static uint8_t color = 5; // Color de l'habitació
|
static int color = 5; // Color de l'habitació
|
||||||
|
|
||||||
static uint8_t floor_type = 0; // Tile per al piso
|
static int floor_type = 0; // Tile per al piso
|
||||||
static uint8_t walls_type = 0; // Tile per a les pareds
|
static int walls_type = 0; // Tile per a les pareds
|
||||||
static uint8_t doors_type = 0; // Textura per a les portes
|
static int doors_type = 0; // Textura per a les portes
|
||||||
static uint8_t walldoors_type = 0; // Textura per a baix de les portes
|
static int walldoors_type = 0; // Textura per a baix de les portes
|
||||||
|
|
||||||
// Surface on se guarden els gràfics de cada cosa
|
// Surface on se guarden els gràfics de cada cosa
|
||||||
static draw::surface *floor_surf = nullptr;
|
static draw::surface *floor_surf = nullptr;
|
||||||
@@ -46,6 +48,8 @@ namespace room
|
|||||||
walls_surf = draw::loadSurface("walls.gif");
|
walls_surf = draw::loadSurface("walls.gif");
|
||||||
doors_surf = draw::loadSurface("doors.gif");
|
doors_surf = draw::loadSurface("doors.gif");
|
||||||
aux_surf = draw::loadSurface("roomaux.gif");
|
aux_surf = draw::loadSurface("roomaux.gif");
|
||||||
|
|
||||||
|
editor::updateRoomList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh()
|
void refresh()
|
||||||
@@ -171,7 +175,7 @@ namespace room
|
|||||||
}
|
}
|
||||||
free(original_buffer);
|
free(original_buffer);
|
||||||
}
|
}
|
||||||
|
current_room = room;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,33 +341,35 @@ namespace room
|
|||||||
|
|
||||||
namespace editor
|
namespace editor
|
||||||
{
|
{
|
||||||
|
static bool room_exists[256];
|
||||||
|
|
||||||
int &refWidth() { return inner_w; }
|
int &refWidth() { return inner_w; }
|
||||||
int &refHeight() { return inner_h; }
|
int &refHeight() { return inner_h; }
|
||||||
|
|
||||||
uint8_t &refDoor(const int which) { return door_height[which]; }
|
int &refDoor(const int which) { return door_height[which]; }
|
||||||
|
|
||||||
void setWidth(const int value) { inner_w = value; update(); }
|
int &refColor() { return color; }
|
||||||
void setHeight(const int value) { inner_h = value; update(); }
|
int &refFloorTex() { return floor_type; }
|
||||||
void setDoor(const int which, const int value) { door_height[which] = value; update(); }
|
int &refWallTex() { return walls_type; }
|
||||||
|
int &refDoorTex() { return doors_type; }
|
||||||
|
int &refWallDoorTex() { return walldoors_type; }
|
||||||
|
|
||||||
void setColor(const int value) { color = value; update(); }
|
int &refExit(const int which) { return exits[which]; }
|
||||||
void setFloorTex(const int value) { floor_type = value; update(); }
|
|
||||||
void setWallTex(const int value) { walls_type = value; update(); }
|
|
||||||
void setDoorTex(const int value) { doors_type = value; update(); }
|
|
||||||
void setWallDoorTex(const int value) { walldoors_type = value; update(); }
|
|
||||||
void setExit(const int which, const int value) { exits[which] = value; update(); }
|
|
||||||
|
|
||||||
const int getWidth() { return inner_w; }
|
bool roomExists(const int which) { return room_exists[which]; }
|
||||||
const int getHeight() { return inner_h; }
|
|
||||||
const int getDoor(const int which) { return door_height[which]; }
|
|
||||||
|
|
||||||
const int getColor() { return color; }
|
void updateRoomList()
|
||||||
const int getFloorTex() { return floor_type; }
|
{
|
||||||
const int getWallTex() { return walls_type; }
|
for (int room=0; room<64; ++room)
|
||||||
const int getDoorTex() { return doors_type; }
|
{
|
||||||
const int getWallDoorTex() { return walldoors_type; }
|
char filename[] = "rooms/00.txt";
|
||||||
|
filename[6] = int(room/10)+48;
|
||||||
|
filename[7] = (room%10)+48;
|
||||||
|
room_exists[room] = (file::fileExists(filename));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const int getExit(const int which) { return exits[which]; }
|
int getCurrentRoom() { return current_room; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#define NO_DOOR 0
|
#define NO_DOOR 0
|
||||||
#define DOOR_XP 1
|
#define DOOR_XP 1
|
||||||
@@ -35,30 +36,19 @@ namespace room
|
|||||||
int &refWidth();
|
int &refWidth();
|
||||||
int &refHeight();
|
int &refHeight();
|
||||||
|
|
||||||
uint8_t &refDoor(const int which);
|
int &refDoor(const int which);
|
||||||
|
|
||||||
void setWidth(const int value);
|
int &refColor();
|
||||||
void setHeight(const int value);
|
int &refFloorTex();
|
||||||
void setDoor(const int which, const int value);
|
int &refWallTex();
|
||||||
|
int &refDoorTex();
|
||||||
|
int &refWallDoorTex();
|
||||||
|
|
||||||
void setColor(const int value);
|
int &refExit(const int which);
|
||||||
void setFloorTex(const int value);
|
|
||||||
void setWallTex(const int value);
|
|
||||||
void setDoorTex(const int value);
|
|
||||||
void setWallDoorTex(const int value);
|
|
||||||
|
|
||||||
void setExit(const int which, const int value);
|
bool roomExists(const int which);
|
||||||
|
void updateRoomList();
|
||||||
|
|
||||||
const int getWidth();
|
int getCurrentRoom();
|
||||||
const int getHeight();
|
|
||||||
const int getDoor(const int which);
|
|
||||||
|
|
||||||
const int getColor();
|
|
||||||
const int getFloorTex();
|
|
||||||
const int getWallTex();
|
|
||||||
const int getDoorTex();
|
|
||||||
const int getWallDoorTex();
|
|
||||||
|
|
||||||
const int getExit(const int which);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user