コード例 #1
0
ファイル: WebInterface.cpp プロジェクト: dreamerc/amule
bool CamulewebApp::CheckDirForTemplate(wxString& dir, const wxString& tmpl)
{
	DebugShow(wxT("checking for directory '") + dir + wxT("'..."));
	if (wxFileName::DirExists(dir)) {
		DebugShow(wxT(" yes\n"));
		dir = JoinPaths(dir, tmpl);
		DebugShow(wxT("checking for directory '") + dir + wxT("'..."));
		if (wxFileName::DirExists(dir)) {
			DebugShow(wxT(" yes\n"));
			wxString tmplPath = JoinPaths(dir, wxT("login.php"));
			DebugShow(wxT("checking for file '") + tmplPath + wxT("'..."));
			if (wxFileName::FileExists(tmplPath)) {
				DebugShow(wxT(" yes\n"));
				// dir is already set to the directory component of the template path
				return true;
			} else {
				DebugShow(wxT(" no\n"));
			}
		} else {
			DebugShow(wxT(" no\n"));
		}
	} else {
		DebugShow(wxT(" no\n"));
	}

	return false;
}
コード例 #2
0
bool CMusic::LoadfromMusicTable(const std::string &gamepath, const std::string &levelfilename)
{
    bool fileloaded = false;
    std::ifstream Tablefile;

    std::string musicpath = getResourceFilename(JoinPaths("music", "table.cfg"), gamepath, false, true);

    if(musicpath != "")
    	fileloaded = OpenGameFileR(Tablefile, musicpath);

    if(fileloaded)
    {
    	std::string str_buf;

    	while(!Tablefile.eof())
    	{
    		getline(Tablefile, str_buf, ' ');
    		str_buf.erase(0, str_buf.find_first_not_of('\n'));
    		if( str_buf == levelfilename )	// found the level! Load the song!
    		{
    			// Get the song filename and load it!
    			getline(Tablefile, str_buf);
    			TrimSpaces(str_buf);
    			std::string filename = getResourceFilename(JoinPaths("music", str_buf), gamepath, false, true);
    			if( load(filename) )
    				play();
    			return true;
    		}
    		Tablefile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    	}
    }
	return false;
}
コード例 #3
0
ファイル: WebInterface.cpp プロジェクト: dreamerc/amule
wxString CamulewebApp::SetLocale(const wxString& language)
{
	wxString lang = CaMuleExternalConnector::SetLocale(language); // will call setlocale() for us

	// SetLocale() may indeed return an empty string, when no locale has been selected yet and
	// no locale change was requested, or, in the worst case, if the last locale change didn't succeed.
	if (!lang.IsEmpty()) {
		DebugShow(wxT("*** Language set to: ") + lang + wxT(" ***\n"));
#ifdef ENABLE_NLS
		wxString domain = wxT("amuleweb-") + m_TemplateName;
		Unicode2CharBuf domainBuf = unicode2char(domain);
		const char *c_domain = (const char *)domainBuf;

		// Try to find a message catalog
		// First look in ~/.aMule/webserver/<template>, but only if a local template was used
		wxString dir;
		if (m_localTemplate) {
			dir = JoinPaths(JoinPaths(JoinPaths(GetConfigDir(), wxT("webserver")), m_TemplateName), wxT("locale"));
			DebugShow(wxT("looking for message catalogs in ") + dir + wxT("... "));
		}
		if (!m_localTemplate || !DirHasMessageCatalog(dir, lang, domain)) {
			if (m_localTemplate) {
				DebugShow(wxT("no\n"));
			}
#if defined __WXMAC__  || defined __WXMSW__
			// on Mac, the bundle may be tried, too
			dir = wxStandardPaths::Get().GetDataDir();
#elif defined(__UNIX__)
			dir = JoinPaths(static_cast<wxStandardPaths&>(wxStandardPaths::Get()).GetInstallPrefix(), JoinPaths(wxT("share"), wxT("locale")));
#endif
			DebugShow(wxT("looking for message catalogs in ") + dir + wxT("... "));
			if (!DirHasMessageCatalog(dir, lang, domain)) {
				DebugShow(wxT("no\n"));
				dir = wxEmptyString;
			} else {
				DebugShow(wxT("yes\n"));
			}
		} else {
			DebugShow(wxT("yes\n"));
		}
		// If we found something, then use it otherwise it may still be present at the system default location
		if (!dir.IsEmpty()) {
			Unicode2CharBuf buffer = unicode2char(dir);
			const char *c_dir = (const char *)buffer;
			bindtextdomain(c_domain, c_dir);
		}
		// We need to have the returned messages in UTF-8
		bind_textdomain_codeset(c_domain, "UTF-8");
		// And finally select the message catalog
		textdomain(c_domain);
#endif /* ENABLE_NLS */
	}

	return lang;
}
コード例 #4
0
ファイル: amuleDlg.cpp プロジェクト: marcoll/amule
bool CamuleDlg::Check_and_Init_Skin()
{
	bool ret = true;
	wxString skinFileName(thePrefs::GetSkin());

	if (skinFileName.IsEmpty() || skinFileName.IsSameAs(_("- default -"))) {
		return false;
	}

	wxString userDir(JoinPaths(GetConfigDir(), wxT("skins")) + wxFileName::GetPathSeparator());

	wxStandardPathsBase &spb(wxStandardPaths::Get());
#ifdef __WINDOWS__ 
	wxString dataDir(spb.GetPluginsDir());
#elif defined(__WXMAC__)
		wxString dataDir(spb.GetDataDir());
#else
	wxString dataDir(spb.GetDataDir().BeforeLast(wxT('/')) + wxT("/amule"));
#endif
	wxString systemDir(JoinPaths(dataDir,wxT("skins")) + wxFileName::GetPathSeparator());


	skinFileName.Replace(wxT("User:"******"System:"), systemDir );

	m_skinFileName.Assign(skinFileName);
	if (!m_skinFileName.FileExists()) {
		AddLogLineC(CFormat(
			_("Skin directory '%s' does not exist")) %
			skinFileName );
		ret = false;
	} else if (!m_skinFileName.IsFileReadable()) {
		AddLogLineC(CFormat(
			_("WARNING: Unable to open skin file '%s' for read")) %
			skinFileName);
		ret = false;
	}

	wxFFileInputStream in(m_skinFileName.GetFullPath());
	wxZipInputStream zip(in);
	wxZipEntry *entry;

	while ((entry = zip.GetNextEntry()) != NULL) {
		wxZipEntry*& current = cat[entry->GetInternalName()];
		delete current;
		current = entry;
	}

	return ret;
}
コード例 #5
0
void CEGASprit::DerivePlayerSprites( const int id, std::vector<GsSprite> &sprites )
{
    for(Uint16 s=0 ; s<gGraphics.getSpriteVec(id).size() ; s++)
	{
        GsSprite &Sprite = gGraphics.getSprite(id,s);
		Sprite.optimizeSurface();
	}

	// Try to load player sprites here!
	std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(m_gamepath, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
    const std::string spriteFn = "sprite"+itoa(id)+"_";
    FilterFilelist(filelist, spriteFn);
	std::set<std::string>::iterator it = filelist.begin();
	for( ; it != filelist.end() ; it++ )
	{
        std::string name = *it;

        const int num = getRessourceID(name, spriteFn);
        GsSprite &Sprite = gGraphics.getSprite(id,num);
        std::string filename = getResourceFilename("gfx/"+name, m_gamepath, false, true);
        Sprite.loadHQSprite(filename);
        Sprite.applyTransparency();
    }
}
コード例 #6
0
byte *getActionBasePtr()
{
    auto &exeFile = gKeenFiles.exeFile;

    if(exeFile.isPythonScript())
    {
        if(actionFormatData.empty())
        {
            int episode = exeFile.getEpisode();

            const std::string fname = "keen" + itoa(episode) + ".act";

            const auto actFilePath = JoinPaths(gKeenFiles.gameDir,fname);
            const auto actFullFilePath = GetFullFileName(actFilePath);

            gLogging << "Loading Action file " << actFullFilePath;

            if(actFullFilePath == "")
            {
                gLogging << "Error Loading Action file " << actFullFilePath;
                return nullptr;
            }

            loadActionFile(actFullFilePath);
        }

        return actionFormatData.data();
    }
    else
    {
        return exeFile.getDSegPtr();
    }
}
コード例 #7
0
int CPreviews::openNextScene()
{
	// Here we set the function pointer for the cycle and load stuff for it...
	m_scene_number++;
	std::string filename = "preview";
	filename += itoa(m_scene_number);
	filename += ".ck";
	filename += itoa(m_episode);

	// If the we have scene to load, load it, else open the text which ends the preview
	if(openScene(filename))
	{
        this->ponder_ptr = &CPreviews::processPreviewScene;
        this->render_ptr = &CPreviews::drawPreviewScene;
	}
	else
	{
		std::string filename = JoinPaths(g_pBehaviorEngine->m_ExeFile.getDataDirectory(), "previews.ck");
		filename += itoa(g_pBehaviorEngine->getEpisode());

		mp_TextViewer.reset( new CTextViewer(0, 8, 320, 160) );

		if(!mp_TextViewer->loadTextfromFile(filename))
			m_destroy_me = true;

        this->render_ptr = &CPreviews::showText;
        this->ponder_ptr = &CPreviews::processShowText;
	}

	return 0;
}
コード例 #8
0
// This method is called by the menu. It assures that the
// PlayGame instance will call load() and get the right data.
bool CSaveGameController::prepareLoadGame(int SaveSlot)
{
    const std::string savefile = "cksave" + itoa(SaveSlot) + ".ck"+itoa(m_Episode);
    m_statefilename = JoinPaths(m_savedir, savefile);
    m_datablock.clear();

    g_pBehaviorEngine->EventList().add( new LoadGameEvent() );

    return true;
}
コード例 #9
0
/**
 * \brief	This function will look for certain files used in the game. It looks on the local dir
 * 			and is it didn't find the file, it will look on the global director GLOBAL_DIR. In case
 * 			it finds something there, it return that alternate path.
 *  \param	filename		the filename for which we are looking
 *  \param	gamepath		if a game started, path to that one
 *  \param	essential		essential means whether the file is really needed or the game can live without it.
 * 	\param	can_be_global	This means, that the file can be read from the global directory. In some cases it must not.
 */
std::string getResourceFilename(const std::string &filename, const std::string &gamepath,
                                bool essential, bool can_be_global)
{
    std::string text;
    std::string vfs_path;

    if(gamepath != "")
    {
        vfs_path = JoinPaths(gamepath, filename);
        text = "Looking for " + vfs_path + " ... ";
        // try to look at the local path of the game.
        if(!IsFileAvailable(vfs_path))
            vfs_path = "";
    }

    if(vfs_path == "" && can_be_global)
    {
        // if it didn't find the file try looking at the global resources
        vfs_path = JoinPaths(GLOBAL_DIR, filename);
        text = "Looking for " + vfs_path + " ... ";

        if(!IsFileAvailable(vfs_path))
            vfs_path = "";
    }

    if( vfs_path == "" )
    {
        if(essential)
        {
            text += "missing!\n";
            text += "The file " + filename + " was not found. Please provide that file!\n";
        }
        else
            text.clear();
    }
    else
        text += "found!\n";

    if(!text.empty())
        gLogging.textOut(GREEN, text);

    return vfs_path;
}
コード例 #10
0
ファイル: CImageButton.cpp プロジェクト: iamnilay3/openlierox
////////////////
// Apply the given selector
void CImageButton::ApplySelector(const CSSParser::Selector &sel, const std::string& prefix)
{
	CWidget::ApplySelector(sel, prefix);

	// Go through the attributes
	for (std::list<CSSParser::Attribute>::const_iterator it = sel.getAttributes().begin(); it != sel.getAttributes().end(); it++)  {
		if (it->getName() == "image")  {
			sPath = JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL());
			bmpImage = LoadGameImage(sPath, true);
		}
	}
}
コード例 #11
0
ファイル: CListview.cpp プロジェクト: iamnilay3/openlierox
//////////////////
// Apply the given selector to the column
void CListviewColumn::CColumnStyle::ApplySelector(const CSSParser::Selector& sel, const std::string& prefix)
{
	cBackground.ApplySelector(sel, prefix);
	cBorder.ApplySelector(sel, prefix);
	cFont.ApplySelector(sel, prefix);
	cText.ApplySelector(sel, prefix);

	// Go through the attributes
	FOR_EACH_ATTRIBUTE(sel, it)  {
		if (it->getName() == prefix + "arrow-image")
			bmpSortArrow.set(LoadGameImage(JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL()), true), it->getPriority());
	}
}
コード例 #12
0
ファイル: CScrollbar.cpp プロジェクト: iamnilay3/openlierox
///////////////////
// Apply the given tag
void CScrollbar::ApplyTag(xmlNodePtr node)
{
	CWidget::ApplyTag(node);

	iMin = MAX(0, xmlGetInt(node, "min"));
	iMax = MAX(iMin + 1, xmlGetInt(node, "max", iMin + 1));
	iValue = CLAMP(xmlGetInt(node, "value"), iMin, iMax);
	iItemsperbox = CLAMP(xmlGetInt(node, "itemsperbox"), 0, iMax);

	std::string base = xmlGetBaseURL(node);
	if (xmlPropExists(node, "topbtn"))
		bmpTop.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "topbtn"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "bottombtn"))
		bmpBottom.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "bottombtn"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "slidertop"))
		bmpSliderTop.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "slidertop"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "sliderbottom"))
		bmpSliderBottom.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "sliderbottom"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "slidermain"))
		bmpSliderMiddle.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "slidermain"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "color"))
		iColor.set(xmlGetColour(node, "color", iColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "highcolor"))
		iHighlightColor.set(xmlGetColour(node, "highcolor", iHighlightColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "shadowcolor"))
		iShadowColor.set(xmlGetColour(node, "shadowcolor", iShadowColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "bgcolor"))
		iBackgroundColor.set(xmlGetColour(node, "bgcolor", iBackgroundColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "arrowcolor"))
		iArrowColor.set(xmlGetColour(node, "arrowcolor", iArrowColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "dir"))  {
		std::string dir = xmlGetString(node, "dir", "vertical");
		if (stringcaseequal(dir, "vertical"))
			iDirection.set(scrVertical, TAG_ATTR_PRIORITY);
		else if (stringcaseequal(dir, "horizontal"))
			iDirection.set(scrHorizontal, TAG_ATTR_PRIORITY);
	}
}
コード例 #13
0
ファイル: CBorder.cpp プロジェクト: iamnilay3/openlierox
///////////////////
// Apply a selector to one border side
void CBorder::ApplySelectorToBorder(const CSSParser::Selector &sel, const std::string &prefix, const std::string &side, CBorder::BorderLineSettings &sett)
{
	bool fail = false;
	std::string att = prefix + "border-" + side;
	FOR_EACH_ATTRIBUTE(sel, it)  {
		if (it->getName() == att + "color" || it->getName() == att + "light" || it->getName() == "colour")  {
			sett.clLight.set(it->getFirstValue().getColor(sett.clLight), it->getPriority());
			sett.clDark.set(sett.clLight, it->getPriority());
		} else if (it->getName() == att + "dark")  {
			sett.clDark.set(it->getFirstValue().getColor(sett.clDark), it->getPriority());
		} else if (it->getName() == att + "size")  {
			sett.iThickness.set(it->getFirstValue().getInteger(0), it->getPriority());
		} else if (it->getName() == att + "style")  {
			sett.iStyle.set(StringToBorderStyle(it->getFirstValue().getString(), fail), it->getPriority());
		} else if (it->getName() == att + "image")  {
			sett.bmpLine.set(LoadGameImage(JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL())), it->getPriority());
		} else if (it->getName() == prefix + "border")  {
			bool thickness_set = false;
			for (std::vector<CSSParser::Attribute::Value>::const_iterator val = it->getParsedValue().begin(); val != it->getParsedValue().end(); val++)  {
				// Style
				BorderStyle style = StringToBorderStyle(val->getString(), fail);
				if (!fail)  {
					sett.iStyle.set(style, it->getPriority());
					if (!thickness_set)
						sett.iThickness.set(MAX(1, (int)sett.iThickness), it->getPriority()); // for example "border: solid black" means "1px solid black"
					continue;
				}

				// Thickness
				int thick = from_string<int>(val->getString(), fail);
				if (!fail && thick >= 0)  {
					thickness_set = true;
					sett.iThickness.set(thick, it->getPriority());
				}

				// Color
				Color c = StrToCol(val->getString(), fail);
				if (!fail)  {
					sett.clDark.set(c, it->getPriority());
					sett.clLight.set(c, it->getPriority());
				}
			}
		}
	}
}
コード例 #14
0
ファイル: searchFunctionsFree.cpp プロジェクト: ana-GT/LJM2
/**
 * @function FindVarietyPaths2
 * @brief Using Free Space
 */
