diff --git a/source/jdraw.cpp b/source/jdraw.cpp index d3e1cf5..27b18b8 100644 --- a/source/jdraw.cpp +++ b/source/jdraw.cpp @@ -56,13 +56,13 @@ namespace draw void clear(const uint8_t val) { - if (!stencil) return; + if (!enabled || !stencil) return; memset(stencil->pixels, val, stencil->w*stencil->h); } void set(const uint8_t val) { - if (!stencil) return; + if (!enabled || !stencil) return; value = val; } diff --git a/source/m_editor_templates.cpp b/source/m_editor_templates.cpp new file mode 100644 index 0000000..6625314 --- /dev/null +++ b/source/m_editor_templates.cpp @@ -0,0 +1,59 @@ +#include "m_editor_templates.h" +#include "jdraw.h" +#include "jinput.h" +#include "misc.h" +#include +#include "actor.h" +#include + +namespace modules +{ + namespace editor_templates + { + std::vector templates; + + void init() + { + for (int i=0; iname, (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; + + } + } +} diff --git a/source/m_editor_templates.h b/source/m_editor_templates.h new file mode 100644 index 0000000..879a12f --- /dev/null +++ b/source/m_editor_templates.h @@ -0,0 +1,10 @@ +#pragma once + +namespace modules +{ + namespace editor_templates + { + void init(); + bool loop(); + } +} diff --git a/source/m_game.cpp b/source/m_game.cpp index 1bb9a5a..75da86a 100644 --- a/source/m_game.cpp +++ b/source/m_game.cpp @@ -270,6 +270,7 @@ namespace modules if (editor::isEditing()) { if (input::keyPressed(SDL_SCANCODE_TAB)) return GAME_EDITOR_MAP; + if (input::keyPressed(SDL_SCANCODE_GRAVE)) return GAME_EDITOR_TEMPLATES; editor_move_selected(); actor::updateEditor(actor::getFirst()); diff --git a/source/m_game.h b/source/m_game.h index e84a977..5b274ac 100644 --- a/source/m_game.h +++ b/source/m_game.h @@ -8,6 +8,7 @@ namespace modules #define GAME_MENU 0 #define GAME_DEAD 1 #define GAME_EDITOR_MAP 2 + #define GAME_EDITOR_TEMPLATES 3 void init(); int loop(); diff --git a/source/main.cpp b/source/main.cpp index ad5a217..74c4b44 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -20,6 +20,7 @@ #include "m_menu_tecles.h" #include "m_menu_audio.h" #include "m_editor_map.h" +#include "m_editor_templates.h" #define M_LOGO 0 #define M_MENU 1 @@ -139,6 +140,8 @@ bool game::loop() } } else if (option==GAME_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; @@ -147,6 +150,11 @@ bool game::loop() current_module = M_GAME; } break; + case M_EDITOR_TEMPLATES: + if (!modules::editor_templates::loop()) { + current_module = M_GAME; + } + break; case M_INGAME: option = modules::ingame::loop(); if (option != INGAME_NONE) {