Skip to content

Commit

Permalink
Show factory queue on rollover (#3597)
Browse files Browse the repository at this point in the history
* add show factory queue on rollover

* refresh factory queue after new build order

* Fix bug when selected unit prevents displaying of queue on rollover

* Improve check for build queue on hovering

* Add game option and update localization files

* Add game option support for feature

* added queue background textures

* code reworking

* Revert "code reworking"

This reverts commit 89a65f0.

* loc for option

* change display behavior

* replaced Grid with custom implementation

* fix merge commit

* fix merge

* Hittest fix

* added avatar bg for other factions

* Added brackets

* fix unit icon overflow

* Make option dynamic (do not require restart)

* Turn option on by default

Co-authored-by: Willem Bart Wijnia <w.b.wijnia@gmail.com>
Co-authored-by: Adjax <aigiz.iskuzhin@yandex.ru>
  • Loading branch information
3 people committed Dec 11, 2021
1 parent 819f02e commit df4bfea
Show file tree
Hide file tree
Showing 25 changed files with 174 additions and 4 deletions.
2 changes: 2 additions & 0 deletions loc/CN/strings_db.lua
Expand Up @@ -7515,8 +7515,10 @@ OPTIONS_0242="总是显示自定义名称"
OPTIONS_0243="渲染敌方单位生命条"
OPTIONS_0244="在建造菜单中显示武器的详细信息"
OPTIONS_0245="更好的取消命令"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="为快捷键启用周期预览"
OPTIONS_0248="当它打开时,你可以预览快捷键的周期"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="周期复位时间"
OPTIONS_0252="时间精确到毫秒,一直到快捷键被重置"
OPTIONS_0253="用更好的图标取代默认的图标"
Expand Down
2 changes: 2 additions & 0 deletions loc/CZ/strings_db.lua
Expand Up @@ -1383,8 +1383,10 @@ OPTIONS_0242="Always Render Custom Names"
OPTIONS_0243="Force Render Enemy Lifebars"
OPTIONS_0244="Show Armament Detail in Build Menu"
OPTIONS_0245="Improved Unit deselection"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Enable Cycle Preview for Hotbuild"
OPTIONS_0248="When on, you can cycle the Hotbuild preview"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Cycle reset time"
OPTIONS_0252="Time in milliseconds until hotbuild cycle will reset"
OPTIONS_0253="Replaces the default strategic build icons with something more visible."
Expand Down
2 changes: 2 additions & 0 deletions loc/DE/strings_db.lua
Expand Up @@ -1382,8 +1382,10 @@ OPTIONS_0242="Einheiten Namen immer anzeigen"
OPTIONS_0243="Gegnerische Lebensbalken erzwingen"
OPTIONS_0244="Zeige Bewaffnungsdetails im Bau Menü"
OPTIONS_0245="Erweiterte Einheiten Abwahl"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Ermögliche Wechsel für Hotbuild Vorschau"
OPTIONS_0248="Wenn eingeschaltet kann die Hotbuildvorschau durch mehrmaliges drücken der Hotbuildtaste gewechselt werden"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Rotations Rückstellzeit"
OPTIONS_0252="Zeit in Millisekunden bis Hotbuildauswahl zurückgesetzt wird"
OPTIONS_0253="Ersetzt die strategischen Standard Bau Icons gegen Größere die besser zu sehen sind."
Expand Down
2 changes: 2 additions & 0 deletions loc/ES/strings_db.lua
Expand Up @@ -1366,8 +1366,10 @@ OPTIONS_0242="Permitir Siempre Nombres Personalizados"
OPTIONS_0243="Forzar Aparición de Barras de Vida Enemigas"
OPTIONS_0244="Mostrar Detalles del Armamento en el Menú de Construcción"
OPTIONS_0245="Deselección de Unidades Mejorado"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Activa la Previsualización Cíclica de los Atajos de Construcción"
OPTIONS_0248="Cuando está activado, puedes pasar en ciclo la previsualización de los Atajos de Construcción"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Tiempo de Reinicio del Ciclo"
OPTIONS_0252="Tiempo en milisegundos hasta que el ciclo de atajos de construcción se reinicie"
OPTIONS_0253="Reemplaza los iconos estratégicos de construcción por defecto con unos más fáciles de ver."
Expand Down
2 changes: 2 additions & 0 deletions loc/FR/strings_db.lua
Expand Up @@ -7653,8 +7653,10 @@ OPTIONS_0243 = "Forcer l'affichage des barres de vie ennemies"
OPTIONS_0244 = "Détails dans les menus de construction"
tooltipui0692 = "Affiche des informations détaillées sur les capacités de l'unité dans le menu de construction"
OPTIONS_0245 = "Utiliser la dé-selection améliorée d'unité"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Afficher le menu des prédéfinis"
OPTIONS_0248="Active un menu qui permet de parcourir les prédéfinis avec la touche rapide associée"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Persistence du menu des prédef."
OPTIONS_0252="Durée avant réinitialisation du curseur du menu des prédéfinis"
OPTIONS_0253="Remplace les icônes stratégiques de construction standard par des versions plus grandes et lisibles"
Expand Down
2 changes: 2 additions & 0 deletions loc/IT/strings_db.lua
Expand Up @@ -7794,8 +7794,10 @@ OPTIONS_0243 = "Forzare la visualizzazione delle barre di vita delle unità nemi
OPTIONS_0244 = "Mostra i dettagli dell'armamento nel menu di costruzione"
tooltipui0692 = "Mostra informazioni dettagliate sulle armi delle unità dal menu di costruzione"
OPTIONS_0245 = "Migliora la desezione delle unità"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Enable Cycle Preview for Hotbuild"
OPTIONS_0248="When on, you can cycle the Hotbuild preview"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Cycle reset time"
OPTIONS_0252="Time in milliseconds until hotbuild cycle will reset"
OPTIONS_0253="Replaces the default strategic build icons with something more visible."
Expand Down
2 changes: 2 additions & 0 deletions loc/PL/strings_db.lua
Expand Up @@ -1383,8 +1383,10 @@ OPTIONS_0242="Always Render Custom Names"
OPTIONS_0243="Force Render Enemy Lifebars"
OPTIONS_0244="Show Armament Detail in Build Menu"
OPTIONS_0245="Improved Unit deselection"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Enable Cycle Preview for Hotbuild"
OPTIONS_0248="When on, you can cycle the Hotbuild preview"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Cycle reset time"
OPTIONS_0252="Time in milliseconds until hotbuild cycle will reset"
OPTIONS_0253="Replaces the default strategic build icons with something more visible."
Expand Down
2 changes: 2 additions & 0 deletions loc/RU/strings_db.lua
Expand Up @@ -8595,8 +8595,10 @@ OPTIONS_0242="Всегда показывать имена"
OPTIONS_0243="Показывать вражеские индикаторы жизни"
OPTIONS_0244="Показывать вооружение в строит-ом меню"
OPTIONS_0245="Улучшенный сброс выбранных юнитов"
OPTIONS_0246="Отображать очередь строительства фабрики"
OPTIONS_0247="Включить зацикленность предварительного просмотра для Hotbuild"
OPTIONS_0248="Когда включено, вы можете зациклить предварительной просмотр Hotbuild"
OPTIONS_0249="Отображает над описанием фабрики ее очередь строительства при наведении на нее мышкой"
OPTIONS_0251="Время сброса цикла"
OPTIONS_0252="Время в миллисекундах, по истечению которого цикл Hotbuild сбрасывается"
OPTIONS_0253="Заменить все стандартные иконки техники и сооружений на что-то более видимое."
Expand Down
2 changes: 2 additions & 0 deletions loc/TW/strings_db.lua
Expand Up @@ -7516,8 +7516,10 @@ OPTIONS_0242="Always Render Custom Names"
OPTIONS_0243="Force Render Enemy Lifebars"
OPTIONS_0244="Show Armament Detail in Build Menu"
OPTIONS_0245="Improved Unit deselection"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Enable Cycle Preview for Hotbuild"
OPTIONS_0248="When on, you can cycle the Hotbuild preview"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Cycle reset time"
OPTIONS_0252="Time in milliseconds until hotbuild cycle will reset"
OPTIONS_0253="Replaces the default strategic build icons with something more visible."
Expand Down
2 changes: 2 additions & 0 deletions loc/TZM/strings_db.lua
Expand Up @@ -7779,8 +7779,10 @@ OPTIONS_0243 = "Force Render Enemy Lifebars"
OPTIONS_0244 = "Show Armament Detail in Build Umuɣ"
tooltipui0692 = "Shows detailed information about the weapons a unit has from the build menu"
OPTIONS_0245 = "Improved Unit deselection"
OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Enable Cycle Preview for Hotbuild"
OPTIONS_0248="When on, you can cycle the Hotbuild preview"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Cycle reset time"
OPTIONS_0252="Time in milliseconds until hotbuild cycle will reset"
OPTIONS_0253="Replaces the default strategic build icons with something more visible."
Expand Down
3 changes: 2 additions & 1 deletion loc/US/strings_db.lua
Expand Up @@ -7489,9 +7489,10 @@ OPTIONS_0242 = "Always Render Custom Names"
OPTIONS_0243 = "Force Render Enemy Lifebars"
OPTIONS_0244 = "Show Armament Detail in Build Menu"
OPTIONS_0245 = "Improved Unit deselection"

OPTIONS_0246 = "Show Factory Queue on Hover"
OPTIONS_0247="Enable Cycle Preview for Hotbuild"
OPTIONS_0248="When on, you can cycle the Hotbuild preview"
OPTIONS_0249="Shows Factory queue above unit description when hover over unit with mouse"
OPTIONS_0251="Cycle reset time"
OPTIONS_0252="Time in milliseconds until hotbuild cycle will reset"
OPTIONS_0253="Replaces the default strategic build icons with something more visible."
Expand Down
1 change: 1 addition & 0 deletions lua/keymap/hotbuild.lua
Expand Up @@ -566,6 +566,7 @@ function buildActionUnit(name, modifier)

if maxPos == 1 then
IssueBlueprintCommand("UNITCOMMAND_BuildFactory", unit, count)
Construction.RefreshUI()
else
factoryHotkey(unit, count)
end
Expand Down
15 changes: 15 additions & 0 deletions lua/options/options.lua
Expand Up @@ -540,6 +540,19 @@ options = {
},
},

