[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 end
modComputing.getFormSmartphone = function(player) modComputing.smartphone.getFormSpec = function(player)
local playername = player:get_player_name() local formspec = ""
..modComputing.smartphone.getFormBackground()
..modComputing.smartphone.getAppListConteiner(player)
return formspec
end
modComputing.smartphone.getFormBackground = function()
local formspec = "" local formspec = ""
.."formspec_version[6]" .."formspec_version[6]"
.."size["..(10*271/484)..",10.0,true]" .."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]" .."image[0,0;"..(10*271/484)..",10.0;text_smartphone_271x484.png;true]"
.."style_type[label;font=mono;font_size=10;textcolor=#FFFFFF]" .."style_type[label;font=mono;font_size=10;textcolor=#FFFFFF]"
.."label[0.75,1.975;"..core.formspec_escape(modComputing.getTextClockBar()).."]" .."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]" .."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")).."]" --.."button_exit[0.75,2.50;1.5,1.5;btnClose;"..core.formspec_escape(modComputing.translate("Banana\nStore")).."]"
@ -56,16 +67,21 @@ modComputing.getFormSmartphone = function(player)
local sizeButtonY = modComputing.smartphone.sizeButtonY local sizeButtonY = modComputing.smartphone.sizeButtonY
for k,v in pairs(appnames) do for k,v in pairs(appnames) do
appsCount = appsCount + 1
local apps = modComputing.get_apps() local apps = modComputing.get_apps()
--modComputing.debug("apps = "..dump(apps) --[[, playername--]])
local icon_name = apps[v].icon_name local icon_name = apps[v].icon_name
local icon_title = apps[v].icon_title local icon_title = apps[v].icon_title
local icon_descryption = apps[v].icon_descryption local icon_descryption = apps[v].icon_descryption
local icon_type = apps[v].icon_type local icon_type = apps[v].icon_type
local icon_image = apps[v].icon_image local icon_image = apps[v].icon_image
local on_iconclick = apps[v].on_iconclick local on_iconclick = apps[v].on_iconclick
local is_visible = apps[v].is_visible or true
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 local page = math.floor((appsCount - 1) / (maxRow * maxCol)) --math.floor : arredonda sempre para menos
if page == modComputing.show_page[playername] then if page == modComputing.show_page[playername] then
local iconInPage = appsCount - math.floor(page * maxRow * maxCol) local iconInPage = appsCount - math.floor(page * maxRow * maxCol)
@ -110,7 +126,7 @@ modComputing.getFormSmartphone = function(player)
..newToolTip..newAppButton..newAppLabel ..newToolTip..newAppButton..newAppLabel
.."container_end[]" .."container_end[]"
end --Final of: if page == modComputing.show_page[playername] then end --Final of: if page == modComputing.show_page[playername] then
end
end --FONAL OF: for k,v in pairs(appnames) do end --FONAL OF: for k,v in pairs(appnames) do
local maxPages = math.floor((appsCount - 1) / (maxRow * maxCol)) --math.floor : arredonda sempre para menos local maxPages = math.floor((appsCount - 1) / (maxRow * maxCol)) --math.floor : arredonda sempre para menos
@ -169,7 +185,7 @@ end
modComputing.show_smartphone = function(player) modComputing.show_smartphone = function(player)
local playername = player:get_player_name() local playername = player:get_player_name()
core.show_formspec(playername, "frmSmartphone", modComputing.getFormSmartphone(player)) core.show_formspec(playername, "frmSmartphone", modComputing.smartphone.getFormSpec(player))
end end
core.register_on_player_receive_fields(function(player, formname, fields) core.register_on_player_receive_fields(function(player, formname, fields)