Example #1
0
//load from command-line, etc
void Utility::loadMedia(string pathname) {
  pathname.transform("\\", "/");
  if(pathname.endswith("/")) pathname.rtrim("/");

  //if a filename was provided: convert to game folder and then load
  if(!directory::exists(pathname) && file::exists(pathname)) {
    auto e = program->emulator[0];
    if(auto container = importMedia(pathname)) {
      utility->showMessage({"Imported ",pathname,"."});
      if(container != "<system>")
        loadMedia(e, e->media[0], container);
    }
    return;
  }
  if(!directory::exists(pathname)) return;
  string type = extension(pathname);

  //determine type by comparing extension against all emulation cores
  for(auto &emulator : program->emulator) {
    for(auto &media : emulator->media) {
      if(media.bootable == false) continue;
      if(type != media.type) continue;
      return loadMedia(emulator, media, {pathname, "/"});
    }
  }

  MessageWindow().setText("Unable to determine media type.").warning();
}
Example #2
0
string Utility::importMedia(string pathname) {
  string container;
  
  if(file::exists(pathname) && file::size(pathname) <= 0x10000) {
    // Check if it's one of the system ROMs
    if(auto manifest = program->getUserResource("Nintendo DS.sys/manifest.bml")) {
      auto elem     = Markup::Document(vectorstream(manifest()).text());
      auto contents = file::read(pathname);
      auto hash     = sha256(contents.data(), contents.size());
      auto sysfolder = program->savePath("Nintendo DS.sys/");
      
      if(hash == elem["system/memory/arm9/sha256"].text()) {
        string dest = {sysfolder, elem["system/memory/arm9/data"].text()};
        file::write(dest, contents);
        return "<system>";
      }
      else if(hash == elem["system/memory/arm7/sha256"].text()) {
        string dest = {sysfolder, elem["system/memory/arm7/data"].text()};
        file::write(dest, contents);
        return "<system>";
      }
    }
  }
  
  if(!NintendoDS::validateHeader(filestream(pathname, file::mode::read))) {
    MessageWindow().setTitle("Import failed").setText(
      {"Couldn't import ",pathname,".\n"
       "\n"
       "This file doesn't look like a Nintendo DS title.\n"})
      .error();
    return "";
  }
  else if(!NintendoDS::importROMImage(container, libraryPath(), pathname)) {
    MessageWindow().setTitle("Import failed").setText(
      {"Couldn't import ",pathname,".\n"
       "\n"
       "Check to see if you've got sufficient permissions and disk space."})
      .error();
    return "";
  }
  return container;
}
Example #3
0
void LibraryImport::onImportActivate() {
  if(program->ananke.open() == false) {
    MessageWindow().setText("ananke must be installed to use this feature").warning();
    return;
  }
  function<string ()> browse = program->ananke.sym("ananke_browse");
  if(!browse) return;
  audio.clear();  //ananke's browser is modal
  string pathname = browse();
  pathname.rtrim<1>("/");
  if(pathname.empty()) return;

  //after importing game, take user to the relevant game list to show the newly imported title
  string type = extension(pathname);
  for(signed bootable = 1; bootable >= 0; bootable--) {
    unsigned selection = 0;
    for(auto& browser : libraryManager->browsers) {
      unsigned mode = 0;
      for(auto& media : browser->emulator.media) {
        if(type == media.type && media.bootable == bootable) {
          browser->mediaMode.setSelection(mode);
          libraryManager->libraryFrame.setSelection(selection);
          libraryManager->onChange();

          //find game in list and select it
          string name = notdir(nall::basename(pathname));
          for(unsigned n = 0; n < browser->folders.rows(); n++) {
            if(browser->folders.text(n, 0) == name) {
              browser->folders.setSelection(n);
              browser->onChange();
              break;
            }
          }

          return;
        }
        mode++;
      }
      selection++;
    }
  }
}
Example #4
0
//load from command-line, etc
void Utility::loadMedia(string pathname) {
  pathname.transform("\\", "/");
  if(pathname.endsWith("/")) pathname.rtrim("/");

  if(!directory::exists(pathname)) return;
  string type = extension(pathname);

  //determine type by comparing extension against all emulation cores
  for(auto& emulator : program->emulator) {
    for(auto& media : emulator->media) {
      if(media.bootable == false) continue;
      if(type != media.type) continue;
      loadMedia(emulator, media, {pathname, "/"});
      libraryManager->setVisible(false);
      return;
    }
  }

  MessageWindow().setText("Unable to determine media type.").warning();
}
Example #5
0
protected func Activate(int iByPlayer)
  {
  MessageWindow(GetDesc(), iByPlayer);
  return true;
  }
Example #6
0
func Activate(int iPlayer)
{
	MessageWindow("Die Waffenfabriken können alle alles produzieren",iPlayer);
	return(1);
}	
Example #7
0
protected func Activate(iPlr)
{
  MessageWindow(GetDesc(), iPlr);
  return(1);
}
Example #8
0
protected func Activate(iByPlayer) 
{
  MessageWindow(GetDesc(), iByPlayer);
  return(1);
}
Example #9
0
func Activate(int iPlayer)
{
	MessageWindow("Erzeugt eine Sperre in der Mitte der landschaft, um zu verhindern, das sich die Gegner vor der Zeit einen Besuch abstatten",iPlayer);
}
Example #10
0
protected func Activate(int iByPlayer)
{
	MessageWindow(GetProperty("Description"), iByPlayer);
	return true;
}
Example #11
0
protected func Activate(caller) {
  MessageWindow(GetDesc(), caller);
  return(1);
}