mirror of
https://gitlab.com/lunovox/computing.git
synced 2025-03-15 14:41:20 +00:00
114 lines
4 KiB
Lua
114 lines
4 KiB
Lua
|
|
|
|
modComputing.getTextClockBar = function()
|
|
--return modComputing.getTextNowWeekDay3S()..", "..modComputing.getTextNowDate().." "..modComputing.getTextNowTime()
|
|
return modComputing.translate(
|
|
"@1, @2 @3",
|
|
modComputing.getTextNowWeekDay3S(),
|
|
modComputing.getTextNowDate(),
|
|
modComputing.getTextNowTime()
|
|
)
|
|
end
|
|
|
|
modComputing.getFormSmartphone = function(player)
|
|
local formspec = ""
|
|
.."formspec_version[6]"
|
|
.."size["..(10*271/484)..",10.0,true]"
|
|
.."no_prepend[]"
|
|
.."bgcolor[#08080844;true]" --Padrão: #080808BB | true = 100% transparente
|
|
.."style_type[label;font=mono;font_size=11;textcolor=#FFFFFF]"
|
|
.."style_type[image_button;font=normal;font_size=14;textcolor=#FFFFFF]"
|
|
.."style_type[image_button_exit;font=normal;font_size=14;textcolor=#FFFFFF]"
|
|
--.."background[-0.75,-2.00;"..(10*271/484)..",10.0;text_smartphone_271x484.png;true]"
|
|
.."image[0,0;"..(10*271/484)..",10.0;text_smartphone_271x484.png;true]"
|
|
.."label[0.75,1.975;"..core.formspec_escape(modComputing.getTextClockBar()).."]"
|
|
--.."button_exit[0.75,2.50;1.5,1.5;btnClose;"..core.formspec_escape(modComputing.translate("Banana\nStore")).."]"
|
|
|
|
|
|
|
|
local appsCount = 0
|
|
local appnames = modComputing.get_appnames()
|
|
local apps = modComputing.get_apps()
|
|
--modComputing.debug("apps = "..dump(apps) --[[, playername--]])
|
|
--apps = table.sort(apps)
|
|
for k,v in pairs(appnames) do
|
|
appsCount = appsCount + 1
|
|
local appname = v
|
|
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 maxCol = 2
|
|
local maxRow = 3
|
|
local offSetX = 1.10
|
|
local offSetY = 2.50
|
|
local sizeButtonX = 1.75
|
|
local sizeButtonY = 1.75
|
|
local page = math.floor(appsCount / (maxRow * maxCol)) --math.floor : arredonda sempre para menos
|
|
local iconInPage = appsCount - math.floor(page * maxRow * maxCol)
|
|
local iconRow = math.floor((iconInPage - 1) / maxCol)
|
|
local iconCol = (iconInPage - 1) % maxCol
|
|
--local iconRow = (iconInPage - 1) % maxRow
|
|
--local iconCol = 0
|
|
--local iconRow = iconInPage - 1
|
|
|
|
--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("btn_"..icon_name)..";"..core.formspec_escape(icon_title.."\n * "..icon_descryption)..";#008800;#FFFFFF]"
|
|
|
|
local newButton = core.formspec_escape("image_"..icon_type).."["
|
|
..(offSetX + (iconCol * sizeButtonX))..","
|
|
..(offSetY + (iconRow * sizeButtonY))
|
|
..";1.5,1.5;"
|
|
..core.formspec_escape(icon_image)..";" --texture name
|
|
..core.formspec_escape("btn_"..icon_name)..";" --button name
|
|
--..core.formspec_escape(appname).." "..iconRow.."/"..iconCol.."\n"..core.formspec_escape("page:"..page.."\ninpg:"..iconInPage)..";" --label
|
|
--..core.formspec_escape(icon_title)..";" --label
|
|
..";" --label empty
|
|
.."false;" --NOCLIP
|
|
.."true;" --drawborder
|
|
..core.formspec_escape(icon_image.."^[invert:rgb") --pressed texture name
|
|
.."]"
|
|
|
|
--modComputing.debug("newButton = "..dump(newButton) --[[, playername--]])
|
|
|
|
formspec = formspec..newToolTip..newButton
|
|
end
|
|
|
|
|
|
|
|
return formspec
|
|
end
|
|
|
|
modComputing.show_smartphone = function(player)
|
|
local playername = player:get_player_name()
|
|
core.show_formspec(playername, "frmSmartphone", modComputing.getFormSmartphone(player))
|
|
end
|
|
|
|
|
|
core.register_craftitem("computing:smartphone", {
|
|
description = modComputing.translate("SMARTPHONE"),
|
|
inventory_image = "icon_smartphone_128x128.png",
|
|
on_use = function(itemstack, player, pointed_thing)
|
|
modComputing.show_smartphone(player)
|
|
end,
|
|
})
|
|
|
|
--[[
|
|
core.register_craft({
|
|
output = 'computing:smartphone',
|
|
recipe = {
|
|
{"default:paper" ,"" ,""},
|
|
{"" ,"" ,""},
|
|
{"" ,"" ,""},
|
|
}
|
|
})
|
|
--]]
|
|
|
|
core.register_alias("smartphone", "computing:smartphone")
|
|
|
|
|
|
|