Exemplo n.º 1
0
static void draw_time() {
	int min, sec, hundr;
	GetTimeComponents (g_game.time, &min, &sec, &hundr);
	string timestr = Int_StrN (min, 2);
	string secstr = Int_StrN (sec, 2);
	string hundrstr = Int_StrN (hundr, 2);

	timestr += ":";
	timestr += secstr;

	if (param.use_papercut_font < 2) {
		Tex.Draw (CHRON_ICON, 0, -4, 1);
		Tex.DrawNumStr (timestr, 60, 10, 1, colWhite);
		Tex.DrawNumStr (hundrstr, 176, 10, 0.7, colWhite);
	} else {

		/*
			glEnable (GL_LINE_SMOOTH);
			glEnable (GL_BLEND);
			glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
			glLineWidth (1.5);
		*/
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);

		//Tex.Draw (T_TIME, 16, 20, 1);
		FT.SetColor (colDYell);
		FT.SetSize (32);
		FT.DrawString (160, 6, hundrstr);
		FT.SetSize (42);
		FT.DrawString (70, 10, timestr);
	}
}
Exemplo n.º 2
0
bool CScore::SaveHighScore () const {
	CSPList splist ((int)Scorelist.size()*MAX_SCORES);

	for (size_t li=0; li<Scorelist.size(); li++) {
		const TScoreList* lst = &Scorelist[li];
		if (lst != NULL) {
			int num = lst->numScores;
			if (num > 0) {
				for (int sc=0; sc<num; sc++) {
					const TScore& score = lst->scores[sc];
					string line = "*[course] " + Course.CourseList[li].dir;
					line += " [plyr] " + score.player;
					line += " [pts] " + Int_StrN (score.points);
					line += " [herr] " + Int_StrN (score.herrings);
					line += " [time] " + Float_StrN (score.time, 1);
					splist.Add (line);
				}
			}
		}
	}
	if (!splist.Save (param.config_dir, "highscore")) {
		Message ("could not save highscore list");
		return false;
	}
	return true;
}
Exemplo n.º 3
0
string CWinsys::GetResName (size_t idx) const {
	if (idx >= NUM_RESOLUTIONS) return "800 x 600";
	if (idx == 0) return ("auto");
	string line = Int_StrN (resolutions[idx].width);
	line += " x " + Int_StrN (resolutions[idx].height);
	return line;
}
Exemplo n.º 4
0
void CCharShape::SaveCharNodes (string dir, string filename) {
	CSPList list (MAX_CHAR_NODES + 10);
	string line, order, joint;
	TCharNode *node;
	TCharAction *act;
	int  i, ii, aa;
	TVector3 rotation;
	bool rotflag;

	list.Add ("# Generated by Tuxracer tools");
	list.Add ("");
	if (numMatlines > 0) {
		list.Add ("# Materials:");
		for (i=0; i<numMatlines; i++) list.Add (Matlines[i]);
		list.Add ("");
	}

	list.Add ("# Nodes:");
	for (i=1; i<numNodes; i++) {
		node = Nodes[i];
		act = Actions[i];
		if (node->parent_name >= node->node_name) Message ("wrong parent index");
		line = "*[node] " + Int_StrN (node->node_name);
		line += " [par] " + Int_StrN (node->parent_name); 
		order = act->order;
		rotation = NullVec;
		rotflag = false;

		if (order.size() > 0) {
			line += " [order] " + order;
			for (ii=0; ii<(int)order.size(); ii++) {
				aa = order.at(ii)-48;	
				switch (aa) {
					case 0: line += " [trans] " + Vector_StrN (act->vec[ii], 2); break;
					case 4: line += " [scale] " + Vector_StrN (act->vec[ii], 2); break;
 					case 1: rotation.x = act->dval[ii]; rotflag = true; break;
 					case 2: rotation.y = act->dval[ii]; rotflag = true; break;
 					case 3: rotation.z = act->dval[ii]; rotflag = true; break;
					case 5: line += " [vis] " + Float_StrN (act->dval[ii], 0); break;
					case 9: rotation.z = act->dval[ii]; rotflag = true; break;
				}
			}
			if (rotflag) line += " [rot] " + Vector_StrN (rotation, 2);
		}
		if (act->mat.size() > 0) line += " [mat] " + act->mat;
		if (node->joint.size() > 0) line += " [joint] " + node->joint;
		if (act->name.size() > 0) line += " [name] " + act->name;
		if (node->render_shadow) line += " [shad] 1";
		
		list.Add (line);
		if (i<numNodes-3) {
			if (node->visible && !Nodes[i+1]->visible) list.Add ("");
			joint = Nodes[i+2]->joint;
			if (joint.size() > 0) list.Add ("# " + joint);
		}
	}	
	list.Save (dir, filename);
}
Exemplo n.º 5
0
void CScore::Loop () {
	int ww = Winsys.resolution.width;
	int hh = Winsys.resolution.height;

	Music.Update ();
	check_gl_error();
	ClearRenderContext ();
	ScopedRenderMode rm(GUI);
	SetupGuiDisplay ();

	if (param.ui_snow) {
		update_ui_snow ();
		draw_ui_snow();
	}

	Tex.Draw (BOTTOM_LEFT, 0, hh - 256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);
	//Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), Winsys.scale);

//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top,
//			0, colMBackgr, colBlack, 0.2);

	FT.AutoSizeN (7);
	FT.SetColor (colWhite);
	FT.DrawString (CENTER, AutoYPosN (Winsys.resolution.width > Winsys.resolution.height ? 6 : 22), Trans.Text(62));

	DrawFrameX (area.left, frametop, framewidth - 93, frameheight, 3, colMBackgr, colWhite, 1.0);
	FT.AutoSizeN (4);
	FT.SetColor (colDYell);
	FT.DrawString (area.left+20, frametop, CourseList[course->GetValue()].name);

	const TScoreList *list = Score.GetScorelist (course->GetValue());

	FT.SetColor (colWhite);
	if (list != NULL) {
		FT.AutoSizeN (3);
		if (list->numScores < 1) {
			FT.DrawString (CENTER, area.top + 140, Trans.Text(63));
		} else {
			for (int i=0; i<min(MAX_SCORES, list->numScores); i++) {
				int y = listtop + i*linedist;
				FT.DrawString (area.left, y, ordinals[i]);
				FT.DrawString (area.left + dd1, y, Int_StrN (list->scores[i].points));
				FT.DrawString (area.left + dd2, y, list->scores[i].player);
				FT.DrawString (area.left + dd3, y,
				               Int_StrN (list->scores[i].herrings) + "  herrings");
				FT.DrawString (area.left + dd4, y,
				               Float_StrN (list->scores[i].time, 1) + "  sec");
			}
		}
	} else Message ("score list out of range");

	DrawGUI();

	Winsys.SwapBuffers();
}
Exemplo n.º 6
0
void PrintGLInfo (){
#ifndef __PSP__
    char *extensions;
    char *p, *oldp;
    int i;
    GLint int_val;
    GLfloat float_val;
    GLboolean boolean_val;
	string ss;

    Message ("Gl vendor: ", (char*)glGetString (GL_VENDOR));
    Message ("Gl renderer: ", (char*)glGetString (GL_RENDERER));
    Message ("Gl version: ", (char*)glGetString (GL_VERSION));
    extensions = NewStr ((char*) glGetString (GL_EXTENSIONS));
    Message ("", "");
	Message ("Gl extensions:", "");
	Message ("", "");
	
    oldp = extensions;
    while ((p=strchr(oldp,' '))) {
		*p='\0';
		Message (oldp,"");
		oldp = p+1;
    }
    if (*oldp) Message (oldp,"");

    free (extensions);
	Message ("", "");
    for (i=0; i<(int)(sizeof(gl_values)/sizeof(gl_values[0])); i++) {
		switch (gl_values[i].type) {
			case GL_INT:
	    	glGetIntegerv (gl_values[i].value, &int_val);
		    ss = Int_StrN (int_val);
			Message (gl_values[i].name, ss.c_str());
		    break;

			case GL_FLOAT:
		    glGetFloatv (gl_values[i].value, &float_val);
    		ss = Float_StrN (float_val, 2);
			Message (gl_values[i].name, ss.c_str());
		    break;

			case GL_UNSIGNED_BYTE:
	    	glGetBooleanv (gl_values[i].value, &boolean_val);
		    ss = Int_StrN (boolean_val);
			Message (gl_values[i].name, ss.c_str());
		    break;

			default:
			Message ("","");
		}
    }
#endif
}
Exemplo n.º 7
0
void SPAddIndx3N  (string &s, const string &tag, const TIndex3 val) {
	s += "[";
	s += tag;
	s += "]";
	s += ' ';
	s += Int_StrN (val.i);
	s += ' ';
	s += Int_StrN (val.j);
	s += ' ';
	s += Int_StrN (val.k);
}
Exemplo n.º 8
0
void SPAddIndx4N  (string &s, const string &tag, const TIndex4 val) {
	s += '[';
	s += tag;
	s += ']';
	s += ' ';
	s += Int_StrN (val.i);
	s += ' ';
	s += Int_StrN (val.j);
	s += ' ';
	s += Int_StrN (val.k);
	s += ' ';
	s += Int_StrN (val.l);
}
Exemplo n.º 9
0
void PrintGLInfo () {
    GLint int_val;
    GLfloat float_val;
    GLboolean boolean_val;
	string ss;

    Message ("Gl vendor: ", (char*)glGetString (GL_VENDOR));
    Message ("Gl renderer: ", (char*)glGetString (GL_RENDERER));
    Message ("Gl version: ", (char*)glGetString (GL_VERSION));
    string extensions = (char*)glGetString (GL_EXTENSIONS);
    Message ("", "");
	Message ("Gl extensions:", "");
	Message ("", "");

	size_t oldpos = 0;
	size_t pos;
    while ((pos = extensions.find(' ', oldpos)) != string::npos) {
		string s = extensions.substr(oldpos, pos-oldpos);
		Message(s, "");
		oldpos = pos+1;
    }
	Message(extensions.substr(oldpos), "");

	Message ("", "");
    for (int i=0; i<(int)(sizeof(gl_values)/sizeof(gl_values[0])); i++) {
		switch (gl_values[i].type) {
			case GL_INT:
	    	glGetIntegerv (gl_values[i].value, &int_val);
		    ss = Int_StrN (int_val);
			Message (gl_values[i].name, ss);
		    break;

			case GL_FLOAT:
		    glGetFloatv (gl_values[i].value, &float_val);
    		ss = Float_StrN (float_val, 2);
			Message (gl_values[i].name, ss);
		    break;

			case GL_UNSIGNED_BYTE:
	    	glGetBooleanv (gl_values[i].value, &boolean_val);
		    ss = Int_StrN (boolean_val);
			Message (gl_values[i].name, ss);
		    break;

			default:
			Message ("","");
		}
    }
}
Exemplo n.º 10
0
void CGameConfig::Loop () {
	int ww = Winsys.resolution.width;
	int hh = Winsys.resolution.height;

	Music.Update ();

	check_gl_error();
	Music.Update ();
	ScopedRenderMode rm(GUI);
	ClearRenderContext ();
	SetupGuiDisplay ();

	if (param.ui_snow) {
		update_ui_snow ();
		draw_ui_snow();
	}

	//Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), 1.0);
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);

