Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ascii map #137

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions prs-ascii-map.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

asciiMap = asciiMap or {}
asciiMap.mapContainer = asciiMap.mapContainer or Geyser.ScrollBox:new({
x = 0,
y = 0,
width = "100%",
height = "100%",
}, GUI.tabwindow3.AsciiMapcenter)

asciiMap.mapLabel = asciiMap.mapLabel or Geyser.Label:new({
x = 0,
y = 0,
width = "100%",
height = "100%",
}, asciiMap.mapContainer)

MAP_CMD_ID = 1
GETTING_TOO_BIG_NUMBER = 1000000
currentId = 0

function sendMapCommand()
currentId = currentId + 1
if currentId > GETTING_TOO_BIG_NUMBER then
currentId = 1
end
send("gmcp cmd " .. MAP_CMD_ID .. currentId .. " map", false)
end

function mapEventHandler(event, args)
if (gmcp.Char.Output.id ~= MAP_CMD_ID .. currentId) then
return
end

asciiMap.mapLabel:decho("<pre>" .. ansi2decho(gmcp.Char.Output.output) .. "</pre>")
asciiMap.mapLabel:setStyleSheet([[
font-family: Bitstream Vera Sans Mono;
background-color: #111;
font-size: 10px;
]])
asciiMap.mapLabel:enableAutoAdjustSize(true, true)
end

if map_handler_id then
killAnonymousEventHandler(map_handler_id)
end
map_handler_id = registerAnonymousEventHandler("gmcp.Char.Output", mapEventHandler)

if send_command_handler_id then
killAnonymousEventHandler(send_command_handler_id)
end
send_command_handler_id = registerAnonymousEventHandler("gmcp.Char.room", sendMapCommand)

2 changes: 1 addition & 1 deletion prs-gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ GUI.tabwindow3 = GUI.tabwindow3 or Adjustable.TabWindow:new({
inactiveTabFGColor = "#555555",
color1 = "rgb(24,24,28)",
color2 = "rgb(16,16,20)",
tabs = {"Map"}
tabs = {"Map", "AsciiMap"}
}, GUI.right_top)

GUI.tabwindow4 = GUI.tabwindow4 or Adjustable.TabWindow:new({
Expand Down