Esempio n. 1
0
void ReadFont(LPSTR styleFile)
{
	strcpy(temp1, ReadString(styleFile, "*font:", "Verdana"));
	strcpy(temp2, ReadString(styleFile, "window.font:", temp1));
	strcpy(mSkin.windowFont.Face, ReadString(styleFile, "window.label.focus.font:", temp2));

	if (strchr(mSkin.windowFont.Face, '/')) // xoblite font name/size/weight format
	{
		strcpy(temp1, mSkin.windowFont.Face);

		strcpy(temp1, Tokenize(temp1, mSkin.windowFont.Face, "/"));

		if (strlen(temp1))
		{
			char height[MAX_LINE_LENGTH];
			strcpy(temp1, Tokenize(temp1, height, "/"));
			mSkin.windowFont.Height = atoi(height);

			if (IsInString(temp1, "Bold")) mSkin.windowFont.Weight = FW_BOLD;
			else mSkin.windowFont.Weight = FW_NORMAL;
		}
		else
		{
			mSkin.windowFont.Height = 12;
			mSkin.windowFont.Weight = FW_BOLD;
		}
	}
	else
	{
		mSkin.windowFont.Height = ReadInt(styleFile, "*fontHeight:", 12);
		mSkin.windowFont.Height = ReadInt(styleFile, "window.fontHeight:", mSkin.windowFont.Height);
		mSkin.windowFont.Height = ReadInt(styleFile, "window.label.focus.fontHeight:", mSkin.windowFont.Height);

		strcpy(temp1, ReadString(styleFile, "window.fontWeight:", "Normal"));
		strcpy(temp2, ReadString(styleFile, "window.label.focus.fontWeight:", "Normal"));
		if (IsInString(temp2, "Bold")) mSkin.windowFont.Weight = FW_BOLD;
		else mSkin.windowFont.Weight = FW_NORMAL;
	}

	strcpy(temp1, ReadString(styleFile, "window.alignment:", "Center"));
	strcpy(temp2, ReadString(styleFile, "window.label.focus.alignment:", temp1));
	strcpy(temp1, ReadString(styleFile, "window.label.focus.justify:", temp2));
	if (IsInString(temp1, "Left")) mSkin.windowFont.Justify = DT_LEFT;
	else if (IsInString(temp1, "Right")) mSkin.windowFont.Justify = DT_RIGHT;
	else mSkin.windowFont.Justify = DT_CENTER;

	mSkin.windowFont.validated = true; // Not sure what this bbLean proprietary flag is used for... /qwilk
}
Esempio n. 2
0
bool CLoadMD3::LoadSkin(t3DModel *pModel, LPSTR strSkin)
{
	if(!pModel || !strSkin) return false;

	ifstream fin(strSkin);

	if(fin.fail())
	{
		MessageBox(NULL, "Unable to load skin!", "Error", MB_OK);
		return false;
	}

	string strLine = "";
	int textureNameStart = 0;

	while(getline(fin, strLine))
	{
		for(int i = 0; i < pModel->numOfObjects; i++)
		{
			if( IsInString(strLine, pModel->pObject[i].strName) )			
			{			
				for(int j = strLine.length() - 1; j > 0; j--)
				{
					if(strLine[j] == '/')
					{
						textureNameStart = j + 1;
						break;
					}	
				}
				tMaterialInfo texture;
				strcpy(texture.strFile, &strLine[textureNameStart]);
				texture.uTile = texture.uTile = 1;
				pModel->pObject[i].materialID = pModel->numOfMaterials;
				pModel->pObject[i].bHasTexture = true;
				pModel->numOfMaterials++;
				pModel->pMaterials.push_back(texture);
			}
		}
	}

	fin.close();
	return true;
}
Esempio n. 3
0
void Parser::ValidateElements() {
  // Validate anime type and episode title
  if (!elements_.empty(kElementAnimeType) &&
      !elements_.empty(kElementEpisodeTitle)) {
    // Here we check whether the episode title contains an anime type
    const auto episode_title = elements_.get(kElementEpisodeTitle);
    for (auto it = elements_.begin(); it != elements_.end(); ) {
      if (it->first == kElementAnimeType) {
        if (IsInString(episode_title, it->second)) {
          if (episode_title.size() == it->second.size()) {
            elements_.erase(kElementEpisodeTitle);  // invalid episode title
          } else {
            const auto keyword = keyword_manager.Normalize(it->second);
            if (keyword_manager.Find(kElementAnimeType, keyword)) {
              it = elements_.erase(it);  // invalid anime type
              continue;
            }
          }
        }
      }
      ++it;
    }
  }
}
Esempio n. 4
0
//=============================================================================
bool get_style(StyleItem *si, const char *key)
{
    const char *s, *p;
    COLORREF c; int w;
    char fullkey[80], *r;

    memset(si, 0, sizeof *si);
    r = strchr(strcpy(fullkey, key), 0);
    s = stylePath();

    strcpy(r, ".appearance:");
    p = ReadString(s, fullkey, NULL);
    if (p) {
        si->bordered = IsInString(p, "border");
    } else {
        strcpy(r, ":");
        p = ReadString(s, fullkey, NULL);
        if (NULL == p)
            return false;
        si->bordered = true;
    }
    ParseItem(p, si);

    if (B_SOLID != si->type || si->interlaced)
        strcpy(r, ".color1:");
    else
        strcpy(r, ".backgroundColor:");
    c = ReadColor(s, fullkey, NULL);
    if ((COLORREF)-1 == c) {
        strcpy(r, ".color:");
        c = ReadColor(s, fullkey, NULL);
        if ((COLORREF)-1 == c)
            return false;
    }

    si->Color = si->ColorTo = c;
    if (B_SOLID != si->type || si->interlaced) {
        strcpy(r, ".color2:");
        c = ReadColor(s, fullkey, NULL);
        if ((COLORREF)-1 == c) {
            strcpy(r, ".colorTo:");
            c = ReadColor(s, fullkey, NULL);
        }
        if ((COLORREF)-1 != c)
            si->ColorTo = c;
    }

    if (si->bordered) {
        strcpy(r, ".borderColor:");
        c = ReadColor(s, fullkey, NULL);
        if ((COLORREF)-1 != c)
            si->borderColor = c;
        else
            si->borderColor = ReadColor(s, "borderColor:", "black");

        strcpy(r, ".borderWidth:");
        w = ReadInt(s, fullkey, -100);
        if (-100 != w)
            si->borderWidth = w;
        else
            si->borderWidth = ReadInt(s, "borderWidth:", 1);
    }

    strcpy(r, ".marginWidth:");
    w = ReadInt(s, fullkey, -100);
    if (-100 != w)
        si->marginWidth = w;
    else
        si->marginWidth = ReadInt(s, "bevelWidth:", 2);
    return true;
}
bool KPModel::LoadFile(void)
{
	char	buffer[512];						// buffer for the obj file
	char	mtlfileName[MAX_PATH] = "";			// path to the material library file
	FILE	*mtlfile;							// handle of the material library file
	char	materialName[100];					// name of the currently active material

	UINT	v0=0,v1=0,v2=0,vt0=0,vt1=0,vt2=0;	// temporary vetrex and vertex texture index ids
	UINT	numVertices = 0, numTextCoords = 0; // temporary data counters
	UINT	numGroups = 0;
	UINT	*numFaces;							// tmp counter for faces of each group
	VERTEX  *v  = NULL;							// tmp vertex and vertex texture coordinate buffers
	VERTEX  *vt = NULL;
	UINT	vi =0, vti = 0,	gi = 0;				// tmp indexes
	KPVector vMin, vMax;						// Max and min coordinates of the object
	UINT	vCount=0, iCount=0;



	if (!m_pDevice)
		return false;

	numFaces = new UINT[65534];
	ZeroMemory(numFaces, sizeof(UINT)*65534);

	////
	//	First we have to load the materials and textures
	////

	while ( fgets(buffer, sizeof(buffer), m_pFile) != NULL )
	{
		// Load the Material Libraries
		//////////////////////////////

		// If the line starts with a Material Library definition
		if ( IsInString(buffer, "mtllib ") == 0 )
		{
			// Get the file path from buffer and open the file
			sscanf_s(buffer, "mtllib %s", mtlfileName, sizeof(mtlfileName));

			// Open the Material Library
			fopen_s(&mtlfile, mtlfileName, "r");
			assert(mtlfile);

			if ( mtlfile )
			{
				LoadMaterials(mtlfile);
				fclose(mtlfile);
			}
			else
				return false;
		}

	} // ! while loading materials

	rewind(m_pFile);

	////
	//	Count the number of vertex, texture, group and face entries
	////

	while ( fgets(buffer, sizeof(buffer), m_pFile) != NULL )
	{
		if ( buffer[0] == 'v' && buffer[1] == ' ' )
			numVertices++;
		else if ( buffer[0] == 'v' && buffer[1] == 't' )
			numTextCoords++;
		else if	( buffer[0] == 'f' && buffer[1] == ' ' )
		{
			iCount+=3;
			numFaces[numGroups-1]++;
		}
		else if ( IsInString(buffer, "usemtl ") != -1 )
			numGroups++;
	} // ! while

	vCount = numVertices;

	rewind(m_pFile);
	
	////
	//	Allocate memory for the arrays
	////

	try
	{
		v			= new VERTEX[numVertices];
		vt			= new VERTEX[numTextCoords];
		m_pBufferID = new UINT[m_numMaterials];
	}
	catch (std::bad_alloc)
	{
		delete[] v;
		delete[] vt;
		v		= NULL;
		vt		= NULL;

		return false;
	}

	////
	//	Start reading the data
	////

	while ( fgets(buffer, sizeof(buffer), m_pFile) != NULL )
	{
		if ( buffer[0] == 'v' && buffer[1] == ' ' )
		{
			sscanf_s(buffer, "v  %f %f %f", &v[vi].x, &v[vi].y, &v[vi].z);
			vi++;
		}
		else if ( buffer[0] == 'v' && buffer[1] == 't' )
		{
			sscanf_s(buffer, "vt %f %f", &vt[vti].tu, &vt[vti].tv);
			vti++;
		}
		else if ( IsInString(buffer, "usemtl ") != -1 )
		{
			// Now we can allocate vertex and index buffers
			try
			{
				m_numVertices = numFaces[gi]*3;
				m_pVertices = new VERTEX[m_numVertices];
				m_numIndices= m_numVertices;
				m_pIndices	= new WORD[m_numIndices];
			}
			catch (std::bad_alloc)
			{
				delete m_pVertices;
				delete m_pIndices;
			}

			// Change the active material to the specified one
			sscanf_s(buffer, "usemtl %s", materialName, sizeof(materialName));

			// Loop through the face entries belonging to this group
			for ( UINT i = 0; i< numFaces[gi]; ++i )
			{
				// Read new line from file
				if ( fgets(buffer, sizeof(buffer), m_pFile) != NULL )
				{
					// Fill temprorary variables with face data
					if ( strstr(buffer, "/") )
						sscanf_s(buffer, "f %d/%d %d/%d %d/%d", &v0, &vt0, &v1, &vt1, &v2, &vt2);
					else
						sscanf_s(buffer, "f %d %d %d", &v0, &v1, &v2);

					// Construct the vertices and indices
					//
					int idx = i*3;

					memcpy(&m_pVertices[idx], &v[v0-1], sizeof(VERTEX));
					memcpy(&m_pVertices[idx+1], &v[v1-1], sizeof(VERTEX));
					memcpy(&m_pVertices[idx+2], &v[v2-1], sizeof(VERTEX));

					if ( strstr(buffer, "/") )
					{
						m_pVertices[idx].tu = vt[vt0-1].tu;
						m_pVertices[idx].tv = vt[vt0-1].tv;
						m_pVertices[idx+1].tu = vt[vt1-1].tu;
						m_pVertices[idx+1].tv = vt[vt1-1].tv;
						m_pVertices[idx+2].tu = vt[vt2-1].tu;
						m_pVertices[idx+2].tv = vt[vt2-1].tv;
					}

					// TODO: Vector normals for better lightning.


					// Build the vertex index list
					//
					m_pIndices[idx]	  = idx;
					m_pIndices[idx+1] = idx+1;
					m_pIndices[idx+2] = idx+2;

				} // ! if read line

			} // ! for faces
			
			// Add data to the vertex cache manager
			//
			if ( ! m_pDevice->GetVertexManager() )
				return false;

			if ( FAILED( m_pDevice->GetVertexManager()->CreateStaticBuffer(VID_UU, m_pSkins[MapMaterial(materialName)], m_numVertices,	m_numIndices, m_pVertices, m_pIndices, &m_pBufferID[MapMaterial(materialName)]) ) )
				return false;
			// we are done with this material group, set index to next
			gi++;

			delete m_pVertices; m_pVertices = NULL;
			delete m_pIndices; m_pIndices = NULL;
			m_numVertices = m_numIndices = 0;
		} // ! else usemtl
	} // ! while

	// Find Min and Max point of the object
	// Find half length diameter of the bounding box
	memcpy(&vMin, &v[0], sizeof(float)*3);
	memcpy(&vMax, &v[0], sizeof(float)*3);

	for (UINT i=1; i< numVertices; ++i)
	{
		if ( vMin.x > v[i].x )
			 vMin.x = v[i].x;
		if ( vMin.y > v[i].y )
			 vMin.y = v[i].y;
		if ( vMin.z > v[i].z )
			 vMin.z = v[i].z;

		if ( vMax.x < v[i].x )
			 vMax.x = v[i].x;
		if ( vMax.y < v[i].y )
			 vMax.y = v[i].y;
		if ( vMax.z < v[i].z )
			 vMax.z = v[i].z;
	}

	m_vCenter = (vMax + vMin) * 0.5f;
	m_fHalfLength = ((vMax - vMin) * 0.5f).GetLength();

	delete[] numFaces;
	delete[] v;
	delete[] vt;
	v  = NULL;
	vt = NULL;
	numFaces = NULL;

	m_numVertices = vCount;
	m_numIndices = iCount;
	return true;

} // ! LoadFile
void KPModel::LoadMaterials(FILE *file)
{

	assert(file);

	if (!file || !m_pDevice)
		return;

	char	buffer[128];						// buffer for the material library file
	KPCOLOR	cA, cD, cS, cE;						// Ambient, Diffuse, Specular and Emissing color values
	char	matName[100];						// Material Name
	char	textureFilePath[MAX_PATH];			// Path of the texture file, if there is any
	long int offset = 0;						// Offset of the previously read line

	ZeroMemory(matName, sizeof(matName));

	// Count the number of materials in the file
	//////////////////////////////////////////////////////
	while ( fgets( buffer, sizeof(buffer), file) != NULL )
	{
		if ( IsInString(buffer, "newmtl ") == 0 )
		{
			// Store the material's name
			sscanf_s(buffer, "newmtl %s", matName, sizeof(matName));
			//g_matMap[matName] = m_numMaterials++;
			m_MaterialMap[m_numMaterials++] = matName;
		}
	}
	// Back to the beginning of the file
	//fseek(file, 0, SEEK_SET);
	rewind(file);
	
	// Prepate the array of skin IDs
	m_pSkins = new UINT[m_numMaterials];

	// Load the material data
	/////////////////////////
	while ( fgets( buffer, sizeof(buffer), file) != NULL )
	{
		// If it is a beginning of the first material description
		// Process the properties
		if ( IsInString(buffer, "newmtl ") == 0 )
		{
			ZeroMemory(&cA, sizeof(KPCOLOR));
			ZeroMemory(&cD, sizeof(KPCOLOR));
			ZeroMemory(&cS, sizeof(KPCOLOR));
			ZeroMemory(&cE, sizeof(KPCOLOR));
			ZeroMemory(matName, sizeof(matName));
			ZeroMemory(textureFilePath, sizeof(textureFilePath));

			// Get the material's name
			sscanf_s(buffer, "newmtl %s", matName, sizeof(matName));

			// Start reading the material properties
			while ( fgets( buffer, sizeof(buffer), file) != NULL )
			{

				// if this line is the beginning of a new material description
				if ( IsInString(buffer, "newmtl ") == 0 )
				{
					// Just one line back and break the loop
					fseek(file, offset, SEEK_SET);
					break;
				}
				else
				{
					// Store the last line that was not a new entry
					offset = ftell(file);

					// Look for diffuse texture name
					if ( IsInString(buffer, "map_Kd") != -1 )
						sscanf_s(buffer, "\tmap_Kd %s", textureFilePath, sizeof(textureFilePath));

					// Look for color values
					else if ( IsInString(buffer, "Ka ") != -1 )
						sscanf_s(buffer, "\tKa %f %f %f", &cA.fR, &cA.fG, &cA.fB);
					else if ( IsInString(buffer, "Kd ") != -1 )
						sscanf_s(buffer, "\tKd %f %f %f", &cD.fR, &cD.fG, &cD.fB);
					else if ( IsInString(buffer, "Ks ") != -1 )
						sscanf_s(buffer, "\tKs %f %f %f", &cS.fR, &cS.fG, &cS.fB);
					else if ( IsInString(buffer, "Ke ") != -1 )
						sscanf_s(buffer, "\tKe %f %f %f", &cE.fR, &cE.fG, &cE.fB);

				} // ! if
			} // ! while properties
			
			// Save the material data
			if ( strlen(matName) > 0 && matName != '\0' )
			{

				if( !m_pDevice->GetSkinManager())
					return;

				m_pDevice->GetSkinManager()->AddSkin(&cA, &cD, &cE, &cS, 1.0, &m_pSkins[MapMaterial(matName)]);
				m_pDevice->GetSkinManager()->AddTexture(m_pSkins[MapMaterial(matName)],textureFilePath, false, 0, NULL, 0);

			}
		} // ! if entry

	} // ! while
		
} // ! LoadMaterials
Esempio n. 7
0
void ReadStyleElement(LPSTR styleFile, GradientItem* gradientItem, LPSTR paramString)
{
	strcpy(param, paramString);
	int nLen = strlen(param);

	//====================

	// Appearance (solid/gradient, bevel type, etc)
	char appearance[MAX_LINE_LENGTH];
	strcpy(&param[nLen], ":");
	strcpy(temp1, ReadString(styleFile, param, "Raised Gradient Vertical Bevel1"));
	strcpy(&param[nLen], ".appearance:");
	strcpy(appearance, ReadString(styleFile, param, temp1));

	if (IsInString(appearance, "solid")) gradientItem->type = B_SOLID;
	else if (IsInString(appearance, "horizontal")) gradientItem->type = B_HORIZONTAL;
	else if (IsInString(appearance, "vertical")) gradientItem->type = B_VERTICAL;
	else if (IsInString(appearance, "crossdiagonal")) gradientItem->type = B_CROSSDIAGONAL;
	else if (IsInString(appearance, "diagonal")) gradientItem->type = B_DIAGONAL;
	else if (IsInString(appearance, "pipecross")) gradientItem->type = B_PIPECROSS;
	else if (IsInString(appearance, "elliptic")) gradientItem->type = B_ELLIPTIC;
	else if (IsInString(appearance, "rectangle")) gradientItem->type = B_RECTANGLE;
	else if (IsInString(appearance, "pyramid")) gradientItem->type = B_PYRAMID;
	else gradientItem->type = B_SOLID;

	if (IsInString(appearance, "parentrelative")) gradientItem->parentRelative = true;
	else gradientItem->parentRelative = false;

	if (IsInString(appearance, "flat")) gradientItem->bevelstyle = BEVEL_FLAT;
	else if (IsInString(appearance, "sunken")) gradientItem->bevelstyle = BEVEL_SUNKEN;
	else gradientItem->bevelstyle = BEVEL_RAISED;

	if (IsInString(appearance, "bevel2")) gradientItem->bevelposition = BEVEL2;
	else gradientItem->bevelposition = BEVEL1;

	if (IsInString(appearance, "interlaced")) gradientItem->interlaced = true;
	else gradientItem->interlaced = false;

	//====================

	// Border
	strcpy(&param[nLen], ".borderColor:");
	gradientItem->borderColor = ReadColor(styleFile, param, borderColorAsString);

	strcpy(&param[nLen], ".borderWidth:");
	gradientItem->borderWidth = ReadInt(styleFile, param, 255);
	if (gradientItem->borderWidth == 255)
	{
		if (IsInString(appearance, "border")) gradientItem->borderWidth = mSkin.borderWidth;
		else gradientItem->borderWidth = 0;
	}

	//====================

	// Margin (including various tweaks to look like the original bbLeanSkin)
	if (gradientItem == &mSkin.windowTitleFocus)
	{
		gradientItem->marginWidth = ReadInt(styleFile, "window.title.focus.marginWidth:", 1);
		gradientItem->marginWidth = ReadInt(styleFile, "window.title.marginWidth:", gradientItem->marginWidth);
	}
	else if (gradientItem == &mSkin.windowLabelFocus)
	{
		gradientItem->marginWidth = ReadInt(styleFile, "window.label.focus.marginWidth:", 2);
		gradientItem->marginWidth = ReadInt(styleFile, "window.label.marginWidth:", gradientItem->marginWidth);
	}
	else if (gradientItem == &mSkin.windowButtonFocus)
	{
		gradientItem->marginWidth = ReadInt(styleFile, "window.button.focus.marginWidth:", 2);
		gradientItem->marginWidth = ReadInt(styleFile, "window.button.marginWidth:", gradientItem->marginWidth);
	}
	else
	{
		strcpy(&param[nLen], ".marginWidth:");
		gradientItem->marginWidth = ReadInt(styleFile, param, 1);
	}

	gradientItem->validated = VALID_MARGIN; // Not sure what this bbLean proprietary flag is used for... /qwilk

	//====================

	// Background colours
	strcpy(&param[nLen], ".backgroundColor:");
	strcpy(temp1, ReadString(styleFile, param, "0xffffff"));
	strcpy(&param[nLen], ".color1:");
	strcpy(temp2, ReadString(styleFile, param, temp1));
	strcpy(&param[nLen], ".color:");
	gradientItem->Color = ReadColor(styleFile, param, temp2);

	if (gradientItem->type == B_SOLID) gradientItem->ColorTo = gradientItem->Color;
	else
	{
		strcpy(&param[nLen], ".color2:");
		strcpy(temp1, ReadString(styleFile, param, "0xdddddd"));
		strcpy(&param[nLen], ".colorTo:");
		gradientItem->ColorTo = ReadColor(styleFile, param, temp1);
	}

	//====================

	// Foreground colours (mutually exclusive)
	strcpy(&param[nLen], ".foregroundColor:");
	strcpy(temp1, ReadString(styleFile, param, "0x000000"));
	strcpy(&param[nLen], ".picColor:");
	strcpy(temp2, ReadString(styleFile, param, temp1));
	strcpy(&param[nLen], ".textColor:");
	gradientItem->TextColor = ReadColor(styleFile, param, temp2);
}
Esempio n. 8
0
void GetStyleSettings()
{
	// Get the path to the current style file from Blackbox...
	strcpy(stylepath, stylePath());

	// ...and some additional parameters
	bevelWidth = ReadInt(stylepath, "bevelWidth:", 2);
	borderWidth = ReadInt(stylepath, "borderWidth:", 1);

	// Get the applicable color settings from the current style...
	backColor = ReadColor(stylepath, "toolbar.color:", "#000000");
	backColorTo = ReadColor(stylepath, "toolbar.colorTo:", "#FFFFFF");
	
	borderColor = ReadColor(stylepath, "borderColor:", "#000000");

	// ...gradient type, bevel etc. from toolbar:(using a StyleItem)...
	char tempstyle[MAX_LINE_LENGTH];
	strcpy(tempstyle, ReadString(stylepath, "toolbar:", "Flat Gradient Vertical"));
	if (myStyleItem) delete myStyleItem;
	myStyleItem = new StyleItem;
	ParseItem(tempstyle, myStyleItem);

	
	
 if(StrStrI(windowStyle, "label") != NULL  && strlen(windowStyle) < 6)
	{
		// ...gradient type, bevel etc. from toolbar.label:(using a StyleItem)...
		char tempstyle2[MAX_LINE_LENGTH];
		strcpy(tempstyle2, ReadString(stylepath, "toolbar.label:", "parentrelative"));
		if (!IsInString("", tempstyle2)&&!IsInString(tempstyle2, "parentrelative"))
		{
			if (myStyleItem2) delete myStyleItem2;	//if everything is found in toolbar.label: then make a new StyleItem
			myStyleItem2 = new StyleItem;			
			ParseItem(tempstyle2, myStyleItem2);
			
			if (!IsInString("", ReadString(stylepath, "toolbar.label.color:", "")))
				backColor2 = ReadColor(stylepath, "toolbar.label.color:", "#000000");
			else
    			backColor2 = ReadColor(stylepath, "toolbar.color:", "#FFFFFF");

			if (!IsInString("", ReadString(stylepath, "toolbar.label.colorTo:", "")))
				backColorTo2 = ReadColor(stylepath, "toolbar.label.colorTo:", "#000000");
			else
				backColorTo2 = ReadColor(stylepath, "toolbar.colorTo:", "#000000");
			
			fontColor = ReadColor(stylepath, "toolbar.label.textColor:", "#FFFFFF");
		}
		else
		{
			if (myStyleItem2) delete myStyleItem2;	//else use the the toolbar: settings
			myStyleItem2 = new StyleItem;
			ParseItem(tempstyle, myStyleItem2);	//use original tempstyle if "parentrelative"
			backColor2 = backColor;			//have to do this if parent relative found, it seems bb4win uses
			backColorTo2 = backColorTo;		//the toolbar.color if parent relative is found for toolbar.label
			fontColor = ReadColor(stylepath, "toolbar.textColor:", "#FFFFFF");
		}
	} 
	else if(StrStrI(windowStyle, "windowlabel") != NULL)
	{
		// ...gradient type, bevel etc. from toolbar.windowLabel:(using a StyleItem)...
		char tempstyle2[MAX_LINE_LENGTH];
		strcpy(tempstyle2, ReadString(stylepath, "toolbar.windowLabel:", "parentrelative"));
		if (!IsInString("", tempstyle2)&&!IsInString(tempstyle2, "parentrelative"))
		{
			if (myStyleItem2) delete myStyleItem2;	//if everything is found in toolbar.windowLabel: then make a new StyleItem
			myStyleItem2 = new StyleItem;			
			ParseItem(tempstyle2, myStyleItem2);
			
			if (!IsInString("", ReadString(stylepath, "toolbar.windowLabel.color:", "")))
				backColor2 = ReadColor(stylepath, "toolbar.windowLabel.color:", "#000000");
			else
    			backColor2 = ReadColor(stylepath, "toolbar.color:", "#FFFFFF");

			if (!IsInString("", ReadString(stylepath, "toolbar.windowLabel.colorTo:", "")))
				backColorTo2 = ReadColor(stylepath, "toolbar.windowLabel.colorTo:", "#000000");
			else
				backColorTo2 = ReadColor(stylepath, "toolbar.colorTo:", "#000000");
			
			fontColor = ReadColor(stylepath, "toolbar.windowLabel.textColor:", "#FFFFFF");
		}
	}
	else if(StrStrI(windowStyle, "toolbar") != NULL)
	{
		if (myStyleItem2) delete myStyleItem2;	//else use the the toolbar: settings
			myStyleItem2 = new StyleItem;
			ParseItem(tempstyle, myStyleItem2);	//use original tempstyle if "parentrelative"
			backColor2 = ReadColor(stylepath, "toolbar.color:", "#FFFFFF");		//have to do this if parent relative found, it seems bb4win uses
			backColorTo2 = ReadColor(stylepath, "toolbar.colorTo:", "#000000");	//the toolbar.color if parent relative is found for toolbar.windowLabel
			fontColor = ReadColor(stylepath, "toolbar.textColor:", "#FFFFFF");
	}
		else if(StrStrI(windowStyle, "buttonpr") != NULL)
	{
		// ...gradient type, bevel etc. from toolbar.windowLabel:(using a StyleItem)...
		char tempstyle2[MAX_LINE_LENGTH];
		strcpy(tempstyle2, ReadString(stylepath, "toolbar.button.pressed:", "parentrelative"));
		if (!IsInString("", tempstyle2)&&!IsInString(tempstyle2, "parentrelative"))
		{
			if (myStyleItem2) delete myStyleItem2;	//if everything is found in toolbar.windowLabel: then make a new StyleItem
			myStyleItem2 = new StyleItem;			
			ParseItem(tempstyle2, myStyleItem2);
			
			if (!IsInString("", ReadString(stylepath, "toolbar.button.pressed.color:", "")))
				backColor2 = ReadColor(stylepath, "toolbar.button.pressed.color:", "#000000");
			else
    			backColor2 = ReadColor(stylepath, "toolbar.color:", "#FFFFFF");

			if (!IsInString("", ReadString(stylepath, "toolbar.button.pressed.colorTo:", "")))
				backColorTo2 = ReadColor(stylepath, "toolbar.button.pressed.colorTo:", "#000000");
			else
				backColorTo2 = ReadColor(stylepath, "toolbar.colorTo:", "#000000");
			
			fontColor = ReadColor(stylepath, "toolbar.button.pressed.picColor:", "#FFFFFF");
		}
		else
		{
			if (myStyleItem2) delete myStyleItem2;	//else use the the toolbar: settings
			myStyleItem2 = new StyleItem;
			ParseItem(tempstyle, myStyleItem2);	//use original tempstyle if "parentrelative"
			backColor2 = backColor;			//have to do this if parent relative found, it seems bb4win uses
			backColorTo2 = backColorTo;		//the toolbar.color if parent relative is found for toolbar.clock
			fontColor = ReadColor(stylepath, "toolbar.textColor:", "#FFFFFF");
		}
	}
	else if(StrStrI(windowStyle, "buttonnp") != NULL)
	{
		// ...gradient type, bevel etc. from toolbar.windowLabel:(using a StyleItem)...
		char tempstyle2[MAX_LINE_LENGTH];
		strcpy(tempstyle2, ReadString(stylepath, "toolbar.button:", "parentrelative"));
		if (!IsInString("", tempstyle2)&&!IsInString(tempstyle2, "parentrelative"))
		{
			if (myStyleItem2) delete myStyleItem2;	//if everything is found in toolbar.windowLabel: then make a new StyleItem
			myStyleItem2 = new StyleItem;			
			ParseItem(tempstyle2, myStyleItem2);
			
			if (!IsInString("", ReadString(stylepath, "toolbar.button.color:", "")))
				backColor2 = ReadColor(stylepath, "toolbar.button.color:", "#000000");
			else
    			backColor2 = ReadColor(stylepath, "toolbar.color:", "#FFFFFF");

			if (!IsInString("", ReadString(stylepath, "toolbar.button.colorTo:", "")))
				backColorTo2 = ReadColor(stylepath, "toolbar.button.colorTo:", "#000000");
			else
				backColorTo2 = ReadColor(stylepath, "toolbar.colorTo:", "#000000");
			
			fontColor = ReadColor(stylepath, "toolbar.button.picColor:", "#FFFFFF");
		}
		else
		{
			if (myStyleItem2) delete myStyleItem2;	//else use the the toolbar: settings
			myStyleItem2 = new StyleItem;
			ParseItem(tempstyle, myStyleItem2);	//use original tempstyle if "parentrelative"
			backColor2 = backColor;			//have to do this if parent relative found, it seems bb4win uses
			backColorTo2 = backColorTo;		//the toolbar.color if parent relative is found for toolbar.clock
			fontColor = ReadColor(stylepath, "toolbar.textColor:", "#FFFFFF");
		}
	}
	else
	{
		// ...gradient type, bevel etc. from toolbar.clock:(using a StyleItem)...
		char tempstyle2[MAX_LINE_LENGTH];
		strcpy(tempstyle2, ReadString(stylepath, "toolbar.clock:", "parentrelative"));
		if (!IsInString("", tempstyle2)&&!IsInString(tempstyle2, "parentrelative"))
		{
			if (myStyleItem2) delete myStyleItem2;	//if everything is found in toolbar.clock: then make a new StyleItem
			myStyleItem2 = new StyleItem;			
			ParseItem(tempstyle2, myStyleItem2);
			
			if (!IsInString("", ReadString(stylepath, "toolbar.clock.color:", "")))
				backColor2 = ReadColor(stylepath, "toolbar.clock.color:", "#000000");
			else
    			backColor2 = ReadColor(stylepath, "toolbar.color:", "#FFFFFF");

			if (!IsInString("", ReadString(stylepath, "toolbar.clock.colorTo:", "")))
				backColorTo2 = ReadColor(stylepath, "toolbar.clock.colorTo:", "#000000");
			else
				backColorTo2 = ReadColor(stylepath, "toolbar.colorTo:", "#000000");
			
			fontColor = ReadColor(stylepath, "toolbar.clock.textColor:", "#FFFFFF");
		}
		else
		{
			if (myStyleItem2) delete myStyleItem2;	//else use the the toolbar: settings
			myStyleItem2 = new StyleItem;
			ParseItem(tempstyle, myStyleItem2);	//use original tempstyle if "parentrelative"
			backColor2 = backColor;			//have to do this if parent relative found, it seems bb4win uses
			backColorTo2 = backColorTo;		//the toolbar.color if parent relative is found for toolbar.clock
			fontColor = ReadColor(stylepath, "toolbar.textColor:", "#FFFFFF");
		}
	}

	// ...font settings...
	strcpy(fontFace, ReadString(stylepath, "toolbar.font:", ""));
	if (!_stricmp(fontFace, "")) strcpy(fontFace, ReadString(stylepath, "*font:", "Tahoma"));
	
}
Esempio n. 9
0
bool CModelMD3::LoadAnimations(LPSTR strConfigFile)
{
	tAnimationInfo animations[MAX_ANIMATIONS] = {0};

	ifstream fin(strConfigFile);
	if( fin.fail() )
	{
		return false;
	}

	string strWord = "";				
	string strLine = "";				
	int currentAnim = 0;				
	int torsoOffset = 0;				
	while( fin >> strWord)
	{
		if(!isdigit( strWord[0] ))
		{
			getline(fin, strLine);
			continue;
		}

		int startFrame = atoi(strWord.c_str());
		int numOfFrames = 0, loopingFrames = 0, framesPerSecond = 0;
		fin >> numOfFrames >> loopingFrames >> framesPerSecond;

		animations[currentAnim].startFrame		= startFrame;
		animations[currentAnim].endFrame		= startFrame + numOfFrames;
		animations[currentAnim].loopingFrames	= loopingFrames;
		animations[currentAnim].framesPerSecond = framesPerSecond;

		fin >> strLine >> strLine;
		strcpy(animations[currentAnim].strName, strLine.c_str());

		if(IsInString(strLine, "BOTH"))
		{
			m_Upper.pAnimations.push_back(animations[currentAnim]);
			m_Lower.pAnimations.push_back(animations[currentAnim]);
		}
		else if(IsInString(strLine, "TORSO"))
		{
			m_Upper.pAnimations.push_back(animations[currentAnim]);
		}
		else if(IsInString(strLine, "LEGS"))
		{	
			if(!torsoOffset)
				torsoOffset = animations[LEGS_WALKCR].startFrame - animations[TORSO_GESTURE].startFrame;

			animations[currentAnim].startFrame -= torsoOffset;
			animations[currentAnim].endFrame -= torsoOffset;

			m_Lower.pAnimations.push_back(animations[currentAnim]);
		}
	
		currentAnim++;
	}	

	m_Lower.numOfAnimations = m_Lower.pAnimations.size();
	m_Upper.numOfAnimations = m_Upper.pAnimations.size();
	m_Head.numOfAnimations = m_Head.pAnimations.size();
	m_Weapon.numOfAnimations = m_Head.pAnimations.size();

	return true;
}