//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top,
//			0, colMBackgr, colBlack, 0.2);

	FT.AutoSizeN (4);

	FT.SetColor (colWhite);
	FT.DrawString (area.left, area.top, Trans.Text(86));
	FT.DrawString (area.left, area.top + dd, Trans.Text(94));
	FT.DrawString (area.left, area.top + dd * 2, Trans.Text(33));
	FT.DrawString (area.left, area.top + dd * 3, Trans.Text(34));
	FT.DrawString (area.left, area.top + dd * 4, Trans.Text(36));
	FT.DrawString (area.left, area.top + dd * 5, Trans.Text(35));

	FT.DrawString (area.left+240, area.top, Trans.Text(87 + vid_orient->GetValue()));
	FT.DrawString (area.left+240, area.top + dd, Float_StrN(sensit->GetValue() / 10.0f, 1));
	FT.DrawString (area.left+240, area.top + dd * 2, Int_StrN (mus_vol->GetValue()));
	FT.DrawString (area.left+240, area.top + dd * 3, Int_StrN (sound_vol->GetValue()));
	FT.DrawString (area.left+240, area.top + dd * 4, Int_StrN (detail_level->GetValue()));
	FT.DrawString (area.left+240, area.top + dd * 5, Trans.languages[language->GetValue()].language);

	DrawGUI();

	Reshape (ww, hh);
	Winsys.SwapBuffers ();
}
Exemplo n.º 11
0
void CTexture::LoadTextureList () {
    int rep, id;
    string texfile, line, name;

    TextureIndex = "";
    CSPList list (200);
    if (list.Load (param.tex_dir, "textures.lst")) {
        for (int i=0; i<list.Count(); i++) {
            line = list.Line (i);
            name = SPStrN (line, "name", "");
            id = SPIntN (line, "id", 0);
            texfile = SPStrN (line, "file", "");
            rep = SPIntN (line, "repeat", 0);
            if (id >= 0 && id < MAX_COMMON_TEX) {
                if (rep>0) CommonTex[id] =
                        LoadMipmapTexture (param.tex_dir.c_str(), texfile.c_str(), rep);
                else CommonTex[id] =
                        LoadTexture (param.tex_dir.c_str(), texfile.c_str());
                if (CommonTex[id] > 0) {
                    TextureIndex = TextureIndex + "[" + name + "]" + Int_StrN (CommonTex[id]);
                    numTextures++;
                }
            } else Message ("wrong texture id in textures.lst");
        }
    } else Message ("failed to load common textures");
}
Exemplo n.º 12
0
string CCharShape::GetNodeJoint (size_t idx) const {
	if (idx >= numNodes) return "";
	TCharNode *node = Nodes[idx];
	if (node == NULL) return "";
	if (!node->joint.empty()) return node->joint;
	else return Int_StrN ((int)node->node_name);
}
Exemplo n.º 13
0
string CCharShape::GetNodeJoint (int idx) {
	if (idx < 0 || idx >= numNodes) return "";
	TCharNode *node = Nodes[idx];
	if (node == NULL) return "";
	if (node->joint.size() > 0) return node->joint;
	else return Int_StrN (node->node_name);
}
Exemplo n.º 14
0
void RenderSingleFrame (double timestep) {
	if (!must_render) return;
	check_gl_error ();

	// ------------------ 3d scenery ----------------------------------
	set_gl_options (TUX);
    ClearRenderContext (colDDBackgr);

	string hlname = TestFrame.GetHighlightName (curr_joint);
	TestChar.highlight_node = TestChar.GetNodeName (hlname);

	glPushMatrix ();
 	SetToolLight ();
	GluCamera.Update (timestep);

	TestFrame.CalcKeyframe (curr_frame, &TestChar, ref_position);
	TestChar.Draw ();
	glPopMatrix ();

	// ----------------- 2d screen ------------------------------------
	SetupGuiDisplay ();
	set_gl_options (TEXFONT);

	if (FrameHasChanged ()) DrawChanged ();

	FT.SetFont ("bold");
	FT.SetSize (20);
	FT.SetColor (colYellow);
	FT.DrawString (-1, 10, "Keyframe mode");

	FT.SetFont ("normal");
	FT.SetSize (16);
	int xl, yt;
	for (int i=0; i<TestFrame.numFrames; i++) {
		if (i != curr_frame) {
			FT.SetColor (colLGrey); 
			FT.SetFont ("normal");
		} else {
			FT.SetColor (colYellow);
			FT.SetFont ("bold");
		}
		xl = ITrunc (i, framebase) * 100 + 20;
		yt = IFrac (i, framebase) * 18 + 20;
		FT.DrawString (xl, yt, Int_StrN (i));		
	}

	FT.SetFont ("normal");
	FT.SetColor (colLGrey); 
	PrintFrameParams (param.y_resolution - 330, TestFrame.GetFrame (curr_frame));

	if (ToolsFinalStage ()) {
		FT.SetSize (20);
		FT.SetColor (colYellow);
		FT.DrawString (-1, param.y_resolution - 50, "Quit program. Save character list (y/n)");
	}

	Reshape (param.x_resolution, param.y_resolution);
    Winsys.SwapBuffers();
	must_render = false;
}
Exemplo n.º 15
0
void CPlayers::LoadAvatars () {
	CSPList list (MAX_AVATARS);
	int i;
	string line, filename;
	GLuint texid;

	if (!list.Load (param.player_dir, "avatars.lst")) {
		Message ("could not load avators.lst");
		return;
	}

	AvatarIndex = "";
	numAvatars = 0;
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		filename = SPStrN (line, "file", "unknown");
		texid = Tex.LoadTexture (param.player_dir, filename);
		if (texid > 0) {
			avatars[numAvatars].filename = filename;
			avatars[numAvatars].texid = texid;
			AvatarIndex += "[" + filename + "]";
			AvatarIndex += Int_StrN (texid);
			numAvatars++;
		}
	}
}
Exemplo n.º 16
0
void DrawFps() {
	const  int   maxFrames = 50;
	static int   numFrames = 0;
	static float averagefps = 0;
	static float sumTime = 0;

	if (!param.display_fps)
		return;

	if (numFrames >= maxFrames) {
		averagefps = 1 / sumTime * maxFrames;
		numFrames = 0;
		sumTime = 0;
	} else {
		sumTime += g_game.time_step;
		numFrames++;
	}
	if (averagefps < 1) return;

	string fpsstr = Int_StrN((int)averagefps);
	if (param.use_papercut_font < 2) {
		Tex.DrawNumStr (fpsstr, (Winsys.resolution.width - 60) / 2, 10, 1, colWhite);
	} else {
		if (averagefps >= 35)
			FT.SetColor (colWhite);
		else
			FT.SetColor (colRed);
		FT.DrawString ((Winsys.resolution.width - 60) / 2, 10, fpsstr);
	}
}
Exemplo n.º 17
0
// for testing:
void CScore::PrintScorelist (size_t list_idx) const {
	if (list_idx >= Scorelist.size()) return;
	const TScoreList *list = &Scorelist[list_idx];

	if (list->numScores < 1) {
		PrintStr ("no entries in this score list");
	} else {
		for (int i=0; i<list->numScores; i++) {
			string line = "player: " + list->scores[i].player;
			line += " points: " + Int_StrN (list->scores[i].points);
			line += " herrings: " + Int_StrN (list->scores[i].herrings);
			line += " time: " + Float_StrN (list->scores[i].time, 2);
			PrintString (line);
		}
	}
}
Exemplo n.º 18
0
void DrawWind2 (float dir, float speed, CControl *ctrl) {
	string windstr;
	if (g_game.wind_id < 1) return;

	Tex.Draw (SPEEDMETER, 0, param.y_resolution-140, 1.0);
    glDisable (GL_TEXTURE_2D );


	float alpha, red, blue, len;
	len = 45;
	if (speed <= 50) {
		alpha = speed / 50;
		red = 0;
	} else {
		alpha = 1.0;
		red = (speed - 50) / 50;
	}
	blue = 1.0 - red;

	glPushMatrix ();
	glColor4f (red, 0, blue, alpha);
	glTranslatef (72, 66, 0);
	glRotatef (dir, 0, 0, 1);
	glBegin (GL_QUADS);
	    glVertex2f (-5, 0.0);
	    glVertex2f (5, 0.0);
	    glVertex2f (5, -len);
	    glVertex2f (-5, -len);
	glEnd();
	glPopMatrix ();

	// direction indicator
	TVector3 movdir = ctrl->cvel;
	NormVectorN (movdir);
	float dir_angle = atan (movdir.x / movdir.z) * 57.3;

	glPushMatrix ();
	glColor4f (0, 0.5, 0, 1.0);
	glTranslatef (72, 66, 0);
	glRotatef (dir_angle + 180, 0, 0, 1);
	glBegin (GL_QUADS);
	    glVertex2f (-2, 0.0);
	    glVertex2f (2, 0.0);
	    glVertex2f (2, -50);
	    glVertex2f (-2, -50);
	glEnd();
	glPopMatrix ();

    glEnable (GL_TEXTURE_2D );

 	Tex.Draw (SPEED_KNOB, 64, param.y_resolution - 74, 1.0);
	windstr = Int_StrN ((int)speed, 3);
	if (param.use_papercut_font < 2) {
		Tex.DrawNumStr (windstr.c_str(), 130, param.y_resolution - 55, 1, colWhite);
	} else {
		FT.SetColor (colBlue);
		FT.DrawString (130, param.y_resolution - 55, windstr);
	}
}
Exemplo n.º 19
0
void SPSetIntN (string &s, const string &tag, const int val) {
	int pos = SPPosN (s, tag);
	if (pos >= 0) {
		int ipos = pos + tag.size() + 2;
		string item = SPItemN (s, tag);
		if (item.size() > 0) SDeleteN (s, ipos, item.size()); 
		SInsertN (s, ipos, Int_StrN (val));
	} else SPAddIntN (s, tag, val);
}
Exemplo n.º 20
0
void DrawSpeed (ETR_DOUBLE speed) {
	string speedstr = Int_StrN ((int)speed, 3);
	if (param.use_papercut_font < 2) {
		Tex.Draw (GAUGE_ICON, Winsys.resolution.width - 145, Winsys.resolution.height - 60, 1);
		Tex.DrawNumStr (speedstr, Winsys.resolution.width - 80, Winsys.resolution.height - 46, 1, colWhite);
	} else {
		FT.SetColor (colDDYell);
		FT.DrawString (Winsys.resolution.width-82, Winsys.resolution.height-80, speedstr);
	}
}
Exemplo n.º 21
0
void DrawSpeed (double speed) {
	string speedstr;
	speedstr = Int_StrN ((int)speed, 3);
	if (param.use_papercut_font < 2) {
		Tex.DrawNumStr (speedstr.c_str(), 
			param.x_resolution - 85, param.y_resolution-74, 1, colWhite);
	} else {
		FT.SetColor (colDDYell);
		FT.DrawString (param.x_resolution-82, param.y_resolution-80, speedstr);
	}
}
Exemplo n.º 22
0
static void draw_herring_count (int herring_count) {
	string hcountstr = Int_StrN (herring_count, 3);
	if (param.use_papercut_font < 2) {
		Tex.Draw (HERRING_ICON, Winsys.resolution.width - 145, -4, 1);
		Tex.DrawNumStr (hcountstr, Winsys.resolution.width - 80, 10, 1, colWhite);
	} else {
		FT.SetColor (colDYell);
		FT.DrawString ( Winsys.resolution.width - 90, 10, hcountstr);
		Tex.Draw (T_YELLHERRING, Winsys.resolution.width-160, 12, 1);
	}
}
Exemplo n.º 23
0
void CPlayers::SavePlayers () const {
	string playerfile = param.config_dir + SEP "players";
	CSPList list(plyr.size());
	for (size_t i=0; i<plyr.size(); i++) {
		string item = "*[name]" + plyr[i].name;
		item +="[avatar]" + plyr[i].avatar->filename;
		item += "[unlocked]" + plyr[i].funlocked;
		if (&plyr[i] == g_game.player) item += "[active]1";
		else item += "[active]0";
		item += "[character]" + Int_StrN(plyr[i].character);
		list.Add (item);
	}
	list.Save (playerfile);
}
Exemplo n.º 24
0
static void draw_herring_count (int herring_count){
	string hcountstr;



	hcountstr = Int_StrN (herring_count, 3);
	if (param.use_papercut_font < 2) {
		Tex.DrawNumStr (hcountstr.c_str(), param.x_resolution - 90, 10, 1, colWhite);
		Tex.Draw (HERRING_ICON, param.x_resolution-160, -20, 1);
	} else {
		FT.SetColor (colDYell);
		FT.DrawString ( param.x_resolution - 90, 10, hcountstr);
		Tex.Draw (T_YELLHERRING, param.x_resolution-160, 12, 1);
	}
}
Exemplo n.º 25
0
void CSPList::MakeIndex (string &index, const string &tag) {
	index = "";
	string item;
	int idx = 0;

	for (int i=0; i<fcount; i++) {
		item = SPItemN (flines[i], tag);
		STrimN (item);
		if (item.size() > 0) {
			index += "[";
			index += item;			
			index += "]";
			index += Int_StrN (idx);
			idx++;
		}
	}
}
Exemplo n.º 26
0
void GameOverMessage (CControl *ctrl) {
    int fwidth = 500;

    string line;
    float leftframe = (param.x_resolution - fwidth) / 2;
    float topframe = 80;

    TColor backcol = MakeColor (1, 1, 1, 1);
    TColor framecol = MakeColor (0.7, 0.7, 1, 1);

    if (param.use_papercut_font > 0) FT.SetSize (28);
    else FT.SetSize (22);
    if (g_game.raceaborted) {
        DrawMessageFrame (leftframe, topframe, fwidth, 100, 4, backcol, framecol, 0.5);
        FT.SetColor (colDBlue);
        FT.DrawString (CENTER, topframe+30, Trans.Text(25));
    } else {
        DrawMessageFrame (leftframe, topframe, fwidth, 210, 4, backcol, framecol, 0.5);

        if (param.use_papercut_font > 0) FT.SetSize (20);
        else FT.SetSize (14);
        if (g_game.race_result >= 0 || g_game.game_type != CUPRACING) FT.SetColor (colDBlue);
        else FT.SetColor (colDRed);

        line = "Score:  ";
        FT.DrawString (leftframe+80, topframe+15, line);
        line = Int_StrN (g_game.score);
        line += "  pts";
        FT.DrawString (leftframe+240, topframe+15, line);

        line = "Herring:  ";
        FT.DrawString (leftframe+80, topframe+40, line);
        line = Int_StrN (g_game.herring);
        if (g_game.game_type == CUPRACING) {
            line += "  (";
            line += Int_StrN (g_game.herring_req.i);
            line += ")";
        }
        FT.DrawString (leftframe+240, topframe+40, line);

        line = "Time:  ";
        FT.DrawString (leftframe+80, topframe+65, line);
        line = Float_StrN (g_game.time, 2);
        line += "  s";
        if (g_game.game_type == CUPRACING) {
            line += "  (";
            line += Float_StrN (g_game.time_req.x, 2);
            line += ")";
        }
        FT.DrawString (leftframe+240, topframe+65, line);

        line = "Path length:  ";
        FT.DrawString (leftframe+80, topframe+90, line);
        line = Float_StrN (ctrl->way, 2);
        line += "  m";
        FT.DrawString (leftframe+240, topframe+90, line);

        line = "Average speed:  ";
        FT.DrawString (leftframe+80, topframe+115, line);
        line = Float_StrN (ctrl->way / g_game.time * 3.6, 2);
        line += "  km/h";
        FT.DrawString (leftframe+240, topframe+115, line);

        if (param.use_papercut_font > 0) FT.SetSize (28);
        else FT.SetSize (22);
        if (g_game.game_type == CUPRACING) {
            switch (g_game.race_result) {
            case -1:
                FT.DrawString (CENTER, topframe+150, Trans.Text(21));
                break;
            case 0:
                FT.DrawString (CENTER, topframe+150, Trans.Text(22));
                break;
            case 1:
                FT.DrawString (CENTER, topframe+150, Trans.Text(23));
                break;
            case 2:
                FT.DrawString (CENTER, topframe+150,  Trans.Text(24));
                break;
            }
        } else {
            if (highscore_pos < 5) {
                line = "Position ";
                line += Int_StrN (highscore_pos + 1);
                line += " in highscore list";
                FT.DrawString (CENTER, topframe+150, line);
            }
        }
    }
}
Exemplo n.º 27
0
bool CEvents::LoadEventList () {
	CSPList list(256);
	int i, ii, type;
	string line, item, race, cup;
	int num;

	if (!list.Load (param.common_course_dir, "events.lst")) {
		Message ("could not load events.lst");
		return false;
	}

	// pass 1: races
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		type = SPIntN (line, "struct", -1);
		if (type == 0) {
			if (numRaces < MAX_RACES2) {
				RaceList[numRaces].race = SPStrN (line, "race", "error");
				item = SPStrN (line, "course", "");
				RaceList[numRaces].course = Course.GetCourseIdx (item);
				item = SPStrN (line, "light", "");
				RaceList[numRaces].light = Env.GetLightIdx (item);
				RaceList[numRaces].snow = SPIntN (line, "snow", 0);
				RaceList[numRaces].wind = SPIntN (line, "wind", 0);
				RaceList[numRaces].time = SPVector3N (line, "time", MakeVector (0, 0, 0));
				RaceList[numRaces].herrings = SPIndex3N (line, "herring", MakeIndex3 (0, 0, 0));
				RaceList[numRaces].music_theme = Music.GetThemeIdx (SPStrN (line, "theme", "normal"));
				numRaces++;
			}
		}
	}
	list.MakeIndex (RaceIndex, "race");

	// pass 2: cups
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		type = SPIntN (line, "struct", -1);
		if (type == 1) {
			if (numCups < MAX_CUPS2) {
				CupList[numCups].cup = SPStrN (line, "cup", "error");
				CupList[numCups].name = SPStrN (line, "name", "unknown");
				CupList[numCups].desc = SPStrN (line, "desc", "unknown");
				num = SPIntN (line, "num", 0);
				CupList[numCups].num_races = num;
				for (ii=0; ii<num; ii++) {
					race = SPStrN (line, Int_StrN (ii+1), "");
					CupList[numCups].races[ii] = GetRaceIdx (race);
				}
				numCups++;
			}
		}
	}
	list.MakeIndex (CupIndex, "cup");

	// pass 3: events
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		type = SPIntN (line, "struct", -1);
		if (type == 2) {
			if (numEvents < MAX_EVENTS2) {
				EventList[numEvents].name = SPStrN (line, "name", "unknown");
				num = SPIntN (line, "num", 0);
				EventList[numEvents].num_cups = num;
				for (ii=0; ii<num; ii++) {
					cup = SPStrN (line, Int_StrN (ii+1), "");
					EventList[numEvents].cups[ii] = GetCupIdx (cup);
				}
				numEvents++;
			}
		}
	}
	list.MakeIndex (EventIndex, "event");

	return true;
}
Exemplo n.º 28
0
void DrawWind(float dir, float speed, const CControl *ctrl) {
	if (g_game.wind_id < 1) return;

	//float dir_angle = RADIANS_TO_ANGLES(atan2(ctrl->cvel.x, ctrl->cvel.z));
	string windstr = Int_StrN ((int)speed, 3);

	glPushMatrix();
	glTranslatef (32, 28, 0);
	glRotatef(dir, 0, 0, 1);
	glTranslatef (-32, -28, 0);
	Tex.Draw(ARROW_ICON, 0, Winsys.resolution.height - 60, 1);
	glPopMatrix();

	Tex.DrawNumStr(windstr, 60, Winsys.resolution.height - 46, 1, colWhite);

#if 0
	if (g_game.wind_id < 1) return;

	Tex.Draw (SPEEDMETER, 0, Winsys.resolution.height-140, 1.0);
	glDisable (GL_TEXTURE_2D);


	float alpha, red, blue;
	if (speed <= 50) {
		alpha = speed / 50;
		red = 0;
	} else {
		alpha = 1.0;
		red = (speed - 50) / 50;
	}
	blue = 1.0 - red;

	glPushMatrix ();
	glColor4f (red, 0, blue, alpha);
	glTranslatef (72, 66, 0);
	glRotatef(dir, 0, 0, 1);
	glEnableClientState(GL_VERTEX_ARRAY);
	static const int len = 45;
	static const GLshort vtx1 [] = {
		-5, 0.0,
		5, 0.0,
		5, -len,
		- 5, -len
	};
	glVertexPointer(2, GL_SHORT, 0, vtx1);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	// direction indicator
	float dir_angle = RADIANS_TO_ANGLES(atan2(ctrl->cvel.x, ctrl->cvel.z));

	glColor4f (0, 0.5, 0, 1.0);
	glRotatef (dir_angle - dir, 0, 0, 1);
	static const GLshort vtx2 [] = {
		-2, 0,
		2, 0,
		2, -50,
		-2, -50
	};
	glVertexPointer(2, GL_SHORT, 0, vtx2);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	glDisableClientState(GL_VERTEX_ARRAY);
	glPopMatrix ();

	glEnable (GL_TEXTURE_2D);

	Tex.Draw (SPEED_KNOB, 64, Winsys.resolution.height - 74, 1.0);
	string windstr = Int_StrN ((int)speed, 3);
	if (param.use_papercut_font < 2) {
		Tex.DrawNumStr (windstr, 130, Winsys.resolution.height - 55, 1, colWhite);
	} else {
		FT.SetColor (colBlue);
		FT.DrawString (130, Winsys.resolution.height - 55, windstr);
	}
#endif
}
Exemplo n.º 29
0
void CEvent::Loop (double timestep) {
	int ww = Winsys.resolution.width;
	int hh = Winsys.resolution.height;

	check_gl_error();
	ScopedRenderMode rm(GUI);
	Music.Update ();
    ClearRenderContext ();
	SetupGuiDisplay ();

	if (param.ui_snow) {
		update_ui_snow (timestep);
		draw_ui_snow ();
	}
	Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), Winsys.scale);
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);

