Skip to content

Commit

Permalink
VERSION{v1.8.8.5}
Browse files Browse the repository at this point in the history
Fix the broken music slider and linked the trackbars (a page refresh for the submenu is still required).
Add information for the fighter pullup error.
  • Loading branch information
GoogleFrog committed Aug 25, 2020
1 parent d30570c commit 8777f8c
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 51 deletions.
32 changes: 20 additions & 12 deletions LuaRules/Gadgets/unit_fighter_pullup.lua
@@ -1,30 +1,38 @@
if not gadgetHandler:IsSyncedCode() then return end

function gadget:GetInfo() return {
name = "Fighter pull-up",
desc = "Sets attack safety distance for fighter/bomber aircraft",
author = "raaar",
date = "2015",
license = "PD",
layer = 3,
enabled = true
} end
function gadget:GetInfo()
return {
name = "Fighter pull-up",
desc = "Sets attack safety distance for fighter/bomber aircraft",
author = "raaar",
date = "2015",
license = "PD",
layer = 3,
enabled = true
}
end

local pullupDist = {}

for unitDefID, unitDef in pairs(UnitDefs) do
local dist = unitDef.customParams.fighter_pullup_dist
if dist then
pullupDist[unitDefID] = dist
end
end

local spMcSetAirMoveTypeData = Spring.MoveCtrl.SetAirMoveTypeData
local spMoveCtrlGetTag = Spring.MoveCtrl.GetTag
local spMoveCtrlSetAirMoveTypeData = Spring.MoveCtrl.SetAirMoveTypeData
local moveTypeDataTable = {attackSafetyDistance = 123}

function gadget:UnitCreated(unitID, unitDefID)
local dist = pullupDist[unitDefID]
if dist then
moveTypeDataTable.attackSafetyDistance = dist
spMcSetAirMoveTypeData(unitID, moveTypeDataTable)
if spMoveCtrlGetTag(unitID) == nil then
moveTypeDataTable.attackSafetyDistance = dist
spMoveCtrlSetAirMoveTypeData(unitID, moveTypeDataTable)
else
Spring.Echo("LUA_ERRRUN", "Fighter pullup with spMoveCtrlGetTag", (UnitDefs[unitDefID] and UnitDefs[unitDefID].name) or "noname")
end
end
end
15 changes: 7 additions & 8 deletions LuaUI/Configs/epicmenu_conf.lua
Expand Up @@ -589,7 +589,11 @@ local pathAudio = 'Settings/Audio'
min = 0,
max = 100,
springsetting = 'snd_volmaster',
OnChange = function(self) spSendCommands{"set snd_volmaster " .. self.value} end,
OnChange = function(self)
if WG.crude and WG.crude.SetMasterVolume then
WG.crude.SetMasterVolume(self.value)
end
end,
simpleMode = true,
everyMode = true,
})
Expand Down Expand Up @@ -646,14 +650,9 @@ local pathAudio = 'Settings/Audio'
-- springsetting = 'snd_volmusic', -- TODO: we should probably switch from WG to this at some point
value = WG.music_volume or 0.5,
OnChange = function(self)
if (WG.music_start_volume or 0 > 0) then
Spring.SetSoundStreamVolume(self.value / WG.music_start_volume)
else
Spring.SetSoundStreamVolume(self.value)
if WG.crude and WG.crude.SetMusicVolume then
WG.crude.SetMusicVolume(self.value)
end
local prevValue = WG.music_volume
--settings.music_volume = self.value
WG.music_volume = self.value
end,
simpleMode = true,
everyMode = true,
Expand Down
93 changes: 62 additions & 31 deletions LuaUI/Widgets/gui_epicmenu.lua
Expand Up @@ -184,6 +184,12 @@ local transkey = include("Configs/transkey.lua")
local wantToReapplyBinding = false
local hackyOptionMemory = {}
local hackyOptionMemoryWhitelist = {
['Master Volume'] = true,
['Music Volume'] = true,
}
--------------------------------------------------------------------------------
-- Widget globals
WG.crude = {}
Expand Down Expand Up @@ -395,6 +401,40 @@ local function otvalidate(t)
end
--end cool new framework
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local musicTrackbar, masterVolumeTrackbar
WG.crude.SetMasterVolume = function (newVolume, viaTrackbar)
spSendCommands{"set snd_volmaster " .. newVolume}
if viaTrackbar then
if hackyOptionMemory['Master Volume'] then
hackyOptionMemory['Master Volume'].value = newVolume
end
elseif masterVolumeTrackbar then
masterVolumeTrackbar:SetValue(newVolume)
end
end
WG.crude.SetMusicVolume = function (newVolume, viaTrackbar)
if (WG.music_start_volume or 0 > 0) then
Spring.SetSoundStreamVolume(newVolume / WG.music_start_volume)
else
Spring.SetSoundStreamVolume(newVolume)
end
settings.config["epic_Settings/Audio_Music_Volume"] = newVolume
WG.music_volume = newVolume
if viaTrackbar then
if hackyOptionMemory['Music Volume'] then
hackyOptionMemory['Music Volume'].value = newVolume
end
elseif musicTrackbar then
musicTrackbar:SetValue(newVolume)
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
WG.crude.SetSkin = function(Skin)
Expand Down Expand Up @@ -1178,6 +1218,10 @@ local function AddOption(path, option, wname ) --Note: this is used when loading

