From 21e2a8ef715954df11acef840665e15c642a0278 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 1 Nov 2024 14:18:10 +0300 Subject: [PATCH 1/3] add problems list to console (WIP) --- res/layouts/console.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/res/layouts/console.xml b/res/layouts/console.xml index bbe869d0..84183f61 100644 --- a/res/layouts/console.xml +++ b/res/layouts/console.xml @@ -19,4 +19,11 @@ onup="on_history_up()" ondown="on_history_down()"> + + + From e51c6bed78df2aef26389ad73a982d556e6532aa Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 1 Nov 2024 15:50:39 +0300 Subject: [PATCH 2/3] add 'core:warning' event --- res/layouts/console.xml | 14 +++++++------- res/layouts/console.xml.lua | 6 ++++++ res/layouts/templates/problem.xml | 6 ++++++ res/scripts/stdmin.lua | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 res/layouts/templates/problem.xml diff --git a/res/layouts/console.xml b/res/layouts/console.xml index 84183f61..3e1b802d 100644 --- a/res/layouts/console.xml +++ b/res/layouts/console.xml @@ -11,6 +11,13 @@ gravity="bottom-left" > + + + - - - diff --git a/res/layouts/console.xml.lua b/res/layouts/console.xml.lua index 597dfcb7..79a82e3f 100644 --- a/res/layouts/console.xml.lua +++ b/res/layouts/console.xml.lua @@ -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) diff --git a/res/layouts/templates/problem.xml b/res/layouts/templates/problem.xml new file mode 100644 index 00000000..0dfb2794 --- /dev/null +++ b/res/layouts/templates/problem.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/res/scripts/stdmin.lua b/res/scripts/stdmin.lua index ec3b1fec..530ec091 100644 --- a/res/scripts/stdmin.lua +++ b/res/scripts/stdmin.lua @@ -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()) From b29b4387892eb24a4eb3d1e9f202d63322be4b0a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 1 Nov 2024 17:20:59 +0300 Subject: [PATCH 3/3] fix --- res/layouts/console.xml.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/res/layouts/console.xml.lua b/res/layouts/console.xml.lua index 79a82e3f..791e1fb2 100644 --- a/res/layouts/console.xml.lua +++ b/res/layouts/console.xml.lua @@ -1,10 +1,12 @@ history = session.get_entry("commands_history") history_pointer = #history +local warning_id = 0 events.on("core:warning", function (wtype, text) document.problemsLog:add(gui.template("problem", { - type="warning", text=wtype..": "..text, id=tostring(math.random()) + type="warning", text=wtype..": "..text, id=tostring(warning_id) })) + warning_id = warning_id + 1 end) function setup_variables()