Skip to content

Commit ed7b090

Browse files
committed
Added the ingame version of the mission tip window, only for quickly checking mission text.
The images and objectives are missing and the font doesn't match, but it can at least show text.
1 parent a6f03a0 commit ed7b090

1 file changed

Lines changed: 205 additions & 4 deletions

File tree

LuaMenu/widgets/gui_campaign_handler.lua

Lines changed: 205 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,12 +746,191 @@ local function ProcessPlanetResign(planetID, battleFrames)
746746
WG.Analytics.SendIndexedRepeatEvent("campaign:planet_" .. planetID .. ":difficulty_" .. WG.CampaignData.GetDifficultySetting() .. ":lose", math.floor(battleFrames/30), ":resign")
747747
end
748748

749+
750+
--------------------------------------------------------------------------------
751+
--------------------------------------------------------------------------------
752+
-- Briefing Window (Debug Only)
753+
754+
local function GetNewTextHandler(parentControl, paragraphSpacing, imageSize)
755+
local offset = 0
756+
757+
local holder = Chili.Control:New{
758+
x = 0,
759+
y = 0,
760+
right = 0,
761+
padding = {0,0,0,0},
762+
parent = parentControl,
763+
}
764+
765+
local externalFunctions = {}
766+
767+
function externalFunctions.AddEntry(textBody, imageFile)
768+
local textPos = 4
769+
if imageFile then
770+
textPos = imageSize + 10
771+
772+
local image = Chili.Image:New{
773+
x = 4,
774+
y = offset,
775+
width = imageSize,
776+
height = imageSize,
777+
keepAspect = true,
778+
file = imageFile,
779+
parent = holder
780+
}
781+
local label = Chili.TextBox:New{
782+
x = 0,
783+
y = 0,
784+
right = 4,
785+
height = textSpacing,
786+
align = "left",
787+
valign = "top",
788+
text = "\0\0\0\0" .. imageFile,
789+
fontsize = 12,
790+
parent = image,
791+
}
792+
end
793+
794+
local label = Chili.TextBox:New{
795+
x = textPos,
796+
y = offset + 6,
797+
right = 4,
798+
height = textSpacing,
799+
align = "left",
800+
valign = "top",
801+
text = textBody,
802+
fontsize = 16, -- The ingame font is not the same as chobby, so size is different
803+
parent = holder,
804+
}
805+
806+
local offsetSize = (#label.physicalLines)*14 + 2
807+
if imageFile and (offsetSize < imageSize) then
808+
offsetSize = imageSize
809+
end
810+
811+
offset = offset + offsetSize + paragraphSpacing
812+
holder:SetPos(nil, nil, nil, offset - paragraphSpacing/2)
813+
return offset
814+
end
815+
816+
return externalFunctions
817+
end
818+
819+
local function InitializeBriefingWindow(planetInformation)
820+
local BRIEF_WIDTH = 720
821+
local BRIEF_HEIGHT = 680
822+
823+
local SCROLL_POS = 70
824+
local SCROLL_HEIGHT = 170
825+
local DEFAULT_SCROLL_SIZE = 320
826+
827+
local wantUnpause = true
828+
829+
local externalFunctions = {}
830+
831+
local screenWidth, screenHeight = Spring.GetViewGeometry()
832+
833+
local briefingWindow = Chili.Window:New{
834+
classname = "main_window",
835+
name = 'mission_galaxy_brief',
836+
x = math.floor((screenWidth - BRIEF_WIDTH)/2),
837+
y = math.max(50, math.floor((screenHeight - BRIEF_HEIGHT)/2.5)),
838+
width = BRIEF_WIDTH,
839+
height = BRIEF_HEIGHT,
840+
minWidth = BRIEF_WIDTH,
841+
minHeight = BRIEF_HEIGHT,
842+
dockable = false,
843+
draggable = false,
844+
resizable = false,
845+
tweakDraggable = true,
846+
tweakResizable = true,
847+
parent = Chili.Screen0,
848+
}
849+
briefingWindow:BringToFront()
850+
851+
Chili.Label:New{
852+
x = 0,
853+
y = 12,
854+
width = briefingWindow.width - (briefingWindow.padding[2] + briefingWindow.padding[4]),
855+
height = 26,
856+
fontsize = 44,
857+
align = "center",
858+
caption = "Planet " .. planetInformation.name,
859+
parent = briefingWindow,
860+
}
861+
862+
local mainHolder = Chili.ScrollPanel:New{
863+
x = "4%",
864+
y = SCROLL_POS,
865+
width = "44%",
866+
height = SCROLL_HEIGHT,
867+
horizontalScrollbar = false,
868+
parent = briefingWindow,
869+
}
870+
871+
local bonusHolder
872+
if bonusObjectiveBlock then
873+
bonusHolder = Chili.ScrollPanel:New{
874+
right = "4%",
875+
y = SCROLL_POS,
876+
width = "44%",
877+
height = SCROLL_HEIGHT,
878+
horizontalScrollbar = false,
879+
parent = briefingWindow,
880+
}
881+
end
882+
883+
local textScroll = Chili.ScrollPanel:New{
884+
x = "4%",
885+
y = SCROLL_POS + SCROLL_HEIGHT + 22,
886+
right = "4%",
887+
bottom = 80,
888+
horizontalScrollbar = false,
889+
parent = briefingWindow,
890+
}
891+
local planetTextHandler = GetNewTextHandler(textScroll, 22, 64)
892+
local textSize = planetTextHandler.AddEntry(planetInformation.infoDisplay.extendedText)
893+
894+
if planetInformation.tips then
895+
local tips = tipsOverride or planetInformation.tips
896+
for i = 1, #tips do
897+
textSize = planetTextHandler.AddEntry(tips[i].text, tips[i].image)
898+
end
899+
end
900+
901+
local totalSize = math.min(math.floor(screenHeight*0.90), (BRIEF_HEIGHT + math.max(0, textSize - DEFAULT_SCROLL_SIZE)))
902+
local finalPosition = math.max(50, math.floor((screenHeight - totalSize)/2.5))
903+
briefingWindow:SetPos(nil, finalPosition, nil, totalSize)
904+
905+
function externalFunctions.Close()
906+
briefingWindow:Dispose()
907+
end
908+
909+
Chili.Button:New{
910+
x = "38%",
911+
right = "38%",
912+
bottom = 10,
913+
height = 60,
914+
caption = "Continue",
915+
fontsize = 26,
916+
OnClick = {
917+
function ()
918+
externalFunctions.Close()
919+
end
920+
},
921+
parent = briefingWindow
922+
}
923+
924+
return externalFunctions
925+
end
926+
749927
--------------------------------------------------------------------------------
750928
--------------------------------------------------------------------------------
751929
-- TODO: use shader animation to ease info panel in
752930

753931
local function SelectPlanet(popupOverlay, planetHandler, planetID, planetData, startable)
754932
local Configuration = WG.Chobby.Configuration
933+
local debugBriefWindow = Configuration.debugMode and InitializeBriefingWindow(planetData)
755934

756935
WG.Chobby.interfaceRoot.GetRightPanelHandler().CloseTabs()
757936
WG.Chobby.interfaceRoot.GetMainWindowHandler().CloseTabs()
@@ -957,6 +1136,10 @@ local function SelectPlanet(popupOverlay, planetHandler, planetID, planetData, s
9571136

9581137
-- close button
9591138
local function CloseFunc()
1139+
if debugBriefWindow then
1140+
debugBriefWindow.Close()
1141+
debugBriefWindow = false
1142+
end
9601143
if starmapInfoPanel then
9611144
starmapInfoPanel:Dispose()
9621145
starmapInfoPanel = nil
@@ -979,7 +1162,6 @@ local function SelectPlanet(popupOverlay, planetHandler, planetID, planetData, s
9791162
parent = buttonHolder,
9801163
}
9811164

982-
9831165
WG.Chobby.interfaceRoot.SetBackgroundCloseListener(CloseFunc)
9841166

9851167
-- planet image
@@ -1292,12 +1474,31 @@ local function GetPlanet(popupOverlay, planetListHolder, planetID, planetData, a
12921474
if (not LIVE_TESTING) and Configuration.debugMode then
12931475
local number = Label:New {
12941476
x = 3,
1295-
y = 3,
1477+
y = 0,
12961478
right = 6,
1297-
bottom = 6,
12981479
align = "center",
1299-
valign = "center",
1480+
valign = "top",
13001481
caption = planetID,
1482+
fontsize = 8,
1483+
objectOverrideFont = Configuration:GetFont(3),
1484+
parent = image,
1485+
}
1486+
1487+
local allies = 1 -- The player
1488+
for i = 1, #planetData.gameConfig.aiConfig do
1489+
if planetData.gameConfig.aiConfig[i].allyTeam == 0 then
1490+
allies = allies + 1
1491+
end
1492+
end
1493+
local enemies = #planetData.gameConfig.aiConfig - allies + 1
1494+
local teamSizes = Label:New {
1495+
x = 3,
1496+
y = 20,
1497+
right = 6,
1498+
align = "center",
1499+
valign = "top",
1500+
caption = allies .. "v" .. enemies,
1501+
fontsize = 8,
13011502
objectOverrideFont = Configuration:GetFont(3),
13021503
parent = image,
13031504
}

0 commit comments

Comments
 (0)