Skip to content

Commit

Permalink
gui: replace deprecated printEx with printf
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyu-len committed Apr 13, 2020
1 parent 494a266 commit e7280c4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/libtcod/gui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ void Button::render() {
if (w > 0 && h > 0) { con->rect(x, y, w, h, true, TCOD_BKGND_SET); }
if (label) {
if (pressed && mouseIn) {
con->printEx(x + w / 2, y, TCOD_BKGND_NONE, TCOD_CENTER, "-%s-", label);
con->printf(x + w / 2, y, TCOD_BKGND_NONE, TCOD_CENTER, "-%s-", label);
} else {
con->printEx(x + w / 2, y, TCOD_BKGND_NONE, TCOD_CENTER, label);
con->printf(x + w / 2, y, TCOD_BKGND_NONE, TCOD_CENTER, "%s", label);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libtcod/gui/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Label::Label(int x, int y, const char *label, const char *tip)
void Label::render() {
con->setDefaultBackground(back);
con->setDefaultForeground(fore);
con->printEx(x, y, TCOD_BKGND_NONE, TCOD_LEFT, label);
con->printf(x, y, TCOD_BKGND_NONE, TCOD_LEFT, "%s", label);
}
void Label::computeSize() {
w = label ? static_cast<int>(strlen(label)) : 0;
Expand Down
4 changes: 2 additions & 2 deletions src/libtcod/gui/textbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ void TextBox::render() {
con->setDefaultBackground(back);
con->setDefaultForeground(fore);
con->rect(x,y,w,h,true,TCOD_BKGND_SET);
if ( label ) con->printEx(x,y,TCOD_BKGND_NONE,TCOD_LEFT,label);
if ( label ) con->printf(x,y,TCOD_BKGND_NONE,TCOD_LEFT, "%s", label);

con->setDefaultBackground(keyboardFocus == this ? foreFocus : fore);
con->setDefaultForeground(keyboardFocus == this ? backFocus : back);
con->rect(x+boxx,y,boxw,h,false,TCOD_BKGND_SET);
int len = static_cast<int>(strlen(txt) - offset);
if (len > boxw) len = boxw;
if ( txt ) con->printEx(x+boxx,y,TCOD_BKGND_NONE,TCOD_LEFT,"%.*s",len,&txt[offset]);
if ( txt ) con->printf(x+boxx,y,TCOD_BKGND_NONE,TCOD_LEFT,"%.*s",len,&txt[offset]);
if (keyboardFocus == this && blink > 0.0f) {
if (insert) {
con->setCharBackground(x+boxx+pos-offset,y,fore);
Expand Down
5 changes: 3 additions & 2 deletions src/libtcod/gui/togglebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ void ToggleButton::render() {
con->setDefaultBackground(mouseIn ? backFocus : back);
con->setDefaultForeground(mouseIn ? foreFocus : fore);
con->rect(x,y,w,h,true,TCOD_BKGND_SET);
const char check = pressed ? TCOD_CHAR_CHECKBOX_SET : TCOD_CHAR_CHECKBOX_UNSET;
if ( label ) {
con->printEx(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%c %s",pressed ? TCOD_CHAR_CHECKBOX_SET : TCOD_CHAR_CHECKBOX_UNSET, label);
con->printf(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%c %s", check, label);
} else {
con->printEx(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%c",pressed ? TCOD_CHAR_CHECKBOX_SET : TCOD_CHAR_CHECKBOX_UNSET);
con->printf(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%c", check);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libtcod/gui/toolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public :
con->setChar(x+w,y,TCOD_CHAR_TEEW);
con->setDefaultBackground(fore);
con->setDefaultForeground(back);
con->printEx(x+w/2,y,TCOD_BKGND_SET,TCOD_CENTER," %s ",txt);
con->printf(x+w/2,y,TCOD_BKGND_SET,TCOD_CENTER," %s ",txt);
}
char *txt;
};
Expand Down

0 comments on commit e7280c4

Please sign in to comment.