Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions LuaMenu/widgets/api_chili.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function widget:DrawLoadScreen()
if WG.Chobby and WG.Chobby.Configuration and WG.Chobby.Configuration.hideInterface then
return
end

gl.Color(1,1,1,1)
if (not screen0:IsEmpty()) then
gl.PushMatrix()
Expand All @@ -125,7 +125,7 @@ function widget:TweakDrawScreen()
if WG.Chobby and WG.Chobby.Configuration and WG.Chobby.Configuration.hideInterface then
return
end

gl.Color(1,1,1,1)
if (not screen0:IsEmpty()) then
gl.PushMatrix()
Expand All @@ -143,7 +143,7 @@ function widget:DrawGenesis()
if WG.Chobby and WG.Chobby.Configuration and WG.Chobby.Configuration.hideInterface then
return
end

gl.Color(1,1,1,1)
tf.Update()
th.Update()
Expand Down Expand Up @@ -220,6 +220,12 @@ function widget:TextInput(utf8, ...)
return screen0:TextInput(utf8, ...)
end

function widget:TextEditing(utf8, start, length, ...)
if Spring.IsGUIHidden() then return false end

return screen0:TextEditing(utf8, start, length, ...)
end


local oldSizeX, oldSizeY
function widget:ViewResize(vsx, vsy)
Expand Down
22 changes: 18 additions & 4 deletions LuaMenu/widgets/chobby/components/chat_windows.lua
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,14 @@ function ChatWindows:GetChannelConsole(chanName)
self.userListPanels[chanName] = userListPanel

local caption = "#" .. chanName
local myFont = Font:New(Configuration:GetFont(1))
local tooltip = nil
local origCaption = caption
local fontSize = 1
local myFont = Font:New(Configuration:GetFont(fontSize))
caption = StringUtilities.GetTruncatedStringWithDotDot(caption, myFont, 70)
if origCaption ~= caption then
tooltip = origCaption
end