std::vector< std::vector<Eigen::Vector3i> > LJM2::FindVarietyPaths2( int _x1, int _y1, int _z1,
									   			   	  		        int _x2, int _y2, int _z2, 
																    int _times, float _alpha ) {

	mAlpha = _alpha;
	std::vector< std::vector<Eigen::Vector3i> > paths;
    std::vector<Eigen::Vector3i> path;
	std::vector< std::vector<int> > nodePaths;
	std::vector<int> allNodePaths;

	time_t ts; time_t tf; double dt; 
	//-- Find the nearest points
	int startIndex = ref( _x1, _y1, _z1 );
	int targetIndex = ref( _x2, _y2, _z2 );

	printf("--> Start: %d Target: %d \n", startIndex, targetIndex );	

	InitSearch();

	for( size_t i = 0; i < _times; ++i ) {

		path.resize(0);
        //ts = clock();
		path = FindPath( startIndex, targetIndex );
        //tf = clock();
        printf("--[%d] Found Path of size %d \n", i, path.size() ); 
        //printf(" Time elapsed: %.3f  \n", (double) (tf - ts)/CLOCKS_PER_SEC );
		paths.push_back( path );
		nodePaths.push_back( mPath );

		//-- Update the values
        //ts = clock();
		ResetSearch();
        //tf = clock();
        //printf("--[%d] Search : Time elapsed: %.3f  \n", i, (double) (tf - ts)/CLOCKS_PER_SEC );
		allNodePaths = JoinPaths( nodePaths );
        ts = clock();
		UpdateNodeValues( allNodePaths ); 
        //tf = clock();
        //printf("--[%d] UpdateNodes : Time elapsed: %.3f  \n", i, (double) (tf - ts)/CLOCKS_PER_SEC );
	}

	return paths;
}
コード例 #15
0
bool COGGPlayer::loadMusicForLevel(const CExeFile& ExeFile, const int level)
{
	// Now get the proper music slot reading the assignment table.
	Uint16 music_order = 0;
	const int Idx = ExeFile.getEpisode()-4;
	memcpy( &music_order, ExeFile.getRawData()+GalaxySongAssignments[Idx]+level*sizeof(Uint16), sizeof(Uint16));
	
	if(music_order > 20)
	{
	  g_pLogFile->textOut("Sorry, this track is invalid! Please report the developers.");
	  return false;
	}
	
	m_filename = "slot" + itoa(music_order) + ".ogg";
	m_filename = getResourceFilename(JoinPaths("music", m_filename), ExeFile.getDataDirectory(), false, false);

	if(m_filename.empty())	
	   return false;
	    
    return open();
}
コード例 #16
0
	// appends word to end of path if it doesnt exist at the end of path
	// path = "my/path" or "my/path and word = "view" -> path == "my/path/view
	CString AppendWordIfNotAtEndOfPath(const CString& _path, const CString& word,
		std::vector<CString> delimiters)
	{
		// delimiters could be passed in with initializer list
		if (delimiters.size() == 0) {
			delimiters.push_back(_T("\\"));
			delimiters.push_back(_T("/"));
		}

		// word is stripped of any special path characters, since its a word in a path
		CString word_without_specials = RemoveCharsIfEqualsAny(word, delimiters);

		// if the word without special path chars is at the end of the path, then
		// nothing needs to be done here, return the original path
		if (IsAtEndOfPath(_path, word_without_specials, delimiters)) {
			return _path;
		}

		// otherwise join the path with the word and return it
		CString path = _path;
		path = path.Trim();
		path = JoinPaths(path, word_without_specials, delimiters);
		return path;
	}
