⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_tooltip.lua

📁 这是整套横扫千军3D版游戏的源码
💻 LUA
字号:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------  file:    gui_tooltip.lua--  brief:   recolors some of the tooltip info--  author:  Dave Rodgers----  Copyright (C) 2007.--  Licensed under the terms of the GNU GPL, v2 or later.------------------------------------------------------------------------------------------------------------------------------------------------------------------function widget:GetInfo()  return {    name      = "Tooltip",    desc      = "A colorful tooltip modification",    author    = "trepan",    date      = "Jan 8, 2007",    license   = "GNU GPL, v2 or later",    layer     = 0,    enabled   = false  --  loaded by default?  }end------------------------------------------------------------------------------------------------------------------------------------------------------------------ Automatically generated local definitionslocal glColor                 = gl.Colorlocal glText                  = gl.Textlocal spGetCurrentTooltip     = Spring.GetCurrentTooltiplocal spGetSelectedUnitsCount = Spring.GetSelectedUnitsCountlocal spSendCommands          = Spring.SendCommands----------------------------------------------------------------------------------------------------------------------------------------------------------------include("colors.h.lua")local fontSize = 12local ySpace   = 4local yStep    = fontSize + ySpacelocal gap      = 4local fh = (1 > 0)local fontName  = "LuaUI/Fonts/FreeSansBold_14"if (fh) then  fh = fontHandler.UseFont(fontName)endif (fh) then  fontSize  = fontHandler.GetFontSize()  yStep     = fontHandler.GetFontYStep() + 2endlocal currentTooltip = ''--------------------------------------------------------------------------------local vsx, vsy = widgetHandler:GetViewSizes()function widget:ViewResize(viewSizeX, viewSizeY)  vsx = viewSizeX  vsy = viewSizeYend--------------------------------------------------------------------------------function widget:Initialize()  spSendCommands({"tooltip 0"})endfunction widget:Shutdown()  spSendCommands({"tooltip 1"})end--------------------------------------------------------------------------------local magic = '\001'function widget:WorldTooltip(ttType, data1, data2, data3)--  do return end  if (ttType == 'unit') then    return magic .. 'unit #' .. data1  elseif (ttType == 'feature') then    return magic .. 'feature #' .. data1  elseif (ttType == 'ground') then    return magic .. string.format('ground @ %.1f %.1f %.1f',                                  data1, data2, data3)  elseif (ttType == 'selection') then    return magic .. 'selected ' .. spGetSelectedUnitsCount()  else    return 'WTF? ' .. '\'' .. tostring(ttType) .. '\''  endendif (true) then  widget.WorldTooltip = nilend--------------------------------------------------------------------------------function widget:DrawScreen()  if (fh) then    fh = fontHandler.UseFont(fontName)    glColor(1, 1, 1)  end  local white = "\255\255\255\255"  local bland = "\255\211\219\255"  local mSub, eSub  local tooltip = spGetCurrentTooltip()  if (string.sub(tooltip, 1, #magic) == magic) then    tooltip = 'WORLD TOOLTIP:  ' .. tooltip  end  tooltip, mSub = string.gsub(tooltip, bland.."Me",   "\255\1\255\255Me")  tooltip, eSub = string.gsub(tooltip, bland.."En", "  \255\255\255\1En")  tooltip = string.gsub(tooltip,                        "Hotkeys:", "\255\255\128\128Hotkeys:\255\128\192\255")  tooptip =       string.gsub(tooltip, "a", "b")  local unitTip = ((mSub + eSub) == 2)  local i = 0  local disableCache = (fh and string.find(tooltip, "^Pos"))  if (disableCache) then    fontHandler.DisableCache()  -- ground tooltips change too much for caching  end  for line in string.gfind(tooltip, "([^\n]*)\n?") do    if (unitTip and (i == 0)) then      line = "\255\255\128\255" .. line    else      line = "\255\255\255\255" .. line    end        if (fh) then      fontHandler.Draw(line, gap, gap + (4 - i) * yStep)    else      glText(line, gap, gap + (4 - i) * yStep, fontSize, "o")    end    i = i + 1  end  if (disableCache) then    fontHandler.EnableCache()  endend----------------------------------------------------------------------------------------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -