local version = tonumber( (string.gsub(string.gsub(GetVersion(), '1.5.', ''), '1.6.', '')) )

if version < 3652 then -- All versions below 3652 don't have buildin global icon support, so we need to insert the icons by our own function
	LOG('Extreme Wars: [unitview.lua '..debug.getinfo(1).currentline..'] - Gameversion is older then 3652. Hooking "UpdateWindow" to add our own unit icons')

local MyUnitIdTable = {
   xrl0303=true, -- Bomb - (Bomb)
   uab2105=true, -- Air Seeker - (Anti-Air Air Turret)
   ueb4205=true, -- Light Parashield - (Light Shield Generator)
   ueb2105=true, -- DA1 Railgun - (Anti-Air Turret)
   urb1207=true, -- Ailuin - (Medium Hydroelectric Power Generator)
   xsb2106=true, -- Air Uttaus - (Air Point Defense)
   ueb1208=true, -- Haryk - (Medium Naval Mass Rig)
   xsse0001=true, -- The Tlacuconos - (Experimental Tech1 Spaceship)
   urse0001=true, -- The Shadow - (Tech 1 Experimental Spaceship)
   ueaew0002=true, -- E.F.O.F Protector - (Tech 2 Experimental Support Spaceship)
   uab1208=true, -- Quynn - (Medium Naval Mass Rig)
   ueb2110=true, -- Mortimer - (Heavy Light Artillery Installation)
   urb4401=true, -- Scavenger - (Tech 3 Experimental Anti-Nuke.)
   uab2201=true, -- Diskobolia - (Anti Navy Installation)
   ura0205=true, -- The Hawk - (EMP Bomber)
   ura0402=true, -- Spaceship Class : The Hive - (Tech 3 Experimental Transportation Spaceship)
   xsa0306=true, -- Virutola - ()
   ueb2201=true, -- Killer Whale AN.  - (Anti Navy Installation)
   xsb2105=true, -- Air AA Defense - (Air AA Defense)
   ues0106=true, -- Aviso Class - (Aviso)
   ueb2106=true, -- Air DM1 Plasma Cannon - (Air Point Defense)
   urbew0001=true, -- Cerberus - (Tech 2 Experimental Point Defense.)
   uel0206=true, -- Morter Tank Tech 2 - (Morter Tank Tech 2)
   xsb2206=true, -- Uttaushala - (Point Defense)
   uas0106=true, -- Aviso Class - (Aviso)
   uab2106=true, -- Air Point Defense Erupter - (Air Point Defense)
   uea0111=true, -- A215F Support Rev Protector - (A215F Support Rev)
   url0320=true, -- Scorpion - (Scorpion)
   uelew0003=true, -- Alexander Prototype E415M - (Tech 2 Experimental Deployable Tank)
   xsl0206=true, -- Ohiescebom - (Mobile Anti-Subs Launcher)
   url0206=true, -- Turtle Tank - (Amphibious Heavy Tank)
   urb2105=true, -- Tracer - (Anti-Air Turret)
   xsaew0002=true, -- Tech 2 Experimental Teleportable Transporter - (Tech 2 Experimental Air Transport)
   uea0306=true, -- Tornado - (Fighter/Bomber)
   uese0001=true, -- E.F.O.F Cleaner - (Tech 1 Experimental Spaceship)
   xsb1107=true, -- Eruya-leatoh - (Hydroelectric Power Generator)
   urb1107=true, -- Meteli - (Hydroelectric Power Generator)
   uase0001=true, -- The Falling Star - (Tech 1 Experimental Spaceship)
   url0311=true, -- Tech 3 Missile Bot - (Tech 3 Missile Bot)
   urb5201=true, -- Zinmoira - (Tech 1 Air Staging Facility)
   ueb5201=true, -- Refuel & Repair - (Air Staging Facility)
   uea0402=true, -- EFOF Transportator - (Tech 3 Experimental Transportation Spaceship)
   uab5201=true, -- Light Cradle - (Air Staging Facility)
   uelew0001=true, -- UEF Fortress Prototype E500M - (Tech 1 Heavy Tank Experimental.)
   ualew0001=true, -- Enfranchisor - (Tech 1 Hover Tank Experimental.)
   urs0106=true, -- Light Aviso - (Aviso)
   xss0106=true, -- Lyteul-Hau-esel - (Aviso)
   ueb2206=true, -- Air Triad - (Point Defense)
   ueb1108=true, -- Islesbury - (Naval Mass Rig)
   uab1108=true, -- Padstow - (Naval Mass Rig)
   urlew0001=true, -- Manticore Rev1.0 - (Tech 1 Experimental Deployable Bot.)
   ues0204=true, -- Nemo - (Light Attack Submarine)
   uab2206=true, -- Oblivion - (Point Defense)
   urb1108=true, -- Ballachulish - (Naval Mass Rig)
   xslew0001=true, -- Whouhamoua - (Experimental T2 QuadBot)
   xsb1108=true, -- Hyalatoh - (Naval Mass Rig)
   uelew0004=true, -- Obliterator - (Tech 2 Experimental Heavy Bot)
   ualew0002=true, -- Thelxinaeonus - (Tech 2 Experimental Tractor Hover Tank)
   xsb5201=true, -- Mini-Iathu-uhthe - (Air Staging Beacon)
   uea0401=true, -- E.F.O.F Infallible - (Tech 3 Experimental Spaceship)
   xsb2306=true, -- Heavy Point Defense - (Heavy Point Defense)
   uel0108=true, -- SD-MA12 Bunker - (Deployable Tank)
   uea0105=true, -- A215F Support Rev Destructor - (A215F Support Rev Destructor)
   urb2306=true, -- Obelisk - (Obelisk)
   ueb1207=true, -- HPG X200 - (Medium Hydroelectric Power Generator)
   urb2201=true, -- Deucalion Tower - (Anti Navy Installation)
   xss0104=true, -- Arty Frigate - (Arty Frigate)
   uab1207=true, -- Estelar - (Medium Hydroelectric Power Generator)
   xsl0110=true, -- Ehuhua - (Mobile Shield Generator)
   xrle0004=true, -- Manticore Rev2.0 - (Tech 2 Experimental Deployable Bot.)
   url0403=true, -- Ticklord - (Tech 3 Experimental Mega Bot.)
   uab2207=true, -- Marr - (Anti-Air Flak Artillery)
   ual5001=true, -- The Renaissance - (Mobile Air Staging Platform )
   uel0305=true, -- Imperator MarkI - (Heavy Tank)
   uas0204=true, -- Light Sylph - (Light Attack Submarine)
   xsb1208=true, -- Tristoris - (Medium Naval Mass Rig)
   xsb1207=true, -- Luhorn - (Medium Hydroelectric Power Generator)
   urb1208=true, -- Valberos - (Medium Naval Mass Rig)
   xss0204=true, -- Pity-Sou-istle - (Light Attack Submarine)
   ual0305=true, -- Gerridae - (Heavy Hover Tank)
   urs0204=true, -- Eel - (Light Attack Submarine)
   urs0104=true, -- Arty Frigate Class - (Arty Frigate)
   xsle0001=true, -- Experimental Tech 1 Assault Bot - (Experimental Tech 1 Assault Bot)
   uab1107=true, -- Galssop - (Hydroelectric Power Generator)
   uaaew0004=true, -- Helios Bomber - (Experimental Tech 2 Bomber)
   urb2207=true, -- Burst Master - (Anti-Air Flak Artillery)
   uea0112=true, -- Light Stinger - (Tech 1 Gunship)
   ueb1107=true, -- HPG X100 - (Hydroelectric Power Generator)
   ueb2207=true, -- Air Cleaner - (Anti-Air Flak Artillery)
   xsb2207=true, -- Sinnatha - (Anti-Air Flak Artillery)
   uel0311=true, -- ZV27 - (Sam Missile Launcher)
   ues0104=true, -- Arty Ship Class - (Arty Frigate)
   urb2106=true, -- Auto Gun - (Point Defense)
   urb2206=true, -- Cerberus - (Point Defense)
   ualew0003=true, -- Thor Charriot - (Tech 2 Experimental Heavy Assault TankedBike)
   uas0104=true, -- Arty Frigate Beacon Class - (Arty Frigate)
   uel0110=true, -- R-Jam-10M - (False Radar Signals Generator)
}



	local IconPath = "/Mods/XtremWars"

	local oldUpdateWindow = UpdateWindow
	function UpdateWindow(info)
		oldUpdateWindow(info)
		if MyUnitIdTable[info.blueprintId] then
			controls.icon:SetTexture(IconPath .. '/icons/units/' .. info.blueprintId .. '_icon.dds')
		end
	end

else
	LOG('Extreme Wars: [unitview.lua '..debug.getinfo(1).currentline..'] - Gameversion is 3652 or newer. No need to insert the unit icons by our own function.')
end -- All versions below 3652 don't have buildin global icon support, so we need to insert the icons by our own function