vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | TITAN_VOLUME_ID = "Volume"; |
2 | TITAN_VOLUME_FRAME_SHOW_TIME = 0.5; |
||
3 | |||
4 | function TitanPanelVolumeButton_OnLoad() |
||
5 | this.registry = { |
||
6 | id = TITAN_VOLUME_ID, |
||
7 | builtIn = 1, |
||
8 | version = TITAN_VERSION, |
||
9 | menuText = TITAN_VOLUME_MENU_TEXT, |
||
10 | tooltipTitle = TITAN_VOLUME_TOOLTIP, |
||
11 | tooltipTextFunction = "TitanPanelVolumeButton_GetTooltipText", |
||
12 | iconWidth = 32, |
||
13 | iconButtonWidth = 18, |
||
14 | }; |
||
15 | end |
||
16 | |||
17 | function TitanPanelVolumeButton_OnShow() |
||
18 | TitanPanelVolume_SetVolumeIcon(); |
||
19 | end |
||
20 | |||
21 | function TitanPanelVolumeButton_OnEnter() |
||
22 | -- Confirm master volume value |
||
23 | TitanPanelVolumeControlSlider:SetValue(1 - GetCVar("MasterVolume")); |
||
24 | TitanPanelVolume_SetVolumeIcon(); |
||
25 | end |
||
26 | |||
27 | function TitanPanelVolumeControlSlider_OnEnter() |
||
28 | this.tooltipText = TitanOptionSlider_TooltipText(TITAN_VOLUME_CONTROL_TOOLTIP, TitanPanelVolume_GetVolumeText(GetCVar("MasterVolume"))); |
||
29 | GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT"); |
||
30 | GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1); |
||
31 | TitanUtils_StopFrameCounting(this:GetParent()); |
||
32 | end |
||
33 | |||
34 | function TitanPanelVolumeControlSlider_OnLeave() |
||
35 | this.tooltipText = nil; |
||
36 | GameTooltip:Hide(); |
||
37 | TitanUtils_StartFrameCounting(this:GetParent(), TITAN_VOLUME_FRAME_SHOW_TIME); |
||
38 | end |
||
39 | |||
40 | function TitanPanelVolumeControlSlider_OnShow() |
||
41 | getglobal(this:GetName().."Text"):SetText(TitanPanelVolume_GetVolumeText(GetCVar("MasterVolume"))); |
||
42 | getglobal(this:GetName().."High"):SetText(TITAN_VOLUME_CONTROL_LOW); |
||
43 | getglobal(this:GetName().."Low"):SetText(TITAN_VOLUME_CONTROL_HIGH); |
||
44 | this:SetMinMaxValues(0, 1); |
||
45 | this:SetValueStep(0.01); |
||
46 | this:SetValue(1 - GetCVar("MasterVolume")); |
||
47 | |||
48 | position = TitanUtils_GetRealPosition(TITAN_VOLUME_ID); |
||
49 | |||
50 | TitanPanelVolumeControlFrame:SetPoint("BOTTOMRIGHT", "TitanPanel" .. TitanUtils_GetWhichBar(TITAN_VOLUME_ID) .."Button", "TOPRIGHT", 0, 0); |
||
51 | if (position == TITAN_PANEL_PLACE_TOP) then |
||
52 | TitanPanelVolumeControlFrame:ClearAllPoints(); |
||
53 | TitanPanelVolumeControlFrame:SetPoint("TOPLEFT", "TitanPanel" .. TitanUtils_GetWhichBar(TITAN_VOLUME_ID) .."Button", "BOTTOMLEFT", UIParent:GetRight() - TitanPanelVolumeControlFrame:GetWidth(), -4); |
||
54 | else |
||
55 | TitanPanelVolumeControlFrame:ClearAllPoints(); |
||
56 | TitanPanelVolumeControlFrame:SetPoint("BOTTOMLEFT", "TitanPanel" .. TitanUtils_GetWhichBar(TITAN_VOLUME_ID) .."Button", "TOPLEFT", UIParent:GetRight() - TitanPanelVolumeControlFrame:GetWidth(), 0); |
||
57 | end |
||
58 | |||
59 | end |
||
60 | |||
61 | function TitanPanelVolumeControlSlider_OnValueChanged() |
||
62 | SetCVar("MasterVolume", 1 - this:GetValue()); |
||
63 | getglobal(this:GetName().."Text"):SetText(TitanPanelVolume_GetVolumeText(GetCVar("MasterVolume"))); |
||
64 | TitanPanelVolume_SetVolumeIcon(); |
||
65 | |||
66 | -- Update GameTooltip |
||
67 | if (this.tooltipText) then |
||
68 | this.tooltipText = TitanOptionSlider_TooltipText(TITAN_VOLUME_CONTROL_TOOLTIP, TitanPanelVolume_GetVolumeText(GetCVar("MasterVolume"))); |
||
69 | GameTooltip:SetText(this.tooltipText, nil, nil, nil, nil, 1); |
||
70 | end |
||
71 | end |
||
72 | |||
73 | function TitanPanelVolume_GetVolumeText(volume) |
||
74 | return tostring(floor(100 * volume + 0.5)) .. "%"; |
||
75 | end |
||
76 | |||
77 | function TitanPanelVolumeControlFrame_OnLoad() |
||
78 | getglobal(this:GetName().."Title"):SetText(TITAN_VOLUME_CONTROL_TITLE); |
||
79 | this:SetBackdropBorderColor(1, 1, 1); |
||
80 | this:SetBackdropColor(0, 0, 0, 1); |
||
81 | end |
||
82 | |||
83 | function TitanPanelVolumeControlFrame_OnUpdate(elapsed) |
||
84 | TitanUtils_CheckFrameCounting(this, elapsed); |
||
85 | end |
||
86 | |||
87 | function TitanPanelVolume_SetVolumeIcon() |
||
88 | local icon = getglobal("TitanPanelVolumeButtonIcon"); |
||
89 | local masterVolume = tonumber(GetCVar("MasterVolume")); |
||
90 | if (masterVolume <= 0) then |
||
91 | icon:SetTexture(TITAN_ARTWORK_PATH.."TitanVolumeMute"); |
||
92 | elseif (masterVolume < 0.33) then |
||
93 | icon:SetTexture(TITAN_ARTWORK_PATH.."TitanVolumeLow"); |
||
94 | elseif (masterVolume < 0.66) then |
||
95 | icon:SetTexture(TITAN_ARTWORK_PATH.."TitanVolumeMedium"); |
||
96 | else |
||
97 | icon:SetTexture(TITAN_ARTWORK_PATH.."TitanVolumeHigh"); |
||
98 | end |
||
99 | end |
||
100 | |||
101 | function TitanPanelVolumeButton_GetTooltipText() |
||
102 | local volumeText = TitanPanelVolume_GetVolumeText(GetCVar("MasterVolume")); |
||
103 | return "".. |
||
104 | TITAN_VOLUME_TOOLTIP_VALUE.."\t"..TitanUtils_GetHighlightText(volumeText).."\n".. |
||
105 | TitanUtils_GetGreenText(TITAN_VOLUME_TOOLTIP_HINT1).."\n".. |
||
106 | TitanUtils_GetGreenText(TITAN_VOLUME_TOOLTIP_HINT2); |
||
107 | end |
||
108 | |||
109 | function TitanPanelRightClickMenu_PrepareVolumeMenu() |
||
110 | TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_VOLUME_ID].menuText); |
||
111 | TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_VOLUME_ID, TITAN_PANEL_MENU_FUNC_HIDE); |
||
112 | end |