Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Hotbuild fixes #2039

Merged
merged 3 commits into from Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 22 additions & 29 deletions lua/keymap/hotbuild.lua
Expand Up @@ -14,8 +14,6 @@ local Bitmap = import('/lua/maui/bitmap.lua').Bitmap
local LayoutHelpers = import('/lua/maui/layouthelpers.lua')
local Effect = import('/lua/maui/effecthelpers.lua')

local upgradeTab = import('/lua/keymap/upgradeTab.lua').upgradeTab

local unitkeygroups
local cyclePos
local cycleThread = false
Expand Down Expand Up @@ -57,7 +55,7 @@ function initCycleMap()
cycleMap.Width:Set(400)
cycleMap.Height:Set(150)
cycleMap.Top:Set(function() return GetFrame(0).Bottom()*.75 end)
cycleMap.Left:Set(function() return (GetFrame(0).Right()-cycleMap.Width())/2 end)
cycleMap.Left:Set(function() return (GetFrame(0).Right()-cycleMap.Width())/2 end)
cycleMap:DisableHitTest()
cycleMap:Hide()

Expand Down Expand Up @@ -181,7 +179,7 @@ function buildAction(name)
local selection = GetSelectedUnits()
if selection then
-- If current selection is engineer or commander
if table.getsize(EntityCategoryFilterDown(categories.ENGINEER, selection)) > 0 then
if table.getsize(EntityCategoryFilterDown(categories.ENGINEER - categories.STRUCTURE, selection)) > 0 then
buildActionBuilding(name, modifier)
else -- Buildqueue or normal applying all the command
buildActionUnit(name, modifier)
Expand Down Expand Up @@ -245,9 +243,9 @@ function buildActionBuilding(name, modifier)
cycleMap:Show()
-- Start the fading thread
cycleThread = ForkThread(function()
local stayTime = options.hotbuild_cycle_reset_time / 2000.0
local fadeTime = options.hotbuild_cycle_reset_time / 2000.0
WaitSeconds(stayTime)
local stayTime = options.hotbuild_cycle_reset_time / 2000.0
local fadeTime = options.hotbuild_cycle_reset_time / 2000.0
WaitSeconds(stayTime)
if (not cycleMap:IsHidden()) then
Effect.FadeOut(cycleMap, fadeTime, 0.6, 0.1)
end
Expand All @@ -256,7 +254,7 @@ function buildActionBuilding(name, modifier)
end)
else
cycleThread = ForkThread(function()
WaitSeconds(options.hotbuild_cycle_reset_time / 1000.0)
WaitSeconds(options.hotbuild_cycle_reset_time / 1000.0)
cyclePos = 0
end)
end
Expand Down Expand Up @@ -378,18 +376,18 @@ function buildActionTemplate(modifier)
cycleMap:Show()
-- Start the fading thread
cycleThread = ForkThread(function()
local stayTime = options.hotbuild_cycle_reset_time / 2000.0
local fadeTime = options.hotbuild_cycle_reset_time / 2000.0
WaitSeconds(stayTime)
if not cycleMap:IsHidden() then
local stayTime = options.hotbuild_cycle_reset_time / 2000.0
local fadeTime = options.hotbuild_cycle_reset_time / 2000.0
WaitSeconds(stayTime)
if not cycleMap:IsHidden() then
Effect.FadeOut(cycleMap, fadeTime, 0.6, 0.1)
end
WaitSeconds(fadeTime)
cyclePos = 0
end)
else
cycleThread = ForkThread(function()
WaitSeconds(options.hotbuild_cycle_reset_time / 1000.0)
WaitSeconds(options.hotbuild_cycle_reset_time / 1000.0)
cyclePos = 0
end)
end
Expand Down Expand Up @@ -453,8 +451,8 @@ function buildActionUnit(name, modifier)
end

for i, v in values do
if v == '_upgrade' then
return buildActionUpgrade()
if v == '_upgrade' and buildActionUpgrade() then
return
end
end
local count = 1
Expand All @@ -479,24 +477,19 @@ end
function buildActionUpgrade()
local selectedUnits = GetSelectedUnits()
local availableOrders, availableToggles, buildableCategories = GetUnitCommandData(selectedUnits)
local bpTypes = {}
local result = true

for index, unit in selectedUnits do
local bpId = unit:GetBlueprint().BlueprintId
local cmd = upgradeTab[bpId]
local bp = unit:GetBlueprint()
local cmd = bp.General.UpgradesTo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this wont break upgrades of factories to support/HQ factories?

Currently a t1 factory upgrades to a support factory as long as there is an HQ factory and directly to an HQ when there is none.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it actually does break that. If that functionality is to be preserved I'll also need to change the hotkey label code. It puts the upgrade key label on the HQ, yet pressing the key builds the support factory.


SelectUnits({unit})
if type(cmd) == "table" then -- Issue the first upgrade command that we may build
for k,v in cmd do
if EntityCategoryContains(buildableCategories, v) then
IssueBlueprintCommand("UNITCOMMAND_Upgrade", v, 1, false)
break
end
end
elseif type(cmd) == "string" then -- Direct upgrade path
if EntityCategoryContains(buildableCategories, cmd) then
IssueBlueprintCommand("UNITCOMMAND_Upgrade", cmd, 1, false)
end
if cmd and EntityCategoryContains(buildableCategories, cmd) then
IssueBlueprintCommand("UNITCOMMAND_Upgrade", cmd, 1, false)
else
result = false
end
end
SelectUnits(selectedUnits)
return result
end
7 changes: 7 additions & 0 deletions lua/keymap/unitkeygroups.lua
Expand Up @@ -174,6 +174,7 @@ unitkeygroups = {
},
["Upgrades"] = {
"_upgrade",
"T3_Mobile_AA",
"T3_Heavy_Air_Transport",
"T3_Torpedo_Bomber",
},
Expand Down Expand Up @@ -557,6 +558,12 @@ unitkeygroups = {
"uel0205",
"url0205",
},
["T3_Mobile_AA"] = {
"dalk003",
"delk002",
"drlk001",
"dslk004",
},
["T2_Engineer"] = {
"ual0208",
"uel0208",
Expand Down
88 changes: 0 additions & 88 deletions lua/keymap/upgradetab.lua

This file was deleted.