Skip to content

Commit

Permalink
Don't use a reference for strings otherwise garbage printed :)
Browse files Browse the repository at this point in the history
  • Loading branch information
wally4000 committed Jul 22, 2024
1 parent ecbc059 commit c065ed9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions Source/SysGL/Graphics/UIContextGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ class IUIContext : public CUIContext
virtual u32 DrawText( s32 x, s32 y, const std::string text, u32 length, c32 colour, c32 drop_colour );
virtual u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, u32 length, c32 colour );
virtual u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, u32 length, c32 colour, c32 drop_colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour, c32 drop_colour );
virtual s32 DrawTextArea( s32 left, s32 top, u32 width, u32 height, const std::string& text, c32 colour, EVerticalAlign vertical_align );

virtual u32 GetFontHeight() const;
virtual u32 GetTextWidth( const char * text ) const;

private:
s32 AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length, EAlignType align_type );
s32 AlignText( s32 min_x, s32 max_x, const std::string p_str, u32 length, EAlignType align_type );

private:
CDrawText::EFont mCurrentFont;
Expand Down Expand Up @@ -252,7 +252,7 @@ u32 IUIContext::GetTextWidth( const char * text ) const
return CDrawText::GetTextWidth( mCurrentFont, text );
}

s32 IUIContext::AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length, EAlignType align_type )
s32 IUIContext::AlignText( s32 min_x, s32 max_x, const std::string p_str, u32 length, EAlignType align_type )
{
s32 x = 0;

Expand Down Expand Up @@ -302,13 +302,13 @@ u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const std::string text
return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour, drop_colour );
}

u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour )
u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour )
{

return CDrawText::Render( mCurrentFont, AlignText( min_x, max_x, text, length, align_type ), y, 1.0f, text, length, colour );
}

u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour )
u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour, c32 drop_colour )
{

return CDrawText::Render( mCurrentFont, AlignText( min_x, max_x, text, length, align_type ) , y, 1.0f, text, length, colour, drop_colour );
Expand Down
12 changes: 6 additions & 6 deletions Source/SysPSP/Graphics/UIContextPSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ class IUIContext : public CUIContext
virtual u32 DrawText( s32 x, s32 y, const std::string, u32 length, c32 colour, c32 drop_colour );
virtual u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, u32 length, c32 colour );
virtual u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, u32 length, c32 colour, c32 drop_colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour );
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour, c32 drop_colour );
virtual s32 DrawTextArea( s32 left, s32 top, u32 width, u32 height, const std::string& text, c32 colour, EVerticalAlign vertical_align );

virtual u32 GetFontHeight() const;
virtual u32 GetTextWidth( const char * text ) const;

private:
s32 AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length, EAlignType align_type );
s32 AlignText( s32 min_x, s32 max_x, const std::string p_str, u32 length, EAlignType align_type );

private:
CDrawText::EFont mCurrentFont;
Expand Down Expand Up @@ -301,7 +301,7 @@ u32 IUIContext::GetTextWidth( const char * text ) const
return CDrawText::GetTextWidth( mCurrentFont, text );
}

s32 IUIContext::AlignText( s32 min_x, s32 max_x, const char * p_str, u32 length, EAlignType align_type )
s32 IUIContext::AlignText( s32 min_x, s32 max_x, const std::string p_str, u32 length, EAlignType align_type )
{
s32 x;

Expand Down Expand Up @@ -351,13 +351,13 @@ u32 IUIContext::DrawTextScale( s32 x, s32 y, float scale, const std::string text
return CDrawText::Render( mCurrentFont, x, y, scale, text, length, colour, drop_colour );
}

u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour )
u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour )
{

return CDrawText::Render( mCurrentFont, AlignText( min_x, max_x, text, length, align_type ), y, 1.0f, text, length, colour );
}

