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 ability to request gems by their value #1079

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Hiranus
Copy link
Contributor

@Hiranus Hiranus commented Apr 20, 2024

No description provided.

@myk002
Copy link
Member

myk002 commented Apr 20, 2024

could you update your fork? it appears to be out of date. For the future, it is better practice to create a branch on your fork before submitting a PR. That way you have the ability to work on other things while this PR is still under review.

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.

needs documentation in the Overlays section of docs/caravan.rst

internal/caravan/tradeagreement.lua Outdated Show resolved Hide resolved
internal/caravan/tradeagreement.lua Outdated Show resolved Hide resolved
@Hiranus Hiranus reopened this Apr 24, 2024
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.

Other than a request to uphold the style of the surrounding code, I think this looks great! Thanks!

Comment on lines +8 to 16
TradeAgreementOverlay.ATTRS {
desc = 'Adds select all/none functionality when requesting trade agreement items.',
default_pos = { x = 45, y = -6 },
default_enabled = true,
viewscreens = 'dwarfmode/Diplomacy/Requests',
frame = { w = 40, h = 4 },
frame_style = gui.MEDIUM_FRAME,
frame_background = gui.CLEAR_PEN,
}
Copy link
Member

Choose a reason for hiding this comment

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

Inside of tables, the convention (at least inside of DFHack code) is to have no spaces around the =

self:addviews {
widgets.HotkeyLabel {
frame = { t = 1, l = 0 },
label = 'Select materials with value',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
label = 'Select materials with value',
label = 'Select by value',

return matPrices, matValuesUnique
end

local function ValueSelector()
Copy link
Member

Choose a reason for hiding this comment

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

convention for local functions is snake_case, not PascalCase (which is generally used for class names)

label = 'Select materials with value',
key = 'CUSTOM_CTRL_M',
on_activate = ValueSelector,
visible = function() return GetTab() ~= nil end,
Copy link
Member

Choose a reason for hiding this comment

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

since GetTab (or get_tab, once renamed) is a function, this can just be visible=get_tab

Comment on lines +125 to +126
list[index] = tostring(value.value) ..
" - " .. tostring(value.count) .. " " .. (value.count == 1 and currTab.labelSingular or currTab.labelPlural)
Copy link
Member

Choose a reason for hiding this comment

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

for multi-part strings like this, it is usually cleaner to use a format string:

('%d - %d %s'):format(value.value, value.count,
    value.count == 1 and currTab.labelSingular or currTab.labelPlural)

Copy link
Member

Choose a reason for hiding this comment

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

I'd also suggest adding the "gear" symbol after the value to indicate price. the number-heavy string label also feels a bit user-unfriendly. we might want to post some more screenshots to the #feature-discuss Discord channel to get feedback on that.

labelSingular = labelSingular,
labelPlural = labelPlural,
getCivResourceList = getCivResourceList,
funcGetValue = funcGetValue,
Copy link
Member

Choose a reason for hiding this comment

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

the convention for this type of variable is to name it like get_value_fn

@myk002
Copy link
Member

myk002 commented May 16, 2024

ping

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