1212#include " df/unit.h"
1313#include " df/world.h"
1414#include " df/item_quality.h"
15+ #include " df/caravan_state.h"
1516
1617#include " modules/Gui.h"
1718#include " modules/Items.h"
@@ -53,6 +54,23 @@ static string getQualityName(const df::item_quality quality)
5354 return ENUM_KEY_STR (item_quality, quality);
5455}
5556
57+ static bool can_trade ()
58+ {
59+ if (df::global::ui->caravans .size () == 0 )
60+ return false ;
61+
62+ for (auto it = df::global::ui->caravans .begin (); it != df::global::ui->caravans .end (); it++)
63+ {
64+ auto caravan = *it;
65+ auto trade_state = caravan->trade_state ;
66+ auto time_remaining = caravan->time_remaining ;
67+ if ((trade_state != 1 && trade_state != 2 ) || time_remaining == 0 )
68+ return false ;
69+ }
70+
71+ return true ;
72+ }
73+
5674template <class T >
5775class StockListColumn : public ListColumn <T>
5876{
@@ -64,7 +82,7 @@ class StockListColumn : public ListColumn<T>
6482 OutputString (COLOR_LIGHTBLUE , x, y, " " );
6583
6684 if (item->flags .bits .rotten )
67- OutputString (COLOR_CYAN , x, y, " N " );
85+ OutputString (COLOR_CYAN , x, y, " X " );
6886 else
6987 OutputString (COLOR_LIGHTBLUE , x, y, " " );
7088
@@ -214,7 +232,7 @@ class ViewscreenStocks : public dfhack_viewscreen
214232 hide_flags.bits .in_job = !hide_flags.bits .in_job ;
215233 populateItems ();
216234 }
217- else if (input->count (interface_key::CUSTOM_SHIFT_T ))
235+ else if (input->count (interface_key::CUSTOM_SHIFT_X ))
218236 {
219237 hide_flags.bits .rotten = !hide_flags.bits .rotten ;
220238 populateItems ();
@@ -296,6 +314,14 @@ class ViewscreenStocks : public dfhack_viewscreen
296314 populateItems ();
297315 }
298316 }
317+ else if (input->count (interface_key::CUSTOM_SHIFT_W ))
318+ {
319+ ++min_wear;
320+ if (min_wear > 3 )
321+ min_wear = 0 ;
322+
323+ populateItems ();
324+ }
299325
300326 else if (input->count (interface_key::CUSTOM_SHIFT_Z ))
301327 {
@@ -389,7 +415,7 @@ class ViewscreenStocks : public dfhack_viewscreen
389415 OutputString (COLOR_BROWN , x, y, " Filters" , true , left_margin);
390416 OutputString (COLOR_LIGHTRED , x, y, " Press Shift-Hotkey to Toggle" , true , left_margin);
391417 OutputFilterString (x, y, " In Job" , " J" , !hide_flags.bits .in_job , true , left_margin, COLOR_LIGHTBLUE );
392- OutputFilterString (x, y, " Rotten" , " T " , !hide_flags.bits .rotten , true , left_margin, COLOR_CYAN );
418+ OutputFilterString (x, y, " Rotten" , " X " , !hide_flags.bits .rotten , true , left_margin, COLOR_CYAN );
393419 OutputFilterString (x, y, " Foreign Made" , " G" , !hide_flags.bits .foreign , true , left_margin, COLOR_BROWN );
394420 OutputFilterString (x, y, " Owned" , " O" , !hide_flags.bits .owned , true , left_margin, COLOR_GREEN );
395421 OutputFilterString (x, y, " Forbidden" , " F" , !hide_flags.bits .forbid , true , left_margin, COLOR_RED );
@@ -407,10 +433,10 @@ class ViewscreenStocks : public dfhack_viewscreen
407433 OutputHotkeyString (x, y, " Max Qual: " , " /*" );
408434 OutputString (COLOR_BROWN , x, y, getQualityName (max_quality), true , left_margin);
409435
436+ ++y;
410437 OutputHotkeyString (x, y, " Min Wear: " , " Shift-W" );
411438 OutputString (COLOR_BROWN , x, y, int_to_string (min_wear), true , left_margin);
412-
413-
439+
414440 ++y;
415441 OutputString (COLOR_BROWN , x, y, " Actions (" );
416442 OutputString (COLOR_LIGHTGREEN , x, y, int_to_string (items_column.getDisplayedListSize ()));
@@ -561,10 +587,25 @@ class ViewscreenStocks : public dfhack_viewscreen
561587 auto label = Items::getDescription (item, 0 , false );
562588 if (wear > 0 )
563589 {
564- string wearX = " " ;
565- for ( int i = 0 ; i < wear; i++ )
590+ string wearX;
591+ switch ( wear)
566592 {
567- wearX += " X" ;
593+ case 1 :
594+ wearX = " x" ;
595+ break ;
596+
597+ case 2 :
598+ wearX = " X" ;
599+ break ;
600+
601+ case 3 :
602+ wearX = " xX" ;
603+ break ;
604+
605+ default :
606+ wearX = " XX" ;
607+ break ;
608+
568609 }
569610
570611 label = wearX + label + wearX;
0 commit comments