Quantcast

Fix page2 and navigation between pages

James Whitehead II [10-02-10 - 15:31]
Fix page2 and navigation between pages
Filename
Clique.xml
CliqueOptions.lua
diff --git a/Clique.xml b/Clique.xml
index ad3ee54..71375ea 100755
--- a/Clique.xml
+++ b/Clique.xml
@@ -1,8 +1,6 @@
 <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/
-    http://wowprogramming.com/FrameXML/UI.xsd">
-
+    xsi:schemaLocation="http://www.blizzard.com/wow/ui/ http://wowprogramming.com/FrameXML/UI.xsd">
     <Button name="CliqueRowTemplate" enableMouse="true" virtual="true">
         <Size x="298" y="30"/>
         <Layers>
@@ -196,6 +194,34 @@
                             <Size x="24" y="24"/>
                         </ThumbTexture>
                     </Slider>
+                    <Button name="$parentButtonSpell" parentKey="button_spell" inherits="MagicButtonTemplate">
+                        <Size x="100" y="22"/>
+                        <Anchors>
+                            <Anchor point="BOTTOMLEFT" relativeTo="CliqueConfig" />
+                        </Anchors>
+                        <Scripts>
+                            <OnClick>
+                                CliqueConfig:Button_OnClick(self)
+                            </OnClick>
+                        </Scripts>
+                    </Button>
+                    <Button name="$parentButtonOther" parentKey="button_other" inherits="MagicButtonTemplate">
+                        <Size x="100" y="22"/>
+                        <Anchors>
+                            <Anchor point="TOPLEFT" relativeTo="$parentButtonSpell" relativePoint="TOPRIGHT"/>
+                        </Anchors>
+                        <Scripts>
+                            <OnClick>
+                                CliqueConfig:Button_OnClick(self)
+                            </OnClick>
+                        </Scripts>
+                    </Button>
+                    <Button name="$parentButtonEdit" parentKey="button_edit" inherits="MagicButtonTemplate">
+                        <Size x="80" y="22"/>
+                        <Anchors>
+                            <Anchor point="BOTTOMRIGHT" relativeTo="CliqueConfig"/>
+                        </Anchors>
+                    </Button>
                 </Frames>
                 <Scripts>
                     <OnShow>
@@ -217,7 +243,7 @@
                         <Anchors>
                             <Anchor point="BOTTOMLEFT" relativeTo="$parent" relativePoint="BOTTOMLEFT">
                                 <Offset>
-                                    <AbsDimension x="20" y="85"/>
+                                    <AbsDimension x="1" y="0"/>
                                 </Offset>
                             </Anchor>
                         </Anchors>
@@ -274,47 +300,30 @@
                             </ScrollFrame>
                         </Frames>
                     </Button>
-                    <Button name="CliqueConfigSave" parentKey="save" inherits="UIPanelButtonTemplate2" text="SAVE">
-                        <Size x="82" y="22"/>
+                    <Button name="$parentButtonSave" parentKey="button_save" inherits="MagicButtonTemplate">
+                        <Size x="100" y="22"/>
                         <Anchors>
-                            <Anchor point="BOTTOMRIGHT">
-                                <Offset x="-40" y="64"/>
-                            </Anchor>
+                            <Anchor point="BOTTOMLEFT" relativeTo="CliqueConfig" />
                         </Anchors>
                         <Scripts>
-                            <OnClick>CliqueConfig:Save_OnClick(self, button, down)</OnClick>
+                            <OnClick>
+                                CliqueConfig:Button_OnClick(self)
+                            </OnClick>
                         </Scripts>
                     </Button>
-                    <Button name="CliqueConfigCancel" parentKey="cancel" inherits="UIPanelButtonTemplate2" text="CANCEL">
-                        <Size x="82" y="22"/>
+                    <Button name="$parentButtonCancel" parentKey="button_cancel" inherits="MagicButtonTemplate">
+                        <Size x="80" y="22"/>
                         <Anchors>
