Added -l flag

master
bzt 2019-12-08 08:56:12 +01:00
parent bc93d34a19
commit 2a510802fd
7 changed files with 80 additions and 53 deletions

View File

@ -4,25 +4,6 @@ Minetest MTS Editor
<img src="https://gitlab.com/bztsrc/mtsedit/raw/master/etc/mtsedit.png"> This is a simple editor for
[Minetest](https://www.minetest.net) Schematic files ([MTS](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/mts_format.md))
```
MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
./mtsedit [-v] [-d|-p|-P] [-m map] <.mts|.schematic> [out.mts]
./mtsedit -g <block.png>
./mtsedit -t <blockimgs.csv> [blockid]
./mtsedit -i [Minetest mods dir]
-v: verbose output
-d: dump layers to output
-p: save preview
-P: save preview, cut structure in half
-m map: replace block type mapping
-g: generate slab and stairs from block image
-t: generate block images from texture data
-i: install Minetest mod
out.mts: output to file
```
Batch Mode
----------

View File

@ -5,10 +5,29 @@ This is the description of the windowless operation mode.
See also the [GUI usage](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/usage.md).
```
MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
./mtsedit [-v] [-l <lang>] [-d|-p|-P] [-m map] <.mts|.schematic> [out.mts]
./mtsedit -g <block.png>
./mtsedit -t <blockimgs.csv> [blockid]
./mtsedit -i [Minetest mods dir]
-v: verbose output
-d: dump layers to output
-p: save preview
-P: save preview, cut structure in half
-m map: replace block type mapping
-g: generate slab and stairs from block image
-t: generate block images from texture data
-i: install Minetest mod
out.mts: output to file
```
Batch Mode
----------
You can use this tool from scripts to bulk convert schematic files or generate preview for them.
You can use this tool to bulk process schematic files from scripts.
### Dump Schematic to Standard Output

View File

@ -6,13 +6,20 @@ an usage to stdout.
See also [batch mode usage](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/batch.md).
```
MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
./mtsedit [-v] [-l <lang>] <.mts|.schematic|directory>
```
Configuration
-------------
For the data directory, see [blocks.csv](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/blocks.md).
For the data directory, see [blocks.csv](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/blocks.md). If not found, provide
the path in MTSDATA environment variable.
The User Interface is translatable. It should detect your computer's language automatically, but if not, set the `LANG`
environment variable. Supported languages:
environment variable, or add `-l` to command line. Supported languages:
- "en" English
- "hu" Magyar
- "es" Español
@ -23,6 +30,7 @@ environment variable. Supported languages:
```
LANG=hu ./mtsedit monkeyisland.mts
./mtsedit -l hu monkeyisland.mts
```
Note that block names are user provided, there's no translation for those, unless you provide `blocks_(lang).txt` files too.
@ -65,6 +73,18 @@ here. On the right, you see the current zoom ratio, and the brush's height and s
Everything else on the screen is the main editor area `E`.
### Mouse Handling
| Mouse Event | Description |
|-----------------------------------|---------------------------------------------------|
| mouse left button | place the selected block |
| mouse right button | rotate block |
| middle buttons (scroll) | scroll the editor area |
| <kbd>Shift</kbd> + scroll up/down | move the upper layers up and down |
| <kbd>Shift</kbd> + scroll left | rotate the current block counter clock-wise |
| <kbd>Shift</kbd> + scroll right | rotate the current block clock-wise |
| <kbd>Ctrl</kbd> + scroll up/down | zoom in or out |
### 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).
@ -75,18 +95,12 @@ Main editor window:
| Key | Description |
|-----------------------------------|---------------------------------------------------|
| mouse left button | place the selected block |
| mouse right button | rotate block |
| middle buttons (scroll) | scroll the editor area |
| <kbd>Shift</kbd> + scroll up/down | move the upper layers up and down |
| <kbd>Shift</kbd> + scroll left | rotate the current block counter clock-wise |
| <kbd>Shift</kbd> + scroll right | rotate the current block clock-wise |
| <kbd>PgUp</kbd> / <kbd>PgDn</kbd> | change current layer |
| arrows | select current block |
| arrow keys | move cursor, select current block |
| <kbd>Space</kbd> | place selected block |
| <kbd>Backspace</kbd> | erase current block |
| <kbd>Enter</kbd> | flood fill (or erase) entire areas |
| <kbd>Ctrl</kbd> + arrows | scroll the editor area |
| <kbd>Ctrl</kbd> + arrow keys | scroll the editor area |
| <kbd>Shift</kbd> + up / down | move the upper layers up and down |
| <kbd>Shift</kbd> + left | rotate the current block counter clock-wise |
| <kbd>Shift</kbd> + right | rotate the current block clock-wise |

View File

@ -1,14 +1,15 @@
[Desktop Entry]
Name=MTSEdit
Name[en_US]=MTSEdit
GenericName=Minetest Schematic Editor
GenericName[en_US]=Minetest Schematic Editor
Comment=Edit and convert MTS schematic files
Exec=mtsedit %F
TryExec=mtsedit ~/.minetest/worlds
Terminal=false
Version=1.0
Type=Application
Name=MTSEdit
Comment=Edit and convert MTS schematic files
Exec=LANG=hu mtsedit ~/.minetest/worlds
Icon=mtsedit
Categories=Graphics;3DGraphics;Editor;
Terminal=false
StartupNotify=false
Categories=Application;Game;Graphics;3DGraphics;Editor;
MimeType=model/vnd.mts;application/x-minetest-schematic;
Actions=Edit
[Desktop Action Edit]
Name=Edit with MTSEdit
Exec=mtsedit %F

Binary file not shown.

Binary file not shown.

View File

@ -150,25 +150,24 @@ int APIENTRY WinMain(_unused HINSTANCE hInstance, _unused HINSTANCE hPrevInstanc
int main(int argc, char** argv, char** envp)
{
int i, j, opt = 0, ret = 0;
char **env, *newmap = NULL;
char **env, *newmap = NULL, *lc = NULL;
/* detect the language and load dictionary for it */
for(env = envp; env && *env; env++)
if(!memcmp(*env, "LANG=", 5)) {
for(i = 0; i < NUMLANGS; i++) {
if(!memcmp(*env + 5, dict[i][0], strlen(dict[i][0]))) {
lang = &dict[i][1];
break;
}
/* detect the language (or get from command line) and load dictionary for it */
for(env = envp; env && *env; env++) if(!memcmp(*env, "LANG=", 5)) { lc = *env + 5; break; }
for(i = 1; i < argc; i++) if(argv[i][0] == '-' && argv[i][1] == 'l') { lc = argv[i+1]; break; }
if(lc)
for(i = 0; i < NUMLANGS; i++) {
if(!memcmp(lc, dict[i][0], strlen(dict[i][0]))) {
lang = &dict[i][1];
break;
}
break;
}
/* get blocks data */
blocks_getdir(argv, envp);
if(argc < 2) {
usage: printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license\r\n\r\n"
"./mtsedit [-v] [-d|-p|-P] [-m map] <.mts|.schematic> [out.mts]\r\n"
"./mtsedit [-v] [-l <lang>] [-d|-p|-P] [-m map] <.mts|.schematic> [out.mts]\r\n"
"./mtsedit -g <block.png>\r\n"
"./mtsedit -t <blockimgs.csv> [blockid]\r\n"
"./mtsedit -i [Minetest mods dir]\r\n"
@ -190,6 +189,7 @@ usage: printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
case 't': opt = 5; break;
case 'i': opt = 6; break;
case 'm': if(!opt) { opt = 7; } newmap = argv[++j]; break;
case 'l': j++; break;
default: goto usage; break;
}
i++;
@ -198,7 +198,13 @@ usage: printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
}
}
if(i >= argc || !argv[i]) goto usage;
strncpy(mtsfile, argv[i], sizeof(mtsfile));
#ifndef __WIN32__
if(argv[i][0] == '~') {
strncpy(mtsfile, home, sizeof(mtsfile));
strncat(mtsfile, argv[i] + 1, sizeof(mtsfile));
} else
#endif
strncpy(mtsfile, argv[i], sizeof(mtsfile));
savelen = savepos = strlen(mtsfile);
tmpblk = (unsigned char*)malloc(32 * 32 * 4);
if(!tmpblk) error(lang[ERR_MEM]);
@ -219,7 +225,13 @@ usage: printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
}
}
if(argv[i+1]) {
strncpy(mtsfile, argv[i+1], sizeof(mtsfile));
#ifndef __WIN32__
if(argv[i+1][0] == '~') {
strncpy(mtsfile, home, sizeof(mtsfile));
strncat(mtsfile, argv[i+1] + 1, sizeof(mtsfile));
} else
#endif
strncpy(mtsfile, argv[i+1], sizeof(mtsfile));
ret = mts_save();
}
}