46 void laFame::load(
char *strFameFile)
49 if(fp.fileOpen(strFameFile)==NULL)
51 for(
unsigned i=0; i<10; i++)
53 strcpy(_arNames[i],
"(empty)");
59 for(
unsigned i=0; i<10; i++)
61 fp.readText(_arNames[i]);
62 fp.readDouble(_arPlayTimes+i);
66 void laFame::ctlSave(
char *strFameFile)
68 FILE *f = fopen(strFameFile,
"w");
69 for(
unsigned i=0; i<10; i++)
71 fprintf(f,
"name: '%s'\n", _arNames[i]);
72 fprintf(f,
"play-time: %.2f\n\n", (
float)_arPlayTimes[i]);
77 void laFame::ctlUpdate(
char* strName,
double dPlayTime)
79 M_BOOL bUnsorted = M_FALSE;
80 M_BOOL bFound = M_FALSE;
82 for(
unsigned i=0; i<10; i++)
84 if(!strcmp(_arNames[i], strName))
86 if(dPlayTime<_arPlayTimes[i])
88 _arPlayTimes[i] = dPlayTime;
98 for(
unsigned i=0; i<10; i++)
100 if( (_arPlayTimes[i]>dPlayTime) || (!strcmp(_arNames[i],
"(empty)")))
102 for(
unsigned j=9; j<=i; j--)
104 strcpy(_arNames[j], _arNames[j-1]);
105 _arPlayTimes[j] = _arPlayTimes[j-1];
107 strcpy(_arNames[i], strName);
108 _arPlayTimes[i] = dPlayTime;
116 unsigned nMin, nLastSorted;
120 for(nLastSorted=0; nLastSorted<10; nLastSorted++)
124 for(
unsigned i=nLastSorted+1; i<10; i++){
125 if( (_arPlayTimes[i]<_arPlayTimes[nMin]) && strcmp(_arNames[i],
"(empty)") )
131 if(nMin!=nLastSorted)
133 strcpy(strTemp, _arNames[nLastSorted]);
134 strcpy(_arNames[nLastSorted], _arNames[nMin]);
135 strcpy(_arNames[nMin], strTemp);
137 dTemp = _arPlayTimes[nLastSorted];
138 _arPlayTimes[nLastSorted] = _arPlayTimes[nMin];
139 _arPlayTimes[nMin] = dTemp;
145 unsigned laFame::getMin(
unsigned i)
147 return (
unsigned)_arPlayTimes[i]/60;
150 unsigned laFame::getSec(
unsigned i)
152 unsigned min = (unsigned)_arPlayTimes[i]/60;
153 return (
unsigned)_arPlayTimes[i] - min*60;