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

make it much harder to accidentally offend the elves #1264

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions caravan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ end
OVERLAY_WIDGETS = {
trade=trade.TradeOverlay,
tradebanner=trade.TradeBannerOverlay,
tradeethics=trade.TradeEthicsWarningOverlay,
tradeagreement=tradeagreement.TradeAgreementOverlay,
movegoods=movegoods.MoveGoodsOverlay,
movegoods_hider=movegoods.MoveGoodsHiderOverlay,
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Template for new versions:
- `embark-anyone`: allows you to embark as any civilisation, including dead, and non-dwarven ones

## New Features
- `caravan`: DFHack dialogs for trade screens (both ``Bring goods to depot`` and the ``Trade`` barter screen) can now filter by item origins (foreign vs. fort-made) and can filter bins by whether they have a mix of ethically acceptable and unacceptable items in them
- `caravan`: If you have managed to select an item that is ethically unacceptable to the merchant, an "Ethics warning" badge will now appear next to the "Trade" button. Clicking on the badge will show you which items that you have selected are problematic. The dialog has a button that you can click to deselect the problematic items in the trade list.
- `confirm`: If you have ethically unacceptable items selected for trade, the "Are you sure you want to trade" confirmation will warn you about them

## Fixes
- `timestream`: ensure child growth events (e.g. becoming an adult) are not skipped over
Expand Down
116 changes: 72 additions & 44 deletions internal/caravan/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ function get_slider_widgets(self, suffix)
key_back='CUSTOM_SHIFT_C',
key='CUSTOM_SHIFT_V',
options={
{label='XXTatteredXX', value=3},
{label='XFrayedX', value=2},
{label='xWornx', value=1},
{label='Pristine', value=0},
{label='XXTatteredXX', value=3, pen=COLOR_BROWN},
{label='XFrayedX', value=2, pen=COLOR_LIGHTRED},
{label='xWornx', value=1, pen=COLOR_YELLOW},
{label='Pristine', value=0, pen=COLOR_GREEN},
},
initial_option=3,
on_change=function(val)
Expand All @@ -132,10 +132,10 @@ function get_slider_widgets(self, suffix)
key_back='CUSTOM_SHIFT_E',
key='CUSTOM_SHIFT_R',
options={
{label='XXTatteredXX', value=3},
{label='XFrayedX', value=2},
{label='xWornx', value=1},
{label='Pristine', value=0},
{label='XXTatteredXX', value=3, pen=COLOR_BROWN},
{label='XFrayedX', value=2, pen=COLOR_LIGHTRED},
{label='xWornx', value=1, pen=COLOR_YELLOW},
{label='Pristine', value=0, pen=COLOR_GREEN},
},
initial_option=0,
on_change=function(val)
Expand All @@ -160,7 +160,7 @@ function get_slider_widgets(self, suffix)
},
},
widgets.Panel{
frame={t=5, l=0, r=0, h=4},
frame={t=6, l=0, r=0, h=4},
subviews={
widgets.CycleHotkeyLabel{
view_id='min_quality'..suffix,
Expand All @@ -170,13 +170,13 @@ function get_slider_widgets(self, suffix)
key_back='CUSTOM_SHIFT_Z',
key='CUSTOM_SHIFT_X',
options={
{label='Ordinary', value=0},
{label='-Well Crafted-', value=1},
{label='+Finely Crafted+', value=2},
{label='*Superior*', value=3},
{label=CH_EXCEPTIONAL..'Exceptional'..CH_EXCEPTIONAL, value=4},
{label=CH_MONEY..'Masterful'..CH_MONEY, value=5},
{label='Artifact', value=6},
{label='Ordinary', value=0, pen=COLOR_GRAY},
{label='-Well Crafted-', value=1, pen=COLOR_LIGHTBLUE},
{label='+Fine Crafted+', value=2, pen=COLOR_BLUE},
{label='*Superior*', value=3, pen=COLOR_YELLOW},
{label=CH_EXCEPTIONAL..'Exceptional'..CH_EXCEPTIONAL, value=4, pen=COLOR_BROWN},
{label=CH_MONEY..'Masterful'..CH_MONEY, value=5, pen=COLOR_MAGENTA},
{label='Artifact', value=6, pen=COLOR_GREEN},
},
initial_option=0,
on_change=function(val)
Expand All @@ -194,13 +194,13 @@ function get_slider_widgets(self, suffix)
key_back='CUSTOM_SHIFT_Q',
key='CUSTOM_SHIFT_W',
options={
{label='Ordinary', value=0},
{label='-Well Crafted-', value=1},
{label='+Finely Crafted+', value=2},
{label='*Superior*', value=3},
{label=CH_EXCEPTIONAL..'Exceptional'..CH_EXCEPTIONAL, value=4},
{label=CH_MONEY..'Masterful'..CH_MONEY, value=5},
{label='Artifact', value=6},
{label='Ordinary', value=0, pen=COLOR_GRAY},
{label='-Well Crafted-', value=1, pen=COLOR_LIGHTBLUE},
{label='+Fine Crafted+', value=2, pen=COLOR_BLUE},
{label='*Superior*', value=3, pen=COLOR_YELLOW},
{label=CH_EXCEPTIONAL..'Exceptional'..CH_EXCEPTIONAL, value=4, pen=COLOR_BROWN},
{label=CH_MONEY..'Masterful'..CH_MONEY, value=5, pen=COLOR_MAGENTA},
{label='Artifact', value=6, pen=COLOR_GREEN},
},
initial_option=6,
on_change=function(val)
Expand All @@ -225,7 +225,7 @@ function get_slider_widgets(self, suffix)
},
},
widgets.Panel{
frame={t=10, l=0, r=0, h=4},
frame={t=12, l=0, r=0, h=4},
subviews={
widgets.CycleHotkeyLabel{
view_id='min_value'..suffix,
Expand All @@ -235,14 +235,14 @@ function get_slider_widgets(self, suffix)
key_back='CUSTOM_SHIFT_B',
key='CUSTOM_SHIFT_N',
options={
{label='1'..CH_MONEY, value={index=1, value=1}},
{label='20'..CH_MONEY, value={index=2, value=20}},
{label='50'..CH_MONEY, value={index=3, value=50}},
{label='100'..CH_MONEY, value={index=4, value=100}},
{label='500'..CH_MONEY, value={index=5, value=500}},
{label='1000'..CH_MONEY, value={index=6, value=1000}},
{label='1'..CH_MONEY, value={index=1, value=1}, pen=COLOR_BROWN},
{label='20'..CH_MONEY, value={index=2, value=20}, pen=COLOR_BROWN},
{label='50'..CH_MONEY, value={index=3, value=50}, pen=COLOR_BROWN},
{label='100'..CH_MONEY, value={index=4, value=100}, pen=COLOR_BROWN},
{label='500'..CH_MONEY, value={index=5, value=500}, pen=COLOR_BROWN},
{label='1000'..CH_MONEY, value={index=6, value=1000}, pen=COLOR_BROWN},
-- max "min" value is less than max "max" value since the range of inf - inf is not useful
{label='5000'..CH_MONEY, value={index=7, value=5000}},
{label='5000'..CH_MONEY, value={index=7, value=5000}, pen=COLOR_BROWN},
},
initial_option=1,
on_change=function(val)
Expand All @@ -260,13 +260,13 @@ function get_slider_widgets(self, suffix)
key_back='CUSTOM_SHIFT_T',
key='CUSTOM_SHIFT_Y',
options={
{label='1'..CH_MONEY, value={index=1, value=1}},
{label='20'..CH_MONEY, value={index=2, value=20}},
{label='50'..CH_MONEY, value={index=3, value=50}},
{label='100'..CH_MONEY, value={index=4, value=100}},
{label='500'..CH_MONEY, value={index=5, value=500}},
{label='1000'..CH_MONEY, value={index=6, value=1000}},
{label='Max', value={index=7, value=math.huge}},
{label='1'..CH_MONEY, value={index=1, value=1}, pen=COLOR_BROWN},
{label='20'..CH_MONEY, value={index=2, value=20}, pen=COLOR_BROWN},
{label='50'..CH_MONEY, value={index=3, value=50}, pen=COLOR_BROWN},
{label='100'..CH_MONEY, value={index=4, value=100}, pen=COLOR_BROWN},
{label='500'..CH_MONEY, value={index=5, value=500}, pen=COLOR_BROWN},
{label='1000'..CH_MONEY, value={index=6, value=1000}, pen=COLOR_BROWN},
{label='Max', value={index=7, value=math.huge}, pen=COLOR_GREEN},
},
initial_option=7,
on_change=function(val)
Expand Down Expand Up @@ -479,10 +479,22 @@ function get_advanced_filter_widgets(self, context)
}
end

function get_info_widgets(self, export_agreements, context)
function get_info_widgets(self, export_agreements, strict_ethical_bins_default, context)
return {
widgets.CycleHotkeyLabel{
view_id='provenance',
frame={t=0, l=0, w=34},
key='CUSTOM_SHIFT_P',
label='Item origins:',
options={
{label='All', value='all', pen=COLOR_GREEN},
{label='Foreign-made only', value='foreign', pen=COLOR_YELLOW},
{label='Fort-made only', value='local', pen=COLOR_BLUE},
},
on_change=function() self:refresh_list() end,
},
widgets.Panel{
frame={t=0, l=0, r=0, h=2},
frame={t=2, l=0, r=0, h=2},
subviews={
widgets.Label{
frame={t=0, l=0},
Expand All @@ -506,7 +518,7 @@ function get_info_widgets(self, export_agreements, context)
key='CUSTOM_SHIFT_A',
options={
{label='Yes', value=true, pen=COLOR_GREEN},
{label='No', value=false}
{label='No', value=false},
},
initial_option=false,
on_change=function() self:refresh_list() end,
Expand All @@ -515,7 +527,7 @@ function get_info_widgets(self, export_agreements, context)
},
},
widgets.Panel{
frame={t=3, l=0, r=0, h=3},
frame={t=5, l=0, r=0, h=4},
subviews={
widgets.Label{
frame={t=0, l=0},
Expand All @@ -530,18 +542,34 @@ function get_info_widgets(self, export_agreements, context)
key='CUSTOM_SHIFT_G',
options={
{label='Show only ethically acceptable items', value='only', pen=COLOR_GREEN},
{label='Ignore ethical restrictions', value='show'},
{label='Ignore ethical restrictions', value='show', pen=COLOR_YELLOW},
{label='Show only ethically unacceptable items', value='hide', pen=COLOR_RED},
},
initial_option='only',
option_gap=0,
visible=self.animal_ethics or self.wood_ethics,
on_change=function() self:refresh_list() end,
},
widgets.ToggleHotkeyLabel{
view_id='strict_ethical_bins',
frame={t=3, l=0},
key='CUSTOM_SHIFT_U',
options={
{label='Include mixed bins', value=false, pen=COLOR_GREEN},
{label='Exclude mixed bins', value=true, pen=COLOR_YELLOW},
},
initial_option=strict_ethical_bins_default,
option_gap=0,
visible=function()
if not self.animal_ethics and not self.wood_ethics then return false end
return self.subviews.ethical:getOptionValue() ~= 'show'
end,
on_change=function() self:refresh_list() end,
},
},
},
widgets.Panel{
frame={t=7, l=0, r=0, h=5},
frame={t=10, l=0, r=0, h=5},
subviews={
widgets.Label{
frame={t=0, l=0},
Expand Down
Loading