+
+unsigned char ui_determine_row ( mm_appref_t *a ) {
+ unsigned int row = 0;
+
+ mm_appref_t *i = g_categories [ ui_category ].refs;
+ while ( i != a ) {
+ i = i -> next;
+ row++;
+ } // while
+ row /= ui_display_context.col_max;
+
+ return ( row );
+}
+
+unsigned char ui_determine_screen_row ( mm_appref_t *a ) {
+ return ( ui_determine_row ( a ) % ui_display_context.row_max );
+}
+
+unsigned char ui_determine_screen_col ( mm_appref_t *a ) {
+ unsigned int col = 0;
+
+ mm_appref_t *i = g_categories [ ui_category ].refs;
+ while ( i != a ) {
+ i = i -> next;
+ col++;
+ } // while
+ col %= ui_display_context.col_max;
+
+ return ( col );
+}
+
+unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p ) {
+ char *viewer, *searchpath;
+ pnd_conf_handle desktoph;
+
+ // viewer
+ searchpath = pnd_conf_query_searchpath();
+
+ desktoph = pnd_conf_fetch_by_id ( pnd_conf_desktop, searchpath );
+
+ if ( ! desktoph ) {
+ return ( 0 );
+ }
+
+ viewer = pnd_conf_get_as_char ( desktoph, "info.viewer" );
+
+ if ( ! viewer ) {
+ return ( 0 ); // no way to view the file
+ }
+
+ // etc
+ if ( ! p -> unique_id ) {
+ return ( 0 );
+ }
+
+ if ( ! p -> info_filename ) {
+ return ( 0 );
+ }
+
+ if ( ! p -> info_name ) {
+ return ( 0 );
+ }
+
+ if ( ! pndrun ) {
+ return ( 0 );
+ }
+
+ // exec line
+ char args [ 1001 ];
+ char *pargs = args;
+ if ( pnd_conf_get_as_char ( desktoph, "info.viewer_args" ) ) {
+ snprintf ( pargs, 1001, "%s %s",
+ pnd_conf_get_as_char ( desktoph, "info.viewer_args" ), p -> info_filename );
+ } else {
+ pargs = NULL;
+ }
+
+ char pndfile [ 1024 ];
+ if ( p -> object_type == pnd_object_type_directory ) {
+ // for PXML-app-dir, pnd_run.sh doesn't want the PXML.xml.. it just wants the dir-name
+ strncpy ( pndfile, p -> object_path, 1000 );
+ } else if ( p -> object_type == pnd_object_type_pnd ) {
+ // pnd_run.sh wants the full path and filename for the .pnd file
+ snprintf ( pndfile, 1020, "%s/%s", p -> object_path, p -> object_filename );
+ }
+
+ if ( ! pnd_apps_exec ( pndrun, pndfile, p -> unique_id, viewer, p -> startdir, pargs,
+ p -> clockspeed ? atoi ( p -> clockspeed ) : 0, PND_EXEC_OPTION_NORUN ) )
+ {
+ return ( 0 );
+ }
+
+ pnd_log ( pndn_debug, "Info Exec=%s\n", pnd_apps_exec_runline() );
+
+ // try running it
+ int x;
+ if ( ( x = fork() ) < 0 ) {
+ pnd_log ( pndn_error, "ERROR: Couldn't fork()\n" );
+ return ( 0 );
+ }
+
+ if ( x == 0 ) {
+ execl ( "/bin/sh", "/bin/sh", "-c", pnd_apps_exec_runline(), (char*)NULL );
+ pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", pnd_apps_exec_runline() );
+ return ( 0 );
+ }
+
+ return ( 1 );
+}
+
+typedef struct {
+ SDL_Rect r;
+ int catnum;
+ mm_appref_t *ref;
+} ui_touch_t;
+#define MAXTOUCH 100
+ui_touch_t ui_touchrects [ MAXTOUCH ];
+unsigned char ui_touchrect_count = 0;
+
+void ui_register_reset ( void ) {
+ bzero ( ui_touchrects, sizeof(ui_touch_t)*MAXTOUCH );
+ ui_touchrect_count = 0;
+ return;
+}
+
+void ui_register_tab ( unsigned char catnum, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
+
+ if ( ui_touchrect_count == MAXTOUCH ) {
+ return;
+ }
+
+ ui_touchrects [ ui_touchrect_count ].r.x = x;
+ ui_touchrects [ ui_touchrect_count ].r.y = y;
+ ui_touchrects [ ui_touchrect_count ].r.w = w;
+ ui_touchrects [ ui_touchrect_count ].r.h = h;
+ ui_touchrects [ ui_touchrect_count ].catnum = catnum;
+ ui_touchrect_count++;
+
+ return;
+}
+
+void ui_register_app ( mm_appref_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
+
+ if ( ui_touchrect_count == MAXTOUCH ) {
+ return;
+ }
+
+ ui_touchrects [ ui_touchrect_count ].r.x = x;
+ ui_touchrects [ ui_touchrect_count ].r.y = y;
+ ui_touchrects [ ui_touchrect_count ].r.w = w;
+ ui_touchrects [ ui_touchrect_count ].r.h = h;
+ ui_touchrects [ ui_touchrect_count ].ref = app;
+ ui_touchrect_count++;
+
+ return;
+}
+
+void ui_touch_act ( unsigned int x, unsigned int y ) {
+
+ unsigned char i;
+ ui_touch_t *t;
+
+ for ( i = 0; i < ui_touchrect_count; i++ ) {
+ t = &(ui_touchrects [ i ]);
+
+ if ( x >= t -> r.x &&
+ x <= t -> r.x + t -> r.w &&
+ y >= t -> r.y &&
+ y <= t -> r.y + t -> r.h
+ )
+ {
+
+ if ( t -> ref ) {
+ ui_selected = t -> ref;
+ ui_push_exec();
+ } else {
+ if ( ui_category != t -> catnum ) {
+ ui_selected = NULL;
+ }
+ ui_category = t -> catnum;
+ render_mask |= CHANGED_CATEGORY;
+ // rescan the dir
+ category_fs_restock ( &(g_categories [ ui_category ]) );
+ }
+
+ break;
+ }
+
+ } // for
+
+ return;
+}
+
+unsigned char ui_forkexec ( char *argv[] ) {
+ char *fooby = argv[0];
+ int x;
+
+ if ( ( x = fork() ) < 0 ) {
+ pnd_log ( pndn_error, "ERROR: Couldn't fork() for '%s'\n", fooby );
+ return ( 0 );
+ }
+
+ if ( x == 0 ) { // child
+ execv ( fooby, argv );
+ pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", fooby );
+ return ( 0 );
+ }
+
+ // parent, success
+ return ( 1 );
+}
+
+unsigned char ui_threaded_defered_preview ( pnd_disco_t *p ) {
+
+ if ( ! cache_preview ( p, pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 ),
+ pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 ) )
+ )
+ {
+ pnd_log ( pndn_debug, "THREAD: Couldn't load preview pic: '%s' -> '%s'\n",
+ IFNULL(p->title_en,"No Name"), p -> preview_pic1 );
+ }
+
+ // trigger that we completed
+ SDL_Event e;
+ bzero ( &e, sizeof(SDL_Event) );
+ e.type = SDL_USEREVENT;
+ e.user.code = sdl_user_finishedpreview;
+ e.user.data1 = p;
+ SDL_PushEvent ( &e );
+
+ return ( 0 );
+}
+
+SDL_Thread *g_icon_thread = NULL;
+void ui_post_scan ( void ) {
+
+ // if deferred icon load, kick off the thread now
+ if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_icons_later", 0 ) == 1 ) {
+
+ g_icon_thread = SDL_CreateThread ( (void*)ui_threaded_defered_icon, NULL );
+
+ if ( ! g_icon_thread ) {
+ pnd_log ( pndn_error, "ERROR: Couldn't create icon thread\n" );
+ }
+
+ } // deferred icon load
+
+ // reset view
+ ui_selected = NULL;
+ ui_rows_scrolled_down = 0;
+ // set back to first tab, to be safe
+ ui_category = 0;
+ ui_catshift = 0;
+
+ // do we have a preferred category to jump to?
+ char *dc = pnd_conf_get_as_char ( g_conf, "categories.default_cat" );
+ if ( dc ) {
+
+ // attempt to find default cat; if we do find it, select it; otherwise
+ // default behaviour will pick first cat (ie: usually All)
+ unsigned int i;
+ for ( i = 0; i < g_categorycount; i++ ) {
+ if ( strcasecmp ( g_categories [ i ].catname, dc ) == 0 ) {
+ ui_category = i;
+ // ensure visibility
+ unsigned int screen_width = ui_display_context.screen_width;
+ unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
+ if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
+ ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
+ }
+ break;
+ }
+ }
+
+ if ( i == g_categorycount ) {
+ pnd_log ( pndn_warning, " User defined default category '%s' but not found, so using default behaviour\n", dc );
+ }
+
+ } // default cat
+
+ // redraw all
+ render_mask |= CHANGED_EVERYTHING;
+
+ return;
+}
+
+unsigned char ui_threaded_defered_icon ( void *p ) {
+ extern pnd_box_handle g_active_apps;
+ pnd_box_handle h = g_active_apps;
+
+ unsigned char maxwidth, maxheight;
+ maxwidth = pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_width", 50 );
+ maxheight = pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_height", 50 );
+
+ pnd_disco_t *iter = pnd_box_get_head ( h );
+
+ while ( iter ) {
+
+ // cache it
+ if ( iter -> pnd_icon_pos &&
+ ! cache_icon ( iter, maxwidth, maxheight ) )
+ {
+ pnd_log ( pndn_warning, " Couldn't load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
+ } else {
+
+ // trigger that we completed
+ SDL_Event e;
+ bzero ( &e, sizeof(SDL_Event) );
+ e.type = SDL_USEREVENT;
+ e.user.code = sdl_user_finishedicon;
+ SDL_PushEvent ( &e );
+
+ //pnd_log ( pndn_warning, " Finished deferred load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
+ usleep ( pnd_conf_get_as_int_d ( g_conf, "minimenu.defer_icon_us", 50000 ) );
+
+ }
+
+ // next
+ iter = pnd_box_get_next ( iter );
+ } // while
+
+ return ( 0 );
+}
+
+void ui_show_hourglass ( unsigned char updaterect ) {
+
+ SDL_Rect dest;
+ SDL_Surface *s = g_imagecache [ IMG_HOURGLASS ].i;
+
+ dest.x = ( 800 - s -> w ) / 2;
+ dest.y = ( 480 - s -> h ) / 2;
+
+ SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, &dest );
+
+ if ( updaterect ) {
+ SDL_UpdateRects ( sdl_realscreen, 1, &dest );
+ }
+
+ return;
+}
+
+unsigned char ui_pick_skin ( void ) {
+#define MAXSKINS 10
+ char *skins [ MAXSKINS ];
+ unsigned char iter;
+
+ char *searchpath = pnd_conf_get_as_char ( g_conf, "minimenu.skin_searchpath" );
+ char tempname [ 100 ];
+
+ iter = 0;
+
+ skins [ iter++ ] = "No skin change";
+
+ SEARCHPATH_PRE
+ {
+ DIR *d = opendir ( buffer );
+
+ if ( d ) {
+ struct dirent *dd;
+
+ while ( ( dd = readdir ( d ) ) ) {
+
+ if ( dd -> d_name [ 0 ] == '.' ) {
+ // ignore
+ } else if ( ( dd -> d_type == DT_DIR || dd -> d_type == DT_UNKNOWN ) &&
+ iter < MAXSKINS )
+ {
+ snprintf ( tempname, 100, "Skin: %s", dd -> d_name );
+ skins [ iter++ ] = strdup ( tempname );
+ }
+
+ }
+
+ closedir ( d );
+ }
+
+ }
+ SEARCHPATH_POST
+
+ int sel = ui_modal_single_menu ( skins, iter, "Skins", "Enter to select; other to return." );
+
+ // did they pick one?
+ if ( sel > 0 ) {
+ FILE *f;
+
+ char *s = strdup ( pnd_conf_get_as_char ( g_conf, "minimenu.skin_selected" ) );
+ s = pnd_expand_tilde ( s );
+
+ f = fopen ( s, "w" );
+
+ free ( s );
+
+ if ( f ) {
+ fprintf ( f, "%s\n", skins [ sel ] + 6 );
+ fclose ( f );
+ }
+
+ return ( 1 );
+ }
+
+ return ( 0 );
+}
+
+void ui_aboutscreen ( char *textpath ) {
+#define PIXELW 7
+#define PIXELH 7
+#define MARGINW 3
+#define MARGINH 3
+#define SCRW 800
+#define SCRH 480
+#define ROWS SCRH / ( PIXELH + MARGINH )
+#define COLS SCRW / ( PIXELW + MARGINW )
+
+ unsigned char pixelboard [ ROWS * COLS ]; // pixel heat
+ bzero ( pixelboard, ROWS * COLS );
+
+ SDL_Surface *rtext;
+ SDL_Rect r;
+
+ SDL_Color rtextc = { 200, 200, 200, 100 };
+
+ // pixel scroller
+ char *textloop [ 500 ];
+ unsigned int textmax = 0;
+ bzero ( textloop, 500 * sizeof(char*) );
+
+ // cursor scroller
+ char cbuffer [ 50000 ];
+ bzero ( cbuffer, 50000 );
+ unsigned int crevealed = 0;
+
+ FILE *f = fopen ( textpath, "r" );
+
+ if ( ! f ) {
+ pnd_log ( pndn_error, "ERROR: Couldn't open about text: %s\n", textpath );
+ return;
+ }
+
+ char textbuf [ 100 ];
+ while ( fgets ( textbuf, 100, f ) ) {
+
+ // add to full buffer
+ strncat ( cbuffer, textbuf, 50000 );
+
+ // chomp
+ if ( strchr ( textbuf, '\n' ) ) {
+ * strchr ( textbuf, '\n' ) = '\0';
+ }
+
+ // add to pixel loop
+ if ( 1||textbuf [ 0 ] ) {
+ textloop [ textmax ] = strdup ( textbuf );
+ textmax++;
+ }
+
+ } // while fgets
+
+ fclose ( f );
+
+ unsigned int textiter = 0;
+ while ( textiter < textmax ) {
+ char *text = textloop [ textiter ];
+
+ rtext = NULL;
+ if ( text [ 0 ] ) {
+ // render to surface
+ rtext = TTF_RenderText_Blended ( g_grid_font, text, rtextc );
+
+ // render font to pixelboard
+ unsigned int px, py;
+ unsigned char *ph;
+ unsigned int *pixels = rtext -> pixels;
+ unsigned char cr, cg, cb, ca;
+ for ( py = 0; py < rtext -> h; py ++ ) {
+ for ( px = 0; px < ( rtext -> w > COLS ? COLS : rtext -> w ); px++ ) {
+
+ SDL_GetRGBA ( pixels [ ( py * rtext -> pitch / 4 ) + px ],
+ rtext -> format, &cr, &cg, &cb, &ca );
+
+ if ( ca != 0 ) {
+
+ ph = pixelboard + ( /*y offset */ 30 * COLS ) + ( py * COLS ) + px /* / 2 */;
+
+ if ( *ph < 100 ) {
+ *ph = 100;
+ }
+
+ ca /= 5;
+ if ( *ph + ca < 250 ) {
+ *ph += ca;
+ }
+
+ } // got a pixel?
+
+ } // x
+ } // y
+
+ } // got text?
+
+ unsigned int runcount = 10;
+ while ( runcount-- ) {
+
+ // clear display
+ SDL_FillRect( sdl_realscreen, NULL /* whole */, 0 );
+
+ // render pixelboard
+ unsigned int x, y;
+ unsigned int c;
+ for ( y = 0; y < ROWS; y++ ) {
+ for ( x = 0; x < COLS; x++ ) {
+
+ if ( 1||pixelboard [ ( y * COLS ) + x ] ) {
+
+ // position
+ r.x = x * ( PIXELW + MARGINW );
+ r.y = y * ( PIXELH + MARGINH );
+ r.w = PIXELW;
+ r.h = PIXELH;
+ // heat -> colour
+ c = SDL_MapRGB ( sdl_realscreen -> format, 100 /* r */, 0 /* g */, pixelboard [ ( y * COLS ) + x ] );
+ // render
+ SDL_FillRect( sdl_realscreen, &r /* whole */, c );
+
+ }
+
+ } // x
+ } // y
+
+ // cool pixels
+ unsigned char *pc = pixelboard;
+ for ( y = 0; y < ROWS; y++ ) {
+ for ( x = 0; x < COLS; x++ ) {
+
+ if ( *pc > 10 ) {
+ (*pc) -= 3;
+ }
+
+ pc++;
+ } // x
+ } // y
+
+ // slide pixels upwards
+ memmove ( pixelboard, pixelboard + COLS, ( COLS * ROWS ) - COLS );
+
+ // render actual readable text
+ {
+
+ // display up to cursor
+ SDL_Rect dest;
+ unsigned int cdraw = 0;
+ SDL_Surface *cs;
+ char ctb [ 2 ];
+
+ if ( crevealed > 200 ) {
+ cdraw = crevealed - 200;
+ }
+
+ dest.x = 400;
+ dest.y = 20;
+
+ for ( ; cdraw < crevealed; cdraw++ ) {
+ ctb [ 0 ] = cbuffer [ cdraw ];
+ ctb [ 1 ] = '\0';
+ // move over or down
+ if ( cbuffer [ cdraw ] == '\n' ) {
+ // EOL
+ dest.x = 400;
+ dest.y += 14;
+
+ if ( dest.y > 450 ) {
+ dest.y = 450;
+ }
+
+ } else {
+ // draw the char
+ cs = TTF_RenderText_Blended ( g_tab_font, ctb, rtextc );
+ if ( cs ) {
+ SDL_BlitSurface ( cs, NULL /* all */, sdl_realscreen, &dest );
+ SDL_FreeSurface ( cs );
+ // over
+ dest.x += cs -> w;
+ }
+ }
+
+ }
+
+ dest.w = 10;
+ dest.h = 20;
+ SDL_FillRect ( sdl_realscreen, &dest /* whole */, 220 );
+
+ // increment cursor to next character
+ if ( cbuffer [ crevealed ] != '\0' ) {
+ crevealed++;
+ }
+
+ } // draw cursor text
+
+ // reveal
+ //
+ SDL_UpdateRect ( sdl_realscreen, 0, 0, 0, 0 ); // whole screen
+
+ usleep ( 50000 );
+
+ // any button? if so, about
+ {
+ SDL_PumpEvents();
+
+ SDL_Event e;
+
+ if ( SDL_PeepEvents ( &e, 1, SDL_GETEVENT, SDL_EVENTMASK(/*SDL_KEYUP|*/SDL_KEYDOWN) ) > 0 ) {
+ return;
+ }
+
+ }
+
+ } // while cooling
+
+ if ( rtext ) {
+ SDL_FreeSurface ( rtext );
+ }
+
+ textiter++;
+ } // while more text
+
+ // free up
+ unsigned int i;
+ for ( i = 0; i < textmax; i++ ) {
+ if ( textloop [ i ] ) {
+ free ( textloop [ i ] );
+ textloop [ i ] = 0;
+ }
+ }
+
+ return;
+}
+
+void ui_revealscreen ( void ) {
+ char *labels [ 500 ];
+ unsigned int labelmax = 0;
+ unsigned int i;
+
+ if ( ! _categories_inviscount ) {
+ return; // nothing to do
+ }
+
+ for ( i = 0; i < _categories_inviscount; i++ ) {
+ labels [ labelmax++ ] = _categories_invis [ i ].catname;
+ }
+
+ int sel = ui_modal_single_menu ( labels, labelmax, "Temporary Category Reveal",
+ "Enter to select; other to return." );
+
+ if ( sel >= 0 ) {
+
+ if ( category_query ( _categories_invis [ sel ].catname ) ) {
+ // already present
+ return;
+ }
+
+ // fix up category name, if its been hacked
+ if ( strchr ( _categories_invis [ sel ].catname, '.' ) ) {
+ char *t = _categories_invis [ sel ].catname;
+ _categories_invis [ sel ].catname = strdup ( strchr ( _categories_invis [ sel ].catname, '.' ) + 1 );
+ free ( t );
+ }
+ // copy invisi-cat into live-cat
+ memmove ( &(g_categories [ g_categorycount ]), &(_categories_invis [ sel ]), sizeof(mm_category_t) );
+ g_categorycount++;
+ // move subsequent invisi-cats up, so the selected invisi-cat is nolonger existing in invisi-list at
+ // all (avoid double-free() later)
+ memmove ( &(_categories_invis [ sel ]), &(_categories_invis [ sel + 1 ]), sizeof(mm_category_t) * ( _categories_inviscount - sel - 1 ) );
+ _categories_inviscount--;
+
+ // switch to the new category
+ ui_category = g_categorycount - 1;
+
+ // ensure visibility
+ unsigned int screen_width = ui_display_context.screen_width;
+ unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
+ if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
+ ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
+ }
+
+ // redraw tabs
+ render_mask |= CHANGED_CATEGORY;
+ }
+
+ return;
+}
+
+void ui_recache_context ( ui_context_t *c ) {
+
+ c -> screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
+
+ c -> font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
+ c -> font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
+ c -> font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
+ c -> font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
+
+ c -> grid_offset_x = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_x" );
+ c -> grid_offset_y = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_y" );
+
+ c -> icon_offset_x = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_x" );
+ c -> icon_offset_y = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_y" );
+ c -> icon_max_width = pnd_conf_get_as_int ( g_conf, "grid.icon_max_width" );
+ c -> icon_max_height = pnd_conf_get_as_int ( g_conf, "grid.icon_max_height" );
+ c -> sel_icon_offset_x = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_x", 0 );
+ c -> sel_icon_offset_y = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_y", 0 );
+
+ c -> text_width = pnd_conf_get_as_int ( g_conf, "grid.text_width" );
+ c -> text_clip_x = pnd_conf_get_as_int ( g_conf, "grid.text_clip_x" );
+ c -> text_offset_x = pnd_conf_get_as_int ( g_conf, "grid.text_offset_x" );
+ c -> text_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_offset_y" );
+ c -> text_hilite_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_hilite_offset_y" );
+
+ c -> row_max = pnd_conf_get_as_int_d ( g_conf, "grid.row_max", 4 );
+ c -> col_max = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 );
+
+ c -> cell_width = pnd_conf_get_as_int ( g_conf, "grid.cell_width" );
+ c -> cell_height = pnd_conf_get_as_int ( g_conf, "grid.cell_height" );
+
+ c -> arrow_bar_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x", 450 );
+ c -> arrow_bar_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y", 100 );
+ c -> arrow_bar_clip_w = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_w", 10 );
+ c -> arrow_bar_clip_h = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_h", 100 );
+ c -> arrow_up_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x", 450 );
+ c -> arrow_up_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y", 80 );
+ c -> arrow_down_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x", 450 );
+ c -> arrow_down_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y", 80 );
+
+ // font colour
+ SDL_Color tmp = { c -> font_rgba_r, c -> font_rgba_g, c -> font_rgba_b, c -> font_rgba_a };
+ c -> fontcolor = tmp;
+
+ // now that we've got 'normal' (detail pane shown) param's, lets check if detail pane
+ // is hidden; if so, override some values with those alternate skin values where possible.
+ if ( ui_detail_hidden ) {
+ // if detail panel is hidden, and theme cannot support it, unhide the bloody thing. (This may help
+ // when someone is amid theme hacking or changing.)
+ if ( ! ui_is_detail_hideable() ) {
+ ui_detail_hidden = 0;
+ }
+
+ // still hidden?
+ if ( ui_detail_hidden ) {
+
+ c -> row_max = pnd_conf_get_as_int_d ( g_conf, "grid.row_max_w", c -> row_max );
+ c -> col_max = pnd_conf_get_as_int_d ( g_conf, "grid.col_max_w", c -> col_max );
+
+ c -> cell_width = pnd_conf_get_as_int_d ( g_conf, "grid.cell_width_w", c -> cell_width );
+ c -> cell_height = pnd_conf_get_as_int_d ( g_conf, "grid.cell_height_w", c -> cell_height );
+
+ c -> arrow_bar_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x_w", 450 );
+ c -> arrow_bar_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y_w", 100 );
+ c -> arrow_up_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x_w", 450 );
+ c -> arrow_up_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y_w", 80 );
+ c -> arrow_down_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x_w", 450 );
+ c -> arrow_down_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y_w", 80 );
+
+ } // if detail hidden.. still.
+
+ } // if detail hidden
+
+ return;
+}
+
+unsigned char ui_is_detail_hideable ( void ) {
+
+ // if skin has a bit of info for wide-mode, we assume wide-mode is available
+ if ( pnd_conf_get_as_char ( g_conf, "grid.row_max_w" ) != NULL ) {
+ return ( 1 );
+ }
+
+ // else not!
+ return ( 0 );
+}
+
+void ui_toggle_detail_pane ( void ) {
+
+ // no bitmask trickery here; I like it to be stand-out obvious at 3am.
+
+ if ( ui_detail_hidden ) {
+ ui_detail_hidden = 0;
+ } else {
+ ui_detail_hidden = 1;
+ }
+
+ // repull skin config
+ ui_recache_context ( &ui_display_context );
+
+ // redraw
+ render_mask |= CHANGED_EVERYTHING;
+
+ return;
+}