diff --git a/.vscode/settings.json b/.vscode/settings.json
index bd7e616..982794c 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -231,6 +231,25 @@
"WorldFrame",
"class",
"QueryCastSequence",
- "message"
+ "message",
+ "hooksecurefunc",
+ "tremove",
+ "SetMacroSpell",
+ "GetMacroItem",
+ "SetMacroItem",
+ "GetLooseMacroIcons",
+ "GetLooseMacroItemIcons",
+ "GetMacroIcons",
+ "GetMacroItemIcons",
+ "GetNumSpellTabs",
+ "GetSpellTabInfo",
+ "GetSpellBookItemInfo",
+ "GetSpellBookItemTexture",
+ "GetFlyoutInfo",
+ "GetFlyoutSlotInfo",
+ "UnitName",
+ "ceil",
+ "GetSpellBookItemName",
+ "IsPassiveSpell"
]
}
diff --git a/MegaMacro.toc b/MegaMacro.toc
index f39e017..6beb3bb 100644
--- a/MegaMacro.toc
+++ b/MegaMacro.toc
@@ -1,7 +1,7 @@
-## Interface: 100007
+## Interface: 100100
## Title: Mega Macro
## Author: Sellorio
-## Version: 1.1.1
+## Version: 1.2.1
## OptionalDeps: ElvUI
## SavedVariables: MegaMacroConfig, MegaMacroGlobalData
@@ -27,4 +27,7 @@ src/engine/parsing/conditions.lua
src/engine/mega-macro-parser.lua
src/main.xml
+src/windows/mega-macro.input-scrollframe.lua
+src/windows/mega-macro.input-scrollframe.xml
+src/windows/mega-macro.scrollframe.xml
src/windows/mega-macro.window.xml
diff --git a/src/windows/mega-macro.input-scrollframe.lua b/src/windows/mega-macro.input-scrollframe.lua
new file mode 100644
index 0000000..8a805bc
--- /dev/null
+++ b/src/windows/mega-macro.input-scrollframe.lua
@@ -0,0 +1,164 @@
+function MegaMacro_EditBox_OnTabPressed(self)
+ if (self.previousEditBox and IsShiftKeyDown()) then
+ self.previousEditBox:SetFocus();
+ elseif (self.nextEditBox) then
+ self.nextEditBox:SetFocus();
+ end
+end
+
+function MegaMacro_EditBox_ClearFocus(self)
+ self:ClearFocus();
+end
+
+function MegaMacro_EditBox_HighlightText(self)
+ self:HighlightText();
+end
+
+function MegaMacro_EditBox_ClearHighlight(self)
+ self:HighlightText(0, 0);
+end
+
+function MegaMacro_ScrollFrame_OnLoad(self)
+ if not self.noScrollBar then
+ local scrollBarTemplate = self.scrollBarTemplate or SCROLL_FRAME_SCROLL_BAR_TEMPLATE;
+ if not scrollBarTemplate then
+ error("SCROLL_FRAME_SCROLL_BAR_TEMPLATE undefined. Check ScrollDefine.lua")
+ end
+
+ local left = self.scrollBarX or SCROLL_FRAME_SCROLL_BAR_OFFSET_LEFT;
+ if not left then
+ error("SCROLL_FRAME_SCROLL_BAR_OFFSET_LEFT undefined. Check ScrollDefine.lua")
+ end
+
+ local top = self.scrollBarTopY or SCROLL_FRAME_SCROLL_BAR_OFFSET_TOP;
+ if not top then
+ error("SCROLL_FRAME_SCROLL_BAR_OFFSET_TOP undefined. Check ScrollDefine.lua")
+ end
+
+ local bottom = self.scrollBarBottomY or SCROLL_FRAME_SCROLL_BAR_OFFSET_BOTTOM;
+ if not bottom then
+ error("SCROLL_FRAME_SCROLL_BAR_OFFSET_BOTTOM undefined. Check ScrollDefine.lua")
+ end
+
+ self.ScrollBar = CreateFrame("EventFrame", nil, self, scrollBarTemplate);
+ self.ScrollBar:SetHideIfUnscrollable(self.scrollBarHideIfUnscrollable);
+ self.ScrollBar:SetHideTrackIfThumbExceedsTrack(self.scrollBarHideTrackIfThumbExceedsTrack);
+ self.ScrollBar:SetPoint("TOPLEFT", self, "TOPRIGHT", left, top);
+ self.ScrollBar:SetPoint("BOTTOMLEFT", self, "BOTTOMRIGHT", left, bottom);
+ self.ScrollBar:Show();
+
+ ScrollUtil.InitScrollFrameWithScrollBar(self, self.ScrollBar);
+
+ self.ScrollBar:Update();
+ end
+end
+
+function MegaMacro_ScrollingEdit_OnTextChanged(self, scrollFrame)
+ -- force an update when the text changes
+ self.handleCursorChange = true;
+ MegaMacro_ScrollingEdit_OnUpdate(self, 0, scrollFrame);
+end
+
+function MegaMacro_ScrollingEdit_OnLoad(self)
+ MegaMacro_ScrollingEdit_SetCursorOffsets(self, 0, 0);
+end
+
+function MegaMacro_ScrollingEdit_SetCursorOffsets(self, offset, height)
+ self.cursorOffset = offset;
+ self.cursorHeight = height;
+end
+
+function MegaMacro_ScrollingEdit_OnCursorChanged(self, x, y, w, h)
+ MegaMacro_ScrollingEdit_SetCursorOffsets(self, y, h);
+ self.handleCursorChange = true;
+end
+
+-- NOTE: If your edit box never shows partial lines of text, then this function will not work when you use
+-- your mouse to move the edit cursor. You need the edit box to cut lines of text so that you can use your
+-- mouse to highlight those partially-seen lines; otherwise you won't be able to use the mouse to move the
+-- cursor above or below the current scroll area of the edit box.
+function MegaMacro_ScrollingEdit_OnUpdate(self, elapsed, scrollFrame)
+ if (not scrollFrame) then
+ scrollFrame = self:GetParent();
+ end
+
+ local hasScrollableExtent = scrollFrame.ScrollBar:HasScrollableExtent();
+ if (not hasScrollableExtent) then
+ -- Return if the scroll frame has no scroll bar or if the scroll bar has no scrollable extent.
+ return;
+ end
+
+ local formattedScrollFrame = _G["MegaMacro_FormattedFrameScrollFrame"];
+ if not formattedScrollFrame then
+ error("MegaMacro_FormattedFrameScrollFrame undefined. Check ScrollDefine.lua")
+ end
+
+ local scroll = scrollFrame:GetVerticalScroll();
+ local formattedScroll = formattedScrollFrame:GetVerticalScroll();
+
+ if (scroll ~= formattedScroll) then
+ formattedScrollFrame:SetVerticalScroll(scroll);
+ end
+
+ if (self.handleCursorChange) then
+ local height, range, size, cursorOffset;
+
+ height = scrollFrame:GetHeight();
+ range = scrollFrame:GetVerticalScrollRange();
+ size = height + range;
+ cursorOffset = -self.cursorOffset;
+
+ if (math.floor(height) <= 0 or math.floor(range) <= 0) then
+ --Frame has no area, nothing to calculate.
+ return;
+ end
+
+ while (cursorOffset < scroll) do
+ scroll = (scroll - (height / 2));
+ if (scroll < 0) then
+ scroll = 0;
+ end
+ scrollFrame:SetVerticalScroll(scroll);
+ formattedScrollFrame:SetVerticalScroll(scroll);
+ end
+
+ -- If the cursor is below the scroll area, scroll down until it's at the bottom of the scroll area.
+ while ((cursorOffset + self.cursorHeight) > (scroll + height) and scroll < range) do
+ scroll = (scroll + (height / 2));
+ -- Don't scroll past the end of the text
+ if (scroll > range) then
+ scroll = range;
+ end
+ scrollFrame:SetVerticalScroll(scroll);
+ formattedScrollFrame:SetVerticalScroll(scroll);
+ end
+
+ self.handleCursorChange = false;
+ end
+end
+
+function MegaMacro_InputScrollFrame_OnLoad(self)
+ -- self.scrollBarX = -10;
+ -- self.scrollBarTopY = -1;
+ -- self.scrollBarBottomY = -3;
+ -- self.scrollBarHideIfUnscrollable = true;
+
+ MegaMacro_ScrollFrame_OnLoad(self);
+
+ self.EditBox:SetWidth(self:GetWidth() - 18);
+ self.EditBox:SetMaxLetters(self.maxLetters);
+end
+
+function MegaMacro_InputScrollFrame_OnMouseDown(self)
+ self.EditBox:SetFocus();
+end
+
+MegaMacro_InputScrollFrame_OnTabPressed = MegaMacro_EditBox_OnTabPressed;
+
+function MegaMacro_InputScrollFrame_OnUpdate(self, elapsed)
+ MegaMacro_ScrollingEdit_OnUpdate(self, elapsed, self:GetParent());
+end
+
+function MegaMacro_InputScrollFrame_OnEscapePressed(self)
+ self:ClearFocus();
+end
diff --git a/src/windows/mega-macro.input-scrollframe.xml b/src/windows/mega-macro.input-scrollframe.xml
new file mode 100644
index 0000000..93a23a1
--- /dev/null
+++ b/src/windows/mega-macro.input-scrollframe.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/windows/mega-macro.scrollframe.xml b/src/windows/mega-macro.scrollframe.xml
new file mode 100644
index 0000000..efaaa2b
--- /dev/null
+++ b/src/windows/mega-macro.scrollframe.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/windows/mega-macro.window.lua b/src/windows/mega-macro.window.lua
index e35b541..60d8124 100644
--- a/src/windows/mega-macro.window.lua
+++ b/src/windows/mega-macro.window.lua
@@ -1,3 +1,5 @@
+UIPanelWindows["MegaMacro_Frame"] = { area = "left", pushable = 1, whileDead = 1, width = PANEL_DEFAULT_WIDTH };
+
local rendering = {
MacrosPerRow = 12,
CharLimitMessageFormat = "%s/%s Characters Used"
@@ -90,7 +92,7 @@ local function InitializeTabs()
MegaMacro_FrameTab2:SetText(MegaMacroCachedClass)
MegaMacro_FrameTab4:SetText(playerName)
- if MegaMacroCachedSpecialization == '' then
+ if MegaMacroCachedSpecialization == "" then
MegaMacro_FrameTab3:SetText("Locked")
MegaMacro_FrameTab5:SetText("Locked")
MegaMacro_FrameTab3:Disable()
@@ -194,6 +196,7 @@ local function SelectMacro(macro)
MegaMacro_FrameSelectedMacroName:SetText(macro.DisplayName)
MegaMacro_FrameSelectedMacroButtonIcon:SetTexture(buttonIcon:GetTexture())
MegaMacro_FrameText:SetText(macro.Code)
+ MegaMacro_FrameText:SetCursorPosition(0)
MegaMacro_EditButton:Enable();
MegaMacro_DeleteButton:Enable();
MegaMacro_FrameText:Enable()
@@ -408,7 +411,7 @@ MegaMacroWindow = {
else
local relativePoint, x, y = MegaMacroConfig_GetWindowPosition()
MegaMacro_Frame:SetMovable(true)
- MegaMacro_Frame:SetSize(640, 524)
+ -- MegaMacro_Frame:SetSize(640, 524)
MegaMacro_Frame:ClearAllPoints()
MegaMacro_Frame:SetPoint(relativePoint, x, y)
MegaMacro_ToggleWindowModeButton:SetText("Lock")
@@ -485,7 +488,7 @@ function MegaMacro_FrameTab_OnClick(self)
MegaMacro_ButtonScrollFrame:SetVerticalScroll(0)
if tabIndex == 6 then
- SelectedScope = 'config'
+ SelectedScope = "config"
MegaMacro_FrameTab_ShowConfig()
return
else
@@ -497,7 +500,6 @@ function MegaMacro_FrameTab_OnClick(self)
InitializeMacroSlots()
SetMacroItems()
InitializeTabs()
-
end
end
@@ -610,11 +612,13 @@ function MegaMacro_TextBox_TextChanged(self)
MegaMacro_FrameCharLimitText:SetFormattedText(
rendering.CharLimitMessageFormat,
MegaMacro_FrameText:GetNumLetters(),
- MegaMacroConfig['MaxMacroLength'])
+ MegaMacroConfig["MaxMacroLength"])
+
+ MegaMacro_ScrollingEdit_OnTextChanged(self, self:GetParent())
- ScrollingEdit_OnTextChanged(self, self:GetParent())
- ScrollingEdit_OnTextChanged(MegaMacro_FormattedFrameText, MegaMacro_FormattedFrameText:GetParent())
+ MegaMacro_ScrollingEdit_OnTextChanged(MegaMacro_FormattedFrameText, MegaMacro_FormattedFrameText:GetParent())
MegaMacro_FormattedFrameText:SetText(MegaMacroParser.Parse(text))
+ MegaMacro_FormattedFrameText:SetCursorPosition(0)
end
function MegaMacro_CancelButton_OnClick()
@@ -622,6 +626,7 @@ function MegaMacro_CancelButton_OnClick()
if SelectedMacro ~= nil then
MegaMacro_FrameText:SetText(SelectedMacro.Code)
+ MegaMacro_FrameText:SetCursorPosition(0)
end
MegaMacro_PopupFrame:Hide()
@@ -655,7 +660,7 @@ function MegaMacro_BlizMacro_Toggle()
MegaMacro_FrameCharLimitText:SetFormattedText(
rendering.CharLimitMessageFormat,
MegaMacro_FrameText:GetNumLetters(),
- MegaMacroConfig['MaxMacroLength'])
+ MegaMacroConfig["MaxMacroLength"])
end
function MegaMacro_EditOkButton_OnClick()
@@ -701,6 +706,10 @@ function MegaMacro_PopupFrame_OnUpdate()
local macroPopupOffset = FauxScrollFrame_GetOffset(MegaMacro_PopupScrollFrame);
local index;
+ -- print("MegaMacro_PopupFrame_OnUpdate")
+ -- print("numMacroIcons: " .. numMacroIcons)
+ -- print("macroPopupOffset: " .. macroPopupOffset)
+
-- Icon list
for i = 1, NUM_MACRO_ICONS_SHOWN do
macroPopupButton = _G["MegaMacro_PopupButton" .. i];
@@ -725,6 +734,33 @@ function MegaMacro_PopupFrame_OnUpdate()
FauxScrollFrame_Update(MegaMacro_PopupScrollFrame, ceil(numMacroIcons / NUM_ICONS_PER_ROW) + 1, NUM_ICON_ROWS, MACRO_ICON_ROW_HEIGHT);
end
+-- function MegaMacro_PopupFrame_OnUpdate1(self)
+-- local numMacroIcons = #IconList;
+-- local macroPopupIcon, macroPopupButton;
+-- local macroPopupOffset = self.cursorOffset;
+-- local index;
+
+-- -- Icon list
+-- for i = 1, NUM_MACRO_ICONS_SHOWN do
+-- macroPopupButton = _G["MegaMacro_PopupButton" .. i];
+-- macroPopupIcon = _G["MegaMacro_PopupButton" .. i .. "Icon"];
+-- index = (macroPopupOffset * NUM_ICONS_PER_ROW) + i;
+-- local iconListData = IconList[index]
+
+-- if index <= numMacroIcons and iconListData then
+-- macroPopupIcon:SetTexture(iconListData.Icon);
+-- macroPopupButton.SpellId = iconListData.SpellId
+-- macroPopupButton:Show();
+-- else
+-- macroPopupIcon:SetTexture("");
+-- macroPopupButton.SpellId = nil
+-- macroPopupButton:Hide();
+-- end
+
+-- macroPopupButton:SetChecked(iconListData and SelectedIcon == iconListData.Icon)
+-- end
+-- end
+
function MegaMacro_PopupButton_OnClick(self)
local buttonIcon = _G[self:GetName() .. "Icon"]
SelectIcon(buttonIcon:GetTexture())
diff --git a/src/windows/mega-macro.window.xml b/src/windows/mega-macro.window.xml
index b6bc762..f89cf9d 100644
--- a/src/windows/mega-macro.window.xml
+++ b/src/windows/mega-macro.window.xml
@@ -1,5 +1,7 @@
-
+
+
self:RegisterForDrag("LeftButton");
@@ -20,6 +22,7 @@
+
MegaMacro_PopupButton_OnClick(self);
@@ -35,16 +38,9 @@
+
-
-
-
-
-
-
-
-
-
+
self:RegisterForDrag("LeftButton");
@@ -87,7 +83,7 @@
-
+
@@ -107,7 +103,7 @@
-
+
@@ -133,7 +129,7 @@
-
+
@@ -141,6 +137,7 @@
+
+
@@ -175,43 +173,15 @@
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -222,7 +192,7 @@
-
+
@@ -231,90 +201,59 @@
-