mirror of
https://github.com/mt-mods/home_workshop_modpack.git
synced 2024-09-27 14:50:42 +02:00
improve browser tab default
This commit is contained in:
parent
fa1f4894af
commit
8267c4d71f
18
computers/default_page.page
Normal file
18
computers/default_page.page
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<global margin=20>
|
||||||
|
<normal>ㅤ</normal>
|
||||||
|
<center><bigger>Welcome to ARPANET</bigger></center>
|
||||||
|
<big>How to use it</big>
|
||||||
|
<normal>on the bottom of this pane is field input which allows you to enter site urls</normal>
|
||||||
|
<normal>example: <mono><style color=blue>domain</style></mono></normal>
|
||||||
|
<normal>example: <mono><style color=blue>domain/demo_page.page</style></mono></normal>
|
||||||
|
<normal>ㅤ</normal>
|
||||||
|
|
||||||
|
<big>Try it out</big>
|
||||||
|
<action name=demo_link _href=demo_page>test url</action>
|
||||||
|
<normal>ㅤ</normal>
|
||||||
|
|
||||||
|
<big>How can I host my own sites?</big>
|
||||||
|
<normal>you will need to set up the server node</normal>
|
||||||
|
<normal>put your webfiles in there in hypertext format in the public_html folder</normal>
|
||||||
|
<normal>domainname/ and domainname/folder/ will connect to the indexpage file found in the DIR</normal>
|
||||||
|
<normal>ㅤ</normal>
|
7
computers/demo_page.page
Normal file
7
computers/demo_page.page
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<global margin=20>
|
||||||
|
<normal>ㅤ</normal>
|
||||||
|
<center><bigger>Welcome to Demo Page</bigger></center>
|
||||||
|
<normal>ㅤ</normal>
|
||||||
|
|
||||||
|
<action name=default_link _href=default_page>go back</action>
|
||||||
|
<normal>ㅤ</normal>
|
|
@ -117,6 +117,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
btn_override or keys[1]
|
btn_override or keys[1]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
--minetest.chat_send_all(keys[1])
|
||||||
|
--minetest.chat_send_all(fields[keys[1]])
|
||||||
|
|
||||||
if element and element.on_event then
|
if element and element.on_event then
|
||||||
--on_event(form, player, element)
|
--on_event(form, player, element)
|
||||||
local form = element.on_event(
|
local form = element.on_event(
|
||||||
|
@ -130,3 +133,29 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if form then computers.formspec.show_formspec(player, formname, form) end
|
if form then computers.formspec.show_formspec(player, formname, form) end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--[[
|
||||||
|
yes, i know this isnt perfect
|
||||||
|
requires a name field in the subtags
|
||||||
|
returns a table keyed by the name field with sub tables containing the other sub tags
|
||||||
|
]]
|
||||||
|
function computers.formspec.get_hypertext_subtags(hypertext, tag)
|
||||||
|
local adata = {}
|
||||||
|
for a in string.gmatch(hypertext, "<"..tag..".->.-</"..tag..">") do
|
||||||
|
local len = #tag+1
|
||||||
|
local tags = string.split(string.sub(a:split(">")[1], len, -1), " ")
|
||||||
|
local name
|
||||||
|
local storage = {}
|
||||||
|
for _, tag_string in pairs(tags) do
|
||||||
|
local split = tag_string:split("=")
|
||||||
|
if split[1] == "name" then
|
||||||
|
name = split[2]
|
||||||
|
else
|
||||||
|
storage[split[1]] = split[2]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
adata[name] = storage
|
||||||
|
end
|
||||||
|
--minetest.chat_send_all(dump(adata))
|
||||||
|
return adata
|
||||||
|
end
|
|
@ -2,6 +2,13 @@ computers.gui = {}
|
||||||
|
|
||||||
local futil = computers.formspec
|
local futil = computers.formspec
|
||||||
|
|
||||||
|
local f = io.open(computers.modpath .. "/default_page.page")
|
||||||
|
local default_page = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
f = io.open(computers.modpath .. "/demo_page.page")
|
||||||
|
local demo_page = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
|
||||||
local function select_btn(form, btn)
|
local function select_btn(form, btn)
|
||||||
--to hardcoded
|
--to hardcoded
|
||||||
for _, obtn in pairs(form.tabs) do
|
for _, obtn in pairs(form.tabs) do
|
||||||
|
@ -170,63 +177,78 @@ function computers.gui.load(pos, node, clicker)
|
||||||
state = 1,
|
state = 1,
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 1,
|
y = 1,
|
||||||
|
--[[
|
||||||
|
hardcoded background for now, need to build in custom element support
|
||||||
|
into hypertext to map to formspec elements
|
||||||
|
]]
|
||||||
{
|
{
|
||||||
type = "background",
|
type = "background",
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
w = 10,
|
w = 10,
|
||||||
h = 11,
|
h = 10,
|
||||||
texture_name = "kuto_button.png^[combine:16x16^[noalpha^[colorize:#ffffff70"
|
texture_name = "[combine:16x16^[noalpha^[colorize:#ffffff70"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "label",
|
type = "hypertext",
|
||||||
x = 1,
|
name = "browser_content",
|
||||||
y = 1.5,
|
|
||||||
label = "browser pane",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type = "button",
|
|
||||||
x = 1,
|
|
||||||
y = 2,
|
|
||||||
w = 5,
|
|
||||||
h = 2,
|
|
||||||
name = "test_btn",
|
|
||||||
label = "test btn",
|
|
||||||
on_event = function(_, player, element)
|
|
||||||
--local cindex = futil.get_index_by_name(form, "browser_ctn")
|
|
||||||
--local eindex = futil.get_index_by_name(form[cindex], "test_btn")
|
|
||||||
--form[cindex][eindex] = {type = "label", x=1, y=3, label = "test button label"}
|
|
||||||
local form = computers.gui.add_tab(player, "Tname", {
|
|
||||||
type = "container",
|
|
||||||
name = "tname_ctn",
|
|
||||||
state = 1,
|
|
||||||
x = 0,
|
|
||||||
y = 1,
|
|
||||||
{
|
|
||||||
type = "background",
|
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
w = 10,
|
w = 10,
|
||||||
h = 11,
|
h = 10,
|
||||||
texture_name = "kuto_button.png^[combine:16x16^[noalpha^[colorize:#ffffff70"
|
text = default_page,
|
||||||
|
on_event = function(form, player, element, value, fields)
|
||||||
|
--minetest.chat_send_all("reached")
|
||||||
|
|
||||||
|
--hard coding some network stuff for now
|
||||||
|
local name = value:split(":")[2]
|
||||||
|
|
||||||
|
local tags = futil.get_hypertext_subtags(element.text, "action")
|
||||||
|
if tags[name] and tags[name]._href and tags[name]._href == "demo_page" then
|
||||||
|
--minetest.chat_send_all(tags[name]._href)
|
||||||
|
element.text = demo_page
|
||||||
|
elseif tags[name] and tags[name]._href and tags[name]._href == "default_page" then
|
||||||
|
element.text = default_page
|
||||||
|
end
|
||||||
|
|
||||||
|
return form
|
||||||
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "label",
|
type = "background",
|
||||||
x = 1,
|
x = 0,
|
||||||
y = 1.5,
|
y = 10,
|
||||||
label = "Tname pane",
|
w = 10,
|
||||||
|
h = 1,
|
||||||
|
texture_name = "[combine:16x16^[noalpha"
|
||||||
},
|
},
|
||||||
})
|
{
|
||||||
|
type = "box",
|
||||||
|
x = 0,
|
||||||
|
y = 10,
|
||||||
|
w = 10,
|
||||||
|
h = 1,
|
||||||
|
color = "#ffffff"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "field",
|
||||||
|
x = 0,
|
||||||
|
y = 10,
|
||||||
|
w = 10,
|
||||||
|
h = 1,
|
||||||
|
name = "browser_url",
|
||||||
|
close_on_enter = false,
|
||||||
|
pwd = "",
|
||||||
|
props = {
|
||||||
|
border = false,
|
||||||
|
},
|
||||||
|
on_event = function(form, player, element, value, fields)
|
||||||
|
--minetest.chat_send_all("url entered")
|
||||||
|
computers.api.chat_send_player(player, "[computers]: networking not currently supported")
|
||||||
|
|
||||||
return form
|
return form
|
||||||
end,
|
end,
|
||||||
props = {
|
},
|
||||||
border = false,
|
|
||||||
bgimg = "kuto_button.png^[combine:16x16^[noalpha^[colorize:#ffffff70",
|
|
||||||
bgimg_hovered = "kuto_button.png^[combine:16x16^[noalpha^[colorize:#ffffff90",
|
|
||||||
bgimg_middle = "4,4",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,3 +315,7 @@ function computers.gui.add_tab(player, tname, tab)
|
||||||
|
|
||||||
return fs
|
return fs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
minetest.chat_send_all(dump(fields))
|
||||||
|
end) ]]
|
Loading…
Reference in New Issue
Block a user