//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top,
//			0, colMBackgr, colBlack, 0.2);

	if (ready == 0) {			// cup not finished
		FT.AutoSizeN (6);
		FT.SetColor (colWhite);
		FT.DrawString (CENTER, AutoYPosN (25), ecup->name);

		DrawBonusExt (bonustop, (int)ecup->races.size(), curr_bonus);

		DrawFrameX (area.left, frametop, framewidth,
			(int)ecup->races.size() * dist + 20, 3, colBackgr, colWhite, 1);

		for (size_t i=0; i<ecup->races.size(); i++) {
			FT.AutoSizeN (3);

			int y = frametop + 10 + (int)i * dist;
			if (i == curr_race)
				FT.SetColor (colDYell);
			else
				FT.SetColor (colWhite);
			FT.DrawString (area.left + 29, y, Course.CourseList[ecup->races[i]->course].name);
			Tex.Draw (CHECKBOX, area.right -54, y, texsize, texsize);
			if (curr_race > i) Tex.Draw (CHECKMARK, area.right-50, y + 4, 0.8);
		}

		FT.AutoSizeN (3);
		int ddd = FT.AutoDistanceN (1);
		FT.SetColor (colDBlue);
		string info = Trans.Text(11);
		info += "   " + Int_StrN (ecup->races[curr_race]->herrings.i);
		info += "   " + Int_StrN (ecup->races[curr_race]->herrings.j);
		info += "   " + Int_StrN (ecup->races[curr_race]->herrings.k);
		FT.DrawString (CENTER, framebottom+15, info);

		info = Trans.Text(12);
		info += "   " + Float_StrN (ecup->races[curr_race]->time.x, 0);
		info += "   " + Float_StrN (ecup->races[curr_race]->time.y, 0);
		info += "   " + Float_StrN (ecup->races[curr_race]->time.z, 0);
		info += "  " + Trans.Text(14);
		FT.DrawString (CENTER, framebottom+15+ddd, info);

	} else if (ready == 1) {		// cup successfully finished
		FT.AutoSizeN (5);
		FT.SetColor (colWhite);
		FT.DrawString (CENTER, messtop, Trans.Text(16));
		DrawBonusExt (bonustop, (int)ecup->races.size(), curr_bonus);
		int res = resultlevel(curr_bonus, ecup->races.size());
		FT.DrawString (CENTER, messtop2, Trans.Text(17) + "  "+Int_StrN (res));
	} else if (ready == 2) {		// cup finished but failed
		FT.AutoSizeN (5);
		FT.SetColor (colLRed);
		FT.DrawString (CENTER, messtop, Trans.Text(18));
		DrawBonusExt (bonustop, ecup->races.size(), curr_bonus);
		FT.DrawString (CENTER, messtop2, Trans.Text(19));
	}

	textbuttons[0]->SetVisible(ready < 1);
	textbuttons[1]->SetVisible(ready < 1);
	textbuttons[2]->SetVisible(!(ready < 1));

	DrawGUI ();
    Winsys.SwapBuffers();
}
Exemplo n.º 30
0
void CRaceSelect::Loop() {
	int ww = Winsys.resolution.width;
	int hh = Winsys.resolution.height;
	TColor col;

	check_gl_error();
	ScopedRenderMode rm(GUI);
	ClearRenderContext ();
	SetupGuiDisplay ();

	Music.Update ();
	if (param.ui_snow) {
		update_ui_snow ();
		draw_ui_snow ();
	}

	//Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), 1.0);
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);

