[Windows Mobile Software Development] Co0kieMonster:
This thread is mainly intended for developers - it's a proof-of-concept to show a new approach to the classic background for all tabs mod.

This is only a proof-of-concept and I won't develop it further because I don't use BG4all myself. But my hope is that the basic concept will be helpful to others, and that it will develop from there.

Traditionally the mod is made by moving the "HomeBackgroud" instance from home.mode9 to manila.mode9. The problem with this is that those are 2 of the most important mode9 files in manila, so they are also needed for a lot of other manila mods.

The result of this is that other mods now have to be made in 2 version: one with bg4all and one without. Also, if a new manila build changes one of the mode9s, the bg4all mod needs to be remade.

A different way of doing it is thought the lua scripts. Specifically only one script needs to be modified to make bg4all:

homebackground.luac

.

This way

no mode9 files are modified

so bg4all can be compatible with a lot of other mods. This way mods don't have to be redone to include bg4all.

I've included the lua source of the modified homebackground.luac for manila 2.5 with comments about what’s been changed, but you can also compare it to the original to get a better idea. At the bottom is a ready-made cab with bg4all for manila 2.5.

Here's the lua code:

-- Decompiled using luadec 3.2
-- File name: 090a4ee8_manila -- \windows\htc\home\scripts\HomeBackground.luac

require("asyncimageloader")
require("shell_svc")
CachedImagePath = "\\Windows\\HomeBackground.img"

HomeBackground.Opacity.value = 0
-- Home Background is not needed at all, so it should be made invisible
-- and we can forget about it from here on

-- from this point on anything that operated on HomeBackground is replaced with BackGroundLevel0
-- compare with the original 090a4ee8_manila to see the differences
-- BackGroundLevel0 is the default manila background that appears on all tabs

InterpolateOpacity = function(l_1_0, l_1_1)
l_1_1.Opacity:Interpolate(l_1_0, 20, 0, Interpolate_EaseOutQuad)
end

BackgroundWidth = 480
BackgroundHeight = 696
LoadDefaultBackground = function()
InterpolateOpacity(0, BackGroundLevel0)
if HomeTitleBar ~= nil then
HomeTitleBar.Opacity.value = 0
_application.Navigation.TabTrayOpacity = 100
end
end

BackgroundImageLoaded = function(l_3_0, l_3_1)
if l_3_0 then
if l_3_1 == 1 then
BackGroundLevel0.TextureCoords.width = l_3_0.TextureCoords.width
BackGroundLevel0.TextureCoords.height = l_3_0.TextureCoords.height
local l_3_2 = l_3_0.TextureCoords.width * l_3_0.Image.Width
local l_3_3 = l_3_0.TextureCoords.height * l_3_0.Image.Height
_StoreImageWidth = l_3_2
_StoreImageHeight = l_3_3
local l_3_4 = l_3_2 / BackgroundWidth
local l_3_5 = l_3_3 / BackgroundHeight
if l_3_4 < l_3_5 then
BackGroundLevel0.Size.height = l_3_3 / l_3_2 * BackgroundWidth
BackGroundLevel0.Size.width = BackgroundWidth
else
BackGroundLevel0.Size.width = l_3_2 / l_3_3 * BackgroundHeight
BackGroundLevel0.Size.height = BackgroundHeight
end
BackGroundLevel0.Position.x = (BackgroundWidth - BackGroundLevel0.Size.width) / 2
BackGroundLevel0.Position.y = 696 - (BackgroundHeight - BackGroundLevel0.Size.height) / 2 -- +696 is added here because the BG0's camera y-axis is set at the bottom, while Home's camera was set at the top
BackGroundLevel0:SetTexture(l_3_0.Image)
InterpolateOpacity(100, BackGroundLevel0)
if HomeTitleBar ~= nil then
local l_3_6 = _application.Store:GetIntValue(Lifetime_Application, "ShowCacheHomePage")
if l_3_6 == 1 then
HomeTitleBar.Opacity.value = 60
_application.Navigation.TabTrayOpacity = 60
end
end
else
LoadDefaultBackground()
end
collectgarbage("collect")
BackgroundAsyncImageLoader = nil
elseif _StoreImageWidth and _StoreImageHeight then
local l_3_7 = _StoreImageWidth / BackgroundWidth
local l_3_8 = _StoreImageHeight / BackgroundHeight
if l_3_7 < l_3_8 then
BackGroundLevel0.Size.height = _StoreImageHeight / _StoreImageWidth * BackgroundWidth
BackGroundLevel0.Size.width = BackgroundWidth
else
BackGroundLevel0.Size.width = _StoreImageWidth / _StoreImageHeight * BackgroundHeight
BackGroundLevel0.Size.height = BackgroundHeight
end
BackGroundLevel0.Position.x = (BackgroundWidth - BackGroundLevel0.Size.width) / 2
BackGroundLevel0.Position.y = 696 - (BackgroundHeight - BackGroundLevel0.Size.height) / 2 -- +696 same as before
end
end

