22.Jul.2009

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@95 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
gerstrong
2009-07-22 16:38:10 +00:00
parent b45ce76900
commit 531ce04fa1
53 changed files with 7040 additions and 5553 deletions

View File

@@ -77,9 +77,10 @@ void CDialog::addSeparator(void)
addOptionText("");
}
void CDialog::addOptionText(const std::string& text)
void CDialog::addOptionText(const char *text)
{
std::string buf;
char buf[TEXT_LENGTH];
memset(buf,0,TEXT_LENGTH);
// This algorithm is similar to one pointer session and
// list implementation. TextList is the head.
if(OptionTextList == NULL)
@@ -87,21 +88,22 @@ void CDialog::addOptionText(const std::string& text)
OptionTextList = new stTextList;
OptionTextList->nextElement = NULL;
OptionTextList->text = "";
memset(OptionTextList->text,0,TEXT_LENGTH);
buf = text;
strcpy(buf,text);
size_t length = buf.length();
unsigned int length;
length = strlen(buf);
// before the text is copied, check if that string is too long.
if(length > w-4)
{
OptionTextList->text = text.substr(0, w-7);
OptionTextList->text += "...";
copy(text,text+w-7,OptionTextList->text);
strcat(OptionTextList->text,"...");
}
else
{
OptionTextList->text = text;
strcpy(OptionTextList->text,text);
}
number_of_options = 1;
@@ -122,41 +124,41 @@ void CDialog::addOptionText(const std::string& text)
curTextList = (stTextList*) curTextList->nextElement;
curTextList->text = "";
memset(curTextList->text,0, TEXT_LENGTH);
number_of_options++;
buf = text;
strcpy(buf,text);
size_t length = buf.length();
unsigned int length;
length = strlen(buf);
// before the text is copied, check if that string is too long.
if(length > w-4)
{
curTextList->text = text.substr(0, w-7);
curTextList->text += "...";
copy(text,text+w-7,curTextList->text);
strcat(curTextList->text,"...");
}
else
{
curTextList->text = text;
strcpy(curTextList->text,text);
}
curTextList->nextElement = NULL;
}
}
void CDialog::setOptionText(unsigned int pos, const std::string& text)
void CDialog::setOptionText(unsigned int pos, const char *text)
{
unsigned int i;
stTextList *curTextList = OptionTextList;
stTextList *curTextList;
for(i=0 ; i<pos ; i++) {
if(!curTextList)
// TODO: print error
return;
curTextList = curTextList->nextElement;
}
curTextList->text = text;
curTextList = OptionTextList;
for(i=0 ; i<pos ; i++)
curTextList = (stTextList*) curTextList->nextElement;
memset(curTextList->text,0,TEXT_LENGTH);
strcpy(curTextList->text,text);
}
void CDialog::setDimensions(int rectx, int recty, int rectw, int recth)
@@ -195,7 +197,7 @@ void CDialog::renderDialog()
while(curTextList != NULL)
{
g_pGraphics->sb_font_draw(curTextList->text, (x+3)<<3, (y+i+1)<<3);
g_pGraphics->sb_font_draw((unsigned char*)(curTextList->text), (x+3)<<3, (y+i+1)<<3);
curTextList = (stTextList*) curTextList->nextElement;
i++;
if(i >= h-2)
@@ -285,7 +287,7 @@ void CDialog::renderOpenDialogAnimation(int x,int y, int w, int h)
isanimated = false;
}
std::string CDialog::getOptionString(unsigned int pos)
char *CDialog::getOptionString(unsigned int pos)
{
unsigned int i;
stTextList *curTextList;
@@ -325,7 +327,7 @@ bool CDialog::setNextSelection()
int i=0;
if(selection+1 < number_of_options)
{
while(getOptionString(selection+i+1) == "")
while(strcmp(getOptionString(selection+i+1),"") == 0)
i++;
selection += i;
@@ -341,7 +343,7 @@ bool CDialog::setPrevSelection()
int i=0;
if(selection-1 > 0)
{
while(getOptionString(selection-i-1) == "")
while(strcmp(getOptionString(selection-i-1),"") == 0)
i++;
selection -= i;