![]() |
|
|
|
|
#1 |
|
Enumerations.
Okay, lets say I've got an enum eMusicBand declared:
enum eMusicBand { BAND_SickOfItAll, BAND_BadBrains, BAND_MinorThreat, BAND_Cro-Mags, BAND_Fugazi, }; I've got a eMusicBand variable 'CurrentBand' and I've got a button in a UWindow, and now, if someone clicks the button, I want 'CurrentBand' to take the 'next' value, e.g. if CurrentBand==BAND_BadBrains , this would be BAND_MinorThreat. Is there a way to do this, except, of course, to write a long switch statement like Switch (CurrentBand) { Case BAND_MinorThreat: CurrentBand = BAND_CroMags; break; ... } I mean, something like CurrentBand++ (doesn't work of course), I thought this should be possible, since each item in an enum does have an int value... Thanks in advantage, RiP
__________________
You're only jealous because the voices are talking to me and not to you! |
|
|
|
|
|
|
#2 |
|
Write a long If statement.
|
|
|
|
|
|
|
#3 |
|
I did. What a work
__________________
You're only jealous because the voices are talking to me and not to you! |
|
|
|
|
|
|
#4 |
|
Registered User
Join Date: Feb. 10th, 2002
Posts: 1
|
CurrentBand++ should work. Have you tried it? After all, enums are stored as a byte. Maybe you would have something like (CurrentBand++) % 5 to cycle through the enum without leaving its range.
__________________
lead coder at Kage:Out of the Shadows, the Shadowrun Modification for UT |
|
|
|
|
|
#5 |
|
Coder
Join Date: Oct. 22nd, 2000
Location: You really don't want to know... trust me...
Posts: 176
|
...and if that doesn't work, you can always write something like this:
local byte tempb; tempb = CurrentBand; tempb++; CurrentBand = tempb; Or a long if statement. Eater. |
|
|
|
|
|
#6 |
|
I agree with JoeWang. It should work just like a byte value. An enumerator is just a fancy way to work with constants instead of abstract numbers. Here's how to properly cycle through that list using the technique he mentioned. I hope it works.
Code:
if (CurrentBand==BAND_Fugazi) //the last band in your enumerator
{
CurrentBand=BAND_SickOfItAll;
//which will be changed to the first one in your enumerator
}
else
{
//otherwise, you just need it to be changed to the next one in your list
CurrentBand++;
}
|
|
|
|
|
|
|
#7 |
|
I tried both solutions, the CurrentBand++ one ("...types are incompatible with ++") and the CurrentBand=tempb one ("... bad expression in '=' "). Casting didn't work either
__________________
You're only jealous because the voices are talking to me and not to you! |
|
|
|
|
|
|
#8 |
|
Coder
Join Date: Oct. 22nd, 2000
Location: You really don't want to know... trust me...
Posts: 176
|
That's not possible... I KNOW you can assign byte values to enums - it's even done in the UT code for the ChallangeHUD, when setting Canvas.Style! So why the hell can't you assing enums to bytes?! Damn UScript.
Damn... that sucks. Eater. |
|
|
|
|
|
#9 | |
|
Quote:
why is life so difficult...... ? |
||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|