Permalink
Browse files

updated some widgets

  • Loading branch information...
Ruwetuin committed Nov 15, 2018
1 parent 2329f74 commit aa7a43487964420234e3815f9ac321e41ec1b0d0
@@ -16,17 +16,8 @@ end
local teams = Spring.GetTeamList()
for i =1, #teams do
local luaAI = Spring.GetTeamLuaAI(teams[i])
if string.find(luaAI, "Chicken:") then
if luaAI == "Chicken: Very Easy" or
luaAI == "Chicken: Easy" or
luaAI == "Chicken: Normal" or
luaAI == "Chicken: Hard" or
luaAI == "Chicken: Very Hard" or
luaAI == "Chicken: Epic!" or
luaAI == "Chicken: Custom" or
luaAI == "Chicken: Survival" then
chickensEnabled = true
end
if luaAI and luaAI ~= "" and string.sub(luaAI, 1, 9) == 'Chicken: ' then
chickensEnabled = true
end
end
@@ -16,18 +16,9 @@ end
local teams = Spring.GetTeamList()
for i =1, #teams do
local luaAI = Spring.GetTeamLuaAI(teams[i])
if string.find(luaAI, "Chicken:") then
if luaAI == "Chicken: Very Easy" or
luaAI == "Chicken: Easy" or
luaAI == "Chicken: Normal" or
luaAI == "Chicken: Hard" or
luaAI == "Chicken: Very Hard" or
luaAI == "Chicken: Epic!" or
luaAI == "Chicken: Custom" or
luaAI == "Chicken: Survival" then
chickensEnabled = true
end
end
if luaAI and luaAI ~= "" and string.sub(luaAI, 1, 9) == 'Chicken: ' then
chickensEnabled = true
end
end
if chickensEnabled == true then
@@ -16,18 +16,9 @@ end
local teams = Spring.GetTeamList()
for i =1, #teams do
local luaAI = Spring.GetTeamLuaAI(teams[i])
if (string.find(luaAI, "Chicken:")) then
if luaAI == "Chicken: Very Easy" or
luaAI == "Chicken: Easy" or
luaAI == "Chicken: Normal" or
luaAI == "Chicken: Hard" or
luaAI == "Chicken: Very Hard" or
luaAI == "Chicken: Epic!" or
luaAI == "Chicken: Custom" or
luaAI == "Chicken: Survival" then
chickensEnabled = true
end
end
if luaAI and luaAI ~= "" and string.sub(luaAI, 1, 9) == 'Chicken: ' then
chickensEnabled = true
end
end
if chickensEnabled == true then
@@ -236,8 +227,10 @@ SetGameRulesParam("chickenTeamID", chickenTeamID)
local function SetToList(set)
local list = {}
local count = 0
for k in pairs(set) do
table.insert(list, k)
count = count + 1
list[count] = k
end
return list
end
@@ -1210,10 +1203,14 @@ local function getMostDefendedArea()
local k = next(defenseMap)
if k then
local x,z = string.match(k, "(%d+),(%d+)")
x = x * DMAREA
z = z * DMAREA
local y = GetGroundHeight(x,z)
return x,y,z
if x ~= nil and z ~= nil then
x = x * DMAREA
z = z * DMAREA
local y = GetGroundHeight(x,z)
return x,y,z
else
return nil, nil, nil
end
else
return nil,nil,nil
end
@@ -16,17 +16,8 @@ end
local teams = Spring.GetTeamList()
for i =1, #teams do
local luaAI = Spring.GetTeamLuaAI(teams[i])
if string.find(luaAI, "Chicken:") then
if luaAI == "Chicken: Very Easy" or
luaAI == "Chicken: Easy" or
luaAI == "Chicken: Normal" or
luaAI == "Chicken: Hard" or
luaAI == "Chicken: Very Hard" or
luaAI == "Chicken: Epic!" or
luaAI == "Chicken: Custom" or
luaAI == "Chicken: Survival" then
chickensEnabled = true
end
if luaAI and luaAI ~= "" and string.sub(luaAI, 1, 9) == 'Chicken: ' then
chickensEnabled = true
end
end
@@ -115,7 +115,8 @@ else
data = userconfig .. data
if data then
data = string.sub(data, 1, 250000)
Spring.SendLuaRulesMsg('pd'..validation..'infolog;'..player..';'..VFS.ZlibCompress(data))
local sendtoauthedplayer = '1'
Spring.SendLuaRulesMsg('pd'..validation..sendtoauthedplayer..'infolog;'..player..';'..VFS.ZlibCompress(data))
end
end
elseif string.sub(msg,1,13) == 'getscreenshot' then

This file was deleted.

