I'm just a C++ newbie, but I hope you guys could help me with this one.
So I've build a program for converting a theme.ini file to a skin.xml file, but the program crashes while it's converting the values!
int x = 0; // tmp var 1
int y = 0; // tmp var 2
string vars[15]; // dataholder
void r4ini2cycloxml(char *source, char *target){
//////////////////////////////////////////////////////
// Read variables from original R4DS Theme.ini file //
//////////////////////////////////////////////////////
ifstream src;
src.open(source, ios::in);
while (!src.eof()) // variable read loop from original r4 theme.ini
{
if (x == 2) { x++; continue; } // skip vars[2]
src >> vars[x]; // line of source r4ds theme.ini is read to vars
if (vars[x][1] == ';') // if it's a comment
{ continue; } // return to the beginning to read the next line
if (vars[x][1] == '[') // same for []
{ continue; } // return!
if (vars[x][1] == 'D') // same for date indicator
{ continue; } // return!
x++; // increase x, so next variable will be read into next vars
}
src.close();
//////////////////////////////////////////
// vars content table //
/////// ////////
// vars[0] "Title="theme title //
// vars[1] "Author="theme author //
// vars[2] undefined //
// vars[3-15] "ColorXX="hex color //
//////////////////////////////////////////
//////////////////////////////////////////////////////////
// Convert variables from R4DS format to CyclODS format //
//////////////////////////////////////////////////////////
// First: the theme title
x = 5; // offset
while(x <= (strlen(vars[0].c_str()) - 1))
{
vars[0][y] = vars[0][x];
vars[0][x] = '\0';
x++; y++;
}
// Theme author
y = 0;
x = 6; // offset
while(x <= (strlen(vars[1].c_str()) - 1))
{
vars[1][y] = vars[1][x];
vars[1][x] = '\0';
x++; y++;
}
// Theme version
vars[2] = "1.0";
// Theme colors
int z = 3;
while(z <= 15){
x = 7;
y = 0;
while(x <= (strlen(vars[z].c_str()) - 1))
{
vars[z][y] = vars[z][x];
vars[z][x] = '\0';
x++; y++;
}
z++;
}
//////////////////////////////////////////////////
// Write variables to new CycloDS skin.xml file //
//////////////////////////////////////////////////
ofstream trgt;
trgt.open(target, ios::trunc);
trgt << "<?xml version=\"1.0\"?>\n";
trgt << "<skin>\n";
trgt << "<skin-name>" << vars[0] << "</skin-name>\n"; // theme title inserted
trgt << "<skin-author>" << vars[1] << "</skin-author>\n"; // theme author inserted
trgt << "<skin-version>" << vars[2] << "</skin-version>\n"; // theme version inserted
trgt << "<top-bitmap file=\"top.bmp\" />\n";
trgt << "<bottom-bitmap file=\"bottom.bmp\" />\n";
trgt << "<menu-icon-bitmap file=\"menu-icons.bmp\" transparent-colour=\"" << vars[3] << "\" />\n";
trgt << "<scrollbar-bitmap file=\"scrollbar.bmp\" transparent-colour=\"" << vars[4] << "\" />\n";
trgt << "<cheat-icon-bitmap file=\"cheat-icons.bmp\" transparent-colour=\"" << vars[5] << "\" />\n";
trgt << "<window-fill colour=\"" << vars[6] << "\" />\n";
trgt << "<button-fill colour=\"" << vars[7] << "\" />\n";
trgt << "<window-border colour=\"" << vars[8] << "\" />\n";
trgt << "<text-list colour=\"" << vars[9] << "\" />\n";
trgt << "<text-window colour=\"" << vars[10] << "\" />\n";
trgt << "<text-status colour=\"" << vars[11] << "\" />\n";
trgt << "<selection color=\"" << vars[12] << "\" transparency=\"5\" />\n";
trgt.close();
x = 0; y = 0;
}
Please help me!
This post has been edited by Aureax: 02 March 2009 - 08:53 AM

New Topic/Question
Reply




MultiQuote





|