{
title = "<LOC OPTIONS_0246>Show Factory Queue on Hover",
key = 'gui_queue_on_hover',
type = 'toggle',
default = 1,
custom = {
states = {
{text = "<LOC _Off>", key = 0 },
{text = "<LOC _On>", key = 1 },
},
},
},

{
title = "<LOC OPTIONS_0232>Middle Click Avatars",
key = 'gui_idle_engineer_avatars',
Expand Down Expand Up @@ -604,6 +617,8 @@ options = {
},
},



{
title = "<LOC OPTIONS_0238>Seperate Idle Builders",
key = 'gui_seperate_idle_builders',
Expand Down
2 changes: 1 addition & 1 deletion lua/ui/dialogs/options.lua
Expand Up @@ -3,7 +3,7 @@
--* Author: Chris Blackwell
--* Summary: Manages the options dialog
--*
--* Copyright 2006 Gas Powered Games, Inc. All rights reserved.
--* Copyright 2006 Gas Powered Games, Inc. All rights reserved.
--*****************************************************************************

local UIUtil = import('/lua/ui/uiutil.lua')
Expand Down
3 changes: 3 additions & 0 deletions lua/ui/game/construction.lua
Expand Up @@ -1130,6 +1130,7 @@ function OnRolloverHandler(button, state)
count = 5
end
IncreaseBuildCountInQueue(item.position, count)
RefreshUI()
end
if self.dragMarker then
self.dragMarker:Destroy()
Expand Down Expand Up @@ -1552,10 +1553,12 @@ function OnClickHandler(button, modifiers)

if modifiers.Left then
IncreaseBuildCountInQueue(item.position, count)

elseif modifiers.Right then
DecreaseBuildCountInQueue(item.position, count)
end
end
RefreshUI()

This comment has been minimized.

Copy link
@Garanas

Garanas Dec 20, 2021

Author Member

This refresh prevents the template menu from opening. Without it, the template window opens just fine when right clicking. With it, it no longer works.

end

local warningtext = false
Expand Down
61 changes: 60 additions & 1 deletion lua/ui/game/layouts/unitview_mini.lua
Expand Up @@ -24,12 +24,71 @@ local iconTextures = {
UIUtil.UIFile('/game/unit_view_icons/fuel.dds'),
UIUtil.UIFile('/game/unit_view_icons/build.dds'),
}

function SetLayout()
local controls = import('/lua/ui/game/unitview.lua').controls

controls.bg:SetTexture(UIUtil.UIFile('/game/unit-build-over-panel/build-over-back_bmp.dds'))
LayoutHelpers.AtLeftIn(controls.bg, controls.parent)
LayoutHelpers.AtBottomIn(controls.bg, controls.parent)

controls.queue.bg:SetTexture(UIUtil.UIFile('/game/unit-build-over-panel/queue_back.dds'))

LayoutHelpers.SetDimensions(controls.queue, 316, 48)
LayoutHelpers.Above(controls.queue, controls.bg, 10)
LayoutHelpers.AtLeftIn(controls.queue, controls.bg, 3)

LayoutHelpers.FillParent(controls.queue.bg, controls.queue)
LayoutHelpers.FillParent(controls.queue.grid, controls.queue)

controls.queue:DisableHitTest()
controls.queue.grid:DisableHitTest()
controls.queue.bg:DisableHitTest()

for id, item in controls.queue.grid.items do
if id > 1 then
local before = controls.queue.grid.items[id-1]
LayoutHelpers.RightOf(item, before, -6)
else
LayoutHelpers.AtLeftTopIn(item, controls.queue.grid, 2)
end
item:DisableHitTest()
item:SetTexture(UIUtil.UIFile('/game/avatar-factory-panel/avatar-s-e-f_bmp.dds'))
LayoutHelpers.DepthOverParent(item.icon, item)
LayoutHelpers.FillParentFixedBorder(item.icon, item, 8)
LayoutHelpers.DepthOverParent(item.text, item.icon)
LayoutHelpers.AtRightBottomIn(item.text, item, 4, 4)
end

controls.queue.bg.leftBracket:SetTexture(UIUtil.UIFile('/game/filter-ping-panel/bracket-left_bmp.dds'))

controls.queue.bg.leftGlowTop:SetTexture(UIUtil.UIFile('/game/bracket-left-energy/bracket_bmp_t.dds'))
controls.queue.bg.leftGlowMiddle:SetTexture(UIUtil.UIFile('/game/bracket-left-energy/bracket_bmp_m.dds'))
controls.queue.bg.leftGlowBottom:SetTexture(UIUtil.UIFile('/game/bracket-left-energy/bracket_bmp_b.dds'))

controls.queue.bg.rightGlowTop:SetTexture(UIUtil.UIFile('/game/bracket-right-energy/bracket_bmp_t.dds'))
controls.queue.bg.rightGlowMiddle:SetTexture(UIUtil.UIFile('/game/bracket-right-energy/bracket_bmp_m.dds'))
controls.queue.bg.rightGlowBottom:SetTexture(UIUtil.UIFile('/game/bracket-right-energy/bracket_bmp_b.dds'))

LayoutHelpers.AtTopIn(controls.queue.bg.leftBracket, controls.queue.bg, -4)
LayoutHelpers.AnchorToLeft(controls.queue.bg.leftBracket, controls.queue.bg, -6)
LayoutHelpers.SetHeight(controls.queue.bg.leftBracket, 54)
controls.queue.bg.leftBracket.Depth:Set(function() return controls.queue.bg.Depth() + 10 end)

LayoutHelpers.AtTopIn(controls.queue.bg.leftGlowTop, controls.queue.bg, -4)
LayoutHelpers.AnchorToLeft(controls.queue.bg.leftGlowTop, controls.queue.bg, -10)
LayoutHelpers.AtBottomIn(controls.queue.bg.leftGlowBottom, controls.queue.bg, -4)
controls.queue.bg.leftGlowBottom.Left:Set(controls.queue.bg.leftGlowTop.Left)
controls.queue.bg.leftGlowMiddle.Top:Set(controls.queue.bg.leftGlowTop.Bottom)
controls.queue.bg.leftGlowMiddle.Bottom:Set(function() return math.max(controls.queue.bg.leftGlowTop.Bottom(), controls.queue.bg.leftGlowBottom.Top()) end)
controls.queue.bg.leftGlowMiddle.Left:Set(function() return controls.queue.bg.leftGlowTop.Left() end)

LayoutHelpers.AtTopIn(controls.queue.bg.rightGlowTop, controls.queue.bg, -4)
LayoutHelpers.AnchorToRight(controls.queue.bg.rightGlowTop, controls.queue.bg, -8)
LayoutHelpers.AtBottomIn(controls.queue.bg.rightGlowBottom, controls.queue.bg, -4)
controls.queue.bg.rightGlowBottom.Left:Set(controls.queue.bg.rightGlowTop.Left)
controls.queue.bg.rightGlowMiddle.Top:Set(controls.queue.bg.rightGlowTop.Bottom)
controls.queue.bg.rightGlowMiddle.Bottom:Set(function() return math.max(controls.queue.bg.rightGlowTop.Bottom(), controls.queue.bg.rightGlowBottom.Top()) end)
controls.queue.bg.rightGlowMiddle.Right:Set(function() return controls.queue.bg.rightGlowTop.Right() end)

controls.bracket:SetTexture(UIUtil.UIFile('/game/unit-build-over-panel/bracket-unit_bmp.dds'))
LayoutHelpers.AtLeftTopIn(controls.bracket, controls.bg, -18, -2)
Expand Down
69 changes: 68 additions & 1 deletion lua/ui/game/unitview.lua
Expand Up @@ -21,6 +21,8 @@ local options = Prefs.GetFromCurrentProfile('options')
local GetUnitRolloverInfo = import("/lua/keymap/selectedinfo.lua").GetUnitRolloverInfo
local unitViewLayout = import(UIUtil.GetLayoutFilename('unitview'))
local unitviewDetail = import('/lua/ui/game/unitviewDetail.lua')
local Grid = import('/lua/maui/grid.lua').Grid
local Construction = import('/lua/ui/game/construction.lua')

local selectedUnit = nil
local updateThread = nil
Expand All @@ -30,6 +32,8 @@ controls = import('/lua/ui/controls.lua').Get()
-- shared between sim and ui
local OverchargeShared = import('/lua/shared/overcharge.lua')

local UpdateWindowShowQueueOfUnit = (categories.SHOWQUEUE * categories.STRUCTURE) + categories.FACTORY

function OverchargeCanKill()
if unitHP[1] and unitHP.blueprintId then
local selected = GetSelectedUnits()
Expand Down Expand Up @@ -254,6 +258,54 @@ local statFuncs = {
end,
}


function CreateQueueGrid(parent)
controls.queue = Bitmap(parent)
controls.queue.grid = Bitmap(controls.queue)
controls.queue.grid.items = {}
controls.queue.bg = Bitmap(controls.queue)
controls.queue:DisableHitTest()

controls.queue.bg.leftBracket = Bitmap(controls.queue.bg)

controls.queue.bg.rightGlowTop = Bitmap(controls.queue.bg)
controls.queue.bg.rightGlowMiddle = Bitmap(controls.queue.bg)
controls.queue.bg.rightGlowBottom = Bitmap(controls.queue.bg)

controls.queue.bg.leftGlowTop = Bitmap(controls.queue.bg)
controls.queue.bg.leftGlowMiddle = Bitmap(controls.queue.bg)
controls.queue.bg.leftGlowBottom = Bitmap(controls.queue.bg)

local function CreateGridUnitIcon(parent)
local item = Bitmap(parent)
item.icon = Bitmap(item)
item.text = UIUtil.CreateText(item, "", 16, 'Arial Black', true)
return item
end

for id = 1, 7 do
controls.queue.grid.items[id] = CreateGridUnitIcon(controls.queue.grid)
end

controls.queue.grid.UpdateQueue = function (self, queue)
if not queue then
controls.queue:Hide()
else
controls.queue:Show()
for id, item in self.items do
if queue[id] then
item:Show()
item.icon:SetTexture( UIUtil.UIFile('/icons/units/' .. queue[id].id .. '_icon.dds', true))
item.text:SetText(tostring(queue[id].count))
else
item:Hide()
end
end
end
end
controls.queue:Hide()
end

function UpdateWindow(info)
if info.blueprintId == 'unknown' then
controls.name:SetText(LOC('<LOC rollover_0000>Unknown Unit'))
Expand Down Expand Up @@ -464,7 +516,7 @@ function UpdateWindow(info)
else
text = massKilledTrue
end

controls.nextVet:SetText(text)
else
controls.vetBar:Hide()
Expand All @@ -476,6 +528,20 @@ function UpdateWindow(info)
if info.userUnit then
unitQueue = info.userUnit:GetCommandQueue()
end


-- # Build queue upon hovering of unit

if Prefs.GetFromCurrentProfile('options.gui_queue_on_hover') > 0 then
if info.userUnit ~= nil and EntityCategoryContains(UpdateWindowShowQueueOfUnit, info.userUnit) and info.userUnit ~= selectedUnit then
controls.queue.grid:UpdateQueue(SetCurrentFactoryForQueueDisplay(info.userUnit))
else
controls.queue:Hide()
end
else
controls.queue:Hide()
end

if info.focus then
if DiskGetFileInfo(UIUtil.UIFile('/icons/units/' .. info.focus.blueprintId .. '_icon.dds', true)) then
controls.actionIcon:SetTexture(UIUtil.UIFile('/icons/units/' .. info.focus.blueprintId .. '_icon.dds', true))
Expand Down Expand Up @@ -732,6 +798,7 @@ function CreateUI()
LayoutHelpers.AtLeftTopIn(controls.enhancements['RCH'], controls.bg, 10, -30)
LayoutHelpers.AtLeftTopIn(controls.enhancements['Back'], controls.bg, 42, -30)
LayoutHelpers.AtLeftTopIn(controls.enhancements['LCH'], controls.bg, 74, -30)
CreateQueueGrid(controls.bg)
end

function OnSelection(units)
Expand Down
4 changes: 4 additions & 0 deletions lua/ui/help/tooltips.lua
Expand Up @@ -2053,6 +2053,10 @@ Tooltips = {
title = '<LOC OPTIONS_0231>Draggable Build Queue',
description = '<LOC OPTIONS_0258>Allows factory build queues to be reordered with drag and drop.',
},
options_gui_queue_on_hover = {
title = '<LOC OPTIONS_0246>Show Factory Queue on Hover',
description = '<LOC OPTIONS_0249>Shows Factory queue above unit description when hover over unit with mouse.',
},
options_gui_idle_engineer_avatars = {
title = '<LOC OPTIONS_0232>Middle Click Avatars',
description = '<LOC OPTIONS_0259>Allows middle clicking idle engineer avatars to select all idle engineers on screen.',
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit df4bfea

Please sign in to comment.