- Nous gràfics
- [FIX] text en el combobox - [NEW] Selector de bitmap - [NEW] Selector de color - [NEW] Shortcuts per a esborrar (SUPR) i duplicar (CTRL+D) actors
This commit is contained in:
@@ -100,6 +100,8 @@ namespace ui
|
||||
draw::rect(x, y, w, h);
|
||||
draw::vline(x+w-11,y+1,h-2);
|
||||
|
||||
draw::print(label, x+3, y+3, PAPER, 0);
|
||||
|
||||
draw::color(WHITE);
|
||||
draw::fillrect(x+w-10, y+1, 9, h-2);
|
||||
|
||||
@@ -111,7 +113,6 @@ namespace ui
|
||||
draw::hline(x+w-10,y+h-2,9);
|
||||
draw::vline(x+w-2,y+1,h-2);
|
||||
|
||||
draw::print(label, x+3, y+3, PAPER, 0);
|
||||
draw::print("v", x+w-7, y+2, PAPER, 0);
|
||||
|
||||
if (inside)
|
||||
|
||||
54
source/m_editor_bitmap_file.cpp
Normal file
54
source/m_editor_bitmap_file.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "m_editor_bitmap_file.h"
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include "room.h"
|
||||
#include "actor.h"
|
||||
#include "m_game.h"
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace editor_bitmap_file
|
||||
{
|
||||
std::vector<std::string> gifs = { "abad.gif", "altres.gif", "caixes.gif", "gat.gif", "gat2.gif", "objectes.gif", "obrer.gif" };
|
||||
|
||||
void init()
|
||||
{
|
||||
draw::resetViewport();
|
||||
//gifs = game::getGifs();
|
||||
}
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) return false;
|
||||
|
||||
if (input::mouseClk(1))
|
||||
{
|
||||
const int x = input::mouseX()/80;
|
||||
const int y = input::mouseY()/80;
|
||||
const int selected = x+y*6;
|
||||
actor::actor_t* act = actor::getSelected();
|
||||
strcpy(act->bmp, gifs[selected].c_str());
|
||||
act->surface = draw::getSurface(gifs[selected]);
|
||||
return false;
|
||||
}
|
||||
|
||||
draw::cls(2);
|
||||
int bx = 0;
|
||||
int by = 0;
|
||||
for (int i=0; i<gifs.size(); ++i)
|
||||
{
|
||||
draw::surface *surf = draw::getSurface(gifs[i].c_str());
|
||||
draw::setSource(surf);
|
||||
const float aspect = float(surf->w) / float(surf->h);
|
||||
const int width = 64.0f*aspect;
|
||||
draw::draw(2+80*bx, 2+by*80, surf->w, surf->h, 0, 0, 0, 64, 64);
|
||||
draw::print(gifs[i].c_str(), 2+80*bx + 32 - (gifs[0].size()/2)*4, 70+by*80, LIGHT+WHITE, PAPER);
|
||||
bx++; if (bx>5) { bx=0; by++; }
|
||||
}
|
||||
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
source/m_editor_bitmap_file.h
Normal file
10
source/m_editor_bitmap_file.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace editor_bitmap_file
|
||||
{
|
||||
void init();
|
||||
bool loop();
|
||||
}
|
||||
}
|
||||
59
source/m_editor_colors.cpp
Normal file
59
source/m_editor_colors.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "m_editor_colors.h"
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include "room.h"
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace editor_colors
|
||||
{
|
||||
void init()
|
||||
{
|
||||
draw::setViewport(468, 117, 52, 52);
|
||||
}
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) return false;
|
||||
|
||||
const char *colors[] = {"PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"};
|
||||
const int color = room::editor::refColor();
|
||||
const int mx = input::mouseX()-468;
|
||||
const int my = input::mouseY()-117;
|
||||
const bool mouse_inside = mx>=0 && mx<52 && my>=0 && my<52;
|
||||
|
||||
if (input::mouseClk(1))
|
||||
{
|
||||
if (mouse_inside) {
|
||||
const int new_color = (my-1)/10;
|
||||
room::editor::refColor() = new_color;
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
draw::color(WHITE);
|
||||
draw::fillrect(0,0,52,52);
|
||||
draw::color(LIGHT+WHITE);
|
||||
draw::hline(0, 0, 52);
|
||||
draw::vline(0, 0, 52);
|
||||
|
||||
draw::color(BLACK);
|
||||
draw::hline(0, 51, 52);
|
||||
draw::vline(51, 0, 52);
|
||||
|
||||
const int hovered_element = mouse_inside ? (my-1)/10 : -1;
|
||||
for (int i=0; i<5; ++i)
|
||||
{
|
||||
if (hovered_element==i) { draw::color(LIGHT+BLUE); draw::fillrect(1,1+i*10,50,10); }
|
||||
draw::print(colors[i], 5, 3+i*10, LIGHT+(color==i?YELLOW:WHITE), PAPER);
|
||||
draw::color(LIGHT+i+7); draw::fillrect(40,2+i*10,7,7);draw::color(PAPER); draw::rect(40,2+i*10,7,7);
|
||||
}
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
10
source/m_editor_colors.h
Normal file
10
source/m_editor_colors.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace editor_colors
|
||||
{
|
||||
void init();
|
||||
bool loop();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ namespace modules
|
||||
std::vector<std::string> gifs;
|
||||
int treeview_scroll = 0;
|
||||
|
||||
std::vector<std::string> getGifs() { return gifs; }
|
||||
|
||||
void init()
|
||||
{
|
||||
actor::clear(true);
|
||||
@@ -256,6 +258,8 @@ namespace modules
|
||||
|
||||
int loop()
|
||||
{
|
||||
int return_value = GAME_NONE;
|
||||
|
||||
if (actor::hero::isDead()) return GAME_DEAD;
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE))
|
||||
@@ -609,8 +613,19 @@ namespace modules
|
||||
|
||||
ui::label("TEXTURES", 2, line, 96, 11, GRAY); line+=10;
|
||||
|
||||
changed |= btn_opt("COLOR", 2, line, room::editor::refColor(), {0, 1, 2, 3, 4}, {"PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"}, 47); //ui::label("COLOR", 2, line, 64, 11);
|
||||
//changed |= btn_small(64, line, room::editor::refColor(), 5, 11);
|
||||
//changed |= btn_opt("COLOR", 2, line, room::editor::refColor(), {0, 1, 2, 3, 4}, {"PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"}, 47); //ui::label("COLOR", 2, line, 64, 11);
|
||||
{
|
||||
const char *colors[] = {"PURPLE", "GREEN", "CYAN", "YELLOW", "WHITE"};
|
||||
ui::label("COLOR", 2, line, 48, 11);
|
||||
const int color = room::editor::refColor();
|
||||
if (ui::combo(colors[color], 48, line, 49, 11)) {
|
||||
//if (ui::button(colors[room::editor::refColor()], 48, line+1, 49, 9)) {
|
||||
//ui::button(colors[room::editor::refColor()], 48, line+1, 49, 9, true);
|
||||
return_value = GAME_EDITOR_COLORS;
|
||||
}
|
||||
draw::color(LIGHT+color+7); draw::fillrect(77,2+line,7,7);draw::color(PAPER); draw::rect(77,2+line,7,7);
|
||||
}
|
||||
|
||||
line += 10;
|
||||
ui::label("FLOOR", 2, line, 48, 11);
|
||||
changed |= btn_small(48, line, room::editor::refFloorTex(), 0, room::getFloorCount()-1, 50);
|
||||
@@ -694,11 +709,22 @@ namespace modules
|
||||
|
||||
ui::label("BITMAP", 2, line, 96, 11, GRAY); line+=10;
|
||||
|
||||
{
|
||||
ui::label("FILE", 2, line, 49, 11);
|
||||
if (ui::combo(act->bmp, 49, line, 48, 11)) {
|
||||
//if (ui::button(colors[room::editor::refColor()], 48, line+1, 49, 9)) {
|
||||
//ui::button(colors[room::editor::refColor()], 48, line+1, 49, 9, true);
|
||||
return_value = GAME_EDITOR_BITMAP_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (btn_opt2("FILE", 2, line, act->bmp, gifs)) {
|
||||
//draw::freeSurface(act->surface);
|
||||
act->surface = draw::getSurface(act->bmp);
|
||||
changed = true;
|
||||
}
|
||||
*/
|
||||
line+=10;
|
||||
ui::label("POS", 2, line, 48, 11);
|
||||
changed |= btn_small(49, line, act->bmp_rect.x, 0, 512, 25);
|
||||
@@ -771,7 +797,7 @@ namespace modules
|
||||
draw::color(PAPER);
|
||||
draw::rect(2, 0, 96, 204);
|
||||
|
||||
if (ui::button("DUPLICATE", 2, line, 48, 11))
|
||||
if (ui::button("DUPLICATE", 2, line, 48, 11) || (input::keyDown(SDL_SCANCODE_LCTRL) && input::keyPressed(SDL_SCANCODE_D)))
|
||||
{
|
||||
actor::actor_t *new_act = actor::duplicate(act);
|
||||
actor::setUniqueName(new_act);
|
||||
@@ -780,7 +806,7 @@ namespace modules
|
||||
actor::select(new_act);
|
||||
changed = true;
|
||||
}
|
||||
if (ui::button("DELETE", 48, line, 48, 11))
|
||||
if (ui::button("DELETE", 48, line, 48, 11) || input::keyPressed(SDL_SCANCODE_DELETE))
|
||||
{
|
||||
actor::remove(act);
|
||||
act = nullptr;
|
||||
@@ -801,7 +827,7 @@ namespace modules
|
||||
};
|
||||
|
||||
draw::render();
|
||||
return GAME_NONE;
|
||||
return return_value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace modules
|
||||
{
|
||||
@@ -9,8 +11,12 @@ namespace modules
|
||||
#define GAME_DEAD 1
|
||||
#define GAME_EDITOR_MAP 2
|
||||
#define GAME_EDITOR_TEMPLATES 3
|
||||
#define GAME_EDITOR_COLORS 4
|
||||
#define GAME_EDITOR_BITMAP_FILE 5
|
||||
|
||||
void init();
|
||||
int loop();
|
||||
|
||||
std::vector<std::string> getGifs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "m_menu_audio.h"
|
||||
#include "m_editor_map.h"
|
||||
#include "m_editor_templates.h"
|
||||
#include "m_editor_colors.h"
|
||||
#include "m_editor_bitmap_file.h"
|
||||
|
||||
#define M_LOGO 0
|
||||
#define M_MENU 1
|
||||
@@ -32,6 +34,8 @@
|
||||
#define M_MENU_AUDIO 7
|
||||
#define M_EDITOR_MAP 8
|
||||
#define M_EDITOR_TEMPLATES 9
|
||||
#define M_EDITOR_COLORS 10
|
||||
#define M_EDITOR_BITMAP_FILE 11
|
||||
|
||||
int current_module = M_LOGO;
|
||||
int zoom = 3;
|
||||
@@ -142,6 +146,10 @@ bool game::loop()
|
||||
modules::editor_map::init(); current_module = M_EDITOR_MAP;
|
||||
} else if (option==GAME_EDITOR_TEMPLATES) {
|
||||
modules::editor_templates::init(); current_module = M_EDITOR_TEMPLATES;
|
||||
} else if (option==GAME_EDITOR_COLORS) {
|
||||
modules::editor_colors::init(); current_module = M_EDITOR_COLORS;
|
||||
} else if (option==GAME_EDITOR_BITMAP_FILE) {
|
||||
modules::editor_bitmap_file::init(); current_module = M_EDITOR_BITMAP_FILE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -155,6 +163,16 @@ bool game::loop()
|
||||
current_module = M_GAME;
|
||||
}
|
||||
break;
|
||||
case M_EDITOR_COLORS:
|
||||
if (!modules::editor_colors::loop()) {
|
||||
current_module = M_GAME;
|
||||
}
|
||||
break;
|
||||
case M_EDITOR_BITMAP_FILE:
|
||||
if (!modules::editor_bitmap_file::loop()) {
|
||||
current_module = M_GAME;
|
||||
}
|
||||
break;
|
||||
case M_INGAME:
|
||||
option = modules::ingame::loop();
|
||||
if (option != INGAME_NONE) {
|
||||
|
||||
Reference in New Issue
Block a user