コード例 #17
0
ファイル: CScrollbar.cpp プロジェクト: iamnilay3/openlierox
///////////////////////
// Apply a selector to the scrollbar
void CScrollbar::ApplySelector(const CSSParser::Selector &sel, const std::string &prefix)
{
	CWidget::ApplySelector(sel, prefix);

	const std::string& base = sel.getBaseURL();
	FOR_EACH_ATTRIBUTE(sel, it)  {
		if (it->getName() == prefix + "top-button")  {
			bmpTop.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL()), true), it->getPriority());
		} else if (it->getName() == prefix + "bottom-button")  {
			bmpBottom.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL()), true), it->getPriority());
		} else if (it->getName() == prefix + "background-image")  {
			bmpBackground.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority());
		} else if (it->getName() == prefix + "slider-top-image")  {
			bmpSliderTop.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority());
		} else if (it->getName() == prefix + "slider-bottom-image")  {
			bmpSliderBottom.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority());
		} else if (it->getName() == prefix + "slider-main-image")  {
			bmpSliderMiddle.set(LoadGameImage(JoinPaths(base, it->getFirstValue().getURL())), it->getPriority());
		} else if (it->getName() == prefix + "face-color" || it->getName() == prefix + "face-colour")  {
			iColor.set(it->getFirstValue().getColor(iColor), it->getPriority());
		} else if (it->getName() == prefix + "background-color" || it->getName() == prefix + "background-colour")  {
			iBackgroundColor.set(it->getFirstValue().getColor(iBackgroundColor), it->getPriority());
		} else if (it->getName() == prefix + "highlight-color" || it->getName() == prefix + "highlight-colour")  {
			iHighlightColor.set(it->getFirstValue().getColor(iHighlightColor), it->getPriority());
		} else if (it->getName() == prefix + "shadow-color" || it->getName() == prefix + "shadow-colour")  {
			iShadowColor.set(it->getFirstValue().getColor(iShadowColor), it->getPriority());
		} else if (it->getName() == prefix + "arrow-color" || it->getName() == prefix + "arrow-colour")  {
			iArrowColor.set(it->getFirstValue().getColor(iArrowColor), it->getPriority());
		} else if (it->getName() == prefix + "direction")  {
			if (it->getFirstValue().getString() == "vertical")
				iDirection.set(scrVertical, it->getPriority());
			else if (it->getFirstValue().getString() == "horizontal")
				iDirection.set(scrHorizontal, it->getPriority());
			else
				iDirection.set(scrVertical, DEFAULT_PRIORITY); // Defaults to vertical
		}
	}
}
コード例 #18
0
bool CEGALatch::loadData( const std::string &path,
                          const short episode,
                          const int version,
                          const unsigned char *data,
                          const bool compresseddata )
{
	std::string filename;
	byte *RawData;
    Uint16 width, height;
    SDL_Surface *sfc;


	filename = getResourceFilename("egalatch.ck" + itoa(episode), path);

	FILE* latchfile = OpenGameFile(filename,"rb");

	if(!latchfile)
		return false;

	RawData = new byte[m_latchplanesize * 4];
    // get the data out of the file into the memory, decompressing it if necessary.
    if (compresseddata)
    {
		if (lz_decompress(latchfile, (unsigned char*) RawData))
		{
			return 1;
		}
    }
    else
    {
    	for(int i=0 ; i<(m_latchplanesize*4) ; i++)
    		RawData[i] = fgetc(latchfile);
    }

    fclose(latchfile);

	// these are the offsets of the different video planes as
	// relative to each other--that is if a pixel in plane1
	// is at N, the byte for that same pixel in plane3 will be
	// at (N + plane3).
	unsigned long plane1, plane2, plane3, plane4;

	plane1 = 0;
	plane2 = (m_latchplanesize * 1);
	plane3 = (m_latchplanesize * 2);
	plane4 = (m_latchplanesize * 3);

	// ** read the 8x8 tiles **
	// set up the getbit() function of CPlanes class
	CPlanes Planes(RawData);
	Planes.setOffsets(plane1 + m_fontlocation, plane2 + m_fontlocation,
					  plane3 + m_fontlocation, plane4 + m_fontlocation, 0);
	// Load these graphics into the GsFont Class of GsGraphics
	// The original vorticon engine only uses one fontmap, but we use another for
	// extra icons. For example sliders are in that map

	gGraphics.freeFonts();
	gGraphics.createEmptyFontmaps(3);

	gGraphics.getFont(0).loadinternalFont();

	GsFont &Font = gGraphics.getFont(1);
	Font.CreateSurface( gGraphics.Palette.m_Palette, SDL_SWSURFACE );
	sfc = Font.getSDLSurface();

	gGraphics.getFont(2).loadAlternateFont();


	if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);

	Uint8 *pixel = (Uint8*) sfc->pixels;
	SDL_FillRect(sfc, NULL, 0);

	for(int p=0;p<4;p++)
		Planes.readPlaneofTiles(p, pixel, 16, 8, m_fonttiles);

	if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);

	// prepare to ** read the 16x16 tiles **
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);

	gGraphics.freeTilemap();
	gGraphics.createEmptyTilemaps(2);
	
	loadTilemap(gGraphics.getTileMap(0), Planes, episode, path);
	
	// prepare to ** read the 16x16 tiles **, this is for the second plane.
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);	
	
	loadTilemap(gGraphics.getTileMap(1), Planes, episode, path);

    gGraphics.getTileMap(0).optimizeSurface();
    gGraphics.getTileMap(1).optimizeSurface();

	// make masked tiles according to it's surfaces
	applyMasks();

	////////////////////
	/// Load Bitmaps ///
	////////////////////

	Planes.setOffsets(plane1 + m_bitmaplocation,
					plane2 + m_bitmaplocation,
					plane3 + m_bitmaplocation,
					plane4 + m_bitmaplocation,
					0);

	// decode bitmaps into the BitmapData structure. The bitmaps are
	// loaded into one continuous stream of image data, with the bitmaps[]
	// array giving pointers to where each bitmap starts within the stream.

	for(int p=0 ; p<4 ; p++)
	{
		for(int b=0 ; b<m_bitmaps ; b++)
		{
            GsBitmap &bitmap = gGraphics.getBitmapFromId(b);
			// this points to the location that we're currently
			// decoding bitmap data to

			sfc= bitmap.getSDLSurface();
			if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
			Uint8* pixel = (Uint8*) sfc->pixels;
			if(p==0)
				SDL_FillRect(sfc, NULL, 0);
			width = bitmap.getWidth(); height = bitmap.getHeight();
			// Now read the raw data

			Planes.readPlane(p, pixel, width, height);

			if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);
		}
	}

	std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(path, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "bitmap");

	std::set<std::string>::iterator it = filelist.begin();

	for( ; it != filelist.end() ; it++ )
	{
		std::string filename=*it;
		int num = getRessourceID(filename, "bitmap");
        GsBitmap &bitmap = gGraphics.getBitmapFromId(num);
		filename = getResourceFilename("gfx/" + filename, path, false);
		bitmap.loadHQBitmap(filename);
	}

	if(RawData){ delete[] RawData; RawData = NULL;}

    // Create an intro in case it does not exist yet
    std::string fullpath = getResourceFilename("preview.bmp", path, false);
    if( fullpath == "" )
    {   // Not found create it
        fullpath = path + "/preview.bmp";
        fullpath = GetWriteFullFileName(fullpath, true);
        GsBitmap *pBitmap = gGraphics.getBitmapFromStr("TITLE");
        SDL_SaveBMP( pBitmap->getSDLSurface(), fullpath.c_str());
    }

	return true;
}
コード例 #19
0
bool CEGASprit::loadData(const std::string& filename, bool compresseddata)
{
	byte *RawData;
    SDL_Surface *sfc;
    Uint8* pixel;
    Uint32 percent = 0;
	
	FILE* latchfile = OpenGameFile(filename.c_str(),"rb");
	
	if(!latchfile)
		return false;
	
	gResourceLoader.setPermilage(10);

	RawData = new byte[m_planesize * 5];
    // get the data out of the file into the memory, decompressing it if necessary.
    if (compresseddata)
    {
		if (lz_decompress(latchfile, RawData))
			return 1;
    }
    else
    {
    	for(int i=0 ; i<(m_planesize*5) ; i++)
    		RawData[i] = fgetc(latchfile);
    }
	
    fclose(latchfile);

	gResourceLoader.setPermilage(50);
	
    // TODO: Try to blit the Font map here!
	// these are the offsets of the different video planes as
	// relative to each other--that is if a pixel in plane1
	// is at N, the byte for that same pixel in plane3 will be
	// at (N + plane3).
	unsigned long plane1, plane2, plane3, plane4, plane5;
	
	plane1 = 0;
	plane2 = (m_planesize * 1);
	plane3 = (m_planesize * 2);
	plane4 = (m_planesize * 3);
	plane5 = (m_planesize * 4);
	
	CPlanes Planes(RawData + m_spriteloc);
	Planes.setOffsets(plane1, plane2, plane3, plane4, plane5);
	
	// load the image data
    gGraphics.createEmptySprites(4,MAX_SPRITES+1);
	for(int i=0 ; i<m_numsprites ; i++)
	{
        GsSprite &Sprite = gGraphics.getSprite(0,i);
		Sprite.setSize( EGASpriteModell[i].width, EGASpriteModell[i].height );
		Sprite.setBoundingBoxCoordinates( (EGASpriteModell[i].hitbox_l << STC),
				(EGASpriteModell[i].hitbox_u << STC),
				(EGASpriteModell[i].hitbox_r << STC),
				(EGASpriteModell[i].hitbox_b << STC) );
		Sprite.createSurface( gVideoDriver.mpVideoEngine->getBlitSurface()->flags,
				gGraphics.Palette.m_Palette );

		percent = (i*50)/m_numsprites;
		gResourceLoader.setPermilage(50+percent);
	}

	gResourceLoader.setPermilage(100);

	for(int p=0 ; p<4 ; p++)
	{
		for(int s=0 ; s<m_numsprites ; s++)
		{
            sfc = gGraphics.getSprite(0,s).getSDLSurface();
			if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
			pixel = (Uint8*) sfc->pixels;

			Planes.readPlane(p, pixel, sfc->w, sfc->h);

			if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);

			percent = (s*100)/m_numsprites;
			gResourceLoader.setPermilage(100+percent);
		}
	}

	gResourceLoader.setPermilage(200);

	// now load the 5th plane, which contains the sprite masks.
	// note that we invert the mask because our graphics functions
	// use white on black masks whereas keen uses black on white.
	for(int s=0 ; s<m_numsprites ; s++)
	{
        GsSprite &Sprite = gGraphics.getSprite(0,s);
		SDL_Surface *pixsfc = Sprite.getSDLSurface();
		SDL_Surface *masksfc = Sprite.getSDLMaskSurface();

		if(SDL_MUSTLOCK(pixsfc)) SDL_LockSurface(pixsfc);
		if(SDL_MUSTLOCK(masksfc)) SDL_LockSurface(masksfc);

		pixel = (Uint8*) masksfc->pixels;

		for(int y=0 ; y<masksfc->h ; y++)
		{
			for(int x=0 ; x<masksfc->w ; x++)
			{
				if(Planes.getbit(4))
                    pixel[y*masksfc->w + x] = ((Uint8*)pixsfc->pixels)[y*pixsfc->w + x];
				else
					pixel[y*masksfc->w + x] = 15;
			}
		}
		if(SDL_MUSTLOCK(masksfc)) SDL_UnlockSurface(masksfc);
		if(SDL_MUSTLOCK(pixsfc)) SDL_UnlockSurface(pixsfc);

		percent = (s*100)/m_numsprites;
		gResourceLoader.setPermilage(200+percent);
	}

	gResourceLoader.setPermilage(300);
	
	if(RawData){ delete[] RawData; RawData = NULL;}
	
    LoadSpecialSprites( gGraphics.getSpriteVec(0) );


    for(unsigned int i=1 ; i<4 ; i++)
    {
        gGraphics.getSpriteVec(i) = gGraphics.getSpriteVec(0);
    }


    // For the other variant let's exchange some colors
    auto &SpriteVecPlayer2 = gGraphics.getSpriteVec(1);
    for( unsigned int i = 0 ; i < SpriteVecPlayer2.size() ; i++)
    {
        auto &sprite = SpriteVecPlayer2[i];
        // Red against Purple
        sprite.exchangeSpriteColor( 5, 4, 0 );
        sprite.exchangeSpriteColor( 13, 12, 0 );

        // Yellow against Green
        sprite.exchangeSpriteColor( 2, 6, 0 );
        sprite.exchangeSpriteColor( 10, 14, 0 );
    }


    auto &SpriteVecPlayer3 = gGraphics.getSpriteVec(2);
    for( auto &sprite : SpriteVecPlayer3)
    {
        // Red against Green
        sprite.exchangeSpriteColor( 2, 4, 0 );
        sprite.exchangeSpriteColor( 10, 12, 0 );

        // Yellow against Purple
        sprite.exchangeSpriteColor( 5, 6, 0 );
        sprite.exchangeSpriteColor( 13, 14, 0 );
    }

    auto &SpriteVecPlayer4 = gGraphics.getSpriteVec(3);
    for( auto &sprite : SpriteVecPlayer4)
    {
        // Red against Yellow
        sprite.exchangeSpriteColor( 6, 4, 0 );
        sprite.exchangeSpriteColor( 14, 12, 0 );

        // Green against Purple
        sprite.exchangeSpriteColor( 2, 5, 0 );
        sprite.exchangeSpriteColor( 10, 13, 0 );
    }


    for(unsigned int i=0 ; i<4 ; i++)
    {
        for(Uint16 s=0 ; s<gGraphics.getSpriteVec(i).size() ; s++)
        {
            GsSprite &Sprite = gGraphics.getSprite(i,s);
            Sprite.optimizeSurface();

            percent = (s*50)/m_numsprites;
            gResourceLoader.setPermilage(300+percent);
        }
    }


    gResourceLoader.setPermilage(350);

    std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(m_gamepath, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "sprite");


	std::set<std::string>::iterator it = filelist.begin();
	int listsize = filelist.size();
    for( int c=0 ; it != filelist.end() ; it++, c++ )
	{
		std::string name=*it;

        if(name.find("_") != name.npos)
            continue;

		int num = getRessourceID(name, "sprite");
		if(num < m_numsprites )
		{
            GsSprite &Sprite = gGraphics.getSprite(0, num);
			std::string filename = getResourceFilename("gfx/"+name, m_gamepath, false, true);
			Sprite.loadHQSprite(filename);
		}

		percent = (c*150)/listsize;
		gResourceLoader.setPermilage(350+percent);
    }



	gResourceLoader.setPermilage(500);

    for(unsigned int i=0 ; i<4 ; i++)
    {
        const int NoSprites = gGraphics.getSpriteVec(i).size();
        for(Uint16 s=0 ; s<NoSprites ; s++)
        {
            gGraphics.getSprite(i,s).applyTransparency();

            percent = (s*250)/NoSprites;
            gResourceLoader.setPermilage(500+percent);
        }
    }

    gResourceLoader.setPermilage(750);

	// Now create special sprites, like those for effects and the doors!
    DeriveSpecialSprites( gGraphics.getTileMap(1), gGraphics.getSpriteVec(0) );
    gResourceLoader.setPermilage(800);

	// Here special Effects are applied, only when the option is enabled for it
	if(gVideoDriver.getSpecialFXConfig())
		ApplySpecialFX();

    gResourceLoader.setPermilage(900);

    // Apply the sprites for player 2,3 and 4
    DerivePlayerSprites( 1,gGraphics.getSpriteVec(1) );
    DerivePlayerSprites( 2,gGraphics.getSpriteVec(2) );
    DerivePlayerSprites( 3,gGraphics.getSpriteVec(3) );
    gResourceLoader.setPermilage(1000);


	return true;
}
コード例 #20
0
ファイル: WebInterface.cpp プロジェクト: dreamerc/amule
static inline bool CheckDirForMessageCatalog(const wxString& dir, const wxString& lang, const wxString& domain)
{
	return wxFileName::FileExists(JoinPaths(dir, JoinPaths(lang, JoinPaths(wxT("LC_MESSAGES"), domain + wxT(".mo")))));
}
コード例 #21
0
ファイル: CEGASprit.cpp プロジェクト: albertz/commandergenius
void CEGASprit::DerivePlayerSprites( std::vector<CSprite> &sprites )
{
	// create the sprites for player 2, 3 and 4
	for(size_t i=0;i<48;i++)
	{
		size_t s = SECOND_PLAYER_BASEFRAME+i;
		sprites.at(i).copy( sprites.at(s), g_pGfxEngine->Palette.m_Palette );
		sprites.at(s).replaceSpriteColor( 13, 11 ,0 );
		sprites.at(s).replaceSpriteColor( 5, 3 ,0 );
		sprites.at(s).replaceSpriteColor( 12, 9 ,0 );
		sprites.at(s).replaceSpriteColor( 4, 1 ,0 );
		sprites.at(s).optimizeSurface();
	}
	for(size_t i=0;i<48;i++)
	{
		size_t s = THIRD_PLAYER_BASEFRAME+i;

		sprites.at(i).copy( sprites.at(s), g_pGfxEngine->Palette.m_Palette );
		sprites.at(s).replaceSpriteColor( 13, 10, 0 ); // Shirt light
		sprites.at(s).replaceSpriteColor( 5, 2, 0 ); // Shirt dark
		sprites.at(s).replaceSpriteColor( 12, 2, 16 ); // Shoes light
		sprites.at(s).replaceSpriteColor( 4, 0, 16 ); // Shoes dark
		sprites.at(s).optimizeSurface();

	}
	for(size_t i=0;i<48;i++)
	{
		size_t s = FOURTH_PLAYER_BASEFRAME+i;
		sprites.at(i).copy( sprites.at(s), g_pGfxEngine->Palette.m_Palette );
		sprites.at(s).replaceSpriteColor( 13, 14, 0 ); // Shirt light
		sprites.at(s).replaceSpriteColor( 5, 6, 0 ); // Shirt dark
		sprites.at(s).replaceSpriteColor( 12, 6, 16 ); // Shoes light
		sprites.at(s).replaceSpriteColor( 4, 0, 16 ); // Shoes dark
		sprites.at(s).optimizeSurface();
	}

	for(Uint16 s=0 ; s<g_pGfxEngine->getSpriteVec().size() ; s++)
	{
		CSprite &Sprite = g_pGfxEngine->getSprite(s);
		Sprite.optimizeSurface();
	}

	// Try to load player sprites here!
	std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(m_gamepath, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "sprite");
	std::set<std::string>::iterator it = filelist.begin();
	for( ; it != filelist.end() ; it++ )
	{
		std::string name=*it;
		int num = getRessourceID(name, "sprite");
		if( num>=SECOND_PLAYER_BASEFRAME && num<FOURTH_PLAYER_BASEFRAME+48 )
		{
			CSprite &Sprite = g_pGfxEngine->getSprite(num);
			std::string filename = getResourceFilename("gfx/"+name, m_gamepath, false, true);
			Sprite.loadHQSprite(filename);
			Sprite.applyTransparency();
		}
	}
}
コード例 #22
0
ファイル: cbworkspace.cpp プロジェクト: joobog/ppsim
void CCodeBlocksWorkspace::GenerateMakefileText(const CString& FileName,
 CCodeBlocksBuildConfig& Config)
{
 // generate individual makefiles for projects
 //std::cout<<"Workspace: "<<FileName.GetCString()<<std::endl;
 CString cwd = GetCurrentDir();
 CString workspace_path = ExtractFilePath(FileName);
 if (!workspace_path.IsEmpty())
 {
  ChangeDir(workspace_path);
 }
 //std::cout<<"Workspace path: "<<workspace_path.GetCString()<<std::endl;
 m_TargetNames.Clear(); m_MakefileNames.Clear();
 for (size_t i = 0; i < m_Units.size(); i++)
 {
  CString project_name = m_Units[i]->m_FileName;
  CString makefile_path = JoinPaths(workspace_path,ExtractFilePath(project_name));
  CString makefile_pathname = JoinPaths(workspace_path,project_name+".mak");
  CString target_name = LowerCase(ChangeFileExt(project_name,""));
  CString makefile_name = ExtractFileName(makefile_pathname);
  //std::cout<<"Project name: "<<project_name.GetCString()<<std::endl;
  //std::cout<<"Makefile path: "<<makefile_path.GetCString()<<std::endl;
  //std::cout<<"Makefile pathname: "<<makefile_pathname.GetCString()<<std::endl;
  target_name = CCodeBlocksProject::DecorateTargetName(target_name);
  //std::cout<<"Target name: "<<target_name.GetCString()<<std::endl;
  //std::cout<<"Makefile name: "<<makefile_name.GetCString()<<std::endl;
  m_TargetNames.Insert(target_name);
  m_MakefilePaths.Insert(makefile_path);
  m_MakefileNames.Insert(makefile_name);
  makefile_pathname = MakeNativePath(makefile_pathname);
  //std::cout<<"Native makefile pathname: "<<makefile_pathname.GetCString()<<std::endl;
  m_Units[i]->m_Project.GenerateMakefile(makefile_pathname,Config);
 }
 //CString cwd = GetCurrentDir();
 // generate workspace makefile
 int active_platforms = 0;
 for (size_t pi = 0, pn = Config.Platforms().GetCount(); pi < pn; pi++)
 {
  if (Config.Platforms().Platform(pi)->Active()) active_platforms++;
 }
 bool single_platform = (1==active_platforms);
 for (size_t pi = 0, pn = Config.Platforms().GetCount(); pi < pn; pi++)
 {
  CPlatform *pl = Config.Platforms().Platform(pi);
  if (!pl->Active()) continue;
  CString makefile_path = ExtractFilePath(FileName);
  CString makefile_name = ExtractFileName(FileName);
  CString platform_suffix;
  if (!single_platform) platform_suffix = "."+LowerCase(pl->Name());
  makefile_name += platform_suffix;
  //ChangeDir(makefile_path);
  //
  m_MakefileText.Clear();
  // head comment
  m_MakefileText.Insert("#------------------------------------------------------------------------------#");
#ifdef REVISION_NUMBER
  {
   CString s = "# This makefile was generated by 'cbp2make' tool rev.                          #";
   CString n = IntegerToString(REVISION_NUMBER);
   int o = FindStr(s,"rev.") + 4;
   for (int i = 0; i < n.GetLength(); i++) s.SetChar(i+o,n[i]);
   m_MakefileText.Insert(s);
  }
#else
  m_MakefileText.Insert("# This makefile was generated by 'cbp2make' tool                               #");
#endif
  m_MakefileText.Insert("#------------------------------------------------------------------------------#");
  m_MakefileText.Insert("");
  // macros
  CString line = "WRKDIR = "+pl->EvalWorkDir();
  m_MakefileText.Insert(line);
  line = "MAKE = "+pl->Tool_Make();
  m_MakefileText.Insert(line);
  m_MakefileText.Insert("");
  // targets
  line = "all:";
  for (int i = 0; i < m_TargetNames.GetCount(); i++)
  {
   line.Append(" ").Append(m_TargetNames[i]);
  }
  m_MakefileText.Insert(line); m_MakefileText.Insert("");
  for (int i = 0; i < m_TargetNames.GetCount(); i++)
  {
   CString makefile_path = m_MakefilePaths[i];
   line = m_TargetNames[i]+":";
   m_MakefileText.Insert(line);
   line = "\t$(MAKE)";
   if (!makefile_path.IsEmpty())
   {
    line += " -C "+pl->ProtectPath(pl->Pd(makefile_path),Config.QuotePathMode());
   }
   line += " all -f "+pl->ProtectPath(pl->Pd(m_MakefileNames[i])+platform_suffix,Config.QuotePathMode());
   m_MakefileText.Insert(line);
   m_MakefileText.Insert("");
  }
  //
  line = "clean:";
  for (int i = 0; i < m_TargetNames.GetCount(); i++)
  {
   line.Append(" clean_").Append(m_TargetNames[i]);
  }
  m_MakefileText.Insert(line); m_MakefileText.Insert("");
  for (int i = 0; i < m_TargetNames.GetCount(); i++)
  {
   CString makefile_path = m_MakefilePaths[i];
   line = "clean_"+m_TargetNames[i]+":";
   m_MakefileText.Insert(line);
   line = "\t$(MAKE)";
   if (!makefile_path.IsEmpty())
   {
    line += " -C "+pl->ProtectPath(pl->Pd(makefile_path),Config.QuotePathMode());
   }
   line += " clean -f "+pl->ProtectPath(pl->Pd(m_MakefileNames[i])+platform_suffix,Config.QuotePathMode());
   m_MakefileText.Insert(line);
   m_MakefileText.Insert("");
  }
  //
  line = ".PHONY:";
  for (int i = 0; i < m_TargetNames.GetCount(); i++)
  {
   line.Append(" ").Append(m_TargetNames[i]);
   line.Append(" clean_").Append(m_TargetNames[i]);
  }
  m_MakefileText.Insert(line); m_MakefileText.Insert("");
  m_MakefileText.SaveToFile(makefile_name);
  m_MakefileText.Clear();
  ChangeDir(cwd);
 }
}
コード例 #23
0
ファイル: WebInterface.cpp プロジェクト: dreamerc/amule
bool CamulewebApp::GetTemplateDir(const wxString& templateName, wxString& templateDir)
{
	wxString dir;
	m_localTemplate = false;

	DebugShow(wxT("looking for template: ") + templateName + wxT("\n"));

#ifdef __WXMAC__
	CFURLRef amuleBundleUrl;
	OSStatus status = LSFindApplicationForInfo(
		kLSUnknownCreator,
		// This magic string is the bundle identifier in aMule.app's Info.plist
		CFSTR("org.amule.aMule"),
		NULL, NULL, &amuleBundleUrl);
	if (status == noErr && amuleBundleUrl) {
		CFBundleRef amuleBundle = CFBundleCreate(NULL, amuleBundleUrl);
		CFRelease(amuleBundleUrl);
		if (amuleBundle) {
			CFURLRef webserverDirUrl = CFBundleCopyResourceURL(
				amuleBundle,
				CFSTR("webserver"),
				NULL, NULL);
			CFRelease(amuleBundle);
			if (webserverDirUrl) {
				CFURLRef absoluteURL =
					CFURLCopyAbsoluteURL(webserverDirUrl);
				CFRelease(webserverDirUrl);
				if (absoluteURL) {
					CFStringRef pathString =
						CFURLCopyFileSystemPath(
							absoluteURL,
							kCFURLPOSIXPathStyle);
					CFRelease(absoluteURL);
					#if wxCHECK_VERSION(2, 9, 0)
						dir = wxCFStringRef(pathString).
						AsString(wxLocale::GetSystemEncoding());
					#else
						dir = wxMacCFStringHolder(pathString).
						AsString(wxLocale::GetSystemEncoding());
					#endif
					if (CheckDirForTemplate(dir, templateName)) {
						templateDir = dir;
						return true;
					}
				}
			}
		}
	}
#endif

	dir = GetConfigDir(wxT("remote.conf")) + wxT("webserver");
	if (CheckDirForTemplate(dir, templateName)) {
		templateDir = dir;
		m_localTemplate = true;
		return true;
	}
#ifdef WEBSERVERDIR
	dir = wxT(WEBSERVERDIR);
	if (CheckDirForTemplate(dir, templateName)) {
		templateDir = dir;
		return true;
	}
#endif
	
	dir = wxStandardPaths::Get().GetResourcesDir();	// Returns 'aMule' when we use 'amule' elsewhere
#if !defined(__WXMSW__) && !defined(__WXMAC__)
	dir = dir.BeforeLast(wxFileName::GetPathSeparator());
	dir = JoinPaths(dir, wxT("amule"));
#endif
	dir = JoinPaths(dir, wxT("webserver"));
	if (CheckDirForTemplate(dir, templateName)) {
		templateDir = dir;
		return true;
	}
	
	// template not found. reverting to default
	const wxChar* const defaultTemplateName = wxT("default");

	if ( templateName == defaultTemplateName ) {
		return false;
	}
	Show(wxT("Template ") + templateName + wxT(" not found, reverting to default\n\n"));
	return GetTemplateDir(defaultTemplateName, templateDir);
}
コード例 #24
0
ファイル: cbworkspace.cpp プロジェクト: joobog/ppsim
bool CWorkspaceUnit::LoadProject(const CString& WorkspacePath)
{
 return m_Project.LoadProject(JoinPaths(WorkspacePath,m_FileName));
}
コード例 #25
0
ファイル: cbp2make.cpp プロジェクト: joobog/ppsim
bool CProcessingMachine::Configure(const CString& FileName)
{
 CGenericProcessingMachine::Configure(""/*FileName*/);
 if (DoShowHelp())
 {
  DisplayHelpMessage();
  return false;
 }
 if (BeVerbose())
 {
  std::cout<<"Command line parameters:"<<std::endl;
  PSC().Print(std::cout);
 }
 if (PSC().VarDefined("--version"))
 {
  std::cout<<"cbp2make rev."<<REVISION_NUMBER<<std::endl;
  return false;
 }
#ifdef REVISION_NUMBER
 if (!BeQuiet()) std::cout<<"Starting cbp2make rev."<<REVISION_NUMBER<<"..."<<std::endl;
#endif
 m_BuildManager.Config().BeQuiet() = BeQuiet();
 m_BuildManager.Config().BeVerbose() = BeVerbose();
 CString cfg_name = ConfigurationName();
 // Lookup configuration file
 // 1) if "-cfg" option is specified, use it as-is
 // 2) if "-cfg" option is not specified do following:
 // 2A) use default configuration in current directory
 //     if it exists or "--local" option is specified.
 // 2B) find and/or create configuration in user's home directory,
 //     if it is not possible, fallback to current directory.
 if (!PSC().VarDefined(GPM_VAR_NAME_CFG) &&
     ((!FileExists(cfg_name) && !PSC().VarDefined("--local")) ||
      PSC().VarDefined("--global")))
 {
  CString cfg_path = JoinPaths(HomeDirPath(),".cbp2make");
  if (!DirExists(cfg_path))
  {
   MakeDir(cfg_path);
  }
  if (DirExists(cfg_path))
  {
   cfg_name = JoinPaths(cfg_path,DefaultConfigurationName());
  }
 }
 if (FileExists(cfg_name))
 {
  if (!BeQuiet()) std::cout<<"Using configuration: "<<cfg_name.GetCString()<<std::endl;
  m_BuildManager.Config().Load(cfg_name);
  m_BuildManager.Config().BeQuiet() = BeQuiet();
  m_BuildManager.Config().BeVerbose() = BeVerbose();
 }
 else
 {
  if (!BeQuiet()) std::cout<<"Using default configuration."<<std::endl;
  m_BuildManager.Config().Platforms().AddDefault();
  m_BuildManager.Config().ToolChains().AddDefault();
  //do not create configuration file unless explicitly instructed to do so
  //m_BuildManager.Config().Save(cfg_name);
 }
 if (PSC().VarDefined("--default-options"))
 {
  m_BuildManager.Config().DefaultOptions() = PSC().VarNamed("--default-options").GetString();
 }
 if (!m_BuildManager.Config().DefaultOptions().IsEmpty())
 {
  PS().AddParameters(m_BuildManager.Config().DefaultOptions());
  PSC().ProcessParameters(PS());
  CGenericProcessingMachine::Configure("");
  m_BuildManager.Config().BeQuiet() = BeQuiet();
  m_BuildManager.Config().BeVerbose() = BeVerbose();
 }
 // cache frequently used variables
 bool os_unix = PSC().VarDefined("-unix");
 bool os_windows = PSC().VarDefined("-windows");
 bool os_mac = PSC().VarDefined("-mac");
 CPlatform::OS_Type os_type = CPlatform::OS_Unix;
 if (os_unix) os_type = CPlatform::OS_Unix;
 else if (os_windows) os_type = CPlatform::OS_Windows;
 else if (os_mac) os_type = CPlatform::OS_Mac;
 bool os_any = os_unix || os_windows || os_mac;
 // configure
 m_BuildManager.Config().Platforms().AddDefault();
 if (PSC().VarDefined("--config"))
 {
  CString config_item_str = PSC().VarNamed("--config").GetString();
  int config_item = GuessStr(config_item_str,"toolchain tool platform variable options",
                             config_item_str,true);
  if (0==config_item)
  {
   CString chain_name = PSC().VarNamed("-chain").GetString();
   if (PSC().VarDefined("--add"))
   {
    if (PSC().VarDefined("-chain"))
    {
     CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name);
     if (0==tc)
     {
      tc = m_BuildManager.ToolChains().Add(os_type,chain_name);
     }
     if (0==tc) return false;
     ConfigureToolchain(tc);
    }
   } // add-toolchain
   else if (PSC().VarDefined("--remove")&&PSC().VarDefined("-chain")&&os_any)
   {
    m_BuildManager.ToolChains().Remove(os_type,chain_name);
   }
  }
  if (1==config_item)
  {
   CString chain_name = PSC().VarNamed("-chain").GetString();
   if (PSC().VarDefined("--add"))
   {
    if (PSC().VarDefined("-chain"))
    {
     CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name);
     if (0==tc)
     {
      tc = m_BuildManager.ToolChains().Add(os_type,chain_name);
     }
     if (0==tc) return false;
     if (PSC().VarDefined("-tool")&&PSC().VarDefined("-type"))
     {
      CString tool_type_str = PSC().VarNamed("-type").GetString();
      int tool_type_int = GuessStr(tool_type_str,"other pp as cc rc sl dl el nl count",
                                   tool_type_str,false);
      CBuildTool::ToolType tool_type = (CBuildTool::ToolType)tool_type_int;
      CString tool_name = PSC().VarNamed("-tool").GetString();
      CBuildTool *bt = tc->FindBuildToolByName(tool_name);
      if (0==bt)
      {
       bt = tc->CreateBuildTool(tool_type);
       bt->Alias() = tool_name;
      }
      if (0==bt) return false;
      ConfigureBuildTool(bt);
     }
    }
   } // add-tool
   else if (PSC().VarDefined("--remove")&&PSC().VarDefined("-chain")&&PSC().VarDefined("-tool")&&os_any)
   {
    CToolChain *tc = m_BuildManager.ToolChains().Find(os_type,chain_name);
    if (0!=tc)
    {
     return tc->RemoveToolByName(PSC().VarNamed("-tool").GetString());
    }
   }
  }
  if (2==config_item)
  {
   if (os_any)
   {
    CPlatform *p = m_BuildManager.Platforms().Find(os_type);
    if (0==p) return false;
    ConfigurePlatform(p);
   }
  }
  if (3==config_item)
  {
   if (PSC().VarDefined("--add"))
   {
    CString set_name = PSC().VarNamed("-set").GetString();
    if (PSC().VarDefined("-name") && PSC().VarDefined("-value"))
    {
     CString var_name = PSC().VarNamed("-name").GetString();
     CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Add(set_name);
     CGlobalVariable *var = vset->Add(var_name);
     if (PSC().VarDefined("-desc"))
     {
      var->Description() = PSC().VarNamed("-desc").GetString();
     }
     if (PSC().VarDefined("-value"))
     {
      var->Add(PSC().VarNamed("-field").GetString(),
               PSC().VarNamed("-value").GetString());
     }
    }
   } // add variable
   else if (PSC().VarDefined("--remove"))
   {
    CString set_name = PSC().VarNamed("-set").GetString();
    if (PSC().VarDefined("-name"))
    {
     CString var_name = PSC().VarNamed("-name").GetString();
     CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Add(set_name);
     CGlobalVariable *var = vset->Add(var_name);
     if (PSC().VarDefined("-field"))
     {
      // if both variable and field names are defined, remove the field
      var->Remove(PSC().VarNamed("-field").GetString());
     }
     else
     {
      // if variable name is defined, but field name is not, remove the variable
      vset->Remove(var_name);
     }
    }
    else
    {
     // if both variable and field names are not defined,
     // but set name is defined, remove the entire set
     if (PSC().VarDefined("-set"))
     {
      m_BuildManager.Config().GlobalVariables().Remove(set_name);
     }
    }
   } // remove variable
  } // config variable
  if (config_item < 0) m_BuildManager.Config().Show();
  std::cout<<"Saving configuration: "<<cfg_name.GetCString()<<std::endl;
  m_BuildManager.Config().Save(cfg_name);
  return false;
 } // config
 //
 bool os_all = PSC().VarDefined("--all-os");
      os_all = os_all || (os_unix && os_windows && os_mac);
      os_unix = os_unix || os_all;
      os_windows = os_windows || os_all;
      os_mac = os_mac || os_all;
 bool os_none = !os_all && !os_unix && !os_windows && !os_mac;
 if (os_none)
 {
#ifdef OS_UNIX
  os_unix = true;
#endif
#ifdef OS_WIN
  os_windows = true;
#endif
#ifdef OS_MAC
  os_mac = true;
#endif
 }
 if (os_unix)
 {
  CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Unix);
  if (p) p->Active() = true;
 }
 if (os_windows)
 {
  CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Windows);
  if (p) p->Active() = true;
 }
 if (os_mac)
 {
  CPlatform *p = m_BuildManager.Config().Platforms().Find(CPlatform::OS_Mac);
  if (p) p->Active() = true;
 }
 //
 {
  CString vset_name = PSC().VarNamed("-set").GetString();
  CGlobalVariableSet *vset = m_BuildManager.Config().GlobalVariables().Find(vset_name);
  if (0!=vset)
  {
   vset->Active() = true;
  }
 }
 m_BuildManager.Config().FlatObjectNames() = PSC().VarDefined("--flat-objects");
 m_BuildManager.Config().FlatObjectPaths() = PSC().VarDefined("--flat-objpath");
 m_BuildManager.Config().MultilineObjects() = PSC().VarDefined("--wrap-objects");
 m_BuildManager.Config().MultilineOptions() = PSC().VarDefined("--wrap-options");
 m_BuildManager.Config().IncludeDependencies() = PSC().VarDefined("--with-deps");
 {
  CString target_case_name = PSC().VarNamed("--target-case").GetString();
  m_BuildManager.Config().TargetNameCase() =
   GuessStr(target_case_name,"keep lower upper",target_case_name,false);
 }
 {
  CString macros_case_name = PSC().VarNamed("--macros-case").GetString();
  m_BuildManager.Config().MacroVariableCase() =
   GuessStr(macros_case_name,"keep lower upper",macros_case_name,false);
 }
 {
  CString quote_path_name = PSC().VarNamed("--quote-path").GetString();
  m_BuildManager.Config().QuotePathMode() =
   GuessStr(quote_path_name,"auto never always",quote_path_name,false);
 }
 m_BuildManager.Config().KeepObjectDirectories() = PSC().VarDefined("--keep-objdir");
 m_BuildManager.Config().KeepOutputDirectories() = PSC().VarDefined("--keep-outdir");
 {
  CStringList targets;
  ParseStr(PSC().VarNamed("-targets").GetString(),',',targets);
  targets.RemoveEmpty();
  targets.RemoveDuplicates();
  m_BuildManager.Config().Targets() = targets;
 }
 //if (BeVerbose()) PSC().Print(std::cout);
 return true;
}
コード例 #26
0
void CSaveGameController::setGameDirectory(const std::string& game_directory)
{
    m_savedir = JoinPaths("save", game_directory);
}
コード例 #27
0
ファイル: CEGALatch.cpp プロジェクト: mcmire/Commander-Genius
bool CEGALatch::loadData( std::string &path, short episode, int version, unsigned char *data, bool compresseddata )
{
	std::string filename;
	byte *RawData;
    Uint16 width, height;
    SDL_Surface *sfc;


	filename = getResourceFilename("egalatch.ck" + itoa(episode), path);

	FILE* latchfile = OpenGameFile(filename,"rb");

	if(!latchfile)
		return false;

	RawData = new byte[m_latchplanesize * 4];
    // get the data out of the file into the memory, decompressing it if necessary.
    if (compresseddata)
    {
		if (lz_decompress(latchfile, (unsigned char*) RawData))
		{
			return 1;
		}
    }
    else
    {
    	for(int i=0 ; i<(m_latchplanesize*4) ; i++)
    		RawData[i] = fgetc(latchfile);
    }

    fclose(latchfile);

	// these are the offsets of the different video planes as
	// relative to each other--that is if a pixel in plane1
	// is at N, the byte for that same pixel in plane3 will be
	// at (N + plane3).
	unsigned long plane1, plane2, plane3, plane4;

	plane1 = 0;
	plane2 = (m_latchplanesize * 1);
	plane3 = (m_latchplanesize * 2);
	plane4 = (m_latchplanesize * 3);

	// ** read the 8x8 tiles **
	// set up the getbit() function of CPlanes class
	CPlanes Planes(RawData);
	Planes.setOffsets(plane1 + m_fontlocation, plane2 + m_fontlocation,
					  plane3 + m_fontlocation, plane4 + m_fontlocation, 0);
	// Load these graphics into the CFont Class of CGfxEngine
	// The original vorticon engine only uses one fontmap, but we use another for
	// extra icons. For example sliders are in that map

	g_pGfxEngine->freeFonts();
	g_pGfxEngine->createEmptyFontmaps(3);

	g_pGfxEngine->getFont(0).loadinternalFont();

	CFont &Font = g_pGfxEngine->getFont(1);
	Font.CreateSurface( g_pGfxEngine->Palette.m_Palette, SDL_SWSURFACE );
	sfc = Font.getSDLSurface();

	g_pGfxEngine->getFont(2).loadAlternateFont();


	if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);

	Uint8 *pixel = (Uint8*) sfc->pixels;
	SDL_FillRect(sfc, NULL, 0);

	for(int p=0;p<4;p++)
		Planes.readPlaneofTiles(p, pixel, 16, 8, m_fonttiles);

	if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);

	// ** read the 16x16 tiles **
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);

	g_pGfxEngine->freeTilemap();
	g_pGfxEngine->createEmptyTilemap(2);
	CTilemap &Tilemap = g_pGfxEngine->getTileMap(1);
	Tilemap.CreateSurface( g_pGfxEngine->Palette.m_Palette, SDL_SWSURFACE, m_num16tiles, 4, 13 );
	sfc = Tilemap.getSDLSurface();
	SDL_FillRect(sfc,NULL, 0);
	if(SDL_MUSTLOCK(sfc))	SDL_LockSurface(sfc);
	Uint8 *u_pixel = (Uint8*) sfc->pixels;

	for(int p=0;p<4;p++)
		Planes.readPlaneofTiles(p, u_pixel, 13, 16, m_num16tiles);

	if(SDL_MUSTLOCK(sfc))	SDL_UnlockSurface(sfc);

	// Load Hi-Colour, VGA, SVGA Tiles into the tilemap
	filename = getResourceFilename("gfx/ck" + itoa(episode) + "tiles.bmp", path, false);
	if(Tilemap.loadHiresTile(filename))
		g_pLogFile->textOut(GREEN, "VGA Bitmap for Tileset has been loaded successfully!");

	// Adapt the tilemap to the display, so they are faster blit
	Tilemap.optimizeSurface();

	// make masked tiles according to it's surfaces
	applyMasks();

	////////////////////
	/// Load Bitmaps ///
	////////////////////

	Planes.setOffsets(plane1 + m_bitmaplocation,
					plane2 + m_bitmaplocation,
					plane3 + m_bitmaplocation,
					plane4 + m_bitmaplocation,
					0);

	// decode bitmaps into the BitmapData structure. The bitmaps are
	// loaded into one continuous stream of image data, with the bitmaps[]
	// array giving pointers to where each bitmap starts within the stream.

	for(int p=0 ; p<4 ; p++)
	{
		for(int b=0 ; b<m_bitmaps ; b++)
		{
		    CBitmap &bitmap = g_pGfxEngine->getBitmap(b);
			// this points to the location that we're currently
			// decoding bitmap data to

			sfc= bitmap.getSDLSurface();
			if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
			Uint8* pixel = (Uint8*) sfc->pixels;
			if(p==0)
				SDL_FillRect(sfc, NULL, 0);
			width = bitmap.getWidth(); height = bitmap.getHeight();
			// Now read the raw data

			Planes.readPlane(p, pixel, width, height);

			if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);
		}
	}

	// optimize the bitmaps and load hq bitmaps if there are some.
	for(int b=0 ; b<m_bitmaps ; b++)
	{
		CBitmap &bitmap = g_pGfxEngine->getBitmap(b);
		bitmap.optimizeSurface();
	}

	std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(path, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "bitmap");

	std::set<std::string>::iterator it = filelist.begin();

	for( ; it != filelist.end() ; it++ )
	{
		std::string filename=*it;
		int num = getRessourceID(filename, "bitmap");
		CBitmap &bitmap = g_pGfxEngine->getBitmap(num);
		filename = getResourceFilename("gfx/" + filename, path, false);
		bitmap.loadHQBitmap(filename);
	}

	if(RawData){ delete[] RawData; RawData = NULL;}

	return true;
}
コード例 #28
0
ファイル: CBorder.cpp プロジェクト: iamnilay3/openlierox
	FOR_EACH_ATTRIBUTE(sel, it)  {
		if (it->getName() == prefix + "border-radius-" + corner)
			sett.iRoundRadius.set(it->getFirstValue().getInteger(0), it->getPriority());
		else if (it->getName() == prefix + "border-image-" + corner)
			sett.bmpCorner.set(LoadGameImage(JoinPaths(sel.getBaseURL(), it->getFirstValue().getURL())), it->getPriority());
	}