Show all Gui controls sequentially
by Ian Omroth Hardingham · 06/13/2007 (10:27 am) · 0 comments
First, put this in an exec-ed cs file.
Run the game, go into a mission (this is important, so that the PlayGui has something to display in front on), open the console and type
Close the console and then start pressing the spacebar to your heart's content. You'll be scrolling through all differently visible gui elements.
new ActionMap(scontMap);
scontMap.bind(keyboard, space, showNextControl);
function testShowCont()
{
showAllGuiConts();
}
function showAllGuiConts()
{
scontMap.push();
$guiShowStage = 1;
$showALLGuis = true;
showCurrentGuiStage();
}
function showCurrentGuiStage()
{
if ($guiShowStage < GuiGroup.getCount())
{
showAllControlsIn(GuiGroup.getObject($guiShowStage));
}
}
function showAllControlsIn(%gui)
{
scontMap.push();
Canvas.setContent(%gui);
findAllControlsIn(%gui);
$currentShowContID = 0;
$currentShowContGui = %gui;
showContMethod();
}
function showNextControl(%val)
{
if (%val)
{
error("NEXT");
if ($currentShowContID >= $nShowConts - 1)
{
if ($showALLGuis)
{
$guiShowStage ++;
showCurrentGuiStage();
}
}
else
{
$currentShowContID += 1;
showContMethod();
}
}
}
function showContMethod()
{
showOnlyControl($showConts[$currentShowContID], $currentShowContGui);
}
function findAllControlsIn(%gui)
{
$nShowConts = 0;
findAllControlsInStage2(%gui);
}
function findAllControlsInStage2(%gui)
{
if (!isLeafCont(%gui))
{
$showConts[$nShowConts] = %gui;
$nShowConts ++;
}
for (%i = 0; %i < %gui.getCount(); %i ++)
{
findAllControlsInStage2(%gui.getObject(%i));
}
}
// a leaf control is one with no children
function isLeafCont(%gui)
{
return %gui.getCount() == 0;
}
// a lower branch control is one in which every child is a leaf
function isLowerBranchCont(%gui)
{
return false;
if (isLeafCont(%gui))
return false;
else
{
error("--------");
error(%gui.getCount());
for (%i = 0; %i < %gui.getCount(); %i ++)
{
error(%gui.getObject(%i).getClassName());
if (!isLeafCont(%gui.getObject(%i)))
{
// we let you off if you're a scroll control
if (%gui.getObject(%i).getClassName() !$= "GuiScrollCtrl")
{
error("DESTROYED");
return false;
}
else
{
error("LET OFF");
}
}
}
return true;
}
}
function showOnlyControl(%control, %ancestor)
{
makeAllCurrentContsInvisible();
%x = %control;
%safetyTest = 0;
while (%x != %ancestor && %safetyTest < 200)
{
%safetyTest ++;
%x.setVisible(1);
%x = %x.getParent();
}
%ancestor.setVisible(1);
if (isLowerBranchCont(%control))
{
makeAllChildrenVisible(%control);
}
}
function makeAllCurrentContsInvisible()
{
for (%i = 0; %i < $nShowConts; %i ++)
{
$showConts[%i].setVisible(0);
}
}
function makeAllChildrenVisible(%gui)
{
for (%i = 0; %i < %gui.getCount(); %i ++)
{
%gui.setVisible(true);
}
}Run the game, go into a mission (this is important, so that the PlayGui has something to display in front on), open the console and type
showAllGuiConts();
Close the console and then start pressing the spacebar to your heart's content. You'll be scrolling through all differently visible gui elements.
About the author
Designer and lead programmer on Frozen Synapse, Frozen Endzone, and Determinance. Co-owner of Mode 7 Games.
