- Comence a implementar el selector de plantilles
This commit is contained in:
@@ -56,13 +56,13 @@ namespace draw
|
|||||||
|
|
||||||
void clear(const uint8_t val)
|
void clear(const uint8_t val)
|
||||||
{
|
{
|
||||||
if (!stencil) return;
|
if (!enabled || !stencil) return;
|
||||||
memset(stencil->pixels, val, stencil->w*stencil->h);
|
memset(stencil->pixels, val, stencil->w*stencil->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set(const uint8_t val)
|
void set(const uint8_t val)
|
||||||
{
|
{
|
||||||
if (!stencil) return;
|
if (!enabled || !stencil) return;
|
||||||
value = val;
|
value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
59
source/m_editor_templates.cpp
Normal file
59
source/m_editor_templates.cpp
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
source/m_editor_templates.h
Normal file
10
source/m_editor_templates.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace editor_templates
|
||||||
|
{
|
||||||
|
void init();
|
||||||
|
bool loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -270,6 +270,7 @@ namespace modules
|
|||||||
if (editor::isEditing())
|
if (editor::isEditing())
|
||||||
{
|
{
|
||||||
if (input::keyPressed(SDL_SCANCODE_TAB)) return GAME_EDITOR_MAP;
|
if (input::keyPressed(SDL_SCANCODE_TAB)) return GAME_EDITOR_MAP;
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_GRAVE)) return GAME_EDITOR_TEMPLATES;
|
||||||
|
|
||||||
editor_move_selected();
|
editor_move_selected();
|
||||||
actor::updateEditor(actor::getFirst());
|
actor::updateEditor(actor::getFirst());
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace modules
|
|||||||
#define GAME_MENU 0
|
#define GAME_MENU 0
|
||||||
#define GAME_DEAD 1
|
#define GAME_DEAD 1
|
||||||
#define GAME_EDITOR_MAP 2
|
#define GAME_EDITOR_MAP 2
|
||||||
|
#define GAME_EDITOR_TEMPLATES 3
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
int loop();
|
int loop();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "m_menu_tecles.h"
|
#include "m_menu_tecles.h"
|
||||||
#include "m_menu_audio.h"
|
#include "m_menu_audio.h"
|
||||||
#include "m_editor_map.h"
|
#include "m_editor_map.h"
|
||||||
|
#include "m_editor_templates.h"
|
||||||
|
|
||||||
#define M_LOGO 0
|
#define M_LOGO 0
|
||||||
#define M_MENU 1
|
#define M_MENU 1
|
||||||
@@ -139,6 +140,8 @@ bool game::loop()
|
|||||||
}
|
}
|
||||||
} else if (option==GAME_EDITOR_MAP) {
|
} else if (option==GAME_EDITOR_MAP) {
|
||||||
modules::editor_map::init(); current_module = M_EDITOR_MAP;
|
modules::editor_map::init(); current_module = M_EDITOR_MAP;
|
||||||
|
} else if (option==GAME_EDITOR_TEMPLATES) {
|
||||||
|
modules::editor_templates::init(); current_module = M_EDITOR_TEMPLATES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -147,6 +150,11 @@ bool game::loop()
|
|||||||
current_module = M_GAME;
|
current_module = M_GAME;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case M_EDITOR_TEMPLATES:
|
||||||
|
if (!modules::editor_templates::loop()) {
|
||||||
|
current_module = M_GAME;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case M_INGAME:
|
case M_INGAME:
|
||||||
option = modules::ingame::loop();
|
option = modules::ingame::loop();
|
||||||
if (option != INGAME_NONE) {
|
if (option != INGAME_NONE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user