diff --git a/src/gui/credits_menu.cpp b/src/gui/credits_menu.cpp index 239160ce4..72cac7908 100644 --- a/src/gui/credits_menu.cpp +++ b/src/gui/credits_menu.cpp @@ -30,35 +30,34 @@ CreditsMenu::CreditsMenu() { std::string filename; + StringList credits_text_list; try { filename = loader->getPath("data/CREDITS"); - FILE *fd = fopen(filename.c_str(), "ra"); + //FIXME: we should change to c++ - filestreams + FILE *fd = fopen(filename.c_str(), "r"); char s[1024]; char *p; while(fgets(s, 1023, fd)) { - p = strdup(s); - m_string_list.push_back(p); + credits_text_list.push_back(std::string(s)); } // while + fclose(fd); + fd = NULL; } catch(std::runtime_error& e) { printf(_("Couldn't load '%s'\n"),filename.c_str()); - m_string_list.push_back(_("CREDIT file was not installed properly!!")); - m_string_list.push_back(_("Please check 'data/CREDIT'!!")); + credits_text_list.push_back(_("CREDIT file was not installed properly!!")); + credits_text_list.push_back(_("Please check 'data/CREDIT'!!")); } - setText(m_string_list); + setText(credits_text_list); } // CreditsMenu //----------------------------------------------------------------------------- CreditsMenu::~CreditsMenu() { - while(m_string_list.size()>0) - { - m_string_list.pop_back(); - } } // ~CreditsMenu /* EOF */ diff --git a/src/gui/credits_menu.hpp b/src/gui/credits_menu.hpp index 761bf0d10..b0ab410ab 100644 --- a/src/gui/credits_menu.hpp +++ b/src/gui/credits_menu.hpp @@ -29,12 +29,11 @@ class CreditsMenu: public ScrolledText { -protected: +private: int m_xLeft, m_xRight, m_yBottom, m_yTop; float m_yPos, m_ySpeed; int m_numberOfLines; int m_fontSize; - StringList m_string_list; public: CreditsMenu(); ~CreditsMenu(); diff --git a/src/gui/scrolled_text.cpp b/src/gui/scrolled_text.cpp index 1b84f4c08..2685cc0d9 100644 --- a/src/gui/scrolled_text.cpp +++ b/src/gui/scrolled_text.cpp @@ -46,7 +46,7 @@ ScrolledText::~ScrolledText() } // ~ScrolledText //----------------------------------------------------------------------------- -void ScrolledText::setText(StringList sl_) +void ScrolledText::setText(StringList const &sl_) { m_string_list=sl_; if(m_rect) glDeleteLists(m_rect, 1); @@ -82,7 +82,7 @@ void ScrolledText::update(float dt) { if((m_y_pos-i*m_font_size < m_y_top + m_y_bottom ) && m_y_pos-i*m_font_size > -m_font_size) - font_gui->Print(m_string_list[i], 24, + font_gui->Print(m_string_list[i].c_str(), 24, m_x_left,(int)m_y_pos-i*m_font_size); } glMatrixMode(GL_PROJECTION); diff --git a/src/gui/scrolled_text.hpp b/src/gui/scrolled_text.hpp index 8cfa4bab3..435dff15e 100644 --- a/src/gui/scrolled_text.hpp +++ b/src/gui/scrolled_text.hpp @@ -25,20 +25,23 @@ #include "base_gui.hpp" #include "player.hpp" -typedef std::vector StringList; class ScrolledText: public BaseGUI { protected: + typedef std::vector StringList; + +private: int m_x_left, m_x_right, m_y_bottom, m_y_top; float m_y_pos, m_y_speed; int m_font_size; StringList m_string_list; int m_rect; + public: ScrolledText(); ~ScrolledText(); - void setText (StringList sl_); + void setText (StringList const &sl_); void select (); void update (float dt);