Issue #94 - Add global filters, reorg to consistently use "Displays" concept

- Config UI reworked, what were previously called "display lists" or some
  variation thereof are now consistently called "Displays".
- Related refactoring of the code.
- Each display now has a global filter which gets applied when the romlist
  is first loaded and is useful for filtering out the stuff you will never
  want.  Other filters then get applied to the results of the global
  filter process.
- Added help messages for the various frontend actions in the "controls"
  configuration.
This commit is contained in:
Andrew Mickelson
2015-02-02 23:10:24 -08:00
parent ae3b3ebbf6
commit aca18adff2
26 changed files with 919 additions and 653 deletions
+85 -53
View File
@@ -242,11 +242,10 @@ Parameters:
* msg - the text to display. The tokens below that appear in the 'msg'
string will be substituted appropriately:
- `[ListTitle]` - the name of the current display list
- `[ListSize]` - the number of items in the current display list
- `[ListEntry]` - the number of the current selection in the current
display list
- `[ListFilterName]` - the name of the current display list filter
- `[DisplayName]` - the name of the current display
- `[ListSize]` - the number of items in the game list
- `[ListEntry]` - the number of the current selection in the game list
- `[FilterName]` - the name of the filter
- `[SortName]` - the attribute that the list was sorted by
- `[Name]` - the short name of the selected game
- `[Title]` - the full name of the selected game
@@ -858,7 +857,7 @@ global layout settings are stored.
#### `fe.list` ####
`fe.list` is an instance of the `fe.CurrentList` class and is where current
list settings are stored.
display settings are stored.
<a name="overlay" />
@@ -940,45 +939,17 @@ Notes:
<a name="CurrentList" />
#### `fe.CurrentList` ####
This class is a container for current list settings. The instance of this
class is the `fe.list` object. This class cannot be otherwise instantiated
in a script.
This class is a container for status information regarding the current display.
The instance of this class is the `fe.list` object. This class cannot be
otherwise instantiated in a script.
Attributes:
* `name` - Get the name of the current list.
* `filter` - Get the name of the current list filter.
* `size` - Get the size of the current list.
* `index` - Get/set the current list selection index.
* `sort_by` - Get the attribute that the list has been sorted by. Will be
equal to one of the following values:
- `Info.NoSort`
- `Info.Name`
- `Info.Title`
- `Info.Emulator`
- `Info.CloneOf`
- `Info.Year`
- `Info.Manufacturer`
- `Info.Category`
- `Info.Players`
- `Info.Rotation`
- `Info.Control`
- `Info.Status`
- `Info.DisplayCount`
- `Info.DisplayType`
- `Info.AltRomname`
- `Info.AltTitle`
- `Info.Extra`
- `Info.Favourite`
- `Info.Tags`
- `Info.PlayedCount`
- `Info.PlayedTime`
- `Info.FileIsAvailable`
* `reverse_order` - [bool] Will be equal to true if the list order has been
reversed.
* `list_limit` - Get the value of the list limit applied to the current
list.
* `filter_index` - Get/set the current filter index.
* `name` - Get the name of the current display.
* `filter_index` - Get/set the index of the currently selected filter.
(see `fe.filters` for the list of available filters).
* `index` - Get/set the index of the currently selected game.
<a name="Overlay" />
#### `fe.Overlay` ####
@@ -1023,6 +994,34 @@ Attributes:
* `name` - Get the filter name.
* `index` - Get the index of the currently selected game in this filter.
* `size` - Get the size of the game list in this filter.
* `sort_by` - Get the attribute that the game list has been sorted by.
Will be equal to one of the following values:
- `Info.NoSort`
- `Info.Name`
- `Info.Title`
- `Info.Emulator`
- `Info.CloneOf`
- `Info.Year`
- `Info.Manufacturer`
- `Info.Category`
- `Info.Players`
- `Info.Rotation`
- `Info.Control`
- `Info.Status`
- `Info.DisplayCount`
- `Info.DisplayType`
- `Info.AltRomname`
- `Info.AltTitle`
- `Info.Extra`
- `Info.Favourite`
- `Info.Tags`
- `Info.PlayedCount`
- `Info.PlayedTime`
- `Info.FileIsAvailable`
* `reverse_order` - [bool] Will be equal to true if the list order has been
reversed.
* `list_limit` - Get the value of the list limit applied to the filter game
list.
<a name="Image" />
@@ -1075,7 +1074,9 @@ Attributes:
coordinates). Default value is 0. Use a negative value to expand
towards the right instead.
* `texture_width` - Get the width of the image texture (in pixels).
*** see [Notes](#ImageNotes).
* `texture_height` - Get the height of the image texture (in pixels).
*** see [Notes](#ImageNotes).
* `subimg_x` - Get/set the x position of top left corner of the image
texture sub-rectangle to display. Default value is 0.
* `subimg_y` - Get/set the y position of top left corner of the image
@@ -1137,19 +1138,51 @@ Member Functions:
surface's draw list (see [`fe.add_surface()`](#add_surface) for parameters
and return value).
<a name="ImageNotes" />
Notes:
* [artworks] Note that Attract-Mode defers the loading of artwork images until
after all layout and plug-in scripts have completed running. This means that
the `texture_width`, `texture_height` and `file_name` attributes are not
available when a layout or plug-in script first adds the artwork resource.
These attributes are available during transition callbacks, and in particular
during the `Transition.FromOldSelection` and `Transition.ToNewList` transitions.
Example:
```` squirrel
local my_art = fe.add_artwork( "snap", 0, 0, 100, 100 );
fe.add_transition_callback("artwork_transition");
function artwork_transition( ttype, var, ttime )
{
if (( ttype == Transition.FromOldSelection )
|| ( ttype == Transition.ToNewList ))
{
//
// do stuff with my_art's texture_width or texture_height here...
//
}
return false;
}
````
* To flip an image vertically, set the `subimg_height` property to
`-1 * texture_height` and `subimg_y` to `texture_height`.
* To flip an image horizontally, set the `subimg_width` property to
`-1 * texture_width` and `subimg_x` to `texture_width`.
// flip "img" vertically
function flip_y( img )
{
img.subimg_height = -1 * img.texture_height;
img.subimg_y = img.texture_height;
}
```` squirrel
// flip "img" vertically
function flip_y( img )
{
img.subimg_height = -1 * img.texture_height;
img.subimg_y = img.texture_height;
}
````
<a name="Text" />
#### `fe.Text` ####
@@ -1163,11 +1196,10 @@ Attributes:
* `msg` - Get/set the text label's message. The tokens below that appear
in the 'msg' string will be substituted appropriately:
- `[ListTitle]` - the name of the current display list
- `[ListSize]` - the number of items in the current display list
- `[ListEntry]` - the number of the current selection in the current
display list
- `[ListFilterName]` - the name of the current display list filter
- `[DisplayName]` - the name of the current display
- `[ListSize]` - the number of items in the game list
- `[ListEntry]` - the number of the current selection in the game list
- `[FilterName]` - the name of the currently displayed filter
- `[SortName]` - the attribute that the list was sorted by
- `[Name]` - the short name of the selected game
- `[Title]` - the full name of the selected game
+52 -19
View File
@@ -16,10 +16,11 @@ No;No
# Help text
#
_help_back;Exit menu
_help_emulators;Configure available emulators
_help_emulators;Configure available game systems and emulators
_help_art_label;The label that identifies this artwork resource (used by layouts)
_help_art_path;The path to the files for this artwork. Multiple paths can be entered if separated by a semicolon.
_help_art_add;Add a new artwork resource (marquee images, screen shots, etc.)
_help_art;An artwork resource available for use by layouts
_help_emu_executable;The full path and name of the emulator executable. $HOME gets replaced with the user's home dir
_help_emu_args;The command line arguments for this emulator. The following get substituted appropriately: [name], [romext], [rompath], [emulator], [romfilename]
_help_emu_rompath;The path to the roms for this emulator. Multiple paths can be entered if separated by a semicolon.
@@ -36,26 +37,58 @@ _help_emu_add;Add a new emulator
_help_filter_name;The name for this filter
_help_filter_rule;Configure filter rule
_help_filter_add_rule;Add a rule to this filter
_help_filter_sort_by;The game information attribute that you wish to sort this list by. Set to "No Sort" to keep the ordering from the source romlist
_help_filter_sort_by;The game information attribute that you wish to sort the collection/rom list by. Set to "No Sort" to keep the ordering from the source collection/rom list
_help_filter_list_limit;Set this to a non-zero value if you wish to limit the size of a sorted list. Use a positive value for the first X entries (i.e. "10" gives the first 10 entries), a negative value for the last X entries (i.e. "-25" gives the last 25 entries), or "0" for no limit
_help_filter_delete;Delete this filter
_help_rule_target;The game information attribute that you wish to filter based on
_help_rule_comp;Comparison type for the filter
_help_rule_value;The regular expression value to filter to. For example, if the filter target is "Year" and comparison is "equals", a value of "1984" will match the year of 1984, "198." will match any year in the 80s, and "(198.)|(199.)" will match any year in the 80s or 90s
_help_rule_delete;Delete this filter rule
_help_list_name;The title of this display list
_help_list_layout;The layout to use for this display list
_help_list_romlist;The romlist to use for this display list
_help_list_filter;Configure filter
_help_list_add_filter;Add a filter to this display list
_help_list_layout_options;Configure any layout-specific options
_help_list_delete;Delete this display list
_help_list_sel;Configure display list
_help_list_add;Add a new display list
_help_display_name;The title for this display
_help_display_layout;The layout to use for this display
_help_display_romlist;The collection/rom list to use for this display
_help_display_filter;Configure this filter from the display's filter set
_help_display_global_filter;Configure global filter rules that are applied to every entry in this display's collection/rom list
_help_display_add_filter;Add a filter to this display's filter set
_help_display_layout_options;Configure any layout-specific options
_help_display_delete;Delete this display
_help_display_sel;Configure display
_help_display_add;Add a new display
_help_input_action;
_help_input_delete;Remove this control mapping
_help_input_add;Add a new control mapping for this action
_help_control_sel;Configure control mappings
_help_control_select;Set the control(s) that launch the current selection
_help_control_up;Set the control(s) that move the selection up
_help_control_down;Set the control(s) that move the selection down
_help_control_page_up;Set the control(s) that move the selection up one page
_help_control_page_down;Set the control(s) that move the selection down one page
_help_control_prev_display;Set the control(s) that move to the previous display
_help_control_next_display;Set the control(s) that move to the next display
_help_control_displays_menu;Set the control(s) that show the "Displays Menu"
_help_control_prev_filter;Set the control(s) that move to the previous filter
_help_control_next_filter;Set the control(s) that move to the next filter
_help_control_filters_menu;Set the control(s) that show the "Filters Menu"
_help_control_toggle_layout;Set the control(s) that toggle the layout script to use (It depends on the layout you are using whether this does anything)
_help_control_toggle_movie;Set the control(s) that toggle whether or not videos should be played
_help_control_toggle_mute;Set the control(s) that mute/unmute frontend sound
_help_control_toggle_rotate_right;Set the control(s) that toggle whether the display should be rotated 90 degrees to the right
_help_control_toggle_flip;Set the control(s) that toggle whether the display should be rotated 100 degrees
_help_control_toggle_rotate_left;Set the control(s) that toggle whether the display should be rotated 90 degrees to the left
_help_control_exit;Set the control(s) that exit the frontend
_help_control_exit_no_menu;Set the control(s) that exit the frontend immediately to the desktop
_help_control_screenshot;Set the control(s) that take a screenshot of the frontend
_help_control_configure;Set the control(s) that show the "Configuration Menu"
_help_control_random_game;Set the control(s) that select a random game from the current list
_help_control_replay_last_game;Set the control(s) that relaunch the last game played
_help_control_add_favourite;Set the control(s) that mark/unmark the currently selected game as a favourite
_help_control_prev_favourite;Set the control(s) that move to the previous favourite
_help_control_next_favourite;Set the control(s) that move to the next favourite
_help_control_add_tags;Set the control(s) to add/remove tags from the currently selected game
_help_control_screen_saver;Set the control(s) that launch screen saver mode
_help_control_prev_letter;Set the control(s) that move to the previous letter
_help_control_next_letter;Set the control(s) that move to the next letter
_help_control_custom1;Set the "Custom1" control(s)
_help_control_custom2;Set the "Custom2" control(s)
_help_joystick_threshold;The threshold for registering joystick moves, from 1 to 100 (100=least sensitive)
_help_mouse_threshold;The threshold for registering mouse moves, from 1 to 100 (100=least sensitive)
_help_plugin_command;The executable associated with this plug-in
@@ -67,18 +100,18 @@ _help_exit_command;Command to execute when Exit (Confirm) is selected [i.e. "sud
_help_default_font;The name of the default font to use
_help_font_path;The directories containing fonts. Multiple directories can be entered if separated by a semicolon. Attract-Mode will recursively search these directories to find a specified font
_help_screen_saver_timeout;The amount of time in seconds to wait before switching to the screen saver. 0 to disable
_help_lists_menu_exit;Configure whether an Exit option should be provided in the"Lists Menu"
_help_displays_menu_exit;Configure whether an Exit option should be provided in the"Displays Menu"
_help_hide_brackets;Hide text in brackets when showing game titles
_help_autolaunch_last_game;Automatically launch the last game played on startup
_help_confirm_favs;Confirm the addition/removal of Favourites
_help_track_usage;Configure whether Attract-Mode should track usage (played time and play count for each game)
_help_window_mode;Set whether Attract-Mode fills the screen or runs in a window
_help_filter_wrap_mode;Set what happens when the "Next Filter" or "Previous Filter" actions reach the end of the filter list
_help_filter_wrap_mode;Set what happens when the "Next Filter" or "Previous Filter" actions reach the end of the filter set
_help_emulators;Configure emulator settings
_help_lists;Configure display lists
_help_controls;Configure controls
_help_sound;Configure sound volumes and sound mappings
_help_displays;Configure the romlist/layout groupings (a.k.a. "Displays") that are available to be cycled through in Attract-Mode
_help_controls;Configure the joystick, keyboard and mouse inputs that control Attract-Mode
_help_sound;Configure sound volumes, sound event mappings and the ambient soundtrack
_help_screen_saver;Configure screen saver
_help_plugins;Configure plug-ins
_help_misc;Configure Miscellaneous settings
_help_plugins;Configure available plug-ins
_help_misc;Configure miscellaneous settings
_sort_regexp;^(Vs\. The |The |Vs\. )
+8 -4
View File
@@ -51,16 +51,20 @@ local lb = fe.add_listbox( 24, 96, 192, 192 );
lb.rows = 13;
lb.charsize = 10;
fe.add_artwork( "marquee", 144, 24, 168, 48 );
fe.add_artwork( "snap", 240, 96, 192, 192 );
local tmp = fe.add_artwork( "marquee", 144, 24, 168, 48 );
tmp.trigger = Transition.EndNavigation;
tmp = fe.add_artwork( "snap", 240, 96, 192, 192 );
tmp.trigger = Transition.EndNavigation;
fe.add_image( "field.png", 0, 0, 456, 336 );
fe.add_text( "[ListTitle]", 118, 316, 220, 14 );
fe.add_text( "[DisplayName]", 118, 316, 220, 14 );
local l = fe.add_text( "[ListEntry]/[ListSize]", 0, 322, 60, 10 );
l.align = Align.Left;
l.set_rgb( 80, 80, 80 );
l = fe.add_text( "[ListFilterName]", 396, 322, 60, 10 );
l = fe.add_text( "[FilterName]", 396, 322, 60, 10 );
l.align = Align.Right;
l.set_rgb( 80, 80, 80 );
+2 -2
View File
@@ -18,7 +18,7 @@ l.sel_style = Style.Bold;
fe.add_image( "bg.png", 0, 0 );
l = fe.add_text( "[ListTitle]", 0, 15, 640, 30 );
l = fe.add_text( "[DisplayName]", 0, 15, 640, 30 );
l.set_rgb( 200, 200, 70 );
l.style = Style.Bold;
@@ -42,7 +42,7 @@ l = fe.add_text( "[ListEntry]/[ListSize]", 320, 424, 290, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;
l = fe.add_text( "[ListFilterName]", 320, 441, 290, 16 );
l = fe.add_text( "[FilterName]", 320, 441, 290, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;
+2 -2
View File
@@ -145,13 +145,13 @@ logo.alpha=255;
//local message = fe.add_text("Loading...",0,100,lw,40);
//message.alpha = 0;
// Optional game texts
local romlist = fe.add_text( "[ListTitle]", 2, 202, 315, 10 );
local romlist = fe.add_text( "[DisplayName]", 2, 202, 315, 10 );
romlist.align = Align.Right;
local cat = fe.add_text( fe.game_info (Info.Category), 2, 212, 315, 10 );
cat.align = Align.Right;
local entries = fe.add_text( "[ListEntry]/[ListSize]", 2, 222, 315, 10 );
entries.align = Align.Right;
local filter = fe.add_text( "[ListFilterName]", -20, 190, lw+40, lh-191 );
local filter = fe.add_text( "[FilterName]", -20, 190, lw+40, lh-191 );
filter.align = Align.Right;
filter.alpha = 32;
// Switch texts on and off
+2 -2
View File
@@ -72,7 +72,7 @@ for ( local i=0; i<ftr_count; i++ )
PAD );
new_label = fe.add_text( "[ListFilterName]", i * x_dim, 0, x_dim, TOP_SPACE );
new_label = fe.add_text( "[FilterName]", i * x_dim, 0, x_dim, TOP_SPACE );
}
else
{
@@ -85,7 +85,7 @@ for ( local i=0; i<ftr_count; i++ )
y_dim,
PAD );
new_label = fe.add_text( "[ListFilterName]", 0, TOP_SPACE + i * y_dim, fe.layout.width, y_dim );
new_label = fe.add_text( "[FilterName]", 0, TOP_SPACE + i * y_dim, fe.layout.width, y_dim );
new_label.alpha = 125;
new_label.set_rgb( 0, 0, 0 );
}
+1 -1
View File
@@ -447,7 +447,7 @@ gridc.name_t = fe.add_text( "[Title]", 0,
fe.layout.height - fe.layout.height / 24 - PAD,
fe.layout.width, fe.layout.height / 24 );
local title = fe.add_text( "[ListTitle]/[ListFilterName]",
local title = fe.add_text( "[DisplayName]/[FilterName]",
0, 0, fe.layout.width/2, fe.layout.height / 32 );
title.align = Align.Left;
+2 -2
View File
@@ -155,7 +155,7 @@ local frame = fe.add_image( "frame.png", 216, 51, 368, 278 );
//
// Initialize misc text
//
local l = fe.add_text( "[ListFilterName] [[ListEntry]/[ListSize]]", 400, 580, 400, 20 );
local l = fe.add_text( "[FilterName] [[ListEntry]/[ListSize]]", 400, 580, 400, 20 );
l.set_rgb( 180, 180, 70 );
l.align = Align.Right;
@@ -185,7 +185,7 @@ orbital.set_slots( sats );
//
// Title text
//
l = fe.add_text( "[ListTitle]", 0, 0, 800, 55 );
l = fe.add_text( "[DisplayName]", 0, 0, 800, 55 );
l.set_rgb( 180, 180, 70 );
l.style = Style.Bold;
+6 -3
View File
@@ -59,6 +59,7 @@ fe.layout.page_size=15;
local surface = fe.add_surface( 480, 360 );
local snap = surface.add_artwork( "snap", 0, 0, 480, 360 );
snap.preserve_aspect_ratio = true;
snap.trigger = Transition.EndNavigation;
// position and pinch the surface
//
@@ -281,11 +282,11 @@ l = fe.add_text( "[ListEntry]/[ListSize]", 370, 458, 240, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;
l = fe.add_text( "[ListTitle]", 4, 4, 140, 16 );
l = fe.add_text( "[DisplayName]", 4, 4, 140, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Left;
l = fe.add_text( "[ListFilterName]", 370, 4, 240, 16 );
l = fe.add_text( "[FilterName]", 370, 4, 240, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;
@@ -317,7 +318,6 @@ function update_lb( ttype, var, ttime )
case Transition.ToNewSelection:
info_bub.set_alpha( 0 );
do_fade_in = true;
fade_in_time = clock() * 1000 + 500;
break;
@@ -347,10 +347,13 @@ function update_lb( ttype, var, ttime )
{
info_bub.set_msg( "Copyright " + year + " " +
fe.game_info( Info.Manufacturer, 0 ) );
do_fade_in = true;
}
else
{
info_bub.set_msg( "" );
do_fade_in = false;
info_bub.set_alpha( 0 );
}
break;
}
+5 -5
View File
@@ -115,10 +115,10 @@ for (local i=(itn/2)*-1;i<=(itn/2);i+=1){
}
// Texts
local fltsh=fe.add_text("< [ListFilterName] >",1,(flh*0.06)+1,flw,flh*0.05);
local fltsh=fe.add_text("< [FilterName] >",1,(flh*0.06)+1,flw,flh*0.05);
fltsh.set_rgb(0,0,0);
local filtername=fe.add_text(fltsh.msg,fltsh.x-1,fltsh.y-1,fltsh.width,fltsh.height);
local listtitle=fe.add_text("[ListSize] [ListTitle]",0,flh*0.11,flw,flh*0.05);
local listtitle=fe.add_text("[ListSize] [DisplayName]",0,flh*0.11,flw,flh*0.05);
local slgsh=fe.add_text("[Title]",lbx+1,lby+1,lbw,ith);
slgsh.set_rgb(0,0,0);
local selgame=fe.add_text(slgsh.msg,slgsh.x-1,slgsh.y-1,slgsh.width,slgsh.height);
@@ -169,8 +169,8 @@ function textTickles(ttime){
function fades(ttype,var,ttime){
switch (ttype){
case Transition.FromGame:
fltsh.msg="< [ListFilterName] >";
filtername.msg="< [ListFilterName] >";
fltsh.msg="< [FilterName] >";
filtername.msg="< [FilterName] >";
return false;
break;
case Transition.ToGame:
@@ -190,4 +190,4 @@ function fades(ttype,var,ttime){
}
fe.add_ticks_callback( "textTickles" );
fe.add_transition_callback( "fades" );
fe.add_transition_callback( "fades" );
+18 -18
View File
@@ -42,7 +42,7 @@ extern const char *FE_ROMLIST_SUBDIR;
namespace {
void build_basic_romlist( const FeEmulatorInfo &emulator,
std::list<FeRomInfo> &romlist )
FeRomInfoListType &romlist )
{
std::vector<std::string> names_list;
emulator.gather_rom_names( names_list );
@@ -86,7 +86,7 @@ std::string url_escape( const std::string &raw )
}
void apply_xml_import( const FeEmulatorInfo &emulator,
std::list<FeRomInfo> &romlist,
FeRomInfoListType &romlist,
FeXMLParser::UiUpdate uiupdate=NULL, void *uiupdatedata=NULL )
{
std::string source = emulator.get_info(
@@ -133,7 +133,7 @@ void apply_xml_import( const FeEmulatorInfo &emulator,
const std::string &extension = exts.front();
// A bit mislabelled: the steam import isn't really xml.
for ( std::list<FeRomInfo>::iterator itr = romlist.begin(); itr != romlist.end(); ++itr )
for ( FeRomInfoListType::iterator itr = romlist.begin(); itr != romlist.end(); ++itr )
{
// We expect appmanifest_* entries in the romname field. Open each of these files and
// extract the data we can use in our list
@@ -243,7 +243,7 @@ void apply_xml_import( const FeEmulatorInfo &emulator,
}
int i=0;
for ( std::list<FeRomInfo>::iterator itr=romlist.begin(); itr!=romlist.end(); ++itr )
for ( FeRomInfoListType::iterator itr=romlist.begin(); itr!=romlist.end(); ++itr )
{
bool exact_match( false );
for ( std::vector<std::string>::iterator its=system_list.begin();
@@ -294,7 +294,7 @@ void apply_xml_import( const FeEmulatorInfo &emulator,
}
void write_romlist( const std::string &filename,
const std::list<FeRomInfo> &romlist )
const FeRomInfoListType &romlist )
{
std::cout << "Writing " << romlist.size() << " entries to: "
@@ -313,7 +313,7 @@ void write_romlist( const std::string &filename,
// Now output the list
//
for ( std::list<FeRomInfo>::const_iterator itl=romlist.begin();
for ( FeRomInfoListType::const_iterator itl=romlist.begin();
itl != romlist.end(); ++itl )
outfile << (*itl).as_output() << std::endl;
@@ -330,14 +330,14 @@ struct myclasscmp
};
void ini_import( const std::string &filename,
std::list<FeRomInfo> &romlist,
FeRomInfoListType &romlist,
FeRomInfo::Index index,
const std::string &init_tag )
{
std::map <std::string, std::string, myclasscmp> my_map;
// create entries in the map for each name we want to find
for ( std::list<FeRomInfo>::iterator itr=romlist.begin();
for ( FeRomInfoListType::iterator itr=romlist.begin();
itr!=romlist.end(); ++itr )
{
my_map[ (*itr).get_info( FeRomInfo::Romname ) ] = "";
@@ -395,7 +395,7 @@ void ini_import( const std::string &filename,
myfile.close();
int count=0;
for ( std::list<FeRomInfo>::iterator itr=romlist.begin();
for ( FeRomInfoListType::iterator itr=romlist.begin();
itr!=romlist.end(); ++itr )
{
std::string val = my_map[ (*itr).get_info( FeRomInfo::Romname ) ];
@@ -418,7 +418,7 @@ void ini_import( const std::string &filename,
}
void apply_import_extras( const FeEmulatorInfo &emulator,
std::list<FeRomInfo> &romlist )
FeRomInfoListType &romlist )
{
const std::vector< std::string > &extras = emulator.get_import_extras();
@@ -438,7 +438,7 @@ void apply_import_extras( const FeEmulatorInfo &emulator,
bool import_mamewah( const std::string &input_filename,
const std::string &emulator_name,
std::list<FeRomInfo> &romlist )
FeRomInfoListType &romlist )
{
// Map the lines of the Mamewah / Wahcade! romlist file to our RomInfo structure
//
@@ -516,7 +516,7 @@ bool import_mamewah( const std::string &input_filename,
bool FeSettings::build_romlist( const std::vector< FeImportTask > &task_list,
const std::string &output_name )
{
std::list<FeRomInfo> total_romlist;
FeRomInfoListType total_romlist;
std::string best_name, list_name, path;
for ( std::vector<FeImportTask>::const_iterator itr=task_list.begin();
@@ -533,7 +533,7 @@ bool FeSettings::build_romlist( const std::vector< FeImportTask > &task_list,
}
else
{
std::list<FeRomInfo> romlist;
FeRomInfoListType romlist;
best_name = emu->get_info( FeEmulatorInfo::Name );
@@ -548,7 +548,7 @@ bool FeSettings::build_romlist( const std::vector< FeImportTask > &task_list,
else
{
// import romlist from file task
std::list<FeRomInfo> romlist;
FeRomInfoListType romlist;
std::string emu_name;
if ( (*itr).emulator_name.empty() )
@@ -576,9 +576,9 @@ bool FeSettings::build_romlist( const std::vector< FeImportTask > &task_list,
FeRomList temp_list( m_config_path );
temp_list.load_from_file( (*itr).file_name, ";" );
std::deque<FeRomInfo> &entries = temp_list.get_list();
FeRomInfoListType &entries = temp_list.get_list();
for ( std::deque<FeRomInfo>::iterator itr = entries.begin(); itr != entries.end(); ++itr )
for ( FeRomInfoListType::iterator itr = entries.begin(); itr != entries.end(); ++itr )
romlist.push_back( *itr );
}
else if ( tail_compare( (*itr).file_name, ".lst" ) )
@@ -595,7 +595,7 @@ bool FeSettings::build_romlist( const std::vector< FeImportTask > &task_list,
if ( my_parser.parse( (*itr).file_name ) )
{
// Update the emulator entries
for ( std::list<FeRomInfo>::iterator itr=romlist.begin(); itr != romlist.end(); ++itr )
for ( FeRomInfoListType::iterator itr=romlist.begin(); itr != romlist.end(); ++itr )
(*itr).set_info( FeRomInfo::Emulator, emu_name );
}
}
@@ -660,7 +660,7 @@ bool FeSettings::build_romlist( const std::string &emu_name, UiUpdate uiu, void
if ( uiu )
uiu( uid, 0 );
std::list<FeRomInfo> romlist;
FeRomInfoListType romlist;
build_basic_romlist( *emu, romlist );
apply_xml_import( *emu, romlist, uiu, uid );
+123 -95
View File
@@ -279,14 +279,14 @@ void FeEmulatorEditMenu::get_options( FeConfigContext &ctx )
std::vector<std::pair<std::string,std::string> >::iterator itr;
for ( itr=alist.begin(); itr!=alist.end(); ++itr )
{
ctx.add_opt( Opt::SUBMENU, (*itr).first, (*itr).second );
ctx.add_opt( Opt::SUBMENU, (*itr).first, (*itr).second, "_help_art" );
ctx.back_opt().opaque = 1;
}
ctx.add_optl( Opt::SUBMENU, "Add Artwork", "", "_help_art_add" );
ctx.back_opt().opaque = 2;
ctx.add_optl( Opt::SUBMENU, "Generate Romlist", "",
ctx.add_optl( Opt::SUBMENU, "Generate Collection/Rom List", "",
"_help_emu_gen_romlist" );
ctx.back_opt().opaque = 3;
@@ -363,7 +363,7 @@ bool FeEmulatorEditMenu::on_option_select(
if ( m_romlist_exists )
{
if ( ctx.confirm_dialog( "Overwrite existing '$1' romlist?",
if ( ctx.confirm_dialog( "Overwrite existing '$1' list?",
emu_name ) == false )
return false;
}
@@ -372,17 +372,17 @@ bool FeEmulatorEditMenu::on_option_select(
ctx.fe_settings.build_romlist( emu_name, my_ui_update, &ctx,
list_size );
ctx.fe_settings.get_resource( "Wrote $1 entries to romlist",
ctx.fe_settings.get_resource( "Wrote $1 entries to Collection/Rom List",
as_str(list_size), ctx.help_msg );
//
// If we don't have a display list configured for this romlist,
// If we don't have a display configured for this romlist,
// configure one now
//
if ( !ctx.fe_settings.check_romlist_configured( emu_name ) )
{
FeListInfo *new_list = ctx.fe_settings.create_list( emu_name );
new_list->set_info( FeListInfo::Romlist, emu_name );
FeDisplayInfo *new_disp = ctx.fe_settings.create_display( emu_name );
new_disp->set_info( FeDisplayInfo::Romlist, emu_name );
}
ctx.save_req = true;
@@ -647,7 +647,7 @@ void FeRuleEditMenu::set_rule_index( FeFilter *filter, int index )
}
FeFilterEditMenu::FeFilterEditMenu()
: m_list( NULL ), m_index( 0 )
: m_display( NULL ), m_index( 0 )
{
}
@@ -655,12 +655,21 @@ void FeFilterEditMenu::get_options( FeConfigContext &ctx )
{
ctx.set_style( FeConfigContext::EditList, "Filter Edit" );
if ( m_list )
if ( m_display )
{
FeFilter *f = m_list->get_filter( m_index );
FeFilter *f = m_display->get_filter( m_index );
ctx.add_optl( Opt::EDIT, "Filter Name", f->get_name(),
"_help_filter_name" );
if ( m_index < 0 )
{
std::string gf;
ctx.fe_settings.get_resource( "Global Filter", gf );
ctx.add_optl( Opt::INFO, "Filter Name", gf, "_help_filter_name" );
}
else
{
ctx.add_optl( Opt::EDIT, "Filter Name", f->get_name(),
"_help_filter_name" );
}
int i=0;
std::vector<FeRule> &rules = f->get_rules();
@@ -695,33 +704,35 @@ void FeFilterEditMenu::get_options( FeConfigContext &ctx )
ctx.add_optl(Opt::SUBMENU,"Add Rule","","_help_filter_add_rule");
ctx.back_opt().opaque = 1;
std::string no_sort_str, sort_val;
ctx.fe_settings.get_resource( "No Sort", no_sort_str );
if ( f->get_sort_by() != FeRomInfo::LAST_INDEX )
sort_val = FeRomInfo::indexStrings[f->get_sort_by()];
else
sort_val = no_sort_str;
std::vector< std::string > targets;
i=0;
while ( FeRomInfo::indexStrings[i] != 0 )
if ( m_index >= 0 ) // don't add the folloiwng options for the global filter
{
targets.push_back( std::string() );
ctx.fe_settings.get_resource( FeRomInfo::indexStrings[i], targets.back() );
i++;
std::string no_sort_str, sort_val;
ctx.fe_settings.get_resource( "No Sort", no_sort_str );
if ( f->get_sort_by() != FeRomInfo::LAST_INDEX )
sort_val = FeRomInfo::indexStrings[f->get_sort_by()];
else
sort_val = no_sort_str;
std::vector< std::string > targets;
i=0;
while ( FeRomInfo::indexStrings[i] != 0 )
{
targets.push_back( std::string() );
ctx.fe_settings.get_resource( FeRomInfo::indexStrings[i], targets.back() );
i++;
}
targets.push_back( no_sort_str );
ctx.add_optl( Opt::LIST, "Sort By", sort_val, "_help_filter_sort_by" );
ctx.back_opt().append_vlist( targets );
ctx.add_optl( Opt::EDIT, "List Limit", as_str( f->get_list_limit() ),
"_help_filter_list_limit" );
ctx.add_optl(Opt::EXIT,"Delete this Filter","","_help_filter_delete");
ctx.back_opt().opaque = 2;
}
targets.push_back( no_sort_str );
ctx.add_optl( Opt::LIST, "Sort By", sort_val, "_help_filter_sort_by" );
ctx.back_opt().append_vlist( targets );
ctx.add_optl( Opt::EDIT, "List Limit", as_str( f->get_list_limit() ),
"_help_filter_list_limit" );
ctx.add_optl(Opt::EXIT,"Delete this Filter","","_help_filter_delete");
ctx.back_opt().opaque = 2;
}
FeBaseConfigMenu::get_options( ctx );
@@ -730,11 +741,11 @@ void FeFilterEditMenu::get_options( FeConfigContext &ctx )
bool FeFilterEditMenu::on_option_select(
FeConfigContext &ctx, FeBaseConfigMenu *& submenu )
{
if ( !m_list )
if ( !m_display )
return true;
FeMenuOpt &o = ctx.curr_opt();
FeFilter *f = m_list->get_filter( m_index );
FeFilter *f = m_display->get_filter( m_index );
if (( o.opaque >= 100 ) || ( o.opaque == 1 ))
{
@@ -761,8 +772,8 @@ bool FeFilterEditMenu::on_option_select(
f->get_name() ) == false )
return false;
m_list->delete_filter( m_index );
m_list=NULL;
m_display->delete_filter( m_index );
m_display=NULL;
m_index=-1;
ctx.save_req=true;
}
@@ -772,9 +783,9 @@ bool FeFilterEditMenu::on_option_select(
bool FeFilterEditMenu::save( FeConfigContext &ctx )
{
if ( m_list )
if (( m_display ) && ( m_index >= 0 ))
{
FeFilter *f = m_list->get_filter( m_index );
FeFilter *f = m_display->get_filter( m_index );
std::string name = ctx.opt_list[0].get_value();
f->set_name( name );
@@ -806,76 +817,88 @@ bool FeFilterEditMenu::save( FeConfigContext &ctx )
return true;
}
void FeFilterEditMenu::set_filter_index( FeListInfo *l, int i )
void FeFilterEditMenu::set_filter_index( FeDisplayInfo *d, int i )
{
m_list=l;
m_display=d;
m_index=i;
}
FeListEditMenu::FeListEditMenu()
: m_list( NULL ),
FeDisplayEditMenu::FeDisplayEditMenu()
: m_display( NULL ),
m_index( 0 )
{
}
void FeListEditMenu::get_options( FeConfigContext &ctx )
void FeDisplayEditMenu::get_options( FeConfigContext &ctx )
{
ctx.set_style( FeConfigContext::EditList, "List Edit" );
ctx.set_style( FeConfigContext::EditList, "Display Edit" );
if ( m_list )
if ( m_display )
{
ctx.add_optl( Opt::EDIT, "List Name",
m_list->get_info( FeListInfo::Name ), "_help_list_name" );
ctx.add_optl( Opt::EDIT, "Name",
m_display->get_info( FeDisplayInfo::Name ), "_help_display_name" );
ctx.add_optl( Opt::LIST, "Layout",
m_list->get_info( FeListInfo::Layout ), "_help_list_layout" );
m_display->get_info( FeDisplayInfo::Layout ), "_help_display_layout" );
std::vector<std::string> layouts;
ctx.fe_settings.get_layouts_list( layouts );
ctx.back_opt().append_vlist( layouts );
ctx.add_optl( Opt::LIST, "Rom List",
m_list->get_info( FeListInfo::Romlist ), "_help_list_romlist" );
ctx.add_optl( Opt::LIST, "Collection/Rom List",
m_display->get_info( FeDisplayInfo::Romlist ), "_help_display_romlist" );
FeFilter *f = m_display->get_filter( -1 );
std::string filter_desc;
if ( f->get_rule_count() < 1 )
ctx.fe_settings.get_resource( "Empty", filter_desc );
else
ctx.fe_settings.get_resource( "$1 Rule(s)",
as_str(f->get_rule_count()), filter_desc );
ctx.add_optl( Opt::SUBMENU, "Global Filter", filter_desc, "_help_display_global_filter" );
ctx.back_opt().opaque = 9;
std::vector<std::string> romlists;
ctx.fe_settings.get_romlists_list( romlists );
ctx.back_opt().append_vlist( romlists );
std::vector<std::string> filters;
m_list->get_filters_list( filters );
m_display->get_filters_list( filters );
int i=0;
for ( std::vector<std::string>::iterator itr=filters.begin();
itr != filters.end(); ++itr )
{
ctx.add_optl( Opt::SUBMENU, "Filter",
(*itr), "_help_list_filter" );
(*itr), "_help_display_filter" );
ctx.back_opt().opaque = 100 + i;
i++;
}
ctx.add_optl( Opt::SUBMENU, "Add Filter", "", "_help_list_add_filter" );
ctx.add_optl( Opt::SUBMENU, "Add Filter", "", "_help_display_add_filter" );
ctx.back_opt().opaque = 1;
ctx.add_optl( Opt::SUBMENU, "Layout Options", "", "_help_list_layout_options" );
ctx.add_optl( Opt::SUBMENU, "Layout Options", "", "_help_display_layout_options" );
ctx.back_opt().opaque = 2;
ctx.add_optl( Opt::EXIT, "Delete this List", "", "_help_list_delete" );
ctx.add_optl( Opt::EXIT, "Delete this Display", "", "_help_display_delete" );
ctx.back_opt().opaque = 3;
}
FeBaseConfigMenu::get_options( ctx );
}
bool FeListEditMenu::on_option_select(
bool FeDisplayEditMenu::on_option_select(
FeConfigContext &ctx, FeBaseConfigMenu *& submenu )
{
FeMenuOpt &o = ctx.curr_opt();
if ( !m_list )
if ( !m_display )
return true;
if (( o.opaque >= 100 ) || ( o.opaque == 1 ))
if (( o.opaque >= 100 ) || ( o.opaque == 1 ) | ( o.opaque == 9 ))
{
// a filter or "Add Filter" is selected
int f_index=0;
@@ -888,15 +911,17 @@ bool FeListEditMenu::on_option_select(
if ( res.empty() )
return false; // if they don't enter a name then cancel
ctx.fe_settings.create_filter( *m_list, res );
ctx.fe_settings.create_filter( *m_display, res );
f_index = m_list->get_filter_count() - 1;
f_index = m_display->get_filter_count() - 1;
ctx.save_req=true;
}
else if ( o.opaque == 9 )
f_index = -1; // this will get us the global filter
else
f_index = o.opaque - 100;
m_filter_menu.set_filter_index( m_list, f_index );
m_filter_menu.set_filter_index( m_display, f_index );
submenu=&m_filter_menu;
}
else if ( o.opaque == 2 )
@@ -908,58 +933,58 @@ bool FeListEditMenu::on_option_select(
}
else if ( o.opaque == 3 )
{
// "Delete this List"
if ( ctx.confirm_dialog( "Delete list '$1'?", m_list->get_info( FeListInfo::Name ) ) == false )
// "Delete this Display"
if ( ctx.confirm_dialog( "Delete display '$1'?", m_display->get_info( FeDisplayInfo::Name ) ) == false )
return false;
ctx.fe_settings.delete_list( m_index );
m_list=NULL;
ctx.fe_settings.delete_display( m_index );
m_display=NULL;
ctx.save_req=true;
}
return true;
}
bool FeListEditMenu::save( FeConfigContext &ctx )
bool FeDisplayEditMenu::save( FeConfigContext &ctx )
{
if ( m_list )
if ( m_display )
{
for ( int i=0; i< FeListInfo::LAST_INDEX; i++ )
m_list->set_info( i, ctx.opt_list[i].get_value() );
for ( int i=0; i< FeDisplayInfo::LAST_INDEX; i++ )
m_display->set_info( i, ctx.opt_list[i].get_value() );
}
return true;
}
void FeListEditMenu::set_list( FeListInfo *l, int index )
void FeDisplayEditMenu::set_display( FeDisplayInfo *d, int index )
{
m_list=l;
m_display=d;
m_index=index;
}
void FeListSelMenu::get_options( FeConfigContext &ctx )
void FeDisplaySelMenu::get_options( FeConfigContext &ctx )
{
ctx.set_style( FeConfigContext::SelectionList, "Configure / Lists" );
ctx.set_style( FeConfigContext::SelectionList, "Configure / Displays" );
std::vector<std::string> name_list;
ctx.fe_settings.get_list_names( name_list );
ctx.fe_settings.get_display_names( name_list );
int i=0;
for ( std::vector<std::string>::iterator itr=name_list.begin();
itr < name_list.end(); ++itr )
{
ctx.add_opt( Opt::MENU, (*itr), "", "_help_list_sel" );
ctx.add_opt( Opt::MENU, (*itr), "", "_help_display_sel" );
ctx.back_opt().opaque = i;
i++;
}
ctx.add_optl( Opt::MENU, "Add New List", "", "_help_list_add" );
ctx.add_optl( Opt::MENU, "Add New Display", "", "_help_display_add" );
ctx.back_opt().opaque = 100000;
FeBaseConfigMenu::get_options( ctx );
}
bool FeListSelMenu::on_option_select(
bool FeDisplaySelMenu::on_option_select(
FeConfigContext &ctx, FeBaseConfigMenu *& submenu )
{
FeMenuOpt &o = ctx.curr_opt();
@@ -967,30 +992,30 @@ bool FeListSelMenu::on_option_select(
if ( o.opaque < 0 )
return true;
FeListInfo *l( NULL );
FeDisplayInfo *d( NULL );
int index(0);
if ( o.opaque == 100000 )
{
std::string res;
ctx.edit_dialog( "Enter List Name", res );
ctx.edit_dialog( "Enter Display Name", res );
if ( res.empty() )
return false; // if they don't enter a name then cancel
ctx.save_req=true;
l = ctx.fe_settings.create_list( res );
index = ctx.fe_settings.lists_count() - 1;
d = ctx.fe_settings.create_display( res );
index = ctx.fe_settings.displays_count() - 1;
}
else
{
l = ctx.fe_settings.get_list( o.opaque );
d = ctx.fe_settings.get_display( o.opaque );
index = o.opaque;
}
if ( l )
if ( d )
{
m_edit_menu.set_list( l, index );
m_edit_menu.set_display( d, index );
submenu = &m_edit_menu;
}
@@ -1133,10 +1158,13 @@ void FeInputSelMenu::get_options( FeConfigContext &ctx )
value += (*iti);
}
std::string help_msg( "_help_control_" );
help_msg += FeInputMap::commandStrings[(*it).command];
ctx.add_optl( Opt::SUBMENU,
FeInputMap::commandDispStrings[(*it).command],
value,
"_help_control_sel" );
help_msg );
}
// Add the joystick and mouse threshold settings to this menu as well
@@ -1316,9 +1344,9 @@ void FeMiscMenu::get_options( FeConfigContext &ctx )
ctx.fe_settings.get_resource( "No", bool_opts[1] );
ctx.add_optl( Opt::LIST,
"Allow Exit from 'Lists Menu'",
ctx.fe_settings.get_lists_menu_exit() ? bool_opts[0] : bool_opts[1],
"_help_lists_menu_exit" );
"Allow Exit from 'Displays Menu'",
ctx.fe_settings.get_displays_menu_exit() ? bool_opts[0] : bool_opts[1],
"_help_displays_menu_exit" );
ctx.back_opt().append_vlist( bool_opts );
ctx.add_optl( Opt::LIST,
@@ -1393,7 +1421,7 @@ bool FeMiscMenu::save( FeConfigContext &ctx )
{
ctx.fe_settings.set_language( m_languages[ ctx.opt_list[0].get_vindex() ] );
ctx.fe_settings.set_info( FeSettings::ListsMenuExit,
ctx.fe_settings.set_info( FeSettings::DisplaysMenuExit,
ctx.opt_list[1].get_vindex() == 0 ? FE_CFG_YES_STR : FE_CFG_NO_STR );
ctx.fe_settings.set_info( FeSettings::HideBrackets,
@@ -1643,7 +1671,7 @@ void FeConfigMenu::get_options( FeConfigContext &ctx )
ctx.help_msg = FE_COPYRIGHT;
ctx.add_optl( Opt::SUBMENU, "Emulators", "", "_help_emulators" );
ctx.add_optl( Opt::SUBMENU, "Lists", "", "_help_lists" );
ctx.add_optl( Opt::SUBMENU, "Displays", "", "_help_displays" );
ctx.add_optl( Opt::SUBMENU, "Controls", "", "_help_controls" );
ctx.add_optl( Opt::SUBMENU, "Sound", "", "_help_sound" );
ctx.add_optl( Opt::SUBMENU, "Screen Saver", "", "_help_screen_saver" );
+11 -11
View File
@@ -29,7 +29,7 @@
class FeSettings;
class FeEmulatorInfo;
class FeListInfo;
class FeDisplayInfo;
class FeFilter;
class FeRule;
class FePlugInfo;
@@ -285,7 +285,7 @@ public:
class FeFilterEditMenu : public FeBaseConfigMenu
{
private:
FeListInfo *m_list;
FeDisplayInfo *m_display;
int m_index;
FeRuleEditMenu m_rule_menu;
@@ -296,31 +296,31 @@ public:
bool on_option_select( FeConfigContext &ctx,
FeBaseConfigMenu *& submenu );
bool save( FeConfigContext &ctx );
void set_filter_index( FeListInfo *l, int i );
void set_filter_index( FeDisplayInfo *d, int i );
};
class FeListEditMenu : public FeBaseConfigMenu
class FeDisplayEditMenu : public FeBaseConfigMenu
{
private:
FeFilterEditMenu m_filter_menu;
FeLayoutEditMenu m_layout_menu;
FeListInfo *m_list;
int m_index; // the index for m_list in FeSettings' master list
FeDisplayInfo *m_display;
int m_index; // the index for m_display in FeSettings' master list
public:
FeListEditMenu();
FeDisplayEditMenu();
void get_options( FeConfigContext &ctx );
bool on_option_select( FeConfigContext &ctx,
FeBaseConfigMenu *& submenu );
bool save( FeConfigContext &ctx );
void set_list( FeListInfo *l, int index );
void set_display( FeDisplayInfo *d, int index );
};
class FeListSelMenu : public FeBaseConfigMenu
class FeDisplaySelMenu : public FeBaseConfigMenu
{
private:
FeListEditMenu m_edit_menu;
FeDisplayEditMenu m_edit_menu;
public:
void get_options( FeConfigContext &ctx );
@@ -402,7 +402,7 @@ class FeConfigMenu : public FeBaseConfigMenu
{
private:
FeEmulatorSelMenu m_emu_menu;
FeListSelMenu m_list_menu;
FeDisplaySelMenu m_list_menu;
FeInputSelMenu m_input_menu;
FeSoundMenu m_sound_menu;
FeSaverEditMenu m_saver_menu;
+285 -142
View File
@@ -299,8 +299,6 @@ const char FeRomListSorter::get_first_letter( const FeRomInfo &one_info )
return name.at( b );
}
const char *FeRule::indexString = "rule";
const char *FeRule::filterCompStrings[] =
{
"equals",
@@ -430,7 +428,7 @@ void FeRule::save( std::ofstream &f ) const
if (( m_filter_target != FeRomInfo::LAST_INDEX )
&& ( m_filter_comp != LAST_COMPARISON ))
{
f << "\t\t" << std::setw(20) << std::left << indexString << ' '
f << "\t\t" << std::setw(20) << std::left << FeFilter::indexStrings[0] << ' '
<< FeRomInfo::indexStrings[ m_filter_target ] << ' '
<< filterCompStrings[ m_filter_comp ] << ' '
<< m_filter_what << std::endl;
@@ -454,7 +452,7 @@ void FeRule::set_values(
const char *FeFilter::indexStrings[] =
{
"filter",
"rule",
"sort_by",
"reverse_order",
"list_limit",
@@ -493,69 +491,97 @@ bool FeFilter::apply_filter( const FeRomInfo &rom ) const
int FeFilter::process_setting( const std::string &setting,
const std::string &value, const std::string &fn )
{
if ( value.empty() )
if ( setting.compare( indexStrings[0] ) == 0 ) // rule
{
m_rules.push_back(
FeRule( FeRomInfo::LAST_INDEX, FeRule::LAST_COMPARISON, "" )
);
return 0;
if ( value.empty() )
{
m_rules.push_back(
FeRule( FeRomInfo::LAST_INDEX, FeRule::LAST_COMPARISON, "" )
);
return 0;
}
FeRomInfo::Index target;
FeRule::FilterComp comp;
std::string what;
std::string token;
size_t pos=0;
token_helper( value, pos, token, FE_WHITESPACE );
int i=0;
while( FeRomInfo::indexStrings[i] != NULL )
{
if ( token.compare( FeRomInfo::indexStrings[i] ) == 0 )
break;
i++;
}
if ( i >= FeRomInfo::LAST_INDEX )
{
invalid_setting( fn, "filter", token,
FeRomInfo::indexStrings, NULL, "target" );
return 1;
}
target = (FeRomInfo::Index)i;
token_helper( value, pos, token, FE_WHITESPACE );
i=0;
while( FeRule::filterCompStrings[i] != NULL )
{
if ( token.compare( FeRule::filterCompStrings[i] ) == 0 )
break;
i++;
}
if ( i >= FeRule::LAST_COMPARISON )
{
invalid_setting( fn, "filter", token, FeRule::filterCompStrings,
NULL, "comparison" );
return 1;
}
comp = (FeRule::FilterComp)i;
// Remainder of the line is filter regular expression (which may contain
// spaces...)
//
if ( pos < value.size() )
what = value.substr( pos );
m_rules.push_back( FeRule( target, comp, what ) );
}
FeRomInfo::Index target;
FeRule::FilterComp comp;
std::string what;
std::string token;
size_t pos=0;
token_helper( value, pos, token, FE_WHITESPACE );
int i=0;
while( FeRomInfo::indexStrings[i] != NULL )
else if ( setting.compare( indexStrings[1] ) == 0 ) // sort_by
{
if ( token.compare( FeRomInfo::indexStrings[i] ) == 0 )
break;
i++;
for ( int i=0; i < FeRomInfo::LAST_INDEX; i++ )
{
if ( value.compare( FeRomInfo::indexStrings[i] ) == 0 )
{
set_sort_by( (FeRomInfo::Index)i );
break;
}
}
}
if ( i >= FeRomInfo::LAST_INDEX )
else if ( setting.compare( indexStrings[2] ) == 0 ) // reverse_order
{
invalid_setting( fn, "filter", token,
FeRomInfo::indexStrings, NULL, "target" );
set_reverse_order( true );
}
else if ( setting.compare( indexStrings[3] ) == 0 ) // list_limit
{
set_list_limit( as_int( value ) );
}
else
{
invalid_setting( fn, "filter", setting, indexStrings );
return 1;
}
target = (FeRomInfo::Index)i;
token_helper( value, pos, token, FE_WHITESPACE );
i=0;
while( FeRule::filterCompStrings[i] != NULL )
{
if ( token.compare( FeRule::filterCompStrings[i] ) == 0 )
break;
i++;
}
if ( i >= FeRule::LAST_COMPARISON )
{
invalid_setting( fn, "filter", token, FeRule::filterCompStrings,
NULL, "comparison" );
return 1;
}
comp = (FeRule::FilterComp)i;
// Remainder of the line is filter regular expression (which may contain
// spaces...)
//
if ( pos < value.size() )
what = value.substr( pos );
m_rules.push_back( FeRule( target, comp, what ) );
return 0;
}
void FeFilter::save( std::ofstream &f ) const
void FeFilter::save( std::ofstream &f, const char *filter_tag ) const
{
std::string n;
if ( m_name.find_first_of( ' ' ) != std::string::npos )
@@ -564,7 +590,7 @@ void FeFilter::save( std::ofstream &f ) const
n = m_name;
f << '\t' << std::setw(20) << std::left
<< indexStrings[0] << ' ' << n << std::endl;
<< filter_tag << ' ' << n << std::endl;
if ( m_sort_by != FeRomInfo::LAST_INDEX )
{
@@ -600,7 +626,18 @@ bool FeFilter::test_for_target( FeRomInfo::Index target ) const
return false;
}
const char *FeListInfo::indexStrings[] =
void FeFilter::clear()
{
m_name.clear();
m_rules.clear();
m_rom_index=0;
m_list_limit=0;
m_size=0;
m_sort_by=FeRomInfo::LAST_INDEX;
m_reverse_order=false;
}
const char *FeDisplayInfo::indexStrings[] =
{
"name",
"layout",
@@ -608,19 +645,28 @@ const char *FeListInfo::indexStrings[] =
NULL
};
FeListInfo::FeListInfo( const std::string &n )
const char *FeDisplayInfo::otherStrings[] =
{
"filter",
"global_filter",
NULL
};
FeDisplayInfo::FeDisplayInfo( const std::string &n )
: m_rom_index( 0 ),
m_filter_index( 0 )
m_filter_index( 0 ),
m_current_config_filter( NULL ),
m_global_filter( "" )
{
m_info[ Name ] = n;
}
const std::string &FeListInfo::get_info( int i ) const
const std::string &FeDisplayInfo::get_info( int i ) const
{
return m_info[i];
}
int FeListInfo::get_rom_index( int filter_index ) const
int FeDisplayInfo::get_rom_index( int filter_index ) const
{
if (( filter_index >= 0 ) && ( filter_index < (int)m_filters.size() ))
return m_filters[ filter_index ].get_rom_index();
@@ -628,7 +674,7 @@ int FeListInfo::get_rom_index( int filter_index ) const
return m_rom_index;
}
void FeListInfo::set_rom_index( int filter_index, int rom_index )
void FeDisplayInfo::set_rom_index( int filter_index, int rom_index )
{
if (( filter_index >= 0 ) && ( filter_index < (int)m_filters.size() ))
m_filters[ filter_index ].set_rom_index( rom_index );
@@ -636,23 +682,23 @@ void FeListInfo::set_rom_index( int filter_index, int rom_index )
m_rom_index = rom_index;
}
std::string FeListInfo::get_current_layout_file() const
std::string FeDisplayInfo::get_current_layout_file() const
{
return m_current_layout_file;
}
void FeListInfo::set_current_layout_file( const std::string &n )
void FeDisplayInfo::set_current_layout_file( const std::string &n )
{
m_current_layout_file = n;
}
void FeListInfo::set_info( int setting,
void FeDisplayInfo::set_info( int setting,
const std::string &value )
{
m_info[ setting ] = value;
}
int FeListInfo::process_setting( const std::string &setting,
int FeDisplayInfo::process_setting( const std::string &setting,
const std::string &value, const std::string &fn )
{
// name is igored here, it gets set directly
@@ -661,7 +707,7 @@ int FeListInfo::process_setting( const std::string &setting,
m_info[ Layout ] = value;
else if ( setting.compare( indexStrings[Romlist] ) == 0 ) // romlist
m_info[ Romlist ] = value;
else if ( setting.compare( FeFilter::indexStrings[0] ) == 0 ) // filter
else if ( setting.compare( otherStrings[0] ) == 0 ) // filter
{
size_t pos=0;
std::string name;
@@ -670,41 +716,28 @@ int FeListInfo::process_setting( const std::string &setting,
// Create a new filter with the given name
//
m_filters.push_back( FeFilter( name ) );
m_current_config_filter = &(m_filters.back());
}
else if ( setting.compare( FeFilter::indexStrings[1] ) == 0 ) // (filter) sort_by
else if ( setting.compare( otherStrings[1] ) == 0 ) // global_filter
{
for ( int i=0; i < FeRomInfo::LAST_INDEX; i++ )
{
if ( value.compare( FeRomInfo::indexStrings[i] ) == 0 )
{
m_filters.back().set_sort_by( (FeRomInfo::Index)i );
break;
}
}
}
else if ( setting.compare( FeFilter::indexStrings[2] ) == 0 ) // (filter) reverse_order
{
m_filters.back().set_reverse_order( true );
}
else if ( setting.compare( FeFilter::indexStrings[3] ) == 0 ) // (filter) list_limit
{
m_filters.back().set_list_limit( as_int( value ) );
}
else if ( setting.compare( FeRule::indexString ) == 0 ) // (filter) rule
{
if ( !m_filters.empty() )
m_filters.back().process_setting( setting, value, fn );
m_global_filter.clear();
m_current_config_filter = &(m_global_filter);
}
else
{
invalid_setting( fn, "list", setting, indexStrings + 1 );
return 1;
if ( m_current_config_filter )
m_current_config_filter->process_setting( setting, value, fn );
else
{
invalid_setting( fn, "list", setting, indexStrings + 1, otherStrings );
return 1;
}
}
return 0;
}
int FeListInfo::process_state( const std::string &state_string )
int FeDisplayInfo::process_state( const std::string &state_string )
{
// state string is in format:
//
@@ -754,7 +787,7 @@ int FeListInfo::process_state( const std::string &state_string )
return 0;
}
std::string FeListInfo::state_as_output() const
std::string FeDisplayInfo::state_as_output() const
{
std::ostringstream state;
@@ -764,7 +797,7 @@ std::string FeListInfo::state_as_output() const
}
else
{
for ( std::deque<FeFilter>::const_iterator itr=m_filters.begin();
for ( std::vector<FeFilter>::const_iterator itr=m_filters.begin();
itr != m_filters.end(); ++itr )
{
state << (*itr).get_rom_index() << ",";
@@ -777,20 +810,23 @@ std::string FeListInfo::state_as_output() const
return state.str();
}
FeFilter *FeListInfo::get_filter( int i )
FeFilter *FeDisplayInfo::get_filter( int i )
{
if (( i >= 0 ) && ( i < (int)m_filters.size() ))
return &(m_filters[i]);
if ( i < 0 )
return &m_global_filter;
return NULL;
if ( i >= (int)m_filters.size() )
return NULL;
return &(m_filters[i]);
}
void FeListInfo::append_filter( const FeFilter &f )
void FeDisplayInfo::append_filter( const FeFilter &f )
{
m_filters.push_back( f );
}
void FeListInfo::delete_filter( int i )
void FeDisplayInfo::delete_filter( int i )
{
if (( m_filter_index > 0 ) && ( m_filter_index >= i ))
m_filter_index--;
@@ -798,18 +834,18 @@ void FeListInfo::delete_filter( int i )
m_filters.erase( m_filters.begin() + i );
}
void FeListInfo::get_filters_list( std::vector<std::string> &l ) const
void FeDisplayInfo::get_filters_list( std::vector<std::string> &l ) const
{
l.clear();
for ( std::deque<FeFilter>::const_iterator itr=m_filters.begin();
for ( std::vector<FeFilter>::const_iterator itr=m_filters.begin();
itr != m_filters.end(); ++itr )
{
l.push_back( (*itr).get_name() );
}
}
void FeListInfo::save( std::ofstream &f ) const
void FeDisplayInfo::save( std::ofstream &f ) const
{
using std::setw;
using std::left;
@@ -825,13 +861,17 @@ void FeListInfo::save( std::ofstream &f ) const
f << '\t' << setw(20) << left
<< indexStrings[Romlist] << ' ' << get_info( Romlist ) << endl;
for ( std::deque<FeFilter>::const_iterator itr=m_filters.begin();
if ( m_global_filter.get_rule_count() > 0 )
m_global_filter.save( f, otherStrings[1] );
for ( std::vector<FeFilter>::const_iterator itr=m_filters.begin();
itr != m_filters.end(); ++itr )
(*itr).save( f );
(*itr).save( f, otherStrings[0] );
}
FeRomList::FeRomList( const std::string &config_path )
: m_config_path( config_path ),
: m_global_filter_ptr( NULL ),
m_config_path( config_path ),
m_fav_changed( false ),
m_tags_changed( false ),
m_availability_checked( false )
@@ -853,13 +893,17 @@ void FeRomList::init_as_empty_list()
m_availability_checked = false;
m_fav_changed=false;
m_tags_changed=false;
m_global_filter_ptr=NULL;
m_extra_favs.clear();
m_extra_tags.clear();
}
bool FeRomList::load_romlist( const std::string &path,
const std::string &romlist_name,
const std::string &user_path,
const std::string &stat_path,
FeListInfo &list_info )
FeDisplayInfo &display )
{
m_user_path = user_path;
m_romlist_name = romlist_name;
@@ -868,24 +912,45 @@ bool FeRomList::load_romlist( const std::string &path,
m_filtered_list.clear();
m_availability_checked = false;
m_global_filter_ptr = NULL;
m_global_filtered_out_count = 0;
FeFilter *first_filter = display.get_global_filter();
if ( first_filter )
{
first_filter->init();
if ( !first_filter->test_for_target( FeRomInfo::FileIsAvailable )
&& !first_filter->test_for_target( FeRomInfo::Favourite )
&& !first_filter->test_for_target( FeRomInfo::Tags ) )
{
// If the global filter doesn't care about file availability,
// favourites or tags then we can apply it right up front when we
// load the romlist. We signal this by setting m_global_filter_ptr
m_global_filter_ptr = first_filter;
first_filter = NULL;
}
}
sf::Clock load_timer;
bool retval = FeBaseConfigurable::load_from_file(
path + m_romlist_name + FE_ROMLIST_FILE_EXTENSION, ";" );
std::cout << " - Loaded master romlist: " << m_romlist_name
<< " (" << m_list.size() << " entries)" << std::endl;
//
// Create rom name to romlist entry lookup map
//
std::map < std::string, FeRomInfo * > rom_map;
std::map < std::string, FeRomInfo * >::iterator rm_itr;
for ( std::deque< FeRomInfo >::iterator itr = m_list.begin(); itr != m_list.end(); ++itr )
for ( FeRomInfoListType::iterator itr = m_list.begin(); itr != m_list.end(); ++itr )
rom_map[ (*itr).get_info( FeRomInfo::Romname ) ] = &(*itr);
//
// Load favourites
//
m_extra_favs.clear();
m_fav_changed=false;
std::string load_name( m_user_path + m_romlist_name + FE_FAVOURITE_FILE_EXTENSION );
std::ifstream myfile( load_name.c_str() );
@@ -904,6 +969,8 @@ bool FeRomList::load_romlist( const std::string &path,
rm_itr = rom_map.find( name );
if ( rm_itr != rom_map.end() )
(*rm_itr).second->set_info( FeRomInfo::Favourite, "1" );
else
m_extra_favs.insert( name );
}
}
@@ -914,6 +981,7 @@ bool FeRomList::load_romlist( const std::string &path,
// Load tags
//
m_tags.clear();
m_extra_tags.clear();
m_tags_changed=false;
load_name = m_user_path + m_romlist_name + "/";
@@ -948,6 +1016,8 @@ bool FeRomList::load_romlist( const std::string &path,
rm_itr = rom_map.find( rname );
if ( rm_itr != rom_map.end() )
(*rm_itr).second->append_tag( (*itt).first.c_str() );
else
m_extra_tags.insert( std::pair<std::string,const char*>(rname, (*itt).first.c_str() ) );
}
}
@@ -955,26 +1025,89 @@ bool FeRomList::load_romlist( const std::string &path,
}
}
// Apply global filter if it hasn't been applied already
if ( first_filter )
{
if ( first_filter->test_for_target( FeRomInfo::FileIsAvailable ) )
get_file_availability();
FeRomInfoListType::iterator last_it=m_list.begin();
for ( FeRomInfoListType::iterator it=m_list.begin(); it!=m_list.end(); )
{
if ( first_filter->apply_filter( *it ) )
{
if ( last_it != it )
it = m_list.erase( last_it, it );
else
++it;
last_it = it;
}
else
{
//
// This rom is being filtered out and we may need to keep track of a few things
//
// 1. Track if this is a favourite...
//
if ( !(*it).get_info( FeRomInfo::Favourite ).empty() )
m_extra_favs.insert( (*it).get_info( FeRomInfo::Romname ) );
//
// 2. Track if this rom has tags we'll need to keep
//
if ( !(*it).get_info( FeRomInfo::Tags ).empty() )
{
const std::string &name = (*it).get_info( FeRomInfo::Romname );
const std::string &tags = (*it).get_info( FeRomInfo::Tags );
const char sep[] = { FE_TAGS_SEP, 0 };
size_t pos=0;
while ( pos < tags.size() )
{
std::string one_tag;
token_helper( tags, pos, one_tag, sep );
std::map<std::string, bool>::iterator itt = m_tags.find( one_tag );
if ( itt != m_tags.end() )
m_extra_tags.insert( std::pair<std::string,const char *>( name, (*itt).first.c_str() ) );
}
}
m_global_filtered_out_count++;
++it;
}
}
if ( last_it != m_list.end() )
m_list.erase( last_it, m_list.end() );
}
std::cout << " - Loaded master romlist '" << m_romlist_name
<< "' in " << load_timer.getElapsedTime().asMilliseconds()
<< " ms (" << m_list.size() << " entries kept, " << m_global_filtered_out_count
<< " discarded)" << std::endl;
load_timer.restart();
//
// Apply filters
//
int filters_count = list_info.get_filter_count();
int filters_count = display.get_filter_count();
//
// If the list_info doesn't have any filters configured, we create a single "filter" in the romlist object
// If the display doesn't have any filters configured, we create a single "filter" in the romlist object
// with every romlist entry in it
//
if ( filters_count == 0 )
filters_count = 1;
sf::Clock filter_timer;
m_filtered_list.reserve( filters_count );
for ( int i=0; i<filters_count; i++ )
{
m_filtered_list.push_back( std::vector< FeRomInfo *>() );
FeFilter *f = list_info.get_filter( i );
FeFilter *f = display.get_filter( i );
if ( f )
{
if ( f->get_size() > 0 ) // if this is non zero then we've loaded before and know how many to expect
@@ -984,14 +1117,14 @@ bool FeRomList::load_romlist( const std::string &path,
get_file_availability();
f->init();
for ( std::deque< FeRomInfo >::iterator itr=m_list.begin(); itr!=m_list.end(); ++itr )
for ( FeRomInfoListType::iterator itr=m_list.begin(); itr!=m_list.end(); ++itr )
if ( f->apply_filter( *itr ) )
m_filtered_list[i].push_back( &( *itr ) );
}
else // no filter situation, so we just add the entire list...
{
m_filtered_list[i].reserve( m_list.size() );
for ( std::deque< FeRomInfo >::iterator itr=m_list.begin(); itr!=m_list.end(); ++itr )
for ( FeRomInfoListType::iterator itr=m_list.begin(); itr!=m_list.end(); ++itr )
m_filtered_list[i].push_back( &( *itr ) );
}
@@ -1037,8 +1170,8 @@ bool FeRomList::load_romlist( const std::string &path,
}
}
std::cout << " - Constructed " << filters_count << " filtered lists in "
<< filter_timer.getElapsedTime().asMilliseconds()
std::cout << " - Constructed " << filters_count << " filters in "
<< load_timer.getElapsedTime().asMilliseconds()
<< " ms (" << filters_count * m_list.size() << " comparisons)" << std::endl;
return retval;
@@ -1050,31 +1183,33 @@ int FeRomList::process_setting( const std::string &setting,
{
FeRomInfo next_rom( setting );
next_rom.process_setting( setting, value, fn );
m_list.push_back( next_rom );
if (( !m_global_filter_ptr ) || ( m_global_filter_ptr->apply_filter( next_rom ) ))
m_list.push_back( next_rom );
else
m_global_filtered_out_count++;
return 0;
}
void FeRomList::save_state() const
void FeRomList::save_state()
{
save_favs();
save_tags();
}
void FeRomList::save_favs() const
void FeRomList::save_favs()
{
if (( !m_fav_changed ) || ( m_user_path.empty() ) || ( m_romlist_name.empty() ))
return;
std::set<std::string> favs_list;
//
// First gather all the favourites from the current list
// First gather all the favourites from the current list into our extra favs list
//
for ( std::deque<FeRomInfo>::const_iterator itr = m_list.begin(); itr != m_list.end(); ++itr )
for ( FeRomInfoListType::const_iterator itr = m_list.begin(); itr != m_list.end(); ++itr )
{
if ( !((*itr).get_info( FeRomInfo::Favourite ).empty()) )
favs_list.insert( (*itr).get_info( FeRomInfo::Romname ) );
m_extra_favs.insert( (*itr).get_info( FeRomInfo::Romname ) );
}
//
@@ -1082,7 +1217,7 @@ void FeRomList::save_favs() const
//
std::string fname = m_user_path + m_romlist_name + FE_FAVOURITE_FILE_EXTENSION;
if ( favs_list.empty() )
if ( m_extra_favs.empty() )
{
delete_file( fname );
}
@@ -1092,14 +1227,14 @@ void FeRomList::save_favs() const
if ( !outfile.is_open() )
return;
for ( std::set<std::string>::const_iterator itf = favs_list.begin(); itf != favs_list.end(); ++itf )
for ( std::set<std::string>::const_iterator itf = m_extra_favs.begin(); itf != m_extra_favs.end(); ++itf )
outfile << (*itf) << std::endl;
outfile.close();
}
}
void FeRomList::save_tags() const
void FeRomList::save_tags()
{
if (( !m_tags_changed ) || ( m_user_path.empty() ) || ( m_romlist_name.empty() ))
return;
@@ -1108,7 +1243,15 @@ void FeRomList::save_tags() const
//
std::multimap< std::string, const char * > tag_to_rom_map;
for ( std::deque<FeRomInfo>::const_iterator itr = m_list.begin(); itr != m_list.end(); ++itr )
for ( std::multimap< std::string, const char * >::const_iterator ite = m_extra_tags.begin(); ite != m_extra_tags.end(); ++ite )
{
tag_to_rom_map.insert(
std::pair<std::string,const char *>(
(*ite).second,
(*ite).first.c_str() ) );
}
for ( FeRomInfoListType::const_iterator itr = m_list.begin(); itr != m_list.end(); ++itr )
{
const std::string &my_tags = (*itr).get_info( FeRomInfo::Tags );
@@ -1163,7 +1306,7 @@ void FeRomList::save_tags() const
}
}
bool FeRomList::set_fav( int filter_index, int rom_index, FeListInfo &list_info, bool fav )
bool FeRomList::set_fav( int filter_index, int rom_index, FeDisplayInfo &display, bool fav )
{
if (( rom_index < 0 ) || ( rom_index >= filter_size( filter_index ) ))
return false;
@@ -1171,7 +1314,7 @@ bool FeRomList::set_fav( int filter_index, int rom_index, FeListInfo &list_info,
(m_filtered_list[filter_index][rom_index])->set_info( FeRomInfo::Favourite, fav ? "1" : "" );
m_fav_changed=true;
return fix_filters( list_info, FeRomInfo::Favourite );
return fix_filters( display, FeRomInfo::Favourite );
}
void FeRomList::get_tags_list( int filter_index, int rom_index,
@@ -1203,7 +1346,7 @@ void FeRomList::get_tags_list( int filter_index, int rom_index,
}
}
bool FeRomList::set_tag( int filter_index, int rom_index, FeListInfo &list_info, const std::string &tag, bool flag )
bool FeRomList::set_tag( int filter_index, int rom_index, FeDisplayInfo &display, const std::string &tag, bool flag )
{
if (( rom_index < 0 ) || ( rom_index >= filter_size( filter_index ) ))
return false;
@@ -1254,15 +1397,15 @@ bool FeRomList::set_tag( int filter_index, int rom_index, FeListInfo &list_info,
itt = m_tags.insert( itt, std::pair<std::string,bool>( tag, true ) );
}
return fix_filters( list_info, FeRomInfo::Tags );
return fix_filters( display, FeRomInfo::Tags );
}
bool FeRomList::fix_filters( FeListInfo &list_info, FeRomInfo::Index target )
bool FeRomList::fix_filters( FeDisplayInfo &display, FeRomInfo::Index target )
{
bool retval = false;
for ( int i=0; i<list_info.get_filter_count(); i++ )
for ( int i=0; i<display.get_filter_count(); i++ )
{
FeFilter *f = list_info.get_filter( i );
FeFilter *f = display.get_filter( i );
ASSERT( f );
if ( f->test_for_target( target ) )
@@ -1270,7 +1413,7 @@ bool FeRomList::fix_filters( FeListInfo &list_info, FeRomInfo::Index target )
m_filtered_list[i].clear();
retval = true;
for ( std::deque< FeRomInfo >::iterator itr=m_list.begin(); itr!=m_list.end(); ++itr )
for ( FeRomInfoListType::iterator itr=m_list.begin(); itr!=m_list.end(); ++itr )
{
if ( f->apply_filter( *itr ) )
m_filtered_list[i].push_back( &( *itr ) );
@@ -1290,7 +1433,7 @@ void FeRomList::get_file_availability()
std::map<std::string,std::vector<FeRomInfo *> > emu_map;
for ( std::deque<FeRomInfo>::iterator itr=m_list.begin(); itr != m_list.end(); ++itr )
for ( FeRomInfoListType::iterator itr=m_list.begin(); itr != m_list.end(); ++itr )
emu_map[ ((*itr).get_info( FeRomInfo::Emulator )) ].push_back( &(*itr) );
// figure out what roms we have for each emulator
+38 -22
View File
@@ -27,7 +27,7 @@
#include <map>
#include <set>
#include <vector>
#include <deque>
#include <list>
struct SQRex;
extern const char *FE_ROMLIST_FILE_EXTENSION;
@@ -141,7 +141,6 @@ public:
LAST_COMPARISON
};
static const char *indexString;
static const char *filterCompStrings[];
static const char *filterCompDisplayStrings[];
@@ -187,7 +186,7 @@ public:
const std::string &value,
const std::string &fn );
void save( std::ofstream & ) const;
void save( std::ofstream &, const char *filter_tag ) const;
const std::string &get_name() const { return m_name; };
void set_name( const std::string &n ) { m_name = n; };
@@ -198,6 +197,7 @@ public:
void set_size( int s ) { m_size=s; };
std::vector<FeRule> &get_rules() { return m_rules; };
int get_rule_count() const { return m_rules.size(); };
FeRomInfo::Index get_sort_by() const { return m_sort_by; }
bool get_reverse_order() const { return m_reverse_order; }
@@ -209,6 +209,8 @@ public:
bool test_for_target( FeRomInfo::Index target ) const; // do changes to the specified target affect this filter?
void clear();
private:
std::string m_name;
std::vector<FeRule> m_rules;
@@ -221,9 +223,9 @@ private:
};
//
// Class for storing information regarding a specific Attract-Mode list
// Class for storing information regarding a specific Attract-Mode display
//
class FeListInfo : public FeBaseConfigurable
class FeDisplayInfo : public FeBaseConfigurable
{
public:
@@ -234,8 +236,9 @@ public:
LAST_INDEX
};
static const char *indexStrings[];
static const char *otherStrings[];
FeListInfo( const std::string &name );
FeDisplayInfo( const std::string &name );
const std::string &get_info( int ) const;
void set_info( int setting, const std::string &value );
@@ -250,11 +253,13 @@ public:
void set_current_filter_index( int i ) { m_filter_index=i; };
int get_current_filter_index() const { return m_filter_index; };
int get_filter_count() const { return m_filters.size(); };
FeFilter *get_filter( int );
FeFilter *get_filter( int ); // use get_filter( -1 ) to get global filter
void append_filter( const FeFilter &f );
void delete_filter( int i );
void get_filters_list( std::vector<std::string> &l ) const;
FeFilter *get_global_filter() { return &m_global_filter; };
std::string get_current_layout_file() const;
void set_current_layout_file( const std::string & );
@@ -266,38 +271,49 @@ public:
private:
std::string m_info[LAST_INDEX];
std::string m_current_layout_file;
int m_rom_index; // only used if there are no filters on this list
int m_rom_index; // only used if there are no filters on this display
int m_filter_index;
FeFilter *m_current_config_filter;
std::deque< FeFilter > m_filters;
std::vector< FeFilter > m_filters;
FeFilter m_global_filter;
};
class FeEmulatorInfo;
typedef std::list<FeRomInfo> FeRomInfoListType;
class FeRomList : public FeBaseConfigurable
{
private:
std::deque<FeRomInfo> m_list;
std::vector<std::vector<FeRomInfo * > > m_filtered_list;
std::vector<FeEmulatorInfo> m_emulators;
FeRomInfoListType m_list; // this is where we keep the info on all the games available for the current display
std::vector<std::vector<FeRomInfo * > > m_filtered_list; // for each filter, store a pointer to the m_list entries in that filter
std::vector<FeEmulatorInfo> m_emulators; // we keep the emulator info here because we need it for checking file availability
std::map<std::string, bool> m_tags; // bool is flag of whether the tag has been changed
std::set<std::string> m_extra_favs; // store for favourites that are filtered out by global filter
std::multimap< std::string, const char * > m_extra_tags; // store for tags that are filtered out by global filter
FeFilter *m_global_filter_ptr; // this will only get set if we are globally filtering out games during the initial load
std::string m_user_path;
std::string m_romlist_name;
const std::string &m_config_path;
bool m_fav_changed;
bool m_tags_changed;
bool m_availability_checked;
int m_global_filtered_out_count; // for keeping stats during load
FeRomList( const FeRomList & );
FeRomList &operator=( const FeRomList & );
// Fix the filters list as needed given the filters in list_info and a change to "target"
// returns true if potential changes were made
bool fix_filters( FeListInfo &list_info, FeRomInfo::Index target );
// Fixes m_filtered_list as needed using the filters in the given "display", with the
// assumption that the specified "target" attribute for all games might have been changed
//
// returns true if list changes might have been made
//
bool fix_filters( FeDisplayInfo &display, FeRomInfo::Index target );
void save_favs() const;
void save_tags() const;
void save_favs();
void save_tags();
public:
FeRomList( const std::string &config_path );
@@ -309,25 +325,25 @@ public:
const std::string &romlist_name,
const std::string &user_path,
const std::string &stat_path,
FeListInfo &list_info );
FeDisplayInfo &display );
int process_setting( const std::string &setting,
const std::string &value,
const std::string &fn );
void save_state() const;
bool set_fav( int filter_index, int rom_index, FeListInfo &list_info, bool fav );
void save_state();
bool set_fav( int filter_index, int rom_index, FeDisplayInfo &display, bool fav );
void get_tags_list( int filter_index, int idx,
std::vector< std::pair<std::string, bool> > &tags_list ) const;
bool set_tag( int filter_index, int rom_index, FeListInfo &list_info, const std::string &tag, bool flag );
bool set_tag( int filter_index, int rom_index, FeDisplayInfo &display, const std::string &tag, bool flag );
bool is_filter_empty( int filter_idx ) const { return m_filtered_list[filter_idx].empty(); };
int filter_size( int filter_idx ) const { return (int)m_filtered_list[filter_idx].size(); };
const FeRomInfo &lookup( int filter_idx, int idx) const { return *(m_filtered_list[filter_idx][idx]); };
FeRomInfo &lookup( int filter_idx, int idx) { return *(m_filtered_list[filter_idx][idx]); };
std::deque<FeRomInfo> &get_list() { return m_list; };
FeRomInfoListType &get_list() { return m_list; };
void get_file_availability();
+23 -15
View File
@@ -508,9 +508,9 @@ const char *FeInputMap::commandStrings[] =
"down",
"page_up",
"page_down",
"prev_list",
"next_list",
"lists_menu",
"prev_display", // was prev_list
"next_display", // was next_list
"displays_menu", // was lists_menu
"prev_filter",
"next_filter",
"filters_menu",
@@ -549,9 +549,9 @@ const char *FeInputMap::commandDispStrings[] =
"Down",
"Page Up",
"Page Down",
"Previous List",
"Next List",
"Lists Menu",
"Previous Display",
"Next Display",
"Displays Menu",
"Previous Filter",
"Next Filter",
"Filters Menu",
@@ -577,7 +577,7 @@ const char *FeInputMap::commandDispStrings[] =
"Custom 1",
"Custom 2",
NULL, // LAST_COMMAND... NULL required here
"Ambient Sounds",
"Ambient Soundtrack",
"Startup Sound",
"Game Return Sound",
NULL
@@ -605,8 +605,8 @@ void FeInputMap::default_mappings()
{ FeInputSource::Keyboard, sf::Keyboard::Escape, ExitMenu },
{ FeInputSource::Keyboard, sf::Keyboard::Up, Up },
{ FeInputSource::Keyboard, sf::Keyboard::Down, Down },
{ FeInputSource::Keyboard, sf::Keyboard::Left, PrevList },
{ FeInputSource::Keyboard, sf::Keyboard::Right, NextList },
{ FeInputSource::Keyboard, sf::Keyboard::Left, PrevDisplay },
{ FeInputSource::Keyboard, sf::Keyboard::Right, NextDisplay },
{ FeInputSource::Keyboard, sf::Keyboard::Return, Select },
{ FeInputSource::Keyboard, sf::Keyboard::LControl, Select },
{ FeInputSource::Keyboard, sf::Keyboard::Tab, Configure },
@@ -762,19 +762,27 @@ void FeInputMap::save( std::ofstream &f ) const
FeInputMap::Command FeInputMap::string_to_command( const std::string &s )
{
Command cmd( LAST_COMMAND );
int i=0;
while ( FeInputMap::commandStrings[i] != NULL )
{
if ( s.compare( commandStrings[i] ) == 0 )
{
cmd = (Command)i;
break;
}
return (Command)i;
i++;
}
return cmd;
//
// For backward compatability... with 1.5 the "*_list" was switched to "*_display"
//
if ( s.compare( "prev_list" ) == 0 )
return PrevDisplay;
else if ( s.compare( "next_list" ) == 0 )
return NextDisplay;
else if ( s.compare( "displays_menu" ) == 0 )
return DisplaysMenu;
return LAST_COMMAND;
}
// Note the alignment of settingStrings matters in fe_config.cpp
+3 -3
View File
@@ -110,9 +110,9 @@ public:
Down,
PageUp,
PageDown,
PrevList,
NextList,
ListsMenu,
PrevDisplay,
NextDisplay,
DisplaysMenu,
PrevFilter,
NextFilter,
FiltersMenu,
+13 -18
View File
@@ -365,7 +365,7 @@ int FePresent::get_toggle_rotation() const
const char *FePresent::get_display_name() const
{
return m_feSettings->get_current_list_title().c_str();
return m_feSettings->get_current_display_title().c_str();
}
const char *FePresent::get_filter_name() const
@@ -538,9 +538,9 @@ bool FePresent::handle_event( FeInputMap::Command c )
toggle_movie();
break;
case FeInputMap::NextList:
case FeInputMap::PrevList:
if ( m_feSettings->navigate_list( ( c == FeInputMap::NextList ) ? 1 : -1 ) )
case FeInputMap::NextDisplay:
case FeInputMap::PrevDisplay:
if ( m_feSettings->navigate_display( ( c == FeInputMap::NextDisplay ) ? 1 : -1 ) )
load_layout();
else
update_to_new_list();
@@ -692,7 +692,7 @@ void FePresent::load_layout( bool initial_load )
set_transforms();
m_screenSaverActive=false;
if ( m_feSettings->lists_count() < 1 )
if ( m_feSettings->displays_count() < 1 )
return;
//
@@ -788,28 +788,19 @@ void FePresent::set_page_size( int ps )
void FePresent::on_stop_frontend()
{
for ( std::vector<FeBaseTextureContainer *>::iterator itm=m_texturePool.begin();
itm != m_texturePool.end(); ++itm )
(*itm)->set_play_state( false );
set_video_play_state( false );
on_transition( EndLayout, FromToFrontend );
}
void FePresent::pre_run()
{
on_transition( ToGame, FromToNoValue );
for ( std::vector<FeBaseTextureContainer *>::iterator itm=m_texturePool.begin();
itm != m_texturePool.end(); ++itm )
(*itm)->set_play_state( false );
set_video_play_state( false );
}
void FePresent::post_run()
{
for ( std::vector<FeBaseTextureContainer *>::iterator itm=m_texturePool.begin();
itm != m_texturePool.end(); ++itm )
(*itm)->set_play_state( m_playMovies );
set_video_play_state( m_playMovies );
on_transition( FromGame, FromToNoValue );
reset_screen_saver();
@@ -819,10 +810,14 @@ void FePresent::post_run()
void FePresent::toggle_movie()
{
m_playMovies = !m_playMovies;
set_video_play_state( m_playMovies );
}
void FePresent::set_video_play_state( bool state )
{
for ( std::vector<FeBaseTextureContainer *>::iterator itm=m_texturePool.begin();
itm != m_texturePool.end(); ++itm )
(*itm)->set_play_state( m_playMovies );
(*itm)->set_play_state( state );
}
void FePresent::toggle_mute()
+1
View File
@@ -148,6 +148,7 @@ protected:
void set_base_rotation( int );
void set_toggle_rotation( int );
void set_layout_font( const char * );
void set_video_play_state( bool state );
public:
FePresent( FeSettings *fesettings, FeFontContainer &defaultfont );
+169 -156
View File
@@ -111,7 +111,7 @@ const char *FE_PLUGIN_SUBDIR = "plugins/";
const char *FE_LANGUAGE_SUBDIR = "language/";
const char *FE_MODULES_SUBDIR = "modules/";
const char *FE_STATS_SUBDIR = "stats/";
const char *FE_LIST_DEFAULT = "default-list.cfg";
const char *FE_LIST_DEFAULT = "default-display.cfg";
const char *FE_FILTER_DEFAULT = "default-filter.cfg";
const char *FE_CFG_YES_STR = "yes";
const char *FE_CFG_NO_STR = "no";
@@ -170,15 +170,15 @@ const char *FeSettings::windowModeDispTokens[] =
const char *FeSettings::filterWrapTokens[] =
{
"default",
"jump_to_next_list",
"jump_to_next_display",
"no_wrap",
NULL
};
const char *FeSettings::filterWrapDispTokens[] =
{
"Wrap within List (Default)",
"Jump to Next List",
"Wrap within Display (Default)",
"Jump to Next Display",
"No Wrap",
NULL
};
@@ -187,21 +187,21 @@ FeSettings::FeSettings( const std::string &config_path,
const std::string &cmdln_font )
: m_rl( config_path ),
m_inputmap(),
m_current_list( -1 ),
m_current_display( -1 ),
m_current_config_object( NULL ),
m_ssaver_time( 600 ),
m_last_launch_list( 0 ),
m_last_launch_display( 0 ),
m_last_launch_filter( 0 ),
m_last_launch_rom( 0 ),
m_joy_thresh( 75 ),
m_mouse_thresh( 10 ),
m_lists_menu_exit( true ),
m_displays_menu_exit( true ),
m_hide_brackets( false ),
m_autolaunch_last_game( false ),
m_confirm_favs( false ),
m_track_usage( true ),
m_window_mode( Default ),
m_filter_wrap_mode( WrapWithinList ),
m_filter_wrap_mode( WrapWithinDisplay ),
m_accel_selection( true ),
m_selection_speed( 40 )
{
@@ -220,9 +220,9 @@ FeSettings::FeSettings( const std::string &config_path,
void FeSettings::clear()
{
m_current_config_object=NULL;
m_current_list = -1;
m_current_display = -1;
m_lists.clear();
m_displays.clear();
m_rl.clear_emulators();
m_plugins.clear();
}
@@ -291,7 +291,7 @@ void FeSettings::load()
}
load_state();
init_list();
init_display();
// Make sure we have some keyboard mappings
//
@@ -329,7 +329,7 @@ const char *FeSettings::configSettingStrings[] =
"default_font",
"font_path",
"screen_saver_timeout",
"lists_menu_exit",
"displays_menu_exit",
"hide_brackets",
"autolaunch_last_game",
"confirm_favourites",
@@ -345,7 +345,7 @@ const char *FeSettings::configSettingStrings[] =
const char *FeSettings::otherSettingStrings[] =
{
"list",
"display",
"sound",
"input_map",
"general",
@@ -360,11 +360,11 @@ int FeSettings::process_setting( const std::string &setting,
const std::string &value,
const std::string &fn )
{
if ( setting.compare( otherSettingStrings[0] ) == 0 ) // list
if (( setting.compare( otherSettingStrings[0] ) == 0 ) // list
|| ( setting.compare( "list" ) == 0 )) // for backwards compatability. As of 1.5, "list" became "display"
{
FeListInfo newList( value );
m_lists.push_back( newList );
m_current_config_object = &m_lists.back();
m_displays.push_back( FeDisplayInfo( value ) );
m_current_config_object = &m_displays.back();
}
else if ( setting.compare( otherSettingStrings[1] ) == 0 ) // sound
m_current_config_object = &m_sounds;
@@ -419,34 +419,38 @@ int FeSettings::process_setting( const std::string &setting,
return m_current_config_object->process_setting( setting, value, fn );
else
{
// For backwards compatability, as of 1.5 "lists_menu_exit" became "displays_menu_exit"
if ( setting.compare( "lists_menu_exit" ) == 0 )
{
set_info( DisplaysMenuExit, value );
return 0;
}
invalid_setting( fn,
"general", setting, otherSettingStrings, configSettingStrings );
return 1;
}
// shouldn't get here
ASSERT( 0 );
}
return 0;
}
void FeSettings::init_list()
void FeSettings::init_display()
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
{
m_rl.init_as_empty_list();
return;
}
const std::string &romlist_name = m_lists[m_current_list].get_info(FeListInfo::Romlist);
const std::string &romlist_name = m_displays[m_current_display].get_info(FeDisplayInfo::Romlist);
if ( romlist_name.empty() )
{
m_rl.init_as_empty_list();
return;
}
std::cout << std::endl << "*** Initializing display: '" << get_current_list_title() << "'" << std::endl;
std::cout << std::endl << "*** Initializing display: '" << get_current_display_title() << "'" << std::endl;
std::string stat_path;
if ( m_track_usage )
@@ -473,11 +477,11 @@ void FeSettings::init_list()
romlist_name,
user_path,
stat_path,
m_lists[m_current_list] ) == false )
m_displays[m_current_display] ) == false )
std::cerr << "Error opening romlist: " << romlist_name << std::endl;
}
void FeSettings::save_state() const
void FeSettings::save_state()
{
m_rl.save_state();
@@ -489,12 +493,12 @@ void FeSettings::save_state() const
std::ofstream outfile( filename.c_str() );
if ( outfile.is_open() )
{
outfile << m_current_list << ";"
<< m_last_launch_list << "," << m_last_launch_filter
outfile << m_current_display << ";"
<< m_last_launch_display << "," << m_last_launch_filter
<< "," << m_last_launch_rom << std::endl;
for ( std::vector<FeListInfo>::const_iterator itl=m_lists.begin();
itl != m_lists.end(); ++itl )
for ( std::vector<FeDisplayInfo>::const_iterator itl=m_displays.begin();
itl != m_displays.end(); ++itl )
outfile << (*itl).state_as_output() << std::endl;
outfile.close();
@@ -503,9 +507,9 @@ void FeSettings::save_state() const
void FeSettings::load_state()
{
if ( m_lists.empty() )
if ( m_displays.empty() )
{
m_current_list = -1;
m_current_display = -1;
return;
}
@@ -522,7 +526,7 @@ void FeSettings::load_state()
std::string tok;
token_helper( line, pos, tok, ";" );
m_current_list = as_int( tok );
m_current_display = as_int( tok );
int i=0;
while (( pos < line.size() ) && ( i < 3 ))
@@ -532,15 +536,15 @@ void FeSettings::load_state()
switch (i)
{
case 0: m_last_launch_list = temp; break;
case 0: m_last_launch_display = temp; break;
case 1: m_last_launch_filter = temp; break;
case 2: m_last_launch_rom = temp; break;
}
i++;
}
for ( std::vector<FeListInfo>::iterator itl=m_lists.begin();
itl != m_lists.end(); ++itl )
for ( std::vector<FeDisplayInfo>::iterator itl=m_displays.begin();
itl != m_displays.end(); ++itl )
{
if ( myfile.good() )
{
@@ -551,19 +555,19 @@ void FeSettings::load_state()
}
// bound checking on the current list state
if ( m_current_list >= (int)m_lists.size() )
m_current_list = m_lists.size() - 1;
if ( m_current_list < 0 )
m_current_list = 0;
if ( m_current_display >= (int)m_displays.size() )
m_current_display = m_displays.size() - 1;
if ( m_current_display < 0 )
m_current_display = 0;
// bound checking on the last launch state
if ( m_last_launch_list >= (int)m_lists.size() )
m_last_launch_list = m_lists.size() - 1;
if ( m_last_launch_list < 0 )
m_last_launch_list = 0;
if ( m_last_launch_display >= (int)m_displays.size() )
m_last_launch_display = m_displays.size() - 1;
if ( m_last_launch_display < 0 )
m_last_launch_display = 0;
if ( m_last_launch_filter >= m_lists[ m_last_launch_list ].get_filter_count() )
m_last_launch_filter = m_lists[ m_last_launch_list ].get_filter_count() - 1;
if ( m_last_launch_filter >= m_displays[ m_last_launch_display ].get_filter_count() )
m_last_launch_filter = m_displays[ m_last_launch_display ].get_filter_count() - 1;
if ( m_last_launch_filter < 0 )
m_last_launch_filter = 0;
}
@@ -609,10 +613,10 @@ bool FeSettings::test_mouse_reset( int mouse_x, int mouse_y ) const
int FeSettings::get_filter_index_from_offset( int offset ) const
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return 0;
int f_count = m_lists[m_current_list].get_filter_count();
int f_count = m_displays[m_current_display].get_filter_count();
if ( f_count == 0 )
return 0;
@@ -635,10 +639,10 @@ int FeSettings::get_filter_index_from_offset( int offset ) const
int FeSettings::get_filter_count() const
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return 0;
return m_lists[m_current_list].get_filter_count();
return m_displays[m_current_display].get_filter_count();
}
int FeSettings::get_filter_size( int filter_index ) const
@@ -648,10 +652,10 @@ int FeSettings::get_filter_size( int filter_index ) const
int FeSettings::get_rom_index( int filter_index, int offset ) const
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return -1;
int retval = m_lists[m_current_list].get_rom_index( filter_index );
int retval = m_displays[m_current_display].get_rom_index( filter_index );
// keep in bounds
int rl_size = m_rl.filter_size( filter_index );
@@ -679,12 +683,12 @@ int FeSettings::get_rom_index( int filter_index, int offset ) const
return retval;
}
const std::string &FeSettings::get_current_list_title() const
const std::string &FeSettings::get_current_display_title() const
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return FE_EMPTY_STRING;
return m_lists[m_current_list].get_info( FeListInfo::Name );
return m_displays[m_current_display].get_info( FeDisplayInfo::Name );
}
const std::string &FeSettings::get_rom_info( int filter_offset, int rom_offset, FeRomInfo::Index index )
@@ -727,10 +731,10 @@ void FeSettings::get_screensaver_file( std::string &path, std::string &file ) co
std::string FeSettings::get_current_layout_file() const
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return FE_EMPTY_STRING;
std::string file = m_lists[m_current_list].get_current_layout_file();
std::string file = m_displays[m_current_display].get_current_layout_file();
if ( file.empty() )
{
std::vector<std::string> my_list;
@@ -758,13 +762,13 @@ std::string FeSettings::get_current_layout_file() const
std::string FeSettings::get_current_layout_dir() const
{
if (( m_current_list < 0 )
|| ( m_lists[ m_current_list ].get_info( FeListInfo::Layout ).empty() ))
if (( m_current_display < 0 )
|| ( m_displays[ m_current_display ].get_info( FeDisplayInfo::Layout ).empty() ))
{
return FE_EMPTY_STRING;
}
return get_layout_dir( m_lists[ m_current_list ].get_info( FeListInfo::Layout ));
return get_layout_dir( m_displays[ m_current_display ].get_info( FeDisplayInfo::Layout ));
}
std::string FeSettings::get_layout_dir( const std::string &layout_name ) const
@@ -789,13 +793,13 @@ FeLayoutInfo &FeSettings::get_layout_config( const std::string &layout_name )
FeLayoutInfo &FeSettings::get_current_layout_config()
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
{
ASSERT( 0 ); // This should not happen
return get_layout_config( "" );
}
return get_layout_config( m_lists[ m_current_list ].get_info( FeListInfo::Layout ) );
return get_layout_config( m_displays[ m_current_display ].get_info( FeDisplayInfo::Layout ) );
}
const std::string &FeSettings::get_config_dir() const
@@ -812,34 +816,34 @@ bool FeSettings::config_file_exists() const
}
// return true if layout needs to be reloaded as a result
bool FeSettings::set_list( int index )
bool FeSettings::set_display( int index )
{
std::string old = get_current_layout_dir() + get_current_layout_file();
if ( index >= (int)m_lists.size() )
m_current_list = 0;
if ( index >= (int)m_displays.size() )
m_current_display = 0;
else if ( index < 0 )
m_current_list = m_lists.size() - 1;
m_current_display = m_displays.size() - 1;
else
m_current_list = index;
m_current_display = index;
m_rl.save_state();
init_list();
init_display();
return ( old.compare( get_current_layout_dir() + get_current_layout_file() ) != 0 );
}
// return true if layout needs to be reloaded as a result
bool FeSettings::navigate_list( int step, bool wrap_mode )
bool FeSettings::navigate_display( int step, bool wrap_mode )
{
bool retval = set_list( m_current_list + step );
bool retval = set_display( m_current_display + step );
if ( wrap_mode )
{
if ( step > 0 )
set_current_selection( 0, -1 );
else if ( m_current_list >= 0 )
set_current_selection( m_lists[m_current_list].get_filter_count() - 1, -1 );
else if ( m_current_display >= 0 )
set_current_selection( m_displays[m_current_display].get_filter_count() - 1, -1 );
}
return retval;
@@ -848,23 +852,23 @@ bool FeSettings::navigate_list( int step, bool wrap_mode )
// return true if layout needs to be reloaded as a result
bool FeSettings::navigate_filter( int step )
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return false;
int filter_count = m_lists[m_current_list].get_filter_count();
int new_filter = m_lists[m_current_list].get_current_filter_index() + step;
int filter_count = m_displays[m_current_display].get_filter_count();
int new_filter = m_displays[m_current_display].get_current_filter_index() + step;
if ( new_filter >= filter_count )
{
if ( m_filter_wrap_mode == JumpToNextList )
return navigate_list( 1, true );
if ( m_filter_wrap_mode == JumpToNextDisplay )
return navigate_display( 1, true );
new_filter = ( m_filter_wrap_mode == NoWrap ) ? filter_count - 1 : 0;
}
if ( new_filter < 0 )
{
if ( m_filter_wrap_mode == JumpToNextList )
return navigate_list( -1, true );
if ( m_filter_wrap_mode == JumpToNextDisplay )
return navigate_display( -1, true );
new_filter = ( m_filter_wrap_mode == NoWrap ) ? 0 : filter_count - 1;
}
@@ -873,37 +877,37 @@ bool FeSettings::navigate_filter( int step )
return false;
}
int FeSettings::get_current_list_index() const
int FeSettings::get_current_display_index() const
{
return m_current_list;
return m_current_display;
}
// if rom_index < 0, then the rom index is left unchanged and only the filter index is changed
void FeSettings::set_current_selection( int filter_index, int rom_index )
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return;
m_lists[m_current_list].set_current_filter_index( filter_index );
m_displays[m_current_display].set_current_filter_index( filter_index );
if ( rom_index >= 0 )
m_lists[m_current_list].set_rom_index( filter_index, rom_index );
m_displays[m_current_display].set_rom_index( filter_index, rom_index );
}
int FeSettings::get_current_filter_index() const
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return 0;
return m_lists[m_current_list].get_current_filter_index();
return m_displays[m_current_display].get_current_filter_index();
}
const std::string &FeSettings::get_filter_name( int filter_index )
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return FE_EMPTY_STRING;
FeFilter *f = m_lists[m_current_list].get_filter( filter_index );
FeFilter *f = m_displays[m_current_display].get_filter( filter_index );
if ( !f )
return FE_EMPTY_STRING;
@@ -917,11 +921,11 @@ void FeSettings::get_current_sort( FeRomInfo::Index &idx, bool &rev, int &limit
rev = false;
limit = 0;
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return;
FeFilter *f = m_lists[m_current_list].get_filter(
m_lists[m_current_list].get_current_filter_index() );
FeFilter *f = m_displays[m_current_display].get_filter(
m_displays[m_current_display].get_current_filter_index() );
if ( f )
{
@@ -940,9 +944,9 @@ void FeSettings::step_current_selection( int step )
bool FeSettings::select_last_launch()
{
bool retval = false;
if ( m_current_list != m_last_launch_list )
if ( m_current_display != m_last_launch_display )
{
set_list( m_last_launch_list );
set_display( m_last_launch_display );
retval = true;
}
@@ -966,7 +970,7 @@ bool FeSettings::get_current_fav() const
bool FeSettings::set_current_fav( bool status )
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return false;
int filter_index = get_current_filter_index();
@@ -974,7 +978,7 @@ bool FeSettings::set_current_fav( bool status )
return m_rl.set_fav(
filter_index,
get_rom_index( filter_index, 0 ),
m_lists[m_current_list],
m_displays[m_current_display],
status );
}
@@ -1053,7 +1057,7 @@ void FeSettings::get_current_tags_list(
bool FeSettings::set_current_tag(
const std::string &tag, bool flag )
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return false;
int filter_index = get_current_filter_index();
@@ -1061,18 +1065,18 @@ bool FeSettings::set_current_tag(
return m_rl.set_tag(
filter_index,
get_rom_index( filter_index, 0 ),
m_lists[m_current_list],
m_displays[m_current_display],
tag,
flag );
}
void FeSettings::toggle_layout()
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return;
std::vector<std::string> list;
std::string layout_file = m_lists[m_current_list].get_current_layout_file();
std::string layout_file = m_displays[m_current_display].get_current_layout_file();
get_basename_from_extension(
list,
@@ -1099,7 +1103,7 @@ void FeSettings::toggle_layout()
}
layout_file = list[ ( index + 1 ) % list.size() ];
m_lists[ m_current_list ].set_current_layout_file( layout_file );
m_displays[ m_current_display ].set_current_layout_file( layout_file );
}
void FeSettings::set_volume( FeSoundInfo::SoundType t, const std::string &v )
@@ -1176,7 +1180,7 @@ void FeSettings::run( int &minimum_run_seconds )
const std::string &rom_name = rom.get_info( FeRomInfo::Romname );
minimum_run_seconds = as_int( emu->get_info( FeEmulatorInfo::Minimum_run_time ) );
m_last_launch_list = get_current_list_index();
m_last_launch_display = get_current_display_index();
m_last_launch_filter = filter_index;
m_last_launch_rom = rom_index;
@@ -1288,7 +1292,7 @@ void FeSettings::run( int &minimum_run_seconds )
if ( m_track_usage )
{
const std::string rl_name = m_lists[m_current_list].get_info( FeListInfo::Romlist );
const std::string rl_name = m_displays[m_current_display].get_info( FeDisplayInfo::Romlist );
std::string path = m_config_path + FE_STATS_SUBDIR;
confirm_directory( path, rl_name );
@@ -1338,10 +1342,10 @@ void FeSettings::do_text_substitutions_absolute( std::string &str, int filter_in
if ( n > 0 )
{
n -= perform_substitution( str, "[ListTitle]",
get_current_list_title() );
n -= perform_substitution( str, "[DisplayName]",
get_current_display_title() );
n -= perform_substitution( str, "[ListFilterName]",
n -= perform_substitution( str, "[FilterName]",
get_filter_name( filter_index ) );
n -= perform_substitution( str, "[ListSize]",
@@ -1349,7 +1353,16 @@ void FeSettings::do_text_substitutions_absolute( std::string &str, int filter_in
n -= perform_substitution( str, "[ListEntry]",
as_str( rom_index + 1 ) );
}
// [ListTitle] deprecated as of 1.5
n -= perform_substitution( str, "[ListTitle]",
get_current_display_title() );
// [ListFilterName] deprecated as of 1.5
n -= perform_substitution( str, "[ListFilterName]",
get_filter_name( filter_index ) );
}
if ( n > 0 )
{
@@ -1543,19 +1556,19 @@ int FeSettings::get_screen_saver_timeout() const
return m_ssaver_time;
}
bool FeSettings::get_lists_menu_exit() const
bool FeSettings::get_displays_menu_exit() const
{
return m_lists_menu_exit;
return m_displays_menu_exit;
}
void FeSettings::get_list_names( std::vector<std::string> &list ) const
void FeSettings::get_display_names( std::vector<std::string> &list ) const
{
list.clear();
list.reserve( m_lists.size() );
list.reserve( m_displays.size() );
for ( std::vector<FeListInfo>::const_iterator itr=m_lists.begin();
itr < m_lists.end(); ++itr )
list.push_back( (*itr).get_info( FeListInfo::Name ) );
for ( std::vector<FeDisplayInfo>::const_iterator itr=m_displays.begin();
itr < m_displays.end(); ++itr )
list.push_back( (*itr).get_info( FeDisplayInfo::Name ) );
}
const std::string FeSettings::get_info( int index ) const
@@ -1582,8 +1595,8 @@ const std::string FeSettings::get_info( int index ) const
break;
case ScreenSaverTimeout:
return as_str( m_ssaver_time);
case ListsMenuExit:
return ( m_lists_menu_exit ? FE_CFG_YES_STR : FE_CFG_NO_STR );
case DisplaysMenuExit:
return ( m_displays_menu_exit ? FE_CFG_YES_STR : FE_CFG_NO_STR );
case HideBrackets:
return ( m_hide_brackets ? FE_CFG_YES_STR : FE_CFG_NO_STR );
case AutoLaunchLastGame:
@@ -1643,8 +1656,8 @@ bool FeSettings::set_info( int index, const std::string &value )
m_ssaver_time = as_int( value );
break;
case ListsMenuExit:
m_lists_menu_exit = config_str_to_bool( value );
case DisplaysMenuExit:
m_displays_menu_exit = config_str_to_bool( value );
break;
case HideBrackets:
@@ -1733,16 +1746,16 @@ bool FeSettings::set_info( int index, const std::string &value )
}
FeListInfo *FeSettings::get_list( int list_index )
FeDisplayInfo *FeSettings::get_display( int index )
{
if ( ( list_index < 0 ) || ( list_index >= (int)m_lists.size() ))
if ( ( index < 0 ) || ( index >= (int)m_displays.size() ))
return NULL;
std::vector<FeListInfo>::iterator itr=m_lists.begin() + list_index;
std::vector<FeDisplayInfo>::iterator itr=m_displays.begin() + index;
return &(*itr);
}
void FeSettings::create_filter( FeListInfo &l, const std::string &name ) const
void FeSettings::create_filter( FeDisplayInfo &d, const std::string &name ) const
{
FeFilter new_filter( name );
@@ -1750,31 +1763,31 @@ void FeSettings::create_filter( FeListInfo &l, const std::string &name ) const
if ( internal_resolve_config_file( m_config_path, defaults_file, NULL, FE_FILTER_DEFAULT ) )
new_filter.load_from_file( defaults_file );
l.append_filter( new_filter );
d.append_filter( new_filter );
}
FeListInfo *FeSettings::create_list( const std::string &n )
FeDisplayInfo *FeSettings::create_display( const std::string &n )
{
if ( m_current_list == -1 )
m_current_list=0;
if ( m_current_display == -1 )
m_current_display=0;
FeListInfo new_list( n );
FeDisplayInfo new_display( n );
std::string defaults_file;
if ( internal_resolve_config_file( m_config_path, defaults_file, NULL, FE_LIST_DEFAULT ) )
new_list.load_from_file( defaults_file );
new_display.load_from_file( defaults_file );
// If there is no layout set, set a good default one now
//
if ( new_list.get_info( FeListInfo::Layout ).empty() )
if ( new_display.get_info( FeDisplayInfo::Layout ).empty() )
{
if ( !m_lists.empty() )
if ( !m_displays.empty() )
{
// If other lists are configured, give the new list the same layout as
// the last configured list
//
new_list.set_info( FeListInfo::Layout,
m_lists.back().get_info( FeListInfo::Layout ) );
new_display.set_info( FeDisplayInfo::Layout,
m_displays.back().get_info( FeDisplayInfo::Layout ) );
}
else
{
@@ -1783,21 +1796,21 @@ FeListInfo *FeSettings::create_list( const std::string &n )
std::vector<std::string> layouts;
get_layouts_list( layouts ); // the returned list is sorted alphabetically
if ( !layouts.empty() )
new_list.set_info( FeListInfo::Layout, layouts.front() );
new_display.set_info( FeDisplayInfo::Layout, layouts.front() );
}
}
// If there is no romlist set, use the one from the last list created
//
if (( new_list.get_info( FeListInfo::Romlist ).empty() )
&& ( !m_lists.empty() ))
if (( new_display.get_info( FeDisplayInfo::Romlist ).empty() )
&& ( !m_displays.empty() ))
{
new_list.set_info( FeListInfo::Romlist,
m_lists.back().get_info( FeListInfo::Romlist ) );
new_display.set_info( FeDisplayInfo::Romlist,
m_displays.back().get_info( FeDisplayInfo::Romlist ) );
}
m_lists.push_back( new_list );
return &(m_lists.back());
m_displays.push_back( new_display );
return &(m_displays.back());
}
void FeSettings::get_layouts_list( std::vector<std::string> &layouts ) const
@@ -1819,36 +1832,36 @@ void FeSettings::get_layouts_list( std::vector<std::string> &layouts ) const
}
}
void FeSettings::delete_list( int list_index )
void FeSettings::delete_display( int index )
{
if ( ( list_index < 0 ) || ( list_index >= (int)m_lists.size() ))
if ( ( index < 0 ) || ( index >= (int)m_displays.size() ))
return;
std::vector<FeListInfo>::iterator itr=m_lists.begin() + list_index;
m_lists.erase( itr );
std::vector<FeDisplayInfo>::iterator itr=m_displays.begin() + index;
m_displays.erase( itr );
if ( m_current_list >= list_index )
m_current_list--;
if ( m_current_display >= index )
m_current_display--;
if ( m_current_list < 0 )
m_current_list=0;
if ( m_current_display < 0 )
m_current_display=0;
}
void FeSettings::get_current_list_filter_names(
void FeSettings::get_current_display_filter_names(
std::vector<std::string> &list ) const
{
if ( m_current_list < 0 )
if ( m_current_display < 0 )
return;
m_lists[ m_current_list ].get_filters_list( list );
m_displays[ m_current_display ].get_filters_list( list );
}
bool FeSettings::check_romlist_configured( const std::string &n ) const
{
for ( std::vector<FeListInfo>::const_iterator itr=m_lists.begin();
itr!=m_lists.end(); ++itr )
for ( std::vector<FeDisplayInfo>::const_iterator itr=m_displays.begin();
itr!=m_displays.end(); ++itr )
{
if ( n.compare( (*itr).get_info( FeListInfo::Romlist ) ) == 0 )
if ( n.compare( (*itr).get_info( FeDisplayInfo::Romlist ) ) == 0 )
return true;
}
@@ -1877,8 +1890,8 @@ void FeSettings::save() const
outfile << "# Generated by " << FE_NAME << " " << FE_VERSION << std::endl
<< "#" << std::endl;
for ( std::vector<FeListInfo>::const_iterator it=m_lists.begin();
it != m_lists.end(); ++it )
for ( std::vector<FeDisplayInfo>::const_iterator it=m_displays.begin();
it != m_displays.end(); ++it )
{
(*it).save( outfile );
outfile << std::endl;
@@ -1945,9 +1958,9 @@ void FeSettings::get_resource( const std::string &token,
perform_substitution( str, "$1", rep );
}
int FeSettings::lists_count() const
int FeSettings::displays_count() const
{
return m_lists.size();
return m_displays.size();
}
void FeSettings::get_available_plugins( std::vector < std::string > &ll ) const
+23 -23
View File
@@ -60,7 +60,7 @@ public:
static const char *windowModeTokens[];
static const char *windowModeDispTokens[];
enum FilterWrapModeType { WrapWithinList=0, JumpToNextList, NoWrap };
enum FilterWrapModeType { WrapWithinDisplay=0, JumpToNextDisplay, NoWrap };
static const char *filterWrapTokens[];
static const char *filterWrapDispTokens[];
@@ -71,7 +71,7 @@ public:
DefaultFont,
FontPath,
ScreenSaverTimeout,
ListsMenuExit,
DisplaysMenuExit,
HideBrackets,
AutoLaunchLastGame,
ConfirmFavourites,
@@ -95,7 +95,7 @@ private:
std::string m_language;
std::vector<std::string> m_font_paths;
std::vector<FeListInfo> m_lists;
std::vector<FeDisplayInfo> m_displays;
std::vector<FePlugInfo> m_plugins;
std::vector<FeLayoutInfo> m_layout_params;
FeRomList m_rl;
@@ -106,15 +106,15 @@ private:
FeLayoutInfo m_saver_params;
sf::IntRect m_mousecap_rect;
int m_current_list;
int m_current_display;
FeBaseConfigurable *m_current_config_object;
int m_ssaver_time;
int m_last_launch_list;
int m_last_launch_display;
int m_last_launch_filter;
int m_last_launch_rom;
int m_joy_thresh; // [1..100], 100=least sensitive
int m_mouse_thresh; // [1..100], 100=least sensitive
bool m_lists_menu_exit;
bool m_displays_menu_exit;
bool m_hide_brackets;
bool m_autolaunch_last_game;
bool m_confirm_favs;
@@ -131,7 +131,7 @@ private:
const std::string &,
const std::string & );
void init_list();
void init_display();
void load_state();
void clear();
@@ -147,7 +147,7 @@ public:
const std::string &cmdln_font );
void load();
void save_state( void ) const;
void save_state();
FeInputMap::Command map_input( const sf::Event &e );
bool config_map_input( const sf::Event &e, std::string &s, FeInputMap::Command &conflict );
@@ -168,19 +168,19 @@ public:
void step_current_selection( int step );
void set_current_selection( int filter_index, int rom_index ); // use rom_index<0 to only change the filter
// Switches the display list
// returns true if the list change results in a new layout, false otherwise
// Switches the display
// returns true if the display change results in a new layout, false otherwise
//
bool set_list( int index );
int get_current_list_index() const;
int lists_count() const;
bool set_display( int index );
int get_current_display_index() const;
int displays_count() const;
bool navigate_list( int step, bool wrap_mode=false );
bool navigate_display( int step, bool wrap_mode=false );
bool navigate_filter( int step );
int get_current_filter_index() const;
const std::string &get_filter_name( int filter_index );
void get_current_list_filter_names( std::vector<std::string> &list ) const;
void get_current_display_filter_names( std::vector<std::string> &list ) const;
int get_filter_index_from_offset( int offset ) const;
int get_filter_size( int filter_index ) const;
int get_filter_count() const;
@@ -202,7 +202,7 @@ public:
void get_current_sort( FeRomInfo::Index &idx, bool &rev, int &limit );
const std::string &get_current_list_title() const;
const std::string &get_current_display_title() const;
const std::string &get_rom_info( int filter_offset, int rom_offset, FeRomInfo::Index index );
const std::string &get_rom_info_absolute( int filter_index, int rom_index, FeRomInfo::Index index );
bool hide_brackets() const { return m_hide_brackets; }
@@ -236,7 +236,7 @@ public:
WindowType get_window_mode() const;
FilterWrapModeType get_filter_wrap_mode() const;
int get_screen_saver_timeout() const;
bool get_lists_menu_exit() const;
bool get_displays_menu_exit() const;
bool get_current_fav() const;
@@ -253,7 +253,7 @@ public:
void get_current_tags_list(
std::vector< std::pair<std::string, bool> > &tags_list ) const;
// returns true if the current list chnaged as a result of setting the tag
// returns true if the current list changed as a result of setting the tag
bool set_current_tag(
const std::string &tag, bool flag );
//
@@ -281,12 +281,12 @@ public:
const std::string get_info( int index ) const; // see "ConfigSettingIndex"
bool set_info( int index, const std::string & );
void get_list_names( std::vector<std::string> &list ) const;
FeListInfo *get_list( int index );
FeListInfo *create_list( const std::string &n );
void delete_list( int index );
void get_display_names( std::vector<std::string> &d ) const;
FeDisplayInfo *get_display( int index );
FeDisplayInfo *create_display( const std::string &n );
void delete_display( int index );
void create_filter( FeListInfo &l, const std::string &name ) const;
void create_filter( FeDisplayInfo &l, const std::string &name ) const;
// return true if specified romlist name is configured for use as a display
// list
+19 -29
View File
@@ -414,13 +414,15 @@ void FeVM::on_new_layout( const std::string &path,
fe.Bind( _SC("CurrentList"), Class <FePresent, NoConstructor>()
.Prop( _SC("name"), &FePresent::get_display_name )
.Prop( _SC("filter"), &FePresent::get_filter_name )
.Prop( _SC("size"), &FePresent::get_list_size )
.Prop( _SC("index"), &FePresent::get_selection_index, &FePresent::set_selection_index )
.Prop( _SC("sort_by"), &FePresent::get_sort_by )
.Prop( _SC("reverse_order"), &FePresent::get_reverse_order )
.Prop( _SC("list_limit"), &FePresent::get_list_limit )
.Prop( _SC("filter_index"), &FePresent::get_filter_index, &FePresent::set_filter_index )
// The following are deprecated as of version 1.5 in favour of using the fe.filters array:
.Prop( _SC("filter"), &FePresent::get_filter_name ) // deprecated as of 1.5
.Prop( _SC("size"), &FePresent::get_list_size ) // deprecated as of 1.5
.Prop( _SC("sort_by"), &FePresent::get_sort_by ) // deprecated as of 1.5
.Prop( _SC("reverse_order"), &FePresent::get_reverse_order ) // deprecated as of 1.5
.Prop( _SC("list_limit"), &FePresent::get_list_limit ) // deprecated as of 1.5
);
fe.Bind( _SC("Overlay"), Class <FeVM, NoConstructor>()
@@ -460,6 +462,9 @@ void FeVM::on_new_layout( const std::string &path,
.Prop( _SC("name"), &FeFilter::get_name )
.Prop( _SC("index"), &FeFilter::get_rom_index )
.Prop( _SC("size"), &FeFilter::get_size )
.Prop( _SC("sort_by"), &FeFilter::get_sort_by )
.Prop( _SC("reverse_order"), &FeFilter::get_reverse_order )
.Prop( _SC("list_limit"), &FeFilter::get_list_limit )
);
//
@@ -509,14 +514,14 @@ void FeVM::on_new_layout( const std::string &path,
//
// Define variables that get exposed to Squirrel
//
FeListInfo *li = m_feSettings->get_list( m_feSettings->get_current_list_index() );
FeDisplayInfo *di = m_feSettings->get_display( m_feSettings->get_current_display_index() );
Table ftab; // hack Table to Array because creating the Array straight up doesn't work
fe.Bind( _SC("filters"), ftab );
Array farray( ftab.GetObject() );
for ( int i=0; i < li->get_filter_count(); i++ )
farray.SetInstance( farray.GetSize(), li->get_filter( i ) );
for ( int i=0; i < di->get_filter_count(); i++ )
farray.SetInstance( farray.GetSize(), di->get_filter( i ) );
fe.SetInstance( _SC("layout"), (FePresent *)this );
fe.SetInstance( _SC("list"), (FePresent *)this );
@@ -1474,27 +1479,14 @@ void FeVM::cb_signal( const char *sig )
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
FeVM *fev = (FeVM *)sq_getforeignptr( vm );
//
// First check for signals corresponding to input actions
//
int i=0, index=-1;
while ( FeInputMap::commandStrings[i] != 0 )
{
if ( strcmp( FeInputMap::commandStrings[i], sig ) == 0 )
{
index = i;
break;
}
i++;
}
if ( index > -1 )
FeInputMap::Command c = FeInputMap::string_to_command( sig );
if ( c != FeInputMap::LAST_COMMAND )
{
//
// Post the command so it can be handled the next time we are
// processing events...
//
fev->m_posted_commands.push( (FeInputMap::Command)index );
fev->m_posted_commands.push( c );
return;
}
@@ -1507,18 +1499,16 @@ void FeVM::cb_signal( const char *sig )
NULL
};
i=0;
int i=0;
while ( signals[i] != 0 )
{
if ( strcmp( signals[i], sig ) == 0 )
{
index = i;
break;
}
i++;
}
switch (index)
switch (i)
{
case 0: // "reset_window"
fev->m_window.on_exit();
+9 -9
View File
@@ -116,7 +116,7 @@ bool FeMapComp::operator()(const char *lhs, const char *rhs) const
// Mame XML Parser
//
FeMameXMLParser::FeMameXMLParser(
std::list <FeRomInfo> &romlist,
FeRomInfoListType &romlist,
UiUpdate u,
void *d )
: FeXMLParser( u, d ),
@@ -140,7 +140,7 @@ void FeMameXMLParser::start_element(
{
if ( strcmp( attribute[i], "name" ) == 0 )
{
std::map<const char *, std::list<FeRomInfo>::iterator, FeMapComp>::iterator itr;
std::map<const char *, FeRomInfoListType::iterator, FeMapComp>::iterator itr;
itr = m_map.find( attribute[i+1] );
if ( itr != m_map.end() )
{
@@ -346,14 +346,14 @@ void FeMameXMLParser::end_element( const char *element )
bool FeMameXMLParser::parse( const std::string &prog )
{
std::string base_args = "-listxml";
std::list<FeRomInfo>::iterator itr;
FeRomInfoListType::iterator itr;
m_percent=m_count=0;
//
// run "mame -listxml" and find each rom.
//
m_map.clear();
for ( std::list<FeRomInfo>::iterator itr=m_romlist.begin();
for ( FeRomInfoListType::iterator itr=m_romlist.begin();
itr != m_romlist.end(); ++itr )
m_map[ (*itr).get_info( FeRomInfo::Romname ).c_str() ] = itr;
@@ -371,7 +371,7 @@ bool FeMameXMLParser::parse( const std::string &prog )
{
std::cout << "Discarded " << m_discarded.size()
<< " entries based on xml info: ";
std::vector<std::list<FeRomInfo>::iterator>::iterator itr;
std::vector<FeRomInfoListType::iterator>::iterator itr;
for ( itr = m_discarded.begin(); itr != m_discarded.end(); ++itr )
{
std::cout << (*(*itr)).get_info( FeRomInfo::Romname ) << " ";
@@ -387,7 +387,7 @@ bool FeMameXMLParser::parse( const std::string &prog )
// Mess XML Parser
//
FeMessXMLParser::FeMessXMLParser(
std::list <FeRomInfo> &romlist,
FeRomInfoListType &romlist,
UiUpdate u,
void *d )
: FeXMLParser( u, d ), m_romlist( romlist )
@@ -528,13 +528,13 @@ bool FeMessXMLParser::parse( const std::string &prog,
{
// First get our machine -listxml settings
//
std::list<FeRomInfo> temp_list;
FeRomInfoListType temp_list;
temp_list.push_back( FeRomInfo( system_name ) );
FeMameXMLParser listxml( temp_list );
listxml.parse( prog );
std::list<FeRomInfo>::iterator itr;
FeRomInfoListType::iterator itr;
if ( !temp_list.empty() )
{
const FeRomInfo &ri = temp_list.front();
@@ -570,7 +570,7 @@ bool FeMessXMLParser::parse( const std::string &prog,
return retval;
}
FeHyperSpinXMLParser::FeHyperSpinXMLParser( std::list<FeRomInfo> & li )
FeHyperSpinXMLParser::FeHyperSpinXMLParser( FeRomInfoListType & li )
: m_romlist( li ), m_collect_data( false )
{
}
+10 -10
View File
@@ -73,14 +73,14 @@ public:
class FeMameXMLParser : private FeXMLParser
{
public:
FeMameXMLParser( std::list<FeRomInfo> &, UiUpdate u=NULL, void *d=NULL );
FeMameXMLParser( FeRomInfoListType &, UiUpdate u=NULL, void *d=NULL );
bool parse( const std::string &base_command );
private:
std::list<FeRomInfo> &m_romlist;
std::list<FeRomInfo>::iterator m_itr;
std::map<const char *, std::list<FeRomInfo>::iterator, FeMapComp> m_map;
std::vector<std::list<FeRomInfo>::iterator> m_discarded;
FeRomInfoListType &m_romlist;
FeRomInfoListType::iterator m_itr;
std::map<const char *, FeRomInfoListType::iterator, FeMapComp> m_map;
std::vector<FeRomInfoListType::iterator> m_discarded;
int m_count;
int m_percent;
int m_displays;
@@ -95,12 +95,12 @@ private:
class FeMessXMLParser : private FeXMLParser
{
public:
FeMessXMLParser( std::list<FeRomInfo> &, UiUpdate u=NULL, void *d=NULL );
FeMessXMLParser( FeRomInfoListType &, UiUpdate u=NULL, void *d=NULL );
bool parse( const std::string &command, const std::string &args );
private:
std::list<FeRomInfo> &m_romlist;
std::list<FeRomInfo>::iterator m_itr;
FeRomInfoListType &m_romlist;
FeRomInfoListType::iterator m_itr;
std::string m_name;
std::string m_description;
std::string m_year;
@@ -120,14 +120,14 @@ private:
class FeHyperSpinXMLParser : private FeXMLParser
{
public:
FeHyperSpinXMLParser( std::list<FeRomInfo> & );
FeHyperSpinXMLParser( FeRomInfoListType & );
bool parse( const std::string &filename );
private:
void start_element( const char *, const char ** );
void end_element( const char * );
std::list<FeRomInfo> &m_romlist;
FeRomInfoListType &m_romlist;
FeRomInfo m_current_rom;
bool m_collect_data;
};
+9 -9
View File
@@ -291,7 +291,7 @@ int main(int argc, char *argv[])
// go straight into config mode if there are no lists configured for
// display
//
bool config_mode = ( feSettings.lists_count() < 1 );
bool config_mode = ( feSettings.displays_count() < 1 );
while (window.isOpen() && (!exit_selected))
{
@@ -308,8 +308,8 @@ int main(int argc, char *argv[])
if ( feSettings.get_font_file( defaultFontFile ) )
defaultFont.set_font( defaultFontFile );
feSettings.set_list(
feSettings.get_current_list_index() );
feSettings.set_display(
feSettings.get_current_display_index() );
feVM.load_layout();
@@ -506,16 +506,16 @@ int main(int argc, char *argv[])
config_mode = true;
break;
case FeInputMap::ListsMenu:
case FeInputMap::DisplaysMenu:
{
std::vector<std::string> names_list;
feSettings.get_list_names( names_list );
feSettings.get_display_names( names_list );
std::string title;
feSettings.get_resource( "Lists", title );
int last_list = names_list.size() - 1;
if ( feSettings.get_lists_menu_exit() )
if ( feSettings.get_displays_menu_exit() )
{
//
// Add an exit option at the end of the lists menu
@@ -528,7 +528,7 @@ int main(int argc, char *argv[])
int list_index = feOverlay.common_list_dialog(
title,
names_list,
feSettings.get_current_list_index(),
feSettings.get_current_display_index(),
names_list.size() - 1 );
// test if the exit option selected, return -2 if it has been
@@ -548,7 +548,7 @@ int main(int argc, char *argv[])
}
else
{
if ( feSettings.set_list( list_index ) )
if ( feSettings.set_display( list_index ) )
feVM.load_layout();
else
feVM.update_to_new_list();
@@ -560,7 +560,7 @@ int main(int argc, char *argv[])
case FeInputMap::FiltersMenu:
{
std::vector<std::string> names_list;
feSettings.get_current_list_filter_names( names_list );
feSettings.get_current_display_filter_names( names_list );
std::string title;
feSettings.get_resource( "Filters", title );