master
bzt 2019-12-05 01:12:30 +01:00
parent ba505c16c6
commit 3a8363283b
20 changed files with 174 additions and 77 deletions

View File

@ -7,12 +7,14 @@ This is a simple editor for [Minetest](https://www.minetest.net) Schematic files
```
MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
./mtsedit [-d|-p|-P|-g] [-m map] <.mts|.schematic> [out.mts]
./mtsedit [-v] [-d|-p|-P|-g|-i] [-m map] [-f] <.mts|.schematic> [out.mts]
-v: verbose output
-d: dump layers to output
-p: save preview
-P: save preview, cut structure in half
-g: generate slab and stairs from block image
-i: generate block images from texture data
-m map: replace block type mapping
out.mts: output to file
@ -39,6 +41,8 @@ The other component is a Minetest mod, under the [mt-mod](https://gitlab.com/bzt
small Lua script runs inside the game, and can import your edited MTS files into the game's world. It can also save MTS files
and capable of generating the blocks.csv for you.
<img src="https://gitlab.com/bztsrc/mtsedit/raw/master/docs/mtseditmod.png">
Compilation
-----------
@ -46,8 +50,7 @@ This is very simple, as MTSEdit was written in ANSI C. The one and only dependen
in the "src" directory, and that will autodetect your operating system (Linux, BSD, MacOSX and Windows).
It also needs some [data files](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/blocks.md), which can be found
[here](https://gitlab.com/bztsrc/mtsedit/tree/master/data). You can generate the blocks.csv with the
[MTSEdit Minetest Mod](https://gitlab.com/bztsrc/mtsedit/tree/master/mt-mod).
[here](https://gitlab.com/bztsrc/mtsedit/tree/master/data).
### Under Linux, BSD, MacOSX

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 17 KiB

BIN
docs/mtseditmod.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View File

@ -24,6 +24,7 @@ Interactive Mode
----------------
This is the default. If you start MTSEdit with a single parameter, being an MTS file's path, it will open it in a GUI editor.
If you run MTSEdit with the `-f` (force start GUI) argument, then it will start at the specify file name window.
### Main Editor Window
@ -33,8 +34,13 @@ You can find the toolbar `A` on the left. The icons are:
1. Load / Reload Structure
2. Save As
3. Save Preview
4. Change Orientation
5. Add Blocks to Palette
4. Layer Operations (small icons)
5. Undo / Redo (last two small icons)
6. Select Brush
7. Add Blocks to Palette
Layer Operations are: change orientation, flip structure, insert Y layer, remove Y layer, insert X layer, remove X layer,
insert Z layer, remove Z layer.
Beneath the icons is the palette `B`. You can add blocks to here from the Add Blocks menu, and then you can quickly access them
by shortcuts.
@ -48,12 +54,16 @@ On the bottom left corner, you find the Layer-related options `C`:
5. Current Layer's Probability
The bottom line is the status bar `D`. You'll see the block names here as you hover over them. Messages like file saved also shown
here.
here. On the right, you see the current zoom ratio, and the brush's height and shape.
Everything else on the screen is the main editor area `E`.
### Keyboard Shortcuts
The GUI was designed in a way that you can use it without a mouse (actually it's faster to only use the keyboard in some cases).
Therefore the keyboard shortcuts may seem odd; the reason for the layout is that <kbd>Space</kbd> is the main "painter" key, and
the other functions are arranged close to it. Having a key of the letter that the function starts with was a secondary importance.
Main editor window:
| Key | Description |
@ -95,6 +105,8 @@ Main editor window:
| <kbd>Ctrl</kbd> + <kbd>V</kbd> | remove current Z layer |
| <kbd>B</kbd> | select brush (use geometric objects) |
| <kbd>M</kbd> / <kbd>Tab</kbd> | open block map, search all available blocks |
| <kbd>,</kbd> / <kbd>&lt;</kbd> | zoom out |
| <kbd>.</kbd> / <kbd>&gt;</kbd> | zoom in |
| <kbd>0</kbd>, <kbd>Backquote</kbd> | select Air block (erase mode) |
| <kbd>1</kbd> - <kbd>9</kbd> | quickly access one of the blocks from the palette |
| <kbd>G</kbd> | set current layer as ground level |

BIN
examples/Notre_Dame.mts Normal file

Binary file not shown.

BIN
examples/Notre_Dame.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
examples/Old_Mine.mts Normal file

Binary file not shown.

BIN
examples/Old_Mine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

BIN
examples/Pantheon.mts Normal file

Binary file not shown.

BIN
examples/Pantheon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@ -29,7 +29,7 @@
#include "main.h"
int dx = 0, dz = 0, cx = 0, cz = 0, ox = 0, oy = 0, up = 0, zoom = 32;
int dx = 0, dz = 0, cx = 0, cz = 0, ox = 0, oy = 0, up = 0, zoom = 128, zz = 0, zx = 0, zs = 0;
char dstr[32];
/**
@ -66,22 +66,40 @@ void edit_placenode(int y, int z, int x, int i)
status = i ? blocks[i].name : NULL;
}
/**
* Zoom in
*/
int edit_zoomin()
{
if(zoom < 256) { zoom += 32; return 1; }
return 0;
}
/**
* Zoom out
*/
int edit_zoomout()
{
if(zoom > 32) { zoom -= 32; return 1; }
return 0;
}
/**
* Redraw the Edit Area
*/
void edit_redraw(int full)
{
int i, j, k = 160, l, X, Z, x, y, z, sx, sy, mx;
int i, j, k = 160, l, X, Z, x, y, z, sx, sy, mx, zl;
unsigned char *b = (uint8_t*)&theme[THEME_TABBG];
SDL_Rect dst, src;
if(!dx || !dz) {
dst.x = 36; dst.y = 0; dst.w = screen->w - 36; dst.h = screen->h - font->height;
SDL_FillRect(screen, &dst, theme[THEME_TABBG]);
return;
}
zz = dz * zoom / 128; zx = dx * zoom / 128; zs = 32 * zoom / 128;
if(zz < 1) zz = 1;
if(zx < 1) zx = 1;
if(zs < 1) zs = 1;
zl = zs - 2*(2 + zz);
mx = ((bg->w / 2 / dx) + (bg->h / 2 / dz)) /2;
mx = (((bg->w / 2 / zx) + (bg->h / 2 / zz)) / 2) + 1;
sx = bg->w / 2;
sy = bg->h / 2;
@ -96,12 +114,12 @@ void edit_redraw(int full)
for(y = mx > currlayer ? 0 : currlayer - mx; y < currlayer; y++) {
for(z = -mx; z < mx; z++) {
for(x = -mx; x < mx; x++) {
dst.x = sx + dx * (x - z);
dst.y = sy + dz * (z + x + 2*(currlayer - y));
dst.w = dst.h = zs;
dst.x = sx + zx * (x - z);
dst.y = sy + zz * (z + x) + zl * (currlayer - y);
X = 127 + x + oy + ox;
Z = 127 + z + oy - ox;
if(X < 0 || X > 255 || Z < 0 || Z > 255 ||
dst.x + 32 < 0 || dst.x > bg->w || dst.y + 32 < 0 || dst.y > bg->h) continue;
if(X < 0 || X > 255 || Z < 0 || Z > 255 || dst.x < 0 || dst.x > bg->w || dst.y < 0 || dst.y > bg->h) continue;
i = nodes[y][Z][X].param0;
j = nodes[y][Z][X].param2 & 0x1F;
if(i) {
@ -117,23 +135,28 @@ void edit_redraw(int full)
}
}
blk->pixels = blocks[i].dr[j];
SDL_BlitSurface(blk, &src, bg, &dst);
if(dst.w == src.w)
SDL_BlitSurface(blk, &src, bg, &dst);
else
SDL_BlitScaled(blk, &src, bg, &dst);
}
}
}
}
/* foreground, layers above */
memset(fg->pixels, 0, fg->pitch * fg->h);
if(up > mx) up = mx;
mts_getbounds(0, NULL, NULL);
k = ((max - mix) + (maz - miz) + 1) / 2;
if(up > k) up = k;
for(y = currlayer + 1; y < (currlayer + mx < 255 ? currlayer + mx : 255); y++) {
for(z = -mx; z < mx; z++) {
for(x = -mx; x < mx; x++) {
dst.x = sx + dx * (x - z);
dst.y = sy + dz * (z + x + (currlayer - y - 1) - mx + up);
dst.w = dst.h = zs;
dst.x = sx + zx * (x - z);
dst.y = sy + zz * (z + x - k + up) + zl * ((currlayer - y));
X = 127 + x + oy + ox;
Z = 127 + z + oy - ox;
if(X < 0 || X > 255 || Z < 0 || Z > 255 ||
dst.x + 32 < 36 || dst.x > fg->w || dst.y + 32 < 0 || dst.y > fg->h) continue;
if(X < 0 || X > 255 || Z < 0 || Z > 255 || dst.x < 0 || dst.x > fg->w || dst.y < 0 || dst.y > fg->h) continue;
i = nodes[y][Z][X].param0;
j = nodes[y][Z][X].param2 & 0x1F;
if(i) {
@ -145,7 +168,10 @@ void edit_redraw(int full)
for(l = 0; l < 32 * 32 * 4; l += 4) blocks[i].tr[j][l+3] >>= 2;
}
blk->pixels = blocks[i].tr[j];
SDL_BlitSurface(blk, &src, fg, &dst);
if(dst.w == src.w)
SDL_BlitSurface(blk, &src, fg, &dst);
else
SDL_BlitScaled(blk, &src, fg, &dst);
}
}
}
@ -156,33 +182,39 @@ void edit_redraw(int full)
memset(cl->pixels, 0, cl->pitch * cl->h);
for(z = -mx; z < mx; z++) {
for(x = -mx; x < mx; x++) {
src.w = src.h = dst.w = dst.h = 32; src.x = src.y = 0;
dst.x = sx + dx * (x - z);
dst.y = sy + dz * (z + x);
src.w = src.h = 32; dst.w = dst.h = zs; src.x = src.y = 0;
dst.x = sx + zx * (x - z);
dst.y = sy + zz * (z + x);
X = 127 + x + oy + ox;
Z = 127 + z + oy - ox;
if(X < 0 || X > 255 || Z < 0 || Z > 255 ||
dst.x + 32 < 0 || dst.x > cl->w || dst.y + 32 < 0 || dst.y > cl->h) continue;
if(dst.x < 0) { src.x = -dst.x; src.w += dst.x; dst.w += dst.x; dst.x = 0; }
if(dst.y < 0) { src.y = -dst.y; src.h += dst.y; dst.h += dst.y; dst.y = 0; }
if(X < 0 || X > 255 || Z < 0 || Z > 255 || dst.x < 0 || dst.x > cl->w || dst.y < 0 || dst.y > cl->h) continue;
i = nodes[currlayer][Z][X].param0;
j = nodes[currlayer][Z][X].param2 & 0x1F;
if((X == cx && Z == cz) || brush_selected(X, Z)) {
blk->pixels = (uint8_t*)icons->pixels + 64 * icons->pitch;
SDL_BlitSurface(blk, &src, cl, &dst);
if(dst.w == src.w)
SDL_BlitSurface(blk, &src, cl, &dst);
else
SDL_BlitScaled(blk, &src, cl, &dst);
}
if(i) {
blk->pixels = blocks[i].img[j] ? blocks[i].img[j] : (blocks[i].img[0] ? blocks[i].img[0] :
(uint8_t*)icons->pixels + 32 * icons->pitch);
SDL_BlitSurface(blk, &src, cl, &dst);
if(dst.w == src.w)
SDL_BlitSurface(blk, &src, cl, &dst);
else
SDL_BlitScaled(blk, &src, cl, &dst);
}
if((X == cx && Z == cz) || brush_selected(X, Z)) {
blk->pixels = (uint8_t*)icons->pixels + 96 * icons->pitch;
SDL_BlitSurface(blk, &src, cl, &dst);
if(dst.w == src.w)
SDL_BlitSurface(blk, &src, cl, &dst);
else
SDL_BlitScaled(blk, &src, cl, &dst);
}
}
}
src.x = src.y = dst.y = 0; dst.x = 36; src.w = dst.w = bg->w; src.h = dst.h = bg->h;
src.x = src.y = 32; dst.y = 0; dst.x = 36; src.w = dst.w = bg->w; src.h = dst.h = bg->h;
SDL_BlitSurface(bg, &src, screen, &dst);
SDL_BlitSurface(cl, &src, screen, &dst);
SDL_BlitSurface(fg, &src, screen, &dst);
@ -191,17 +223,21 @@ void edit_redraw(int full)
/**
* Edit Area scrolling event handler
*/
void edit_scroll(SDL_Event *event)
int edit_scroll(SDL_Event *event)
{
int lu = up, lx = ox, ly = oy;
if(shift) {
if(event->wheel.y) {
up -= event->wheel.y;
if(up < -128) up = -128;
if(up > 127) up = 127;
} else
} else {
edit_rotate(currlayer, cz, cx, event->wheel.x < 0 ? 1 : 0);
return 1;
}
} else if(ctrl) {
edit_rotate(currlayer, cz, cx, 1);
if(event->wheel.y > 0) return edit_zoomout();
if(event->wheel.y < 0) return edit_zoomin();
} else {
oy += event->wheel.y;
if(oy < -128) oy = -128;
@ -210,6 +246,7 @@ void edit_scroll(SDL_Event *event)
if(ox < -128) ox = -128;
if(ox > 127) ox = 127;
}
return (lu != up || lx != ox || ly != oy);
}
/**
@ -218,16 +255,16 @@ void edit_scroll(SDL_Event *event)
void edit_mouseover(SDL_Event *event)
{
int l, k, x, y, X = cx, Z = cz;
x = event->type == SDL_MOUSEMOTION ? event->motion.x : event->button.x;
y = event->type == SDL_MOUSEMOTION ? event->motion.y : event->button.y;
x = (event->type == SDL_MOUSEMOTION ? event->motion.x : event->button.x) + 32;
y = (event->type == SDL_MOUSEMOTION ? event->motion.y : event->button.y) + 32;
l = (int)(y - (bg->h / 2));
if(l < 0) l -= dz;
l /= dz; l--;
k = (int)(x - 36 - (bg-> w / 2) - dx/2);
if(k < 0) k -= dx;
k -= (l & 1 ? dx/2 : 0);
k /= dx;
if(l < 0) l -= zz;
l /= zz; l--;
k = (int)(x - 36 - (bg-> w / 2) - zx/2);
if(k < 0) k -= zx;
k -= (l & 1 ? zx/2 : 0);
k /= zx;
cz = (l - k) / 2;
cx = l - cz;
cz += 127 + oy - ox;
@ -322,6 +359,8 @@ void edit_key(SDL_Event *event)
blocks[nodes[currlayer][cz][cx].param0].name : NULL;
}
break;
case SDLK_COMMA: edit_zoomout(); break;
case SDLK_PERIOD: edit_zoomin(); break;
case SDLK_BACKSPACE:
case SDLK_DELETE:
case SDLK_SPACE:

View File

@ -242,7 +242,7 @@ void hist_add(int y, int z, int x, unsigned short op0, unsigned char op2, unsign
/**
* Undo from history
*/
void hist_undo()
int hist_undo()
{
int i, j, x, y, z;
@ -298,13 +298,15 @@ void hist_undo()
}
histtop++;
status = nodes[currlayer][cz][cx].param0 ? blocks[nodes[currlayer][cz][cx].param0].name : NULL;
return 1;
}
return 0;
}
/**
* Redo from history
*/
void hist_redo()
int hist_redo()
{
int i, j, x, y, z;
@ -360,7 +362,9 @@ void hist_redo()
case HIST_DELX: mts_delx(history[histtop].x); break;
}
status = nodes[currlayer][cz][cx].param0 ? blocks[nodes[currlayer][cz][cx].param0].name : NULL;
return 1;
}
return 0;
}
/**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -181,7 +181,7 @@ int main(int argc, char** argv, char** envp)
if(argc < 2) {
printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license\r\n\r\n"
"./mtsedit [-v] [-d|-p|-P|-g|-i] [-m map] <.mts|.schematic> [out.mts]\r\n\r\n -v: %s\r\n -d: %s"
"./mtsedit [-v] [-d|-p|-P|-g|-i] [-m map] [-f] <.mts|.schematic> [out.mts]\r\n\r\n -v: %s\r\n -d: %s"
"\r\n -p: %s\r\n -P: %s\r\n -g: %s\r\n -i: %s\r\n -m map: %s\r\n out.mts: %s\r\n",
lang[INF_VERB], lang[INF_DUMP], lang[INF_PRE1], lang[INF_PRE2], lang[INF_GEN], lang[INF_BLK],
lang[INF_MAP], lang[INF_OUT]);
@ -197,18 +197,24 @@ int main(int argc, char** argv, char** envp)
case 'P': opt = 3; break;
case 'g': opt = 4; break;
case 'i': opt = 5; break;
case 'm': if(!opt) { opt = 6; } newmap = argv[++j]; break;
case 'f': opt = 6; break;
case 'm': if(!opt) { opt = 7; } newmap = argv[++j]; break;
}
i++;
} else {
i = j; break;
}
}
strncpy(mtsfile, argv[i], sizeof(mtsfile));
savelen = savepos = strlen(argv[i]);
if(opt == 6) {
opt = 0;
activetool = 1;
} else
strncpy(mtsfile, argv[i], sizeof(mtsfile));
savelen = savepos = strlen(mtsfile);
tmpblk = (unsigned char*)malloc(32 * 32 * 4);
if(!tmpblk) error(lang[ERR_MEM]);
if(argv[i+1] && !opt) opt = 6;
if(i+1 <= argc && argv[i+1] && !opt) opt = 7;
if(opt && opt != 4) {
parseblocks();
readschem();
@ -230,7 +236,7 @@ int main(int argc, char** argv, char** envp)
case 2:
case 3: ret = mts_view(opt-2); break;
case 4: ret = stairgen(); break;
case 5: /* todo: generate block images */ break;
case 5: printf("not implemented yet, sorry\n"); /* todo: generate block images */ break;
case 0:
/* start the main user interface */
sdlmain();

View File

@ -109,7 +109,7 @@ typedef struct {
extern int numpalettes, lenpalettes, palette[16], strmaxw, strsep, savelen, savepos, savepal, savebiome, numresults, *results;
extern int currlayer, gndlayer, mts_x, mts_y, mts_z, mix, miy, miz, max, may, maz, bound_valid, dx, dz, cx, cz, ox, oy, up;
extern int shift, ctrl, activetool, activeblock, quitting, verbose, x0, x1, y0, y1, brush_type, brush_hollow;
extern int zx, zz, zs, shift, ctrl, activetool, activeblock, quitting, verbose, x0, x1, y0, y1, brush_type, brush_hollow, zoom;
extern char **palettes, layerprob[256];
extern int numblocks;
extern mtsblock_t *blocks;
@ -222,8 +222,10 @@ void sdlmain();
/* edit.c */
void edit_placenode(int y, int z, int x, int i);
int edit_zoomin();
int edit_zoomout();
void edit_redraw(int full);
void edit_scroll(SDL_Event *event);
int edit_scroll(SDL_Event *event);
void edit_mouseover(SDL_Event *event);
void edit_mousedown(_unused SDL_Event *event);
void edit_key(SDL_Event *event);
@ -233,8 +235,8 @@ void edit_rotate(int y, int z, int x, int ccw);
void hist_prepare(int type, int volume);
void hist_commit();
void hist_add(int y, int z, int x, unsigned short op0, unsigned char op2, unsigned short np0, unsigned char np2);
void hist_undo();
void hist_redo();
int hist_undo();
int hist_redo();
void hist_free(int s, int e);
/* save.c */

View File

@ -312,6 +312,7 @@ int mts_view(int type)
status = lang[ERR_PREVIEW];
mts_getbounds(0, NULL, NULL);
if(mix > max) return 1;
bound_valid = 0;
/* calculate dimensions and create images */
n = (max - mix) + (maz - miz) + 1;

View File

@ -71,6 +71,8 @@ help_t helpkeys[] = {
{ GROUNDLEVEL, " G " },
{ LAYERUP, " PgUp " },
{ LAYERDOWN, " PgDn " },
{ ZOOMOUT, " , \001 / \001 < " },
{ ZOOMIN, " . \001 / \001 > " },
{ SCROLL, " Ctrl \001 + \001\033\001 \001\030\001 \001\031\001 \001\032" }
};
@ -219,13 +221,24 @@ void sdltoolbar()
sprintf(str, "%3d%%", layerprob[currlayer] * 100 / 127);
sdlprint(2, screen->h - font->height, THEME_INACT, THEME_BG, str);
/* status bar */
src.x = 16; src.y = 8 * 32 + 80; dst.x = screen->w - 9 * font->width - 9 - 52; dst.y = screen->h - font->height / 2 - 8;
src.w = src.h = dst.w = dst.h = 16;
SDL_BlitSurface(icons, &src, screen, &dst);
dst.x += 20;
sprintf(str, "%3d%%", zoom * 100 / 128);
sdlprint(dst.x, screen->h - font->height, THEME_FG, THEME_BG, str);
dst.x += 4 * (font->width+2);
src.x = 0;
SDL_BlitSurface(icons, &src, screen, &dst);
dst.x += 24;
sprintf(str, "%3d", brush_height());
sdlprint(screen->w - 5 * font->width - 8, screen->h - font->height, THEME_FG, THEME_BG, str);
sdlprint(dst.x, screen->h - font->height, THEME_FG, THEME_BG, str);
dst.x += 3 * (font->width+1);
memcpy(str, "\xC2\x80\xC2\x80", 5);
strsep = 0;
str[1] = 0x80 + (4*brush_type) + (2*brush_hollow);
str[3] = 0x81 + (4*brush_type) + (2*brush_hollow);
sdlprint(screen->w - 2 * font->width - 4, screen->h - font->height, THEME_FG, THEME_BG, str);
sdlprint(dst.x, screen->h - font->height, THEME_FG, THEME_BG, str);
strsep = 1;
if(s)
sdlprint(42, screen->h - font->height, THEME_FG, THEME_BG, s);
@ -236,12 +249,19 @@ void sdltoolbar()
*/
void sdlredraw()
{
SDL_Rect dst;
/* main window area */
switch(activetool) {
case 1: save_redraw(); break;
case 15: edit_redraw(1); brush_redraw(); break;
case 16: search_redraw(); break;
default: edit_redraw(1); break;
if(!dx || !dz) {
dst.x = 36; dst.y = 0; dst.w = screen->w - 36; dst.h = screen->h - font->height;
SDL_FillRect(screen, &dst, theme[THEME_TABBG]);
} else {
switch(activetool) {
case 1: save_redraw(); break;
case 15: edit_redraw(1); brush_redraw(); break;
case 16: search_redraw(); break;
default: edit_redraw(1); break;
}
}
/* toolbar and status bar */
@ -323,9 +343,9 @@ void sdlmain()
SDL_FreeSurface(icons);
icons = SDL_CreateRGBSurfaceFrom((uint32_t*)icondata, iw, ih, 32, iw*4, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
blk = SDL_CreateRGBSurfaceFrom(NULL, 32, 32, 32, 32*4, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
fg = SDL_CreateRGBSurface(0, screen->w - 36, screen->h - font->height, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
cl = SDL_CreateRGBSurface(0, screen->w - 36, screen->h - font->height, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
bg = SDL_CreateRGBSurface(0, screen->w - 36, screen->h - font->height, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
fg = SDL_CreateRGBSurface(0, screen->w - 36 + 64, screen->h - font->height + 64, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
cl = SDL_CreateRGBSurface(0, screen->w - 36 + 64, screen->h - font->height + 64, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
bg = SDL_CreateRGBSurface(0, screen->w - 36 + 64, screen->h - font->height + 64, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
memset(&histcurr, 0, sizeof(histlist_t));
dx = dz = 0;
@ -371,11 +391,11 @@ void sdlmain()
SDL_FreeSurface(fg);
SDL_FreeSurface(bg);
screen = SDL_GetWindowSurface(window);
fg = SDL_CreateRGBSurface(0, screen->w - 36, screen->h - font->height, 32,
fg = SDL_CreateRGBSurface(0, screen->w - 36 + 64, screen->h - font->height + 64, 32,
0xFF, 0xFF00, 0xFF0000, 0xFF000000);
cl = SDL_CreateRGBSurface(0, screen->w - 36, screen->h - font->height, 32,
cl = SDL_CreateRGBSurface(0, screen->w - 36 + 64, screen->h - font->height + 64, 32,
0xFF, 0xFF00, 0xFF0000, 0xFF000000);
bg = SDL_CreateRGBSurface(0, screen->w - 36, screen->h - font->height, 32,
bg = SDL_CreateRGBSurface(0, screen->w - 36 + 64, screen->h - font->height + 64, 32,
0xFF, 0xFF00, 0xFF0000, 0xFF000000);
sdlredraw();
break;
@ -413,6 +433,12 @@ void sdlmain()
if(event.motion.y < (int)(screen->h - 3*font->height - 2*36))
j = (event.motion.y - 4 - 5 * 36 - 88) / 32;
} else
if(event.motion.y > screen->h - (int)font->height) {
if(event.motion.x > screen->w - 9 * (int)font->width - 9 - 52 &&
event.motion.x < screen->w - 7 * (int)font->width - 2 - 32) i = 14;
if(event.motion.x > screen->w - 7 * (int)font->width - 7 - 32 &&
event.motion.x < screen->w - 5 * (int)font->width - 5 - 12) i = 13;
} else
if(activetool == 16) search_mouseover(&event); else
if(activetool == -1) {
if(event.motion.x > screen->w - 32 && event.motion.y >= (int)(screen->h - font->height - 32)) i = -5;
@ -461,6 +487,7 @@ void sdlmain()
}
break;
case SDL_MOUSEBUTTONUP:
i = 1;
if(activetool != -1 && activetool == overtool) {
switch(activetool) {
case 0: sdldo(0); break;
@ -473,23 +500,26 @@ void sdlmain()
case 8: sdldo(9); break;
case 9: sdldo(10); break;
case 10: sdldo(11); break;
case 11: hist_undo(); break;
case 12: hist_redo(); break;
case 11: i = hist_undo(); break;
case 12: i = hist_redo(); break;
case 13: i = edit_zoomin(); break;
case 14: i = edit_zoomout(); break;
case 17: if(currlayer < 255) currlayer++; break;
case 18: if(currlayer > 0) currlayer--; break;
}
if(activetool != 1 && activetool != 15 && activetool != 16) activetool = -1;
}
sdlredraw();
if(i) sdlredraw();
break;
case SDL_MOUSEWHEEL:
i = 1;
if(overtool == -3) mts_layerprob(event.wheel.y); else
switch(activetool) {
case 1: save_scroll(&event); break;
case 16: search_scroll(&event); break;
case -1: edit_scroll(&event); break;
case -1: i = edit_scroll(&event); break;
}
sdlredraw();
if(i) sdlredraw();
break;
/* handle the keyboard */