From 33320c800dc2d3afe3b6006577a25d1d714a507a Mon Sep 17 00:00:00 2001 From: darkrose Date: Sun, 2 Mar 2014 20:44:02 +1000 Subject: [PATCH] implement formspec - I seem to have done this before --- doc/formspec.txt | 80 ++++ src/CMakeLists.txt | 2 +- src/client.cpp | 62 ++- src/client.h | 4 +- src/clientserver.h | 14 + src/content_nodemeta.cpp | 39 +- src/content_nodemeta.h | 19 +- src/game.cpp | 169 ++++---- src/guiFormSpecMenu.cpp | 822 +++++++++++++++++++++++++++++++++++++++ src/guiFormSpecMenu.h | 215 ++++++++++ src/guiInventoryMenu.cpp | 527 ------------------------- src/guiInventoryMenu.h | 162 -------- src/guiTextInputMenu.h | 7 +- src/inventory.cpp | 70 ++++ src/inventory.h | 68 ++++ src/modalMenu.h | 2 +- src/nodemetadata.h | 7 +- src/server.cpp | 86 ++-- 18 files changed, 1503 insertions(+), 852 deletions(-) create mode 100644 doc/formspec.txt create mode 100644 src/guiFormSpecMenu.cpp create mode 100644 src/guiFormSpecMenu.h delete mode 100644 src/guiInventoryMenu.cpp delete mode 100644 src/guiInventoryMenu.h diff --git a/doc/formspec.txt b/doc/formspec.txt new file mode 100644 index 0000000..0ef1920 --- /dev/null +++ b/doc/formspec.txt @@ -0,0 +1,80 @@ +Formspec +-------- +Formspec defines a menu. Currently not much else than inventories are +supported. It is a string, with a somewhat strange format. + +Spaces and newlines can be inserted between the blocks, as is used in the +examples. + +Examples: +- Chest: + size[8,9] + list[current_name;main;0,0;8,4;] + list[current_player;main;0,5;8,4;] +- Furnace: + size[8,9] + list[current_name;fuel;2,3;1,1;] + list[current_name;src;2,1;1,1;] + list[current_name;dst;5,1;2,2;] + list[current_player;main;0,5;8,4;] + +Elements: + +size[,] +^ Define the size of the menu in inventory slots +^ deprecated: invsize[,;] + +list[;;,;,;] +^ Show an inventory list + +image[,;,;] +^ Show an image +^ Position and size units are inventory slots + +field[,;,;;