From cfb56c9255fbf37a6bb9f0a6758db87320364cf6 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Tue, 29 Jun 2021 16:22:31 +0500 Subject: Added more debug values --- cwd/assets/altcraft/scripts/ui.lua | 13 +++++++++++++ cwd/assets/altcraft/ui/hud.rml | 7 +++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'cwd/assets/altcraft') 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 @@

FPS: ∞?

Pos: ∞?

-

Select pos: ∞?

-

Select block: ∞?

+

Select: ∞?

+

   block: ∞? (...?)

+

   light: ∞?

+

Sections: ∞? / ∞? (∞?)

+

   rendered: ∞? (∞? faces)

HP: ∞?

-- cgit v1.2.3 From 12990cee44efdae378ffbfb4d717ed8a1eafc6dc Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Wed, 30 Jun 2021 18:08:59 +0500 Subject: Added Loading screen --- cwd/assets/altcraft/scripts/init.lua | 1 + cwd/assets/altcraft/ui/loading-styles.rcss | 9 +++++++++ cwd/assets/altcraft/ui/loading.rml | 11 +++++++++++ 3 files changed, 21 insertions(+) create mode 100644 cwd/assets/altcraft/ui/loading-styles.rcss create mode 100644 cwd/assets/altcraft/ui/loading.rml (limited to 'cwd/assets/altcraft') diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua index 790bab0..ffd74b7 100644 --- a/cwd/assets/altcraft/scripts/init.lua +++ b/cwd/assets/altcraft/scripts/init.lua @@ -15,6 +15,7 @@ function plugin.onLoad () con:LoadDocument("altcraft/ui/hud") con:LoadDocument("altcraft/ui/pause") con:LoadDocument("altcraft/ui/options") + con:LoadDocument("altcraft/ui/loading") uiMainMenu:Show() AC.Settings.Load() 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 @@ + + + + + Loading + + + + Loading + + -- cgit v1.2.3 From 48e564a32c266c8d4649c6f50bf4eac56f771c0d Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Fri, 2 Jul 2021 12:26:39 +0500 Subject: Added Respawn screen --- cwd/assets/altcraft/scripts/init.lua | 1 + cwd/assets/altcraft/ui/respawn-styles.rcss | 24 ++++++++++++++++++++++++ cwd/assets/altcraft/ui/respawn.rml | 12 ++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 cwd/assets/altcraft/ui/respawn-styles.rcss create mode 100644 cwd/assets/altcraft/ui/respawn.rml (limited to 'cwd/assets/altcraft') diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua index ffd74b7..e13fc81 100644 --- a/cwd/assets/altcraft/scripts/init.lua +++ b/cwd/assets/altcraft/scripts/init.lua @@ -16,6 +16,7 @@ function plugin.onLoad () con:LoadDocument("altcraft/ui/pause") con:LoadDocument("altcraft/ui/options") con:LoadDocument("altcraft/ui/loading") + con:LoadDocument("altcraft/ui/respawn") uiMainMenu:Show() AC.Settings.Load() 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 @@ + + + + + NeedRespawn + + + You died! + + + + -- cgit v1.2.3 From b37e52c9facd4c41183c016fd5c91f8829407766 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 4 Jul 2021 17:21:50 +0500 Subject: Added basic Chat --- cwd/assets/altcraft/scripts/init.lua | 34 +++++++++++++++++- cwd/assets/altcraft/scripts/ui.lua | 17 +++++++++ cwd/assets/altcraft/ui/chat-styles.rcss | 62 +++++++++++++++++++++++++++++++++ cwd/assets/altcraft/ui/chat.rml | 16 +++++++++ 4 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 cwd/assets/altcraft/ui/chat-styles.rcss create mode 100644 cwd/assets/altcraft/ui/chat.rml (limited to 'cwd/assets/altcraft') diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua index e13fc81..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 () @@ -17,6 +18,7 @@ function plugin.onLoad () 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() @@ -72,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,'&','&') + msg = string.gsub(msg,'<','<') + msg = string.gsub(msg,'>','>') + msg = string.gsub(msg,'""','"') + msg = string.gsub(msg,"''",''') + + 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('

%s

', 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 98f0fae..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() 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 @@ + + + + + + Chat + + +
+
+ + +
-- cgit v1.2.3