-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ascii-map): add ascii-map tab (#137)
It works like a charm! I'll be working on adjustable font size, but for now it's working great!
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters