Ejemplo n.º 1
0
/// search google for artist images
void EditMetadataDialog::searchForArtistImages(void)
{
    QString artist = m_metadata->Artist().replace(' ', '+');
    artist = QUrl::toPercentEncoding(artist, "+");

    QUrl url("http://www.google.co.uk/images?q=" + artist, QUrl::TolerantMode);

    QString cleanName = fixFilename(m_metadata->Artist().toLower());
    QString file = GetConfDir() + QString("/MythMusic/Icons/%1/%2.jpg").arg("artist").arg(cleanName);

    QFileInfo fi(file);
    GetMythMainWindow()->HandleMedia("WebBrowser", url.toString(), fi.absolutePath() + '/', fi.fileName());
}
Ejemplo n.º 2
0
/// search flickr for genre images
void EditMetadataDialog::searchForGenreImages(void)
{
    QString genre= m_metadata->Genre().replace(' ', '+');
    genre = QUrl::toPercentEncoding(genre, "+");

    QUrl url("http://www.flickr.com/search/groups/?w=908425%40N22&m=pool&q=" + genre, QUrl::TolerantMode);

    QString cleanName = fixFilename(m_metadata->Genre().toLower());
    QString file = GetConfDir() + QString("/MythMusic/Icons/%1/%2.jpg").arg("genre").arg(cleanName);

    QFileInfo fi(file);
    GetMythMainWindow()->HandleMedia("WebBrowser", url.toString(), fi.absolutePath() + '/', fi.fileName());
}
Ejemplo n.º 3
0
Model *ResourceLoader::loadModel(const Common::String &filename, CMap *c, Model *parent) {
	Common::String fname = fixFilename(filename);
	Common::SeekableReadStream *stream;

	stream = openNewStreamFile(fname.c_str());
	if(!stream)
		error("Could not find model %s", filename.c_str());

	Model *result = new Model(filename, stream, c, parent);
	_models.push_back(result);
	delete stream;

	return result;
}
Ejemplo n.º 4
0
Material *ResourceLoader::loadMaterial(const Common::String &filename, CMap *c) {
	Common::String fname = fixFilename(filename, false);
	fname.toLowercase();
	Common::SeekableReadStream *stream;

	stream = openNewStreamFile(fname.c_str(), true);
	if(!stream)
		error("Could not find material %s", filename.c_str());

	Material *result = new Material(fname, stream, c);
	delete stream;

	return result;
}
Ejemplo n.º 5
0
AnimationEmi *ResourceLoader::loadAnimationEmi(const Common::String &filename) {
	Common::String fname = fixFilename(filename);
	Common::SeekableReadStream *stream;
	
	stream = openNewStreamFile(fname.c_str(), true);
	if(!stream) {
		warning("Could not find animation %s", filename.c_str());
		return NULL;
	}
	
	AnimationEmi *result = new AnimationEmi(filename, stream);
	delete stream;

	return result;
}
Ejemplo n.º 6
0
Skeleton *ResourceLoader::loadSkeleton(const Common::String &filename) {
	Common::String fname = fixFilename(filename);
	Common::SeekableReadStream *stream;

	stream = openNewStreamFile(fname.c_str(), true);
	if (!stream) {
		warning("Could not find skeleton %s", filename.c_str());
		return nullptr;
	}

	Skeleton *result = new Skeleton(filename, stream);
	delete stream;

	return result;
}
Ejemplo n.º 7
0
EMIModel *ResourceLoader::loadModelEMI(const Common::String &filename, EMIModel *parent) {
	Common::String fname = fixFilename(filename);
	Common::SeekableReadStream *stream;

	stream = openNewStreamFile(fname.c_str());
	if(!stream) {
		warning("Could not find model %s", filename.c_str());
		return NULL;
	}

	EMIModel *result = new EMIModel(filename, stream, parent);
	_emiModels.push_back(result);
	delete stream;

	return result;
}
Ejemplo n.º 8
0
Sprite *ResourceLoader::loadSprite(const Common::String &filename, EMICostume *costume) {
    assert(g_grim->getGameType() == GType_MONKEY4);
    Common::SeekableReadStream *stream;

    const Common::String fname = fixFilename(filename, true);

    stream = openNewStreamFile(fname.c_str(), true);
    if (!stream) {
        warning("Could not find sprite %s", fname.c_str());
        return NULL;
    }

    Sprite *result = new Sprite();
    result->loadBinary(stream, costume);
    delete stream;

    return result;
}
Ejemplo n.º 9
0
Costume *ResourceLoader::loadCostume(const Common::String &filename, Costume *prevCost) {
	Common::String fname = fixFilename(filename);
	fname.toLowercase();

	Common::SeekableReadStream *stream = openNewStreamFile(fname.c_str(), true);
	if (!stream) {
		error("Could not find costume \"%s\"", filename.c_str());
	}
	Costume *result;
	if (g_grim->getGameType() == GType_MONKEY4) {
		result = new EMICostume(filename, prevCost);		
	} else {
		result = new Costume(filename, prevCost);
	}
	result->load(stream);
	delete stream;
	
	return result;
}
Ejemplo n.º 10
0
Material *ResourceLoader::loadMaterial(const Common::String &filename, CMap *c) {
    Common::String fname = fixFilename(filename, false);
    fname.toLowercase();
    Common::SeekableReadStream *stream;

    stream = openNewStreamFile(fname.c_str(), true);
    if (!stream) {
        // FIXME: EMI demo references files that aren't included. Return a known material.
        // This should be fixed in the data files instead.
        if (g_grim->getGameType() == GType_MONKEY4 && g_grim->getGameFlags() & ADGF_DEMO) {
            const Common::String replacement("fx/candle.sprb");
            warning("Could not find material %s, using %s instead", filename.c_str(), replacement.c_str());
            return loadMaterial(replacement, NULL);
        }
    }

    Material *result = new Material(fname, stream, c);
    delete stream;

    return result;
}
Ejemplo n.º 11
0
int konMain( int argc, char *argv[] )
{
	int filesArgStart = 1;  //Where the files start on the command line
  char fullPath[MAXPATH+1];

  // Store startup time
  time( &KonSystem::startupTime );

  // See if an instance is running: If so, send files

  Window::popupWindow( ControllerWindow::getTitle() );	// This is only necessary on Win

	if( NamedMessagePipe::supportsPipes() )
	{
    NamedMessagePipe *pipe = new NamedMessagePipe();

    if( !pipe->connect( PIPENAME ) )
    {
      if( argc == 1 )
        pipe->sendMessage( "***" );
      else
      {
        for( int i = 1; i < argc; i++ )
        {
					if( strchr( argv[i], '*' ) != NULL || strchr( argv[i], '?' ) != NULL )
					{
						Dir dir( argv[i], DirEntry::ARCHIVED, 0 );

						for( int d = 0; d < dir.getEntries(); d++ )
						{
							fixFilename( argv[i], dir.getEntryAt(d)->getName(), fullPath );
		          pipe->sendMessage( fullPath );
						}
					}
					else
					{
	    		  System::getFullPath( argv[i], fullPath, MAXPATH );
	          pipe->sendMessage( fullPath );
					}
        }
        delete pipe;
      }
	    Window::popupWindow( ControllerWindow::getTitle() );	// This is only necessary on Win
      return 0;
    }

    delete pipe;
	}
	else
	{
    Window *wnd = new Window( Desktop::getInstance(), 0, 0, 10, 10 );
		BOOL res = TRUE;

    if( argc == 1 )
	    res = wnd->sendDataToWindow( ControllerWindow::getTitle(), "***" );
    else
			for( int i = 1; i < argc; i++ )
			{
				if( strchr( argv[i], '*' ) != NULL || strchr( argv[i], '?' ) != NULL )
				{
					Dir dir( argv[i], DirEntry::ARCHIVED, 0 );

					for( int d = 0; d < dir.getEntries(); d++ )
					{
						fixFilename( argv[i], dir.getEntryAt(d)->getName(), fullPath );
						res = wnd->sendDataToWindow( ControllerWindow::getTitle(), fullPath );
						if( !res ) break;
					}
				}
				else
				{
    			System::getFullPath( argv[i], fullPath, MAXPATH );
					res = wnd->sendDataToWindow( ControllerWindow::getTitle(), fullPath );
				}
				if( !res ) break;
			}

		if( res ) return 0;	// Exit, everything worked OK
    delete wnd;	// Didn't find a previous instance, continue
	}

  // Set up Kon base directory

  KonSystem::baseDir = argv[0];

  char *slashPos = strrchr( argv[0], '\\' );

  if( slashPos != NULL )
    *(slashPos+1) = 0;

  KonSystem::bmpDir = new char[strlen( argv[0] ) + 10];
  sprintf( KonSystem::bmpDir, "%s\\bmp\\", argv[0] );
  KonSystem::kDir = new char[strlen( argv[0] ) + 10];
  sprintf( KonSystem::kDir, "%s\\k\\", argv[0] );

  char filename[MAXPATH+1];

  sprintf( filename, "%s%s", KonSystem::baseDir, "english.prp" );

  if( Strings::loadStrings( filename ) )
  {
  	PopupMessage *message = 
    	new PopupMessage( Desktop::getInstance(),
                        "Startup error", "Couldn't load english.prp",
                        PopupMessage::error );
		message->getResult();
    return 1;
  }

	Settings::initSettings();

  sprintf( filename, "%s%s", System::getSettingsDir(), WINPRPFILENAME );
  WinProperties::loadProperties( filename );

  sprintf( filename, "%s%s", System::getSettingsDir(), KONPRPFILENAME );
  ClassProperties::restoreProperties( filename );

  sprintf( filename, "%s%s", KonSystem::baseDir, "kon.syn" );

  SyntaxContainer::loadSyntaxes( filename );

  KeyBindings::createInstance();

  // Create common commands instance

  KCommonCommands::createInstance();

  // Create the errorCollector instance

  KErrorCollector::createInstance( Strings::get(54) );

  // Execute the startup script

	if( Settings::errorCollectorVisible )
		KErrorCollector::getInstance()->show();

  Kstartup *kStartup = new Kstartup();
  delete kStartup;

  ControllerWindow::createInstance();

  MainWindow *mainWin =
    new MainWindow( Desktop::getInstance(), "Kon", 10, 10, 600, 450 );
  mainWin->setVisible( TRUE );

  // Load files on commandline

	if( argc > 1 )
  {
  	for( int i = 1; i < argc; i++ )
		{
			if( strchr( argv[i], '*' ) != NULL || strchr( argv[i], '?' ) != NULL )
			{
				Dir dir( argv[i], DirEntry::ARCHIVED, 0 );

				for( int d = 0; d < dir.getEntries(); d++ )
				{
					fixFilename( argv[i], dir.getEntryAt(d)->getName(), fullPath );
          ControllerWindow::getInstance()->loadFile( mainWin, fullPath, TRUE, TRUE, Settings::reuseExistingBuffer );
//	    		mainWin->addFile( fullPath, TRUE, TRUE );
				}
			}
			else
        ControllerWindow::getInstance()->loadFile( mainWin, argv[i], TRUE, TRUE, Settings::reuseExistingBuffer );
//    		mainWin->addFile( argv[i], TRUE, TRUE );
		}
  }
  else
	{
		char filename[MAXPATH];
		BufferAdmin::getNextScratchName( filename );
    ControllerWindow::getInstance()->loadFile( mainWin, filename, TRUE, TRUE, Settings::reuseExistingBuffer );
//   	mainWin->addFile( filename, TRUE, TRUE );
	}

	if( NamedMessagePipe::supportsPipes() )
	{
    // Start pipe server
    PipeServer *pipeServer = new PipeServer();
    pipeServer->start( 4096 );
	}

	AutosaveThread::createInstance();

  // Check license

  KonSystem::registered = FALSE;

  char regFile[MAXPATH];
  sprintf( regFile, "%s%s", KonSystem::baseDir, "kon.reg" );

  FILE *f = fopen( regFile, "rb");

  if( f != NULL )
  {
    fread( KonSystem::regName, sizeof(KonSystem::regName), 1, f );
    fread( KonSystem::regKey, sizeof(KonSystem::regKey), 1, f );

    int i;
    for( i = 0; i < strlen(KonSystem::regName); i++ )
      KonSystem::regName[i] ^= 0xef;

    for( i = 0; i < strlen(KonSystem::regKey); i++ )
      KonSystem::regKey[i] ^= 0xef;

    // Check if license key is correct

    char result[MAXREGCODELEN*2];
    result[0] = 0;
    int ok = scramble( KonSystem::regName, result );

    if( !ok || strcmp( KonSystem::regKey, result ) )
    {
      // Failed registration
  	  PopupMessage *message = 
    	  new PopupMessage( mainWin,
                          Strings::get(221), Strings::get(222),
                          PopupMessage::error );
		  message->getResult();
    }
    else
      KonSystem::registered = TRUE;
    fclose( f );
  }

  if( !KonSystem::registered )
  {
    AboutDialog *aboutDialog =
      new AboutDialog( mainWin );

    aboutDialog->setVisible( TRUE );

    delete aboutDialog;
  }

  Application::run();

  KErrorCollector::killInstance();

  sprintf( filename, "%s%s", System::getSettingsDir(), WINPRPFILENAME );
  WinProperties::saveProperties( filename );

  sprintf( filename, "%s%s", System::getSettingsDir(), KONPRPFILENAME );
  ClassProperties::saveProperties( filename );

  KModules::saveModulesList();

  if( !KonSystem::registered )
  {
    AboutDialog *aboutDialog =
      new AboutDialog( Desktop::getInstance() );

    aboutDialog->setVisible( TRUE );

    delete aboutDialog;
  }

  return 0;
}