コード例 #1
0
ファイル: test_compact_menu.c プロジェクト: Acknex/TUST
void main ()
{
	video_mode = 8;
	fps_max = 60;
	wait(2);
	bmap_zbuffer ( bmap_createblack(2048,2048,32) );
	mouse_mode = 4;
	mouse_map = bmap_create ( "arrow_yellow.pcx" );
	vec_fill ( &screen_color, 128 );
	
	level_load ( "" );
	camera->pan = -40;
	camera->tilt = -30;
	evnCameraLocate ();
	vec_set ( &colCameraBG, vector(150,150,150) );
	camera->bg = pixel_for_vec ( &colCameraBG, 100, 8888 );
	
	ENTITY *ent = ent_create ( CUBE_MDL, nullvector, NULL );
	
	// Create style for the menues
	// CMMEMBER *myMenuStyle = cmstyle_create ( FONT *font, COLOR *colText, COLOR *colBack, COLOR *colOver )
	FONT *fntTTF = font_create("Arial#16");
	CMStyle *myMenuStyle01 = cmstyle_create ( fntTTF, vector(40,40,40), vector(250,250,250), vector(210,210,210) );
	FONT *fntBitmap = font_create("ackfont.pcx");
	CMStyle *myMenuStyle02 = cmstyle_create ( fntBitmap, vector(170,170,255), vector(30,20,0), vector(0,0,185) );
	
	// Create a compact menu panel
	// PANEL *cmenu_create ( char *chrMember, var pos_x, var pos_y, var size_x, var layer, var flags, CMStyle *style )
	PANEL *myMenu01 = cmenu_create ( "menu name.submenu=txtMain", 110, 20, 200, 1, SHOW, myMenuStyle01 );
	PANEL *myMenu02 = cmenu_create ( "debug & statics.submenu=txtCMDebug", 500, 20, 200, 1, SHOW, myMenuStyle01 );
	
	cmenu_modify ( myMenu02, 120, myMenuStyle02 );
	
	bmpSky = bmap_create ( "sky_fu_256+6.tga" );
	
	while ( !key_esc && !nExit )
	{
		str_setchr ( strString, 1, random(32)+32 );
		wait(1);
	}
	
	bmap_remove ( bmpSky );
	bmpSky = NULL;
	bmap_remove ( mouse_map );
	mouse_map = NULL;
	
	cmenu_remove ( myMenu01 );
	sys_free ( myMenuStyle01 ); 
	font_remove ( fntTTF );
	
	cmenu_remove ( myMenu02 );
	sys_free ( myMenuStyle02 );
	font_remove ( fntBitmap ); 
	
	sys_exit ( NULL );

}
コード例 #2
0
ChapterData *ChapterDataCreate(const char *name, const char *internal_name,
                               const STRING *thumbnail_name, const COLOR *vsun_color,
						       const COLOR *vfog_color, const VECTOR *vfog_range,
						       const float vsun_light)
{
	ASSERT(internal_name, _chr("Fatal error in ChapterDataCreate(): A null char * pointer was given to the function, cannot create the data block."));
	ASSERT(strlen(internal_name) < CHAPTER_INAME_MAX_LENGTH, _chr("Fatal error in ChapterDataCreate(): Chapter name's length exceeds CHAPTER_INAME_MAX_LENGTH."));

	ChapterData *data     = (ChapterData *) sys_malloc(sizeof(ChapterData));
	data->chapter_name    = (char *)        sys_malloc(CHAPTER_NAME_MAX_LENGTH * sizeof(char));
	data->chapter_iname   = (char *)        sys_malloc(CHAPTER_INAME_MAX_LENGTH * sizeof(char));
	data->pad             = (float *)       sys_malloc(CHAPTER_PAD_VARS_MAX_LENGTH * sizeof(float));
	data->sun_light       = -1.0;

	// The chapter name can be left blank, whilist the chapter's internal name (its scene file)
	// must not be blank - each ChapterData struct has to be linked to a scene in some way.
	if(name)
		if(strlen(name) <= CHAPTER_NAME_MAX_LENGTH)
			strcpy(data->chapter_name, name);

	strcpy(data->chapter_iname, internal_name);

	// Continue to allocate and set up any additional parameters.
	if(thumbnail_name)
		if(file_exists(thumbnail_name))
			data->thumbnail = bmap_create(thumbnail_name);

	if(vsun_color)
	{
		data->sun_color     = (COLOR *) sys_malloc(sizeof(COLOR));
		vec_set(data->sun_color, vsun_color);
	}

	if(vfog_color)
	{
		data->fog_color     = (COLOR *) sys_malloc(sizeof(COLOR));
		vec_set(data->fog_color, vfog_color);

		if(vfog_range)
		{
			data->fog_range = (VECTOR *) sys_malloc(sizeof(VECTOR));
			vec_set(data->fog_range, vfog_range);
		}
	}

	if(vsun_light >= 0.0)
		data->sun_light = vsun_light;

	return data;
}