help me to modify that widget

help me to modify that widget

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

help me to modify that widget

Post by manolo_ »

so thats the lua i ripped from ca some time ago, so i want to change it a lil but, so it will show the E and M costs for morph/build in a next line, so how?

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function widget:GetInfo()
  return {
    name      = "InlineTip-BM",
    desc      = "v0.3 Prints unit name next to cursor when hovering over buildpic.",
    author    = "CarRepairer",
    date      = "2008-08-20",
    license   = "GNU GPL, v2 or later",
    layer     = 1, 
    enabled   = false  --  loaded by default?
  }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local Spring          = Spring
local gl, GL          = gl, GL
local widgetHandler   = widgetHandler
local panelFont       = LUAUI_DIRNAME.."Fonts/KOMTXT___16"



--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local fhDraw          = fontHandler.Draw
local glColor         = gl.Color
local GetCurrentTooltip = Spring.GetCurrentTooltip
local GetMouseState = Spring.GetMouseState 

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

fontHandler.UseFont(panelFont)
local panelFontSize  = fontHandler.GetFontSize()
fontHandler.DisableCache()

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local function getShortTooltip()
	local tooltip = GetCurrentTooltip()

	if tooltip:find('Build') == 1 then
		return tooltip:gsub('([^-]*)\-.*', '%1')
	elseif tooltip:find('Morph') == 5 then
		return tooltip:gsub('([^(time)]*)\(time).*', '%1')
	end
	return false
	
end


function widget:DrawScreen()

	local curTooltip = getShortTooltip()

	if (curTooltip) then
		fontHandler.DisableCache()

		fontHandler.UseFont(panelFont)
		glColor(1,1,1,1)
	
		local mx, my = GetMouseState()
		fhDraw(curTooltip, mx + 15, my - 15)
	end

end


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function widget:Initialize()
end

function widget:Shutdown()
	fontHandler.FreeFonts()
	fontHandler.FreeCache()
end


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: help me to modify that widget

Post by Tribulex »

Is this for xta? Just keep in mind that I am actually making an inline tooltip for xta. I dont mean to burst your bubble, but if you tell me what you want in it Ill put it in.
User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: help me to modify that widget

Post by manolo_ »

i didnt knew that, but i just want to have the name and the E/M-costs while i hover over the build/morph-pic. the widget shows the name, so i need someone how adds the line for the costs
Post Reply

Return to “Lua Scripts”