Skip to content

Commit

Permalink
Reworked formspecs and kahrl's hexcolor parser
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockMen committed Nov 3, 2013
1 parent 0b78889 commit 25edae0
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 69 deletions.
4 changes: 2 additions & 2 deletions builtin/mm_menubar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ end

--------------------------------------------------------------------------------
function menubar.refresh()
menubar.formspec = "box[-0.3,5.625;12.4,1.3;000000]" ..
"box[-0.3,5.6;12.4,0.05;FFFFFF]"
menubar.formspec = "box[-0.3,5.625;12.4,1.3;#000000]" ..
"box[-0.3,5.6;12.4,0.05;#FFFFFF]"
menubar.buttons = {}

local button_base = -0.25
Expand Down
6 changes: 3 additions & 3 deletions builtin/modstore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ function modstore.getmodlist(list)
retval = retval .. "label[10,-0.4;" .. fgettext("Page $1 of $2", list.page+1, list.pagecount) .. "]"

retval = retval .. "button[11.6,-0.1;0.5,0.5;btn_modstore_page_up;^]"
retval = retval .. "box[11.6,0.35;0.28,8.6;000000]"
retval = retval .. "box[11.6,0.35;0.28,8.6;#000000]"
local scrollbarpos = 0.35 + (8.1/(list.pagecount-1)) * list.page
retval = retval .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;32CD32]"
retval = retval .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;#32CD32]"
retval = retval .. "button[11.6,9.0;0.5,0.5;btn_modstore_page_down;v]"


Expand All @@ -206,7 +206,7 @@ function modstore.getmodlist(list)
if details ~= nil then
local screenshot_ypos = (i-1 - (list.page * modstore.modsperpage))*1.9 +0.2

retval = retval .. "box[0," .. screenshot_ypos .. ";11.4,1.75;FFFFFF]"
retval = retval .. "box[0," .. screenshot_ypos .. ";11.4,1.75;#FFFFFF]"

--screenshot
if details.screenshot_url ~= nil and
Expand Down
45 changes: 41 additions & 4 deletions doc/lua_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,22 @@ list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]
list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;<starting item index>]
^ Show an inventory list

listcolors[<slot_bg_normal>;<slot_bg_hover>]
^ Sets background color of slots in HEX-Color format
^ Sets background color of slots on mouse hovering

listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>]
^ Sets background color of slots in HEX-Color format
^ Sets background color of slots on mouse hovering
^ Sets color of slots border

listcolors[<slot_bg_normal>;<slot_bg_hover>;<slot_border>;<tooltip_bgcolor>;<tooltip_fontcolor>]
^ Sets background color of slots in HEX-Color format
^ Sets background color of slots on mouse hovering
^ Sets color of slots border
^ Sets background color of tooltips
^ Sets font color of tooltips

image[<X>,<Y>;<W>,<H>;<texture name>]
^ Show an image
^ Position and size units are inventory slots
Expand All @@ -881,11 +897,21 @@ item_image[<X>,<Y>;<W>,<H>;<item name>]
^ Show an inventory image of registered item/node
^ Position and size units are inventory slots

bgcolor[<color>;<fullscreen>]
^ Sets background color of formspec in HEX-Color format
^ If true the background color is drawn fullscreen (does not effect the size of the formspec)

background[<X>,<Y>;<W>,<H>;<texture name>]
^ Use a background. Inventory rectangles are not drawn then.
^ Position and size units are inventory slots
^ Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px

background[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>]
^ Use a background. Inventory rectangles are not drawn then.
^ Position and size units are inventory slots
^ Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px
^ If true the background is clipped to formspec size (x and y are used as offset values, w and h are ignored)

pwdfield[<X>,<Y>;<W>,<H>;<name>;<label>]
^ Textual password style field; will be sent to server when a button is clicked
^ x and y position the field relative to the top left of the menu
Expand Down Expand Up @@ -972,15 +998,15 @@ textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>]
^ x and y position the itemlist relative to the top left of the menu
^ w and h are the size of the itemlist
^ name fieldname sent to server on doubleclick value is current selected element
^ listelements can be prepended by #color in hexadecimal format RRGGBB,
^ listelements can be prepended by #color in hexadecimal format RRGGBB (only),
^ if you want a listelement to start with # write ##

textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<selected idx>;<transparent>]
^Scrollabel itemlist showing arbitrary text elements
^ x and y position the itemlist relative to the top left of the menu
^ w and h are the size of the itemlist
^ name fieldname sent to server on doubleclick value is current selected element
^ listelements can be prepended by #RRGGBB in hexadecimal format
^ listelements can be prepended by #RRGGBB (only) in hexadecimal format
^ if you want a listelement to start with # write ##
^ index to be selected within textlist
^ true/false draw transparent background
Expand All @@ -998,7 +1024,7 @@ box[<X>,<Y>;<W>,<H>;<color>]
^ simple colored semitransparent box
^ x and y position the box relative to the top left of the menu
^ w and h are the size of box
^ color in hexadecimal format RRGGBB
^ color in HEX-Color format

dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]
^ show a dropdown field
Expand All @@ -1007,7 +1033,7 @@ dropdown[<X>,<Y>;<W>;<name>;<item 1>,<item 2>, ...,<item n>;<selected idx>]
^ fieldname data is transfered to lua
^ items to be shown in dropdown
^ index of currently selected dropdown item
^ color in hexadecimal format RRGGBB
^ color in hexadecimal format RRGGBB (only)

checkbox[<X>,<Y>;<name>;<label>;<selected>]
^ show a checkbox
Expand All @@ -1027,6 +1053,17 @@ Inventory location:
- "nodemeta:<X>,<Y>,<Z>": Any node metadata
- "detached:<name>": A detached inventory

HEX-Color
---------
#RGB
^ defines a color in hexadecimal format
#RGBA
^ defines a color in hexadecimal format and alpha channel
#RRGGBB
^ defines a color in hexadecimal format
#RRGGBBAA
^ defines a color in hexadecimal format and alpha channel

Vector helpers
---------------
vector.new([x[, y, z]]) -> vector
Expand Down
Loading

0 comments on commit 25edae0

Please sign in to comment.