source: ps2launchargs/source/uLaunchELF/config.c@ 1164

Last change on this file since 1164 was 1101, checked in by iritscen, 7 years ago

Added following to ps2launchargs:\n-Source code.\n-DLL needed to run ps2client.\n-Instructions for building uLaunchELF.

  • Property svn:executable set to *
File size: 70.4 KB
Line 
1//---------------------------------------------------------------------------
2// File name: config.c
3//---------------------------------------------------------------------------
4#include "launchelf.h"
5#include <stdbool.h>
6
7enum
8{
9 DEF_TIMEOUT = 10,
10 DEF_HIDE_PATHS = TRUE,
11 DEF_COLOR1 = GS_SETREG_RGBA(128,128,128,0), //Backgr
12 DEF_COLOR2 = GS_SETREG_RGBA(64,64,64,0), //Frame
13 DEF_COLOR3 = GS_SETREG_RGBA(96,0,0,0), //Select
14 DEF_COLOR4 = GS_SETREG_RGBA(0,0,0,0), //Text
15 DEF_COLOR5 = GS_SETREG_RGBA(96,96,0,0), //Graph1
16 DEF_COLOR6 = GS_SETREG_RGBA(0,96,0,0), //Graph2
17 DEF_COLOR7 = GS_SETREG_RGBA(224,224,224,0), //Graph3
18 DEF_COLOR8 = GS_SETREG_RGBA(0,0,0,0), //Graph4
19 DEF_DISCCONTROL = FALSE,
20 DEF_INTERLACE = TRUE,
21 DEF_MENU_FRAME = TRUE,
22 DEF_MENU = TRUE,
23 DEF_RESETIOP = TRUE,
24 DEF_NUMCNF = 1,
25 DEF_SWAPKEYS = FALSE,
26 DEF_HOSTWRITE = FALSE,
27 DEF_BRIGHT = 50,
28 DEF_POPUP_OPAQUE = FALSE,
29 DEF_INIT_DELAY = 0,
30 DEF_USBKBD_USED = 1,
31 DEF_SHOW_TITLES = 1,
32 DEF_PATHPAD_LOCK = 0,
33 DEF_JPGVIEW_TIMER = 5,
34 DEF_JPGVIEW_TRANS = 2,
35 DEF_JPGVIEW_FULL = 0,
36 DEF_PSU_HUGENAMES = 0,
37 DEF_PSU_DATENAMES = 0,
38 DEF_PSU_NOOVERWRITE = 0,
39 DEF_FB_NOICONS = 0,
40
41 DEFAULT=0,
42 SHOW_TITLES=12,
43 DISCCONTROL,
44 FILENAME,
45 SCREEN,
46 SETTINGS,
47 NETWORK,
48 OK,
49 CANCEL
50};
51
52char LK_ID[16][10]={
53 "auto",
54 "Circle",
55 "Cross",
56 "Square",
57 "Triangle",
58 "L1",
59 "R1",
60 "L2",
61 "R2",
62 "L3",
63 "R3",
64 "Start",
65 "Select", //Predefined for "CONFIG"
66 "Left", //Predefined for "LOAD CONFIG--"
67 "Right", //Predefined for "LOAD CONFIG++"
68 "ESR"
69};
70char PathPad[30][MAX_PATH];
71char tmp[MAX_PATH];
72SETTING *setting = NULL;
73SETTING *tmpsetting;
74//---------------------------------------------------------------------------
75// End of declarations
76// Start of functions
77//---------------------------------------------------------------------------
78// get_CNF_string is the main CNF parser called for each CNF variable in a
79// CNF file. Input and output data is handled via its pointer parameters.
80// The return value flags 'false' when no variable is found. (normal at EOF)
81//---------------------------------------------------------------------------
82int get_CNF_string(unsigned char **CNF_p_p,
83 unsigned char **name_p_p,
84 unsigned char **value_p_p)
85{
86 unsigned char *np, *vp, *tp = *CNF_p_p;
87
88start_line:
89 while((*tp<=' ') && (*tp>'\0')) tp+=1; //Skip leading whitespace, if any
90 if(*tp=='\0') return false; //but exit at EOF
91 np = tp; //Current pos is potential name
92 if(*tp<'A') //but may be a comment line
93 { //We must skip a comment line
94 while((*tp!='\r')&&(*tp!='\n')&&(*tp>'\0')) tp+=1; //Seek line end
95 goto start_line; //Go back to try next line
96 }
97
98 while((*tp>='A')||((*tp>='0')&&(*tp<='9'))) tp+=1; //Seek name end
99 if(*tp=='\0') return false; //but exit at EOF
100
101 while((*tp<=' ') && (*tp>'\0'))
102 *tp++ = '\0'; //zero&skip post-name whitespace
103 if(*tp!='=') return false; //exit (syntax error) if '=' missing
104 *tp++ = '\0'; //zero '=' (possibly terminating name)
105
106 while((*tp<=' ') && (*tp>'\0') //Skip pre-value whitespace, if any
107 && (*tp!='\r') && (*tp!='\n'))tp+=1; //but do not pass the end of the line
108 if(*tp=='\0') return false; //but exit at EOF
109 vp = tp; //Current pos is potential value
110
111 while((*tp!='\r')&&(*tp!='\n')&&(*tp!='\0')) tp+=1; //Seek line end
112 if(*tp!='\0') *tp++ = '\0'; //terminate value (passing if not EOF)
113 while((*tp<=' ') && (*tp>'\0')) tp+=1; //Skip following whitespace, if any
114
115 *CNF_p_p = tp; //return new CNF file position
116 *name_p_p = np; //return found variable name
117 *value_p_p = vp; //return found variable value
118 return true; //return control to caller
119} //Ends get_CNF_string
120
121//---------------------------------------------------------------------------
122int CheckMC(void)
123{
124 int dummy, ret;
125
126 mcGetInfo(0, 0, &dummy, &dummy, &dummy);
127 mcSync(0, NULL, &ret);
128
129 if( -1 == ret || 0 == ret) return 0;
130
131 mcGetInfo(1, 0, &dummy, &dummy, &dummy);
132 mcSync(0, NULL, &ret);
133
134 if( -1 == ret || 0 == ret ) return 1;
135
136 return -11;
137}
138//---------------------------------------------------------------------------
139unsigned long hextoul(char *string)
140{
141 unsigned long value;
142 char c;
143
144 value = 0;
145 while( !(((c=*string++)<'0')||(c>'F')||((c>'9')&&(c<'A'))) )
146 value = value*16 + ((c>'9') ? (c-'A'+10) : (c-'0'));
147 return value;
148}
149//---------------------------------------------------------------------------
150//storeSkinCNF will save most cosmetic settings to a RAM area
151//------------------------------
152size_t storeSkinCNF(char *cnf_buf)
153{
154 size_t CNF_size;
155
156 sprintf(cnf_buf,
157 "GUI_Col_1_ABGR = %08lX\r\n"
158 "GUI_Col_2_ABGR = %08lX\r\n"
159 "GUI_Col_3_ABGR = %08lX\r\n"
160 "GUI_Col_4_ABGR = %08lX\r\n"
161 "GUI_Col_5_ABGR = %08lX\r\n"
162 "GUI_Col_6_ABGR = %08lX\r\n"
163 "GUI_Col_7_ABGR = %08lX\r\n"
164 "GUI_Col_8_ABGR = %08lX\r\n"
165 "SKIN_FILE = %s\r\n"
166 "GUI_SKIN_FILE = %s\r\n"
167 "SKIN_Brightness = %d\r\n"
168 "TV_mode = %d\r\n"
169 "Screen_Interlace = %d\r\n"
170 "Screen_X = %d\r\n"
171 "Screen_Y = %d\r\n"
172 "Popup_Opaque = %d\r\n"
173 "Menu_Frame = %d\r\n"
174 "Show_Menu = %d\r\n"
175 "%n", // %n causes NO output, but only a measurement
176 setting->color[0], //Col_1
177 setting->color[1], //Col_2
178 setting->color[2], //Col_3
179 setting->color[3], //Col_4
180 setting->color[4], //Col_5
181 setting->color[5], //Col_6
182 setting->color[6], //Col_7
183 setting->color[7], //Col_8
184 setting->skin, //SKIN_FILE
185 setting->GUI_skin, //GUI_SKIN_FILE
186 setting->Brightness, //SKIN_Brightness
187 setting->TV_mode, //TV_mode
188 setting->interlace, //Screen_Interlace
189 setting->screen_x, //Screen_X
190 setting->screen_y, //Screen_Y
191 setting->Popup_Opaque, //Popup_Opaque
192 setting->Menu_Frame, //Menu_Frame
193 setting->Show_Menu, //Show_Menu
194 &CNF_size // This variable measures the size of sprintf data
195 );
196 return CNF_size;
197}
198//------------------------------
199//endfunc storeSkinCNF
200//---------------------------------------------------------------------------
201//saveSkinCNF will save most cosmetic settings to a skin CNF file
202//------------------------------
203int saveSkinCNF(char *CNF)
204{
205 int ret, fd;
206 char tmp[26*MAX_PATH + 30*MAX_PATH];
207 char cnf_path[MAX_PATH];
208 size_t CNF_size;
209
210 CNF_size = storeSkinCNF(tmp);
211
212 ret = genFixPath(CNF, cnf_path);
213 if((ret < 0) || ((fd=genOpen(cnf_path,O_CREAT|O_WRONLY|O_TRUNC)) < 0)){
214 return -1; //Failed open
215 }
216 ret = genWrite(fd,&tmp,CNF_size);
217 if(ret!=CNF_size)
218 ret = -2; //Failed writing
219 genClose(fd);
220
221 return ret;
222}
223//-----------------------------
224//endfunc saveSkinCNF
225//---------------------------------------------------------------------------
226//saveSkinBrowser will save most cosmetic settings to browsed skin CNF file
227//------------------------------
228void saveSkinBrowser(void)
229{
230 int tst;
231 char path[MAX_PATH];
232 char mess[MAX_PATH];
233 char *p;
234
235 tst = getFilePath(path, SAVE_CNF);
236 if(path[0] == '\0')
237 goto abort;
238 if(!strncmp(path, "cdfs", 4))
239 goto abort;
240
241 drawMsg(LNG(Enter_File_Name));
242
243 tmp[0]=0;
244 if(tst > 0){ //if an existing file was selected, use its name
245 p = strrchr(path, '/'); //find separator between path and name
246 if(p != NULL){
247 strcpy(tmp, p+1);
248 p[1] = '\0';
249 }else //if we got a pathname without separator, something is wrong
250 goto abort;
251 }
252 if((tst >= 0) && (keyboard(tmp, 36)>0))
253 strcat(path, tmp);
254 else{
255abort:
256 tst = -3;
257 goto test;
258 }
259
260 tst = saveSkinCNF(path);
261
262test:
263 switch(tst){
264 case -1:
265 sprintf(mess, "%s \"%s\".", LNG(Failed_To_Save), path);
266 break;
267 case -2:
268 sprintf(mess, "%s \"%s\".", LNG(Failed_writing), path);
269 break;
270 case -3:
271 sprintf(mess, "%s \"%s\".", LNG(Failed_Saving_File), path);
272 break;
273 default:
274 sprintf(mess, "%s \"%s\".", LNG(Saved), path);
275 }
276 drawMsg(mess);
277}
278//-----------------------------
279//endfunc saveSkinBrowser
280//---------------------------------------------------------------------------
281//preloadCNF loads an entire CNF file into RAM it allocates
282//------------------------------
283unsigned char *preloadCNF(char *path)
284{
285 int fd, tst;
286 size_t CNF_size;
287 char cnf_path[MAX_PATH];
288 unsigned char *RAM_p;
289
290 fd=-1;
291 if((tst = genFixPath(path, cnf_path)) >= 0)
292 fd = genOpen(cnf_path, O_RDONLY);
293 if(fd<0){
294failed_load:
295 return NULL;
296 }
297 CNF_size = genLseek(fd, 0, SEEK_END);
298 printf("CNF_size=%d\n", CNF_size);
299 genLseek(fd, 0, SEEK_SET);
300 RAM_p = (char*)malloc(CNF_size);
301 if (RAM_p==NULL) { genClose(fd); goto failed_load; }
302 genRead(fd, RAM_p, CNF_size); //Read CNF as one long string
303 genClose(fd);
304 RAM_p[CNF_size] = '\0'; //Terminate the CNF string
305 return RAM_p;
306}
307//------------------------------
308//endfunc preloadCNF
309//---------------------------------------------------------------------------
310//scanSkinCNF will check for most cosmetic variables of a CNF
311//------------------------------
312int scanSkinCNF(unsigned char *name, unsigned char *value)
313{
314 if(!strcmp(name,"GUI_Col_1_ABGR")) setting->color[0] = hextoul(value);
315 else if(!strcmp(name,"GUI_Col_2_ABGR")) setting->color[1] = hextoul(value);
316 else if(!strcmp(name,"GUI_Col_3_ABGR")) setting->color[2] = hextoul(value);
317 else if(!strcmp(name,"GUI_Col_4_ABGR")) setting->color[3] = hextoul(value);
318 else if(!strcmp(name,"GUI_Col_5_ABGR")) setting->color[4] = hextoul(value);
319 else if(!strcmp(name,"GUI_Col_6_ABGR")) setting->color[5] = hextoul(value);
320 else if(!strcmp(name,"GUI_Col_7_ABGR")) setting->color[6] = hextoul(value);
321 else if(!strcmp(name,"GUI_Col_8_ABGR")) setting->color[7] = hextoul(value);
322 //----------
323 else if(!strcmp(name,"SKIN_FILE")) strcpy(setting->skin,value);
324 else if(!strcmp(name,"GUI_SKIN_FILE")) strcpy(setting->GUI_skin,value);
325 else if(!strcmp(name,"SKIN_Brightness")) setting->Brightness = atoi(value);
326 //----------
327 else if(!strcmp(name,"TV_mode")) setting->TV_mode = atoi(value);
328 else if(!strcmp(name,"Screen_Interlace")) setting->interlace = atoi(value);
329 else if(!strcmp(name,"Screen_X")) setting->screen_x = atoi(value);
330 else if(!strcmp(name,"Screen_Y")) setting->screen_y = atoi(value);
331 //----------
332 else if(!strcmp(name,"Popup_Opaque")) setting->Popup_Opaque = atoi(value);
333 else if(!strcmp(name,"Menu_Frame")) setting->Menu_Frame = atoi(value);
334 else if(!strcmp(name,"Show_Menu")) setting->Show_Menu = atoi(value);
335 else
336 return 0; //when no skin variable
337 return 1; //when skin variable found
338}
339//------------------------------
340//endfunc scanSkinCNF
341//---------------------------------------------------------------------------
342//loadSkinCNF will load most cosmetic settings from CNF file
343//------------------------------
344int loadSkinCNF(char *path)
345{
346 int dummy, var_cnt;
347 unsigned char *RAM_p, *CNF_p, *name, *value;
348
349 if( !(RAM_p = preloadCNF(path)) )
350 return -1;
351 CNF_p = RAM_p;
352 for(var_cnt = 0; get_CNF_string(&CNF_p, &name, &value); var_cnt++)
353 dummy = scanSkinCNF(name, value);
354 free(RAM_p);
355 updateScreenMode(0);
356 if(setting->skin)
357 loadSkin(BACKGROUND_PIC, 0, 0);
358 return 0;
359}
360//------------------------------
361//endfunc loadSkinCNF
362//---------------------------------------------------------------------------
363//loadSkinBrowser will load most cosmetic settings from browsed skin CNF file
364//------------------------------
365void loadSkinBrowser(void)
366{
367 int tst;
368 char path[MAX_PATH];
369 char mess[MAX_PATH];
370
371 getFilePath(path, TEXT_CNF); // No Filtering, Be Careful.
372 tst = loadSkinCNF(path);
373 if(tst<0)
374 sprintf(mess, "%s \"%s\".", LNG(Failed_To_Load), path);
375 else
376 sprintf(mess, "%s \"%s\".", LNG(Loaded_Config), path);
377
378 drawMsg(mess);
379}
380//------------------------------
381//endfunc loadSkinBrowser
382//---------------------------------------------------------------------------
383// Save LAUNCHELF.CNF (or LAUNCHELFx.CNF with multiple pages)
384// sincro: ADD save USBD_FILE string
385// polo: ADD save SKIN_FILE string
386// suloku: ADD save MAIN_SKIN string //dlanor: changed to GUI_SKIN_FILE
387//---------------------------------------------------------------------------
388void saveConfig(char *mainMsg, char *CNF)
389{
390 int i, ret, fd;
391 char c[MAX_PATH], tmp[26*MAX_PATH + 30*MAX_PATH];
392 char cnf_path[MAX_PATH];
393 size_t CNF_size, CNF_step;
394
395 sprintf(tmp, "CNF_version = 3\r\n%n", &CNF_size); //Start CNF with version header
396
397 for(i=0; i<16; i++){ //Loop to save the ELF paths for launch keys
398 if((i<12) || (setting->LK_Flag[i]!=0)){
399 sprintf(tmp+CNF_size,
400 "LK_%s_E1 = %s\r\n"
401 "%n", // %n causes NO output, but only a measurement
402 LK_ID[i], setting->LK_Path[i],
403 &CNF_step // This variable measures the size of sprintf data
404 );
405 CNF_size += CNF_step;
406 }
407 }//ends for
408
409 i = strlen(setting->Misc);
410 sprintf(tmp+CNF_size,
411 "Misc = %s\r\n"
412 "Misc_PS2Disc = %s\r\n"
413 "Misc_FileBrowser = %s\r\n"
414 "Misc_PS2Browser = %s\r\n"
415 "Misc_PS2Net = %s\r\n"
416 "Misc_PS2PowerOff = %s\r\n"
417 "Misc_HddManager = %s\r\n"
418 "Misc_TextEditor = %s\r\n"
419 "Misc_JpgViewer = %s\r\n"
420 "Misc_Configure = %s\r\n"
421 "Misc_Load_CNFprev = %s\r\n"
422 "Misc_Load_CNFnext = %s\r\n"
423 "Misc_Set_CNF_Path = %s\r\n"
424 "Misc_Load_CNF = %s\r\n"
425 "Misc_ShowFont = %s\r\n"
426 "Misc_Debug_Info = %s\r\n"
427 "Misc_About_uLE = %s\r\n"
428 "%n", // %n causes NO output, but only a measurement
429 setting->Misc,
430 setting->Misc_PS2Disc+i,
431 setting->Misc_FileBrowser+i,
432 setting->Misc_PS2Browser+i,
433 setting->Misc_PS2Net+i,
434 setting->Misc_PS2PowerOff+i,
435 setting->Misc_HddManager+i,
436 setting->Misc_TextEditor+i,
437 setting->Misc_JpgViewer+i,
438 setting->Misc_Configure+i,
439 setting->Misc_Load_CNFprev+i,
440 setting->Misc_Load_CNFnext+i,
441 setting->Misc_Set_CNF_Path+i,
442 setting->Misc_Load_CNF+i,
443 setting->Misc_ShowFont+i,
444 setting->Misc_Debug_Info+i,
445 setting->Misc_About_uLE+i,
446 &CNF_step // This variable measures the size of sprintf data
447 );
448 CNF_size += CNF_step;
449
450 CNF_size += storeSkinCNF(tmp+CNF_size);
451
452 sprintf(tmp+CNF_size,
453 "LK_auto_Timer = %d\r\n"
454 "Menu_Hide_Paths = %d\r\n"
455 "Init_CDVD_Check = %d\r\n"
456 "Init_Reset_IOP = %d\r\n"
457 "Menu_Pages = %d\r\n"
458 "GUI_Swap_Keys = %d\r\n"
459 "USBD_FILE = %s\r\n"
460 "NET_HOSTwrite = %d\r\n"
461 "Menu_Title = %s\r\n"
462 "Init_Delay = %d\r\n"
463 "USBKBD_USED = %d\r\n"
464 "USBKBD_FILE = %s\r\n"
465 "KBDMAP_FILE = %s\r\n"
466 "Menu_Show_Titles = %d\r\n"
467 "PathPad_Lock = %d\r\n"
468 "CNF_Path = %s\r\n"
469 "USBMASS_FILE = %s\r\n"
470 "LANG_FILE = %s\r\n"
471 "FONT_FILE = %s\r\n"
472 "JpgView_Timer = %d\r\n"
473 "JpgView_Trans = %d\r\n"
474 "JpgView_Full = %d\r\n"
475 "PSU_HugeNames = %d\r\n"
476 "PSU_DateNames = %d\r\n"
477 "PSU_NoOverwrite = %d\r\n"
478 "FB_NoIcons = %d\r\n"
479 "%n", // %n causes NO output, but only a measurement
480 setting->timeout, //auto_Timer
481 setting->Hide_Paths, //Menu_Hide_Paths
482 setting->discControl, //Init_CDVD_Check
483 setting->resetIOP, //Init_Reset_IOP
484 setting->numCNF, //Menu_Pages
485 setting->swapKeys, //GUI_Swap_Keys
486 setting->usbd_file, //USBD_FILE
487 setting->HOSTwrite, //NET_HOST_write
488 setting->Menu_Title, //Menu_Title
489 setting->Init_Delay, //Init_Delay
490 setting->usbkbd_used, //USBKBD_USED
491 setting->usbkbd_file, //USBKBD_FILE
492 setting->kbdmap_file, //KBDMAP_FILE
493 setting->Show_Titles, //Menu_Show_Titles
494 setting->PathPad_Lock, //PathPad_Lock
495 setting->CNF_Path, //CNF_Path
496 setting->usbmass_file, //USBMASS_FILE
497 setting->lang_file, //LANG_FILE
498 setting->font_file, //FONT_FILE
499 setting->JpgView_Timer, //JpgView_Timer
500 setting->JpgView_Trans, //JpgView_Trans
501 setting->JpgView_Full, //JpgView_Full
502 setting->PSU_HugeNames, //PSU_HugeNames
503 setting->PSU_DateNames, //PSU_DateNames
504 setting->PSU_NoOverwrite, //PSU_NoOverwrite
505 setting->FB_NoIcons, //FB_NoIcons
506 &CNF_step // This variable measures the size of sprintf data
507 );
508 CNF_size += CNF_step;
509
510 for(i=0; i<16; i++){ //Loop to save user defined launch key titles
511 if(setting->LK_Title[i][0]){ //Only save non-empty strings
512 sprintf(tmp+CNF_size,
513 "LK_%s_Title = %s\r\n"
514 "%n", // %n causes NO output, but only a measurement
515 LK_ID[i], setting->LK_Title[i],
516 &CNF_step // This variable measures the size of sprintf data
517 );
518 CNF_size += CNF_step;
519 }//ends if
520 }//ends for
521
522 sprintf(tmp+CNF_size,
523 "PathPad_Lock = %d\r\n"
524 "%n", // %n causes NO output, but only a measurement
525 setting->PathPad_Lock, //PathPad_Lock
526 &CNF_step // This variable measures the size of sprintf data
527 );
528 CNF_size += CNF_step;
529
530 for(i=0; i<30; i++){ //Loop to save non-empty PathPad entries
531 if(PathPad[i][0]){ //Only save non-empty strings
532 sprintf(tmp+CNF_size,
533 "PathPad[%02d] = %s\r\n"
534 "%n", // %n causes NO output, but only a measurement
535 i, PathPad[i],
536 &CNF_step // This variable measures the size of sprintf data
537 );
538 CNF_size += CNF_step;
539 }//ends if
540 }//ends for
541
542 strcpy(c, LaunchElfDir);
543 strcat(c, CNF);
544 ret = genFixPath(c, cnf_path);
545 if((ret >= 0) && ((fd=genOpen(cnf_path, O_RDONLY)) >= 0))
546 genClose(fd);
547 else { //Start of clause for failure to use LaunchElfDir
548 if(setting->CNF_Path[0]==0) { //if NO CNF Path override defined
549 if(!strncmp(LaunchElfDir, "mc", 2))
550 sprintf(c, "mc%d:/SYS-CONF", LaunchElfDir[2]-'0');
551 else
552 sprintf(c, "mc%d:/SYS-CONF", CheckMC());
553
554 if((fd=fioDopen(c)) >= 0){
555 fioDclose(fd);
556 char strtmp[MAX_PATH] = "/";
557 strcat(c, strcat(strtmp, CNF));
558 }else{
559 strcpy(c, LaunchElfDir);
560 strcat(c, CNF);
561 }
562 }
563 } //End of clause for failure to use LaunchElfDir
564
565 ret = genFixPath(c, cnf_path);
566 if((ret < 0) || ((fd=genOpen(cnf_path,O_CREAT|O_WRONLY|O_TRUNC)) < 0)){
567 sprintf(c, "mc%d:/SYS-CONF", CheckMC());
568 if((fd=fioDopen(c)) >= 0){
569 fioDclose(fd);
570 char strtmp[MAX_PATH] = "/";
571 strcat(c, strcat(strtmp, CNF));
572 }else{
573 strcpy(c, LaunchElfDir);
574 strcat(c, CNF);
575 }
576 ret = genFixPath(c, cnf_path);
577 if((fd=genOpen(cnf_path,O_CREAT|O_WRONLY|O_TRUNC)) < 0){
578 sprintf(mainMsg, "%s %s", LNG(Failed_To_Save), CNF);
579 return;
580 }
581 }
582 ret = genWrite(fd,&tmp,CNF_size);
583 if(ret==CNF_size)
584 sprintf(mainMsg, "%s (%s)", LNG(Saved_Config), c);
585 else
586 sprintf(mainMsg, "%s (%s)", LNG(Failed_writing), CNF);
587 genClose(fd);
588}
589//---------------------------------------------------------------------------
590void initConfig(void)
591{
592 int i;
593
594 if(setting!=NULL)
595 free(setting);
596 setting = (SETTING*)malloc(sizeof(SETTING));
597
598 sprintf(setting->Misc, "%s/", LNG_DEF(MISC));
599 sprintf(setting->Misc_PS2Disc, "%s/%s", LNG_DEF(MISC), LNG_DEF(PS2Disc));
600 sprintf(setting->Misc_FileBrowser, "%s/%s", LNG_DEF(MISC), LNG_DEF(FileBrowser));
601 sprintf(setting->Misc_PS2Browser, "%s/%s", LNG_DEF(MISC), LNG_DEF(PS2Browser));
602 sprintf(setting->Misc_PS2Net, "%s/%s", LNG_DEF(MISC), LNG_DEF(PS2Net));
603 sprintf(setting->Misc_PS2PowerOff, "%s/%s", LNG_DEF(MISC), LNG_DEF(PS2PowerOff));
604 sprintf(setting->Misc_HddManager, "%s/%s", LNG_DEF(MISC), LNG_DEF(HddManager));
605 sprintf(setting->Misc_TextEditor, "%s/%s", LNG_DEF(MISC), LNG_DEF(TextEditor));
606 sprintf(setting->Misc_JpgViewer, "%s/%s", LNG_DEF(MISC), LNG_DEF(JpgViewer));
607 sprintf(setting->Misc_Configure, "%s/%s", LNG_DEF(MISC), LNG_DEF(Configure));
608 sprintf(setting->Misc_Load_CNFprev, "%s/%s", LNG_DEF(MISC), LNG_DEF(Load_CNFprev));
609 sprintf(setting->Misc_Load_CNFnext, "%s/%s", LNG_DEF(MISC), LNG_DEF(Load_CNFnext));
610 sprintf(setting->Misc_Set_CNF_Path, "%s/%s", LNG_DEF(MISC), LNG_DEF(Set_CNF_Path));
611 sprintf(setting->Misc_Load_CNF, "%s/%s", LNG_DEF(MISC), LNG_DEF(Load_CNF));
612 sprintf(setting->Misc_ShowFont, "%s/%s", LNG_DEF(MISC), LNG_DEF(ShowFont));
613 sprintf(setting->Misc_Debug_Info, "%s/%s", LNG_DEF(MISC), LNG_DEF(Debug_Info));
614 sprintf(setting->Misc_About_uLE, "%s/%s", LNG_DEF(MISC), LNG_DEF(About_uLE));
615
616 for(i=0; i<16; i++){
617 setting->LK_Path[i][0] = 0;
618 setting->LK_Title[i][0] = 0;
619 setting->LK_Flag[i] = 0;
620 }
621 for(i=0; i<30; i++) PathPad[i][0] = 0;
622
623 strcpy(setting->LK_Path[1], setting->Misc_FileBrowser);
624 setting->LK_Flag[1] = 1;
625 strcpy(setting->LK_Path[4], setting->Misc_About_uLE);
626 setting->LK_Flag[4] = 1;
627 setting->usbd_file[0] = '\0';
628 setting->usbmass_file[0] = '\0';
629 setting->usbkbd_file[0] = '\0';
630 setting->kbdmap_file[0] = '\0';
631 setting->skin[0] = '\0';
632 setting->GUI_skin[0] = '\0';
633 setting->Menu_Title[0] = '\0';
634 setting->CNF_Path[0] = '\0';
635 setting->lang_file[0] = '\0';
636 setting->font_file[0] = '\0';
637 setting->timeout = DEF_TIMEOUT;
638 setting->Hide_Paths = DEF_HIDE_PATHS;
639 setting->color[0] = DEF_COLOR1;
640 setting->color[1] = DEF_COLOR2;
641 setting->color[2] = DEF_COLOR3;
642 setting->color[3] = DEF_COLOR4;
643 setting->color[4] = DEF_COLOR5;
644 setting->color[5] = DEF_COLOR6;
645 setting->color[6] = DEF_COLOR7;
646 setting->color[7] = DEF_COLOR8;
647 setting->screen_x = SCREEN_X;
648 setting->screen_y = SCREEN_Y;
649 setting->discControl = DEF_DISCCONTROL;
650 setting->interlace = DEF_INTERLACE;
651 setting->Menu_Frame = DEF_MENU_FRAME;
652 setting->Show_Menu = DEF_MENU;
653 setting->resetIOP = DEF_RESETIOP;
654 setting->numCNF = DEF_NUMCNF;
655 setting->swapKeys = DEF_SWAPKEYS;
656 setting->HOSTwrite = DEF_HOSTWRITE;
657 setting->Brightness = DEF_BRIGHT;
658 setting->TV_mode = TV_mode_AUTO; //0==Console_auto, 1==NTSC, 2==PAL
659 setting->Popup_Opaque = DEF_POPUP_OPAQUE;
660 setting->Init_Delay = DEF_INIT_DELAY;
661 setting->usbkbd_used = DEF_USBKBD_USED;
662 setting->Show_Titles = DEF_SHOW_TITLES;
663 setting->PathPad_Lock = DEF_PATHPAD_LOCK;
664 setting->JpgView_Timer = -1; //only used to detect missing variable
665 setting->JpgView_Trans = -1; //only used to detect missing variable
666 setting->JpgView_Full = DEF_JPGVIEW_FULL;
667 setting->PSU_HugeNames = DEF_PSU_HUGENAMES;
668 setting->PSU_DateNames = DEF_PSU_DATENAMES;
669 setting->PSU_NoOverwrite = DEF_PSU_NOOVERWRITE;
670 setting->FB_NoIcons = DEF_FB_NOICONS;
671}
672//------------------------------
673//endfunc initConfig
674//---------------------------------------------------------------------------
675// Load LAUNCHELF.CNF (or LAUNCHELFx.CNF with multiple pages)
676// sincro: ADD load USBD_FILE string
677// polo: ADD load SKIN_FILE string
678// suloku: ADD load MAIN_SKIN string //dlanor: changed to GUI_SKIN_FILE
679// dlanor: added error flag return value 0==OK, -1==failure
680//---------------------------------------------------------------------------
681int loadConfig(char *mainMsg, char *CNF)
682{
683 int i, fd, tst, len, mcport, var_cnt, CNF_version;
684 char tsts[20];
685 char path[MAX_PATH];
686 char cnf_path[MAX_PATH];
687 unsigned char *RAM_p, *CNF_p, *name, *value;
688
689 initConfig();
690
691 strcpy(path, LaunchElfDir);
692 strcat(path, CNF);
693 if(!strncmp(path, "cdrom", 5)) strcat(path, ";1");
694
695 fd=-1;
696 if((tst = genFixPath(path, cnf_path)) >= 0)
697 fd = genOpen(cnf_path, O_RDONLY);
698 if(fd<0) {
699 char strtmp[MAX_PATH], *p;
700 int pos;
701
702 p = strrchr(path, '.'); //make p point to extension
703 if(*(p-1)!='F') //is this an indexed CNF
704 p--; //then make p point to index
705 pos = (p-path);
706 strcpy(strtmp, path);
707 strcpy(strtmp+pos-9, "LNCHELF"); //Replace LAUNCHELF with LNCHELF (for CD)
708 strcpy(strtmp+pos-2, path+pos); //Add index+extension too
709 if((tst = genFixPath(strtmp, cnf_path)) >= 0)
710 fd = genOpen(cnf_path, O_RDONLY);
711 if(fd<0) {
712 if(!strncmp(LaunchElfDir, "mc", 2))
713 mcport = LaunchElfDir[2]-'0';
714 else
715 mcport = CheckMC();
716 if(mcport==1 || mcport==0){
717 sprintf(strtmp, "mc%d:/SYS-CONF/", mcport);
718 strcpy(cnf_path, strtmp);
719 strcat(cnf_path, CNF);
720 fd = genOpen(cnf_path, O_RDONLY);
721 if(fd>=0)
722 strcpy(LaunchElfDir, strtmp);
723 }
724 }
725 }
726 if(fd<0) {
727failed_load:
728 sprintf(mainMsg, "%s %s", LNG(Failed_To_Load), CNF);
729 return -1;
730 }
731 // This point is only reached after succefully opening CNF
732 genClose(fd);
733
734 if( (RAM_p = preloadCNF(cnf_path))==NULL )
735 goto failed_load;
736 CNF_p = RAM_p;
737
738//RA NB: in the code below, the 'LK_' variables have been implemented such that
739// any _Ex suffix will be accepted, with identical results. This will need
740// to be modified when more execution methods are implemented.
741
742 CNF_version = 0; // The CNF version is still unidentified
743 for(var_cnt = 0; get_CNF_string(&CNF_p, &name, &value); var_cnt++)
744 { // A variable was found, now we dispose of its value.
745 if(!strcmp(name,"CNF_version")){
746 CNF_version = atoi(value);
747 continue;
748 } else if(CNF_version == 0)
749 goto failed_load; // Refuse unidentified CNF
750
751 if( scanSkinCNF(name, value) )
752 continue;
753
754 for(i=0; i<16; i++){
755 sprintf(tsts, "LK_%s_E%n", LK_ID[i], &len);
756 if(!strncmp(name, tsts, len)) {
757 strcpy(setting->LK_Path[i], value);
758 setting->LK_Flag[i] = 1;
759 break;
760 }
761 }
762 if(i<16) continue;
763 //----------
764 //In the next group, the Misc device must be defined before its subprograms
765 //----------
766 else if(!strcmp(name,"Misc")) sprintf(setting->Misc, "%s/", value);
767 else if(!strcmp(name,"Misc_PS2Disc"))
768 sprintf(setting->Misc_PS2Disc, "%s%s", setting->Misc, value);
769 else if(!strcmp(name,"Misc_FileBrowser"))
770 sprintf(setting->Misc_FileBrowser, "%s%s", setting->Misc, value);
771 else if(!strcmp(name,"Misc_PS2Browser"))
772 sprintf(setting->Misc_PS2Browser, "%s%s", setting->Misc, value);
773 else if(!strcmp(name,"Misc_PS2Net"))
774 sprintf(setting->Misc_PS2Net, "%s%s", setting->Misc, value);
775 else if(!strcmp(name,"Misc_PS2PowerOff"))
776 sprintf(setting->Misc_PS2PowerOff, "%s%s", setting->Misc, value);
777 else if(!strcmp(name,"Misc_HddManager"))
778 sprintf(setting->Misc_HddManager, "%s%s", setting->Misc, value);
779 else if(!strcmp(name,"Misc_TextEditor"))
780 sprintf(setting->Misc_TextEditor, "%s%s", setting->Misc, value);
781 else if(!strcmp(name,"Misc_JpgViewer"))
782 sprintf(setting->Misc_JpgViewer, "%s%s", setting->Misc, value);
783 else if(!strcmp(name,"Misc_Configure"))
784 sprintf(setting->Misc_Configure, "%s%s", setting->Misc, value);
785 else if(!strcmp(name,"Misc_Load_CNFprev"))
786 sprintf(setting->Misc_Load_CNFprev, "%s%s", setting->Misc, value);
787 else if(!strcmp(name,"Misc_Load_CNFnext"))
788 sprintf(setting->Misc_Load_CNFnext, "%s%s", setting->Misc, value);
789 else if(!strcmp(name,"Misc_Set_CNF_Path"))
790 sprintf(setting->Misc_Set_CNF_Path, "%s%s", setting->Misc, value);
791 else if(!strcmp(name,"Misc_Load_CNF"))
792 sprintf(setting->Misc_Load_CNF, "%s%s", setting->Misc, value);
793 else if(!strcmp(name,"Misc_ShowFont"))
794 sprintf(setting->Misc_ShowFont, "%s%s", setting->Misc, value);
795 else if(!strcmp(name,"Misc_Debug_Info"))
796 sprintf(setting->Misc_Debug_Info, "%s%s", setting->Misc, value);
797 else if(!strcmp(name,"Misc_About_uLE"))
798 sprintf(setting->Misc_About_uLE, "%s%s", setting->Misc, value);
799 //----------
800 else if(!strcmp(name,"LK_auto_Timer")) setting->timeout = atoi(value);
801 else if(!strcmp(name,"Menu_Hide_Paths")) setting->Hide_Paths = atoi(value);
802 //---------- NB: color settings moved to scanSkinCNF
803 else if(!strcmp(name,"Init_CDVD_Check")) setting->discControl = atoi(value);
804 else if(!strcmp(name,"Init_Reset_IOP")) setting->resetIOP = atoi(value);
805 else if(!strcmp(name,"Menu_Pages")) setting->numCNF = atoi(value);
806 else if(!strcmp(name,"GUI_Swap_Keys")) setting->swapKeys = atoi(value);
807 else if(!strcmp(name,"USBD_FILE")) strcpy(setting->usbd_file,value);
808 else if(!strcmp(name,"NET_HOSTwrite")) setting->HOSTwrite = atoi(value);
809 else if(!strcmp(name,"Menu_Title")){
810 strncpy(setting->Menu_Title, value, MAX_MENU_TITLE);
811 setting->Menu_Title[MAX_MENU_TITLE] = '\0';
812 }
813 else if(!strcmp(name,"Init_Delay")) setting->Init_Delay = atoi(value);
814 else if(!strcmp(name,"USBKBD_USED")) setting->usbkbd_used = atoi(value);
815 else if(!strcmp(name,"USBKBD_FILE")) strcpy(setting->usbkbd_file,value);
816 else if(!strcmp(name,"KBDMAP_FILE")) strcpy(setting->kbdmap_file,value);
817 else if(!strcmp(name,"Menu_Show_Titles")) setting->Show_Titles = atoi(value);
818 else if(!strcmp(name,"PathPad_Lock")) setting->PathPad_Lock = atoi(value);
819 else if(!strcmp(name,"CNF_Path")) strcpy(setting->CNF_Path,value);
820 else if(!strcmp(name,"USBMASS_FILE")) strcpy(setting->usbmass_file,value);
821 else if(!strcmp(name,"LANG_FILE")) strcpy(setting->lang_file,value);
822 else if(!strcmp(name,"FONT_FILE")) strcpy(setting->font_file,value);
823 //----------
824 else if(!strcmp(name,"JpgView_Timer")) setting->JpgView_Timer = atoi(value);
825 else if(!strcmp(name,"JpgView_Trans")) setting->JpgView_Trans = atoi(value);
826 else if(!strcmp(name,"JpgView_Full")) setting->JpgView_Full = atoi(value);
827 //----------
828 else if(!strcmp(name,"PSU_HugeNames")) setting->PSU_HugeNames = atoi(value);
829 else if(!strcmp(name,"PSU_DateNames")) setting->PSU_DateNames = atoi(value);
830 else if(!strcmp(name,"PSU_NoOverwrite")) setting->PSU_NoOverwrite = atoi(value);
831 else if(!strcmp(name,"FB_NoIcons")) setting->FB_NoIcons = atoi(value);
832 //----------
833 else {
834 for(i=0; i<16; i++){
835 sprintf(tsts, "LK_%s_Title", LK_ID[i]);
836 if(!strcmp(name, tsts)) {
837 strncpy(setting->LK_Title[i], value, MAX_ELF_TITLE-1);
838 break;
839 }
840 }
841 if(i<16) continue;
842 else if(!strncmp(name,"PathPad[",8)){
843 i = atoi(name+8);
844 if(i < 30){
845 strncpy(PathPad[i], value, MAX_PATH-1);
846 PathPad[i][MAX_PATH-1] = '\0';
847 }
848 }
849 }
850 } //ends for
851 for(i=0; i<16; i++) setting->LK_Title[i][MAX_ELF_TITLE-1] = 0;
852 free(RAM_p);
853 if(setting->JpgView_Timer < 0)
854 setting->JpgView_Timer = DEF_JPGVIEW_TIMER;
855 if((setting->JpgView_Trans < 1) || (setting->JpgView_Trans > 4))
856 setting->JpgView_Trans = DEF_JPGVIEW_TRANS;
857 sprintf(mainMsg, "%s (%s)", LNG(Loaded_Config), path);
858 return 0;
859}
860//------------------------------
861//endfunc loadConfig
862//---------------------------------------------------------------------------
863// Polo: ADD Skin Menu with Skin preview
864// suloku: ADD Main skin selection
865//---------------------------------------------------------------------------
866void Config_Skin(void)
867{
868 int s, max_s=7;
869 int x, y;
870 int event, post_event=0;
871 char c[MAX_PATH];
872 char skinSave[MAX_PATH], GUI_Save[MAX_PATH];
873 int Brightness = setting->Brightness;
874 int current_preview = 0;
875
876 strcpy(skinSave, setting->skin);
877 strcpy(GUI_Save, setting->GUI_skin);
878
879 loadSkin(PREVIEW_PIC, 0, 0);
880 current_preview = PREVIEW_PIC;
881
882 s=1;
883 event = 1; //event = initial entry
884 while(1)
885 {
886 //Pad response section
887 waitPadReady(0, 0);
888 if(readpad())
889 {
890 if(new_pad & PAD_UP)
891 {
892 event |= 2; //event |= valid pad command
893 if(s!=1) s--;
894 else s=max_s;
895 }
896 else if(new_pad & PAD_DOWN)
897 {
898 event |= 2; //event |= valid pad command
899 if(s!=max_s) s++;
900 else s=1;
901 }
902 else if(new_pad & PAD_LEFT)
903 {
904 event |= 2; //event |= valid pad command
905 if(s!=1) s=1;
906 else s=max_s;
907 }
908 else if(new_pad & PAD_RIGHT)
909 {
910 event |= 2; //event |= valid pad command
911 if(s!=max_s) s=max_s;
912 else s=1;
913 }
914 else if((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE) )
915 {
916 event |= 2; //event |= valid pad command
917 if(s==1) { //Command == Cancel Skin Path
918 setting->skin[0] = '\0';
919 loadSkin(PREVIEW_PIC, 0, 0);
920 current_preview = PREVIEW_PIC;
921 } else if(s==3) { //Command == Decrease Brightness
922 if((Brightness > 0)&&(testsetskin == 1)) {
923 Brightness--;
924 }
925 } else if(s==4) { //Command == Cancel GUI Skin Path
926 setting->GUI_skin[0] = '\0';
927 loadSkin(PREVIEW_GUI, 0, 0);
928 current_preview = PREVIEW_GUI;
929 }
930 }
931 else if((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE))
932 {
933 event |= 2; //event |= valid pad command
934 if(s==1) { //Command == Set Skin Path
935 getFilePath(setting->skin, SKIN_CNF);
936 loadSkin(PREVIEW_PIC, 0, 0);
937 current_preview = PREVIEW_PIC;
938 } else if(s==2) { //Command == Apply New Skin
939 GUI_active = 0;
940 loadSkin(BACKGROUND_PIC, 0, 0);
941 setting->Brightness = Brightness;
942 strcpy(skinSave, setting->skin);
943 loadSkin(PREVIEW_PIC, 0, 0);
944 current_preview = PREVIEW_PIC;
945 } else if(s==3) { //Command == Increase Brightness
946 if((Brightness < 100)&&(testsetskin == 1)) {
947 Brightness++;
948 }
949 } else if(s==4) { //Command == Set GUI Skin Path
950 getFilePath(setting->GUI_skin, GUI_SKIN_CNF);
951 loadSkin(PREVIEW_GUI, 0, 0);
952 current_preview = PREVIEW_GUI;
953 } else if(s==5) { //Command == Apply GUI Skin
954 strcpy(GUI_Save, setting->GUI_skin);
955 loadSkin(PREVIEW_GUI, 0, 0);
956 current_preview = PREVIEW_GUI;
957 } else if(s==6) { //Command == Show GUI Menu
958 setting->Show_Menu = !setting->Show_Menu;
959 } else if(s==7) { //Command == RETURN
960 setting->skin[0] = '\0';
961 strcpy(setting->skin, skinSave);
962 setting->GUI_skin[0] = '\0';
963 strcpy(setting->GUI_skin, GUI_Save);
964 return;
965 }
966 }
967 else if(new_pad & PAD_TRIANGLE) {
968 setting->skin[0] = '\0';
969 strcpy(setting->skin, skinSave);
970 setting->GUI_skin[0] = '\0';
971 strcpy(setting->GUI_skin, GUI_Save);
972 return;
973 }
974 } //end if(readpad())
975
976 if(event||post_event){ //NB: We need to update two frame buffers per event
977
978 //Display section
979 clrScr(setting->color[0]);
980
981 if ( testsetskin == 1 ) {
982 setBrightness(Brightness);
983 gsKit_prim_sprite_texture(gsGlobal, &TexPreview,
984 SCREEN_WIDTH/4, ( SCREEN_HEIGHT/4 )+60, 0, 0,
985 ( SCREEN_WIDTH/4 )*3, ( ( SCREEN_HEIGHT/4 )*3 )+60, SCREEN_WIDTH, SCREEN_HEIGHT,
986 0, BrightColor);
987 setBrightness(50);
988 } else {
989 gsKit_prim_sprite(gsGlobal,
990 SCREEN_WIDTH/4, ( SCREEN_HEIGHT/4 )+60, ( SCREEN_WIDTH/4 )*3, ( ( SCREEN_HEIGHT/4 )*3 )+60,
991 0, setting->color[0]);
992 }
993 drawFrame( ( SCREEN_WIDTH/4 )-2, ( ( SCREEN_HEIGHT/4 )+60 )-1,
994 ( ( SCREEN_WIDTH/4 )*3 )+1, ( ( SCREEN_HEIGHT/4 )*3 )+60,
995 setting->color[1]);
996
997 x = Menu_start_x;
998 y = Menu_start_y;
999
1000 printXY(LNG(SKIN_SETTINGS), x, y, setting->color[3], TRUE, 0);
1001 y += FONT_HEIGHT;
1002
1003 if(strlen(setting->skin)==0)
1004 sprintf(c, " %s: %s", LNG(Skin_Path), LNG(NULL));
1005 else
1006 sprintf(c, " %s: %s", LNG(Skin_Path), setting->skin);
1007 printXY(c, x, y, setting->color[3], TRUE, 0);
1008 y += FONT_HEIGHT;
1009
1010 sprintf(c, " %s", LNG(Apply_New_Skin));
1011 printXY(c, x, y, setting->color[3], TRUE, 0);
1012 y += FONT_HEIGHT;
1013
1014 sprintf(c, " %s: %d", LNG(Brightness), Brightness);
1015 printXY(c, x, y, setting->color[3], TRUE, 0);
1016 y += FONT_HEIGHT;
1017
1018 if(strlen(setting->GUI_skin)==0)
1019 sprintf(c, " %s %s: %s", LNG(GUI), LNG(Skin_Path), LNG(NULL));
1020 else
1021 sprintf(c, " %s %s: %s", LNG(GUI), LNG(Skin_Path), setting->GUI_skin);
1022 printXY(c, x, y, setting->color[3], TRUE, 0);
1023 y += FONT_HEIGHT;
1024
1025 sprintf(c, " %s", LNG(Apply_GUI_Skin));
1026 printXY(c, x, y, setting->color[3], TRUE, 0);
1027 y += FONT_HEIGHT;
1028
1029 if(setting->Show_Menu)
1030 sprintf(c, " %s: %s", LNG(Show_Menu), LNG(ON));
1031 else
1032 sprintf(c, " %s: %s", LNG(Show_Menu), LNG(OFF));
1033 printXY(c, x, y, setting->color[3], TRUE, 0);
1034 y += FONT_HEIGHT;
1035
1036 sprintf(c, " %s", LNG(RETURN));
1037 printXY(c, x, y, setting->color[3], TRUE, 0);
1038 y += FONT_HEIGHT;
1039
1040 if(current_preview == PREVIEW_PIC)
1041 sprintf(c, "%s ", LNG(Normal));
1042 else
1043 sprintf(c, "%s ", LNG(GUI));
1044 strcat(c, LNG(Skin_Preview));
1045 printXY(c, SCREEN_WIDTH/4, (SCREEN_HEIGHT/4)+78-FONT_HEIGHT, setting->color[3], TRUE, 0);
1046
1047 //Cursor positioning section
1048 y = Menu_start_y + s*(FONT_HEIGHT);
1049 drawChar(LEFT_CUR, x, y, setting->color[3]);
1050
1051 //Tooltip section
1052 if ((s == 1)||(s == 4)) {
1053 if (swapKeys)
1054 sprintf(c, "ÿ1:%s ÿ0:%s", LNG(Edit), LNG(Clear));
1055 else
1056 sprintf(c, "ÿ0:%s ÿ1:%s", LNG(Edit), LNG(Clear));
1057 } else if (s == 3) { //if cursor at a colour component or a screen offset
1058 if (swapKeys)
1059 sprintf(c, "ÿ1:%s ÿ0:%s", LNG(Add), LNG(Subtract));
1060 else
1061 sprintf(c, "ÿ0:%s ÿ1:%s", LNG(Add), LNG(Subtract));
1062 } else if (s == 6) {
1063 if (swapKeys)
1064 sprintf(c, "ÿ1:%s", LNG(Change));
1065 else
1066 sprintf(c, "ÿ0:%s", LNG(Change));
1067 } else {
1068 if (swapKeys)
1069 sprintf(c, "ÿ1:%s", LNG(OK));
1070 else
1071 sprintf(c, "ÿ0:%s", LNG(OK));
1072 }
1073 sprintf(tmp, " ÿ3:%s", LNG(Return));
1074 strcat(c, tmp);
1075 setScrTmp("", c);
1076 }//ends if(event||post_event)
1077 drawScr();
1078 post_event = event;
1079 event = 0;
1080
1081 }//ends while
1082}//ends Config_Skin
1083//---------------------------------------------------------------------------
1084void Config_Screen(void)
1085{
1086 int i;
1087 int s, max_s=35; //define cursor index and its max value
1088 int x, y;
1089 int event, post_event=0;
1090 u64 rgb[8][3];
1091 char c[MAX_PATH];
1092 int space=((SCREEN_WIDTH-SCREEN_MARGIN-4*FONT_WIDTH)-(Menu_start_x+2*FONT_WIDTH))/8;
1093
1094 event = 1; //event = initial entry
1095
1096 for(i=0; i<8; i++) {
1097 rgb[i][0] = setting->color[i] & 0xFF;
1098 rgb[i][1] = setting->color[i] >> 8 & 0xFF;
1099 rgb[i][2] = setting->color[i] >> 16 & 0xFF;
1100 }
1101
1102 s=0;
1103 while(1)
1104 {
1105 //Pad response section
1106 waitPadReady(0, 0);
1107 if(readpad())
1108 {
1109 if(new_pad & PAD_UP)
1110 {
1111 event |= 2; //event |= valid pad command
1112 if(s==0)
1113 s=max_s;
1114 else if(s==24)
1115 s=2;
1116 else
1117 s--;
1118 }
1119 else if(new_pad & PAD_DOWN)
1120 {
1121 event |= 2; //event |= valid pad command
1122 if((s<24)&&(s%3==2))
1123 s=24;
1124 else if(s==max_s)
1125 s=0;
1126 else
1127 s++;
1128 }
1129 else if(new_pad & PAD_LEFT)
1130 {
1131 event |= 2; //event |= valid pad command
1132 if(s>=34) s=32;
1133 else if(s>=32) s=31;
1134 else if(s>=31) s=28;
1135 else if(s>=28) s=27;
1136 else if(s>=27) s=25;
1137 else if(s>=25) s=24; //at or
1138 else if(s>=24) s=21; //if s beyond color settings
1139 else if(s>=3) s-=3; //if s in a color beyond Color1 step to preceding color
1140 }
1141 else if(new_pad & PAD_RIGHT)
1142 {
1143 event |= 2; //event |= valid pad command
1144 if(s>=32) s=34;
1145 else if(s>=31) s=32;
1146 else if(s>=28) s=31;
1147 else if(s>=27) s=28;
1148 else if(s>=25) s=27;
1149 else if(s>=24) s=25;
1150 else if(s>=21) s=24; //if s in Color8, move it to ScreenX
1151 else s+=3; //if s in a color before Color8, step to next color
1152 }
1153 else if((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE) )
1154 { //User pressed CANCEL=>Subtract/Clear
1155 event |= 2; //event |= valid pad command
1156 if(s<24) {
1157 if(rgb[s/3][s%3] > 0) {
1158 rgb[s/3][s%3]--;
1159 setting->color[s/3] =
1160 GS_SETREG_RGBA(rgb[s/3][0], rgb[s/3][1], rgb[s/3][2], 0);
1161 }
1162 } else if(s==25) {
1163 if(setting->screen_x > 0) {
1164 setting->screen_x--;
1165 updateScreenMode(0);
1166 }
1167 } else if(s==26) {
1168 if(setting->screen_y > 0) {
1169 setting->screen_y--;
1170 updateScreenMode(0);
1171 }
1172 } else if(s==31) { //cursor is at Menu_Title
1173 setting->Menu_Title[0] = '\0';
1174 }
1175 }
1176 else if((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE))
1177 { //User pressed OK=>Add/Ok/Edit
1178 event |= 2; //event |= valid pad command
1179 if(s<24) {
1180 if(rgb[s/3][s%3] < 255) {
1181 rgb[s/3][s%3]++;
1182 setting->color[s/3] =
1183 GS_SETREG_RGBA(rgb[s/3][0], rgb[s/3][1], rgb[s/3][2], 0);
1184 }
1185 }else if(s==24){
1186 setting->TV_mode = (setting->TV_mode+1)%3; //Change between 0,1,2
1187 updateScreenMode(1);
1188 } else if(s==25) {
1189 setting->screen_x++;
1190 updateScreenMode(0);
1191 } else if(s==26) {
1192 setting->screen_y++;
1193 updateScreenMode(0);
1194 } else if(s==27) {
1195 setting->interlace = !setting->interlace;
1196 updateScreenMode(1);
1197 } else if(s==28) {
1198 Config_Skin();
1199 } else if(s==29) {
1200 loadSkinBrowser();
1201 } else if(s==30) {
1202 saveSkinBrowser();
1203 } else if(s==31) { //cursor is at Menu_Title
1204 char tmp[MAX_MENU_TITLE+1];
1205 strcpy(tmp, setting->Menu_Title);
1206 if(keyboard(tmp, 36)>=0)
1207 strcpy(setting->Menu_Title, tmp);
1208 } else if(s==32) {
1209 setting->Menu_Frame = !setting->Menu_Frame;
1210 } else if(s==33) {
1211 setting->Popup_Opaque = !setting->Popup_Opaque;
1212 } else if(s==max_s-1) { //Always put 'RETURN' next to last
1213 return;
1214 } else if(s==max_s) { //Always put 'DEFAULT SCREEN SETTINGS' last
1215 setting->skin[0] = '\0';
1216 setting->GUI_skin[0] = '\0';
1217 loadSkin(BACKGROUND_PIC, 0, 0);
1218 setting->color[0] = DEF_COLOR1;
1219 setting->color[1] = DEF_COLOR2;
1220 setting->color[2] = DEF_COLOR3;
1221 setting->color[3] = DEF_COLOR4;
1222 setting->color[4] = DEF_COLOR5;
1223 setting->color[5] = DEF_COLOR6;
1224 setting->color[6] = DEF_COLOR7;
1225 setting->color[7] = DEF_COLOR8;
1226 setting->TV_mode = TV_mode_AUTO;
1227 setting->screen_x = SCREEN_X;
1228 setting->screen_y = SCREEN_Y;
1229 setting->interlace = DEF_INTERLACE;
1230 setting->Menu_Frame = DEF_MENU_FRAME;
1231 setting->Show_Menu = DEF_MENU;
1232 setting->Brightness = DEF_BRIGHT;
1233 setting->Popup_Opaque = DEF_POPUP_OPAQUE;
1234 updateScreenMode(0);
1235
1236 for(i=0; i<8; i++) {
1237 rgb[i][0] = setting->color[i] & 0xFF;
1238 rgb[i][1] = setting->color[i] >> 8 & 0xFF;
1239 rgb[i][2] = setting->color[i] >> 16 & 0xFF;
1240 }
1241 }
1242 }
1243 else if(new_pad & PAD_TRIANGLE)
1244 return;
1245 }
1246
1247 if(event||post_event){ //NB: We need to update two frame buffers per event
1248
1249 //Display section
1250 clrScr(setting->color[0]);
1251
1252 x = Menu_start_x;
1253
1254 for(i=0; i<8; i++){
1255 y = Menu_start_y;
1256 sprintf(c, "%s%d", LNG(Color), i+1);
1257 printXY(c, x+(space*(i+1))-(printXY(c, 0, 0, 0, FALSE, space-FONT_WIDTH/2)/2), y,
1258 setting->color[3], TRUE, space-FONT_WIDTH/2);
1259 if(i==0)
1260 sprintf(c, "%s", LNG(Backgr));
1261 else if(i==1)
1262 sprintf(c, "%s", LNG(Frames));
1263 else if(i==2)
1264 sprintf(c, "%s", LNG(Select));
1265 else if(i==3)
1266 sprintf(c, "%s", LNG(Normal));
1267 else if(i>=4)
1268 sprintf(c, "%s%d", LNG(Graph), i-3);
1269 printXY(c, x+(space*(i+1))-(printXY(c, 0, 0, 0, FALSE, space-FONT_WIDTH/2)/2), y+FONT_HEIGHT,
1270 setting->color[3], TRUE, space-FONT_WIDTH/2);
1271 y += FONT_HEIGHT*2;
1272 printXY("R:", x, y, setting->color[3], TRUE, 0);
1273 sprintf(c, "%02lX", rgb[i][0]);
1274 printXY(c, x+(space*(i+1))-FONT_WIDTH, y, setting->color[3], TRUE, 0);
1275 y += FONT_HEIGHT;
1276 printXY("G:", x, y, setting->color[3], TRUE, 0);
1277 sprintf(c, "%02lX", rgb[i][1]);
1278 printXY(c, x+(space*(i+1))-FONT_WIDTH, y, setting->color[3], TRUE, 0);
1279 y += FONT_HEIGHT;
1280 printXY("B:", x, y, setting->color[3], TRUE, 0);
1281 sprintf(c, "%02lX", rgb[i][2]);
1282 printXY(c, x+(space*(i+1))-FONT_WIDTH, y, setting->color[3], TRUE, 0);
1283 y += FONT_HEIGHT;
1284 sprintf(c, "ÿ4");
1285 printXY(c, x+(space*(i+1))-FONT_WIDTH, y, setting->color[i], TRUE, 0);
1286 } //ends loop for colour RGB values
1287 y += FONT_HEIGHT*2;
1288 sprintf(c, " %s: ", LNG(TV_mode));
1289 if(setting->TV_mode==TV_mode_NTSC)
1290 strcat(c, "NTSC");
1291 else if(setting->TV_mode==TV_mode_PAL)
1292 strcat(c, "PAL");
1293 else
1294 strcat(c, "AUTO");
1295 printXY(c, x, y, setting->color[3], TRUE, 0);
1296 y += FONT_HEIGHT;
1297 y += FONT_HEIGHT / 2;
1298
1299 sprintf(c, " %s: %d", LNG(Screen_X_offset), setting->screen_x);
1300 printXY(c, x, y, setting->color[3], TRUE, 0);
1301 y += FONT_HEIGHT;
1302 sprintf(c, " %s: %d", LNG(Screen_Y_offset), setting->screen_y);
1303 printXY(c, x, y, setting->color[3], TRUE, 0);
1304 y += FONT_HEIGHT;
1305 y += FONT_HEIGHT / 2;
1306
1307 if(setting->interlace)
1308 sprintf(c, " %s: %s", LNG(Interlace), LNG(ON));
1309 else
1310 sprintf(c, " %s: %s", LNG(Interlace), LNG(OFF));
1311 printXY(c, x, y, setting->color[3], TRUE, 0);
1312 y += FONT_HEIGHT;
1313 y += FONT_HEIGHT / 2;
1314
1315 sprintf(c, " %s...", LNG(Skin_Settings));
1316 printXY(c, x, y, setting->color[3], TRUE, 0);
1317 y += FONT_HEIGHT;
1318 sprintf(c, " %s...", LNG(Load_Skin_CNF));
1319 printXY(c, x, y, setting->color[3], TRUE, 0);
1320 y += FONT_HEIGHT;
1321 sprintf(c, " %s...", LNG(Save_Skin_CNF));
1322 printXY(c, x, y, setting->color[3], TRUE, 0);
1323 y += FONT_HEIGHT;
1324 y += FONT_HEIGHT / 2;
1325
1326 if(setting->Menu_Title[0]=='\0')
1327 sprintf(c, " %s: %s", LNG(Menu_Title), LNG(NULL));
1328 else
1329 sprintf(c, " %s: %s", LNG(Menu_Title),setting->Menu_Title);
1330 printXY(c, x, y, setting->color[3], TRUE, 0);
1331 y += FONT_HEIGHT;
1332 y += FONT_HEIGHT / 2;
1333
1334 if(setting->Menu_Frame)
1335 sprintf(c, " %s: %s", LNG(Menu_Frame), LNG(ON));
1336 else
1337 sprintf(c, " %s: %s", LNG(Menu_Frame), LNG(OFF));
1338 printXY(c, x, y, setting->color[3], TRUE, 0);
1339 y += FONT_HEIGHT;
1340
1341 if(setting->Popup_Opaque)
1342 sprintf(c, " %s: %s", LNG(Popups_Opaque), LNG(ON));
1343 else
1344 sprintf(c, " %s: %s", LNG(Popups_Opaque), LNG(OFF));
1345 printXY(c, x, y, setting->color[3], TRUE, 0);
1346 y += FONT_HEIGHT;
1347 y += FONT_HEIGHT / 2;
1348
1349 sprintf(c, " %s", LNG(RETURN));
1350 printXY(c, x, y, setting->color[3], TRUE, 0);
1351 y += FONT_HEIGHT;
1352 sprintf(c, " %s", LNG(Use_Default_Screen_Settings));
1353 printXY(c, x, y, setting->color[3], TRUE, 0);
1354 y += FONT_HEIGHT;
1355
1356 //Cursor positioning section
1357 x = Menu_start_x;
1358 y = Menu_start_y;
1359
1360 if(s<24){ //if cursor indicates a colour component
1361 int colnum = s/3;
1362 int comnum = s-colnum*3;
1363 x += (space*(colnum+1))-(FONT_WIDTH*4);
1364 y += (2+comnum)*FONT_HEIGHT;
1365 } else { //if cursor indicates anything after colour components
1366 y += (s-24+6)*FONT_HEIGHT+FONT_HEIGHT/2; //adjust y for cursor beyond colours
1367 //Here y is almost correct, except for additional group spacing
1368 if(s>=24) //if cursor at or beyond TV mode choice
1369 y+=FONT_HEIGHT/2; //adjust for half-row space below colours
1370 if(s>=25) //if cursor at or beyond screen offsets
1371 y+=FONT_HEIGHT/2; //adjust for half-row space below TV mode choice
1372 if(s>=27) //if cursor at or beyond interlace choice
1373 y+=FONT_HEIGHT/2; //adjust for half-row space below screen offsets
1374 if(s>=28) //if cursor at or beyond 'SKIN SETTINGS'
1375 y+=FONT_HEIGHT/2; //adjust for half-row space below interlace choice
1376 if(s>=31) //if cursor at or beyond 'Menu Title'
1377 y+=FONT_HEIGHT/2; //adjust for half-row space below 'SKIN SETTINGS'
1378 if(s>=32) //if cursor at or beyond 'Menu Frame'
1379 y+=FONT_HEIGHT/2; //adjust for half-row space below 'Menu Title'
1380 if(s>=max_s-1) //if cursor at or beyond 'RETURN'
1381 y+=FONT_HEIGHT/2; //adjust for half-row space below 'Popups Opaque'
1382 }
1383 drawChar(LEFT_CUR, x, y, setting->color[3]); //draw cursor
1384
1385 //Tooltip section
1386 if (s<24||s==25||s==26) { //if cursor at a colour component or a screen offset
1387 if (swapKeys)
1388 sprintf(c, "ÿ1:%s ÿ0:%s", LNG(Add), LNG(Subtract));
1389 else
1390 sprintf(c, "ÿ0:%s ÿ1:%s", LNG(Add), LNG(Subtract));
1391 } else if(s==24||s==27||s==32||s==33) {
1392 //if cursor at 'TV mode', 'INTERLACE', 'Menu Frame' or 'Popups Opaque'
1393 if (swapKeys)
1394 sprintf(c, "ÿ1:%s", LNG(Change));
1395 else
1396 sprintf(c, "ÿ0:%s", LNG(Change));
1397 } else if(s==28||s==29||s==30){ //if cursor at 'SKIN SETTINGS'
1398 if (swapKeys)
1399 sprintf(c, "ÿ1:%s", LNG(OK));
1400 else
1401 sprintf(c, "ÿ0:%s", LNG(OK));
1402 } else if(s==31){ //if cursor at Menu_Title
1403 if (swapKeys)
1404 sprintf(c, "ÿ1:%s ÿ0:%s", LNG(Edit), LNG(Clear));
1405 else
1406 sprintf(c, "ÿ0:%s ÿ1:%s", LNG(Edit), LNG(Clear));
1407 } else { //if cursor at 'RETURN' or 'DEFAULT' options
1408 if (swapKeys)
1409 sprintf(c, "ÿ1:%s", LNG(OK));
1410 else
1411 sprintf(c, "ÿ0:%s", LNG(OK));
1412 }
1413 sprintf(tmp, " ÿ3:%s", LNG(Return));
1414 strcat(c, tmp);
1415 setScrTmp("", c);
1416 }//ends if(event||post_event)
1417 drawScr();
1418 post_event = event;
1419 event = 0;
1420
1421 }//ends while
1422}//ends Config_Screen
1423//---------------------------------------------------------------------------
1424// Other settings by EP
1425// sincro: ADD USBD SELECTOR MENU
1426// dlanor: Add Menu_Title config
1427//---------------------------------------------------------------------------
1428void Config_Startup(void)
1429{
1430 int s, max_s=15; //define cursor index and its max value
1431 int x, y;
1432 int event, post_event=0;
1433 char c[MAX_PATH];
1434
1435 event = 1; //event = initial entry
1436 s=1;
1437 while(1)
1438 {
1439 //Pad response section
1440 waitPadReady(0, 0);
1441 if(readpad())
1442 {
1443 if(new_pad & PAD_UP)
1444 {
1445 event |= 2; //event |= valid pad command
1446 if(s!=1) s--;
1447 else s=max_s;
1448 }
1449 else if(new_pad & PAD_DOWN)
1450 {
1451 event |= 2; //event |= valid pad command
1452 if(s!=max_s) s++;
1453 else s=1;
1454 }
1455 else if(new_pad & PAD_LEFT)
1456 {
1457 event |= 2; //event |= valid pad command
1458 if(s!=max_s) s=max_s;
1459 else s=1;
1460 }
1461 else if(new_pad & PAD_RIGHT)
1462 {
1463 event |= 2; //event |= valid pad command
1464 if(s!=max_s) s=max_s;
1465 else s=1;
1466 }
1467 else if((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE) )
1468 {
1469 event |= 2; //event |= valid pad command
1470 if(s==2 && setting->numCNF>1) setting->numCNF--;
1471 else if(s==4) setting->usbd_file[0] = '\0';
1472 else if(s==5 && setting->Init_Delay>0) setting->Init_Delay--;
1473 else if(s==6 && setting->timeout>0) setting->timeout--;
1474 else if(s==8) setting->usbkbd_file[0] = '\0';
1475 else if(s==9) setting->kbdmap_file[0] = '\0';
1476 else if(s==10) setting->CNF_Path[0] = '\0';
1477 else if(s==11) setting->usbmass_file[0] = '\0';
1478 else if(s==12){
1479 setting->lang_file[0] = '\0';
1480 Load_External_Language();
1481 }
1482 else if(s==13){
1483 setting->font_file[0] = '\0';
1484 loadFont("");
1485 }else if(s==14){
1486 setting->LK_Path[15][0] = 0;
1487 setting->LK_Flag[15] = 0;
1488 }
1489 }
1490 else if((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE))
1491 {
1492 event |= 2; //event |= valid pad command
1493 if(s==1)
1494 setting->resetIOP = !setting->resetIOP;
1495 else if(s==2)
1496 setting->numCNF++;
1497 else if(s==3)
1498 setting->swapKeys = !setting->swapKeys;
1499 else if(s==4)
1500 getFilePath(setting->usbd_file, USBD_IRX_CNF);
1501 else if(s==5)
1502 setting->Init_Delay++;
1503 else if(s==6)
1504 setting->timeout++;
1505 else if(s==7)
1506 setting->usbkbd_used = !setting->usbkbd_used;
1507 else if(s==8)
1508 getFilePath(setting->usbkbd_file, USBKBD_IRX_CNF);
1509 else if(s==9)
1510 getFilePath(setting->kbdmap_file, KBDMAP_FILE_CNF);
1511 else if(s==10)
1512 { char *tmp;
1513
1514 getFilePath(setting->CNF_Path, CNF_PATH_CNF);
1515 if((tmp = strrchr(setting->CNF_Path, '/')))
1516 tmp[1] = '\0';
1517 }
1518 else if(s==11)
1519 getFilePath(setting->usbmass_file, USBMASS_IRX_CNF);
1520 else if(s==12){
1521 getFilePath(setting->lang_file, LANG_CNF);
1522 Load_External_Language();
1523 }else if(s==13){
1524 getFilePath(setting->font_file, FONT_CNF);
1525 if(loadFont(setting->font_file)==0)
1526 setting->font_file[0] = '\0';
1527 }else if(s==14){
1528 getFilePath(setting->LK_Path[15], TRUE);
1529 if(!strncmp(setting->LK_Path[15], "mc0", 3) ||
1530 !strncmp(setting->LK_Path[15], "mc1", 3)){
1531 sprintf(c, "mc%s", &setting->LK_Path[15][3]);
1532 strcpy(setting->LK_Path[15], c);
1533 }
1534 if(setting->LK_Path[15][0])
1535 setting->LK_Flag[15] = 1;
1536 }else if(s==max_s)
1537 return;
1538 }
1539 else if(new_pad & PAD_TRIANGLE)
1540 return;
1541 }
1542
1543 if(event||post_event){ //NB: We need to update two frame buffers per event
1544
1545 //Display section
1546 clrScr(setting->color[0]);
1547
1548 x = Menu_start_x;
1549 y = Menu_start_y;
1550
1551 printXY(LNG(STARTUP_SETTINGS), x, y, setting->color[3], TRUE, 0);
1552 y += FONT_HEIGHT;
1553 y += FONT_HEIGHT / 2;
1554
1555 if(setting->resetIOP)
1556 sprintf(c, " %s: %s", LNG(Reset_IOP), LNG(ON));
1557 else
1558 sprintf(c, " %s: %s", LNG(Reset_IOP), LNG(OFF));
1559 printXY(c, x, y, setting->color[3], TRUE, 0);
1560 y += FONT_HEIGHT;
1561
1562 sprintf(c, " %s: %d", LNG(Number_of_CNFs), setting->numCNF);
1563 printXY(c, x, y, setting->color[3], TRUE, 0);
1564 y += FONT_HEIGHT;
1565
1566 if(setting->swapKeys)
1567 sprintf(c, " %s: ÿ1:%s ÿ0:%s", LNG(Pad_mapping), LNG(OK), LNG(CANCEL));
1568 else
1569 sprintf(c, " %s: ÿ0:%s ÿ1:%s", LNG(Pad_mapping), LNG(OK), LNG(CANCEL));
1570 printXY(c, x, y, setting->color[3], TRUE, 0);
1571 y += FONT_HEIGHT;
1572
1573 if(strlen(setting->usbd_file)==0)
1574 sprintf(c, " %s: %s", LNG(USBD_IRX), LNG(DEFAULT));
1575 else
1576 sprintf(c, " %s: %s", LNG(USBD_IRX), setting->usbd_file);
1577 printXY(c, x, y, setting->color[3], TRUE, 0);
1578 y += FONT_HEIGHT;
1579
1580 sprintf(c, " %s: %d", LNG(Initial_Delay), setting->Init_Delay);
1581 printXY(c, x, y, setting->color[3], TRUE, 0);
1582 y += FONT_HEIGHT;
1583
1584 sprintf(c, " %s: %d", LNG(Default_Timeout), setting->timeout);
1585 printXY(c, x, y, setting->color[3], TRUE, 0);
1586 y += FONT_HEIGHT;
1587
1588 if(setting->usbkbd_used)
1589 sprintf(c, " %s: %s", LNG(USB_Keyboard_Used), LNG(ON));
1590 else
1591 sprintf(c, " %s: %s", LNG(USB_Keyboard_Used), LNG(OFF));
1592 printXY(c, x, y, setting->color[3], TRUE, 0);
1593 y += FONT_HEIGHT;
1594
1595 if(strlen(setting->usbkbd_file)==0)
1596 sprintf(c, " %s: %s", LNG(USB_Keyboard_IRX), LNG(DEFAULT));
1597 else
1598 sprintf(c, " %s: %s", LNG(USB_Keyboard_IRX), setting->usbkbd_file);
1599 printXY(c, x, y, setting->color[3], TRUE, 0);
1600 y += FONT_HEIGHT;
1601
1602 if(strlen(setting->kbdmap_file)==0)
1603 sprintf(c, " %s: %s", LNG(USB_Keyboard_Map), LNG(DEFAULT));
1604 else
1605 sprintf(c, " %s: %s", LNG(USB_Keyboard_Map), setting->kbdmap_file);
1606 printXY(c, x, y, setting->color[3], TRUE, 0);
1607 y += FONT_HEIGHT;
1608
1609 if(strlen(setting->CNF_Path)==0)
1610 sprintf(c, " %s: %s", LNG(CNF_Path_override), LNG(NONE));
1611 else
1612 sprintf(c, " %s: %s", LNG(CNF_Path_override), setting->CNF_Path);
1613 printXY(c, x, y, setting->color[3], TRUE, 0);
1614 y += FONT_HEIGHT;
1615
1616 if(strlen(setting->usbmass_file)==0)
1617 sprintf(c, " %s: %s", LNG(USB_Mass_IRX), LNG(DEFAULT));
1618 else
1619 sprintf(c, " %s: %s", LNG(USB_Mass_IRX), setting->usbmass_file);
1620 printXY(c, x, y, setting->color[3], TRUE, 0);
1621 y += FONT_HEIGHT;
1622
1623 if(strlen(setting->lang_file)==0)
1624 sprintf(c, " %s: %s", LNG(Language_File), LNG(DEFAULT));
1625 else
1626 sprintf(c, " %s: %s", LNG(Language_File), setting->lang_file);
1627 printXY(c, x, y, setting->color[3], TRUE, 0);
1628 y += FONT_HEIGHT;
1629
1630 if(strlen(setting->font_file)==0)
1631 sprintf(c, " %s: %s", LNG(Font_File), LNG(DEFAULT));
1632 else
1633 sprintf(c, " %s: %s", LNG(Font_File), setting->font_file);
1634 printXY(c, x, y, setting->color[3], TRUE, 0);
1635 y += FONT_HEIGHT;
1636
1637 if(strlen(setting->LK_Path[15])==0)
1638 sprintf(c, " ESR elf: %s", LNG(DEFAULT));
1639 else
1640 sprintf(c, " ESR elf: %s", setting->LK_Path[15]);
1641 printXY(c, x, y, setting->color[3], TRUE, 0);
1642 y += FONT_HEIGHT;
1643
1644 y += FONT_HEIGHT / 2;
1645 sprintf(c, " %s", LNG(RETURN));
1646 printXY(c, x, y, setting->color[3], TRUE, 0);
1647 y += FONT_HEIGHT;
1648
1649 //Cursor positioning section
1650 y = Menu_start_y + s*FONT_HEIGHT + FONT_HEIGHT /2;
1651
1652 if(s>=max_s) y+=FONT_HEIGHT/2;
1653 drawChar(LEFT_CUR, x, y, setting->color[3]);
1654
1655 //Tooltip section
1656 if ((s==1)||(s==3)||(s==7)) { //resetIOP || usbkbd_used
1657 if (swapKeys)
1658 sprintf(c, "ÿ1:%s", LNG(Change));
1659 else
1660 sprintf(c, "ÿ0:%s", LNG(Change));
1661 } else if ((s==2)||(s==5)||(s==6)) { //numCNF || Init_Delay || timeout
1662 if (swapKeys)
1663 sprintf(c, "ÿ1:%s ÿ0:%s", LNG(Add), LNG(Subtract));
1664 else
1665 sprintf(c, "ÿ0:%s ÿ1:%s", LNG(Add), LNG(Subtract));
1666 } else if((s==4)||(s==8)||(s==9)||(s==10)
1667 ||(s==11)||(s==12)||(s==13)||(s==14)) {
1668 //usbd_file||usbkbd_file||kbdmap_file||CNF_Path||usbmass_file
1669 if (swapKeys)
1670 sprintf(c, "ÿ1:%s ÿ0:%s", LNG(Browse), LNG(Clear));
1671 else
1672 sprintf(c, "ÿ0:%s ÿ1:%s", LNG(Browse), LNG(Clear));
1673 } else {
1674 if (swapKeys)
1675 sprintf(c, "ÿ1:%s", LNG(OK));
1676 else
1677 sprintf(c, "ÿ0:%s", LNG(OK));
1678 }
1679 sprintf(tmp, " ÿ3:%s", LNG(Return));
1680 strcat(c, tmp);
1681 setScrTmp("", c);
1682 }//ends if(event||post_event)
1683 drawScr();
1684 post_event = event;
1685 event = 0;
1686
1687 }//ends while
1688}//ends Config_Startup
1689//---------------------------------------------------------------------------
1690// Network settings GUI by Slam-Tilt
1691//---------------------------------------------------------------------------
1692void saveNetworkSettings(char *Message)
1693{
1694 char firstline[50];
1695 extern char ip[16];
1696 extern char netmask[16];
1697 extern char gw[16];
1698 int out_fd,in_fd;
1699 int ret=0,i=0;
1700 int size,sizeleft=0;
1701 char *ipconfigfile=0;
1702 char path[MAX_PATH];
1703
1704 // Default message, will get updated if save is sucessfull
1705 sprintf(Message,"%s", LNG(Saved_Failed));
1706
1707 sprintf(firstline,"%s %s %s\n\r",ip,netmask,gw);
1708
1709
1710
1711 // This block looks at the existing ipconfig.dat and works out if there is
1712 // already any data beyond the first line. If there is it will get appended to the output
1713 // to new file later.
1714
1715 if(uLE_related(path, "uLE:/IPCONFIG.DAT")==1)
1716 in_fd = genOpen(path, O_RDONLY);
1717 else
1718 in_fd=-1;
1719
1720 if(strncmp(path, "mc",2)){
1721 mcSync(0,NULL,NULL);
1722 mcMkDir(0, 0, "SYS-CONF");
1723 mcSync(0, NULL, &ret);
1724 }
1725
1726 if (in_fd >= 0) {
1727
1728 size = genLseek(in_fd, 0, SEEK_END);
1729 printf("size of existing file is %ibytes\n\r",size);
1730
1731 ipconfigfile = (char *)malloc(size);
1732
1733 genLseek(in_fd, 0, SEEK_SET);
1734 genRead(in_fd, ipconfigfile, size);
1735
1736
1737 for (i=0; (ipconfigfile[i] != 0 && i<=size); i++)
1738
1739 {
1740 // printf("%i-%c\n\r",i,ipconfigfile[i]);
1741 }
1742
1743 sizeleft=size-i;
1744
1745 genClose(in_fd);
1746 }else
1747 strcpy(path, "mc0:/SYS-CONF/IPCONFIG.DAT");
1748
1749 // Writing the data out
1750
1751 out_fd=genOpen(path, O_WRONLY | O_TRUNC | O_CREAT);
1752 if(out_fd >=0)
1753 {
1754 mcSync(0, NULL, &ret);
1755 genWrite(out_fd,firstline,strlen(firstline));
1756 mcSync(0, NULL, &ret);
1757
1758 // If we have any extra data, spit that out too.
1759 if (sizeleft > 0)
1760 {
1761 mcSync(0, NULL, &ret);
1762 genWrite(out_fd,&ipconfigfile[i],sizeleft);
1763 mcSync(0, NULL, &ret);
1764 }
1765
1766 sprintf(Message,"%s %s", LNG(Saved), path);
1767
1768 genClose(out_fd);
1769
1770 }
1771}
1772//---------------------------------------------------------------------------
1773// Convert IP string to numbers
1774//---------------------------------------------------------------------------
1775void ipStringToOctet(char *ip, int ip_octet[4])
1776{
1777
1778 // This takes a string (ip) representing an IP address and converts it
1779 // into an array of ints (ip_octet)
1780 // Rewritten 22/10/05
1781
1782 char oct_str[5];
1783 int oct_cnt,i;
1784
1785 oct_cnt = 0;
1786 oct_str[0]=0;
1787
1788 for (i=0; ((i<=strlen(ip)) && (oct_cnt<4)); i++)
1789 {
1790 if ((ip[i] == '.') | (i==strlen(ip)))
1791 {
1792 ip_octet[oct_cnt] = atoi(oct_str);
1793 oct_cnt++;
1794 oct_str[0]=0;
1795 } else
1796 sprintf(oct_str,"%s%c",oct_str,ip[i]);
1797 }
1798}
1799//---------------------------------------------------------------------------
1800data_ip_struct BuildOctets(char *ip, char *nm, char *gw)
1801{
1802
1803 // Populate 3 arrays with the ip address (as ints)
1804
1805 data_ip_struct iplist;
1806
1807 ipStringToOctet(ip,iplist.ip);
1808 ipStringToOctet(nm,iplist.nm);
1809 ipStringToOctet(gw,iplist.gw);
1810
1811 return(iplist);
1812}
1813//---------------------------------------------------------------------------
1814void Config_Network(void)
1815{
1816 // Menu System for Network Settings Page.
1817
1818 int s,l;
1819 int x, y;
1820 int event, post_event=0;
1821 char c[MAX_PATH];
1822 extern char ip[16];
1823 extern char netmask[16];
1824 extern char gw[16];
1825 data_ip_struct ipdata;
1826 char NetMsg[MAX_PATH] = "";
1827 char path[MAX_PATH];
1828
1829 event = 1; //event = initial entry
1830 s=1;
1831 l=1;
1832 ipdata = BuildOctets(ip,netmask,gw);
1833
1834 while(1)
1835 {
1836 //Pad response section
1837 waitPadReady(0, 0);
1838 if(readpad())
1839 {
1840 if(new_pad & PAD_UP)
1841 {
1842 event |= 2; //event |= valid pad command
1843 if(s!=1) s--;
1844 else {s=5; l=1; }
1845 }
1846 else if(new_pad & PAD_DOWN)
1847 {
1848 event |= 2; //event |= valid pad command
1849 if(s!=5) s++;
1850 else s=1;
1851 if(s>3) l=1;
1852 }
1853 else if(new_pad & PAD_LEFT)
1854 {
1855 event |= 2; //event |= valid pad command
1856 if(s<4)
1857 if(l>1)
1858 l--;
1859 }
1860 else if(new_pad & PAD_RIGHT)
1861 {
1862 event |= 2; //event |= valid pad command
1863 if(s<4)
1864 if(l<5)
1865 l++;
1866 }
1867 else if((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE) )
1868 {
1869 event |= 2; //event |= valid pad command
1870 if((s<4) && (l>1))
1871 {
1872 if (s == 1)
1873 {
1874 if (ipdata.ip[l-2] > 0)
1875 {
1876 ipdata.ip[l-2]--;
1877 }
1878 }
1879 else if (s == 2)
1880 {
1881 if (ipdata.nm[l-2] > 0)
1882 {
1883 ipdata.nm[l-2]--;
1884 }
1885 }
1886 else if (s == 3)
1887 {
1888 if (ipdata.gw[l-2] > 0)
1889 {
1890 ipdata.gw[l-2]--;
1891 }
1892 }
1893
1894 }
1895 }
1896 else if((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE))
1897 {
1898 event |= 2; //event |= valid pad command
1899 if((s<4) && (l>1))
1900 {
1901 if (s == 1)
1902 {
1903 if (ipdata.ip[l-2] < 255)
1904 {
1905 ipdata.ip[l-2]++;
1906 }
1907 }
1908 else if (s == 2)
1909 {
1910 if (ipdata.nm[l-2] < 255)
1911 {
1912 ipdata.nm[l-2]++;
1913 }
1914 }
1915 else if (s == 3)
1916 {
1917 if (ipdata.gw[l-2] < 255)
1918 {
1919 ipdata.gw[l-2]++;
1920 }
1921 }
1922
1923 }
1924
1925 else if(s==4)
1926 {
1927 sprintf(ip,"%i.%i.%i.%i",ipdata.ip[0],ipdata.ip[1],ipdata.ip[2],ipdata.ip[3]);
1928 sprintf(netmask,"%i.%i.%i.%i",ipdata.nm[0],ipdata.nm[1],ipdata.nm[2],ipdata.nm[3]);
1929 sprintf(gw,"%i.%i.%i.%i",ipdata.gw[0],ipdata.gw[1],ipdata.gw[2],ipdata.gw[3]);
1930
1931 saveNetworkSettings(NetMsg);
1932 }
1933 else
1934 return;
1935 }
1936 else if(new_pad & PAD_TRIANGLE)
1937 return;
1938 }
1939
1940 if(event||post_event){ //NB: We need to update two frame buffers per event
1941
1942 //Display section
1943 clrScr(setting->color[0]);
1944
1945 x = Menu_start_x;
1946 y = Menu_start_y;
1947
1948 printXY(LNG(NETWORK_SETTINGS), x, y, setting->color[3], TRUE, 0);
1949 y += FONT_HEIGHT;
1950
1951 y += FONT_HEIGHT / 2;
1952
1953 int len = (strlen(LNG(IP_Address))+5>strlen(LNG(Netmask))+5)?
1954 strlen(LNG(IP_Address))+5:strlen(LNG(Netmask))+5;
1955 len = (len>strlen(LNG(Gateway))+5)? len:strlen(LNG(Gateway))+5;
1956 sprintf(c, "%s:", LNG(IP_Address));
1957 printXY(c, x+2*FONT_WIDTH, y, setting->color[3], TRUE, 0);
1958 sprintf(c, "%.3i . %.3i . %.3i . %.3i", ipdata.ip[0],ipdata.ip[1],ipdata.ip[2],ipdata.ip[3]);
1959 printXY(c, x+len*FONT_WIDTH, y, setting->color[3], TRUE, 0);
1960 y += FONT_HEIGHT;
1961
1962 sprintf(c, "%s:", LNG(Netmask));
1963 printXY(c, x+2*FONT_WIDTH, y, setting->color[3], TRUE, 0);
1964 sprintf(c, "%.3i . %.3i . %.3i . %.3i", ipdata.nm[0],ipdata.nm[1],ipdata.nm[2],ipdata.nm[3]);
1965 printXY(c, x+len*FONT_WIDTH, y, setting->color[3], TRUE, 0);
1966 y += FONT_HEIGHT;
1967
1968 sprintf(c, "%s:", LNG(Gateway));
1969 printXY(c, x+2*FONT_WIDTH, y, setting->color[3], TRUE, 0);
1970 sprintf(c, "%.3i . %.3i . %.3i . %.3i", ipdata.gw[0],ipdata.gw[1],ipdata.gw[2],ipdata.gw[3]);
1971 printXY(c, x+len*FONT_WIDTH, y, setting->color[3], TRUE, 0);
1972 y += FONT_HEIGHT;
1973
1974 y += FONT_HEIGHT / 2;
1975
1976 if(uLE_related(path, "uLE:/IPCONFIG.DAT")!=1)
1977 strcpy(path, "mc0:/SYS-CONF/IPCONFIG.DAT");
1978 sprintf(c, " %s \"%s\"", LNG(Save_to), path);
1979 printXY(c, x, y, setting->color[3], TRUE, 0);
1980 y += FONT_HEIGHT;
1981
1982 y += FONT_HEIGHT / 2;
1983 sprintf(c, " %s", LNG(RETURN));
1984 printXY(c, x, y, setting->color[3], TRUE, 0);
1985 y += FONT_HEIGHT;
1986
1987 //Cursor positioning section
1988 y = Menu_start_y + s*FONT_HEIGHT + FONT_HEIGHT/2;
1989
1990 if(s>=4) y+=FONT_HEIGHT/2;
1991 if(s>=5) y+=FONT_HEIGHT/2;
1992 if (l > 1)
1993 x += (len-1)*FONT_WIDTH-1+(l-2)*6*FONT_WIDTH;
1994 drawChar(LEFT_CUR, x, y, setting->color[3]);
1995
1996 //Tooltip section
1997 if ((s <4) && (l==1)) {
1998 sprintf(c, "%s", LNG(Right_DPad_to_Edit));
1999 } else if (s < 4) {
2000 if (swapKeys)
2001 sprintf(c, "ÿ1:%s ÿ0:%s", LNG(Add), LNG(Subtract));
2002 else
2003 sprintf(c, "ÿ0:%s ÿ1:%s", LNG(Add), LNG(Subtract));
2004 } else if( s== 4) {
2005 if (swapKeys)
2006 sprintf(c, "ÿ1:%s", LNG(Save));
2007 else
2008 sprintf(c, "ÿ0:%s", LNG(Save));
2009 } else {
2010 if (swapKeys)
2011 sprintf(c, "ÿ1:%s", LNG(OK));
2012 else
2013 sprintf(c, "ÿ0:%s", LNG(OK));
2014 }
2015 sprintf(tmp, " ÿ3:%s", LNG(Return));
2016 strcat(c, tmp);
2017 setScrTmp(NetMsg, c);
2018 }//ends if(event||post_event)
2019 drawScr();
2020 post_event = event;
2021 event = 0;
2022
2023 }//ends while
2024}//ends Config_Network
2025//---------------------------------------------------------------------------
2026// Configuration menu
2027//---------------------------------------------------------------------------
2028void config(char *mainMsg, char *CNF)
2029{
2030 char c[MAX_PATH];
2031 char title_tmp[MAX_ELF_TITLE];
2032 char *localMsg;
2033 int i;
2034 int s;
2035 int x, y;
2036 int event, post_event=0;
2037
2038 tmpsetting = setting;
2039 setting = (SETTING*)malloc(sizeof(SETTING));
2040 *setting = *tmpsetting;
2041
2042 event = 1; //event = initial entry
2043 s=0;
2044 while(1)
2045 {
2046 //Pad response section
2047 waitPadReady(0, 0);
2048 if(readpad())
2049 {
2050 if(new_pad & PAD_UP)
2051 {
2052 event |= 2; //event |= valid pad command
2053 if(s!=0)
2054 s--;
2055 else
2056 s=CANCEL;
2057 }
2058 else if(new_pad & PAD_DOWN)
2059 {
2060 event |= 2; //event |= valid pad command
2061 if(s!=CANCEL)
2062 s++;
2063 else
2064 s=0;
2065 }
2066 else if(new_pad & PAD_LEFT)
2067 {
2068 event |= 2; //event |= valid pad command
2069 if(s>=OK)
2070 s=SHOW_TITLES;
2071 else
2072 s=DEFAULT;
2073 }
2074 else if(new_pad & PAD_RIGHT)
2075 {
2076 event |= 2; //event |= valid pad command
2077 if(s<SHOW_TITLES)
2078 s=SHOW_TITLES;
2079 else if(s<OK)
2080 s=OK;
2081 }
2082 else if((new_pad & PAD_SQUARE) && (s<SHOW_TITLES)){
2083 event |= 2; //event |= valid pad command
2084 strcpy(title_tmp, setting->LK_Title[s]);
2085 if(keyboard(title_tmp, MAX_ELF_TITLE)>=0)
2086 strcpy(setting->LK_Title[s], title_tmp);
2087 }
2088 else if((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE) )
2089 {
2090 event |= 2; //event |= valid pad command
2091 if(s<SHOW_TITLES){
2092 setting->LK_Path[s][0]=0;
2093 setting->LK_Title[s][0]=0;
2094 }
2095 }
2096 else if((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE))
2097 {
2098 event |= 2; //event |= valid pad command
2099 if(s<SHOW_TITLES)
2100 {
2101 getFilePath(setting->LK_Path[s], TRUE);
2102 if(!strncmp(setting->LK_Path[s], "mc0", 3) ||
2103 !strncmp(setting->LK_Path[s], "mc1", 3)){
2104 sprintf(c, "mc%s", &setting->LK_Path[s][3]);
2105 strcpy(setting->LK_Path[s], c);
2106 }
2107 }
2108 else if(s==SHOW_TITLES)
2109 setting->Show_Titles = !setting->Show_Titles;
2110 else if(s==FILENAME)
2111 setting->Hide_Paths = !setting->Hide_Paths;
2112 else if(s==DISCCONTROL)
2113 setting->discControl = !setting->discControl;
2114 else if(s==SCREEN)
2115 Config_Screen();
2116 else if(s==SETTINGS)
2117 Config_Startup();
2118 else if(s==NETWORK)
2119 Config_Network();
2120 else if(s==OK)
2121 {
2122 free(tmpsetting);
2123 saveConfig(mainMsg, CNF);
2124 if(setting->GUI_skin[0]) {
2125 GUI_active = 1;
2126 loadSkin(BACKGROUND_PIC, 0, 0);
2127 }
2128 break;
2129 }
2130 else if(s==CANCEL)
2131 goto cancel_exit;
2132 }
2133 else if(new_pad & PAD_TRIANGLE) {
2134cancel_exit:
2135 free(setting);
2136 setting = tmpsetting;
2137 updateScreenMode(0);
2138 if (setting->GUI_skin[0])
2139 GUI_active = 1;
2140 loadSkin(BACKGROUND_PIC, 0, 0);
2141 Load_External_Language();
2142 loadFont(setting->font_file);
2143 mainMsg[0] = 0;
2144 break;
2145 }
2146 } //end if(readpad())
2147
2148 if(event||post_event){ //NB: We need to update two frame buffers per event
2149
2150 //Display section
2151 clrScr(setting->color[0]);
2152
2153 if(s < SHOW_TITLES) localMsg = setting->LK_Title[s];
2154 else localMsg = "";
2155
2156 x = Menu_start_x;
2157 y = Menu_start_y;
2158 printXY(LNG(Button_Settings), x, y, setting->color[3], TRUE, 0);
2159 y += FONT_HEIGHT;
2160 for(i=0; i<12; i++)
2161 {
2162 switch(i)
2163 {
2164 case 0:
2165 strcpy(c," Default: ");
2166 break;
2167 case 1:
2168 strcpy(c," ÿ0 : ");
2169 break;
2170 case 2:
2171 strcpy(c," ÿ1 : ");
2172 break;
2173 case 3:
2174 strcpy(c," ÿ2 : ");
2175 break;
2176 case 4:
2177 strcpy(c," ÿ3 : ");
2178 break;
2179 case 5:
2180 strcpy(c," L1 : ");
2181 break;
2182 case 6:
2183 strcpy(c," R1 : ");
2184 break;
2185 case 7:
2186 strcpy(c," L2 : ");
2187 break;
2188 case 8:
2189 strcpy(c," R2 : ");
2190 break;
2191 case 9:
2192 strcpy(c," L3 : ");
2193 break;
2194 case 10:
2195 strcpy(c," R3 : ");
2196 break;
2197 case 11:
2198 strcpy(c," START : ");
2199 break;
2200 }
2201 strcat(c, setting->LK_Path[i]);
2202 printXY(c, x, y, setting->color[3], TRUE, 0);
2203 y += FONT_HEIGHT;
2204 }
2205
2206 y += FONT_HEIGHT / 2;
2207
2208 if(setting->Show_Titles)
2209 sprintf(c, " %s: %s", LNG(Show_launch_titles), LNG(ON));
2210 else
2211 sprintf(c, " %s: %s", LNG(Show_launch_titles), LNG(OFF));
2212 printXY(c, x, y, setting->color[3], TRUE, 0);
2213 y += FONT_HEIGHT;
2214
2215 if(setting->discControl)
2216 sprintf(c, " %s: %s", LNG(Disc_control), LNG(ON));
2217 else
2218 sprintf(c, " %s: %s", LNG(Disc_control), LNG(OFF));
2219 printXY(c, x, y, setting->color[3], TRUE, 0);
2220 y += FONT_HEIGHT;
2221
2222 if(setting->Hide_Paths)
2223 sprintf(c, " %s: %s", LNG(Hide_full_ELF_paths), LNG(ON));
2224 else
2225 sprintf(c, " %s: %s", LNG(Hide_full_ELF_paths), LNG(OFF));
2226 printXY(c, x, y, setting->color[3], TRUE, 0);
2227 y += FONT_HEIGHT;
2228
2229 sprintf(c, " %s...", LNG(Screen_Settings));
2230 printXY(c, x, y, setting->color[3], TRUE, 0);
2231 y += FONT_HEIGHT;
2232 sprintf(c, " %s...", LNG(Startup_Settings));
2233 printXY(c, x, y, setting->color[3], TRUE, 0);
2234 y += FONT_HEIGHT;
2235 sprintf(c, " %s...", LNG(Network_Settings));
2236 printXY(c, x, y, setting->color[3], TRUE, 0);
2237 y += FONT_HEIGHT;
2238
2239 sprintf(c, " %s", LNG(OK));
2240 printXY(c, x, y, setting->color[3], TRUE, 0);
2241 y += FONT_HEIGHT;
2242 sprintf(c, " %s", LNG(Cancel));
2243 printXY(c, x, y, setting->color[3], TRUE, 0);
2244
2245 //Cursor positioning section
2246 y = Menu_start_y + (s+1)*FONT_HEIGHT;
2247 if(s>=SHOW_TITLES)
2248 y += FONT_HEIGHT / 2;
2249 drawChar(LEFT_CUR, x, y, setting->color[3]);
2250
2251 //Tooltip section
2252 if (s < SHOW_TITLES) {
2253 if (swapKeys)
2254 sprintf(c, "ÿ1:%s ÿ0:%s ÿ2:%s", LNG(Browse), LNG(Clear), LNG(Edit_Title));
2255 else
2256 sprintf(c, "ÿ0:%s ÿ1:%s ÿ2:%s", LNG(Browse), LNG(Clear), LNG(Edit_Title));
2257 } else if((s==SHOW_TITLES)||(s==FILENAME)||(s==DISCCONTROL)) {
2258 if (swapKeys)
2259 sprintf(c, "ÿ1:%s", LNG(Change));
2260 else
2261 sprintf(c, "ÿ0:%s", LNG(Change));
2262 } else {
2263 if (swapKeys)
2264 sprintf(c, "ÿ1:%s", LNG(OK));
2265 else
2266 sprintf(c, "ÿ0:%s", LNG(OK));
2267 }
2268 sprintf(tmp, " ÿ3:%s", LNG(Return));
2269 strcat(c, tmp);
2270 setScrTmp(localMsg, c);
2271 }//ends if(event||post_event)
2272 drawScr();
2273 post_event = event;
2274 event = 0;
2275
2276 }//ends while
2277 if(setting->discControl)
2278 loadCdModules();
2279}//ends config
2280//---------------------------------------------------------------------------
2281// End of file: config.c
2282//---------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.