|
3 | 3 | local gui = require('gui') |
4 | 4 | local utils = require('utils') |
5 | 5 | local widgets = require('gui.widgets') |
| 6 | +local overlay = require('plugins.overlay') |
| 7 | + |
| 8 | +local toolbar_textures = dfhack.textures.loadTileset('hack/data/art/sitemap_toolbar.png', 8, 12) |
| 9 | + |
| 10 | +function launch_sitemap() |
| 11 | + dfhack.run_script('gui/sitemap') |
| 12 | +end |
6 | 13 |
|
7 | 14 | -- |
8 | 15 | -- Sitemap |
@@ -353,6 +360,87 @@ function SitemapScreen:onDismiss() |
353 | 360 | view = nil |
354 | 361 | end |
355 | 362 |
|
| 363 | + |
| 364 | +-- -------------------------------- |
| 365 | +-- SitemapToolbarOverlay |
| 366 | +-- |
| 367 | + |
| 368 | +SitemapToolbarOverlay = defclass(SitemapToolbarOverlay, overlay.OverlayWidget) |
| 369 | +SitemapToolbarOverlay.ATTRS{ |
| 370 | + desc='Adds a button to the toolbar at the bottom left corner of the screen for launching gui/sitemap.', |
| 371 | + default_pos={x=35, y=-1}, |
| 372 | + default_enabled=true, |
| 373 | + viewscreens='dwarfmode', |
| 374 | + frame={w=28, h=9}, |
| 375 | +} |
| 376 | + |
| 377 | +function SitemapToolbarOverlay:init() |
| 378 | + local button_chars = { |
| 379 | + {218, 196, 196, 191}, |
| 380 | + {179, '-', 'O', 179}, |
| 381 | + {192, 196, 196, 217}, |
| 382 | + } |
| 383 | + |
| 384 | + self:addviews{ |
| 385 | + widgets.Panel{ |
| 386 | + frame={t=0, l=0, w=26, h=5}, |
| 387 | + frame_style=gui.FRAME_PANEL, |
| 388 | + frame_background=gui.CLEAR_PEN, |
| 389 | + frame_inset={l=1, r=1}, |
| 390 | + visible=function() return self.subviews.icon:getMousePos() end, |
| 391 | + subviews={ |
| 392 | + widgets.Label{ |
| 393 | + text={ |
| 394 | + 'Open the general search', NEWLINE, |
| 395 | + 'interface.', NEWLINE, |
| 396 | + NEWLINE, |
| 397 | + {text='Hotkey: ', pen=COLOR_GRAY}, {key='CUSTOM_CTRL_G'}, |
| 398 | + }, |
| 399 | + }, |
| 400 | + }, |
| 401 | + }, |
| 402 | + widgets.Panel{ |
| 403 | + view_id='icon', |
| 404 | + frame={b=0, l=0, w=4, h=3}, |
| 405 | + subviews={ |
| 406 | + widgets.Label{ |
| 407 | + text=widgets.makeButtonLabelText{ |
| 408 | + chars=button_chars, |
| 409 | + pens=COLOR_GRAY, |
| 410 | + tileset=toolbar_textures, |
| 411 | + tileset_offset=1, |
| 412 | + tileset_stride=8, |
| 413 | + }, |
| 414 | + on_click=launch_sitemap, |
| 415 | + visible=function () return not self.subviews.icon:getMousePos() end, |
| 416 | + }, |
| 417 | + widgets.Label{ |
| 418 | + text=widgets.makeButtonLabelText{ |
| 419 | + chars=button_chars, |
| 420 | + pens={ |
| 421 | + {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, |
| 422 | + {COLOR_WHITE, COLOR_GRAY, COLOR_GRAY, COLOR_WHITE}, |
| 423 | + {COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE}, |
| 424 | + }, |
| 425 | + tileset=toolbar_textures, |
| 426 | + tileset_offset=5, |
| 427 | + tileset_stride=8, |
| 428 | + }, |
| 429 | + on_click=launch_sitemap, |
| 430 | + visible=function() return not not self.subviews.icon:getMousePos() end, |
| 431 | + }, |
| 432 | + }, |
| 433 | + }, |
| 434 | + } |
| 435 | +end |
| 436 | + |
| 437 | +function SitemapToolbarOverlay:onInput(keys) |
| 438 | + return SitemapToolbarOverlay.super.onInput(self, keys) |
| 439 | +end |
| 440 | + |
| 441 | +OVERLAY_WIDGETS = {toolbar=SitemapToolbarOverlay} |
| 442 | + |
| 443 | + |
356 | 444 | if dfhack_flags.module then |
357 | 445 | return |
358 | 446 | end |
|
0 commit comments