Oops, something went wrong.
@@ -23,7 +23,7 @@ local GetMouseState = Spring.GetMouseState
function widget:GetInfo()
return {
name = "Autoquit",
desc = versionNumber .. " Automatically quits "..delay.."s after the game ends. Move mouse to cancel.",
desc = versionNumber .. " Automatically quits "..delay.."s after the game ends. Move mouse to postpone. (each minute) ",
author = "Evil4Zerggin & zwzsg",
date = "25 December 2008",
license = "GNU LGPL, v2.1 or later",
@@ -47,7 +47,9 @@ function widget:Update(dt)
local nmx,nmy = GetMouseState()
if nmx~=mx or nmy~=my then
--Echo("<autoquit> Autoquit canceled.")
endTime = false
--endTime = false
endTime = GetTimer() + 60 -- set new endtime, because I've had times that game was running for ages because i wasnt attending pc but somehow it detect a move
mx,my = GetMouseState()
-- widgetHandler:RemoveWidget(self)
elseif DiffTimers(GetTimer(), endTime) > delay then
Echo("<autoquit> Autoquit sending quit command.")
@@ -17,9 +17,9 @@ end
local maxQuality = 8192
local minQuality = 2048 -- I dont think a value below 2048 looks acceptable enough... wont free that much extra cpu power too
local disableBelowMinimum = false
local skipGameframes = 1611 -- dont check if quality change is needed for X gameframes
local fpsDifference = 8 -- if fps differs X amount, then shadow quality will be allowed to change. (we dont want frequent changes because these are causing extra cpu load, also spring spams an echo each time)
local disableFps = 0
local skipGameframes = 60--1611 -- dont check if quality change is needed for X gameframes
local fpsDifference = 7 -- if fps differs X amount, then shadow quality will be allowed to change. (we dont want frequent changes because these are causing extra cpu load)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -28,7 +28,7 @@ local spGetVisibleUnits = Spring.GetVisibleUnits
local spGetVisibleFeatures = Spring.GetVisibleFeatures
local spGetFPS = Spring.GetFPS
local spHaveShadows = Spring.HaveShadows
local averageFps = spGetFPS() + 5
local averageFps = spGetFPS() + 8
local previousQuality = maxQuality
local previousQualityFps = 30
@@ -43,6 +43,35 @@ function widget:Initialize()
if spHaveShadows() and Spring.GetGameFrame() < 1 then
Spring.SendCommands({"shadows 1 "..maxQuality})
end
WG['shadowmanager'] = {}
WG['shadowmanager'].getMaxQuality = function()
return maxQuality
end
WG['shadowmanager'].setMaxQuality = function(value)
maxQuality = value
if spHaveShadows() or turnedShadowsOff then
updateShadows(true)
end
end
WG['shadowmanager'].getMinQuality = function()
return minQuality
end
WG['shadowmanager'].setMinQuality = function(value)
minQuality = value
if spHaveShadows() or turnedShadowsOff then
updateShadows(true)
end
end
WG['shadowmanager'].getDisableFps = function()
return disableFps
end
WG['shadowmanager'].setDisableFps = function(value)
disableFps = value
if spHaveShadows() or turnedShadowsOff then
updateShadows(true)
end
end
end
function widget:Shutdown()
@@ -53,6 +82,32 @@ function widget:Shutdown()
end
end
function updateShadows(force)
quality = math.floor((maxQuality+minQuality) - (maxQuality / (averageFps/20)))
if averageFps > previousQualityFps + fpsDifference or averageFps < previousQualityFps - fpsDifference or force then -- weight fps values with more rendered models heavier
if quality > maxQuality then
quality = maxQuality
end
if quality < minQuality then
quality = minQuality
end
if previousQuality ~= quality or force then
previousQuality = quality
previousQualityFps = averageFps
if averageFps < disableFps then
turnedShadowsOff = true
Spring.SendCommands({"shadows 0"})
--Spring.Echo("Shadow quality: off avgfps: "..math.floor(averageFps))
else
Spring.SendCommands({"shadows 1 "..quality})
--Spring.Echo("Shadow quality: "..quality.." avgfps: "..math.floor(averageFps))
end
end
end
end
function widget:GameFrame(gameFrame)
if spHaveShadows() or shadowsAtInit and turnedShadowsOff then
@@ -66,30 +121,8 @@ function widget:GameFrame(gameFrame)
--local dquality = math.floor((maxQuality+minQuality) - (maxQuality / (averageFps/20)))
--Spring.Echo(averageFps..' '..dquality)
end
if gameFrame%skipGameframes==0 then
quality = math.floor((maxQuality+minQuality) - (maxQuality / (averageFps/20)))
if averageFps > previousQualityFps + fpsDifference or averageFps < previousQualityFps - fpsDifference then -- weight fps values with more rendered models heavier
if quality > maxQuality then
quality = maxQuality
end
if quality < minQuality then
quality = minQuality-1
end
if previousQuality ~= quality then
previousQuality = quality
previousQualityFps = averageFps
if quality < minQuality and disableBelowMinimum then
turnedShadowsOff = true
Spring.SendCommands({"shadows 0"})
--Spring.Echo("Shadow quality: off avgfps: "..math.floor(averageFps))
else
Spring.SendCommands({"shadows 1 "..quality})
--Spring.Echo("Shadow quality: "..quality.." avgfps: "..math.floor(averageFps))
end
end
end
if gameFrame%skipGameframes==0 then
updateShadows()
end
end
end
@@ -98,8 +131,11 @@ end
function widget:GetConfigData(data)
savedTable = {}
savedTable.averageFps = averageFps
savedTable.previousQuality = previousQuality
savedTable.previousQualityFps = previousQualityFps
savedTable.previousQuality = previousQuality
savedTable.previousQualityFps = previousQualityFps
savedTable.maxQuality = maxQuality
savedTable.minQuality = minQuality
savedTable.disableFps = disableFps
return savedTable
end
@@ -109,4 +145,7 @@ function widget:SetConfigData(data)
if data.previousQuality ~= nil then previousQuality = data.previousQuality end
if data.previousQualityFps ~= nil then previousQualityFps = data.previousQualityFps end
end
if data.maxQuality ~= nil then maxQuality = data.maxQuality end
if data.minQuality ~= nil then minQuality = data.minQuality end
if data.disableFps ~= nil then disableFps = data.disableFps end
end
Oops, something went wrong.

0 comments on commit aa7a434

Please sign in to comment.