Skip to content

Commit

Permalink
feat(ascii-map): add ascii-map tab (#137)
Browse files Browse the repository at this point in the history
It works like a charm! I'll be working on adjustable font size, but for now it's working great!
  • Loading branch information
grrtt49 committed Aug 17, 2023
1 parent 2298fe4 commit c7f11ce
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
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

0 comments on commit c7f11ce

Please sign in to comment.