Ejemplo n.º 1
0
void ReadIniFile( const char *file ){
	char *Text;
	float x1,x2,x3,x4;
	int i;

	Text = g_FuncTable.m_pfnProfileLoadString( file, OPTS_SECTION, "Amplitude", "" );
	if ( strlen( Text ) ) {
		Amplitude = atof( Text );
	}
	else{
		Amplitude = 128;
	}

	Text = g_FuncTable.m_pfnProfileLoadString( file, OPTS_SECTION, "Roughness", "" );
	if ( strlen( Text ) ) {
		Roughness = atof( Text );
	}
	else{
		Roughness = 16;
	}

	Text = g_FuncTable.m_pfnProfileLoadString( file, OPTS_SECTION, "WaveLength", "" );
	if ( strlen( Text ) ) {
		WaveLength = atof( Text );
	}
	else{
		WaveLength = 1024;
	}

	Text = g_FuncTable.m_pfnProfileLoadString( file, OPTS_SECTION, "Extents", "" );
	if ( strlen( Text ) ) {
		sscanf( Text,"%f,%f,%f,%f",&x1,&x2,&x3,&x4 );
		Hll = x1;
		Vll = x2;
		Hur = x3;
		Vur = x4;
	}
	else
	{
		Hll = -512;
		Vll = -512;
		Hur =  512;
		Vur =  512;
	}

	Text = g_FuncTable.m_pfnProfileLoadString( file, OPTS_SECTION, "CornerValues", "" );
	if ( strlen( Text ) ) {
		sscanf( Text,"%f,%f,%f,%f",&x1,&x2,&x3,&x4 );
		Z00 = x1;
		Z01 = x2;
		Z10 = x3;
		Z11 = x4;
	}
	else
	{
		Z00 = 0.;
		Z01 = 0.;
		Z10 = 0.;
		Z11 = 0.;
	}

	Text = g_FuncTable.m_pfnProfileLoadString( file, OPTS_SECTION, "TextureOffset", "" );
	if ( strlen( Text ) ) {
		sscanf( Text,"%f,%f",&x1,&x2 );
		TexOffset[0] = x1;
		TexOffset[1] = x2;
	}
	else
	{
		TexOffset[0] = 0.;
		TexOffset[1] = 0.;
	}

	Text = g_FuncTable.m_pfnProfileLoadString( file, OPTS_SECTION,"TextureScale","" );
	if ( strlen( Text ) ) {
		sscanf( Text,"%f,%f",&x1,&x2 );
		TexScale[0] = x1;
		TexScale[1] = x2;
		if ( TexScale[0] == 0. ) {
			TexScale[0] = 1.0;
		}
		if ( TexScale[1] == 0. ) {
			TexScale[1] = 1.0;
		}
	}
	else
	{
		TexScale[0] = 1.;
		TexScale[1] = 1.;
	}

	NH = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"NH",8 );
	NH = max( 1,min( NH,MAX_ROWS ) );
	NV = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"NV",8 );
	NV = max( 1,min( NV,MAX_ROWS ) );

