Wanting to make a icon script

Post here if you want to help developing something for FAF.

Wanting to make a icon script

Postby brandonpotter0 » 31 Oct 2013, 01:10

Hey Peeps, I have been looking at how BlackOps Icon support works and how DMS for Unit icons, and I am curious, is it possible to make an 'addon' to them, so that if the Icon Support detects a unit with the category 'CONSTRUCTION', or any other specified category in its BP, it will overlay a custom DDS ontop of the Up/Down/Over/Sel icons, and that its compatible with both DMS and BOGIS?

I think I know how to get the script to detect what categories the unit has, its just layering the textures I dont know how to do.

Example:
Image


Hooked construction.lua below
Code: Select all
do

local OldCommonLogic = CommonLogic
function CommonLogic()
   OldCommonLogic()
   
    local oldSecChoiceSetControlToType = controls.secondaryChoices.SetControlToType
    controls.secondaryChoices.SetControlToType = function(control, type)
      oldSecChoiceSetControlToType(control, type)
      
      if __blueprints[control.Data.id].Categories.CONSTRUCTION + categories.FACTORY + categories.ENGINEER then
         local ConstBar = '/mods/BattlePack/textures/ui/common/construction_bar.dds'
         if DiskGetFileInfo(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds')) then
            control.ConstBar:SetTexture(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds'))
            control.ConstBar.Height:Set(48)
            control.ConstBar.Width:Set(48)
         else
            control.ConstBar:SetSolidColor('ff00ff00')
         end
      else
         control.ConstBar:SetSolidColor('00000000')
      end       
    end
   
   local oldSecChoCreateElement = controls.secondaryChoices.CreateElement
    controls.secondaryChoices.CreateElement = function()
        local btn = oldSecChoCreateElement()
              
      btn.ConstBar = Bitmap(btn.Icon)
        btn.ConstBar:DisableHitTest()
        LayoutHelpers.AtCenterIn(btn.ConstBar, btn)
               
        return btn
    end
   
   local choiceCreateElement = controls.choices.CreateElement
    controls.choices.CreateElement = function()
        local btn = choiceCreateElement()
              
      btn.ConstBar = Bitmap(btn.Icon)
        btn.ConstBar:DisableHitTest()
        LayoutHelpers.AtCenterIn(btn.ConstBar, btn)
      
        return btn
    end
   
   local choiceSetControlToType = controls.choices.SetControlToType
    controls.choices.SetControlToType = function(control, type)
      
      if __blueprints[control.Data.id].Categories.CONSTRUCTION + categories.FACTORY + categories.ENGINEER then
      local ConstBar = '/mods/BattlePack/textures/ui/common/construction_bar.dds'
         if DiskGetFileInfo(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds')) then
            control.ConstBar:SetTexture(UIUtil.UIFile('/mods/BattlePack/textures/ui/common/construction_bar.dds'))
            control.ConstBar.Height:Set(20)
            control.ConstBar.Width:Set(20)   
         else
            control.ConstBar:SetSolidColor('ff00ff00')
         end
      else
         control.ConstBar:SetSolidColor('00000000')
      end
   end
end


end


However when I tried it, nothing happens :\
Last edited by brandonpotter0 on 31 Oct 2013, 17:01, edited 1 time in total.
User avatar
brandonpotter0
Avatar-of-War
 
Posts: 65
Joined: 19 Oct 2013, 03:05
Location: In bed with the Borg Queen. Bow Chicka bow wow ;)
Has liked: 0 time
Been liked: 0 time

Re: Wanting to make a icon script

Postby brandonpotter0 » 31 Oct 2013, 07:54

Just updated the original post with a new script that might be better to use for what I wanted to do, since the fuel icons and such are layered ontop of the unit icons like how I wanted my new DDS file, but its not working :\
User avatar
brandonpotter0
Avatar-of-War
 
Posts: 65
Joined: 19 Oct 2013, 03:05
Location: In bed with the Borg Queen. Bow Chicka bow wow ;)
Has liked: 0 time
Been liked: 0 time


Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest