void MainMenu::setup(){
	ofAddListener(ofEvents().windowResized,this,&MainMenu::windowResized);

	ofImage cameraIcon;
	cameraIcon.loadImage("icons/camera.png");

	menu.setPosition(ofPoint(ofGetWidth()-cameraIcon.getWidth()-20,20));
	menu.setWidth(cameraIcon.getWidth());

	cameraButton = ofPtr<gui::Button>(new gui::Button);
	cameraButton->setIcon(cameraIcon);
	ofAddListener(cameraButton->pressedE,this,&MainMenu::cameraPressed);
	menu.addWidget(cameraButton);

	ofImage downloadIcon("icons/download.png");

	downloadButton = ofPtr<gui::Button>(new gui::Button);
	downloadButton->setIcon(downloadIcon);
	ofAddListener(downloadButton->pressedE,this,&MainMenu::downloadPressed);
	menu.addWidget(downloadButton);

	//grid.setPosition(ofPoint(20, 20));
	grid.setCellSize(cameraIcon.getWidth()*1.4, cameraIcon.getWidth()*1.4*3./4.);
	grid.setSpacing(20,20);
	grid.setRectangle(ofRectangle(20,20,cameraButton->getRect().x-5,ofGetHeight()));
	refresh();
}
Пример #2
0
//eigentliche laderoutine
Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) {
	Xfire_icon_cache entry = { 0 };

	//shortname
	char shortname[255] = "";

	if (!getIniValue(gameid, "ShortName", shortname))
		return entry;

	//spielid zuweisen
	entry.gameid = gameid;

	//Icons.dll noch nicht geladen?!?
	if (!hIconDll)
	{
		//versuch die Icons.dll zuladen
		char path[MAX_PATH] = "";
		if (!getIconPath(path))
			return entry;
		strcat_s(path, MAX_PATH, IconsdllName);

		hIconDll = LoadLibraryA(path);
	}

	//dll konnte geladen werden
	if (hIconDll) {
		char resourcename[255];
		//kurznamen des spiels uppercasen und .ICO anhängen
		mir_snprintf(resourcename, _countof(resourcename), "XF_%s.ICO", shortname);
		Xfire_base::strtoupper(resourcename);

		//versuche die resource zufinden
		HRSRC hrsrc = FindResourceA(hIconDll, resourcename, "ICONS");
		if (hrsrc) {
			//aus der resource ein HICON erstellen
			int size = SizeofResource(hIconDll, hrsrc);
			//iconresource laden
			HGLOBAL hglobal = LoadResource(hIconDll, hrsrc);
			if (hglobal) {
				//lock
				LPVOID data = LockResource(hglobal);
				if (data) {
					//erzeuge ein handle für das icon und ab in den cache damit
					entry.hicon = this->createHICONfromdata(data, size);
					UnlockResource(hglobal);
				}
				FreeResource(hglobal);
			}
		}
	}

	//kein icon in der dll, dann aus dem internet laden
	if (!entry.hicon)
		entry.hicon = downloadIcon(shortname);

	//wenn ein hicon erzeugt wurde, dann handle erstellen und in den cache laden
	if (entry.hicon)
		entry.handle = this->createIconHandle(entry.hicon);

	//eintrag in den cache, selbst wenn kein icon geladen werden konnte
	this->iconcache.push_back(entry);

	return entry;
}