From ca26b357a7adbdd7233ba85893a65c2e0e621d8f Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 24 Oct 2009 20:22:08 +0100 Subject: [PATCH] Some renaming in IFont --- include/gui/IFont.hpp | 12 ++++++------ src/Game.cpp | 6 +++--- src/gui/Font.cpp | 16 ++++++++-------- src/gui/FuelMeter.cpp | 4 ++-- src/gui/Label.cpp | 10 +++++----- src/gui/Panel.cpp | 8 ++++---- src/gui/ThrottleMeter.cpp | 4 ++-- src/gui2/Theme.cpp | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/gui/IFont.hpp b/include/gui/IFont.hpp index fbf3dbc..ce9a34c 100644 --- a/include/gui/IFont.hpp +++ b/include/gui/IFont.hpp @@ -28,16 +28,16 @@ namespace gui { struct IFont { virtual ~IFont() {} - virtual void setColour(float r, float g, float b, float a=1.0f) = 0; - virtual void getColour(float& r, float& g, float& b, float& a) const = 0; + virtual void set_colour(float r, float g, float b, float a=1.0f) = 0; + virtual void get_colour(float& r, float& g, float& b, float& a) const = 0; virtual void print(int x, int y, const char* fmt, ...) const = 0; - virtual int stringWidth(const char* fmt, ...) const = 0; - virtual int maxHeight() const = 0; + virtual int string_width(const char* fmt, ...) const = 0; + virtual int max_height() const = 0; }; - typedef std::tr1::shared_ptr IFontPtr; + typedef shared_ptr IFontPtr; - IFontPtr loadFont(const std::string& aFile, int aHeight, + IFontPtr load_font(const std::string& aFile, int aHeight, bool shadow=true); } diff --git a/src/Game.cpp b/src/Game.cpp index 8609f36..bf982a6 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -97,8 +97,8 @@ Game::Game(IMapPtr aMap) // Build the GUI myStatsPanel = makeFlowBox(FLOW_BOX_VERT); - IFontPtr stdFont = loadFont("data/fonts/Vera.ttf", 14); - myStatusFont = loadFont("data/fonts/Vera.ttf", 18); + IFontPtr stdFont = load_font("data/fonts/Vera.ttf", 14); + myStatusFont = load_font("data/fonts/Vera.ttf", 18); mySpeedLabel = makeLabel(stdFont); myStatsPanel->addChild(mySpeedLabel); @@ -166,7 +166,7 @@ void Game::overlay() const const int screenH = getGameWindow()->height(); const int screenW = getGameWindow()->width(); - const int len = myStatusFont->stringWidth("%s", myStatusMsg.c_str()); + const int len = myStatusFont->string_width("%s", myStatusMsg.c_str()); myStatusFont->print((screenW - len)/2, screenH - 50, "%s", myStatusMsg.c_str()); } diff --git a/src/gui/Font.cpp b/src/gui/Font.cpp index 35f9f9f..2f3abc5 100644 --- a/src/gui/Font.cpp +++ b/src/gui/Font.cpp @@ -39,10 +39,10 @@ public: ~Font(); void print(int x, int y, const char* fmt, ...) const; - int stringWidth(const char* fmt, ...) const; - void setColour(float r, float g, float b, float a); - void getColour(float& r, float& g, float& b, float& a) const; - int maxHeight() const { return myHeight; } + int string_width(const char* fmt, ...) const; + void set_colour(float r, float g, float b, float a); + void get_colour(float& r, float& g, float& b, float& a) const; + int max_height() const { return myHeight; } private: int nextPowerOf2(int a); void makeDisplayList(FT_Face face, char ch, GLuint listBase, @@ -123,7 +123,7 @@ Font::~Font() FT_Done_FreeType(library); } -void Font::getColour(float& r, float& g, float& b, float& a) const +void Font::get_colour(float& r, float& g, float& b, float& a) const { r = myR; g = myG; @@ -131,7 +131,7 @@ void Font::getColour(float& r, float& g, float& b, float& a) const a = myA; } -void Font::setColour(float r, float g, float b, float a) +void Font::set_colour(float r, float g, float b, float a) { myR = r; myG = g; @@ -311,7 +311,7 @@ void Font::print(int x, int y, const char* fmt, ...) const glPopAttrib(); } -int Font::stringWidth(const char* fmt, ...) const +int Font::string_width(const char* fmt, ...) const { va_list ap; vector lines; @@ -334,7 +334,7 @@ int Font::stringWidth(const char* fmt, ...) const return maxlen; } -IFontPtr gui::loadFont(const string& aFile, int aHeight, bool shadow) +IFontPtr gui::load_font(const string& aFile, int aHeight, bool shadow) { typedef tuple FontToken; static map cache; diff --git a/src/gui/FuelMeter.cpp b/src/gui/FuelMeter.cpp index a789a5d..335c32f 100644 --- a/src/gui/FuelMeter.cpp +++ b/src/gui/FuelMeter.cpp @@ -60,7 +60,7 @@ FuelMeter::FuelMeter(IFontPtr aFont, const string& aCaption, const Colour& aColour) : myValue(0), myFont(aFont), myCaption(aCaption + ": "), myColour(aColour), - myTextWidth(myFont->stringWidth(myCaption.c_str())), + myTextWidth(myFont->string_width(myCaption.c_str())), myMin(0), myMax(10) { @@ -68,7 +68,7 @@ FuelMeter::FuelMeter(IFontPtr aFont, const string& aCaption, int FuelMeter::height() const { - return max(myFont->maxHeight(), METER_HEIGHT); + return max(myFont->max_height(), METER_HEIGHT); } int FuelMeter::width() const diff --git a/src/gui/Label.cpp b/src/gui/Label.cpp index b4b332f..ca29cc4 100644 --- a/src/gui/Label.cpp +++ b/src/gui/Label.cpp @@ -62,23 +62,23 @@ void Label::setColour(float r, float g, float b) int Label::width() const { - return myFont->stringWidth(myText.c_str()); + return myFont->string_width(myText.c_str()); } int Label::height() const { - return myFont->maxHeight(); + return myFont->max_height(); } void Label::render(int x, int y) const { float r, g, b, a; - myFont->getColour(r, g, b, a); + myFont->get_colour(r, g, b, a); - myFont->setColour(myR, myG, myB, 1.0f); + myFont->set_colour(myR, myG, myB, 1.0f); myFont->print(x, y, myText.c_str()); - myFont->setColour(r, g, b, a); + myFont->set_colour(r, g, b, a); } void Label::setText(const char* fmt, ...) diff --git a/src/gui/Panel.cpp b/src/gui/Panel.cpp index df9ee3d..c3490e7 100644 --- a/src/gui/Panel.cpp +++ b/src/gui/Panel.cpp @@ -47,9 +47,9 @@ private: Panel::Panel(const string& aTitle, IContainerPtr aContent) : myTitle(aTitle), myContent(aContent) { - myFont = loadFont("data/fonts/Vera.ttf", 13, false); - myFont->setColour(0.0f, 0.0f, 0.0f); - myTitleWidth = myFont->stringWidth(aTitle.c_str()); + myFont = load_font("data/fonts/Vera.ttf", 13, false); + myFont->set_colour(0.0f, 0.0f, 0.0f); + myTitleWidth = myFont->string_width(aTitle.c_str()); } void Panel::render(int x, int y) const @@ -78,7 +78,7 @@ int Panel::width() const int Panel::height() const { - return myFont->maxHeight() + 2*TITLE_PAD + myContent->height(); + return myFont->max_height() + 2*TITLE_PAD + myContent->height(); } IContainerPtr gui::makePanel(const string& aTitle, IContainerPtr aContent) diff --git a/src/gui/ThrottleMeter.cpp b/src/gui/ThrottleMeter.cpp index d3b8cbf..eeacdb7 100644 --- a/src/gui/ThrottleMeter.cpp +++ b/src/gui/ThrottleMeter.cpp @@ -55,7 +55,7 @@ const int ThrottleMeter::METER_WIDTH(100); ThrottleMeter::ThrottleMeter(IFontPtr aFont) : myValue(0), myFont(aFont), - myTextWidth(myFont->stringWidth("Throttle: ")), + myTextWidth(myFont->string_width("Throttle: ")), myMin(THROTTLE_MIN), myMax(THROTTLE_MAX) { @@ -63,7 +63,7 @@ ThrottleMeter::ThrottleMeter(IFontPtr aFont) int ThrottleMeter::height() const { - return max(myFont->maxHeight(), METER_HEIGHT); + return max(myFont->max_height(), METER_HEIGHT); } int ThrottleMeter::width() const diff --git a/src/gui2/Theme.cpp b/src/gui2/Theme.cpp index 9cf7cb0..9719c18 100644 --- a/src/gui2/Theme.cpp +++ b/src/gui2/Theme.cpp @@ -21,7 +21,7 @@ using namespace gui; Theme::Theme() { - normal_font_ = loadFont("data/fonts/Vera.ttf", 11, false); + normal_font_ = load_font("data/fonts/Vera.ttf", 11, false); } Colour Theme::background() const -- 2.39.2