World Editor Bug and fix suggestion
by Duncan Gray · in Torque Game Engine · 11/23/2005 (10:22 pm) · 2 replies
The terrain texture editor uses a GuiFilterCtrl item with little sliders to set the alpha values of the overlapping textures according to height, slope etc.
Next to it is a GuiTextEditSliderCtrl which is supposed to let you adjust the amount of sliders in the filter, but it is broken in 1.4 as well as 1.3, 1.2 etc
Heres what I found: GuiFilterCtrl is not broken at all. If you type
GuiTextEditSliderCtrl is broken. The "variable" does not get set and the "command" does not get executed at all so these values never get passed to the GuiFilterCtrl
I did a work around for my own purposes by adding a onAction(); call which gets the "command" executed at least.
and at the end of void GuiTextEditSliderCtrl::onMouseDown(const GuiEvent &event), add an
onAction(); call just before the return;
Next I name the GuiTextEditSliderCtrl control(s) in the gui file so that I could access it from script.
I then removed/transfered the "command" data to an ::onAction script call where I set the relevant variable, as follows.
Do the same for the slope slider.
This does "make it work" but the GuiTextEditSliderCtrl is used extensively in the editor and should be fixed properly so the the "variable" and "command" settings work as expected.
Next to it is a GuiTextEditSliderCtrl which is supposed to let you adjust the amount of sliders in the filter, but it is broken in 1.4 as well as 1.3, 1.2 etc
Heres what I found: GuiFilterCtrl is not broken at all. If you type
TextureHeightFilter.controlPoints = 10;in the console while the height adjust is active, the GuiFilterCtrl will display 10 sliders.
GuiTextEditSliderCtrl is broken. The "variable" does not get set and the "command" does not get executed at all so these values never get passed to the GuiFilterCtrl
I did a work around for my own purposes by adding a onAction(); call which gets the "command" executed at least.
bool GuiTextEditSliderCtrl::onKeyDown(const GuiEvent &event)
{
Parent::onKeyDown(event);
onAction();
return true;
}and at the end of void GuiTextEditSliderCtrl::onMouseDown(const GuiEvent &event), add an
onAction(); call just before the return;
Next I name the GuiTextEditSliderCtrl control(s) in the gui file so that I could access it from script.
I then removed/transfered the "command" data to an ::onAction script call where I set the relevant variable, as follows.
function HeightSlider::onAction()
{
%value = HeightSlider.getValue();
TextureHeightFilter.controlPoints = %value;
Texture::saveOperation(); Texture::previewOperation();
}Do the same for the slope slider.
This does "make it work" but the GuiTextEditSliderCtrl is used extensively in the editor and should be fixed properly so the the "variable" and "command" settings work as expected.
About the author
Torque Owner Duncan Gray
Regarding the GuiTextEditSliderCtrl "variable" in the common/editor/Editorgui.gui file
There is at least an attempt made to set the "variable" by the parent ( GuiControl::setVariable), but it prepends a $ and and tries to set it as a global script variable.
The GuiFilterCtrl.controlPoint failed to get set in this manner so I looked a bit further before running out of time.
The GuiFilterCtrl.controlPoints variable was created using addfield not con::addvariable. The 1st creates a method pointer, the latter creates a void pointer.
Con::setVariable(mConsoleVariable, value); seems to expect a console variable as parameter, not a "addfield" type variable.
Regarding the GuiTextEditSliderCtrl "command" in the common/editor/Editorgui.gui file
The "command" never seems to get executed. I think the author assumed the parent would do it but thats not the case here.