Ejemplo n.º 1
0
    void ParseContext::update(const std::string& keyString , InputError::Action action) {
        std::vector<std::string> keys;
        boost::split( keys , keyString , boost::is_any_of(":|"));
        for (const auto& input_key : keys) {
            std::vector<std::string> matching_keys;
            size_t wildcard_pos = input_key.find("*");

            if (wildcard_pos == std::string::npos) {
                if (hasKey( input_key ))
                    updateKey( input_key , action );
            } else
                patternUpdate( input_key , action );

        }
    }
Ejemplo n.º 2
0
//--------------------------------------------------------------//
void ofApp::keyPressed(int key){
  //-----------------------First Menu---------------------------//
  //------------------------------------------------------------//
    /*---employ a big switch case statement here-----*/

    switch(unit){
    case 0:

    if ( key == OF_KEY_DOWN && game_search.size() > 0)
    {
      currentFile++;
      currentFile %= game_search.size();
    }
    else if( key == OF_KEY_UP && game_search.size() > 0)
    {
      currentFile--;
      currentFile %= game_search.size();
    }
    else if(key == OF_KEY_RETURN && game_search.size() > 0)
    {
      //Takes current file and searches for suffix and passes it to .info update
      string g = game_search.getName(currentFile);
      int lastIndex = g.find_last_of(".");
      string name = g.substr(lastIndex + 1);
      ofLogVerbose(g.substr(lastIndex + 1));
      
      //Holds results from suffix parse on .info directory
      vector<string> inf_res = patternUpdate(name);
      
      //Holds results of .info and emulator name parse which is path to emulator
      emu_res = emuUpdate(inf_res);
      

      //reads string path to selected file to in games search to a .txt file
      //--->will need to setup bash script to copy
      //------------------------------------------------------
      game_selection = '"' + game_search.getName(currentFile) + '"';
      ofBuffer msg(game_selection.c_str(), game_selection.length());
      ofFile gameName(ofToDataPath("game_select.txt"), ofFile::WriteOnly);
      gameName.create();
      ofBufferToFile("game_select.txt", msg);
      msg.clear();
      gameName.close();
      ofLogVerbose("written out and closed first time");
      unit = 2;
    }
    break;
    case 2:
    //----------------------------Second Menu-------------------------------//
    //----------------------------------------------------------------------//
    if(key == OF_KEY_DOWN && emu_res.size() > 0)
    {
      currentFile1++;
      currentFile1 %= emu_res.size();
    }
    else if(key == OF_KEY_UP && emu_res.size() > 0){
      currentFile1--;
      currentFile1 %= emu_res.size();
    }
    else if(key == OF_KEY_RETURN && emu_res.size() > 0){
       emu_selection.push_back(emu_res[currentFile1]);
       
       ofFile emuName(ofToDataPath("emu_select.txt"), ofFile::WriteOnly);
       emuName.create();
       ofLogVerbose("file opened");

       ofBuffer msg(emu_res[currentFile1]);
       ofBufferToFile("emu_select.txt", msg);
       msg.clear();
       emuName.close();
       ofLogVerbose("Written to out and closed ,second Tiem!");
       unit = 3;
       /* Work on opening file here and putting emu_selection into it */
    }
    break;
    case 3:

    if(key == OF_KEY_RETURN && emu_res.size() > 0)
    {
      openChildApp();
    }
  }//end of switch 
}