NewsUnrealEdFilesModsFragBULiandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 10th Feb 2002, 03:20 AM   #1
RestInPieces
Registered User
 
RestInPieces's Avatar
 
Join Date: Sep. 20th, 2001
Posts: 65
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!
RestInPieces is offline   Reply With Quote
Old 10th Feb 2002, 08:50 AM   #2
Captain Kewl
I know kewl.
 
Captain Kewl's Avatar
 
Join Date: Feb. 13th, 2001
Location: IN YOUR HOUSE
Posts: 794
Write a long If statement.
Captain Kewl is offline   Reply With Quote
Old 10th Feb 2002, 02:39 PM   #3
RestInPieces
Registered User
 
RestInPieces's Avatar
 
Join Date: Sep. 20th, 2001
Posts: 65
Talking

I did. What a work
__________________
You're only jealous because the voices are talking to me and not to you!
RestInPieces is offline   Reply With Quote
Old 10th Feb 2002, 02:54 PM   #4
JoeWang(Kage)
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
JoeWang(Kage) is offline   Reply With Quote
Old 10th Feb 2002, 05:23 PM   #5
Eater1
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.
Eater1 is offline   Reply With Quote
Old 11th Feb 2002, 12:08 AM   #6
Techno JF
He Who Has Powerful Words
 
Techno JF's Avatar
 
Join Date: Apr. 8th, 2001
Location: a few steps away from Oneiros.
Posts: 961
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++;
}
Techno JF is offline   Reply With Quote
Old 11th Feb 2002, 04:09 AM   #7
RestInPieces
Registered User
 
RestInPieces's Avatar
 
Join Date: Sep. 20th, 2001
Posts: 65
Smile 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
__________________
You're only jealous because the voices are talking to me and not to you!
RestInPieces is offline   Reply With Quote
Old 11th Feb 2002, 07:56 PM   #8
Eater1
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.
Eater1 is offline   Reply With Quote
Old 14th Feb 2002, 09:23 AM   #9
Blödsinn machen
cannon fodder
 
Blödsinn machen's Avatar
 
Join Date: Dec. 4th, 2001
Location: Switzerland
Posts: 68
Quote:
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...... ?
Blödsinn machen is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:29 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer