Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DeadLeaves

Pages: [1]
1
Graphics / sf::Text removes spaces from GetGlobalBounds, SFML 2.0
« on: March 02, 2012, 09:30:50 pm »
Quote from: "texus"
Just use this to get the size (with the spaces).
Code: [Select]
Text.FindCharacterPos(Text.GetString().GetSize()).x


Wont that return the top left of the character. In other words you'd still have to get the width of the last character counted in aswell.

2
Graphics / sf::Text removes spaces from GetGlobalBounds, SFML 2.0
« on: March 01, 2012, 11:54:44 pm »
Fixed it with this function.

Code: [Select]
int GetWidth( sf::Text *Text )
{
//Make sure its not empty, because this would crash it later otherwise.
if( Text->GetString().GetSize() == 0 )
return 0;

//Temp variables that use the same font and size as the original text.
//This is to get the width of one '#'
sf::Text Temp1( "#", Text->GetFont(), Text->GetCharacterSize() );
sf::Text Temp2( "# #", Text->GetFont(), Text->GetCharacterSize() );

//Now we can get the width of the whitespace by subtracting the width of 2 '#' from "# #".
int Width = Temp2.GetGlobalBounds().Width - Temp1.GetGlobalBounds().Width*2;

//The width of the string without taking into consideration for spaces left at the beggining or end.
int TotalWidth = Text->GetGlobalBounds().Width;

//Get the text from the sf::Text as an std::string.
std::string string = Text->GetString();

//Bool to see if we encounter a string consisting of only spaces.
bool OnlySpaces = false;

//Go through all characters in the string from the start.
for( unsigned int i = 0; i < string.size(); i++ )
{
if( string.at( i ) == ' ' )
//Add each space's width to the sum of it all.
TotalWidth += Width;
else
break;

//Check if we have gone through the whole string.
if( i == string.size()-1 )
OnlySpaces = true;
}

//Go through all characters in the string from the end, as long as it wasn't only spaces.
if( !OnlySpaces )
{
for( unsigned int i = string.size()-1; i > 0; i-- )
{
if( string.at( i ) == ' ' )
//Add each space's width to the sum of it all.
TotalWidth += Width;
else
break;
}
}

return TotalWidth;
}


Feel free to use it for whatever.

3
Graphics / sf::Text removes spaces from GetGlobalBounds, SFML 2.0
« on: March 01, 2012, 07:44:49 am »
I guess I also used the wrong search words. So basically, I have to write some stuff to compensate for it since it will not be fixed until an unknown date or not fixed at all.

4
Graphics / sf::Text removes spaces from GetGlobalBounds, SFML 2.0
« on: February 29, 2012, 11:10:11 pm »
When calling sf::Text.GetGlobalBounds().width It will not count in starting or ending white spaces. Is this intentional? If so, is there a way to get the width with the added white space.

In this test, they all print the same.
Code: [Select]

sf::Text test1(" test");
sf::Text test2("test ");
sf::Text test3(" test ");
sf::Text test4("test");
printf("%f\n",test1.GetGlobalBounds().Width);
printf("%f\n",test2.GetGlobalBounds().Width);
printf("%f\n",test3.GetGlobalBounds().Width);
printf("%f\n",test4.GetGlobalBounds().Width);


Tested with SFML 2.0 Build 204

5
General / How can I group shapes/lines together?
« on: December 08, 2010, 05:44:47 pm »
Wouldn't it work to use an image? Or make a polygon?

6
General / Freeze on startup, now only on some computers
« on: December 06, 2010, 10:36:19 pm »
I know I recently made a thread about the same issue, and soon after posted that I found the solution, however that didn't prove to be true, I could've edited the last topic but as I wrote that I found the problem I though no one would read it again.

When I tried to start my SFML applications it only displayed a cmd window and then nothing more happened, I fixed that on MY development computer by changing to static libraries, however when I tried the application on my laptop and on a friends computer I don't get the same result. On some of my friends computers it works just as it should, however on some other friends they get the same bug that I got before. Just freeze on the cmd window.

I tried sending the people who had problems with the static versions a rebuilt version of the exe but with dynamic libraries(ofcourse i also passed them the needed dlls) However to no avail, they still cannot run my application.

So I'm wondering does anyone else know why this is happening?

I also get this warning when using static library, however it still compiles as it should:
Code: [Select]
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

7
General / Freeze on startup
« on: December 05, 2010, 09:46:20 pm »
Hello, I have been using SFML for a few weeks now without any problems. But today I updated my graphics drivers and now all SFML applications I've made freezes on startup. The console window pops up and then it freezes.

I am using the precompiled version of SFML 1.6 for Visual Studio 2008
I have the graphics card: ATI mobility 5650m.
I updated to graphics driver version: 10.11.

Does anyone know what the problem might be?

EDIT: Solved the problem, changed to static instead of dynamic libraries

8
DotNet / ATI Graphic Card Issue
« on: December 05, 2010, 09:12:11 pm »
I have the exact same issue after I upgraded my graphics drivers.
I use an AMD Radeon 5650m upgraded to 10.11 and now SFML applications hangs on startup. I use SFML with visual studio 2008 and I don't use .net or anything fancy, just regular c++ in VS08 and SFML.

Hope we'll get help, or if you solved it please post how you did it.
I know I posted in DotNet forum part, but this is the exact behaviour I encountered

Pages: [1]
anything