Skip to content

Commit

Permalink
- Adjusted Mouse Frame size for improved fit
Browse files Browse the repository at this point in the history
- Added Expressway Regular and Condensed font options
- Enhanced font consistency across the addon
- Improved text length handling with dynamic width adjustment
- Fixed bug when switching to custom mouse layout
  • Loading branch information
1onar committed Nov 8, 2024
1 parent 9cdccc6 commit c47240b
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 138 deletions.
34 changes: 30 additions & 4 deletions KeyUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,12 @@ function addon:CreateTooltip()
keyui_tooltip_frame.key = keyui_tooltip_frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
keyui_tooltip_frame.key:SetPoint("CENTER", keyui_tooltip_frame, "CENTER", 0, 10)
keyui_tooltip_frame.key:SetTextColor(1, 1, 1)
keyui_tooltip_frame.key:SetFont("Fonts\\ARIALN.TTF", 16)
keyui_tooltip_frame.key:SetFont("Interface\\AddOns\\KeyUI\\Media\\Fonts\\Expressway Regular.TTF", 16)

keyui_tooltip_frame.binding = keyui_tooltip_frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
keyui_tooltip_frame.binding:SetPoint("CENTER", keyui_tooltip_frame, "CENTER", 0, -10)
keyui_tooltip_frame.binding:SetTextColor(1, 1, 1)
keyui_tooltip_frame.binding:SetFont("Fonts\\ARIALN.TTF", 16)
keyui_tooltip_frame.binding:SetFont("Interface\\AddOns\\KeyUI\\Media\\Fonts\\Expressway Regular.TTF", 16)

-- Hide the GameTooltip when this custom tooltip hides.
keyui_tooltip_frame:SetScript("OnHide", function() GameTooltip:Hide() end)
Expand All @@ -502,10 +502,13 @@ function addon:ButtonMouseOver(button)

addon.keyui_tooltip_frame:SetPoint("LEFT", button, "RIGHT", 6, 0) -- Position for the Addon Tooltip

if short_modifier_string[key] then
-- Check if the key is in the no_modifier_keys list
if addon.no_modifier_keys[key] then
-- If the key is in the no_modifier_keys list, don't add the modifier string
addon.keyui_tooltip_frame.key:SetText(key)
else
addon.keyui_tooltip_frame.key:SetText(short_modifier_string .. key or "")
-- If it's not a no-modifier key, combine the modifier string with the key
addon.keyui_tooltip_frame.key:SetText(short_modifier_string .. key)
end

addon.keyui_tooltip_frame.binding:SetText(readable_binding or "")
Expand Down Expand Up @@ -753,6 +756,10 @@ function addon:SetKey(button)

-- Set the short key format if button.short_key exists
if button.short_key then

-- Adjust the width of the short_key based on button width
button.short_key:SetWidth(button:GetWidth() - 6)

-- Check if the key should be displayed without modifiers
if addon.no_modifier_keys[original_text] then
-- If the key is in the no_modifier_keys list, display it without modifiers
Expand All @@ -776,6 +783,19 @@ function addon:SetKey(button)
end
end
end

-- Calculate the maximum allowed characters based on button width
local max_allowed_chars = math.floor(button:GetWidth() / 8)
local combined_text = button.short_key:GetText() -- Combined text with modifiers if present

-- Use Condensed font if the combined text exceeds max_allowed_chars
if string.len(combined_text) > max_allowed_chars then
-- Use the Condensed font for longer text
button.short_key:SetFont("Interface\\AddOns\\KeyUI\\Media\\Fonts\\Expressway Condensed.TTF", 16, "OUTLINE")
else
-- Use the Regular font for shorter text
button.short_key:SetFont("Interface\\AddOns\\KeyUI\\Media\\Fonts\\Expressway Regular.TTF", 16, "OUTLINE")
end
end
end

Expand Down Expand Up @@ -903,6 +923,9 @@ function addon:create_action_labels()
if keyboard_button.readable_binding then
local command = keyboard_button.binding

-- Adjust the width of the readable_binding based on button width
keyboard_button.readable_binding:SetWidth(keyboard_button:GetWidth() - 4)

-- Check if the command corresponds to a Dominos action button
if command and command:match("CLICK DominosActionButton(%d+):HOTKEY") then
-- Handle the binding for Dominos action buttons
Expand Down Expand Up @@ -940,6 +963,9 @@ function addon:create_action_labels()
if mouse_button.readable_binding then
local command = mouse_button.binding

-- Adjust the width of the readable_binding based on button width
mouse_button.readable_binding:SetWidth(mouse_button:GetWidth() - 4)

-- Check if the command corresponds to a Dominos action button
if command and command:match("CLICK DominosActionButton(%d+):HOTKEY") then
-- Handle the binding for Dominos action buttons
Expand Down
9 changes: 4 additions & 5 deletions KeyboardFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -929,21 +929,20 @@ function addon:CreateKeyboardButtons()