-                            <Anchor point="RIGHT" relativeTo="CliqueConfigSave" relativePoint="LEFT">
-                                <Offset x="2" y="0"/>
-                            </Anchor>
+                            <Anchor point="BOTTOMRIGHT" relativeTo="CliqueConfig"/>
                         </Anchors>
                         <Scripts>
-                            <OnClick>CliqueConfig:Cancel_OnClick(self, button, down)</OnClick>
+                            <OnClick>
+                                CliqueConfig:Button_OnClick(self)
+                            </OnClick>
                         </Scripts>
                     </Button>
-                </Frames>
+                 </Frames>
             </Frame> <!-- Page 2 - Edit Page -->
-			<Button name="$parentButton1" parentKey="button_add" inherits="MagicButtonTemplate">
-				<Size x="100" y="22"/>
-				<Anchors>
-					<Anchor point="BOTTOMLEFT" />
-				</Anchors>
-                <Scripts>
-                    <OnClick>
-                        CliqueConfig:Button_Add(self)
-                    </OnClick>
-                </Scripts>
-			</Button>
-			<Button name="$parentButton2" parentKey="button_edit" inherits="MagicButtonTemplate">
-				<Size x="80" y="22"/>
-				<Anchors>
-					<Anchor point="BOTTOMRIGHT" />
-				</Anchors>
-			</Button>
         </Frames>
         <Scripts>
             <OnLoad>
diff --git a/CliqueOptions.lua b/CliqueOptions.lua
index 143278e..f8c5e90 100755
--- a/CliqueOptions.lua
+++ b/CliqueOptions.lua
@@ -18,7 +18,7 @@ end
 function CliqueConfig:SetupGUI()
     self.rows = {}
     for i = 1, MAX_ROWS do
-        self.rows[i] = CreateFrame("Button", "CliqueRow" .. i, CliqueConfig, "CliqueRowTemplate")
+        self.rows[i] = CreateFrame("Button", "CliqueRow" .. i, self.page1, "CliqueRowTemplate")
     end

     self.rows[1]:ClearAllPoints()
@@ -41,8 +41,12 @@ function CliqueConfig:SetupGUI()
     self.page1.column2.sortType = "key"
     self.page1.sortType = self.page1.column2.sortType

-    self.button_add:SetText(L["Add binding"])
-    self.button_edit:SetText(L["Edit"])
+    self.page1.button_spell:SetText(L["Bind spell"])
+    self.page1.button_other:SetText(L["Bind other"])
+    self.page1.button_edit:SetText(L["Edit"])
+
+    self.page2.button_save:SetText(L["Save"])
+    self.page2.button_cancel:SetText(L["Cancel"])

     self.page1:Show()
 end
@@ -162,9 +166,23 @@ function CliqueConfig:Spellbook_OnBinding(button, key)
     end
 end

-function CliqueConfig:Button_Add(button)
-    if SpellBookFrame and not SpellBookFrame:IsVisible() then
-        ShowUIPanel(SpellBookFrame)
+function CliqueConfig:Button_OnClick(button)
+    -- Click handler for "Bind spell" button
+    if button == self.page1.button_spell then
+        if SpellBookFrame and not SpellBookFrame:IsVisible() then
+            ShowUIPanel(SpellBookFrame)
+        end
+
+    -- Click handler for "Bind other" button
+    elseif button == self.page1.button_other then
+        self.page1:Hide()
+        self.page2:Show()
+
+    -- Click handler for "Edit" button
+    elseif button == self.page1.button_edit then
+    elseif button == self.page2.button_cancel then
+        self.page2:Hide()
+        self.page1:Show()
     end
 end

@@ -180,10 +198,14 @@ local memoizeBindings = setmetatable({}, {__index = function(t, k, v)
     return binbits
 end})

-local compareFunctions = {
+local compareFunctions;
+compareFunctions = {
     name = function(a, b)
         local texta = addon:GetBindingActionText(a)
         local textb = addon:GetBindingActionText(b)
+        if texta == textb then
+            return compareFunctions.key(a, b)
+        end
         return texta < textb
     end,
     key = function(a, b)