//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top,
//			0, colMBackgr, colBlack, 0.2);

	// course selection
	col = colWhite;
	DrawFrameX (area.left, frametop, framewidth - 100, frameheight, 3, colMBackgr, col, 1.0);
	FT.AutoSizeN (4);
	FT.SetColor (colDYell);
	FT.DrawString (area.left+20, frametop, CourseList[course->GetValue()].name);

	if (CourseList[course->GetValue()].preview)
		CourseList[course->GetValue()].preview->DrawFrame(area.left + 3, prevtop, prevwidth, prevheight, 3, colWhite);

	DrawFrameX (area.right-boxwidth, prevtop-3, boxwidth, prevheight+6, 3, colBackgr, colWhite, 1.0);
	FT.AutoSizeN (2);
	FT.SetColor (colWhite);
	int dist = FT.AutoDistanceN (0);
	for (size_t i=0; i<CourseList[course->GetValue()].num_lines; i++) {
		FT.DrawString (boxleft+8, prevtop+i*dist, CourseList[course->GetValue()].desc[i]);
	}

	FT.DrawString (CENTER, prevtop + prevheight + 10, "Author:  " + CourseList[course->GetValue()].author);

	//FT.DrawString (CENTER, AutoYPosN (45), info);

	if (g_game.force_treemap) {
		FT.AutoSizeN (4);
		static const string forcetrees = "Load trees.png";
		string sizevar = "Size: ";
		sizevar += Int_StrN (g_game.treesize);
		sizevar += " Variation: ";
		sizevar += Int_StrN (g_game.treevar);
		FT.SetColor (colYellow);
		FT.DrawString (CENTER, AutoYPosN (85), forcetrees);
		FT.DrawString (CENTER, AutoYPosN (90), sizevar);
	}

	DrawGUI();

	Winsys.SwapBuffers();
}