vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 path: /PetFeeder/
3 filename: PetFeeder_UnlikedFoodsFrame.lua
4 author: Jeff Parker <jeff3parker@gmail.com>
5 created: Tue, 22 Jan 2005 14:15:00 -0800
6 updated: Tue, 22 Jan 2005 21:39:00 -0800
7  
8 Pet Feeder: a GUI interface allowing you configure happiness level for your pet &
9 drag/drop foods you wish your pet to eat. When the pet happiness drops below
10 the selected threshold will automatically feed your pet.
11 To remove a food from the list, simply click on it.
12 ]]
13  
14 --[[
15 =============================================================================
16 Called when we want to display a list of foods
17 =============================================================================
18 ]]
19  
20 function PetFeeder_UnlikedFoodsFrame_OnReceiveDrag()
21  
22 PetFeeder_DroptheItem( "any" , PETFEEDER_FL_DISLIKED);
23 PetFeeder_Update_Frames();
24  
25 end
26  
27 --[[
28 =============================================================================
29 Called when we want to display a list of foods
30 =============================================================================
31 ]]
32  
33 function PetFeeder_UnlikedFoodsFrame_Update()
34 PetFeeder_FoodsFrame_UpdateExt( PETFEEDER_FL_DISLIKED );
35 end
36  
37 --[[
38 =============================================================================
39 Called when Clear Foods button is clicked
40 =============================================================================
41 ]]
42 function PetFeeder_UnlikedFoodsFrameClearFoodsButton_Update()
43 PetFeeder_ClearFoods( PETFEEDER_FL_DISLIKED );
44 end
45  
46 --[[
47 =============================================================================
48 Called when the button item is clicked
49 =============================================================================
50 ]]
51 function PetFeeder_UnlikedFoodsFrameItemButton_OnClick(button,name)
52 if ( button == "LeftButton" ) then
53 PetFeeder_AddFood( name , PETFEEDER_FL_APPROVED);
54 PetFeeder_Update_Frames();
55 end
56 end
57  
58 function PetFeeder_UnlikedFoodsFrame_OnShow()
59 PetFeeder_Update_Frames();
60 if ( PeetFeederPlayer_Config.SortOption ) then
61 UIDropDownMenu_SetSelectedID(PetFeeder_UnlikedFoodsFrameSortOptionDropDown, PeetFeederPlayer_Config.SortOption, PETFEEDER_SORTOPTION_DROPDOWN);
62 UIDropDownMenu_SetText(PETFEEDER_SORTOPTION_DROPDOWN[PeetFeederPlayer_Config.SortOption].name, PetFeeder_UnlikedFoodsFrameSortOptionDropDown);
63 end
64 if ( PeetFeederPlayer_Config.SortOption2 ) then
65 UIDropDownMenu_SetSelectedID(PetFeeder_UnlikedFoodsFrameSortOption2DropDown, PeetFeederPlayer_Config.SortOption2, PETFEEDER_SORTOPTION_DROPDOWN);
66 UIDropDownMenu_SetText(PETFEEDER_SORTOPTION_DROPDOWN[PeetFeederPlayer_Config.SortOption2].name, PetFeeder_UnlikedFoodsFrameSortOption2DropDown);
67 end
68 end
69  
70 ------------------
71 -- Sort Option Dropdown
72 ------------------
73  
74 local function PetFeeder_UnlikedFoodsFrameSortOptionDropDown_Initialize()
75 local info;
76 for i = 1, getn(PETFEEDER_SORTOPTION_DROPDOWN), 1 do
77 info = { };
78 info.text = PETFEEDER_SORTOPTION_DROPDOWN[i].name;
79 info.func = PetFeeder_UnlikedFoodsFrameSortOptionDropDownButton_OnClick;
80 UIDropDownMenu_AddButton(info);
81 end
82 end
83 local function PetFeeder_UnlikedFoodsFrameSortOption2DropDown_Initialize()
84 local info;
85 for i = 1, getn(PETFEEDER_SORTOPTION_DROPDOWN), 1 do
86 info = { };
87 info.text = PETFEEDER_SORTOPTION_DROPDOWN[i].name;
88 info.func = PetFeeder_UnlikedFoodsFrameSortOption2DropDownButton_OnClick;
89 UIDropDownMenu_AddButton(info);
90 end
91 end
92  
93 function PetFeeder_UnlikedFoodsFrameSortOptionDropDown_OnLoad()
94 UIDropDownMenu_Initialize(PetFeeder_UnlikedFoodsFrameSortOptionDropDown, PetFeeder_UnlikedFoodsFrameSortOptionDropDown_Initialize);
95 UIDropDownMenu_SetWidth(150);
96 UIDropDownMenu_SetButtonWidth(48);
97 UIDropDownMenu_JustifyText("LEFT", PetFeeder_UnlikedFoodsFrameSortOptionDropDown)
98 end
99  
100 function PetFeeder_UnlikedFoodsFrameSortOptionDropDownButton_OnClick()
101 UIDropDownMenu_SetSelectedID(PetFeeder_UnlikedFoodsFrameSortOptionDropDown, this:GetID());
102 PeetFeederPlayer_Config.SortOption = UIDropDownMenu_GetSelectedID(PetFeeder_UnlikedFoodsFrameSortOptionDropDown);
103 PetFeeder_Update_Frames();
104 end
105  
106 function PetFeeder_UnlikedFoodsFrameSortOption2DropDown_OnLoad()
107 UIDropDownMenu_Initialize(PetFeeder_UnlikedFoodsFrameSortOption2DropDown, PetFeeder_UnlikedFoodsFrameSortOption2DropDown_Initialize);
108 UIDropDownMenu_SetWidth(150);
109 UIDropDownMenu_SetButtonWidth(48);
110 UIDropDownMenu_JustifyText("LEFT", PetFeeder_UnlikedFoodsFrameSortOption2DropDown)
111 end
112  
113 function PetFeeder_UnlikedFoodsFrameSortOption2DropDownButton_OnClick()
114 UIDropDownMenu_SetSelectedID(PetFeeder_UnlikedFoodsFrameSortOption2DropDown, this:GetID());
115 PeetFeederPlayer_Config.SortOption2 = UIDropDownMenu_GetSelectedID(PetFeeder_UnlikedFoodsFrameSortOption2DropDown);
116 PetFeeder_Update_Frames();
117 end