using GUIPopupMenuCtrl to set preferences?
by Richard Preziosi · in Torque Game Engine · 10/22/2009 (8:29 am) · 1 replies
I've managed to get this working by myself to a degree, however instead of setting the text it sets it to the selection number. Gonna post what I have and then what it sets in prefs.cs.
What's happening is it's setting $pref::mypref = "1" or whatever number was selected. The numbers after test actually aren't in the code, just put those there to show that it is selecting the %i number instead of the word. It also changes the text that is visible in the popup after you select your choice to the same number and no longer displays the word. Guess my question is, what am I doing wrong that it is selecting the %i instead of the actual text?
function myGui::onWake()
{
%text = "Test1" TAB "Test2" TAB "Test3" TAB "Test4" TAB "Test5" TAB "Test6" TAB "Test7";
mypref_sort.clear();
for ( %i = 0; %i < getFieldCount(%text); %i++ )
mypref_sort.add( getField( %text, %i ), %i );
mypref_sort.setSelected(0);
}
function mypref_sort::onSelect( %this, %id, %text )
{
%myprefName = $pref::mypref[%text]
echo("Player has selected the preference -" SPC %myprefName );
}What's happening is it's setting $pref::mypref = "1" or whatever number was selected. The numbers after test actually aren't in the code, just put those there to show that it is selecting the %i number instead of the word. It also changes the text that is visible in the popup after you select your choice to the same number and no longer displays the word. Guess my question is, what am I doing wrong that it is selecting the %i instead of the actual text?
Torque Owner Richard Preziosi
WinterLeaf Entertainment
function InventoryGui::onWake() { mypref_sort.clear(); mypref_sort.add("One", 0); mypref_sort.add("Two", 1); mypref_sort.add("Three", 2); mypref_sort.add("Four", 3); myprefsort_sort.setSelected($pref::mypref); } function mypref_sort::onSelect(%this, %id, %text) { %this.setText(%text); $pref::mypref = %text; }I feel like that should work for setting it when it starts to the last clicked preference. However it's not. Also what is the purpose of putting ", 0" after the text in the .add(). Just to let it know that it's a different line?
Thanks a bunch