BeginLoadBackgroundImage = function(l_4_0)
if Shell_HaveDRMRightsToFile(machineStatus.HomeBackgroundPath.Value, false) then
BackgroundAsyncImageLoader = AsyncImageLoader()
BackgroundAsyncImageLoader.Priority = TaskPriority_Normal
BackgroundAsyncImageLoader.OnComplete:connect(BackgroundImageLoaded)
BackgroundAsyncImageLoader:BeginLoadFile(l_4_0, false, true)
else
machineStatus.HomeBackgroundPath.Value = ""
machineStatus.CachedBackgroundPath.Value = ""
LoadDefaultBackground()
end
end

BackgroundImageResized = function(l_5_0, l_5_1)
if l_5_1 == 1 and machineStatus.HomeBackgroundPath.Value ~= "" then
machineStatus.CachedBackgroundPath.Value = machineStatus.HomeBackgroundPath.Value
BeginLoadBackgroundImage(CachedImagePath)
else
LoadDefaultBackground()
BackgroundAsyncImageLoader = nil
end
collectgarbage("collect")
end

machineStatus_OnCustomBackgroundUpdate = function()
if _config_os == "windowsmobile" then
local l_6_0 = machineStatus.HomeBackgroundPath.Value
local l_6_1 = machineStatus.CachedBackgroundPath.Value
if l_6_0 ~= l_6_1 then
if BackgroundAsyncImageFactoryLoader ~= nil and BackgroundAsyncImageFactoryLoader:IsRunning() then
BackgroundAsyncImageFactoryLoader = nil
collectgarbage("collect")
end
if BackgroundAsyncImageLoader ~= nil and BackgroundAsyncImageLoader:IsRunning() then
BackgroundAsyncImageLoader = nil
collectgarbage("collect")
end
if l_6_0 == "" then
machineStatus.CachedBackgroundPath.Value = machineStatus.HomeBackgroundPath.Value
LoadDefaultBackground()
else
BackgroundAsyncImageFactoryLoader = AsyncImageFactoryLoader()
BackgroundAsyncImageFactoryLoader.Priority = TaskPriority_BelowNormal
BackgroundAsyncImageFactoryLoader.Quality = 100
BackgroundAsyncImageFactoryLoader.OnComplete:connect(BackgroundImageResized)
BackgroundAsyncImageFactoryLoader:ResizeImage(machineStatus.HomeBackgroundPath.Value, CachedImagePath, EncoderType_JPEG, 512, 512, true, false)
end
elseif l_6_1 ~= "" then
BeginLoadBackgroundImage(CachedImagePath)
else
LoadDefaultBackground()
end
else
LoadDefaultBackground()
end
end

if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
require("RotationTemplate")
HomeBackground_ScreenRotation = class(RotationTemplate)
HomeBackground_ScreenRotation.__init = function(l_7_0)
RotationTemplate.__init(l_7_0)
trace("+++++++[HomeBackground] : __init")
end

HomeBackground_ScreenRotation.OnScreenRotation = function(l_8_0)
trace("+++++++[HomeBackground] : OnScreenRotation")
if _application.Orientation == ScreenOrientation_Portrait then
BackgroundWidth = 480
BackgroundHeight = 696
elseif _application.Orientation == ScreenOrientation_Landscape then
BackgroundWidth = 805
BackgroundHeight = 376
end
BackgroundImageLoaded(nil, nil)
end

end
if _config_os == "windowsmobile" then
if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
_HomeBackground_ScreenRotation = HomeBackground_ScreenRotation()
end
machineStatus.HomeBackgroundPath.OnValueChanged:connect(machineStatus_OnCustomBackgroundUpdate)
_application.OnOrientationChanged:connect(machineStatus_OnCustomBackgroundUpdate) -- needed for correct rotation
machineStatus_OnCustomBackgroundUpdate()
end