コード例 #1
0
ファイル: player_template.c プロジェクト: flags/cdogs-sdl
static void LoadPlayerTemplate(
	PlayerTemplate *t, json_t *node, const int version)
{
	strcpy(t->name, json_find_first_label(node, "Name")->child->text);
	t->Class = StrCharacterClass(
		json_find_first_label(node, "Face")->child->text);
	CASSERT(t->Class != NULL, "cannot find character class");
	if (version == 1)
	{
		// Version 1 used integer palettes
		int skin, arms, body, legs, hair;
		LoadInt(&skin, node, "Skin");
		LoadInt(&arms, node, "Arms");
		LoadInt(&body, node, "Body");
		LoadInt(&legs, node, "Legs");
		LoadInt(&hair, node, "Hair");
		ConvertCharacterColors(skin, arms, body, legs, hair, &t->Colors);
	}
	else
	{
		LoadColor(&t->Colors.Skin, node, "Skin");
		LoadColor(&t->Colors.Arms, node, "Arms");
		LoadColor(&t->Colors.Body, node, "Body");
		LoadColor(&t->Colors.Legs, node, "Legs");
		LoadColor(&t->Colors.Hair, node, "Hair");
	}
}
コード例 #2
0
ファイル: FlarmProfile.cpp プロジェクト: Advi42/XCSoar
void
Profile::Load(const ProfileMap &map, FlarmColorDatabase &db)
{
  LoadColor(map, db, "FriendsGreen", FlarmColor::GREEN);
  LoadColor(map, db, "FriendsBlue", FlarmColor::BLUE);
  LoadColor(map, db, "FriendsYellow", FlarmColor::YELLOW);
  LoadColor(map, db, "FriendsMagenta", FlarmColor::MAGENTA);
}
コード例 #3
0
void
FlarmFriends::Load()
{
  LogStartUp(_T("Loading FLARM friends database"));

  LoadColor(_T("FriendsGreen"), Color::GREEN);
  LoadColor(_T("FriendsBlue"), Color::BLUE);
  LoadColor(_T("FriendsYellow"), Color::YELLOW);
  LoadColor(_T("FriendsMagenta"), Color::MAGENTA);
}
コード例 #4
0
ファイル: map_new.c プロジェクト: CrypticGator/cdogs-sdl
void LoadCharacters(
	CharacterStore *c, json_t *charactersNode, const int version)
{
	json_t *child = charactersNode->child;
	CharacterStoreTerminate(c);
	CharacterStoreInit(c);
	while (child)
	{
		Character *ch = CharacterStoreAddOther(c);
		char *tmp;
		if (version < 7)
		{
			// Old version stored character looks as palette indices
			int face;
			LoadInt(&face, child, "face");
			ch->Class = IntCharacterClass(face);
			int skin, arm, body, leg, hair;
			LoadInt(&skin, child, "skin");
			LoadInt(&arm, child, "arm");
			LoadInt(&body, child, "body");
			LoadInt(&leg, child, "leg");
			LoadInt(&hair, child, "hair");
			ConvertCharacterColors(skin, arm, body, leg, hair, &ch->Colors);
		}
		else
		{
			tmp = GetString(child, "Class");
			ch->Class = StrCharacterClass(tmp);
			CFREE(tmp);
			LoadColor(&ch->Colors.Skin, child, "Skin");
			LoadColor(&ch->Colors.Arms, child, "Arms");
			LoadColor(&ch->Colors.Body, child, "Body");
			LoadColor(&ch->Colors.Legs, child, "Legs");
			LoadColor(&ch->Colors.Hair, child, "Hair");
		}
		LoadInt(&ch->speed, child, "speed");
		tmp = GetString(child, "Gun");
		ch->Gun = StrGunDescription(tmp);
		CFREE(tmp);
		LoadInt(&ch->maxHealth, child, "maxHealth");
		LoadInt(&ch->flags, child, "flags");
		LoadInt(&ch->bot->probabilityToMove, child, "probabilityToMove");
		LoadInt(&ch->bot->probabilityToTrack, child, "probabilityToTrack");
		LoadInt(&ch->bot->probabilityToShoot, child, "probabilityToShoot");
		LoadInt(&ch->bot->actionDelay, child, "actionDelay");
		child = child->next;
	}
}
コード例 #5
0
ファイル: MeshModel.cpp プロジェクト: hongyunL/OpenGL
/* 首先,已知顶点位置坐标v0 v1 v2 v3…和法向量n0 n1 n2 n3…。
* (上述vi 和 ni都是数组,长度为3,表示一个三维向量)
* 因此,指定3个序号,比如0,1,2代表v0v1v2即可指定一个三角形3个顶点的位置;
* 又指定3个序号,比如0,2,4代表n0n2n4即可指定一个三角形3个顶点的法向量。
* 把刚才指定的序号结合在一起,即0,1,2,0,2,4,即可描述一个三角形面的位置和方向 
*/
void MeshModel::LoadMeshDataFrom3DE(
	unsigned vertexNum,
	int face_indicies[][6], unsigned faceIndiciesLength,
	float vertices[][3], unsigned verticesLength,
	float normals[][3], unsigned normalsLength,
	float colorR, float colorG, float colorB)
{
	std::vector<float> vecVertex;
	std::vector<float> vecNormal;
	std::vector<float> vecColor;

	for (unsigned i = 0; i<faceIndiciesLength / sizeof(face_indicies[0]); i++)
	{
		for (unsigned j = 0; j<3; j++)
		{
			int vi = face_indicies[i][j];
			int ni = face_indicies[i][j + 3];//Normal index
			vecVertex.push_back(vertices[vi][0]);
			vecVertex.push_back(vertices[vi][1]);
			vecVertex.push_back(vertices[vi][2]);
			vecNormal.push_back(normals[ni][0]);
			vecNormal.push_back(normals[ni][1]);
			vecNormal.push_back(normals[ni][2]);
			vecColor.push_back(colorR);
			vecColor.push_back(colorG);
			vecColor.push_back(colorB);
		}
	}

	LoadColor(vecColor.data(), vecColor.size()*sizeof(float), GL_FLOAT, 3);
	LoadVertex(vecVertex.data(), vecVertex.size()*sizeof(float), GL_FLOAT, 3);
	LoadNormal(vecNormal.data(), vecNormal.size()*sizeof(float), GL_FLOAT);
}
コード例 #6
0
//====================================================
//	BaseRenderComponent definitions
//====================================================
bool BaseRenderComponent::Init(TiXmlElement* pData)
{
	TiXmlElement* pColorNode = pData->FirstChildElement("Color");
	if (pColorNode)
		m_Color = LoadColor(pColorNode);

	return DelegateInit(pData);
}
コード例 #7
0
int CSynBCGPEditCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CBCGPEditCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	LoadColor();

	return 0;
}
コード例 #8
0
TVizMapContext::TVizMapContext(PVizMap _VizMap): 
        VizMap(_VizMap), VizMapFrameN(0),
        VizMapFrame(_VizMap->GetFirst()), SelMode(vmsmZoom), 
        MgGlassPoints(0), MouseInP(false), LeftButtonDownP(false), 
        MgGlassSize(0.2), NearPointN(-1) { 

    LoadColor();
    LoadCatFullNms();
    ResetFrame();
}
コード例 #9
0
ファイル: OFSNcDlg2.cpp プロジェクト: alex765022/IBN
void COFSNcDlg2::LoadColors(IXMLDOMNode *pXmlRoot)
{
	CComPtr<IXMLDOMNode> pColors = NULL;
	
	m_crButton.Clear();
	m_crDialog.Clear();
	m_crEdit.Clear();
	m_crList.Clear();
	m_crScroll.Clear();
	m_crStatic.Clear();
//	if(m_pBrush)
//	{
//		m_pBrush->DeleteObject();
//		delete m_pBrush;
//		m_pBrush = NULL;
//	}
	
	if(pXmlRoot)
	{
		pXmlRoot->selectSingleNode(CComBSTR(L"Colors"), &pColors);
		if(pColors)
		{
			LoadColor(pColors, _T("Button"), m_crButton);
			LoadColor(pColors, _T("Dialog"), m_crDialog);
			LoadColor(pColors, _T("Edit"), m_crEdit);
			LoadColor(pColors, _T("List"), m_crList);
			LoadColor(pColors, _T("Scroll"), m_crScroll);
			LoadColor(pColors, _T("Static"), m_crStatic);
			//pColors->Release();
		}
	}
}
コード例 #10
0
ファイル: SceneBase.cpp プロジェクト: Pycorax/GDevFramework
void SceneBase::InitColors()
{
	const string COLOR_FILE_PATH = "SONs//Colors.son";

	StopWatch initTimer;
	initTimer.startTimer();

	std::cout << "Loading " << COLOR_FILE_PATH << "... ";

	colList = LoadColor(COLOR_FILE_PATH, colListMap);
	// Push the default Color to the back
	colList.push_back(Color());
	colListMap.push_back("Generic Color");

	if (colList.size() != colListMap.size())
	{
		std::cout << "Error: " << COLOR_FILE_PATH << " has resulted in unequal amounts of Color and Color Names!" << std::endl;
	}
	else
	{
		std::cout << "Loaded! (" << initTimer.getElapsedTime() << "s)" << std::endl;
	}
}
コード例 #11
0
ファイル: OFSNcDlg2.cpp プロジェクト: alex765022/IBN
BOOL COFSNcDlg2::LoadLabel(IXMLDOMNode *pXmlRoot, LPCTSTR szName, CLabel *pLbl, BOOL bVisible)
{
	BOOL bResult = FALSE;
	LoadSkins skin;
	long nErrorCode = 0;
	HRESULT hr = S_OK;
	CString strErrorMessage;
	IStreamPtr pStream = NULL;
	CComPtr<IXMLDOMNode> pLabel = NULL, pFont = NULL;
	CComBSTR bs;
	_bstr_t bsImagePath;
	long x=0, y=0, cx=0, cy=0;
	WCHAR *szNULL = L"\0x00";
	
	pLbl->ShowWindow(SW_HIDE);

	bs.Empty();
	bs = L"Label[@Name='";
	bs += szName;
	bs += L"']";
	pXmlRoot->selectSingleNode(bs, &pLabel);
	if(pLabel)
	{
		bResult = TRUE;
		// Get button coordinates
		bs.Empty();
		SelectChildNode(pLabel, CComBSTR(L"XPos"), NULL, &bs);
		if(bs.m_str != NULL)
			x = wcstol(bs.m_str, &szNULL, 10);
		bs.Empty();
		SelectChildNode(pLabel, CComBSTR(L"YPos"), NULL, &bs);
		if(bs.m_str != NULL)
			y = wcstol(bs.m_str, &szNULL, 10);
		bs.Empty();
		SelectChildNode(pLabel, CComBSTR(L"XLen"), NULL, &bs);
		if(bs.m_str != NULL)
			cx = wcstol(bs.m_str, &szNULL, 10);
		bs.Empty();
		SelectChildNode(pLabel, CComBSTR(L"YLen"), NULL, &bs);
		if(bs.m_str != NULL)
			cy = wcstol(bs.m_str, &szNULL, 10);
		
		COLORREF crText, crBG;
		LoadColor(pLabel, _T("Text"), crText);
		if(crText != CLR_NONE)
			pLbl->SetTextColor(crText);
		LoadColor(pLabel, _T("BG"), crBG);
		if(crBG != CLR_NONE)
		{
			pLbl->SetTransparent(FALSE);
			pLbl->SetBkColor(crBG);
		}
		else
			pLbl->SetTransparent(TRUE);

		// Load font
		pLabel->selectSingleNode(CComBSTR(L"Font"), &pFont);
		if(pFont)
		{
			bs.Empty();
			GetNodeAttribute(pFont, CComBSTR(L"Face"), bs);
			if(bs.m_str != NULL && bs.Length())
				pLbl->SetFontName(CString(bs));

			long n = 0;
			GetNodeAttributeAsLong(pFont, CComBSTR(L"Size"), &n, 10);
			if(n != 0)
				pLbl->SetFontSize(n);

			n = 0;
			GetNodeAttributeAsLong(pFont, CComBSTR(L"Bold"), &n, 10);
				pLbl->SetFontBold(n != 0);
				
			n = 0;
			GetNodeAttributeAsLong(pFont, CComBSTR(L"Italic"), &n, 10);
			pLbl->SetFontItalic(n != 0);
				
			n = 0;
			GetNodeAttributeAsLong(pFont, CComBSTR(L"Underline"), &n, 10);
			pLbl->SetFontUnderline(n != 0);
				
			//pFont->Release();
		}

		
		UINT nFlags = SWP_NOZORDER;
		
		if(bVisible)
			nFlags |= SWP_SHOWWINDOW;
		
		pLbl->SetWindowPos(NULL, x, y, cx, cy, nFlags);
		
		// Load settings for resize
		IXMLDOMNode *pResize = NULL;
		
		pLabel->selectSingleNode(CComBSTR(L"Resize"), &pResize);
		if(pResize)
		{
			long tlcx, tlcy, brcx, brcy;
			
			GetNodeAttributeAsLong(pResize, _bstr_t("TLCX"), &tlcx, 10);
			GetNodeAttributeAsLong(pResize, _bstr_t("TLCY"), &tlcy, 10);
			GetNodeAttributeAsLong(pResize, _bstr_t("BRCX"), &brcx, 10);
			GetNodeAttributeAsLong(pResize, _bstr_t("BRCY"), &brcy, 10);
			
			if(tlcx || tlcy || brcx || brcy)
				AddAnchor(pLbl->GetSafeHwnd(), CSize(tlcx, tlcy), CSize(brcx, brcy));
			
			//pResize->Release();
		}
		
		
		//pLabel->Release();
	}
	return bResult;
}
コード例 #12
0
ファイル: map_new.c プロジェクト: alexmustafa/cdogs-sdl
void LoadMissions(CArray *missions, json_t *missionsNode, int version)
{
	json_t *child;
	for (child = missionsNode->child; child; child = child->next)
	{
		Mission m;
		MissionInit(&m);
		m.Title = GetString(child, "Title");
		m.Description = GetString(child, "Description");
		JSON_UTILS_LOAD_ENUM(m.Type, child, "Type", StrMapType);
		LoadInt(&m.Size.x, child, "Width");
		LoadInt(&m.Size.y, child, "Height");
		if (version <= 10)
		{
			int style;
			LoadInt(&style, child, "WallStyle");
			strcpy(m.WallStyle, IntWallStyle(style));
			LoadInt(&style, child, "FloorStyle");
			strcpy(m.FloorStyle, IntFloorStyle(style));
			LoadInt(&style, child, "RoomStyle");
			strcpy(m.RoomStyle, IntRoomStyle(style));
		}
		else
		{
			char *tmp = GetString(child, "WallStyle");
			strcpy(m.WallStyle, tmp);
			CFREE(tmp);
			tmp = GetString(child, "FloorStyle");
			strcpy(m.FloorStyle, tmp);
			CFREE(tmp);
			tmp = GetString(child, "RoomStyle");
			strcpy(m.RoomStyle, tmp);
			CFREE(tmp);
		}
		if (version <= 9)
		{
			int style;
			LoadInt(&style, child, "ExitStyle");
			strcpy(m.ExitStyle, IntExitStyle(style));
		}
		else
		{
			char *tmp = GetString(child, "ExitStyle");
			strcpy(m.ExitStyle, tmp);
			CFREE(tmp);
		}
		if (version <= 8)
		{
			int keyStyle;
			LoadInt(&keyStyle, child, "KeyStyle");
			strcpy(m.KeyStyle, IntKeyStyle(keyStyle));
		}
		else
		{
			char *tmp = GetString(child, "KeyStyle");
			strcpy(m.KeyStyle, tmp);
			CFREE(tmp);
		}
		if (version <= 5)
		{
			int doorStyle;
			LoadInt(&doorStyle, child, "DoorStyle");
			strcpy(m.DoorStyle, IntDoorStyle(doorStyle));
		}
		else
		{
			char *tmp = GetString(child, "DoorStyle");
			strcpy(m.DoorStyle, tmp);
			CFREE(tmp);
		}
		LoadMissionObjectives(
			&m.Objectives,
			json_find_first_label(child, "Objectives")->child,
			version);
		LoadIntArray(&m.Enemies, child, "Enemies");
		LoadIntArray(&m.SpecialChars, child, "SpecialChars");
		if (version <= 3)
		{
			CArray items;
			CArrayInit(&items, sizeof(int));
			LoadIntArray(&items, child, "Items");
			CArray densities;
			CArrayInit(&densities, sizeof(int));
			LoadIntArray(&densities, child, "ItemDensities");
			for (int i = 0; i < (int)items.size; i++)
			{
				MapObjectDensity mod;
				mod.M = IntMapObject(*(int *)CArrayGet(&items, i));
				mod.Density = *(int *)CArrayGet(&densities, i);
				CArrayPushBack(&m.MapObjectDensities, &mod);
			}
		}
		else
		{
			json_t *modsNode =
				json_find_first_label(child, "MapObjectDensities");
			if (modsNode && modsNode->child)
			{
				modsNode = modsNode->child;
				for (json_t *modNode = modsNode->child;
					modNode;
					modNode = modNode->next)
				{
					MapObjectDensity mod;
					mod.M = StrMapObject(
						json_find_first_label(modNode, "MapObject")->child->text);
					LoadInt(&mod.Density, modNode, "Density");
					CArrayPushBack(&m.MapObjectDensities, &mod);
				}
			}
		}
		LoadInt(&m.EnemyDensity, child, "EnemyDensity");
		LoadWeapons(
			&m.Weapons, json_find_first_label(child, "Weapons")->child);
		strcpy(m.Song, json_find_first_label(child, "Song")->child->text);
		if (version <= 4)
		{
			// Load colour indices
			int wc, fc, rc, ac;
			LoadInt(&wc, child, "WallColor");
			LoadInt(&fc, child, "FloorColor");
			LoadInt(&rc, child, "RoomColor");
			LoadInt(&ac, child, "AltColor");
			m.WallMask = RangeToColor(wc);
			m.FloorMask = RangeToColor(fc);
			m.RoomMask = RangeToColor(rc);
			m.AltMask = RangeToColor(ac);
		}
		else
		{
			LoadColor(&m.WallMask, child, "WallMask");
			LoadColor(&m.FloorMask, child, "FloorMask");
			LoadColor(&m.RoomMask, child, "RoomMask");
			LoadColor(&m.AltMask, child, "AltMask");
		}
		switch (m.Type)
		{
		case MAPTYPE_CLASSIC:
			LoadInt(&m.u.Classic.Walls, child, "Walls");
			LoadInt(&m.u.Classic.WallLength, child, "WallLength");
			LoadInt(&m.u.Classic.CorridorWidth, child, "CorridorWidth");
			LoadClassicRooms(
				&m, json_find_first_label(child, "Rooms")->child);
			LoadInt(&m.u.Classic.Squares, child, "Squares");
			LoadClassicDoors(&m, child, "Doors");
			LoadClassicPillars(&m, child, "Pillars");
			break;
		case MAPTYPE_STATIC:
			if (!TryLoadStaticMap(&m, child, version))
			{
				continue;
			}
			break;
		case MAPTYPE_CAVE:
			LoadInt(&m.u.Cave.FillPercent, child, "FillPercent");
			LoadInt(&m.u.Cave.Repeat, child, "Repeat");
			LoadInt(&m.u.Cave.R1, child, "R1");
			LoadInt(&m.u.Cave.R2, child, "R2");
			break;
		default:
			assert(0 && "unknown map type");
			continue;
		}
		CArrayPushBack(missions, &m);
	}
}
コード例 #13
0
ファイル: Common.cpp プロジェクト: mmanley/Antares
BResources*
read_resources(const char* appSignature)
{
	status_t ret = be_app->GetAppInfo(&kAppInfo);
	if (ret != B_OK) {
		fprintf(stderr, "Failed to init application info: %s\n",
			strerror(ret));
		exit(1);
	}
	
	BFile file(&kAppInfo.ref, O_RDONLY);
	ret = file.InitCheck();
	if (ret != B_OK) {
		fprintf(stderr, "Failed to init application file to read resources: "
			"%s\n", strerror(ret));
		exit(1);
	}

	BResources* r = new BResources(&file);

#define LoadString(n)	(char*)r->LoadResource(B_STRING_TYPE, n, &ignore)
#define LoadColor(n)	*(rgb_color*)r->LoadResource(B_RGB_COLOR_TYPE, n, &ignore)
#define LoadUint8(n)	*(uint8*)r->LoadResource(B_UINT8_TYPE, n, &ignore)

	size_t ignore;
	kVolMenuLabel = LoadString("STR_VM_LABEL");
	kOneFile = LoadString("STR_1_FILE");
	kManyFiles = LoadString("STR_N_FILES");
	kStrRescan = LoadString("STR_RESCAN");
	kStrScanningX = LoadString("STR_SCN_X");
	kStrUnavail = LoadString("STR_UNAVAIL");
	kVolMenuDefault = LoadString("STR_VM_DFLT");
	kVolPrompt = LoadString("STR_VPROMPT");
	kMenuGetInfo = LoadString("STR_M_INFO");
	kMenuOpen = LoadString("STR_M_OPEN");
	kMenuOpenWith = LoadString("STR_M_OPENW");
	kMenuNoApps = LoadString("STR_M_NAPPS");
	kInfoSize = LoadString("STR_SIZE");
	kInfoInFiles = LoadString("STR_INFILES");
	kInfoCreated = LoadString("STR_MADE");
	kInfoModified = LoadString("STR_MOD");
	kInfoTimeFmt = LoadString("STR_TIMEFMT");
	kInfoKind = LoadString("STR_KIND");
	kInfoPath = LoadString("STR_PATH");

	kWindowColor = ui_color(B_PANEL_BACKGROUND_COLOR);
	kOutlineColor = LoadColor("RGB_PIE_OL");
	kPieBGColor = LoadColor("RGB_PIE_BG");
	kEmptySpcColor = LoadColor("RGB_PIE_MT");

	kBasePieColorCount = LoadUint8("N_PIE_COLORS");
	kBasePieColor = new rgb_color[kBasePieColorCount];
	for (int i = 0; i < kBasePieColorCount; i++) {
		char colorName[16] = "RGB_PIE_n";
		colorName[8] = '1' + i;
		kBasePieColor[i] = LoadColor(colorName);
	}

	// Get a reference to the help file.
	BPath path;
	if (find_directory(B_BEOS_DOCUMENTATION_DIRECTORY, &path) == B_OK
		&& path.Append(kHelpFileName) == B_OK) {
		printf("help file =? %s\n", path.Path());
		BEntry entry(path.Path());
		kFoundHelpFile = entry.Exists();
		entry.GetRef(&kHelpFileRef);
	} else
		kFoundHelpFile = false;
		

	return r;
}