[feat][notested] Added param app 'is_visible' for specific player.

This commit is contained in:
Lunovox 2024-11-26 02:40:49 -03:00
parent a5c8106010
commit 4ed0f8dd4e

View file

@ -19,8 +19,14 @@ modComputing.getTextClockBar = function()
)
end
modComputing.getFormSmartphone = function(player)
local playername = player:get_player_name()
modComputing.smartphone.getFormSpec = function(player)
local formspec = ""
..modComputing.smartphone.getFormBackground()
..modComputing.smartphone.getAppListConteiner(player)
return formspec
end
modComputing.smartphone.getFormBackground = function()
local formspec = ""
.."formspec_version[6]"
.."size["..(10*271/484)..",10.0,true]"
@ -32,6 +38,11 @@ modComputing.getFormSmartphone = function(player)
.."image[0,0;"..(10*271/484)..",10.0;text_smartphone_271x484.png;true]"
.."style_type[label;font=mono;font_size=10;textcolor=#FFFFFF]"
.."label[0.75,1.975;"..core.formspec_escape(modComputing.getTextClockBar()).."]"
return formspec
end
modComputing.smartphone.getAppListConteiner = function(player)
local playername = player:get_player_name()
local formspec = ""
.."style_type[container;font=normal;font_size=7;textcolor=#FFFFFF]"
--.."button_exit[0.75,2.50;1.5,1.5;btnClose;"..core.formspec_escape(modComputing.translate("Banana\nStore")).."]"
@ -56,61 +67,66 @@ modComputing.getFormSmartphone = function(player)
local sizeButtonY = modComputing.smartphone.sizeButtonY
for k,v in pairs(appnames) do
appsCount = appsCount + 1
local apps = modComputing.get_apps()
--modComputing.debug("apps = "..dump(apps) --[[, playername--]])
local apps = modComputing.get_apps()
local icon_name = apps[v].icon_name
local icon_title = apps[v].icon_title
local icon_descryption = apps[v].icon_descryption
local icon_type = apps[v].icon_type
local icon_image = apps[v].icon_image
local on_iconclick = apps[v].on_iconclick
local is_visible = apps[v].is_visible or true
local page = math.floor((appsCount - 1) / (maxRow * maxCol)) --math.floor : arredonda sempre para menos
if page == modComputing.show_page[playername] then
local iconInPage = appsCount - math.floor(page * maxRow * maxCol)
local iconRow = math.floor((iconInPage - 1) / maxCol)
local iconCol = (iconInPage - 1) % maxCol
--SAMPLE: image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]
--SAMPLE: image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
local newToolTip = "tooltip["..core.formspec_escape(icon_name)..";"
..core.formspec_escape(
core.colorize("#00FF00", icon_title).."\n"
.."* "..icon_descryption
)
..";#004400;#FFFFFF"
.."]"
local newAppButton = core.formspec_escape("image_"..icon_type).."["
.."0.10,0"
..";1.35,1.35;"
..core.formspec_escape(icon_image)..";" --texture name
..core.formspec_escape(icon_name)..";" --button name
--..";" --label empty
--..core.formspec_escape(appname).." "..iconRow.."/"..iconCol.."\n"..core.formspec_escape("page:"..page.."\ninpg:"..iconInPage)..";" --label
..";" --empty label
.."false;" --NOCLIP
.."false;" --drawborder
..core.formspec_escape(icon_image.."^[invert:rgb") --pressed texture name
.."]"
local newAppLabel = "label[0.10,1.50;"
..core.formspec_escape(icon_title)
.."]"
--modComputing.debug("newAppButton = "..dump(newAppButton) --[[, playername--]])
formspec = formspec
.."container["
..(offSetX + (iconCol * marginConteinerX) + (iconCol * sizeButtonX))..","
..(offSetY + (iconRow * marginConteinerY) + (iconRow * sizeButtonY))
.."]"
--.."box[0,0;1.45,1.65;#00000088]"
..newToolTip..newAppButton..newAppLabel
.."container_end[]"
end --Final of: if page == modComputing.show_page[playername] then
if (type(is_visible)=="boolean" and is_visible == true)
or (type(is_visible)=="function" and is_visible(player))
then
appsCount = appsCount + 1
--modComputing.debug("apps = "..dump(apps) --[[, playername--]])
local page = math.floor((appsCount - 1) / (maxRow * maxCol)) --math.floor : arredonda sempre para menos
if page == modComputing.show_page[playername] then
local iconInPage = appsCount - math.floor(page * maxRow * maxCol)
local iconRow = math.floor((iconInPage - 1) / maxCol)
local iconCol = (iconInPage - 1) % maxCol
--SAMPLE: image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]
--SAMPLE: image_button_exit[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>]
local newToolTip = "tooltip["..core.formspec_escape(icon_name)..";"
..core.formspec_escape(
core.colorize("#00FF00", icon_title).."\n"
.."* "..icon_descryption
)
..";#004400;#FFFFFF"
.."]"
local newAppButton = core.formspec_escape("image_"..icon_type).."["
.."0.10,0"
..";1.35,1.35;"
..core.formspec_escape(icon_image)..";" --texture name
..core.formspec_escape(icon_name)..";" --button name
--..";" --label empty
--..core.formspec_escape(appname).." "..iconRow.."/"..iconCol.."\n"..core.formspec_escape("page:"..page.."\ninpg:"..iconInPage)..";" --label
..";" --empty label
.."false;" --NOCLIP
.."false;" --drawborder
..core.formspec_escape(icon_image.."^[invert:rgb") --pressed texture name
.."]"
local newAppLabel = "label[0.10,1.50;"
..core.formspec_escape(icon_title)
.."]"
--modComputing.debug("newAppButton = "..dump(newAppButton) --[[, playername--]])
formspec = formspec
.."container["
..(offSetX + (iconCol * marginConteinerX) + (iconCol * sizeButtonX))..","
..(offSetY + (iconRow * marginConteinerY) + (iconRow * sizeButtonY))
.."]"
--.."box[0,0;1.45,1.65;#00000088]"
..newToolTip..newAppButton..newAppLabel
.."container_end[]"
end --Final of: if page == modComputing.show_page[playername] then
end
end --FONAL OF: for k,v in pairs(appnames) do
local maxPages = math.floor((appsCount - 1) / (maxRow * maxCol)) --math.floor : arredonda sempre para menos
@ -169,7 +185,7 @@ end
modComputing.show_smartphone = function(player)
local playername = player:get_player_name()
core.show_formspec(playername, "frmSmartphone", modComputing.getFormSmartphone(player))
core.show_formspec(playername, "frmSmartphone", modComputing.smartphone.getFormSpec(player))
end
core.register_on_player_receive_fields(function(player, formname, fields)