136
Modification Help / Re: Provide Your Custom Scripts for Streamlining Development
« on: January 06, 2018, 08:39:36 AM »
Gui positioning helpers (setPosition and setExtent should already exist; come on TGE):
Code: [Select]
// Get the gui's X coordinate
function GuiControl::getLeft(%this) {
return getWord(%this.getPosition(), 0);
}
// Get the gui's Y coordinate
function GuiControl::getTop(%this) {
return getWord(%this.getPosition(), 1);
}
// Get the position of the right-side of the GUI element
function GuiControl::getRight(%this) {
return getWord(%this.getPosition(), 0)+getWord(%this.getExtent(), 0);
}
// Get the position of the bottom-side of the GUI element
function GuiControl::getBottom(%this) {
return getWord(%this.getPosition(), 1)+getWord(%this.getExtent(), 1);
}
// Get the width of the GUI
function GuiControl::getWidth(%this) {
return getWord(%this.getExtent(), 0);
}
// Get the height of the GUI
function GuiControl::getHeight(%this) {
return getWord(%this.getExtent(), 1);
}
// Set the position of this GUI. Seriously, this should be default for GUI controls.
function GuiControl::setPosition(%this, %pos) {
%this.resize(getWord(%pos, 0), getWord(%pos, 1), %this.getWidth(), %this.getHeight());
}
// Set the extent of this GUI. Seriously, this should be default for GUI controls.
function GuiControl::setExtent(%this, %ext) {
%this.resize(%this.getLeft(), %this.getTop(), getWord(%ext, 0), getWord(%ext, 1));
}
Not much use for these unless you're making a GUI with graphical design, but I'm sure that'll come around again some time in the future for some other purpose