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 - dewyatt

Pages: 1 ... 3 4 [5]
61
Graphics / [Solved] SetCenter
« on: July 06, 2008, 07:47:35 pm »
Well I'm reusing the sprite.
And It's not really a sub-rectangle, it uses the full image:
Code: [Select]

mSprite.SetSubRect(sf::IntRect(0, 0, theGlyph->Texture.GetWidth(), theGlyph->Texture.GetHeight()));


The 'Texture' is an sf::Image.
This all worked fine with 1.2.

62
Graphics / [Solved] SetCenter
« on: July 06, 2008, 07:29:58 pm »
Sorry, wrong code.
Changed it.

63
General / Something strange... (Mouse click)
« on: July 06, 2008, 07:10:57 pm »
It does seem to have a small problem.

Just glancing through the code, I'd suggest you clean it up.
That may help you find the problem here.
Instead of all these if statements, use a switch.
And in your execute() loop, you might want to use statics as an optimization since it's called a lot.

64
Graphics / [Solved] SetCenter
« on: July 06, 2008, 06:46:26 pm »
I know that SetRotationCenter, etc, have all been combined into SetCenter in 1.3.
So I changed all my calls to use SetCenter but I just noticed it doesn't seem to be working correctly.

It looks like everything is rotating around it's top-left corner.
Here's some code:
Code: [Select]

mSprite.SetImage(theGlyph->Texture);
mSprite.SetPosition(static_cast<float>(x), static_cast<float>(y));
mSprite.SetSubRect(sf::IntRect(0, 0, theGlyph->Texture.GetWidth(), theGlyph->Texture.GetHeight()));

mSprite.SetCenter(0.5f * theGlyph->Texture.GetWidth(), 0.5f * theGlyph->Texture.GetHeight());
mSprite.SetRotation(mRotation);
mSprite.SetScaleX(mHScale);
mSprite.SetScaleY(mVScale);

mWindow->Draw(mSprite);

It's from my sfmlTTF library (which is more appropriate for my game than sf::String).

65
Feature requests / OS Active window
« on: July 01, 2008, 11:47:01 am »
Sounds good to me!
It's best not to change design or things will get all messy.

66
Feature requests / OS Active window
« on: June 30, 2008, 09:34:21 pm »
I thought I had already written a response to this, but I guess I closed my browser or something before posting.

Anyways, the problem is this:

There is simply no way to determine whether your app has focus on start up.
Actually, after writing a small test program, I would say the LostFocus/GainedFocus events are a little buggy.
I shot a quick video to show you:
http://video.google.com/videoplay?docid=4311287987679040491&hl=en
The app should not react this way.
The problem illustrated in the video is:
-Somebody starts an SFML app
-They go to another window before the app can create its window
-They switch back to the SFML app
-The app does not receive a GainedFocus event notification until the user switches away from, and back to, the window.

Really, this is all beside my original point.
It would just be much more reliable to add a direct haveFocus() method rather than making assumptions on whether your app starts with focus.

Here is the test code:
Code: [Select]

#include <SFML/Graphics.hpp>

int main(int argc, char *argv[])
{
sf::RenderWindow Window;
bool Done = false;
sf::Event Event;
sf::Font Font;
sf::String String;

Font.LoadFromFile("Font.ttf", 32);
String.SetFont(Font);
Window.Create(sf::VideoMode(800, 600, 32), "sfmlFocus", sf::Style::Close);
while (!Done)
{
while (Window.GetEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Done = true;
break;
case sf::Event::KeyPressed:
if (Event.Key.Code == sf::Key::Escape)
Done = true;

break;
case sf::Event::GainedFocus:
String.SetText("Have focus");
break;
case sf::Event::LostFocus:
String.SetText("Do not have focus");
break;
}
}
Window.Draw(String);
Window.Display();
}
}

67
Feature requests / OS Active window
« on: June 29, 2008, 11:26:41 pm »
I think this has been talked about before a little.

What I would like is a function in sf::Window to tell me whether the window is the active window or not.
Not the active sf::Window, but the active OS window.

I know you can use the LostFocus/GainedFocus events but these don't seem to be reliable.
Right now, I keep a variable mHaveFocus.
It starts out as true, we have to ASSUME we are the active OS window.
I don't like to make that assumption because it isn't always true.
I really don't even like to have this variable.
I feel sf::Window should handle it.

I change this variable when I get Lost/Gained focus events.
I then use the variable to determine whether I should draw anything or just handle events and sleep() a bit.

I don't know what you'd call it though, since there's already isActive().
Anyways, let me know if this would be possible.

68
Window / Mouse cursor enter/leave
« on: June 21, 2008, 07:03:21 pm »
I tried that but it looks like you have ACL enabled or something.
The Media Manager doesn't provide any upload option for me.

69
Window / Mouse cursor enter/leave
« on: June 21, 2008, 03:40:18 pm »
Okay, here's the wiki tutorial:
http://sfml-dev.org/wiki/en/tutorials/CEGUI

If someone with the privileges can move the image+example off the external servers, I'd appreciate it.

70
Window / Mouse cursor enter/leave
« on: June 21, 2008, 05:50:11 am »
Quote from: "Laurent"
Why don't you put this tutorial on the wiki ? It would be useful to a many users ;)

Oh yeah, that would be a good idea.
Will do.

71
Window / Mouse cursor enter/leave
« on: June 21, 2008, 05:04:03 am »
Using CEGUI in SFML is easy, you just use CEGUI::OpenGLRenderer.
Here's a screenshot:
http://i107.photobucket.com/albums/m300/silentdae/sfmlCEGUI.jpg
The tutorials on the CEGUI website apply to SFML as well.
http://www.cegui.org.uk/wiki/index.php/Tutorials

