azncrip4lif
07-09-2002, 10:30 PM
this is a script from a part of my project
#include "stringfinder.h"
#include <vector>
typedef unsigned long DWORD;
#include "color.h"
// Color Manager
ColorManager colorList;
//================================================== ======================================
void ColorManager::init()
{
indexes.clear();
list.clear();
insertpos = 0;
// identifer R G B A Access Index
add("cross" ,255,255,255,200 ); // index: 0
add("team1" ,255, 40, 40 ); // index: 1
add("team2" , 40, 80,255 ); // index: 2
add("special" ,155,155,155 ); // index: 3
add("target" ,102,204, 51 ); // index: 4
add("hud" ,120,120,255 ); // index: 5
add("sound" , 68, 68,255 ); // index: 6
add("bombtimer" ,255, 40, 40 ); // index: 7
add("systime" ,255,255,255 ); // index: 8
add("esp" ,255,255, 0 ); // index: 9
add("back" , 0, 0, 0, 128 ); // index:10
add("radar1" , 80,150, 30, 110 ); // index:11
add("radar2" ,150,150,150, 60 ); // index:12
add("text" , 50,100,255 ); // index:13
add("wire" ,255,255, 0 ); // index:14
add("lambert" ,255,255,255 ); // index:15
add("death" ,255, 0, 0 ); // index:16
add("con_back" , 10, 10, 30, 128 ); // index:17
add("con_text" ,255,255, 30 ); // index:18
add("con_text2" ,160,160,222, 128 ); // index:19
add("con_edit" ,255,255,255 ); // index:20
add("menu_back" , 10, 10, 30, 128 ); // index:21
add("menu_select",150, 70, 10, 128 ); // index:22
add("menu_text" ,255,255,255 ); // index:23
add("text_back" , 0, 0, 0, 128 ); // index:24
add("snake_back" , 0, 0, 0, 128 ); // index:25
add("snake_body" , 0,200, 66, 200 ); // index:26
add("snake_item" , 0, 55,222, 200 ); // index:27
add("snake_wall" ,222, 66, 22, 200 ); // index:28
add("tlight" ,222,111,111, 255 ); // index:29
add("snd_step" ,255,255,255, 255 ); // index:30
add("snd_weapon" ,144,155,255, 255 ); // index:31
add("snd_hit" ,222,100, 61, 254 ); // index:32
add("snd_special",222,111,111, 254 ); // index:33
add("snd_default",222,255,222, 255 ); // index:34
add("team3" ,200,200, 0 ); // index:35
add("team4" , 20,222,100 ); // index:36
add("nade" ,100,255,160 ); // index:37
add("treload" ,255,128, 0 ); // index:38
add("ctreload" , 64,144,255 ); // index:39
add("lamer" ,165, 0,165 ); // index:40
add("lamer-lock" ,222, 0,222 ); // index:41
add("tsound" ,255,144,144 ); // index:42
add("ctsound" ,144,144,255 ); // index:43
add("meterone" ,255,0 , 0 ); // index:44
add("metertwo" ,255,128, 0 ); // index:45
add("meterthree" ,255,255, 0 ); // index:46
add("meterfour" ,128,255, 0 ); // index:47
add("meterfive" ,0 ,255, 0 ); // index:48
add("deadt" , 64, 0, 0 ); // index:49
add("deadct" , 0, 0, 64 ); // index:50
}
//================================================== ======================================
void ColorEntry::fill_missing()
{
compiled = (r<<24) + (g<<16) + (b<<8) + a;
fr= float(r)/255.0f/30.0f;
fg= float(g)/255.0f/30.0f;
fb= float(b)/255.0f/30.0f;
onebased_r=float(r)/255.0f;
onebased_g=float(g)/255.0f;
onebased_b=float(b)/255.0f;
onebased_a=float(a)/255.0f;
}
//================================================== ======================================
void ColorManager::add(const char* name,int r, int g, int b, int a)
{
indexes.add(name,insertpos);
ColorEntry tmp;
tmp.r=r;
tmp.g=g;
tmp.b=b;
tmp.a=a;
tmp.fill_missing();
list.push_back(tmp);
insertpos++;
}
#define BOUND_INTEGER(var,min,max) if((var)>(max)){(var)=(max);};if((var)<(min)){(var)=(min);}
//================================================== ======================================
void ColorManager::set(char* name, char* red, char* green, char* blue, char* alpha)
{
if( !indexes.find(name) ){ return; }
int index = indexes.num;
char format[]="%d";
ColorEntry tmp;
sscanf(red ,format,&tmp.r);
sscanf(green ,format,&tmp.g);
sscanf(blue ,format,&tmp.b);
sscanf(alpha ,format,&tmp.a);
tmp.fill_missing();
BOUND_INTEGER(index,0,int(list.size()-1));
list[index] = tmp;
}
static HSPRITE thelogo = SPR_Load("sprites/thelogo.spr");
SPR_Set(thelogo,255,255,255);
int hleft = frame_h;
wrect_t r;
r.left = 0;
r.right = 200;
r.bottom = 256;
int mod = 0;
if(cvarx.menuback==2)
mod = 3;
if(hleft>=256)
{
hleft -= 256;
r.top = 0;
SPR_Draw(mod+0,x,frame_y+hleft,&r);
}
else if(hleft>0)
{
r.top = 256 - hleft;
hleft = 0;
SPR_Draw(mod+0,x,frame_y+hleft,&r);
}
if(hleft>=256)
{
hleft -= 256;
r.top = 0;
SPR_Draw(mod+1,x,frame_y+hleft,&r);
}
else if(hleft>0)
{
r.top = 256 - hleft;
hleft = 0;
SPR_Draw(mod+1,x,frame_y+hleft,&r);
}
if(hleft>0)
{
r.top = 256 - hleft;
hleft = 0;
SPR_Draw(mod+2,x,frame_y+hleft,&r);
}
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.