Enumerations.

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

RestInPieces

New Member
Sep 20, 2001
65
0
0
www.Creep-World.net
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 :)
 

JoeWang(Kage)

New Member
Feb 10, 2002
1
0
0
kage.unrealism.com
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.
 

Techno JF

He Who Has Powerful Words
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++;
}
 

RestInPieces

New Member
Sep 20, 2001
65
0
0
www.Creep-World.net
Thanks anyway...

I tried both solutions, the CurrentBand++ one ("...types are incompatible with ++") and the CurrentBand=tempb one ("... bad expression in '=' "). Casting didn't work either :(
 

Blödsinn machen

cannon fodder
Dec 4, 2001
68
0
0
Switzerland
dwmade.stormpages.com
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.

Canvas.Style is a byte variable, so in fact an enum value is being assigned to byte, not vice-versa. The opposite seems not to work, though (i.e. casting a byte to an enum).
why is life so difficult...... ?