local closeChannelButton = Button:New {
width = 24, height = 24, y = 5, right = Configuration.userListWidth + 18,
Expand All @@ -770,7 +776,8 @@ function ChatWindows:GetChannelConsole(chanName)
{
name = chanName,
caption = caption,
font = Configuration:GetFont(1),
font = Configuration:GetFont(fontSize),
tooltip = tooltip,
children = {
Control:New {
x = 0, y = 0, right = Configuration.userListWidth, bottom = 0,
Expand Down Expand Up @@ -825,8 +832,14 @@ function ChatWindows:GetPrivateChatConsole(userName, switchTo)
self.privateChatConsoles[chanName] = privateChatConsole

local caption = "@" .. userName
local myFont = Font:New(Configuration:GetFont(1))
local tooltip = nil
local origCaption = caption
local fontSize = 1
local myFont = Font:New(Configuration:GetFont(fontSize))
caption = StringUtilities.GetTruncatedStringWithDotDot(caption, myFont, 70)
if origCaption ~= caption then
tooltip = origCaption
end

local closeChannelButton = Button:New {
width = 24, height = 24, y = 5, right = 18,
Expand All @@ -845,7 +858,8 @@ function ChatWindows:GetPrivateChatConsole(userName, switchTo)
{
name = chanName,
caption = caption,
font = Configuration:GetFont(1),
tooltip = tooltip,
font = Configuration:GetFont(fontSize),
children = {
privateChatConsole.panel,
closeChannelButton
Expand Down
79 changes: 45 additions & 34 deletions LuaMenu/widgets/gui_modoptions_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local function UpdateControlValue(key, value)
end
end


local function ResetToDefault()
if not (modoptionDefaults and modoptionChanges) then
return
Expand All @@ -67,23 +67,23 @@ local function ProcessListOption(data, index)
font = WG.Chobby.Configuration:GetFont(2),
tooltip = data.desc,
}

local defaultItem = 1
local defaultKey = modoptionChanges[data.key] or data.def
local defaultKey = modoptionChanges[data.key] or data.def

local items = {}
local itemNameToKey = {}
local itemKeyToName = {}
for i, itemData in pairs(data.items) do
items[i] = itemData.name
itemNameToKey[itemData.name] = itemData.key
itemKeyToName[itemData.key] = itemData.name

if itemData.key == defaultKey then
defaultItem = i
end
end

local list = ComboBox:New {
x = 340,
y = 1,
Expand All @@ -102,7 +102,7 @@ local function ProcessListOption(data, index)
itemKeyToName = itemKeyToName -- Not a chili key
}
modoptionControlNames[data.key] = list

return Control:New {
x = 0,
y = index*32,
Expand All @@ -125,7 +125,7 @@ local function ProcessBoolOption(data, index)
elseif modoptionChanges[data.key] == "1" then
checked = true
end

local checkBox = Checkbox:New {
x = 5,
y = index*32,
Expand All @@ -137,20 +137,20 @@ local function ProcessBoolOption(data, index)
checked = checked,
font = WG.Chobby.Configuration:GetFont(2),
tooltip = data.desc,

OnChange = {
function (obj, newState)
modoptionLocalChanges[data.key] = tostring((newState and 1) or 0)
end
},
}
modoptionControlNames[data.key] = checkBox

return checkBox
end

local function ProcessNumberOption(data, index)

local label = Label:New {
x = 5,
y = 0,
Expand All @@ -162,9 +162,9 @@ local function ProcessNumberOption(data, index)
font = WG.Chobby.Configuration:GetFont(2),
tooltip = data.desc,
}

local oldText = modoptionChanges[data.key] or modoptionDefaults[data.key]

local numberBox = EditBox:New {
x = 340,
y = 1,
Expand All @@ -177,14 +177,14 @@ local function ProcessNumberOption(data, index)
if obj.focused then
return
end

local newValue = tonumber(obj.text)

if not newValue then
obj:SetText(oldText)
return
end

local places = 0
if data.step < 0.01 then
places = 3
Expand All @@ -193,26 +193,26 @@ local function ProcessNumberOption(data, index)
elseif data.step < 1 then
places = 3
end

-- Bound the number
newValue = math.min(data.max, math.max(data.min, newValue))
-- Round to step size
newValue = math.floor(newValue/data.step)*data.step + 0.01*data.step

-- Remove excess accuracy
oldText = string.format("%." .. places .. "f", newValue)
-- Remove trailing zeros
while oldText:find("%.") and (oldText:find("0", oldText:len()) or oldText:find("%.", oldText:len())) do
oldText = oldText:sub(0, oldText:len() - 1)
end

modoptionLocalChanges[data.key] = oldText
obj:SetText(oldText)
end
}
}
modoptionControlNames[data.key] = numberBox

return Control:New {
x = 0,
y = index*32,
Expand All @@ -227,7 +227,7 @@ local function ProcessNumberOption(data, index)
end

local function ProcessStringOption(data, index)

local label = Label:New {
x = 5,
y = 0,
Expand All @@ -239,9 +239,9 @@ local function ProcessStringOption(data, index)
font = WG.Chobby.Configuration:GetFont(2),
tooltip = data.desc,
}

local oldText = modoptionChanges[data.key] or modoptionDefaults[data.key]

local textBox = EditBox:New {
x = 340,
y = 1,
Expand All @@ -259,7 +259,7 @@ local function ProcessStringOption(data, index)
}
}
modoptionControlNames[data.key] = textBox

return Control:New {
x = 0,
y = index*32,
Expand All @@ -278,15 +278,15 @@ local function PopulateTab(options)
-- bool = tickbox
-- number = sliderbar (with label)
-- string = editBox

local contentsPanel = ScrollPanel:New {
x = 6,
right = 5,
y = 10,
bottom = 8,
horizontalScrollbar = false,
}

for i = 1, #options do
local data = options[i]
if data.type == "list" then
Expand Down Expand Up @@ -317,17 +317,28 @@ local function CreateModoptionWindow()
draggable = false,
classname = "main_window",
}

modoptionLocalChanges = Spring.Utilities.CopyTable(modoptionChanges)
modoptionControlNames = {}

local tabs = {}

local tabWidth = 120

for key, data in pairs(modoptionStructure.sections) do
local caption = modoptionStructure.sectionTitles[data.title] or data.title
local fontSize = 2
local tooltip = nil
local origCaption = caption
caption = StringUtilities.GetTruncatedStringWithDotDot(caption, Font:New(WG.Chobby.Configuration:GetFont(fontSize)), tabWidth)
if origCaption ~= caption then
tooltip = origCaption
end
tabs[#tabs + 1] = {
name = key,
caption = modoptionStructure.sectionTitles[data.title] or data.title,
font = WG.Chobby.Configuration:GetFont(2),
caption = caption,
tooltip = tooltip,
font = WG.Chobby.Configuration:GetFont(fontSize),
children = PopulateTab(data.options)
}
end
Expand All @@ -338,7 +349,7 @@ local function CreateModoptionWindow()
y = 49,
bottom = 75,
padding = {0, 0, 0, 0},
minTabWidth = 120,
minTabWidth = tabWidth,
tabs = tabs,
parent = modoptionsSelectionWindow,
OnTabChange = {
Expand Down Expand Up @@ -371,7 +382,7 @@ local function CreateModoptionWindow()
end

local buttonAccept

local function AcceptFunc()
screen0:FocusControl(buttonAccept) -- Defocus the text entry
battleLobby:SetModOptions(modoptionLocalChanges)
Expand All @@ -393,7 +404,7 @@ local function CreateModoptionWindow()
end
},
}

buttonAccept = Button:New {
right = 150,
width = 135,
Expand Down Expand Up @@ -459,7 +470,7 @@ local function InitializeModoptionsDisplay()
text = text .. "\255\120\120\120" .. tostring(key) .. " = \255\255\255\255" .. tostring(value) .. "\n"
empty = false
end

UpdateControlValue(key, value)
end
for key, value in pairs(modoptionChanges) do
Expand All @@ -468,7 +479,7 @@ local function InitializeModoptionsDisplay()
end
end
modoptionChanges = modoptions

lblText:SetText(text)

if mainScrollPanel.parent then
Expand Down
6 changes: 6 additions & 0 deletions libs/chiliui/luamenu/chili/api_chili.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ function widget:TextInput(utf8, ...)
return screen0:TextInput(utf8, ...)
end

function widget:TextEditing(utf8, start, length, ...)
if Spring.IsGUIHidden() then return false end

return screen0:TextEditing(utf8, start, length, ...)
end


function widget:ViewResize(vsx, vsy)
screen0:Resize(vsx, vsy)
Expand Down
Loading