diff --git a/config/plugins/RocketLauncher/file_util.nut b/config/plugins/RocketLauncher/file_util.nut new file mode 100644 index 000000000..c4144304e --- /dev/null +++ b/config/plugins/RocketLauncher/file_util.nut @@ -0,0 +1,276 @@ +/////////////////////////////////////////////////// +// +// Attract-Mode Frontend - History.dat plugin +// +// File utilities +// +/////////////////////////////////////////////////// +const READ_BLOCK_SIZE=80960; +local next_ln_overflow=""; // used by the get_next_ln() function +local idx_path = FeConfigDirectory + "history.idx/"; +local loaded_idx = {}; + +// +// Write a single line of output to f +// +function write_ln( f, line ) +{ + local b = blob( line.len() ); + + for (local i=0; i last_per ) + { + last_per = percent.tointeger(); + if ( fe.overlay.splash_message( + "Generating index (" + + last_per + "%)" ) ) + break; // break loop if user cancels + } + + while ( !blb.eos() ) + { + local line = scan_for_ctrl_ln( blb ); + + if ( line.len() < 5 ) // skips $bio, $end + continue; + + local eq = line.find( "=", 1 ); + if ( eq != null ) + { + local systems = split( line.slice(1,eq), "," ); + local roms = split( line.slice(eq+1), "," ); + + foreach ( s in systems ) + { + if ( !indices.rawin( s ) ) + indices[ s ] <- {}; + + if ( config[ "index_clones" ] == "Yes" ) + { + foreach ( r in roms ) + (indices[ s ])[ r ] + <- ( base_pos + blb.tell() ); + } + else if ( roms.len() > 0 ) + { + (indices[ s ])[ roms[0] ] + <- ( base_pos + blb.tell() ); + } + } + } + } + } + + // + // Make sure the directory we are writing to exists... + // + system( "mkdir \"" + idx_path + "\"" ); + + fe.overlay.splash_message( "Writing index file." ); + + // + // Now write an index file for each system encountered + // + foreach ( n,l in indices ) + { + local idx = file( idx_path + n + ".idx", "w" ); + foreach ( rn,ri in l ) + write_ln( idx, rn + ";" + ri + "\n" ); + + idx.close(); + } + + histf.close(); + + return "Created index for " + indices.len() + + " systems in " + idx_path; +} + +// +// Return the text for the history.dat entry after the given offset +// +function get_history_entry( offset, config ) +{ + local histf = file( fe.path_expand( config[ "dat_path" ] ), "rb" ); + histf.seek( offset ); + + local entry = "\n\n"; // a bit of space to start + local open_entry = false; + + while ( !histf.eos() ) + { + local blb = histf.readblob( READ_BLOCK_SIZE ); + while ( !blb.eos() ) + { + local line = get_next_ln( blb ); + + if ( !open_entry ) + { + // + // forward to the $bio tag + // + if (( line.len() < 1 ) + || ( line != "$bio" )) + continue; + + open_entry = true; + } + else + { + if ( line == "$end" ) + { + entry += "\n\n"; + return entry; + } + else if (!(blb.eos() && ( line == "" ))) + entry += line + "\n"; + } + } + } + + return entry; +} + +// +// Load the index for the given system if it is not already loaded +// +function load_index( sys ) +{ + // check if system index already loaded + // + if ( loaded_idx.rawin( sys ) ) + return true; + + local idx; + try + { + idx = file( idx_path + sys + ".idx", "r" ); + } + catch( e ) + { + loaded_idx[sys] <- null; + return false; + } + + loaded_idx[sys] <- {}; + + while ( !idx.eos() ) + { + local blb = idx.readblob( READ_BLOCK_SIZE ); + while ( !blb.eos() ) + { + local line = get_next_ln( blb ); + local bits = split( line, ";" ); + if ( bits.len() > 0 ) + (loaded_idx[sys])[bits[0]] <- bits[1].tointeger(); + } + } + + return true; +} + +// +// Return the index the history.dat entry for the specified system and rom +// +function get_history_offset( sys, rom, alt, cloneof ) +{ + foreach ( s in sys ) + { + if (( load_index( s ) ) + && ( loaded_idx[s] != null )) + { + if ( loaded_idx[s].rawin( rom ) ) + return (loaded_idx[s])[rom]; + else if ((alt.len() > 0 ) + && ( loaded_idx[s].rawin( alt ) )) + return (loaded_idx[s])[alt]; + else if ((cloneof.len() > 0 ) + && ( loaded_idx[s].rawin( cloneof ) )) + return (loaded_idx[s])[cloneof]; + } + + } + + if (( sys.len() != 1 ) || ( sys[0] != "info" )) + return get_history_offset( ["info"], rom, alt, cloneof ); + + return -1; +} diff --git a/config/plugins/RocketLauncher/plugin.nut b/config/plugins/RocketLauncher/plugin.nut new file mode 100644 index 000000000..d2fd6136c --- /dev/null +++ b/config/plugins/RocketLauncher/plugin.nut @@ -0,0 +1,139 @@ +/////////////////////////////////////////////////// +// +// Attract-Mode Frontend - UltraStik360 plugin +// +// A plugin that allows the intergration with RocketLauncher +// to be seamless +// +/////////////////////////////////////////////////// + +// +// The UserConfig class identifies plugin settings that can be configured +// from Attract-Mode's configuration menu +// + +//To Do +// create a copy routine to save the files to Rocket Launcher +// create a routine to configure the emulators to have their settings changed +// see how both points above can be achieved without it running each time the plugin is used --> ask RayGun + +class UserConfig { + + + rlpath = "D:\\Rocketlauncher\\"; + + + emulatorpic = "D:\\AttractMode\\media\\systemlogos\\"; + + + screenshot = "snap"; + + + wheel = "wheel"; + + + video = "snap"; + + + marquee = "marquee"; + + + fanart = "fanart"; + + + flyer = "flyer"; +}; + +// setup plugin +local config = fe.get_config(); +local my_dir = fe.script_dir; +dofile( my_dir + "file_util.nut" ); + + + + +// write the information to a file when a game is started +fe.add_transition_callback( "rocketlauncher_integration_transition" ); + + +function rocketlauncher_integration_transition( ttype, var, ttime ) +{ + + switch ( ttype ) + { + case Transition.ToGame: + + local rlfile = file("rl_integration.txt","wb+") + local gameInfo = []; + local gamestring = "#Name|Title|Emulator|CloneOf|Year|Manufacturer|Category|Players|Rotation|Control|Status|DisplayCount|DisplayType|AltRomname|AltTitle|Extra|Buttons|Rating\n"; + gameInfo.push(fe.game_info( Info.Name )); + gameInfo.push(fe.game_info( Info.Title )); + gameInfo.push(fe.game_info( Info.Emulator )); // current emulator + gameInfo.push(fe.game_info( Info.CloneOf )); + gameInfo.push(fe.game_info( Info.Year )); + gameInfo.push(fe.game_info( Info.Manufacturer )); + gameInfo.push(fe.game_info( Info.Category )); + gameInfo.push(fe.game_info( Info.Players )); + gameInfo.push(fe.game_info( Info.Rotation )); + gameInfo.push(fe.game_info( Info.Control )); + gameInfo.push(fe.game_info( Info.Status )); + gameInfo.push(fe.game_info( Info.DisplayCount )); + gameInfo.push(fe.game_info( Info.DisplayType )); + gameInfo.push(fe.game_info( Info.AltRomname )); + gameInfo.push(fe.game_info( Info.AltTitle )); + gameInfo.push(fe.game_info( Info.Extra )); + gameInfo.push(fe.game_info( Info.Buttons )); + gameInfo.push(fe.game_info( Info.Tags)); + + foreach (value in gameInfo) + { + gamestring = gamestring + value + "|"; + } + + local screenshot = (config["screenshot"] == "none") ? "" : config["screenshot"]; + local wheel = (config["wheel"] == "none") ? "" : config["wheel"]; + local emulatorpic = config["emulatorpic"] + gameInfo[2] + ".png" + local video = (config["video"] == "none") ? "" : config["video"]; + local marquee = (config["marquee"] == "none") ? "" : config["marquee"]; + local fanart = (config["fanart"] == "none") ? "" : config["fanart"]; + local flyer = (config["flyer"] == "none") ? "" : config["flyer"]; + + screenshot = fe.get_art( screenshot,0,0, Art.ImagesOnly) + "|screenshot(RL Background)" + wheel = fe.get_art( wheel ) + "|wheel art(RL Logo)"; + emulatorpic = emulatorpic + "|emulator art(RL Logo)"; + video = fe.get_art( video ) + "|game_video(RL Video)"; + marquee = fe.get_art( marquee ) + "|game_marquee(RL Artwork)"; + fanart = fe.get_art( fanart ) + "|game_fanart(RL Artwork)"; + flyer = fe.get_art( flyer ) + "|game_flyer(RL Artwork)"; + + local artwork = []; + local artworkstring = ""; + artwork.push(screenshot); // screenshot (RL Background) + artwork.push(wheel); // current game wheel (RL Logo) + artwork.push(emulatorpic); // current system wheel (RL Logo) + artwork.push(video); // videos (RL Video) + artwork.push(marquee); // marquee (RL Artwork) + artwork.push(fanart); // fanart (RL Artwork) + artwork.push(flyer); // flyer (RL Artwork) + + // artwork.push("|screenshot(RL Background)"); // screenshot (RL Background) + // artwork.push("|wheel art(RL Logo)"); // current game wheel (RL Logo) + // artwork.push("|emulator art(RL Logo)"); // current system wheel (RL Logo) + // artwork.push("|game_video(RL Video)"); // videos (RL Video) + // artwork.push("|game_marquee(RL Artwork)"); // marquee (RL Artwork) + // artwork.push("|game_fanart(RL Artwork)"); // fanart (RL Artwork) + // artwork.push("|game_flyer(RL Artwork)"); // flyer (RL Artwork) + + foreach (value in artwork) + { + artworkstring = artworkstring + "\n" + value + } + + write_ln( rlfile, gamestring + artworkstring ); + rlfile.close; + break; + + } + + return false; // must return false +}