Skip to content

Commit

Permalink
gui: fix togglebutton checkbox, toolbar frame, hmtool
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyu-len committed Apr 15, 2020
1 parent f3688ee commit 2460e7a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions samples/hmtool/hmtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ void render() {
sprintf(maxZTxt,"max z : %.2f",mapmax);
sprintf(seedTxt,"seed : %X",seed);
float landProportion=100.0f - 100.0f*backup.countCells(0.0f,sandHeight) / (hm->w*hm->h);
sprintf(landMassTxt,"landMass : %d %%%%",(int)landProportion);
if ( ! isNormalized ) TCODConsole::root->printEx(HM_WIDTH/2,HM_HEIGHT-1,TCOD_BKGND_NONE,TCOD_CENTER,"the map is not normalized !");
sprintf(landMassTxt,"landMass : %d %%",(int)landProportion);
if ( ! isNormalized ) TCODConsole::root->printf(HM_WIDTH/2,HM_HEIGHT-1,TCOD_BKGND_NONE,TCOD_CENTER,"the map is not normalized !");
// message
msgDelay-=TCODSystem::getLastFrameLength();
if ( msg[0] != 0 && msgDelay > 0.0f ) {
Expand Down
2 changes: 1 addition & 1 deletion samples/hmtool/operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const char *Operation::names[]= {
"+fbm",
"*fbm",
"hill",
"\x18\x19 z",
"\u2191\u2193 z",
"smooth",
"rain",
"lerp fbm",
Expand Down
1 change: 1 addition & 0 deletions src/libtcod/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ public :
@Param fmt if NULL, the function only draws a rectangle.
Else, printf-like format string, eventually followed by parameters. You can use control codes to change the colors inside the string.
*/
TCODLIB_FORMAT(8, 9)
void printFrame(int x,int y,int w,int h, bool clear=true, TCOD_bkgnd_flag_t flag = TCOD_BKGND_DEFAULT, const char *fmt=NULL, ...);

/**
Expand Down
6 changes: 3 additions & 3 deletions src/libtcod/gui/togglebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +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;
const char* check = pressed ? "\u2611" : "\u2610";
if ( label ) {
con->printf(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%c %s", check, label);
con->printf(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%s %s", check, label);
} else {
con->printf(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%c", check);
con->printf(x,y,TCOD_BKGND_NONE,TCOD_LEFT,"%s", 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 @@ -103,7 +103,7 @@ void ToolBar::setName(const char *name) {
void ToolBar::render() {
con->setDefaultBackground(back);
con->setDefaultForeground(fore);
con->printFrame(x,y,w,h,true,TCOD_BKGND_SET,name);
TCOD_console_printf_frame(con->get_data(), x, y, w, h, true, TCOD_BKGND_SET, "%s", name);
Container::render();
}

Expand Down

0 comments on commit 2460e7a

Please sign in to comment.