summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cwd/assets/altcraft/scripts/ui.lua13
-rw-r--r--cwd/assets/altcraft/ui/hud.rml7
-rw-r--r--src/DebugInfo.cpp3
-rw-r--r--src/DebugInfo.hpp3
-rw-r--r--src/Plugin.cpp24
-rw-r--r--src/RendererWorld.cpp2
-rw-r--r--src/RendererWorld.hpp3
7 files changed, 48 insertions, 7 deletions
diff --git a/cwd/assets/altcraft/scripts/ui.lua b/cwd/assets/altcraft/scripts/ui.lua
index 392ad27..98f0fae 100644
--- a/cwd/assets/altcraft/scripts/ui.lua
+++ b/cwd/assets/altcraft/scripts/ui.lua
@@ -106,13 +106,26 @@ function UpdateUi()
local selection = AC.GetGameState():GetSelectionStatus()
if selection.isBlockSelected then
bid = wrld:GetBlockId(selection.selectedBlock)
+ binfo = AC.GetBlockInfo(bid)
+ light = wrld:GetBlockLight(selection.selectedBlock)
+ skyLight = wrld:GetBlockSkyLight(selection.selectedBlock)
doc:GetElementById('dbg-select-pos').inner_rml = tostring(selection.selectedBlock)
doc:GetElementById('dbg-select-bid').inner_rml = string.format("%d:%d", bid.id, bid.state)
+ doc:GetElementById('dbg-select-name').inner_rml = string.format("%s:%s", binfo.blockstate, binfo.variant)
+ doc:GetElementById('dbg-select-light').inner_rml = string.format("%d:%d", light, skyLight)
else
doc:GetElementById('dbg-select-pos').inner_rml = ""
doc:GetElementById('dbg-select-bid').inner_rml = ""
+ doc:GetElementById('dbg-select-name').inner_rml = ""
+ doc:GetElementById('dbg-select-light').inner_rml = ""
end
+ doc:GetElementById('dbg-sections-loaded').inner_rml = AC.GetDebugValue(0)
+ doc:GetElementById('dbg-sections-renderer').inner_rml = AC.GetDebugValue(1)
+ doc:GetElementById('dbg-sections-ready').inner_rml = AC.GetDebugValue(2)
+ doc:GetElementById('dbg-sections-culled').inner_rml = AC.GetDebugValue(0) - AC.GetDebugValue(5)
+ doc:GetElementById('dbg-rendered-faces').inner_rml = AC.GetDebugValue(4)
+
local player = AC.GetGameState():GetPlayerStatus()
local playerHp = string.format("%.0f", player.health)
doc:GetElementById('status-hp').inner_rml = playerHp
diff --git a/cwd/assets/altcraft/ui/hud.rml b/cwd/assets/altcraft/ui/hud.rml
index cbf5c86..baa408a 100644
--- a/cwd/assets/altcraft/ui/hud.rml
+++ b/cwd/assets/altcraft/ui/hud.rml
@@ -8,8 +8,11 @@
<div class="dbg-hud">
<p>FPS: <span id="dbg-fps">∞?</span></p>
<p>Pos: <span id="dbg-pos">∞?</span></p>
- <p>Select pos: <span id="dbg-select-pos">∞?</span></p>
- <p>Select block: <span id="dbg-select-bid">∞?</span></p>
+ <p>Select: <span id="dbg-select-pos">∞?</span></p>
+ <p>&nbsp;&nbsp; block: <span id="dbg-select-bid">∞?</span> (<span style="color: yellow;" id="dbg-select-name">...?</span>)</p>
+ <p>&nbsp;&nbsp; light: <span id="dbg-select-light">∞?</span></p>
+ <p>Sections: <span id="dbg-sections-loaded">∞?</span> / <span id="dbg-sections-renderer">∞?</span> (<span id="dbg-sections-ready">∞?</span>)</p>
+ <p>&nbsp;&nbsp; rendered: <span id="dbg-sections-culled">∞?</span> (<span id="dbg-rendered-faces">∞?</span> faces)</p>
</div>
<div class="status-hud">
<p>HP: <span id="status-hp">∞?</span> <progress value="15" max="20" id="status-hp-bar" /> </p>
diff --git a/src/DebugInfo.cpp b/src/DebugInfo.cpp
index 89e9425..37d181d 100644
--- a/src/DebugInfo.cpp
+++ b/src/DebugInfo.cpp
@@ -4,4 +4,5 @@ std::atomic_int DebugInfo::totalSections(0);
std::atomic_int DebugInfo::renderSections(0);
std::atomic_int DebugInfo::readyRenderer(0);
std::atomic_int DebugInfo::gameThreadTime(0);
-std::atomic_int DebugInfo::renderFaces(0); \ No newline at end of file
+std::atomic_int DebugInfo::renderFaces(0);
+std::atomic_int DebugInfo::culledSections(0);
diff --git a/src/DebugInfo.hpp b/src/DebugInfo.hpp
index e6aa17c..7ba1686 100644
--- a/src/DebugInfo.hpp
+++ b/src/DebugInfo.hpp
@@ -5,7 +5,8 @@
struct DebugInfo {
static std::atomic_int totalSections;
static std::atomic_int renderSections;
+ static std::atomic_int culledSections;
static std::atomic_int readyRenderer;
static std::atomic_int gameThreadTime;
static std::atomic_int renderFaces;
-}; \ No newline at end of file
+};
diff --git a/src/Plugin.cpp b/src/Plugin.cpp
index ce995fc..f759d5f 100644
--- a/src/Plugin.cpp
+++ b/src/Plugin.cpp
@@ -11,6 +11,7 @@
#include "Event.hpp"
#include "AssetManager.hpp"
#include "Settings.hpp"
+#include "DebugInfo.hpp"
struct Plugin {
@@ -108,6 +109,25 @@ namespace PluginApi {
void SettingsUpdate() {
PUSH_EVENT("SettingsUpdate", 0);
}
+
+ int GetDebugValue(int valId) {
+ switch (valId) {
+ case 0:
+ return DebugInfo::totalSections;
+ case 1:
+ return DebugInfo::renderSections;
+ case 2:
+ return DebugInfo::readyRenderer;
+ case 3:
+ return DebugInfo::gameThreadTime;
+ case 4:
+ return DebugInfo::renderFaces;
+ case 5:
+ return DebugInfo::culledSections;
+ default:
+ return 0;
+ }
+ }
}
int LoadFileRequire(lua_State* L) {
@@ -194,6 +214,8 @@ void PluginSystem::Init() {
"GetEntitiesList", &World::GetEntitiesList,
"GetEntity",&World::GetEntityPtr,
"Raycast", &World::Raycast,
+ "GetBlockLight", sol::resolve<unsigned char(Vector)const>(&World::GetBlockLight),
+ "GetBlockSkyLight", sol::resolve<unsigned char(Vector)const>(&World::GetBlockSkyLight),
"GetBlockId", &World::GetBlockId,
"SetBlockId", &World::SetBlockId);
@@ -268,6 +290,8 @@ void PluginSystem::Init() {
apiSettings["WriteDouble"] = Settings::WriteDouble;
apiTable["SettingsUpdate"] = PluginApi::SettingsUpdate;
apiTable["GetTime"] = GetTime;
+ apiTable["GetBlockInfo"] = GetBlockInfo;
+ apiTable["GetDebugValue"] = PluginApi::GetDebugValue;
}
lua_State* PluginSystem::GetLuaState() {
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index e3ef738..6996762 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -428,7 +428,7 @@ void RendererWorld::Render(RenderState & renderState) {
section.second.Render(renderState);
renderedFaces += section.second.numOfFaces;
}
- this->culledSections = culledSections;
+ DebugInfo::culledSections = culledSections;
DebugInfo::renderFaces = renderedFaces;
glCheckError();
}
diff --git a/src/RendererWorld.hpp b/src/RendererWorld.hpp
index d031179..85cb736 100644
--- a/src/RendererWorld.hpp
+++ b/src/RendererWorld.hpp
@@ -60,5 +60,4 @@ public:
void Update(double timeToUpdate);
- int culledSections = 0;
-}; \ No newline at end of file
+};