//	Decimate   = GetPrivateProfileInt(OPTS_SECTION,"Decimate",0,file);
//	Decimate = max(0,min(Decimate,100));

	AddHints          = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"AddHints",0 );
	ArghRad2          = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"ArghRad2",0 );
	AutoOverwrite = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"AutoOverwrite",0 );
	FixBorders        = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"FixBorders",1 );
	HideBackFaces = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"HideBackFaces",0 );
	Plane                 = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"Plane",0 );
	Preview               = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"Preview", 0 );
	Antialiasing    = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"Antialiasing",0 ); // ^Fishman - Antializing for the preview window.
	RandomSeed        = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"RandomSeed",1 );
	Skybox                = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"Skybox",0 );
	UseDetail         = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"UseDetail",0 );
	AddTerrainKey   =   g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"AddTerrainKey",0 ); // ^Fishman - Add terrain key to func_group.
	UseLadder         = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"UseLadder",0 );
	WaveType          = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"WaveType",0 );
	vid_x                 = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"vid_x", 0 );
	vid_y                 = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"vid_y", 0 );
	view_x                = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"view_x",0 );
	view_y                = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"view_y",0 );
	view_cx               = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"view_cx",0 );
	view_cy               = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"view_cy",0 );

	UsePatches        = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"UsePatches",0 );

	SlantAngle = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"SlantAngle",60 );
	GimpHints  = g_FuncTable.m_pfnProfileLoadInt( file, OPTS_SECTION,"GimpHints",0 );

	for ( i = 0; i < NUMGAMES; i++ )
	{
		//    strcpy (gszOutputDir[i], g_FuncTable.m_pfnProfileLoadString (file, GameName[i],"OutputDir",""));
		strcpy( Texture[i][0], g_FuncTable.m_pfnProfileLoadString( file, GameName[i], "Texture", "" ) );
		strcpy( Texture[i][1], g_FuncTable.m_pfnProfileLoadString( file, GameName[i], "Texture2", "" ) );
		strcpy( Texture[i][2], g_FuncTable.m_pfnProfileLoadString( file, GameName[i], "Texture3", "" ) );
		//    strcpy (gszTextureDir[i], g_FuncTable.m_pfnProfileLoadString (file, GameName[i],"TextureDir",""));
		//    UsePak[i] = GetPrivateProfileInt(GameName[i],"UsePak",0);
		//    strcpy (pakfile[i], g_FuncTable.m_pfnProfileLoadString (file, GameName[i],"PakFile",""));
		//    strcpy (lastpakfile[i], g_FuncTable.m_pfnProfileLoadString (file, GameName[i],"LastPakFile",""));
		//    strcpy (GameDir[i], g_FuncTable.m_pfnProfileLoadString (file, GameName[i],"GameDir","\0"));
	}
	/*
	   if(!strlen(gszTextureDir[QUAKE2]))
	      strcpy(gszTextureDir[QUAKE2],"c:\\quake2\\baseq2\\textures\\");
	   if(!strlen(gszTextureDir[KINGPIN]))
	      strcpy(gszTextureDir[KINGPIN],"c:\\kingpin\\main\\textures\\");
	 */
	if ( !strlen( Texture[QUAKE2][0] ) ) {
		strcpy( Texture[QUAKE2][0],   "textures/e1u1/grass1_4" );
	}
	if ( !strlen( Texture[HALFLIFE][0] ) ) {
		strcpy( Texture[HALFLIFE][0], "textures/OUT_GRND1" );
	}
	if ( !strlen( Texture[SIN][0] ) ) {
		strcpy( Texture[SIN][0],      "textures/generic/floor_organic/fl_grass" );
	}
	if ( !strlen( Texture[HERETIC2][0] ) ) {
		strcpy( Texture[HERETIC2][0], "textures/canyon/canyon05" );
	}
	if ( !strlen( Texture[KINGPIN][0] ) ) {
		strcpy( Texture[KINGPIN][0],  "textures/bricks/s_sr_m3" );
	}
	if ( !strlen( Texture[GENESIS3D][0] ) ) {
		strcpy( Texture[GENESIS3D][0],"textures/rock13" );
	}
	if ( !strlen( Texture[QUAKE3][0] ) ) {
		strcpy( Texture[QUAKE3][0],   "textures/organics/grass3" );
	}
	if ( !strlen( Texture[QUAKE3][1] ) ) {
		strcpy( Texture[QUAKE3][1],   "textures/common/caulk" );
	}
	strcpy( gbmp.name, g_FuncTable.m_pfnProfileLoadString( file, "Bitmap","Filename","" ) );


	gbmp.colors = NULL;
	if ( strlen( gbmp.name ) ) {
		OpenBitmap();
	}

	strcpy( gbmp.defpath, g_FuncTable.m_pfnProfileLoadString( file, "Bitmap","DefaultPath","" ) );

	Text = g_FuncTable.m_pfnProfileLoadString( file, "Bitmap","BlackValue","" );
	if ( strlen( Text ) ) {
		gbmp.black_value = atof( Text );
	}
	else{
		gbmp.black_value = 0;
	}

	Text = g_FuncTable.m_pfnProfileLoadString( file, "Bitmap","WhiteValue","" );
	if ( strlen( Text ) ) {
		gbmp.white_value = atof( Text );
	}
	else{
		gbmp.white_value = 256.;
	}
}
Ejemplo n.º 2
0
LONG CALLBACK AppWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
  RECT Rect;
  int key;
  switch (msg)
  {
    case WM_COMMAND:
      switch(LOWORD(wParam))
      {
         case CM_FILEEXIT:
            DestroyWindow(hwndApp);
            break;
         case CM_FILEOPEN:
            OpenBitmap();
            break;
         case CM_PALETTE:
            if(!paletteWindow)
               paletteWindow = CreateDialog(hInstApp, "PaletteControl", hwnd, (DLGPROC) PaletteDialog);
            break;
      }
      break;
    case WM_KEYDOWN:
    case WM_KEYUP:
    case WM_CREATE:
      break;

    case WM_PALETTECHANGED:
      break;
    case WM_QUERYNEWPALETTE:
    {
      BOOL changed;
      HDC hDC = GetDC(hwnd);
      if(sfc) sfc->setPalette(NULL);
      changed = RealizePalette(hDC);
      if(changed)
      {
         InvalidateRect(hwnd, NULL, TRUE);
         //((GFXCDSSurface *)sfc)->setHWND(hwnd);
      }
      return changed;
    }
    case WM_SETCURSOR:
      break;

    case WM_ENTERMENULOOP:
      break;

    case WM_EXITMENULOOP:
      break;

    case WM_INITMENUPOPUP:
        break;

    case WM_DESTROY:
      hwndApp = NULL;
      PostQuitMessage(0);
      break;

    case WM_PAINT:
      LPPAINTSTRUCT lpPaint;
      //BeginPaint(hwnd, lpPaint);
      if(sfc) sfc->update();
      //EndPaint(hwnd, lpPaint);
      return 1;
      break;

    case WM_MOVE:
    case WM_SIZE:
      break;

    case WM_MOUSEMOVE:
    case WM_LBUTTONDOWN:
      if(GetKeyState(VK_LBUTTON) < 0)
      {
         imgPoint.x = LOWORD(lParam);
         imgPoint.y = HIWORD(lParam);
         Redraw();
      }
      break;
  }

  return DefWindowProc(hwnd,msg,wParam,lParam);
}