5 * Copyright (C) 2010-2011 Scott Smith
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #define SCREEN_FLAGS SDL_SWSURFACE /**< Basic SDL screen flags. */
32 #define BASE_WIDTH 320 /**< Minimum screen width size (pixels). */
33 #define BASE_HEIGHT 240 /**< Maximum screen height size (pixels). */
34 #if defined(PANDORA) || defined(X86)
35 #define SCREEN_WIDTH 800 /**< Default screen width for Pandora and PC (pixels). */
36 #define SCREEN_HEIGHT 480 /**< Default screen height for Pandora and PC (pixels). */
38 #define SCREEN_WIDTH BASE_WIDTH /**< Default screen width for any other device (pixels). */
39 #define SCREEN_HEIGHT BASE_HEIGHT /**< Default screen height for any other device (pixels). */
41 #define SCREEN_DEPTH 16 /**< Default screen depth for any device (bits per pixel). */
42 #define REFRESH_DELAY 10 /**< Default screen depth for any device (millseconds). */
43 #define MAX_ENTRIES 10 /**< Default maximum entries in the display list. */
44 #define SCROLL_SPEED 2 /**< Default speed for scrolling text. */
45 #define SCROLL_PAUSE_SPEED 100 /**< Default speed for pausing scrolling text when left or right ends are reached. */
46 #define DEAD_ZONE 10000 /**< Default analog joystick deadzone. */
47 #define DELIMITER ";" /**< Default profile delimiter. */
48 #define CFG_LBL_W 30 /**< Mininum character width for the profile label. */
49 #define CFG_VAL_W 30 /**< Mininum character width for the profile value. */
51 // GUI Options Defaults
52 #define ENTRY_Y_DELTA (2*ScreenRatioH) /** Scaled pixel amount used between entries. */
53 #define ENTRY_X_OFFSET (8*ScreenRatioW) /** Scaled pixel amount used to separate gui elements along the X axis. */
54 #define ENTRY_Y_OFFSET (8*ScreenRatioH) /** Scaled pixel amount used to separate gui elements along the Y axis. */
56 #define BUTTONS_MAX_LEFT 7 /** Number of buttons on the left side of the GUI. */
57 #define BUTTONS_MAX_RIGHT 4 /** Number of buttons on the right side of the GUI. */
59 #define BUTTON_W_LEFT (25*ScreenRatioW) /** Scaled pixel width for buttons on the left side. */
60 #define BUTTON_H_LEFT (15*ScreenRatioH) /** Scaled pixel hieght for buttons on the left side. */
61 #define BUTTON_W_RIGHT (80*ScreenRatioW) /** Scaled pixel width for buttons on the right side. */
62 #define BUTTON_H_RIGHT (30*ScreenRatioH) /** Scaled pixel hieght for buttons on the right side. */
64 #define PREVIEW_W (80*ScreenRatioW) /** Scaled pixel width for the preview image. */
65 #define PREVIEW_H (60*ScreenRatioH) /** Scaled pixel height for the preview image. */
67 #define ENTRY_MAX_W (ScreenWidth-(BUTTON_W_RIGHT)-(ENTRY_X_OFFSET*2)) /** Max scaled pixel width for an entry. */
68 #define FILEPATH_MAX_W (ScreenWidth-(ENTRY_X_OFFSET*2)) /** Max scaled pixel width for an the current path. */
70 #define HELP_DEFAULT ""
73 #define OPT_SCREEN_WIDTH "screen_width"
74 #define HELP_SCREEN_WIDTH "Screen width in pixels."
76 #define OPT_SCREEN_HEIGHT "screen_height"
77 #define HELP_SCREEN_HEIGHT "Screen height in pixels."
79 #define OPT_SCREEN_DEPTH "screen_depth"
80 #define HELP_SCREEN_DEPTH "Screen depth in bits per pixel."
82 #define OPT_REFRESH_DELAY "refresh_delay"
83 #define HELP_REFRESH_DELAY "Delay in milliseconds after a screen flip."
85 #define OPT_FULLSCREEN "fullscreen"
86 #define HELP_FULLSCREEN "True if screen is set to fullscreen mode, otherwise false."
89 #define OPT_CPU_CLOCK "cpu_clock"
90 #define HELP_CPU_CLOCK "If supported, will set the CPU to clock value in Mhz."
92 #define OPT_USEZIPSUPPORT "use_zip_support"
93 #define HELP_USEZIPSUPPORT "True if launcher uses internal zip support."
95 #define OPT_SHOWEXTS "show_exts"
96 #define HELP_SHOWEXTS "True if the selector should show file extensions in the filenames, otherwise false."
98 #define OPT_SHOWHIDDEN "show_hidden"
99 #define HELP_SHOWHIDDEN "True if the selector should show hidden files and folders in the display list, otherwise false."
101 #define OPT_SHOWPOINTER "show_pointer"
102 #define HELP_SHOWPOINTER "True if the selector should show the SDL pointer, otherwise false."
104 #define OPT_SHOWLABELS "show_labels"
105 #define HELP_SHOWLABELS "True if the selector should show the button text ttf labels, otherwise false."
107 #define OPT_UNUSED_KEYS_SELECT "unused_keys_select"
108 #define HELP_UNUSED_KEYS_SELECT "True if any unmapped key events should cause the application launch, otherwise false."
110 #define OPT_UNUSED_JOYS_SELECT "unused_buttons_select"
111 #define HELP_UNUSED_JOYS_SELECT "True if any unmapped button events should cause the application launch, otherwise false."
113 #define OPT_RELOAD_LAUNCHER "reload_launcher"
114 #define HELP_RELOAD_LAUNCHER "True if the launcher should reload following the shutdown of the target application, otherwise false."
116 #define OPT_TEXT_SCROLL_OPTION "text_scroll_option"
117 #define HELP_TEXT_SCROLL_OPTION "True if horizontal the text scroll option should enabled, otherwise false."
119 #define OPT_FILENAMEARGNOEXT "filename_arg_no_ext"
120 #define HELP_FILENAMEARGNOEXT "True if the extension for file to be loaded is removed, else the extension is not removed from the filename."
122 #define OPT_FILEABSPATH "file_abs_path"
123 #define HELP_FILEABSPATH "True if the absolute path for the file location should be used to calling the filname, else the path is omitted."
125 #define OPT_ENTRY_FAST_MODE "entry_fast_mode"
126 #define HELP_ENTRY_FAST_MODE "Fast entry navagation mode, where 0 for alphabetic mode 1 for search filter"
128 #define OPT_MAX_ENTRIES "max_entries"
129 #define HELP_MAX_ENTRIES "Maximum number of entries to be in the display list."
131 #define OPT_SCROLL_SPEED "scroll_speed"
132 #define HELP_SCROLL_SPEED "The speed of the horizontal the text scroll speed, lower faster, higher slower.."
134 #define OPT_SCROLL_PAUSE_SPEED "scroll_pause_speed"
135 #define HELP_SCROLL_PAUSE_SPEED "The time delay of the horizontal the text scroll when the left/right ends are reached, lower shorter, higher longer."
137 #define OPT_PROFILE_DELIMITER "profile_delimiter"
138 #define HELP_PROFILE_DELIMITER "Delimiter character"
141 #define OPT_AUTOLAYOUT "autolayout"
142 #define HELP_AUTOLAYOUT "True if the launcher should auto position gui elements, if false manual positions are used."
144 #define OPT_POSX_TITLE "posx_title"
145 #define OPT_POSY_TITLE "posy_title"
146 #define OPT_POSX_BTNLEFT "posx_btnleft"
147 #define OPT_POSY_BTNLEFT "posy_btnleft"
148 #define OPT_POSX_BTNRIGHT "posx_btnright"
149 #define OPT_POSY_BTNRIGHT "posy_btnright"
150 #define OPT_POSX_LISTNAMES "posx_listnames"
151 #define OPT_POSY_LISTNAMES "posy_listnames"
153 #define HELP_POSX_TITLE "X coordinate in the upper left corner"
154 #define HELP_POSY_TITLE "Y coordinate in the upper left corner"
155 #define HELP_POSX_BTNLEFT "X coordinate in the upper left corner"
156 #define HELP_POSY_BTNLEFT "Y coordinate in the upper left corner"
157 #define HELP_POSX_BTNRIGHT "X coordinate in the bottom left corner"
158 #define HELP_POSY_BTNRIGHT "Y coordinate in the bottom left corner"
159 #define HELP_POSX_LISTNAMES "X coordinate in the upper left corner"
160 #define HELP_POSY_LISTNAMES "Y coordinate in the upper left corner"
163 #define OPT_ENTRY_Y_DELTA "entry_y_delta"
164 #define OPT_ENTRY_X_OFFSET "entry_x_offset"
165 #define OPT_ENTRY_Y_OFFSET "entry_y_offset"
166 #define OPT_BUTTON_W_LEFT "button_w_left"
167 #define OPT_BUTTON_H_LEFT "button_h_left"
168 #define OPT_BUTTON_W_RIGHT "button_w_right"
169 #define OPT_BUTTON_H_RIGHT "button_h_right"
170 #define OPT_PREVIEW_W "preview_w"
171 #define OPT_PREVIEW_H "preview_h"
172 #define OPT_ENTRY_MAX_W "entry_max_w"
173 #define OPT_FILEPATH_MAX_W "filepath_max_w"
175 #define OPT_BUTTONLEFT_ENABLED "buttonleft_enable"
176 #define OPT_BUTTONRIGHT_ENABLED "buttonright_enable"
178 #define HELP_ENTRY_Y_DELTA "todo"
179 #define HELP_ENTRY_X_OFFSET "todo"
180 #define HELP_ENTRY_Y_OFFSET "todo"
181 #define HELP_BUTTON_W_LEFT "todo"
182 #define HELP_BUTTON_H_LEFT "todo"
183 #define HELP_BUTTON_W_RIGHT "todo"
184 #define HELP_BUTTON_H_RIGHT "todo"
185 #define HELP_PREVIEW_W "todo"
186 #define HELP_PREVIEW_H "todo"
187 #define HELP_ENTRY_MAX_W "todo"
188 #define HELP_FILEPATH_MAX_W "todo"
191 #define OPT_PATH_ZIPTEMP "zip_temp_path"
192 #define HELP_PATH_ZIPTEMP "Path to store extracted files from zip."
194 #define OPT_PATH_PREVIEWS "previews_path"
195 #define HELP_PATH_PREVIEWS "Path to read preview graphics."
197 #define OPT_PATH_FONT "font_path"
198 #define HELP_PATH_FONT "Path to ttf font file."
200 #define OPT_FONT_SIZE_SMALL "font_size_small"
201 #define HELP_FONT_SIZE_SMALL "Font size identified as small."
203 #define OPT_FONT_SIZE_MEDIUM "font_size_medium"
204 #define HELP_FONT_SIZE_MEDIUM "Font size identified as medium."
206 #define OPT_FONT_SIZE_LARGE "font_size_large"
207 #define HELP_FONT_SIZE_LARGE "Font size identified as large."
209 #define OPT_PATH_BACKGND "image_background"
210 #define HELP_PATH_BACKGND "Path to background graphic."
212 #define OPT_PATH_POINTER "image_pointer"
213 #define HELP_PATH_POINTER "Path to pointer graphic"
215 #define OPT_PATH_SELECTPOINTER "image_selectpointer"
216 #define HELP_PATH_SELECTPOINTER "Path to selector pointer graphic"
218 #define OPT_PATH_ONEUP "image_upone"
219 #define HELP_PATH_ONEUP "Path to button graphic for one up."
221 #define OPT_PATH_ONEDN "image_downone"
222 #define HELP_PATH_ONEDN "Path to button graphic for one down."
224 #define OPT_PATH_PGUP "image_pageup"
225 #define HELP_PATH_PGUP "Path to button graphic for page up."
227 #define OPT_PATH_PGDN "image_pagedown"
228 #define HELP_PATH_PGDN "Path to button graphic for page down."
230 #define OPT_PATH_DIRUP "image_dirup"
231 #define HELP_PATH_DIRUP "Path to button graphic for dir up."
233 #define OPT_PATH_DIRDN "image_dirdown"
234 #define HELP_PATH_DIRDN "Path to button graphic for dir down."
236 #define OPT_PATH_CFG_APP "image_cfgapp"
237 #define HELP_PATH_CFG_APP "Path to button graphic for cfg app."
239 #define OPT_PATH_CFG_ITEM "image_cfgitem"
240 #define HELP_PATH_CFG_ITEM "Path to button graphic for cfg item."
242 #define OPT_PATH_SELECT "image_select"
243 #define HELP_PATH_SELECT "Path to button graphic for cfg select."
245 #define OPT_PATH_QUIT "image_quit"
246 #define HELP_PATH_QUIT "Path to button graphic for quit."
249 #define OPT_COLOR_BUTTON "color_buttons"
250 #define HELP_COLOR_BUTTON "Color index used for the coloring the fallback button."
252 #define OPT_COLOR_FONTBUTTON "color_fontbuttons"
253 #define HELP_COLOR_FONTBUTTON "Color index used for the coloring the font used in the fallback button."
255 #define OPT_COLOR_BACKGND "color_background"
256 #define HELP_COLOR_BACKGND "Color index used for the coloring the screen background. "
258 #define OPT_COLOR_FONTFILES "color_fontfiles"
259 #define HELP_COLOR_FONTFILES "Color index used for the coloring the entries that are files."
261 #define OPT_COLOR_FONTFOLDERS "color_fontfolders"
262 #define HELP_COLOR_FONTFOLDERS "Color index used for the coloring the entries that are folders."
265 #define OPT_KEYUP "key_up"
266 #define OPT_KEYDOWN "key_down"
267 #define OPT_KEYLEFT "key_left"
268 #define OPT_KEYRIGHT "key_right"
269 #define OPT_KEYDIRUP "key_dirup"
270 #define OPT_KEYDIRDOWN "key_dirdown"
271 #define OPT_KEYCFGENTRY "key_cfgentry"
272 #define OPT_KEYCFGAPP "key_cfgapp"
273 #define OPT_KEYSETONE "key_setone"
274 #define OPT_KEYSETALL "key_setall"
275 #define OPT_KEYSELECT "key_select"
276 #define OPT_KEYBACK "key_back"
277 #define OPT_KEYQUIT "key_quit"
280 #define OPT_JOYUP "button_up"
281 #define OPT_JOYDOWN "button_down"
282 #define OPT_JOYLEFT "button_left"
283 #define OPT_JOYRIGHT "button_right"
284 #define OPT_JOYDIRUP "button_dirup"
285 #define OPT_JOYDIRDOWN "button_dirdown"
286 #define OPT_JOYCFGENTRY "button_cfgentry"
287 #define OPT_JOYCFGAPP "button_cfgapp"
288 #define OPT_JOYSETONE "button_setone"
289 #define OPT_JOYSETALL "button_setall"
290 #define OPT_JOYSELECT "button_select"
291 #define OPT_JOYBACK "button_back"
292 #define OPT_JOYQUIT "button_quit"
294 #define OPT_DEADZONE "deadzone"
295 #define HELP_DEADZONE "Deadzone for analog joysticks."
297 /** @brief Internal user events
300 EVENT_ONE_UP=0, /**< 0 Move selection one item up. */
301 EVENT_ONE_DOWN, /**< 1 Move selection one item down. */
302 EVENT_PAGE_UP, /**< 2 Move selection one page up. */
303 EVENT_PAGE_DOWN, /**< 3 Move selection one page down. */
304 EVENT_DIR_UP, /**< 4 Move current path one directory up. */
305 EVENT_DIR_DOWN, /**< 5 Move current path one directory down. */
306 EVENT_ZIP_MODE, /**< 6 Mode to use when extracing files from a zip. */
307 EVENT_CFG_APP, /**< 7 Enter mode to configure the launcher. */
308 EVENT_CFG_ITEM, /**< 8 Enter mode to configure an entry. */
309 EVENT_SET_ONE, /**< 9 For an argument set selected value for the current entry. */
310 EVENT_SET_ALL, /**< 10 For an argument set selected value for the all entry. */
311 EVENT_SELECT, /**< 11 Select the current item. */
312 EVENT_BACK, /**< 12 Go back from the current mode and return to the previous mode. */
313 EVENT_QUIT, /**< 13 Quit the launcher. */
314 EVENT_TOTAL, /**< 14 Total number of events. */
315 EVENT_NONE /**< 15 No event. */
318 /** @brief Mode for navagating to an entry quickly.
320 enum ENTRY_FAST_MODE_T {
321 ENTRY_FAST_MODE_ALPHA=0,
322 ENTRY_FAST_MODE_FILTER
325 /** @brief Basic colors
347 /** @brief Font sizes
356 /** @brief Class that handles loading and saving of all configurable options
358 class CConfig : public CBase
366 /** @brief Set configuration options to calculated defaults
368 void SetDefaults ( void );
370 /** @brief Load the configuration option from file
371 * @param location : path and filename to config file
372 * @return 0 no errors or 1 if an error is detected
374 int8_t Load ( const string& location );
376 /** @brief Save the configuration option from file
377 * @param location : path and filename to config file
378 * @return 0 no errors or 1 if an error is detected
380 int8_t Save ( const string& location );
382 bool ResetGUI; /**< NOT CONFIGURABLE Set via argument and uses scaled defaults and not config file */
383 bool Fullscreen; /**< CONFIGURABLE Refer to HELP_FULLSCREEN */
384 bool ScreenFlip; /**< CONFIGURABLE Refer to HELP_SCREENFLIP */
385 bool UseZipSupport; /**< CONFIGURABLE Refer to HELP_USEZIPSUPPORT */
386 bool ShowExts; /**< CONFIGURABLE Refer to HELP_SHOWEXTS */
387 bool ShowHidden; /**< CONFIGURABLE Refer to HELP_SHOWHIDDEN */
388 bool ShowPointer; /**< CONFIGURABLE Refer to HELP_SHOWPOINTER */
389 bool ShowLabels; /**< CONFIGURABLE Refer to HELP_SHOWLABELS */
390 bool UnusedKeysLaunch; /**< CONFIGURABLE Refer to HELP_UNUSED_KEYS_SELECT */
391 bool UnusedJoysLaunch; /**< CONFIGURABLE Refer to HELP_UNUSED_JOYS_SELECT */
392 bool ReloadLauncher; /**< CONFIGURABLE Refer to HELP_RELOAD_LAUNCHER */
393 bool TextScrollOption; /**< CONFIGURABLE Refer to HELP_TEXT_SCROLL_OPTION */
394 bool AutoLayout; /**< CONFIGURABLE Refer to HELP_AUTOLAYOUT */
395 bool FilenameArgNoExt; /**< CONFIGURABLE Refer to HELP_FILENAMEARGNOEXT */
396 bool FilenameAbsPath; /**< CONFIGURABLE Refer to HELP_FILEABSPATH */
397 uint8_t EntryFastMode; /**< CONFIGURABLE Refer to HELP_ENTRY_FAST_MODE */
398 uint8_t MaxEntries; /**< CONFIGURABLE Refer to HELP_MAX_ENTRIES */
399 uint8_t ColorButton; /**< CONFIGURABLE Refer to HELP_COLOR_BUTTON */
400 uint8_t ColorFontButton; /**< CONFIGURABLE Refer to HELP_COLOR_FONTBUTTON */
401 uint8_t ColorBackground; /**< CONFIGURABLE Refer to HELP_COLOR_BACKGND */
402 uint8_t ColorFontFiles; /**< CONFIGURABLE Refer to HELP_COLOR_FONTFILES */
403 uint8_t ColorFontFolders; /**< CONFIGURABLE Refer to HELP_COLOR_FONTFOLDERS */
404 int16_t AnalogDeadZone; /**< CONFIGURABLE Refer to HELP_DEADZONE */
405 int16_t ScreenWidth; /**< CONFIGURABLE Refer to HELP_SCREEN_WIDTH */
406 int16_t ScreenHeight; /**< CONFIGURABLE Refer to HELP_SCREEN_HEIGHT */
407 int16_t ScreenDepth; /**< CONFIGURABLE Refer to HELP_SCREEN_DEPTH */
408 uint16_t CPUClock; /**< CONFIGURABLE Refer to HELP_CPU_CLOCK */
409 uint16_t ScrollSpeed; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
410 uint16_t ScrollPauseSpeed; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
411 uint16_t EntryYDelta; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
412 uint16_t EntryXOffset; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
413 uint16_t EntryYOffset; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
414 uint16_t ButtonWidthLeft; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
415 uint16_t ButtonHeightLeft; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
416 uint16_t ButtonWidthRight; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
417 uint16_t ButtonHeightRight; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
418 uint16_t PreviewWidth; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
419 uint16_t PreviewHeight; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
420 uint16_t DisplayListMaxWidth; /**< CONFIGURABLE Refer to HELP_DISPLAY_LIST_MAX_WIDTH */
421 uint16_t FilePathMaxWidth; /**< CONFIGURABLE Refer to HELP_SCROLL_PAUSE_SPEED */
422 uint16_t PosX_Title; /**< CONFIGURABLE */
423 uint16_t PosY_Title; /**< CONFIGURABLE */
424 uint16_t PosX_ButtonLeft; /**< CONFIGURABLE */
425 uint16_t PosY_ButtonLeft; /**< CONFIGURABLE */
426 uint16_t PosX_ButtonRight; /**< CONFIGURABLE */
427 uint16_t PosY_ButtonRight; /**< CONFIGURABLE */
428 uint16_t PosX_ListNames; /**< CONFIGURABLE */
429 uint16_t PosY_ListNames; /**< CONFIGURABLE */
430 float ScreenRatioW; /**< NOT CONFIGURABLE The ratio of the current resolution to the base resolution, used for scaling. */
431 float ScreenRatioH; /**< NOT CONFIGURABLE The ratio of the current resolution to the base resolution, used for scaling. */
432 string ZipPath; /**< CONFIGURABLE Refer to HELP_PATH_ZIPTEMP */
433 string PreviewsPath; /**< CONFIGURABLE Refer to HELP_PATH_PREVIEWS */
434 string PathFont; /**< CONFIGURABLE Refer to HELP_PATH_FONT */
435 string PathBackground; /**< CONFIGURABLE Refer to HELP_PATH_BACKGND */
436 string PathPointer; /**< CONFIGURABLE Refer to HELP_PATH_POINTER */
437 string PathSelectPointer; /**< CONFIGURABLE Refer to HELP_PATH_SELECTPOINTER */
438 string Delimiter; /**< CONFIGURABLE Refer to HELP_PROFILE_DELIMITER */
439 vector<bool> ButtonModesLeftEnable; /**< CONFIGURABLE force buttons to be disabled */
440 vector<bool> ButtonModesRightEnable; /**< CONFIGURABLE force buttons to be disabled */
441 vector<string> PathButtons; /**< CONFIGURABLE Paths for the button graphics */
442 vector<SDLKey> KeyMaps; /**< CONFIGURABLE Key mappings to user actions */
443 vector<uint8_t> JoyMaps; /**< CONFIGURABLE Button mappings to user actions */
444 vector<uint8_t> FontSizes; /**< CONFIGURABLE Point size of the font sizes */
445 vector<SDL_Color> Colors; /**< NOT CONFIGURABLE Basic color types */
446 vector<string> ColorNames; /**< NOT CONFIGURABLE Basic color names */