/trunk
local mainWindow = TortaParentFrame; |
-- ==================================================================== |
-- UIManager.lua |
-- Contains functions used for operations that impact what the user |
-- sees. |
-- ==================================================================== |
-- Windows |
local mainWindow = TortaParentFrame; |
local startPage = TortaParentFrameStartPage; |
local mainPage = TortaParentFrameMainPage; |
local explorerWindow = TortaParentFrameMainPageExplorerSubWindow; |
local clDisplayWindow = TortaParentFrameMainPageCLDisplaySubWindow; |
local nbDisplayWindow = TortaParentFrameMainPageNBDisplaySubWindow; |
-- Misc. Widgets |
local explorerScrollBar = TortaParentFrameMainPageExplorerSubWindowScrollBar; |
local clDisplayWindow = TortaParentFrameMainPageDisplaySubWindow; |
local clScrollBar = TortaParentFrameMainPageDisplaySubWindowScrollBar; |
local noLoadedListText = TortaParentFrameMainPageDisplaySubWindowNoLoadedListText; |
local noTasksText = TortaParentFrameMainPageDisplaySubWindowNoTasksText; |
local clTopButton = TortaParentFrameMainPageDisplaySubWindowTaskButton1; |
local cl3HeaderText = TortaParentFrameMainPageDisplaySubWindowHeaderText; |
local clScrollBar = TortaParentFrameMainPageCLDisplaySubWindowScrollBar; |
local noLoadedListText = TortaParentFrameMainPageCLDisplaySubWindowNoLoadedListText; |
local noTasksText = TortaParentFrameMainPageCLDisplaySubWindowNoTasksText; |
local clTopButton = TortaParentFrameMainPageCLDisplaySubWindowTaskButton1; |
local cl3HeaderText = TortaParentFrameMainPageCLDisplaySubWindowHeaderText; |
local taskEditor = TortaParentFrameMainPageTaskEditorSubWindow; |
local taskBar = TortaParentFrameMainPageTaskbar; |
local clTaskBar = TortaParentFrameMainPageCLTaskbar; |
local nbTaskBar = TortaParentFrameMainPageNBTaskbar; |
local editTaskEB = TortaParentFrameMainPageTaskEditorSubWindowScrollFrameEditBox; |
local uncheckAllButton = TortaParentFrameMainPageTaskbarUncheckAllButton; |
local checkAllButton = TortaParentFrameMainPageTaskbarCheckAllButton; |
local addTaskButton = TortaParentFrameMainPageTaskbarAddTaskButton; |
local removeTaskButton = TortaParentFrameMainPageTaskbarRemoveTaskButton; |
local uncheckAllButton = TortaParentFrameMainPageCLTaskbarUncheckAllButton; |
local checkAllButton = TortaParentFrameMainPageCLTaskbarCheckAllButton; |
local addTaskButton = TortaParentFrameMainPageCLTaskbarAddTaskButton; |
local removeTaskButton = TortaParentFrameMainPageCLTaskbarRemoveTaskButton; |
local explorerNoListsText = TortaParentFrameMainPageExplorerSubWindowNoListsText; |
local statsButton = TortaParentFrameMainPageTaskbarStatsButton; |
local explorerNoNtbksText = TortaParentFrameMainPageExplorerSubWindowNoNotebooksText; |
local statsButton = TortaParentFrameMainPageCLTaskbarStatsButton; |
local EXPLORER_LISTBUTTON_HEIGHT = 16; |
local Torta = Torta; |
noLoadedListText:SetText("|cffffd000Torta Checklist has no list loaded.|r\nYou currently do not have a list loaded. You can either select a list in Turtle Explorer or create a new one by right-clicking inside Turtle Explorer."); |
noLoadedListText:SetText("|cffffd000No loaded list. I feel ignored. /cry|r\nYou currently do not have a list loaded. You can either select a list in Turtle Explorer or create a new one by right-clicking inside Turtle Explorer."); |
noTasksText:SetText("|cffffd000Woah, no tasks!|r\nThe currently loaded list does not appear to have any tasks in it. You can create new tasks for this list by clicking the \"Add A Task\" button below."); |
Torta.gui.exListButtons = { TortaParentFrameMainPageExplorerSubWindowListButton1 }; |
-- Checklist subwindow stuff |
Torta.gui.clRecycleBin = {}; |
Torta.gui.clListButtons = { TortaParentFrameMainPageDisplaySubWindowTaskButton1 }; |
Torta.gui.clListButtons = { TortaParentFrameMainPageCLDisplaySubWindowTaskButton1 }; |
---------------------------------------------------------------------------------------- |
Torta.gui.elements = {}; |
e.clTopButton = clTopButton; |
e.cl3HeaderText = cl3HeaderText; |
e.taskEditor = taskEditor; |
e.taskBar = taskBar; |
e.clTaskBar = clTaskBar; |
e.nbTaskBar = nbTaskBar; |
e.editTaskEB = editTaskEB; |
e.uncheckAllButton = uncheckAllButton; |
e.checkAllButton = checkAllButton; |
e.addTaskButton = addTaskButton; |
e.removeTaskButton = removeTaskButton; |
e.explorerNoListsText = explorerNoListsText; |
e.explorerNoNtbksText = explorerNoNtbksText |
e.statsButton = statsButton; |
e = nil; |
---------------------------------------------------------------------------------------- |
frame:Hide(); |
end |
local FADETIME = 0.2 |
local FADETIME = 0.25; |
function Torta.gui:ToggleWindow(window) |
window = window or mainWindow; |
if self:IsFrameScaling(window) or UIFrameIsFading(window) then |
startPage:Show(); |
mainPage:Hide(); |
else |
self.tab = tabID; |
startPage:Hide(); |
mainPage:Show(); |
if tabID == 2 then |
clDisplayWindow:Show(); |
clTaskBar:Show(); |
nbDisplayWindow:Hide(); |
nbTaskBar:Hide(); |
else |
clDisplayWindow:Hide(); |
clTaskBar:Hide(); |
nbDisplayWindow:Show(); |
nbTaskBar:Show(); |
end |
self:UpdateExplorerScrollBar(); |
end |
end |
local lineplusoffset; |
local button; |
explorerNoListsText:Hide(); |
if #Torta.db.profile.lists > 0 then |
local lists = Torta.db.profile.lists; |
FauxScrollFrame_Update(explorerScrollBar, #Torta.db.profile.lists, #self.exListButtons, 16, nil, nil, nil, nil, nil, nil, true) |
local loadedListID = Torta.db.profile.cfg.loadedList; |
for line = 1, #self.exListButtons do |
lineplusoffset = line + FauxScrollFrame_GetOffset(explorerScrollBar); |
button = self.exListButtons[line]; |
if lineplusoffset <= #Torta.db.profile.lists then |
if not lists[lineplusoffset] then return end |
button:SetText(lists[lineplusoffset].meta.listName); |
button:SetID(lineplusoffset); |
if lineplusoffset ~= loadedListID then |
button:UnlockHighlight(); |
explorerNoNtbksText:Hide(); |
if self.tab == 2 then -- if Torta Checklist is selected |
if #Torta.db.profile.lists > 0 then |
local lists = Torta.db.profile.lists; |
FauxScrollFrame_Update(explorerScrollBar, #Torta.db.profile.lists, #self.exListButtons, 16, nil, nil, nil, nil, nil, nil, true) |
local loadedListID = Torta.db.profile.cfg.loadedList; |
for line = 1, #self.exListButtons do |
lineplusoffset = line + FauxScrollFrame_GetOffset(explorerScrollBar); |
button = self.exListButtons[line]; |
if lineplusoffset <= #Torta.db.profile.lists then |
if not lists[lineplusoffset] then return end |
button.text:SetText(lists[lineplusoffset].meta.listName); |
button:SetID(lineplusoffset); |
if lineplusoffset ~= loadedListID then |
button:UnlockHighlight(); |
else |
button:LockHighlight(); |
end |
button:Show(); |
else |
button:LockHighlight(); |
button:Hide(); |
end |
button:Show(); |
else |
button:Hide(); |
end |
else |
explorerScrollBar:Hide(); |
explorerNoListsText:Show(); |
for i = 1, #self.exListButtons do |
self.exListButtons[i]:Hide(); |
end |
end |
else |
explorerScrollBar:Hide(); |
explorerNoListsText:Show(); |
for i = 1, #self.exListButtons do |
self.exListButtons[i]:Hide(); |
else -- if Torta Notebook is selected |
if #Torta.db.profile.notes > 0 then |
local notes = Torta.db.profile.notes; |
FauxScrollFrame_Update(explorerScrollBar, #Torta.db.profile.notes, #self.exListButtons, 16, nil, nil, nil, nil, nil, nil, true) |
local loadedListID = Torta.db.profile.cfg.loadedList; |
for line = 1, #self.exListButtons do |
lineplusoffset = line + FauxScrollFrame_GetOffset(explorerScrollBar); |
button = self.exListButtons[line]; |
if lineplusoffset <= #Torta.db.profile.notes then |
if not notes[lineplusoffset] then return end |
button:SetText(notes[lineplusoffset].meta.name); |
button:SetID(lineplusoffset); |
if lineplusoffset ~= loadedListID then |
button:UnlockHighlight(); |
else |
button:LockHighlight(); |
end |
button:Show(); |
else |
button:Hide(); |
end |
end |
else |
explorerScrollBar:Hide(); |
explorerNoNtbksText:Show(); |
for i = 1, #self.exListButtons do |
self.exListButtons[i]:Hide(); |
end |
end |
end |
end |
noTasksText:Hide(); |
noLoadedListText:Hide(); |
if self.data then |
clDisplayWindow:Show(); |
nbDisplayWindow:Hide(); |
if self.listData then |
noLoadedListText:Hide(); |
cl3HeaderText:SetText(self.data.meta.listName); |
FauxScrollFrame_Update(clScrollBar, #self.data.text, #self.clListButtons, 32, nil, nil, nil, nil, nil, nil, true) |
cl3HeaderText:SetText(self.listData.meta.listName); |
FauxScrollFrame_Update(clScrollBar, #self.listData.text, #self.clListButtons, 32, nil, nil, nil, nil, nil, nil, true) |
if not isFromOnShow then |
clScrollBar:Show(); |
end |
for line = 1, #self.clListButtons do |
lineplusoffset = line + FauxScrollFrame_GetOffset(clScrollBar); |
button = self.clListButtons[line]; |
if lineplusoffset <= #self.data.text then |
button.text:SetFormattedText("|cffffd000%i.)|r %s", lineplusoffset, self.data.text[lineplusoffset]); |
button.check:SetChecked(self.data.stat[lineplusoffset]); |
if lineplusoffset <= #self.listData.text then |
button.text:SetFormattedText("|cffffd000%i.)|r %s", lineplusoffset, self.listData.text[lineplusoffset]); |
button.check:SetChecked(self.listData.stat[lineplusoffset]); |
button:SetID(lineplusoffset); |
button.check:SetID(lineplusoffset); |
button:SetID(lineplusoffset); |
button:Hide(); |
end |
end |
if #self.data.text == 0 then |
if #self.listData.text == 0 then |
noTasksText:Show(); |
clScrollBar:Hide() |
else |
end |
FauxScrollFrame_SetOffset(clScrollBar, offset); |
FauxScrollFrame_Update(clScrollBar, #self.data.text, #self.clListButtons, 32, nil, nil, nil, nil, nil, nil, true) |
FauxScrollFrame_Update(clScrollBar, #self:GetLoadedList().text, #self.clListButtons, 32, nil, nil, nil, nil, nil, nil, true) |
self:CheckCLButtons(); |
self:UpdateCLScrollBar(); |
offset = offset + 1 |
-- ==================================================================== |
local clExplorerDropdownInfo = { |
{ |
text = "Turtle Explorer", |
text = "Tortoise Explorer", |
isTitle = true |
}, |
{ |
func = function() Torta.cl3:CreateList(); end |
}, |
{ |
text = "Profiles... (NYI)", |
func = function() end |
}, |
{ |
text = "", |
notClickable = true |
}, |
isTitle = true |
}, |
{ |
text = "Create a new list", |
func = function() Torta.cl3:CreateList(); end, |
}, |
{ |
text = "Rename this list", |
func = function() Torta.cl3:RenameList(Torta.gui.selectedExplorerButton:GetID()); end |
}, |
notClickable = true |
}, |
{ |
text = "Create a new list", |
func = function() Torta.cl3:CreateList(); end, |
}, |
{ |
text = "Profiles... (NYI)", |
func = function() end |
}, |
{ |
text = "", |
notClickable = true |
}, |
{ |
text = "Close", |
func = function() TortaDropDownMenuFrame:Hide(); end |
} |
function Torta.gui:clShowButtonDropdown(button) |
assert(button); |
self.selectedExplorerButton = button; |
clListDropdownInfo[1].text = button:GetText(); |
clListDropdownInfo[1].text = button.text:GetText(); |
EasyMenu(clListDropdownInfo, dropdown, "cursor", 0, 0, "MENU", 3); |
end |
button:GetParent():Hide(); |
end, |
EditBoxOnEnterPressed = function(editBox) |
print(editBox:GetName()); |
local newName = editBox:GetText(); |
print(newName); |
Torta.cl3:RenameList(Torta.gui.selectedExplorerButton:GetID(), newName); |
editBox:GetParent():Hide(); |
end, |
hideOnEscape = 1, |
} |
StaticPopupDialogs["TORTA_CLDELETELIST"] = { |
text = "Are you REALLY sure you want to delete the list \"|cffffd000%s|r\"?", |
text = "Are you ABSOLUTELY sure you want to delete the list \"|cffffd000%s|r\"?", |
button1 = YES, |
button2 = NO, |
showAlert = true, |
mainWindow:SetMinResize(820, 450); |
PanelTemplates_SetNumTabs(mainWindow, 3); |
Torta.gui:OnTabClicked(1); |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Frame name="$parentTaskbar" inherits="TortaTooltipStyleFrameTemplate" parent="TortaParentFrameMainPage"> |
<Frame name="$parentCLTaskbar" inherits="TortaTooltipStyleFrameTemplate" parent="TortaParentFrameMainPage"> |
<Anchors> |
<Anchor point="BOTTOMLEFT"> |
<Offset y="5"/> |
</Frames> |
<!-- END OF TASKBAR BUTTONS --> |
</Frame> |
<Frame name="$parentNBTaskbar" inherits="TortaTooltipStyleFrameTemplate" parent="TortaParentFrameMainPage"> |
<Anchors> |
<Anchor point="BOTTOMLEFT"> |
<Offset y="5"/> |
</Anchor> |
<Anchor point="TOPRIGHT" relativePoint="BOTTOMRIGHT"> |
<Offset y="35"/> |
</Anchor> |
</Anchors> |
</Frame> |
</Ui> |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Frame name="$parentDisplaySubWindow" inherits="TortaSubWindowTemplate" parent="TortaParentFrameMainPage"> |
<Frame name="$parentCLDisplaySubWindow" inherits="TortaSubWindowTemplate" parent="TortaParentFrameMainPage"> |
<Anchors> |
<Anchor point="TOPLEFT" relativeTo="$parentExplorerSubWindow" relativePoint="TOPRIGHT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentTaskbar" relativePoint="TOPRIGHT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentNBTaskbar" relativePoint="TOPRIGHT"/> |
</Anchors> |
<Layers> |
<Layer level="ARTWORK"> |
<Frame name="$parentTaskEditorSubWindow" inherits="TortaSubWindowTemplate" parent="TortaParentFrameMainPage" hidden="false"> |
<Anchors> |
<Anchor point="BOTTOMLEFT" relativeTo="$parentExplorerSubWindow" relativePoint="BOTTOMRIGHT"/> |
<Anchor point="TOPRIGHT" relativeTo="$parentTaskbar" relativePoint="BOTTOMRIGHT"> |
<Anchor point="TOPRIGHT" relativeTo="$parentCLTaskbar" relativePoint="BOTTOMRIGHT"> |
<Offset y="150"/> |
</Anchor> |
</Anchors> |
</ScrollFrame> |
</Frames> |
</Frame> |
<Frame name="$parentNBDisplaySubWindow" inherits="TortaSubWindowTemplate" parent="TortaParentFrameMainPage"> |
<Anchors> |
<Anchor point="TOPLEFT" relativeTo="$parentExplorerSubWindow" relativePoint="TOPRIGHT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentNBTaskbar" relativePoint="TOPRIGHT"/> |
</Anchors> |
<Layers> |
<Layer level="ARTWORK"> |
<FontString name="$parentHeaderText" inherits="GameFontNormal" text="Torta Notebook"> |
<Anchors> |
<Anchor point="LEFT" relativeTo="$parentHeaderTexture"/> |
<Anchor point="RIGHT" relativeTo="$parentHeaderTexture"/> |
</Anchors> |
</FontString> |
<FontString name="$parentNYIText" inherits="GameFontHighlight" text="Torta Notebook is not yet implemented and is still (quite literally :P) on the to-do list. Development of Torta Checklist is currently a higher priority. Sorry!"> |
<Anchors> |
<Anchor point="LEFT"> |
<Offset x="30"/> |
</Anchor> |
<Anchor point="RIGHT"> |
<Offset x="-30"/> |
</Anchor> |
<Anchor point="TOP"/> |
<Anchor point="BOTTOM"/> |
</Anchors> |
</FontString> |
</Layer> |
</Layers> |
</Frame> |
</Ui> |
</OnClick> |
<OnLoad> |
self:RegisterForClicks("LeftButtonDown", "RightButtonDown"); |
local fs = self:CreateFontString(nil, "ARTWORK", "GameFontHighlight"); |
fs:SetPoint("LEFT", self, "LEFT", 5); |
fs:SetPoint("RIGHT", self, "RIGHT", -5); |
fs:SetText("Hello, World!"); |
fs:SetJustifyH("LEFT"); |
fs:SetJustifyV("TOP"); |
self.text = fs; |
</OnLoad> |
</Scripts> |
</Button> |
<Anchor point="TOPLEFT"> |
<Offset y="-2"/> |
</Anchor> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentTaskbar" relativePoint="TOPLEFT"> |
<Offset x="205" y="0"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentCLTaskbar" relativePoint="TOPLEFT"> |
<Offset x="225" y="0"/> |
</Anchor> |
</Anchors> |
<Layers> |
<Layer level="ARTWORK"> |
<FontString name="$parentHeaderText" inherits="GameFontNormal" text="Turtle Explorer"> |
<FontString name="$parentHeaderText" inherits="GameFontNormal" text="Tortoise Explorer"> |
<Anchors> |
<Anchor point="LEFT" relativeTo="$parentHeaderTexture"/> |
<Anchor point="RIGHT" relativeTo="$parentHeaderTexture"/> |
</Anchors> |
</FontString> |
<FontString name="$parentNoListsText" inherits="GameFontHighlight" text="You do not appear to have any lists. Right-click here to open up a context menu to create one."> |
<FontString name="$parentNoListsText" hidden="true" inherits="GameFontHighlight" text="You do not appear to have any lists. Right-click here to open up a context menu to create one."> |
<Anchors> |
<Anchor point="LEFT"> |
<Offset x="5"/> |
<Anchor point="BOTTOM"/> |
</Anchors> |
</FontString> |
<FontString name="$parentNoNotebooksText" hidden="true" inherits="GameFontHighlight" text="No notebooks were found in Torta's database. You can right-click here to open a context menu to create one."> |
<Anchors> |
<Anchor point="LEFT"> |
<Offset x="5"/> |
</Anchor> |
<Anchor point="RIGHT"> |
<Offset x="-5"/> |
</Anchor> |
<Anchor point="TOP"/> |
<Anchor point="BOTTOM"/> |
</Anchors> |
</FontString> |
</Layer> |
</Layers> |
<Frames> |
</OnUpdate> |
<OnMouseDown> |
if button == "RightButton" then |
Torta.gui:clShowExplorerDropdownMenu() |
if Torta.gui.tab == 2 then |
Torta.gui:clShowExplorerDropdownMenu() |
else |
-- open the Notebook dropdown menu here |
end |
end |
</OnMouseDown> |
</Scripts> |
function Checklist3:LoadList(listID) |
local lists = Torta.db.profile.lists; |
self:HideTaskEditor(); |
if (listID == nil) or (Torta.gui.data == lists[listID]) then |
if (listID == nil) or (Torta.gui.listData == lists[listID]) then |
-- "Unload" the list, show the no list loaded text, hide stuff |
gui.data = nil; |
gui.listData = nil; |
widgets.cl3HeaderText:SetText("Torta Checklist"); |
Torta.db.profile.cfg.loadedList = false; |
self.openTask = nil; |
else |
-- Do the opposite! |
Torta.gui.data = lists[listID]; |
gui.listData = lists[listID]; |
FauxScrollFrame_SetOffset(Torta.gui.elements.clScrollBar, 0); |
getglobal(widgets.clScrollBar:GetName() .. "ScrollBar"):SetValue(0); |
widgets.cl3HeaderText:SetText(lists[listID].meta.listName); |
function Checklist3:HideTaskEditor() |
dispWnd:ClearAllPoints(); |
dispWnd:SetPoint(unpack(displayWindowPoints)); |
dispWnd:SetPoint("BOTTOMRIGHT", widgets.taskBar, "TOPRIGHT"); |
dispWnd:SetPoint("BOTTOMRIGHT", widgets.clTaskBar, "TOPRIGHT"); |
tEditor:Hide(); |
self.openTask = nil; |
widgets.removeTaskButton:Disable(); |
end |
gui:UpdateExplorerScrollBar(); |
if not Torta.db.profile.lists[Torta.db.profile.cfg.loadedList] then |
print(Torta.db.profile.cfg.loadedList); |
-- print(Torta.db.profile.cfg.loadedList); |
Torta.db.profile.cfg.loadedList = false; |
self:LoadList(nil); |
gui:UpdateCLScrollBar(); |
function Checklist3:RenameList(listID, newName) |
-- print(listID, newName); |
if not (type(newName) == "string") then |
-- print(":D"); |
local listName = self:GetList(listID).meta.listName |
local dialog = StaticPopup_Show("TORTA_CLRENAMELIST", listName); |
getglobal(dialog:GetName() .. "EditBox"):SetText(listName); |
local Notebook = Torta.nb2; |
function Notebook:InitializeNotebook() |
PanelTemplates_DisableTab(TortaParentFrame, 3); |
end |