-- Keyboard Keybind text string on the top right of the button (e.g. a-c-s-1)
keyboard_button.short_key = keyboard_button:CreateFontString(nil, "OVERLAY", "GameFontNormal")
keyboard_button.short_key:SetFont("Fonts\\ARIALN.TTF", 15, "OUTLINE")
keyboard_button.short_key:SetTextColor(1, 1, 1)
keyboard_button.short_key:SetHeight(20)
keyboard_button.short_key:SetWidth(70)
--keyboard_button.short_key:SetWidth(52) -- will be calculated in addon:SetKey
keyboard_button.short_key:SetPoint("TOPRIGHT", keyboard_button, "TOPRIGHT", -4, -6)
keyboard_button.short_key:SetJustifyH("RIGHT")
keyboard_button.short_key:SetJustifyV("TOP")
keyboard_button.short_key:Show()

-- Font string to display the interface action text (toggled by function addon:create_action_labels)
keyboard_button.readable_binding = keyboard_button:CreateFontString(nil, "OVERLAY", "GameFontNormal")
keyboard_button.readable_binding:SetFont("Fonts\\ARIALN.TTF", 12, "OUTLINE")
keyboard_button.readable_binding:SetFont("Interface\\AddOns\\KeyUI\\Media\\Fonts\\Expressway Condensed.TTF", 12, "OUTLINE")
keyboard_button.readable_binding:SetTextColor(1, 1, 1)
keyboard_button.readable_binding:SetHeight(30)
keyboard_button.readable_binding:SetWidth(56)
--keyboard_button.readable_binding:SetWidth(56) -- will be calculated in addon:create_action_labels
keyboard_button.readable_binding:SetPoint("BOTTOM", keyboard_button, "BOTTOM", 1, 6)
keyboard_button.readable_binding:SetJustifyV("BOTTOM")
keyboard_button.readable_binding:SetText("")
Expand Down Expand Up @@ -1146,7 +1145,7 @@ function addon:KeyboardLayoutSelecter()
elseif layout == "Cyborg_II" then
info.text = "Cyborg II"
elseif layout == "Moonlander_MK_I" then
info.text = "Moonlander Default Layout"
info.text = "Moonlander Mark I"
else
info.text = layout -- For other layouts, keep the original text
end
Expand Down
20 changes: 10 additions & 10 deletions LayoutsKeyboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3459,11 +3459,11 @@ addon.default_keyboard_layouts = {
{ 'E', 192, -68, u, u },
{ 'R', 254, -72, u, u },
{ 'T', 316, -76, u, u },
{ 'N/A', 378, -80, u, u },
{ 'Custom', 378, -80, u, u },

-- Row 2 right half

{ 'N/A', 750, -80, u, u },
{ 'Custom', 750, -80, u, u },
{ 'Y', 812, -76, u, u },
{ 'U', 874, -72, u, u },
{ 'I', 936, -68, u, u },
Expand All @@ -3479,11 +3479,11 @@ addon.default_keyboard_layouts = {
{ 'D', 192, -130, u, u },
{ 'F', 254, -134, u, u },
{ 'G', 316, -138, u, u },
{ 'N/A', 378, -142, u, u },
{ 'Custom', 378, -142, u, u },

-- Row 3 right half

{ 'N/A', 750, -142, u, u },
{ 'Custom', 750, -142, u, u },
{ 'H', 812, -138, u, u },
{ 'J', 874, -134, u, u },
{ 'K', 936, -130, u, u },
Expand All @@ -3499,7 +3499,7 @@ addon.default_keyboard_layouts = {
{ 'C', 192, -192, u, u },
{ 'V', 254, -196, u, u },
{ 'B', 316, -200, u, u },
-- { 'N/A', 378, -142, u, u },
-- { 'Custom', 378, -142, u, u },

-- Row 4 right half

Expand All @@ -3509,27 +3509,27 @@ addon.default_keyboard_layouts = {
{ '.', 998, -196, u, u },
{ '/', 1060, -200, u, u },
{ 'RSHIFT', 1122, -204, u, u },
-- { 'N/A', 1184, -142, u, u },
-- { 'Custom', 1184, -142, u, u },

-- Row 5 left half

{ '`', 6, -266, u, u },
{ 'CAPSLOCK', 68, -262, u, u },
{ 'N/A', 130, -258, u, u },
{ 'Custom', 130, -258, u, u },
{ 'LEFT', 192, -254, u, u },
{ 'RIGHT', 254, -258, u, u },
-- { 'B', 316, -200, u, u },
-- { 'N/A', 378, -142, u, u },
-- { 'Custom', 378, -142, u, u },

-- Row 5 right half

{ 'UP', 874, -258, u, u },
{ 'DOWN', 936, -254, u, u },
{ '[', 998, -258, u, u },
{ ']', 1060, -262, u, u },
{ 'N/A', 1122, -266, u, u },
{ 'Custom', 1122, -266, u, u },
-- { 'B', 1184, -200, u, u },
-- { 'N/A', 1246, -142, u, u },
-- { 'Custom', 1246, -142, u, u },

-- -- Left Thumb Area
{ 'LALT', 378, -266, u2, u },
Expand Down
Loading

0 comments on commit c47240b

Please sign in to comment.