Skip to content

Commit

Permalink
Merge pull request #420 from Spring-Chobby/master
Browse files Browse the repository at this point in the history
Up to date with chobby.
  • Loading branch information
GoogleFrog authored Dec 13, 2017
2 parents d0475a0 + 06eb16f commit efcb433
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 49 deletions.
5 changes: 4 additions & 1 deletion LuaMenu/configs/gameConfig/evorts/mainConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ local externalFuncAndData = {
--_defaultGameArchiveName = "??", fill this in.
_defaultGameRapidTag = "evo:stable", -- Do not read directly
editor = "rapid://sb-evo:test",
--editor = "SpringBoard EVO $VERSION",
--editor = "SpringBoard EVO $VERSION",
mapWhitelist = mapWhitelist,
aiBlacklist = aiBlacklist,
settingsConfig = settingsConfig,
Expand All @@ -45,10 +45,13 @@ local externalFuncAndData = {
rankFunction = rankFunction,
headingLarge = headingLarge,
headingSmall = headingSmall,
taskbarTitle = "Evolution RTS",
taskbarTitleShort = "Evo RTS",
taskbarIcon = taskbarIcon,
background = background,
minimapOverridePath = minimapOverridePath,
minimapThumbnailPath = minimapThumbnailPath,
ignoreServerVersion = true,
}

function externalFuncAndData.CheckAvailability()
Expand Down
16 changes: 9 additions & 7 deletions LuaMenu/configs/gameConfig/evortsdev/mainConfig.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local zkBaseConfig = VFS.Include(LUA_DIRNAME .. "configs/gameConfig/evorts/mainConfig.lua")
local evoBaseConfig = VFS.Include(LUA_DIRNAME .. "configs/gameConfig/evorts/mainConfig.lua")
local shortname = "evortsdev"

local skirmishDefault = VFS.Include(LUA_DIRNAME .. "configs/gameConfig/" .. shortname .. "/skirmishDefault.lua")
Expand All @@ -7,10 +7,12 @@ local skirmishDefault = VFS.Include(LUA_DIRNAME .. "configs/gameConfig/" .. s
-- Getters
---------------------------------------------------------------------------------

zkBaseConfig.dirName = "evortsdev"
zkBaseConfig.name = "EvoRTS Dev"
zkBaseConfig._defaultGameArchiveName = "Evolution RTS - $VERSION"
zkBaseConfig._defaultGameRapidTag = nil
zkBaseConfig.skirmishDefault = skirmishDefault
evoBaseConfig.dirName = "evortsdev"
evoBaseConfig.name = "EvoRTS Dev"
evoBaseConfig.taskbarTitle = "Evolution RTS Dev"
evoBaseConfig.taskbarTitleShort = "Evo RTS Dev"
evoBaseConfig._defaultGameArchiveName = "Evolution RTS - $VERSION"
evoBaseConfig._defaultGameRapidTag = nil
evoBaseConfig.skirmishDefault = skirmishDefault

return zkBaseConfig
return evoBaseConfig
7 changes: 5 additions & 2 deletions LuaMenu/configs/gameConfig/zk/mainConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,20 @@ local externalFuncAndData = {
headingLarge = headingLarge,
headingSmall = headingSmall,
subheadings = subheadings,
taskbarTitle = "Zero-K",
taskbarTitleShort = "Zero-K",
taskbarIcon = taskbarIcon,
background = background,
minimapOverridePath = minimapOverridePath,
minimapThumbnailPath = minimapThumbnailPath,
gameUnitInformation = gameUnitInformation,
link_reportPlayer = link_reportPlayer,
link_userPage = link_userPage,
link_reportPlayer = link_reportPlayer,
link_userPage = link_userPage,
link_homePage = link_homePage,
link_replays = link_replays,
link_maps = link_maps,
link_particularMapPage = link_particularMapPage,
ignoreServerVersion = false,
}

function externalFuncAndData.CheckAvailability()
Expand Down
2 changes: 2 additions & 0 deletions LuaMenu/configs/gameConfig/zkdev/mainConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ local skirmishDefault = VFS.Include(LUA_DIRNAME .. "configs/gameConfig/" .. s

zkBaseConfig.dirName = "zkdev"
zkBaseConfig.name = "Zero-K Dev"
zkBaseConfig.taskbarTitle = "Zero-K Dev"
zkBaseConfig.taskbarTitleShort = "Zero-K Dev"
zkBaseConfig._defaultGameArchiveName = "Zero-K $VERSION"
zkBaseConfig._defaultGameRapidTag = nil
zkBaseConfig.singleplayerConfig = singleplayerConfig
Expand Down
45 changes: 22 additions & 23 deletions LuaMenu/widgets/api_download_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ end

local function DownloadQueueUpdate()
requestUpdate = false

if #downloadQueue == 0 then
CallListeners("DownloadQueueUpdate", downloadQueue, removedDownloads)
return
end
table.sort(downloadQueue, DownloadSortFunc)

local front = downloadQueue[1]
if not front.active then
if USE_WRAPPER_DOWNLOAD and WG.WrapperLoopback then
Expand All @@ -109,7 +109,7 @@ local function DownloadQueueUpdate()
end
front.active = true
end

CallListeners("DownloadQueueUpdate", downloadQueue, removedDownloads)
end

Expand Down Expand Up @@ -156,13 +156,13 @@ local function RemoveDownload(name, fileType, putInRemoveList, removalType)
if not index then
return false
end

if removalType == "success" then
CallListeners("DownloadFinished", downloadQueue[index].id, name, fileType)
else
CallListeners("DownloadFailed", downloadQueue[index].id, removalType, name, fileType)
end

if putInRemoveList then
downloadQueue[index].removalType = removalType
removedDownloads[#removedDownloads + 1] = downloadQueue[index]
Expand All @@ -182,11 +182,11 @@ function externalFunctions.QueueDownload(name, fileType, priority)
if priority == -1 then
priority = topPriority + 1
end

if topPriority < priority then
topPriority = priority
end

local index = GetDownloadIndex(downloadQueue, name, fileType)
if index then
local data = downloadQueue[index]
Expand All @@ -196,7 +196,7 @@ function externalFunctions.QueueDownload(name, fileType, priority)
end
return
end

downloadCount = downloadCount + 1
downloadQueue[#downloadQueue + 1] = {
name = name,
Expand All @@ -213,7 +213,7 @@ function externalFunctions.SetDownloadTopPriority(name, fileType)
if not index then
return
end

topPriority = topPriority + 1
downloadQueue[index].priority = topPriority
requestUpdate = true
Expand All @@ -225,15 +225,15 @@ function externalFunctions.CancelDownload(name, fileType)
if not index then
return false
end

if downloadQueue[index].active then
WG.WrapperLoopback.AbortDownload(name, typeMap[fileType])
return
end

downloadQueue[index].removalType = "cancel"
removedDownloads[#removedDownloads + 1] = downloadQueue[index]

downloadQueue[index] = downloadQueue[#downloadQueue]
downloadQueue[#downloadQueue] = nil
requestUpdate = true
Expand All @@ -244,7 +244,7 @@ function externalFunctions.RetryDownload(name, fileType)
if not index then
return false
end

externalFunctions.QueueDownload(name, fileType, removedDownloads[index].priority)
removedDownloads[index] = removedDownloads[#removedDownloads]
removedDownloads[#removedDownloads] = nil
Expand All @@ -257,7 +257,7 @@ function externalFunctions.RemoveRemovedDownload(name, fileType)
if not index then
return false
end

removedDownloads[index] = removedDownloads[#removedDownloads]
removedDownloads[#removedDownloads] = nil
requestUpdate = true
Expand Down Expand Up @@ -286,7 +286,7 @@ function wrapperFunctions.DownloadFinished(name, fileType, success, aborted)
end
RemoveDownload(name, fileType, true, (aborted and "cancel") or (success and "success") or "fail")
end

--Chotify:Post({
-- title = "Download " .. ((success and "Finished") or "Failed"),
-- body = (name or "???") .. " of type " .. (fileType or "???"),
Expand All @@ -298,7 +298,7 @@ function wrapperFunctions.DownloadFileProgress(name, fileType, progress, seconds
if not index then
return
end

totalLength = (tonumber(totalLength or 0) or 0)/1023^2
CallListeners("DownloadProgress", downloadQueue[index].id, totalLength*math.min(1, (tonumber(progress or 0) or 0)/100), totalLength, name)
end
Expand All @@ -318,8 +318,7 @@ function widget:DownloadProgress(downloadID, downloaded, total)
if not index then
return
end

CallListeners("DownloadProgress", downloadQueue[index].id, downloaded, total)
CallListeners("DownloadProgress", downloadQueue[index].id, downloaded, total, downloadQueue[index].name)
end

function widget:DownloadStarted(downloadID)
Expand All @@ -328,7 +327,7 @@ function widget:DownloadStarted(downloadID)
return
end
local data = downloadQueue[index]

CallListeners("DownloadStarted", data.id, data.name, data.fileType)
end

Expand All @@ -338,7 +337,7 @@ function widget:DownloadFinished(downloadID)
return
end
local data = downloadQueue[index]

RemoveDownload(data.name, data.fileType, true, "success")
end

Expand All @@ -348,7 +347,7 @@ function widget:DownloadFailed(downloadID, errorID)
return
end
local data = downloadQueue[index]

RemoveDownload(data.name, data.fileType, true, "fail")
end

Expand Down Expand Up @@ -379,7 +378,7 @@ local function GetRequiredDownloads()
externalFunctions.MaybeDownloadArchive(campaignStartMaps[i], "map", 1.5)
end
end

local skirmishPages = Configuration.gameConfig and Configuration.gameConfig.skirmishSetupData and Configuration.gameConfig.skirmishSetupData.pages
if skirmishPages then
for i = 1, #skirmishPages do
Expand All @@ -398,7 +397,7 @@ WG.DownloadHandler = externalFunctions
function widget:Initialize()
CHOBBY_DIR = LUA_DIRNAME .. "widgets/chobby/"
VFS.Include(LUA_DIRNAME .. "widgets/chobby/headers/exports.lua", nil, VFS.RAW_FIRST)

WG.DownloadWrapperInterface = wrapperFunctions
WG.Delay(GetRequiredDownloads, 1)
end
4 changes: 4 additions & 0 deletions LuaMenu/widgets/chobby/components/ai_list_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ function AiListWindow:AddAi(displayName, shortName, version)
while found do
found = false
aiName = displayName .. " (" .. tostring(counter) .. ")"
-- Ubserver AI names cannot include whitespace
if WG.Server.protocol == "spring" then
aiName = aiName:gsub(" ", "")
end
for _, userName in pairs(self.lobby.battleAis) do
if aiName == userName then
found = true
Expand Down
2 changes: 1 addition & 1 deletion LuaMenu/widgets/chobby/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Chobby:_Initialize()
WG.Delay(function()
lobby:AddListener("OnSuggestedEngineVersion",
function(listener, engineName)
if engineName and not WG.Chobby.Configuration:IsValidEngineVersion(engineName) then
if engineName and not WG.Chobby.Configuration.gameConfig.ignoreServerVersion and not WG.Chobby.Configuration:IsValidEngineVersion(engineName) then
WG.Chobby.InformationPopup("Wrong Spring engine version. The required version is '" .. engineName .. "', your version is '" .. Spring.Utilities.GetEngineVersion() .. "'.\n\nRestart the game to get the correct version.", 480, 248)
end
end
Expand Down
24 changes: 15 additions & 9 deletions LuaMenu/widgets/gui_battle_room_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
local downloader = WG.Chobby.Downloader(false, downloaderPos, 8, nil, nil, nil, OnDownloaderVisibility)
leftOffset = leftOffset + 120


-- Example downloads
--MaybeDownloadArchive("Titan-v2", "map")
--MaybeDownloadArchive("tinyskirmishredux1.1", "map")
Expand Down Expand Up @@ -479,7 +479,7 @@ local function SetupInfoButtonsPanel(leftInfo, rightInfo, battle, battleID, myUs
lblHaveMap:SetPos(nil, offset)
end
externalFunctions.UpdateBattleMode(battle.disallowCustomTeams)

function externalFunctions.SetHaveGame(newHaveGame)
if newHaveGame then
imHaveGame.file = IMG_READY
Expand Down Expand Up @@ -1258,7 +1258,7 @@ local function InitializeSetupPage(subPanel, screenHeight, pageConfig, nextPage,
buttonHeight = 56
buttonFont = 4
end

subPanel:SetVisibility(not prevPage)

local lblBattleTitle = Label:New {
Expand Down Expand Up @@ -1318,7 +1318,7 @@ local function InitializeSetupPage(subPanel, screenHeight, pageConfig, nextPage,
},
parent = subPanel,
}

if prevPage then
Button:New {
x = "5%",
Expand All @@ -1337,7 +1337,7 @@ local function InitializeSetupPage(subPanel, screenHeight, pageConfig, nextPage,
parent = subPanel,
}
end

for i = 1, #pageConfig.options do
local x, y, right, height, caption, tooltip
if pageConfig.minimap then
Expand Down Expand Up @@ -1416,7 +1416,7 @@ local function SetupEasySetupPanel(mainWindow, standardSubPanel, setupData)

local _, screenHeight = Spring.GetWindowGeometry()
local panelOffset = math.max(8, math.min(60, ((screenHeight - 768)*0.16 + 8)))

local pages = {}
for i = 1, #pageConfigs do
pages[i] = Control:New {
Expand All @@ -1428,7 +1428,7 @@ local function SetupEasySetupPanel(mainWindow, standardSubPanel, setupData)
parent = mainWindow,
}
end

for i = 1, #pages do
InitializeSetupPage(pages[i], screenHeight, pageConfigs[i], pages[i + 1], pages[i - 1], selectedOptions, ApplyFunction)
end
Expand Down Expand Up @@ -1587,7 +1587,13 @@ local function InitializeControls(battleID, oldLobby, topPoportion, setupData)
return
end
if Configuration:IsValidEngineVersion(battle.engineVersion) then
battleTitle = i18n(Configuration.battleTypeToName[battle.battleMode]) .. ": " .. tostring(battle.title)
local battleTypeName = Configuration.battleTypeToName[battle.battleMode]
if battleTypeName then
battleTitle = i18n(battleTypeName) .. ": " .. tostring(battle.title)
else
battleTitle = tostring(battle.title)
end

local truncatedTitle = StringUtilities.GetTruncatedStringWithDotDot(battleTitle, lblBattleTitle.font, lblBattleTitle.width)
lblBattleTitle:SetCaption(truncatedTitle)
else
Expand Down Expand Up @@ -1925,7 +1931,7 @@ function widget:Initialize()
UpdateArchiveStatus(true)
end
WG.DownloadHandler.AddListener("DownloadFinished", downloadFinished)

WG.BattleRoomWindow = BattleRoomWindow
end

Expand Down
11 changes: 10 additions & 1 deletion LuaMenu/widgets/gui_chili_lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ function widget:Initialize()
Chobby.lobbyInterfaceHolder = lobbyInterfaceHolder
Chobby.interfaceRoot = interfaceRoot

Spring.SetWMCaption("Zero-K", "Zero-K")
local taskbarTitle = Chobby.Configuration.gameConfig.taskbarTitle
local taskbarTitleShort = Chobby.Configuration.gameConfig.taskbarTitleShort or taskbarTitle
if taskbarTitle then
Spring.SetWMCaption(taskbarTitle, taskbarTitleShort)
end
local taskbarIcon = Chobby.Configuration.gameConfig.taskbarIcon
if taskbarIcon then
Spring.SetWMIcon(taskbarIcon)
Expand All @@ -95,6 +99,11 @@ function widget:Initialize()

local function onConfigurationChange(listener, key, value)
if key == "gameConfigName" then
local taskbarTitle = Chobby.Configuration.gameConfig.taskbarTitle
local taskbarTitleShort = Chobby.Configuration.gameConfig.taskbarTitleShort or taskbarTitle
if taskbarTitle then
Spring.SetWMCaption(taskbarTitle, taskbarTitleShort)
end
local taskbarIcon = Chobby.Configuration.gameConfig.taskbarIcon
if taskbarIcon then
Spring.SetWMIcon(taskbarIcon)
Expand Down
Loading

0 comments on commit efcb433

Please sign in to comment.