Associateing Enums

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
DEEhunter





Posts: 897
Joined: Sun Jun 19, 2005 4:04 pm
Location: 127.0.0.1
Contact:

Associateing Enums

Post by DEEhunter »

I have a application that edits the many stored bytes of a file. It opens a file and displays the editable information in combo boxes but I can never make it actually read the byte and display the associated information. Say I have this in a read function:

reader.BaseStream.Position = 0xblahblah;
Charactertype Ctype = (Charactertype)reader.ReadByte();
this.combobox.SelectedIndex = (int)Ctype;
playerType = (int)Ctype;
And I have this as my enum:
public enum Charactertype : byte
{
chartype1 = 0xblah,
chartype2 = 0xblah
}
And this as my combobox entries:
chartype1
chartype2
How would I make my read function Read the byte and Select the correct combo box entry? I will also need it to save information if the user changes the entry.
Image

Deviantart | My City | Wmclan | Gamertag | [url=irc://irc.halomods.com/melon]#melon[/url]
User avatar
xzodia




Translator Connoisseur Coagulator

Posts: 1981
Joined: Sun May 15, 2005 10:31 am
Location: UK
Contact:

Re: Associateing Enums

Post by xzodia »

Have you already added the entries to the combobox?
If so then it should work...but try using Decimals instead of hex

reader.BaseStream.Position = -Decimal Offset-;
Charactertype Ctype = (Charactertype)reader.ReadByte();
this.combobox.SelectedIndex = (int)Ctype;
playerType = (int)Ctype;

public enum Charactertype : byte
{
chartype1 = -Decimal Byte-,
chartype2 = -Decimal Byte-
}

And this as my combbox entries:
chartype1
chartype2
Image
Halo 2 Plugins | Lock-on To Just About Anything | My Sites | Snow Hog
Old Plugins you have, upgrade you must...
Always Maintain a High Quality-To-Crap Ratio.
Post Reply