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

add the Tracks gui, hotkey friendly #1172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Crystalwarrior
Copy link
Contributor

Support for showing directions, hiding your tracks and hiding other tracks

@Crystalwarrior
Copy link
Contributor Author

for dfhack.keybindings.init I guess it could be
keybinding add Ctrl-U@dungeonmode/Default gui/tracks

end
end

TestOverlay = defclass(TestOverlay, widgets.Window)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably name this (and TestScreen) something other than "Test"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in addition, it's not an overlay. The common pattern is to name the screen FooScreen and the Window Foo. E.g. TracksScreen and Tracks

Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will need a few more rounds of review, but first it needs docs so I know what the intended use case and behavior is

edit: also, please clean up lint and pre-commit.ci warnings

}

--tile=dfhack.screen.findGraphicsTile('INTERFACE_BITS_BUILDING_PLACEMENT', 1, 0)
local pen_direction = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for actual arrows for the cardinal directions, use the arrow characters.

e.g. from trackstop.lua:

local NORTH = 'North '..string.char(24)
local EAST = 'East '..string.char(26)
local SOUTH = 'South '..string.char(25)
local WEST = 'West '..string.char(27)


--tile=dfhack.screen.findGraphicsTile('INTERFACE_BITS_BUILDING_PLACEMENT', 1, 0)
local pen_direction = {
to_pen{ch='v',fg=COLOR_YELLOW,}, -- tile=dfhack.screen.findGraphicsTile('ROLLERS', 8, 2),}, -- 0 South
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lists in Lua are 1-based. If you want to match the value of the direction flag (which appears to be a 0-based enum), assign the indices directly, like:

local pen_direction = {
[df.spoor_flag_dir.north] = to_pen{...},
[df.spoor_flag_dir.south] = ...

end
end

TestOverlay = defclass(TestOverlay, widgets.Window)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in addition, it's not an overlay. The common pattern is to name the screen FooScreen and the Window Foo. E.g. TracksScreen and Tracks

window,
}
onTimer()
repeatUtil.scheduleEvery(timerId, 1, 'ticks', onTimer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest not using repeatUtil here. That makes cleanup messy. Instead, update in your own render method when the tick counter has incremented.

Comment on lines +66 to +67
default_pos={x=20, y=0},
default_enabled=true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two aren't Window attributes and can be removed

Comment on lines +70 to +72
viewscreens= {
'dungeonmode/Default',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can be removed

Comment on lines +84 to +86
self.directional = false
self.show_yours = true
self.show_others = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to copy widget state into your object. you can access the widget state directly. Then you also don't need to have on_change handlers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants