would be a simply matter of adding a regex. Something like \^([0-9][0-9]) and then have it pick from an array with the index matching to the number specified.
QString iChat::returnColor(int colorNumber)
{
if (colorNumber == 0)
{
return QColor(255,255,255).name();
//none
}
else
if (colorNumber == 1)
{
return QColor(255,255,255).name();
//white
}
else
if (colorNumber == 2)
{
return QColor(255,0,0).name();
//red
}
else
if (colorNumber == 3)
{
return QColor(148,0,0).name();
//dark_red
}
else
if (colorNumber == 4)
{
return QColor(0,0,255).name();
//blue
}
else
if (colorNumber == 5)
{
return QColor(41,168,219).name();
//dark_blue
}
else
if (colorNumber == 6)
{
return QColor(255,0,255).name();
//purple
}
else
if (colorNumber == 7)
{
return QColor(3,3,3).name();
//black
}
else
if (colorNumber == 8)
{
return QColor(128,128,128).name();
//grey
}
else
if (colorNumber == 9)
{
return QColor(255,255,0).name();
//yellow
}
else
if (colorNumber == 10)
{
return QColor(0,255,0).name();
//green
}
else
if (colorNumber == 11)
{
return QColor(51,153,255).name();
//neptune
}
else
if (colorNumber == 12)
{
return QColor(51,255,153).name();
//ecto
}
else
if (colorNumber == 13)
{
return QColor(153,255,51).name();
//spring
}
else
if (colorNumber == 14)
{
return QColor(153,51,255).name();
//violet
}
else
if (colorNumber == 15)
{
return QColor(255,51,153).name();
//pink
}
else
if (colorNumber == 16)
{
return QColor(255,186,38).name();
//orange
}
else
if (colorNumber == 17)
{
return QColor(242,204,204).name();
//skin
}
else
if (colorNumber == 18)
{
return QColor(255,230,76).name();
//light_orange
}
else
if (colorNumber == 19)
{
return QColor(102,51,0).name();
//brown
}
else
if (colorNumber == 20)
{
return QColor(166,5,36).name();
//blood
}
else
if (colorNumber == 21)
{
return QColor(237,191,166).name();
//relax
}
else
if (colorNumber == 22)
{
return QColor(245,227,247).name();
//relax_active
}
else
if (colorNumber == 23)
{
return QColor(217,71,0).name();
//hold
}
else
if (colorNumber == 24)
{
return QColor(224,133,82).name();
//hold_active
}
else
if (colorNumber == 25)
{
return QColor(128,128,255).name();
//fracture
}
else
if (colorNumber == 26)
{
return QColor(178,255,26).name();
//acid
}
else
if (colorNumber == 27)
{
return QColor(255,51,242).name();
//amethyst
}
else
if (colorNumber == 28)
{
return QColor(0,128,255).name();
//aqua
}
else
if (colorNumber == 29)
{
return QColor(204,102,51).name();
//bronze
}
else
if (colorNumber == 30)
{
return QColor(51,51,51).name();
//demon
}
else
if (colorNumber == 31)
{
return QColor(255,51,230).name();
//dragon
}
else
if (colorNumber == 32)
{
return QColor(153,0,230).name();
//elf
}
else
if (colorNumber == 33)
{
return QColor(255,255,76).name();
//gold
}
else
if (colorNumber == 34)
{
return QColor(51,51,230).name();
//marine
}
else
if (colorNumber == 35)
{
return QColor(255,204,76).name();
//noxious
}
else
if (colorNumber == 36)
{
return QColor(0,128,26).name();
//orc
}
else
if (colorNumber == 37)
{
return QColor(204,204,204).name();
//quicksilver
}
else
if (colorNumber == 38)
{
return QColor(76,255,255).name();
//radioactive
}
else
if (colorNumber == 39)
{
return QColor(153,230,255).name();
//sapphire
}
else
if (colorNumber == 40)
{
return QColor(76,255,76).name();
//toxic
}
else
if (colorNumber == 41)
{
return QColor(255,0,0).name();
//vampire
}
else
if (colorNumber == 42)
{
return QColor(255,204,204).name();
//chronos
}
else
if (colorNumber == 43)
{
return QColor(140,115,166).name();
//gaia
}
else
if (colorNumber == 44)
{
return QColor(191,166,128).name();
//gladiator
}
else
if (colorNumber == 45)
{
return QColor(178,76,76).name();
//hydra
}
else
if (colorNumber == 46)
{
return QColor(230,255,255).name();
//pharos
}
else
if (colorNumber == 47)
{
return QColor(255,255,128).name();
//sphinx
}
else
if (colorNumber == 48)
{
return QColor(128,178,140).name();
//titan
}
else
if (colorNumber == 49)
{
return QColor(166,255,255).name();
//typhon
}
else
if (colorNumber == 50)
{
return QColor(255,255,255).name();
//pure
}
else
if (colorNumber == 51)
{
return QColor(15,15,15).name();
//dark
}
else
if (colorNumber == 52)
{
return QColor(31,31,31).name();
//dusky
}
else
if (colorNumber == 53)
{
return QColor(46,46,46).name();
//coal
}
else
if (colorNumber == 54)
{
return QColor(168,168,168).name();
//ash
}
else
if (colorNumber == 55)
{
return QColor(204,204,204).name();
//ghostly
}
else
if (colorNumber == 56)
{
return QColor(0,0,51).name();
//deepblue
}
else
if (colorNumber == 57)
{
return QColor(199,0,61).name();
//garnet
}
else
if (colorNumber == 58)
{
return QColor(255,13,143).name();
//hotpink
}
else
if (colorNumber == 59)
{
return QColor(112,105,255).name();
//darkcerulean
}
else
if (colorNumber == 60)
{
return QColor(255,156,227).name();
//lightpink
}
else
if (colorNumber == 61)
{
return QColor(255,117,23).name();
//pumpkin
}
else
if (colorNumber == 62)
{
return QColor(31,54,76).name();
//azurite
}
else
if (colorNumber == 63)
{
return QColor(184,194,252).name();
//ivory
}
else
if (colorNumber == 64)
{
return QColor(41,161,156).name();
//parrot
}
else
if (colorNumber == 65)
{
return QColor(99,0,0).name();
//shaman
}
else
if (colorNumber == 66)
{
return QColor(255,212,217).name();
//sakura
}
else
if (colorNumber == 67)
{
return QColor(222,112,112).name();
//peach
}
else
if (colorNumber == 68)
{
return QColor(184,0,0).name();
//flame
}
else
if (colorNumber == 69)
{
return QColor(23,23,23).name();
//deep
}
else
if (colorNumber == 70)
{
return QColor(171,0,0).name();
//ruby
}
else
if (colorNumber == 71)
{
return QColor(255,0,0).name();
//crimson
}
else
if (colorNumber == 72)
{
return QColor(250,189,54).name();
//nova
}
else
if (colorNumber == 73)
{
return QColor(163,3,3).name();
//maroon
}
else
if (colorNumber == 74)
{
return QColor(43,148,219).name();
//coral
}
else
if (colorNumber == 75)
{
return QColor(46,148,186).name();
//indigo
}
else
if (colorNumber == 76)
{
return QColor(173,0,0).name();
//sangria
}
else
if (colorNumber == 77)
{
return QColor(3,3,3).name();
//text
}
else
if (colorNumber == 78)
{
return QColor(255,255,255).name();
//text_bg
}
else
if (colorNumber == 79)
{
return QColor(41,168,219).name();
//text_sel
}
else
if (colorNumber == 80)
{
return QColor(128,128,128).name();
//text_disabled
}
else
if (colorNumber == 81)
{
return QColor(3,3,3).name();
//menu_text
}
else
if (colorNumber == 82)
{
return QColor(255,255,255).name();
//menu_text_bg
}
else
if (colorNumber == 83)
{
return QColor(41,168,219).name();
//menu_text_sel
}
else
if (colorNumber == 84)
{
return QColor(128,128,128).name();
//menu_text_disabled
}
else
if (colorNumber == 85)
{
return QColor(3,3,3).name();
//msg_notype
}
else
if (colorNumber == 86)
{
return QColor(0,0,0).name();
//msg_whisper
}
else
if (colorNumber == 87)
{
return QColor(128,128,128).name();
//msg_server
}
else
if (colorNumber == 88)
{
return QColor(0,0,255).name();
//msg_urlserver
}
else
if (colorNumber == 89)
{
return QColor(148,0,0).name();
//msg_ingame
}
else
if (colorNumber == 90)
{
return QColor(0,0,255).name();
//msg_gamurl
}
else
if (colorNumber == 91)
{
return QColor(3,3,3).name();
//msg_user
}
else
if (colorNumber == 92)
{
return QColor(255,51,0).name();
//msg_player
}
else
if (colorNumber == 93)
{
return QColor(41,168,219).name();
//msg_url
}
else
if (colorNumber == 94)
{
return QColor(255,0,255).name();
//msg_urlsel
}
else
if (colorNumber == 95)
{
return QColor(0,23,0).name();
//opal
}
else
if (colorNumber == 96)
{
return QColor(0,0,0).name();
//void
}
else
return QColor(0,0,0).name();
//unknown
}
Of course it was constructed using this shit and regreplace xD\^(\d\d)
looks more simple.
Also I had color support in iBot. That looked mosterlike:
Of course it was constructed using this shit and regreplace xDQString iChat::returnColor(int colorNumber) { if (colorNumber == 0) { return QColor(255,255,255).name(); //none } else if (colorNumber == 1) { return QColor(255,255,255).name(); //white } else if (colorNumber == 2) { return QColor(255,0,0).name(); //red } else if (colorNumber == 3) { return QColor(148,0,0).name(); //dark_red } else if (colorNumber == 4) { return QColor(0,0,255).name(); //blue } else if (colorNumber == 5) { return QColor(41,168,219).name(); //dark_blue } else if (colorNumber == 6) { return QColor(255,0,255).name(); //purple } else if (colorNumber == 7) { return QColor(3,3,3).name(); //black } else if (colorNumber == 8) { return QColor(128,128,128).name(); //grey } else if (colorNumber == 9) { return QColor(255,255,0).name(); //yellow } else if (colorNumber == 10) { return QColor(0,255,0).name(); //green } else if (colorNumber == 11) { return QColor(51,153,255).name(); //neptune } else if (colorNumber == 12) { return QColor(51,255,153).name(); //ecto } else if (colorNumber == 13) { return QColor(153,255,51).name(); //spring } else if (colorNumber == 14) { return QColor(153,51,255).name(); //violet } else if (colorNumber == 15) { return QColor(255,51,153).name(); //pink } else if (colorNumber == 16) { return QColor(255,186,38).name(); //orange } else if (colorNumber == 17) { return QColor(242,204,204).name(); //skin } else if (colorNumber == 18) { return QColor(255,230,76).name(); //light_orange } else if (colorNumber == 19) { return QColor(102,51,0).name(); //brown } else if (colorNumber == 20) { return QColor(166,5,36).name(); //blood } else if (colorNumber == 21) { return QColor(237,191,166).name(); //relax } else if (colorNumber == 22) { return QColor(245,227,247).name(); //relax_active } else if (colorNumber == 23) { return QColor(217,71,0).name(); //hold } else if (colorNumber == 24) { return QColor(224,133,82).name(); //hold_active } else if (colorNumber == 25) { return QColor(128,128,255).name(); //fracture } else if (colorNumber == 26) { return QColor(178,255,26).name(); //acid } else if (colorNumber == 27) { return QColor(255,51,242).name(); //amethyst } else if (colorNumber == 28) { return QColor(0,128,255).name(); //aqua } else if (colorNumber == 29) { return QColor(204,102,51).name(); //bronze } else if (colorNumber == 30) { return QColor(51,51,51).name(); //demon } else if (colorNumber == 31) { return QColor(255,51,230).name(); //dragon } else if (colorNumber == 32) { return QColor(153,0,230).name(); //elf } else if (colorNumber == 33) { return QColor(255,255,76).name(); //gold } else if (colorNumber == 34) { return QColor(51,51,230).name(); //marine } else if (colorNumber == 35) { return QColor(255,204,76).name(); //noxious } else if (colorNumber == 36) { return QColor(0,128,26).name(); //orc } else if (colorNumber == 37) { return QColor(204,204,204).name(); //quicksilver } else if (colorNumber == 38) { return QColor(76,255,255).name(); //radioactive } else if (colorNumber == 39) { return QColor(153,230,255).name(); //sapphire } else if (colorNumber == 40) { return QColor(76,255,76).name(); //toxic } else if (colorNumber == 41) { return QColor(255,0,0).name(); //vampire } else if (colorNumber == 42) { return QColor(255,204,204).name(); //chronos } else if (colorNumber == 43) { return QColor(140,115,166).name(); //gaia } else if (colorNumber == 44) { return QColor(191,166,128).name(); //gladiator } else if (colorNumber == 45) { return QColor(178,76,76).name(); //hydra } else if (colorNumber == 46) { return QColor(230,255,255).name(); //pharos } else if (colorNumber == 47) { return QColor(255,255,128).name(); //sphinx } else if (colorNumber == 48) { return QColor(128,178,140).name(); //titan } else if (colorNumber == 49) { return QColor(166,255,255).name(); //typhon } else if (colorNumber == 50) { return QColor(255,255,255).name(); //pure } else if (colorNumber == 51) { return QColor(15,15,15).name(); //dark } else if (colorNumber == 52) { return QColor(31,31,31).name(); //dusky } else if (colorNumber == 53) { return QColor(46,46,46).name(); //coal } else if (colorNumber == 54) { return QColor(168,168,168).name(); //ash } else if (colorNumber == 55) { return QColor(204,204,204).name(); //ghostly } else if (colorNumber == 56) { return QColor(0,0,51).name(); //deepblue } else if (colorNumber == 57) { return QColor(199,0,61).name(); //garnet } else if (colorNumber == 58) { return QColor(255,13,143).name(); //hotpink } else if (colorNumber == 59) { return QColor(112,105,255).name(); //darkcerulean } else if (colorNumber == 60) { return QColor(255,156,227).name(); //lightpink } else if (colorNumber == 61) { return QColor(255,117,23).name(); //pumpkin } else if (colorNumber == 62) { return QColor(31,54,76).name(); //azurite } else if (colorNumber == 63) { return QColor(184,194,252).name(); //ivory } else if (colorNumber == 64) { return QColor(41,161,156).name(); //parrot } else if (colorNumber == 65) { return QColor(99,0,0).name(); //shaman } else if (colorNumber == 66) { return QColor(255,212,217).name(); //sakura } else if (colorNumber == 67) { return QColor(222,112,112).name(); //peach } else if (colorNumber == 68) { return QColor(184,0,0).name(); //flame } else if (colorNumber == 69) { return QColor(23,23,23).name(); //deep } else if (colorNumber == 70) { return QColor(171,0,0).name(); //ruby } else if (colorNumber == 71) { return QColor(255,0,0).name(); //crimson } else if (colorNumber == 72) { return QColor(250,189,54).name(); //nova } else if (colorNumber == 73) { return QColor(163,3,3).name(); //maroon } else if (colorNumber == 74) { return QColor(43,148,219).name(); //coral } else if (colorNumber == 75) { return QColor(46,148,186).name(); //indigo } else if (colorNumber == 76) { return QColor(173,0,0).name(); //sangria } else if (colorNumber == 77) { return QColor(3,3,3).name(); //text } else if (colorNumber == 78) { return QColor(255,255,255).name(); //text_bg } else if (colorNumber == 79) { return QColor(41,168,219).name(); //text_sel } else if (colorNumber == 80) { return QColor(128,128,128).name(); //text_disabled } else if (colorNumber == 81) { return QColor(3,3,3).name(); //menu_text } else if (colorNumber == 82) { return QColor(255,255,255).name(); //menu_text_bg } else if (colorNumber == 83) { return QColor(41,168,219).name(); //menu_text_sel } else if (colorNumber == 84) { return QColor(128,128,128).name(); //menu_text_disabled } else if (colorNumber == 85) { return QColor(3,3,3).name(); //msg_notype } else if (colorNumber == 86) { return QColor(0,0,0).name(); //msg_whisper } else if (colorNumber == 87) { return QColor(128,128,128).name(); //msg_server } else if (colorNumber == 88) { return QColor(0,0,255).name(); //msg_urlserver } else if (colorNumber == 89) { return QColor(148,0,0).name(); //msg_ingame } else if (colorNumber == 90) { return QColor(0,0,255).name(); //msg_gamurl } else if (colorNumber == 91) { return QColor(3,3,3).name(); //msg_user } else if (colorNumber == 92) { return QColor(255,51,0).name(); //msg_player } else if (colorNumber == 93) { return QColor(41,168,219).name(); //msg_url } else if (colorNumber == 94) { return QColor(255,0,255).name(); //msg_urlsel } else if (colorNumber == 95) { return QColor(0,23,0).name(); //opal } else if (colorNumber == 96) { return QColor(0,0,0).name(); //void } else return QColor(0,0,0).name(); //unknown }
EDIT: Color codes changed scince than O_o