Here's a quick introduction though:
This part isn't SFML specific.
If you haven't already, download the SDK.
You may need to copy CEGUI-SDK\RendererModules\OpenGLGUIRenderer\*.h to CEGUI-SDK\include.

If you're not linking to the static CEGUI libs, you'll want to copy some DLLs to your app folder:
CEGUIBase.dll
CEGUIDevILImageCodec.dll
CEGUIExpatParser.dll
CEGUIFalagardWRBase.dll
CEGUISILLYImageCodec.dll
OpenGLGUIRenderer.dll
SILLY.dll

Plus the debug (CEGUIBase_d.dll, etc) versions as well.
The code from the screenshot was:
Code: [Select]

CEGUI::OpenGLRenderer* CEGUIRenderer = new OpenGLRenderer(0);
CEGUI::System* CEGUISystem = new System(CEGUIRenderer);
CEGUI::Window* RootWindow;

SchemeManager::getSingleton().loadScheme("WindowsLook.scheme");
FontManager::getSingleton().createFont("DejaVuSans-10.font");

CEGUISystem->setDefaultMouseCursor("WindowsLook", "MouseArrow");
CEGUISystem->setDefaultTooltip("WindowsLook/Tooltip");

CEGUI::WindowManager& WindowMgr = WindowManager::getSingleton();

RootWindow = WindowMgr.createWindow("WindowsLook/Static");
RootWindow->setProperty("FrameEnabled", "false");
CEGUISystem->setGUISheet(RootWindow);

CEGUI::Window* Dialog = WindowMgr.createWindow("WindowsLook/FrameWindow");
Dialog->setMinSize(UVector2(UDim(0, 400),UDim(0, 300)));
Dialog->setText("Window");
RootWindow->addChildWindow(Dialog);

That's all before your render loop.
Then, in your render loop add:
Code: [Select]

CEGUI::System::getSingleton().renderGUI();

Before your call to SFML's Window::Display().

To run that, you'll also need to have these files (from CEGUI-SDK/Samples/datafiles) in your app folder:
WindowsLook.scheme
WindowsLookWidgets.scheme
WindowsLook.tga
WindowsLook.imageset
DejaVuSans-10.font
DejaVuSans.ttf
WindowsLook.looknfeel

You'll also want to inject inputs into CEGUI.
Here's some code for that:
Code: [Select]

while (Window.GetEvent(Event))
{
switch (Event.Type)
{
case sf::Event::KeyPressed:
CEGUI::System::getSingleton().injectKeyDown(Event.Key.Code);
CEGUI::System::getSingleton().injectChar(Event.Text.Unicode);
break;
case sf::Event::KeyReleased:
CEGUI::System::getSingleton().injectKeyUp(Event.Key.Code);
break;
case sf::Event::MouseMoved:
CEGUI::System::getSingleton().injectMousePosition(Window.GetInput().GetMouseX(), Window.GetInput().GetMouseY());
break;
case sf::Event::MouseButtonPressed:
switch (Event.MouseButton.Button)
{
case sf::Mouse::Left:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
break;
case sf::Mouse::Middle:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);
break;
case sf::Mouse::Right:
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);
break;
}
break;
case sf::Event::MouseButtonReleased:
switch (Event.MouseButton.Button)
{
case sf::Mouse::Left:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
break;
case sf::Mouse::Middle:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);
break;
case sf::Mouse::Right:
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);
break;
}
break;
case sf::Event::MouseWheelMoved:
CEGUI::System::getSingleton().injectMouseWheelChange(Event.MouseWheel.Delta);
break;
}
}

Finally, I think that's all.
It takes a bit to get it all set up but it's worth it.
Sure beats writing your own GUI.

72
Window / Mouse cursor enter/leave
« on: June 14, 2008, 03:43:46 pm »
The main reason is that SFML is cross-platform (yay!).
Another reason is that the HGE community seems to be pretty dead.
Lastly, I like SFML's code (interface+implementation) more than HGEs.
It seems well thought-out.

73
Window / Mouse cursor enter/leave
« on: June 14, 2008, 01:50:46 pm »
Great, thanks!
No rush, it's not exactly a high priority thing.

And thanks for SFML, I'm glad I switched from HGE.  :)

74
Window / Mouse cursor enter/leave
« on: June 14, 2008, 01:14:33 pm »
Well to quote the cegui wiki:
Quote

 bool injectMouseLeaves( void )

This function informs CEGUI that the mouse cursor has left the system application window which CEGUI considers it's rendering area. This is useful if running in windowed mode to inform widgets that the mouse has actually left the CEGUI display completely (otherwise it may not get to know, since under some systems no more mouse events are generated for a OS window once the mouse has left it).

But the real reason I wanted this feature:
When dragging a CEGUI window around, if the mouse leaves the application window, the CEGUI window still acts as if the mouse button is held down (though it may not be) and the window is being dragged.
In other words, you can drag a window until the mouse is outside of the application, release the mouse button, then bring the mouse back in on the opposite side of the application and the window will 'jump' there and still drag around until you press+release the mouse button.

If I could be notified that the mouse left the application window then I'm sure I could find a way to inform CEGUI that the window is no longer being dragged.
There may be a way around this but I haven't been able to find any yet.

75
Window / Mouse cursor enter/leave
« on: June 14, 2008, 11:35:11 am »
It seems there isn't any event for the mouse cursor entering/leaving the window (in windowed mode).
Is there another way to detect this?
Or should I post this in feature requests?
I'm using CEGUI and having such notification would be nice (not required).

Pages: 1 ... 3 4 [5]