1.40 bug: Control::setPosition doesn't work?

groov

Veteran XX
so i've known for a while that Control::setPosition doesn't work in 1.40 - not sure why, never really even thought about it just saw that it doesn't do anything

but then bins sent me his config and it has 'popupfix.acs.cs' which seems to have some kind of workaround or fix that its using for its remoteCP/BP/TP stuff

can anyone explain how this works? i don't understand how its fixing/working around setting hud positions

like, i see that its doing

Code:
%id = Control::getId("Popup_Container_T");
	%id.position =  %x ~ " " ~ %y;

but then what's it doing with those vars? i just dont get it

plaes halp i am dumb

Code:
$RemotePopup[B, y] = 25; //bottom print
$RemotePopup[C, y] = 700; //center print
$RemotePopup[T, y] = 25; //top print

$RemotePopup[B, width] = 30; //in percent
$RemotePopup[C, width] = 30; //in percent
$RemotePopup[T, width] = 30; //in percent


function RemotePopup::Init(%which) 
{
	if ( $RemotePopup[%which,Loaded] )
		return;

	$RemotePopup[%which,Loaded] = true;
	
	%name = "Popup_Container_" ~ %which;
	%text = "Popup_Text_" ~ %which;
	
	HUD::New::Shaded(%name, 100 , $RemotePopup[%which, y], $RemotePopup[%which, width] * 1280 / 100, 55, RemotePopup::Wake, RemotePopup::Sleep);
	newObject(%text, FearGuiFormattedText, 0, 1, 20, 20);
	HUD::Add(%name, %text);
	

	Control::SetVisible(%name, false);
}

function RemotePopup::Wake()
{
	%width = getWord(Control::getExtent("PlayGui"),0);
	Control::setExtent("Popup_Container_B", $RemotePopup[B, width] * %width / 100.0, getword(Control::getExtent("Popup_Container_B"),1));
	Control::setExtent("Popup_Container_C", $RemotePopup[C, width] * %width / 100.0, getword(Control::getExtent("Popup_Container_C"),1));
	Control::setExtent("Popup_Container_T", $RemotePopup[T, width] * %width / 100.0, getword(Control::getExtent("Popup_Container_T"),1));
	
	%x = (%width / 2) - (getword(Control::getExtent("Popup_Container_B"),0)/2);
	%y = getword(Control::getPosition("Popup_Container_B"),1);
	
	//fix horrible 1.40 bug where Control::setPosition won't work
	%id = Control::getId("Popup_Container_B");
	%id.position =  %x ~ " " ~ %y;
	
	%x = (%width / 2) - (getword(Control::getExtent("Popup_Container_C"),0)/2);
	%y = getword(Control::getPosition("Popup_Container_C"),1);
	
	%id = Control::getId("Popup_Container_C");
	%id.position =  %x ~ " " ~ %y;
	
	%x = (%width / 2) - (getword(Control::getExtent("Popup_Container_T"),0)/2);
	%y = getword(Control::getPosition("Popup_Container_T"),1);
	
	%id = Control::getId("Popup_Container_T");
	%id.position =  %x ~ " " ~ %y;

	//what should usually work
	//Control::setPosition("Popup_Container_B", %x,%y);
	//Control::setPosition("Popup_Container_C", %x,%y);
	//Control::setPosition("Popup_Container_T", %x,%y);
	
	
}
function RemotePopup::Sleep()
{
	
}


function remoteBP(%manager, %msg, %timeout) //don't rename the params or the attachments will fail
{
	RemotePopup::set("B", %manager, %msg, %timeout);
}
function remoteCP(%manager, %msg, %timeout) //don't rename the params or the attachments will fail
{
	RemotePopup::set("C", %manager, %msg, %timeout);
}
function remoteTP(%manager, %msg, %timeout) //don't rename the params or the attachments will fail
{
	RemotePopup::set("T", %manager, %msg, %timeout);
}

