From: Ricardo Cruz Date: Fri, 30 Apr 2004 11:20:42 +0000 (+0000) Subject: Return a string, instead of a char array pointer, in order to please Ingo. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=eb8846e4cf6da55956f4b923d500469b160bd53b;p=supertux.git Return a string, instead of a char array pointer, in order to please Ingo. SVN-Revision: 861 --- diff --git a/src/menu.cpp b/src/menu.cpp index 67f4bbc90..f385245c5 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -196,7 +196,7 @@ MenuItem::change_input(const char *text_) } } -char* MenuItem::get_input_with_symbol(bool active_item) +std::string MenuItem::get_input_with_symbol(bool active_item) { if(!active_item) input_flickering = true; @@ -212,13 +212,15 @@ else } } -static char str[1024]; +char str[1024]; if(input_flickering) sprintf(str,"%s-",input); else sprintf(str,"%s ",input); -return (char*)str; +std::string string = str; + +return str; } /* Set ControlField a key */ @@ -558,9 +560,9 @@ Menu::draw_item(int index, // Position of the current item in the menu if(pitem.kind == MN_TEXTFIELD || pitem.kind == MN_NUMFIELD) { if(active_item == index) - gold_text->draw_align(pitem.get_input_with_symbol(true), x_pos + text_pos, y_pos, A_HMIDDLE, A_VMIDDLE, 2); + gold_text->draw_align((pitem.get_input_with_symbol(true)).c_str(), x_pos + text_pos, y_pos, A_HMIDDLE, A_VMIDDLE, 2); else - gold_text->draw_align(pitem.get_input_with_symbol(false), x_pos + text_pos, y_pos, A_HMIDDLE, A_VMIDDLE, 2); + gold_text->draw_align((pitem.get_input_with_symbol(false)).c_str(), x_pos + text_pos, y_pos, A_HMIDDLE, A_VMIDDLE, 2); } else gold_text->draw_align(pitem.input, diff --git a/src/menu.h b/src/menu.h index 5d2a6368f..74a8669cd 100644 --- a/src/menu.h +++ b/src/menu.h @@ -103,7 +103,7 @@ public: static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int id, int* int_p); - char* get_input_with_symbol(bool active_item); // returns the text with an input symbol + std::string get_input_with_symbol(bool active_item); // returns the text with an input symbol private: bool input_flickering; Timer input_flickering_timer;