u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour )
u32 IUIContext::DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour, c32 drop_colour )
{

return CDrawText::Render( mCurrentFont, AlignText( min_x, max_x, text, length, align_type ), y, 1.0f, text, length, colour, drop_colour );
Expand Down
2 changes: 1 addition & 1 deletion Source/UI/RomPreferencesScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace
class CTextureHashFrequency : public CUISetting
{
public:
CTextureHashFrequency( ETextureHashFrequency * setting, const char * name, const char * description )
CTextureHashFrequency( ETextureHashFrequency * setting, const std::string name, const char * description )
: CUISetting( name, description )
, mSetting( setting )
{
Expand Down
8 changes: 4 additions & 4 deletions Source/UI/UIContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ class CUIContext
u32 DrawText( s32 x, s32 y, const std::string text, c32 colour, c32 drop_colour ) { return DrawText( x, y, text, text.length(), colour, drop_colour ); }
u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, c32 colour ) { return DrawTextScale( x, y, scale,text, text.length(), colour ); }
u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, c32 colour, c32 drop_colour ) { return DrawTextScale( x, y, scale,text, text.length(), colour, drop_colour ); }
u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, c32 colour ) { return DrawTextAlign( min_x, max_x, align_type, y, text, strlen( text ), colour ); }
u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, c32 colour, c32 drop_colour ) { return DrawTextAlign( min_x, max_x, align_type, y, text, strlen( text ), colour, drop_colour ); }
u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, c32 colour ) { return DrawTextAlign( min_x, max_x, align_type, y, text, text.length(), colour ); }
u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, c32 colour, c32 drop_colour ) { return DrawTextAlign( min_x, max_x, align_type, y, text, text.length(), colour, drop_colour ); }

virtual u32 DrawText( s32 x, s32 y, const std::string text, u32 length, c32 colour ) = 0;
virtual u32 DrawText( s32 x, s32 y, const std::string text, u32 length, c32 colour, c32 drop_colour ) = 0;
virtual u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, u32 length, c32 colour ) = 0;
virtual u32 DrawTextScale( s32 x, s32 y, float scale, const std::string text, u32 length, c32 colour, c32 drop_colour ) = 0;
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour ) = 0;
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const char * text, u32 length, c32 colour, c32 drop_colour ) = 0;
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour ) = 0;
virtual u32 DrawTextAlign( s32 min_x, s32 max_x, EAlignType align_type, s32 y, const std::string text, u32 length, c32 colour, c32 drop_colour ) = 0;

virtual s32 DrawTextArea( s32 left, s32 top, u32 width, u32 height, const std::string& text, c32 colour, EVerticalAlign vertical_align ) = 0;

Expand Down
2 changes: 1 addition & 1 deletion Source/UI/UISetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "UIContext.h"


CUISetting::CUISetting( const std::string& name, const std::string& description )
CUISetting::CUISetting( const std::string name, const std::string description )
: mName( name )
, mDescription( description )
{}
Expand Down
10 changes: 5 additions & 5 deletions Source/UI/UISetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CUISetting : public CUIElement
{
public:
CUISetting( const std::string& name, const std::string& description );
CUISetting( const std::string name, const std::string description );
virtual ~CUISetting() {}

virtual const char * GetSettingName() const = 0;

virtual void OnSelected() { OnNext(); }

virtual const std::string& GetName() const { return mName; }
virtual const std::string GetName() const { return mName; }
virtual const std::string GetDescription() const { return mDescription; }

virtual bool IsReadOnly() const { return false; }
Expand All @@ -44,16 +44,16 @@ class CUISetting : public CUIElement
virtual void Draw( CUIContext * context, s32 min_x, s32 max_x, EAlignType halign, s32 y, bool selected ) const;

private:
const std::string& mName;
const std::string& mDescription;
const std::string mName;
const std::string mDescription;
};


class CBoolSetting : public CUISetting
{
public:

CBoolSetting( bool * p_bool, const std::string& name, const std::string& description, const char * true_text, const char * false_text, bool read_only = false )
CBoolSetting( bool * p_bool, const std::string name, const std::string description, const char * true_text, const char * false_text, bool read_only = false )
: CUISetting( name, description )
, mBool( p_bool )
, mTrueText( true_text )
Expand Down

0 comments on commit c065ed9

Please sign in to comment.