function RemotePopup::set(%which, %manager, %msg, %timeout)
{
	if(%manager != 2048)
		return;
	
	//fix the message of the day thing, should be fixed serverside tho
	if(%timeout == 0)
		%timeout = 10;
		
	
	//echo(%which, %manager, %msg, %timeout);
	%container = "Popup_Container_" ~ %which;
	%text = "Popup_Text_" ~ %which;
	
	if(%msg == "")
	{
		Control::SetVisible(%container, false);
		return;
	}
	if(%timeout)
		Schedule::Add("RemotePopup::Clear(\"" ~ %which ~ "\");", %timeout);
	
	//determine the needed height
	%tmp = %msg;
	%lines = 1;
	echo(string::findsubstr(%tmp, "\n"));
	while( (%idx = string::findsubstr(%tmp, "\n")) != -1)
	{
		%lines++;
		%tmp = string::getsubstr(%tmp, %idx+1, string::len(%tmp));
	}
	Control::setExtent(%container, getword(Control::getExtent(%container),0), (%lines * 14) + 6);
	Control::SetValue(%text, %msg);
	Control::SetVisible(%container, true);
}
function RemotePopup::Clear(%which)
{
	%container = "Popup_Container_" ~ %which;
	%text = "Popup_Text_" ~ %which;

	Control::SetValue(%text, "");
	Control::SetVisible(%container, false);
}
RemotePopup::Init("B");
RemotePopup::Init("C");
RemotePopup::Init("T");

function RemotePopup::RestoreFix(%i) before Hud::Restore {
	%name = $Hud::Huds[%i, name];
	if(String::findSubStr(%name, "Popup_Container_") != -1)
		halt;
}
 
Last edited:
?
those mystic vars turn into control.position = "100 100";

which is a referenced field in the control as you can see in those gui.cs'

Code:
			instant FearGui::FGControl {
				position = "60 0";
 
i had a feeling that was the case but

how do they turn into that tho, is that somewhere in hud.cs? thats where i got lost

i kinda get that he's stopping the hud::restore for those @ the end but where does the %id.position make its way into control.position
 
the engine uses that for the object position (I think)

it's the %objectid.position getting reset to overcome the 1.40 "bug"

when u set a %something.something it acts like a global variable of sorts

probably could explain it better years ago when I still messed with this stuff

edit: i wonder if u can use something similar to add options gui stuff via script instead of editing the gui files...

FUCK U TRIBES
 
Last edited:
that's sorta part of where i was confused

cause i thought a % variable is local to that function so how the heck was it being used

the more time goes by the more i realize how little i still understand about tribe

between what most people have forgotten, and stuff i never learned getting into script so late - there is much tribeknowledge lost to time forever
 
the variable is local but it pointing to some global control, it's pretty much the same if you have a local variable on your stack and you save the pointer to the control in there


here the fix for Control::SetPosition, the internal function is also used for setExtent and also both values are passed to the update function... but that function only updates the extent.
 
Last edited:
rad i will test

i completely forgot what i ever wanted to do with this

but i like that if i remember i can do it

mj u r king as usual if u ever come to north americas we shall smoke many doobies and dabs
 
Is this the bug that caused the reset of playGui elements to not work for HUDs? I remember raging and asking why it wasn't working via script, but when manually doing it via tree(); it would? D:
 
north americas we shall smoke many doobies and dabs
I gonna quote this to redeem later


Is this the bug that caused the reset of playGui elements to not work for HUDs? I remember raging and asking why it wasn't working via script, but when manually doing it via tree(); it would? D:

Dunno if this is the root cause but I'm pretty sure that it caused some problems and made my config look like this while debugging this issue http://i.imgur.com/Xt9oCqN.jpg
 
Is this the bug that caused the reset of playGui elements to not work for HUDs? I remember raging and asking why it wasn't working via script, but when manually doing it via tree(); it would? D:

oh yeah, that was it - we were trying to script your config so it would automatically align the chatdisplay with the ctfhud/itemhud/etc

but then we found Control:setPosition was borked and gave up on the idea
 
Back
Top