@@ -12,6 +12,8 @@ local m_floor = math.floor
1212local m_huge = math.huge
1313local s_format = string.format
1414
15+ local emotionList = {" Ire" , " Guilt" , " Greed" , " Paranoia" , " Envy" , " Disgust" , " Despair" , " Fear" , " Suffering" , " Isolation" }
16+
1517--- @param node table
1618--- @return boolean
1719local function IsAnointableNode (node )
2022
2123--- @class NotableDBControl : ListControl
2224local NotableDBClass = newClass (" NotableDBControl" , " ListControl" , function (self , anchor , rect , itemsTab , db , dbType )
23- self .ListControl (anchor , rect , 16 , " VERTICAL" , false )
25+ local headerHeight = 68
26+ local innerRect = {rect [1 ], rect [2 ]+ headerHeight , rect [3 ], rect [4 ]- headerHeight }
27+ self .ListControl (anchor , innerRect , 16 , " VERTICAL" , false )
2428 self .itemsTab = itemsTab
2529 self .db = db
2630 self .dbType = dbType
@@ -32,15 +36,52 @@ local NotableDBClass = newClass("NotableDBControl", "ListControl", function(self
3236 self .sortDropList = { }
3337 self .sortOrder = { }
3438 self .sortMode = " NAME"
35- self .controls .sort = new (" DropDownControl" , {" BOTTOMLEFT " ,self ," TOPLEFT" }, {0 , - 22 , 360 , 18 }, self .sortDropList , function (index , value )
39+ self .controls .sort = new (" DropDownControl" , {" TOPLEFT " ,self ," TOPLEFT" }, {0 , - headerHeight , 360 , 18 }, self .sortDropList , function (index , value )
3640 self :SetSortMode (value .sortMode )
3741 end )
38- self .controls .search = new (" EditControl" , {" BOTTOMLEFT " ,self , " TOPLEFT " }, {0 , - 2 , 258 , 18 }, " " , " Search" , " %c" , 100 , function ()
42+ self .controls .search = new (" EditControl" , {" TOPLEFT " ,self . controls . sort , " BOTTOMLEFT " }, {0 , 2 , 258 , 18 }, " " , " Search" , " %c" , 100 , function ()
3943 self .listBuildFlag = true
4044 end , nil , nil , true )
4145 self .controls .searchMode = new (" DropDownControl" , {" LEFT" ,self .controls .search ," RIGHT" }, {2 , 0 , 100 , 18 }, { " Anywhere" , " Names" , " Modifiers" }, function (index , value )
4246 self .listBuildFlag = true
4347 end )
48+
49+ -- Create and set up emotion filters.
50+ local function getEmotionImages ()
51+ local tree = main :LoadTree (latestTreeVersion )
52+ local images = {}
53+ for _ , emotionName in ipairs (emotionList ) do
54+ images [emotionName ] = tree :GetAssetByName (emotionName )
55+ end
56+
57+ return images
58+ end
59+ self .emotionImages = getEmotionImages ()
60+
61+ self .controls .emotionLabel = new (" LabelControl" , {" TOPLEFT" , self .controls .search , " BOTTOMLEFT" }, {0 , 6 , 100 , 16 }, " Emotions: " )
62+ self .emotionsAvailable = { }
63+ local function emoCheckOnChange (name )
64+ self .emotionsAvailable [name ] = true
65+ return function (state )
66+ self .emotionsAvailable [name ] = state
67+ self .listBuildFlag = true
68+ end
69+ end
70+ local function emoCheck (name , relTo )
71+ local anchor = {" LEFT" , relTo , " RIGHT" }
72+ local rect = {2 , 0 , 26 , 26 }
73+ local ctl = new (" CheckBoxControl" , anchor , rect , " " , emoCheckOnChange (name ), " Distilled " .. name , true )
74+ if self .emotionImages then ctl :SetCheckImage (self .emotionImages [name ]) end
75+ return ctl
76+ end
77+
78+ local emotionCheckBoxes = {}
79+ for i ,emo in ipairs (emotionList ) do
80+ local emoCtl = emoCheck (emo , emotionCheckBoxes [i - 1 ] or self .controls .emotionLabel )
81+ emotionCheckBoxes [i ] = emoCtl
82+ self .controls [" emotionCheckbox" .. emo ] = emoCtl
83+ end
84+
4485 self :BuildSortOrder ()
4586 self .listBuildFlag = true
4687end )
@@ -52,6 +93,13 @@ function NotableDBClass:DoesNotableMatchFilters(node)
5293 return false
5394 end
5495
96+ -- Exclude notables the player doesn't have the emotions for.
97+ for _ ,emo in ipairs (node .recipe ) do
98+ if not self .emotionsAvailable [emo ] then
99+ return false
100+ end
101+ end
102+
55103 local searchStr = self .controls .search .buf :lower ():gsub (" [%-%.%+%[%]%$%^%%%?%*]" , " %%%0" )
56104 if searchStr :match (" %S" ) then
57105 local found = false
0 commit comments