otset( pathoptions[path], wname..option.key, option )--is used for remake epicMenu's button(s)

-- hax
if hackyOptionMemoryWhitelist[option.name] then
hackyOptionMemory[option.name] = option
end
end

local function RemOption(path, option, wname )
Expand Down Expand Up @@ -2293,7 +2337,7 @@ local function GetMainPanel(parent, width, height)
value = spGetConfigInt("snd_volmaster", 50),
OnChange = {
function(self)
spSendCommands{"set snd_volmaster " .. self.value}
WG.crude.SetMasterVolume(self.value, true)
if WG.ttsNotify then
WG.ttsNotify()
end
Expand All @@ -2309,23 +2353,19 @@ local function GetMainPanel(parent, width, height)
max = 1,
step = 0.01,
trackColor = color.main_fg,
value = settings.music_volume or 0.5,
prevValue = settings.music_volume or 0.5,
value = settings.config["epic_Settings/Audio_Music_Volume"] or 0.5,
OnChange = {
function(self)
if ((WG.music_start_volume or 0) > 0) then
Spring.SetSoundStreamVolume(self.value / WG.music_start_volume)
else
Spring.SetSoundStreamVolume(self.value)
if WG.crude and WG.crude.SetMusicVolume then
WG.crude.SetMusicVolume(self.value, true)
end
settings.music_volume = self.value
WG.music_volume = self.value
self.prevValue = self.value
end
},
},
},
}
masterVolumeTrackbar = stackChildren[#stackChildren].children[1]
musicTrackbar = stackChildren[#stackChildren].children[2]
--stackChildren[#stackChildren + 1] = Trackbar:New{
-- tooltip = 'Volume',
-- height = 15,
Expand Down Expand Up @@ -2414,7 +2454,7 @@ local function GetMainPanel(parent, width, height)
value = spGetConfigInt("snd_volmaster", 50),
OnChange = {
function(self)
spSendCommands{"set snd_volmaster " .. self.value}
WG.crude.SetMasterVolume(self.value, true)
if WG.ttsNotify then
WG.ttsNotify()
end
Expand All @@ -2431,33 +2471,19 @@ local function GetMainPanel(parent, width, height)
max = 1,
step = 0.01,
trackColor = color.main_fg,
value = settings.music_volume or 0.5,
prevValue = settings.music_volume or 0.5,
value = settings.config["epic_Settings/Audio_Music_Volume"] or 0.5,
OnChange = {
function(self)
if ((WG.music_start_volume or 0) > 0) then
Spring.SetSoundStreamVolume(self.value / WG.music_start_volume)
else
Spring.SetSoundStreamVolume(self.value)
end
settings.music_volume = self.value
WG.music_volume = self.value
if (self.prevValue > 0 and self.value <= 0) then
widgetHandler:DisableWidget("Music Player")
if WG.crude and WG.crude.SetMusicVolume then
WG.crude.SetMusicVolume(self.value, true)
end
if (self.prevValue <= 0 and self.value > 0) then
-- Disable first in case widget is already enabled.
-- This is required for it to notice the volume
-- change from 0 in some cases.
widgetHandler:DisableWidget("Music Player")
widgetHandler:EnableWidget("Music Player")
end
self.prevValue = self.value
end
},
},
},
}
masterVolumeTrackbar = stackChildren[#stackChildren].children[2]
musicTrackbar = stackChildren[#stackChildren].children[4]

holderWidth = holderWidth + sliderWidth + 2
end
Expand Down Expand Up @@ -3196,7 +3222,12 @@ function widget:SetConfigData(data)

WG.lang(settings.lang)

WG.music_volume = settings.music_volume or 0.5
if settings.music_volume then
settings.config["epic_Settings/Audio_Music_Volume"] = settings.music_volume
settings.music_volume = nil
end

WG.crude.SetMusicVolume(settings.config["epic_Settings/Audio_Music_Volume"] or 0.5)
LoadKeybinds()
end

Expand Down

0 comments on commit 8777f8c

Please sign in to comment.