see last post
You'd need to use GetTextWidth (string, font), SetGuiObjectSize (gui, obj, width, height), and SetGUIObjectPosition (gui, obj, x, y), e.g (something like):
// Label0 is the label to be changed, at position 5, 5
//Label1 is the label to be moved.
int width = GetTextWidth (text, 0); // where 'text' is the contents of Label0, change font number as needed
int height = GetTextHeight (text, 0, width); // not be needed, if labels will have a fixed height
SetGUIObjectSize (GUI, 0, width, height); // change size of Label0 to fit text
SetGUIObjectPosition (GUI, 1, 5 + width, 5); // move Label1 to position
(You might have to make it int width = GetTextWidth (text, 0) + 1; (and height + 1, as well) to make it fit properly.)
But, wouldn't it be easier to just combine them into a single string?
thanks for that code3, ill try that. No it wouldn't be easier for them to be combined as he labels are filled at different points in different uncitons.
okay. iv decided to follow some of Ashens advice and try and concatonate(sp) the two strings together. Ive searched the manual and there doesn't seem to be a GetLabelText function (why not?) so therefore i was hoping someone could help. I want, in repeatedly execute, to find the text box text, store it in a buffer, find the gui mouseover(already sorted) and stick that in front of the buffer text. Is this possible?
I don't think you can the label text directly (although it'd probably be useful).
Since you've deleted your first post, I'm not totally sure what you're trying to do, but I think you'll have to set a string instead of the label text, then set the label text itself it rep_ex. (Rather than setting the text directly, then changing it in rep_ex.) E.g.:
// Where you're setting the label text at tthe moment
StrFormat (labeltext, "Use ");
//instead of SetLabelText (GUI, LABEL, "Use ");
// Then, in rep_ex
StrCat (labeltext, mouseover); // add the mouseover string to the end of labeltext
SetLabelText (GUI, LABEL, labeltext);
(Sorry if this doesn't make sense, but as I said I'm not too clear on what you're after.)
does this work with @overhotspot@ though? I will repeat what i want if it will help.
I have two labels on my status line. One that when a gui is on, displays the text of that gui object. I also have a label with @overhotspot@. what i want is these two to be combined into one label, their funcitons still to be performed and they must look like they are one item. Thats why i asked for the rearranging of the labels before. But that didn't work as the labels are filled multiple times with different things and move around and get squashed.
Yeah, just set the 'mouseover' string to @OVERHOTSPOT@, and it should be fine. (Again, if I'm understanding what you want.)
okay, i nearly have it working, except that beacuse it is in rep ex, it fills the label up too many times and hte game crashes, is there any way to limit how many times it is entered. still using rep ex?
Damn, forgot about that! Always happens when I post something without testing it.
Maybe use a third string, and StrFormat?
string newtext;
StrFormat (newtext "%s %s", labeltext, mouseover);
Or, use a variable to see if it's been set:
//create an int
int settext;
// Where you're setting the label text at the moment
StrFormat (labeltext, "Use ");
settext = 0; // reset int, so labeltext can update
// Then, in rep_ex
if (settext == 0) { // if labeltext hasn't been changed
StrCat (labeltext, mouseover); // add the mouseover string to the end of labeltext
settext = 1; // mark labeltext as changed
}
SetLabelText (GUI, LABEL, labeltext);
thanks ashen, works beautifully now.