Untitled diff
258 lines
init start
init start
-- local SCRIPT_VERSION = '1.0.1'
-- local SCRIPT_VERSION = '1.0.1'
-- screenshot options
-- screenshot options
local saveOriginal = false -- save full original, unaltered screenshot
local saveOriginal = true -- save full original, unaltered screenshot
local createWorldVersion = true -- create a version of the screenshot that only shows the world area
local createWorldVersion = true -- create a version of the screenshot that only shows the world area
local createFullVersion = false -- create a version of the screenshot that shows the whole client
local createFullVersion = true -- create a version of the screenshot that shows the whole client
local focusClient = true -- focus client before taking the screenshot
local focusClient = true -- focus client before taking the screenshot
local drawHuds = true -- if desktop composition is enabled (Windows Vista, 7 or 8), draw HUDs on SS
local drawHuds = true -- if desktop composition is enabled (Windows Vista, 7 or 8), draw HUDs on SS
local relocateHuds = true -- draws the huds at a custom location on the screenshot (need desktop composition enabled)
local relocateHuds = true -- draws the huds at a custom location on the screenshot (need desktop composition enabled)
local compressionQuality = 100 -- file compression rate, values ranging from 1 to 100
local compressionQuality = 100 -- file compression rate, values ranging from 1 to 100
-- hud locations, relative to world window. negative coordinates will be right / bottom aligned
-- hud locations, relative to world window. negative coordinates will be right / bottom aligned
local relocateLocations = {
local relocateLocations = {
{ name = "GeneralInfo", x = 4, y = -20 },
{ name = "GeneralInfo", x = 4, y = -20 },
{ name = "MonitorMyStats", x = 0, y = 0 },
{ name = "MonitorMyStats", x = 0, y = 0 },
{ name = "MonitorMyHunting", x = - 242, y = 0 },
{ name = "MonitorMyHunting", x = - 242, y = 0 },
}
}
-- alteration options
-- alteration options
local showEquipment = true -- show your character equipment on world screenshot
local showEquipment = true -- show your character equipment on world screenshot
local hidePersonalInfo = true -- hide personal info on screenshot (character name)
local hidePersonalInfo = true -- hide personal info on screenshot (character name)
local hideHudInfo = true -- hide personal info on HUD (must be supported by HUD)
local hideHudInfo = true -- hide personal info on HUD (must be supported by HUD)
-- technical settings
-- technical settings
local hideMethod = "both" -- "shuffle" = shuffle pixels, "blur" = blur region, "both" = both (strongest)
local hideMethod = "both" -- "shuffle" = shuffle pixels, "blur" = blur region, "both" = both (strongest)
local textSearchTolerance = 30 -- how many % of the text for hiding we want to can be obstructed (by other text on top)
local textSearchTolerance = 30 -- how many % of the text for hiding we want to can be obstructed (by other text on top)
-- internal setup (don't change below)
-- internal setup (don't change below)
-- note: textures/child_huds get rendered in the order
-- note: textures/child_huds get rendered in the order
-- they were created and not selected, needs fixing
-- they were created and not selected, needs fixing
local glowTexture = createtexture()
local glowTexture = createtexture()
local clientTexture = createtexture()
local clientTexture = createtexture()
local shotTexture = createtexture()
local shotTexture = createtexture()
local glowRendered = false
local glowRendered = false
local takeScreenshot = false
local takeScreenshot = false
local fileName = 'smartss'
local fileName = 'smartss'
local function renderglow()
local function renderglow()
local rectSize = 34
local rectSize = 34
local glowSize = 4
local glowSize = 4
local fullSize = glowSize + rectSize + glowSize
local fullSize = glowSize + rectSize + glowSize
-- leave space for glow on edges
-- leave space for glow on edges
selecthud(glowTexture)
selecthud(glowTexture)
setfixedsize(fullSize, fullSize)
setfixedsize(fullSize, fullSize)
-- fill with transparent color
-- fill with transparent color
setbordercolor(-1)
setbordercolor(-1)
setfillstyle("color", -1)
setfillstyle("color", -1)
drawrect(0, 0, fullSize, fullSize)
drawrect(0, 0, fullSize, fullSize)
-- black rect in center
-- black rect in center
setfillstyle("color", 0x80000000)
setfillstyle("color", 0x80000000)
drawrect(glowSize, glowSize, rectSize-1, rectSize-1)
drawrect(glowSize, glowSize, rectSize-1, rectSize-1)
-- apply glow around rect
-- apply glow around rect
drawgloweffect(0x000000, glowSize)
drawgloweffect(0x000000, glowSize)
--hudsnapshot("glow", 100)
--hudsnapshot("glow", 100)
end
end
local function copyequip()
local function copyequip()
local slotLocations = {37, 2, 0, 16, 74, 16, 37, 39, 74, 53, 0, 53, 37, 76, 37, 113, 0, 90, 74, 90}
local slotLocations = {37, 2, 0, 16, 74, 16, 37, 39, 74, 53, 0, 53, 37, 76, 37, 113, 0, 90, 74, 90}
local equipx, equipy = getwindowpos("equip")
local equipx, equipy = getwindowpos("equip")
if equipx ~= nil then
if equipx ~= nil then
local destx = $worldwin.width - 123 - 16
local destx = $worldwin.width - 123 - 16
local desty = $worldwin.height - 155 - 16
local desty = $worldwin.height - 155 - 16
for i=1,10 do
for i=1,10 do
local slotx = 10 + slotLocations[i*2-1]
local slotx = 10 + slotLocations[i*2-1]
local sloty = 4 + slotLocations[i*2]
local sloty = 4 + slotLocations[i*2]
-- add glow
-- add glow
setcompositionmode(CompositionMode_SourceOver)
setcompositionmode(CompositionMode_SourceOver)
drawtexture(glowTexture, destx+slotx-2, desty+sloty-2, 100)
drawtexture(glowTexture, destx+slotx-2, desty+sloty-2, 100)
-- copy equip slot
-- copy equip slot
setcompositionmode(CompositionMode_Automatic)
setcompositionmode(CompositionMode_Automatic)
drawtexture(clientTexture, destx+slotx, desty+sloty, 100, equipx - $clientwin.x + slotx, equipy - $clientwin.y + sloty, 34, 34)
drawtexture(clientTexture, destx+slotx, desty+sloty, 100, equipx - $clientwin.x + slotx, equipy - $clientwin.y + sloty, 34, 34)
end
end
end
end
end
end
local function hideregion(r)
local function hideregion(r)
if hideMethod == "shuffle" or hideMethod == "both" then
if hideMethod == "shuffle" or hideMethod == "both" then
drawshufflepixelseffect(r.left, r.top, r.width, r.height)
drawshufflepixelseffect(r.left, r.top, r.width, r.height)
end
end
if hideMethod == "blur" or hideMethod == "both" then
if hideMethod == "blur" or hideMethod == "both" then
drawblureffect(r.left, r.top, r.width, r.height, 8, 2)
drawblureffect(r.left, r.top, r.width, r.height, 8, 2)
end
end
end
end
local function takeshot()
local function takeshot()
if hudready(clientTexture) and hudready(shotTexture) and hudready(glowTexture) then
if hudready(clientTexture) and hudready(shotTexture) and hudready(glowTexture) then
local worldx = $worldwin.x - $clientwin.x
local worldx = $worldwin.x - $clientwin.x
local worldy = $worldwin.y - $clientwin.y
local worldy = $worldwin.y - $clientwin.y
local worldw = $worldwin.width
local worldw = $worldwin.width
local worldh = $worldwin.height
local worldh = $worldwin.height
-- grab whole client screen
-- grab whole client screen
selecthud(clientTexture)
selecthud(clientTexture)
setfixedsize($clientwin.width, $clientwin.height)
setfixedsize($clientwin.width, $clientwin.height)
grabclientwindow()
grabclientwindow()
if saveOriginal then
if saveOriginal then
hudsnapshot(fileName .. ".original", compressionQuality)
hudsnapshot(fileName .. ".original", compressionQuality)
end
end
-- hide information
-- hide information
if hidePersonalInfo then
if hidePersonalInfo then
-- hide name in chat text in world window ($name says:)
-- hide name in chat text in world window ($name says:)
hideclienttext($name, worldx, worldy, worldw, worldh, true, hideMethod, 8, 2, textSearchTolerance)
hideclienttext($name, worldx, worldy, worldw, worldh, true, hideMethod, 8, 2, textSearchTolerance)
if createFullVersion then
if createFullVersion then
-- hide name in chat window
-- hide name in chat window
hideclienttext($name, 0, worldy + worldh + 62, -194, -22, false, hideMethod, 8, 2)
hideclienttext($name, 0, worldy + worldh + 62, -194, -22, false, hideMethod, 8, 2)
-- hide private channel names
-- hide private channel names
foreach channel c do
foreach channel c do
if c.outid > 6 then
if c.outid > 6 then
hideclienttext(c.name, 0, worldy + worldh + 44, -194, 16, true, hideMethod, 8, 2)
hideclienttext(c.name, 0, worldy + worldh + 44, -194, 16, true, hideMethod, 8, 2)
end
end
end
end
end
end
-- hide name above char, in case the other way failed (text/other names on top?)
-- hide name above char, in case the other way failed (text/other names on top?)
local r = getnamearea($self, worldw, worldh)
local r = getnamearea($self, worldw, worldh)
if r then
if r then
-- map to client coordinates, and expand
-- map to client coordinates, and expand
r.left = r.left + worldx
r.left = r.left + worldx
r.top = r.top + worldy + 1
r.top = r.top + worldy + 1
r.width = r.width + 1
r.width = r.width + 1
r.height = r.height + 2
r.height = r.height + 2
-- hide the region
-- hide the region
hideregion(r)
hideregion(r)
end
end
end
end
if drawHuds and not $windowsxp then
if drawHuds and not $windowsxp then
-- draw huds transparently
-- draw huds transparently
setcompositionmode(CompositionMode_SourceOver)
setcompositionmode(CompositionMode_SourceOver)
local i = 0
local i = 0
while isscript("display", i) do
while isscript("display", i) do
local listname = scriptlistname("display", i)
local listname = scriptlistname("display", i)
local x = nil
local x = nil
local y = nil
local y = nil
if relocateHuds then
if relocateHuds then
for _, h in ipairs(relocateLocations) do
for _, h in ipairs(relocateLocations) do
if h.name == listname then
if h.name == listname then
if h.x < 0 then x = worldx + worldw + h.x else x = worldx + h.x end
if h.x < 0 then x = worldx + worldw + h.x else x = worldx + h.x end
if h.y < 0 then y = worldy + worldh + h.y else y = worldy + h.y end
if h.y < 0 then y = worldy + worldh + h.y else y = worldy + h.y end
end
end
end
end
end
end
grabhud(listname, x, y)
grabhud(listname, x, y)
i = i + 1
i = i + 1
end
end
-- restore changed defaults
-- restore changed defaults
setcompositionmode(CompositionMode_Automatic)
setcompositionmode(CompositionMode_Automatic)
end
end
-- draw windbot logo
-- draw windbot logo
setcompositionmode(CompositionMode_SourceOver)
setcompositionmode(CompositionMode_SourceOver)
local logow, logoh = 64, 64
local logow, logoh = 64, 64
drawimage('windbot.png', worldx + 5, worldy + worldh - (logoh + 25), 0, 0, logow, logoh)
drawimage('windbot.png', worldx + 5, worldy + worldh - (logoh + 25), 0, 0, logow, logoh)
-- restore changed defaults
-- restore changed defaults
setcompositionmode(CompositionMode_Automatic)
setcompositionmode(CompositionMode_Automatic)
if createFullVersion then
if createFullVersion then
hudsnapshot(fileName .. ".full", compressionQuality)
hudsnapshot(fileName .. ".full", compressionQuality)
end
end
if createWorldVersion then
if createWorldVersion then
-- render a glow effect to place under equip
-- render a glow effect to place under equip
if not glowRendered then
if not glowRendered then
renderglow()
renderglow()
glowRendered = true
glowRendered = true
end
end
-- switch to screenshot texture
-- switch to screenshot texture
selecthud(shotTexture)
selecthud(shotTexture)
setfixedsize(worldw, worldh)
setfixedsize(worldw, worldh)
-- copy world area of client
-- copy world area of client
drawtexture(clientTexture, 0, 0, 100, worldx, worldy, worldw, worldh)
drawtexture(clientTexture, 0, 0, 100, worldx, worldy, worldw, worldh)
-- copy equipment
-- copy equipment
if showEquipment then
if showEquipment then
copyequip()
copyequip()
end
end
-- save texture to file
-- save texture to file
hudsnapshot(fileName .. ".world", compressionQuality)
hudsnapshot(fileName .. ".world", compressionQuality)
-- free texture
-- free texture
freetexture(shotTexture)
freetexture(shotTexture)
end
end
-- release texture contents to free memory (without deleting it)
-- release texture contents to free memory (without deleting it)
-- we won't be using it until next screenshot
-- we won't be using it until next screenshot
freetexture(clientTexture)
freetexture(clientTexture)
end
end
end
end
function smartscreenshot(name)
function smartscreenshot(name)
takeScreenshot = true
takeScreenshot = true
fileName = name or 'smartss'
fileName = name or 'smartss'
end
end
auto(50)
auto(50)
init end
init end
-- runtime part
-- runtime part
if takeScreenshot then
if takeScreenshot then
if not TakingScreenshot then
if not TakingScreenshot then
-- huds can check for TakingScreenshot type
-- huds can check for TakingScreenshot type
-- to avoid drawing identifiable information
-- to avoid drawing identifiable information
TakingScreenshot = hideHudInfo and ("hide_personal_info method:" .. hideMethod) or "normal"
TakingScreenshot = hideHudInfo and ("hide_personal_info method:" .. hideMethod) or "normal"
debugscript("Taking screenshot")
debugscript("Taking screenshot")
-- huds can be hidden and outdated if client not focused
-- huds can be hidden and outdated if client not focused
-- and give chance for hud to hide personal info
-- and give chance for hud to hide personal info
forcerefreshhuds()
forcerefreshhuds()
debugscript("Huds refreshed")
debugscript("Huds refreshed")
-- take the screenshot
-- take the screenshot
takeshot()
takeshot()
debugscript("Done")
debugscript("Done")
TakingScreenshot = nil
TakingScreenshot = nil
end
end
takeScreenshot = false
takeScreenshot = false
end
end