summaryrefslogtreecommitdiffstats
path: root/cwd/assets
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2021-07-04 14:47:44 +0200
committerGitHub <noreply@github.com>2021-07-04 14:47:44 +0200
commit8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a (patch)
tree1e9510a1c2ff7f6c0eaaba211c38e0a855b36ca9 /cwd/assets
parentMerge pull request #64 from LaG1924/ftr/render-optimization (diff)
parentAdded screenshot-mode (diff)
downloadAltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.gz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.bz2
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.lz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.xz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.zst
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.zip
Diffstat (limited to 'cwd/assets')
-rw-r--r--cwd/assets/altcraft/scripts/init.lua36
-rw-r--r--cwd/assets/altcraft/scripts/ui.lua30
-rw-r--r--cwd/assets/altcraft/ui/chat-styles.rcss62
-rw-r--r--cwd/assets/altcraft/ui/chat.rml16
-rw-r--r--cwd/assets/altcraft/ui/hud.rml7
-rw-r--r--cwd/assets/altcraft/ui/loading-styles.rcss9
-rw-r--r--cwd/assets/altcraft/ui/loading.rml11
-rw-r--r--cwd/assets/altcraft/ui/respawn-styles.rcss24
-rw-r--r--cwd/assets/altcraft/ui/respawn.rml12
9 files changed, 204 insertions, 3 deletions
diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua
index 790bab0..b60a988 100644
--- a/cwd/assets/altcraft/scripts/init.lua
+++ b/cwd/assets/altcraft/scripts/init.lua
@@ -6,6 +6,7 @@ local plugin = {
onChangeState = nil,
onTick = nil,
onRequestBlockInfo = nil,
+ onChatMessage = nil,
}
function plugin.onLoad ()
@@ -15,6 +16,9 @@ function plugin.onLoad ()
con:LoadDocument("altcraft/ui/hud")
con:LoadDocument("altcraft/ui/pause")
con:LoadDocument("altcraft/ui/options")
+ con:LoadDocument("altcraft/ui/loading")
+ con:LoadDocument("altcraft/ui/respawn")
+ con:LoadDocument("altcraft/ui/chat")
uiMainMenu:Show()
AC.Settings.Load()
@@ -70,9 +74,39 @@ function plugin.onRequestBlockInfo(blockPos)
return blocks.GetBlockInfo(blockPos)
end
+function plugin.onChatMessage(chat, pos)
+ local chatDoc = {}
+ for i,d in ipairs(rmlui.contexts["default"].documents) do
+ if d.title == "Chat" then
+ chatDoc = d
+ end
+ end
+
+ local msg = chat:ToPlainText()
+ msg = string.gsub(msg,'&','&amp;')
+ msg = string.gsub(msg,'<','&lt;')
+ msg = string.gsub(msg,'>','&gt;')
+ msg = string.gsub(msg,'""','&quot;')
+ msg = string.gsub(msg,"''",'&apos;')
+
+ local color = ""
+ if pos == 0 then
+ color = ""
+ elseif pos == 1 then
+ color = 'style="color: #BBBBBB"'
+ elseif pos == 2 then
+ color = 'style="color: maroon"'
+ else
+ color = 'style="color: navy"'
+ end
+
+ chatDoc:GetElementById('chat').inner_rml = chatDoc:GetElementById('chat').inner_rml .. string.format('<p class="chat-msg" %s>%s</p>', color, msg)
+ MoveChatToBottom = true
+end
+
AC.RegisterDimension(0, Dimension.new("overworld", true))
AC.RegisterDimension(-1, Dimension.new("the_nether", false))
AC.RegisterDimension(1, Dimension.new("the_end", false))
AC.RegisterPlugin(plugin)
-plugin = nil \ No newline at end of file
+plugin = nil
diff --git a/cwd/assets/altcraft/scripts/ui.lua b/cwd/assets/altcraft/scripts/ui.lua
index 392ad27..b938737 100644
--- a/cwd/assets/altcraft/scripts/ui.lua
+++ b/cwd/assets/altcraft/scripts/ui.lua
@@ -53,6 +53,16 @@ function ConnectToServer(doc)
doc:GetElementById('username'):GetAttribute('value'))
end
+function SendChatMessage(doc)
+ local msg = doc:GetElementById("chat-input"):GetAttribute("value")
+ if msg == nil then
+ return
+ end
+ doc:GetElementById("chat-input"):SetAttribute("value", "")
+
+ AC.SendChatMessage(msg)
+end
+
function OptionsDefaultHandler(event)
local input = event.current_element.previous_sibling
local id = input:GetAttribute("id")
@@ -85,14 +95,21 @@ end
function UpdateUi()
local doc = {}
local uiDoc = {}
+ local chatDoc = {}
for i,d in ipairs(rmlui.contexts["default"].documents) do
if d.title == "Playing" then
doc = d
elseif d.title == "Options" then
uiDoc = d
+ elseif d.title == "Chat" then
+ chatDoc = d
end
end
+ if MoveChatToBottom ~= nil and MoveChatToBottom == true then
+ chatDoc:GetElementById('chat').scroll_top = chatDoc:GetElementById('chat').scroll_height
+ end
+
if AC.GetGameState() and AC.GetGameState():GetPlayer() and AC.GetGameState():GetTimeStatus().worldAge > 0 then
local time = AC.GetTime()
local rawFps = 1.0 / time:GetRealDeltaS()
@@ -106,13 +123,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/chat-styles.rcss b/cwd/assets/altcraft/ui/chat-styles.rcss
new file mode 100644
index 0000000..91f5b81
--- /dev/null
+++ b/cwd/assets/altcraft/ui/chat-styles.rcss
@@ -0,0 +1,62 @@
+#body-chat {
+
+}
+
+p {
+ display: block;
+}
+
+scrollbarvertical {
+ background-color: #2c2c2c55;
+ width: 3vh;
+ left: 0;
+}
+
+scrollbarvertical sliderbar {
+ height: 10vh;
+ background-color: #9c9c9c55;
+}
+
+scrollbarvertical sliderbar:active {
+ background-color: #cfd69d;
+}
+
+scrollbarvertical sliderarrowdec {
+ display: none;
+}
+
+scrollbarvertical sliderarrowinc {
+ display: none;
+}
+
+#chat {
+ background-color: #00000055;
+ width: 80%;
+ height: 70%;
+ position: fixed;
+ bottom: 10%;
+ left: 0;
+ text-align: left;
+ overflow-y: auto;
+}
+
+.chat-msg {
+ font-size: 5vh;
+ bottom: 0%;
+}
+
+#chat-input {
+ width: 90%;
+}
+
+#chat-send {
+ margin: 0.25%;
+}
+
+#chat-footer {
+ position: fixed;
+ display: block;
+ bottom: 0;
+ width: 100%;
+ left: 0;
+}
diff --git a/cwd/assets/altcraft/ui/chat.rml b/cwd/assets/altcraft/ui/chat.rml
new file mode 100644
index 0000000..8634450
--- /dev/null
+++ b/cwd/assets/altcraft/ui/chat.rml
@@ -0,0 +1,16 @@
+<rml>
+ <head>
+ <link type="text/rcss" href="mc-styles" />
+ <link type="text/rcss" href="chat-styles" />
+ <script src="/altcraft/scripts/ui"></script>
+ <title>Chat</title>
+ </head>
+ <body class="body-chat">
+ <div id="chat">
+ </div>
+ <div id="chat-footer">
+ <input type="text" id="chat-input" class="mc-text" onkeydown="if event.parameters.key_identifier == 72 then SendChatMessage(document) end" />
+ <button id="chat-send" class="mc-button" onclick="SendChatMessage(document)">Send</button>
+ </div>
+ </body>
+</rml>
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/cwd/assets/altcraft/ui/loading-styles.rcss b/cwd/assets/altcraft/ui/loading-styles.rcss
new file mode 100644
index 0000000..b376fe8
--- /dev/null
+++ b/cwd/assets/altcraft/ui/loading-styles.rcss
@@ -0,0 +1,9 @@
+#body-loading {
+ background-color: #160f08;
+ color: white;
+}
+
+#loading {
+ font-size: 20vh;
+ margin: 30% auto auto;
+}
diff --git a/cwd/assets/altcraft/ui/loading.rml b/cwd/assets/altcraft/ui/loading.rml
new file mode 100644
index 0000000..2d84c37
--- /dev/null
+++ b/cwd/assets/altcraft/ui/loading.rml
@@ -0,0 +1,11 @@
+<rml>
+ <head>
+ <link type="text/rcss" href="mc-styles" />
+ <link type="text/rcss" href="loading-styles" />
+ <title>Loading</title>
+ <script src="/altcraft/scripts/ui"></script>
+ </head>
+ <body id="body-loading">
+ <strong class="mc-title" id="loading">Loading</strong>
+ </body>
+</rml>
diff --git a/cwd/assets/altcraft/ui/respawn-styles.rcss b/cwd/assets/altcraft/ui/respawn-styles.rcss
new file mode 100644
index 0000000..c6bbd7a
--- /dev/null
+++ b/cwd/assets/altcraft/ui/respawn-styles.rcss
@@ -0,0 +1,24 @@
+.body-respawn {
+ background-color: #800000AA;
+}
+
+#died {
+ font-size: 10vh;
+ margin: 30% auto auto;
+}
+
+#respawn {
+ display: inline-block;
+ width: 45%;
+ height: 8%;
+ position: fixed;
+ margin: 10% auto auto;
+}
+
+#disconnect {
+ display: inline-block;
+ width: 45%;
+ height: 8%;
+ position: fixed;
+ margin: 20% auto auto;
+}
diff --git a/cwd/assets/altcraft/ui/respawn.rml b/cwd/assets/altcraft/ui/respawn.rml
new file mode 100644
index 0000000..093a169
--- /dev/null
+++ b/cwd/assets/altcraft/ui/respawn.rml
@@ -0,0 +1,12 @@
+<rml>
+ <head>
+ <link type="text/rcss" href="mc-styles" />
+ <link type="text/rcss" href="respawn-styles" />
+ <title>NeedRespawn</title>
+ </head>
+ <body class="body-respawn">
+ <strong class="mc-title" id="died">You died!</strong>
+ <button class="mc-button" onclick="AC.GetGameState():PerformRespawn()" id="respawn">Respawn</button>
+ <button class="mc-button" onclick="AC.Disconnect()" id="disconnect">Title screen</button>
+ </body>
+</rml>