Skip to content

Commit

Permalink
Major UI changes
Browse files Browse the repository at this point in the history
- Added title bar (and made only this draggable instead of the entire frame)
- Added close button again
- Removed scroll bar textures
  • Loading branch information
cloudbells committed Aug 25, 2019
1 parent 5b6627d commit 6d87340
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 137 deletions.
9 changes: 9 additions & 0 deletions Database/Trainers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ FieldGuide.HUNTER_PET_TRAINERS = {
}
}

FieldGuide.WARLOCK_PET_TRAINERS = {
["ALLIANCE"] = {

},
["HORDE"] = {

}
}

FieldGuide.SPELL_TRAINERS = {
["WARRIOR"] = {
["ALLIANCE"] = {
Expand Down
48 changes: 12 additions & 36 deletions FieldGuide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---------------------------------------
1. Add price for the pinned vendor in the tooltip.
2. Add Warlock trainers.
3. Add logic for finding closest Warlock/Hunter trainer – refactor so it isn't shit.
3. Add logic for finding closest Warlock pet trainer – refactor so it isn't shit.
4. Add tomes.
5. Add tutorial (shift+scroll for horizontal scroll/shift+right-click for marking all of the same spells etc)
6. (Add racials.)
Expand Down Expand Up @@ -113,16 +113,21 @@ local function findPortalTrainer(spell)
return trainer
end

-- Returns the closest spell trainer to the player for the given spell.
local function findClosestSpellTrainer(spell)
-- Returns the closest trainer for the given skill.
local function findClosestTrainer(skill)
local tempFaction = faction == "Horde" and selectedClass == "PALADIN" and "ALLIANCE" or faction == "Alliance" and selectedClass == "SHAMAN" and "HORDE" or faction:upper()
local backupTrainer = nil -- For if there is no trainer on the same continent as the player.
local sameContinentTrainer = nil
local shortestDistance = 100000 -- For if there is no trainer on the same continent as the player.
local sameContinentDistance = 100000
local instance = select(3, hbd:GetPlayerWorldPosition())
for _, trainer in ipairs(FieldGuide.SPELL_TRAINERS[selectedClass][tempFaction]) do
if not (spell.level > 6 and trainer.noob) then
local conditional = nil
local trainerTable = nil
for _, trainer in ipairs((selectedClass == "WEAPONS" and FieldGuide.WEAPON_TRAINERS[tempFaction])
or (selectedClass == "HUNTER_PETS" and FieldGuide.HUNTER_PET_TRAINERS[tempFaction])
or (selectedClass == "WARLOCK_PETS" and FieldGuide.WARLOCK_PET_TRAINERS[tempFaction])
or FieldGuide.SPELL_TRAINERS[selectedClass][tempFaction]) do
if selectedClass == "WEAPONS" and trainer[skill.spellId] or skill.level ~= nil and not (skill.level > 6 and trainer.noob) then
local distance = getDistance(trainer.x / 100, trainer.y / 100, trainer.map)
if FieldGuide.getContinent(trainer.map) == instance and distance < sameContinentDistance then
sameContinentDistance = distance
Expand All @@ -139,31 +144,6 @@ local function findClosestSpellTrainer(spell)
return backupTrainer
end

-- Returns the closest weapon trainer to the player for the given weapon.
local function findClosestWeaponTrainer(weapon)
local backupTrainer = nil -- For if there is no trainer on the same continent as the player.
local sameContinentTrainer = nil
local shortestDistance = 100000 -- For if there is no trainer on the same continent as the player.
local sameContinentDistance = 100000
local instance = select(3, hbd:GetPlayerWorldPosition())
for _, trainer in ipairs(FieldGuide.WEAPON_TRAINERS[faction:upper()]) do
if trainer[weapon.spellId] then
local distance = getDistance(trainer.x / 100, trainer.y / 100, trainer.map)
if FieldGuide.getContinent(trainer.map) == instance and distance < sameContinentDistance then
sameContinentDistance = distance
sameContinentTrainer = FieldGuide.copy(trainer)
elseif distance < shortestDistance then
shortestDistance = distance
backupTrainer = FieldGuide.copy(trainer)
end
end
end
backupTrainer = sameContinentTrainer ~= nil and sameContinentTrainer or backupTrainer
backupTrainer.x = backupTrainer.x / 100
backupTrainer.y = backupTrainer.y / 100
return backupTrainer
end

-- Checks if the pin exists as a frame and as a saved variable.
-- Returns true if it does exist, then the frames, and then the variables.
local function doesPinExist(name)
Expand Down Expand Up @@ -647,7 +627,7 @@ end
-- Initializes all frames, level strings, and textures for reuse.
local function initFrames()
NBR_OF_SPELL_ROWS = floor(FieldGuideFrame:GetHeight() / 100)
Y_SPACING = math.ceil(FieldGuideFrame:GetHeight() / NBR_OF_SPELL_ROWS) / 1.175
Y_SPACING = math.ceil(FieldGuideFrame:GetHeight() / NBR_OF_SPELL_ROWS) / 1.1625
local nbrOfSpellBtns = floor((FieldGuideFrame:GetWidth() - BUTTON_X_START * 2) / BUTTON_X_SPACING) * NBR_OF_SPELL_ROWS
NBR_OF_SPELL_COLUMNS = nbrOfSpellBtns / NBR_OF_SPELL_ROWS -- The number of buttons in x.
-- Create spell buttons.
Expand Down Expand Up @@ -762,12 +742,8 @@ function FieldGuideSpellButton_OnClick(self, button)
local trainer = nil
if self.name:find("Teleport") or self.name:find("Portal") then
trainer = findPortalTrainer(self)
elseif selectedClass == "HUNTER_PETS" then

elseif selectedClass == "WARLOCK_PETS" then

else
trainer = selectedClass ~= "WEAPONS" and findClosestSpellTrainer(self) or findClosestWeaponTrainer(self)
trainer = findClosestTrainer(self)
end
if not doesPinExist(trainer.name) and self.spellCost ~= 0 then
addMapPin(trainer.map, trainer.x, trainer.y, trainer.name)
Expand Down
152 changes: 51 additions & 101 deletions FieldGuide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,7 @@
<AbsValue val="16" />
</FontHeight>
</FontString>
<FontString name="FieldGuideCostStringTemplate" font="Fonts/ARIALN.ttf" outline="NORMAL" justifyH="LEFT" virtual="true">
<Shadow>
<Color a="0.5" r="0" g="0" b="0" />
<Offset x="1" y="-1" />
</Shadow>
<FontHeight>
<AbsValue val="20" />
</FontHeight>
</FontString>
<Frame name="FieldGuideFrame" parent="UIParent" enableMouse="true" movable="true" clampedToScreen="true">
<Frame name="FieldGuideFrame" parent="UIParent" clampedToScreen="true" enableMouse="true" movable="true" frameStrata="DIALOG">
<Size x="668" y="500" /> <!-- 668x500 original (13 spells) -->
<Anchors>
<Anchor point="CENTER" />
Expand All @@ -98,20 +89,43 @@
</Texture>
</Layer>
<Layer level="OVERLAY">
<Texture name="$parentScrollSeparatorTexture" file="Interface/Addons/FieldGuide/Media/Buttons/ScrollbarVertical-Knob">
<Size x="48" y="56" />
<Texture name="$parentTitleTexture" file="Interface/DialogFrame/UI-DialogBox-Header">
<Size x="240" y="60" />
<Anchors>
<Anchor point="BOTTOMRIGHT" x="0" y="-4" />
<Anchor point="TOP" x="0" y="12" />
</Anchors>
</Texture>
<FontString name="$parentTitleString" font="Fonts/FRIZQT__.ttf" outline="NORMAL" justifyH="LEFT" text="Field Guide">
<Color a="1" r="1" g="0.82" b="0" />
<FontHeight>
<AbsValue val="12" />
</FontHeight>
<Anchors>
<Anchor point="TOP" x="0" y="-1" />
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<Frame name="$parentTitleDraggable" enableMouse="true">
<Size x="120" y="30" />
<Anchors>
<Anchor point="TOP" x="0" y="10" />
</Anchors>
<Scripts>
<OnMouseDown>
self:GetParent():StartMoving()
</OnMouseDown>
<OnMouseUp>
self:GetParent():StopMovingOrSizing()
</OnMouseUp>
</Scripts>
</Frame>
<Slider name="$parentVerticalSlider" orientation="VERTICAL" minValue="0" maxValue="0" defaultValue="0" valueStep="1">
<Size x="25" y="1" />
<Anchors>
<Anchor point="TOPRIGHT" relativeTo="FieldGuideFrame" x="-11" y="-24" />
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" y="49" />
<Anchor point="TOPRIGHT" relativeTo="FieldGuideFrame" x="-12" y="-49" />
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" y="45" />
</Anchors>
<Scripts>
<OnValueChanged>
Expand All @@ -125,7 +139,7 @@
<Button name="$parentScrollUpButton">
<Size x="32" y="32" />
<Anchors>
<Anchor point="TOPRIGHT" relativeTo="FieldGuideFrame" x="-7" y="-5" />
<Anchor point="TOPRIGHT" relativeTo="FieldGuideFrame" x="-9" y="-30" />
</Anchors>
<Scripts>
<OnClick>
Expand All @@ -140,7 +154,7 @@
<Button name="$parentScrollDownButton">
<Size x="32" y="32" />
<Anchors>
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-7" y="31" />
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-9" y="26" />
</Anchors>
<Scripts>
<OnClick>
Expand All @@ -155,64 +169,35 @@
</Frames>
<Layers>
<Layer level="ARTWORK">
<Texture name="$parentBackground" setAllPoints="true">
<Color a="1" r="0" g="0" b="0" />
</Texture>
</Layer>
<Layer level="ARTWORK" textureSubLevel="1">
<Texture name="$parentTop" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarVertical">
<Size x="31" y="102" />
<Anchors>
<Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" relativeTo="FieldGuideFrame" x="-8" y="-8" />
</Anchors>
<TexCoords left="0" right="0.484375" top="0" bottom="0.4"/>
</Texture>
<Texture name="$parentBottom" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarVertical">
<Size x="31" y="106"/>
<Anchors>
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-8" y="36" />
</Anchors>
<TexCoords left="0.515625" right="1.0" top="0" bottom="0.4140625" />
</Texture>
<Texture name="$parentMiddle" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarVertical">
<Size x="31" y="1" />
<Texture name="$parentBackground">
<Anchors>
<Anchor point="TOP" relativeTo="$parentTop" relativePoint="BOTTOM" />
<Anchor point="BOTTOM" relativeTo="$parentBottom" relativePoint="TOP" />
<Anchor point="TOPLEFT" x="2" y="" />
<Anchor point="BOTTOMRIGHT" x="-4" y="0" />
</Anchors>
<TexCoords left="0" right="0.484375" top=".75" bottom="1" />
</Texture>
</Layer>
<Layer level="OVERLAY">
<Texture name="$parentExtension" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarVertical">
<Size x="6" y="32" />
<Anchors>
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-8" y="10" />
</Anchors>
<TexCoords left="0.90625" right="1.0" top="0" bottom="0" />
<Color a="0.5" r="0" g="0" b="0" />
</Texture>
</Layer>
</Layers>
</Slider>
<Slider name="$parentHorizontalSlider" orientation="HORIZONTAL" minValue="0" maxValue="0" defaultValue="0" valueStep="1">
<Size x="1" y="25" />
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="FieldGuideFrame" x="22" y="10" />
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-51" />
<Anchor point="BOTTOMLEFT" relativeTo="FieldGuideFrame" x="27" y="10" />
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-48" />
</Anchors>
<Scripts>
<OnValueChanged>
FieldGuide_OnHorizontalValueChanged(self, value)
</OnValueChanged>
</Scripts>
<ThumbTexture name="$parentThumbTexture" file="Interface/Addons/FieldGuide/Media/Buttons/ScrollbarHorizontal-Knob">
<Size x="32" y="32" />
<Size x="32" y="31" />
</ThumbTexture>
<Frames>
<Button name="$parentScrollLeftButton">
<Size x="32" y="32" />
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="FieldGuideFrame" x="4" y="6" />
<Anchor point="BOTTOMLEFT" relativeTo="FieldGuideFrame" x="7" y="7" />
</Anchors>
<Scripts>
<OnClick>
Expand All @@ -227,7 +212,7 @@
<Button name="$parentScrollRightButton">
<Size x="32" y="32" />
<Anchors>
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-33" y="6" />
<Anchor point="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-28" y="7" />
</Anchors>
<Scripts>
<OnClick>
Expand All @@ -242,41 +227,12 @@
</Frames>
<Layers>
<Layer level="ARTWORK">
<Texture name="$parentBackground" setAllPoints="true">
<Color a="1" r="0" g="0" b="0" />
</Texture>
</Layer>
<Layer level="ARTWORK" textureSubLevel="2">
<Texture name="$parentLeft" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarHorizontal">
<Size x="102" y="31" />
<Texture name="$parentBackground">
<Anchors>
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" relativeTo="FieldGuideFrame" x="9" y="7" />
<Anchor point="TOPLEFT" x="0" y="-2" />
<Anchor point="BOTTOMRIGHT" x="0" y="4" />
</Anchors>
<TexCoords left="0.58203125" right="1" top="0.515625" bottom="1" />
</Texture>
<Texture name="$parentRight" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarHorizontal">
<Size x="102" y="31" />
<Anchors>
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-36" y="7" />
</Anchors>
<TexCoords left="0.6" right="1" top="0" bottom="0.484375" />
</Texture>
<Texture name="$parentMiddle" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarHorizontal">
<Size x="1" y="31" />
<Anchors>
<Anchor point="LEFT" relativeTo="$parentLeft" relativePoint="RIGHT" />
<Anchor point="RIGHT" relativeTo="$parentRight" relativePoint="LEFT" />
</Anchors>
<TexCoords left="0" right="0.25" top="0" bottom="0.484375" />
</Texture>
</Layer>
<Layer level="OVERLAY">
<Texture name="$parentExtension" file="Interface/Addons/FieldGuide/Media/Scrollbar/ScrollbarHorizontal">
<Size x="24" y="6" />
<Anchors>
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" relativeTo="FieldGuideFrame" x="-12" y="7" />
</Anchors>
<TexCoords left="0.78125" right="0.90234375" top="0.90625" bottom="1.0" />
<Color a="0.5" r="0" g="0" b="0" />
</Texture>
</Layer>
</Layers>
Expand All @@ -302,16 +258,16 @@
</OnClick>
</Scripts>
</CheckButton>
<Frame name="FieldGuideDropdownFrame" inherits="UIDropDownMenuTemplate" frameStrata="MEDIUM">
<Button name="$parentCloseButton" inherits="UIPanelCloseButton">
<Anchors>
<Anchor point="TOPRIGHT" x="-8" y="-8" />
</Anchors>
</Button>
<Frame name="FieldGuideDropdownFrame" inherits="UIDropDownMenuTemplate">
<Anchors>
<Anchor point="TOPRIGHT" x="-40" y="-26"/>
<Anchor point="TOPRIGHT" x="-36" y="-27" />
</Anchors>
</Frame>
<!-- <Button name="$parentCloseButton" inherits="UIPanelCloseButton"> -->
<!-- <Anchors> -->
<!-- <Anchor point="TOPRIGHT" x="3" y="4" /> -->
<!-- </Anchors> -->
<!-- </Button> -->
</Frames>
<Scripts>
<OnLoad>
Expand All @@ -323,12 +279,6 @@
<OnHide>
PlaySound(SOUNDKIT.IG_SPELLBOOK_CLOSE)
</OnHide>
<OnDragStart>
self:StartMoving()
</OnDragStart>
<OnDragStop>
self:StopMovingOrSizing()
</OnDragStop>
<OnMouseWheel>
FieldGuide_Scroll(delta)
</OnMouseWheel>
Expand Down
Binary file removed Media/Scrollbar/ScrollbarHorizontal.tga
Binary file not shown.
Binary file removed Media/Scrollbar/ScrollbarVertical.tga
Binary file not shown.

0 comments on commit 6d87340

Please sign in to comment.