add 'core:warning' event

This commit is contained in:
MihailRis 2024-11-01 15:50:39 +03:00
parent 9ede50045b
commit e51c6bed78
4 changed files with 20 additions and 7 deletions

View File

@ -11,6 +11,13 @@
gravity="bottom-left"
></textbox>
</container>
<panel id="problemsLog"
color="#00000010"
position-func="gui.get_viewport()[1]-350,0"
size-func="351,gui.get_viewport()[2]-40"
padding="5,15,5,15">
<label>@Problems</label>
</panel>
<textbox id='prompt'
consumer='submit'
margin='0'
@ -19,11 +26,4 @@
onup="on_history_up()"
ondown="on_history_down()">
</textbox>
<panel id="problems-log"
color="#00000010"
position-func="gui.get_viewport()[1]-350,0"
size-func="351,gui.get_viewport()[2]-40"
padding="5,15,5,15">
<label>@Problems</label>
</panel>
</container>

View File

@ -1,6 +1,12 @@
history = session.get_entry("commands_history")
history_pointer = #history
events.on("core:warning", function (wtype, text)
document.problemsLog:add(gui.template("problem", {
type="warning", text=wtype..": "..text, id=tostring(math.random())
}))
end)
function setup_variables()
local pid = hud.get_player()
local x,y,z = player.get_pos(pid)

View File

@ -0,0 +1,6 @@
<container id="%{id}" size="32" tooltip="%{text}">
<image src="gui/%{type}" size="32"/>
<label pos="36,2">%{text}</label>
<image src="gui/cross" interactive="true" size="16" gravity="top-right"
onclick="document['%{id}']:destruct()"></image>
</container>

View File

@ -238,6 +238,7 @@ function on_deprecated_call(name, alternatives)
return
end
__warnings_hidden[name] = true
events.emit("core:warning", "deprecated call", name)
if alternatives then
debug.warning("deprecated function called ("..name.."), use "..
alternatives.." instead\n"..debug.traceback())