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

Pages: 1 2 [3] 4
31
You've helped me a lot by pointing me towards the benefits of maps over vectors.  That helps me a lot.

I think by learning from your code and also Wavesonics resource manager, I can come up with something customized that will fit well in my project.

Thank you for your help.

32
Quote from: "l0calh05t"
Quote from: "forrestcupp"
So, does anyone have any solutions of an easier way to handle this problem?  Is it a big enough problem to even open a can of worms like this?  I'm open to suggestions here.


You could have a look at my resource manager ( http://www.sfml-dev.org/wiki/en/sources/resource_manager_l0calh05t ), it includes a sf::Font example. This would prevent reloading of the fonts as long as different elements use the same font size (so 8 buttons with font size 20 will share one font)
The main problem I'm seeing as I look through your code is that if someone doesn't have the boost libraries installed, it will render the whole thing useless.  I'd kind of hate to put that requirement on it.  It's definitely giving me stuff to think about, though.

33
Quote from: "l0calh05t"
Quote from: "forrestcupp"
It might be a little while before I have time to look through the code and figure out how to fit it in.  

If I can work it out, is it ok for me to use your code?  If so, what would be the proper protocol for doing that?  I'm new at working with free licenses, and it looks like your license's terminology is slightly different than the zlib/libpng license I used.  I don't know how it works to mix code with different licenses and the best way to direct the credit where it is due.


Since you mentioned the license... I just noticed that I didn't replace all the <> tags... Anyways... it's just your basic 3-clause BSD license which means, yes, you can use the code, but the copyright holder (me) has to be mentioned and the license in the documentation (or otherwise visibly included with the program). Furthermore you may not use my name in any advertising without my permission.
As far as I understand, you could use my code in your project and redistribute it, as long as you point out that parts of the code (and which parts) are licensed under a different license. (But I am no Lawyer)
As far as you understand, would it satisfy the requirements for me to just leave your license in the comments above your code just like you have it?  Of course, I would also give you credit in the wiki.

I need to take the time to make sure I can get it to work, first, though.  Thanks a lot for your assistance.


Edit:
I have updated my code with redkiing's fix for resizing the windows.  That fix is posted to the wiki now.  Thank you redkiing.

34
Quote from: "l0calh05t"

Why not use a manager like mine as a member of cpGuiContainer, and get your fonts from there? This would be invisible to the user. (It will add dependencies to boost::thread and boost::smart_ptr though... if you can get away with no thread safety, you might remove the lock/mutex and boost::smart_ptr only requires a few headers)
It might be a little while before I have time to look through the code and figure out how to fit it in.  

If I can work it out, is it ok for me to use your code?  If so, what would be the proper protocol for doing that?  I'm new at working with free licenses, and it looks like your license's terminology is slightly different than the zlib/libpng license I used.  I don't know how it works to mix code with different licenses and the best way to direct the credit where it is due.

35
Quote from: "redkiing"
Hi forrestcupp,
Nice work!! I think you're gui toolkit is really easy to use, and the included controls are indeed very useful.
However, I don't like that when you resize the window, the gui objects used by the toolkit don't work anymore. They keep using the old coords, so when you try clicking one button when the window has been resized, nothing happens...

I've navigated through your code and I modified the required functions to make it work.
Sweet!  Thank you!

I didn't even think about that because I'm going to be mostly using full screen.  Also, I'm used to wxWidgets not automatically resizing everything for you.  I'll update it when I get a chance and get it posted.  Thanks again.

Quote from: "l0calh05t"

Well, you could of course modify the resource manager to discard anything the moment it goes out of use by storing boost::weak_pointers in the map instead of boost::shared_pointers (would only require an extra check in the GetResource function, because a resource in the map doesn't have to mean it's still loaded anymore)
I know what I'm about to ask is probably remedial.  

I have a class called cpGuiContainer that takes care of some global GUI stuff.  Do you think I could just make an std::vector of sf::Fonts in my cpGuiContainer class.  It will always have my default font, and when someone loads a new font, it will be loaded into this vector if it's not already there.  Through my GuiContainer, I can keep track of what object uses which font, and only have one instance per font/fontsize.  Then when an object changes fonts/fontsizes, at that time cpGuiContainer can load the new one if necessary, and purge the vector of any unused fonts.  That way, it only happens when the user changes a font.  If I did that, instead of having each object create an instance to a font, the objects would be using a pointer to a font that is in cpGuiContainer's vector.

If that could work, it may be a more personalized way for me to do it.  What do you think?

36
Quote from: "l0calh05t"
Quote from: "forrestcupp"
So, does anyone have any solutions of an easier way to handle this problem?  Is it a big enough problem to even open a can of worms like this?  I'm open to suggestions here.


You could have a look at my resource manager ( http://www.sfml-dev.org/wiki/en/sources/resource_manager_l0calh05t ), it includes a sf::Font example. This would prevent reloading of the fonts as long as different elements use the same font size (so 8 buttons with font size 20 will share one font)
What would happen if you called ReleaseUnusedResources() from inside the event loop instead of directly after?  

I'm trying to visualize a way to incorporate something like this without the user of cpGUI even having to know about its workings.

37
I'm thinking about the font problem mentioned earlier, and here's the problem.  SFML currently doesn't properly resize fonts.  If you have a font that was loaded at a size of 12 and resize it to 20, it's still has the same pixels it had as 12 but is blown up to be the size of 20.  Because of that, it doesn't look so great sometimes.  Even starting at a high size and lowering the size leaves nasty artifacts.

So in my code, I opted for quality by actually reloading the font at the new size when the user calls the SetFontSize() function.  The thing is, people are going to at least want different font sizes for different things like text boxes, selection boxes or buttons, even if they're using the default font.  If I have a central font, and the user wants to resize one thing, they will all be resized as a result of my method of doing things for quality sake.

So it seems that every time someone wants an object with a different font size, I would have to load a different font into a font manager.  I can't really see how that would be any better on resources than each object having its own font, unless I were to reprogram the entire way that SFML works with fonts.  I'm definitely not going to do that because my wife is having a baby next week, and it's not really my job anyway to do that.

So, does anyone have any solutions of an easier way to handle this problem?  Is it a big enough problem to even open a can of worms like this?  I'm open to suggestions here.

38
Quote from: "Meltra Bour"
First small steps, I'm a bit of a c++ newby but ...

The thing I was missing was a font manager, it seems you create a new instance of sf::Font for every object in the gui. It feels like this is a bit of a waist on resources, using a manager to spread one instance over several objects would speed up loading and reduce memory usage. Or is my newby mind playing trick on me ?
I'll have to consider how to do that without losing the ability to have different fonts for different objects.  I could probably figure out a way to do it through the cpGuiContainer.

That is a good point, though.

Quote from: "Auron"
Looks nice, it will be great to see when its released.
Are you talking about mine, which was the original post, or Lokk's?  If you're talking about mine, it's in the wiki in the project section.

39
SFML wiki / New wiki page for cpGUI
« on: August 08, 2009, 06:51:58 pm »
cpGUI is an easy to use, object oriented GUI toolkit based on SFML 1.5.  It's released under the zlib/libpng license.

I've put up a detailed wiki page in the English Projects section that can be found here.  You can download the files from the wiki page, and also see a screenshot.

The wiki has a description of all of the classes and the user functions in each class.

Hopefully someone can get some use out of it.

40
Sorry to preempt you.  I guess it's always good for people to have choices.  It's also good to have different license choices, since you're using GPLv3 and I'm using zlib/libpng license.

Anyway, I got a wiki page up under the English Projects section.  You can find my wiki page here, and you can download the code from that page.  It's in a zip file.


Edit:
I've updated my code to put everything in a namespace called cp.  I also fixed a small bug with the drop down box.

41
Graphics / Image Not Showing
« on: August 07, 2009, 09:26:52 pm »
You're clearing the screen after you draw things.  That's why you don't see anything on the screen.

Also what Laurent said about the event checking is pretty obvious, too.

42
General / Tutorial Issue: Using Render Windows
« on: August 07, 2009, 09:21:33 pm »
If it's debug, you have to put a -d at the end of the lib names.

Also, don't you have to define SFML_DYNAMIC in the preprocessor definitions?

43
I was working on some GUI stuff to use in my SFML projects, and it ended up turning into a decent object oriented GUI toolkit.  It's object oriented, and extremely easy to use.  

I figured it might be useful to people, so I'm going to release it under the zlib/libpng license like SFML.  It is called cpGUI, and it's based on SFML version 1.5.

It includes the following controls:
* Normal highlightable Buttons with a text label
* Image Buttons that are based on an sf::Image
* Shape Buttons that take an sf::Shape and turn it into a clickable button
* Check Boxes
* Selection Boxes with the ability to add choices.  It uses a scroll bar when necessary
* Drop Down Boxes with the ability to add choices and set maximum depth. A scroll bar is used when you reach your maximum depth.
* Text Input Boxes - a one line box for inputting text.  It has a blinking caret, but it is non-editable
* Text Boxes for loading a simple text file and displaying it.  The Text Box will automatically word wrap the text according to the size of the box you create.  This is useful for displaying instructions or licensing info. Text Boxes are non-editable and read only.
* A GuiContainer class that contains all of your objects - used for setting focus, and also some other things under the hood.

Almost all of the work is done for you, and it is very simple to use.  In most of the controls, you can easily customize the colors, fonts, size, & position.  Each object can return its state and tell you if the mouse enters or exits the control, and can tell you if the button was clicked or if it's down.

If anyone is interested, I can upload it and put it in the wiki when I have time.  I'll post a screen shot that includes all of the available controls.  If I post the files in the wiki, I'll include the example code for the screen shot with lots of comments explaining how to use cpGUI.

Update:
I have added a built-in font manager to help save on resources. Now, rather than having a separate font for each object, new fonts are only loaded when necessary. Also, when a font is no longer used by any object, it is automatically deleted. Other than cpGUI's default font, you will never have an unused font in memory.

This is all automatic, and it doesn't change how cpGUI is used.

Thanks to “Meltra Bour” for pointing out the need on the forums. Thanks to “l0calh05t” & “Wavesonics” for helping me learn how to implement this.

**Major Update** - 9/28/9

See this post for details.  Includes functions for setting mouseover color, bug fixes, and separate files to include only the controls you need for your project.

**Update** - 9/29/09

See this post for details.  Update includes various tweaks, bug fixes, and now cpGUI has static libraries.


You can download the latest update in the Projects section of the Wiki.



44
Window / Caps lock
« on: August 07, 2009, 01:01:40 am »
I only have one class that takes text input, so it might be worth it.  Can you point me to any examples on how to use a TextEvent.  I can't seem to find anything.  There's really nothing in that section of the Docs.

Thanks for your help.

Edit:

I found your example in this thread.

I wrote about 150 lines of code to do what I could have done in about 6.  Thank you for your help.

45
Window / Caps lock
« on: August 06, 2009, 11:02:57 pm »
I actually already did it using sf::Input.  It will do any printable key on an American keyboard, whether shifted or not.  The only thing missing is caps lock.  If the caps lock thing isn't possible, it's not possible.

The reason I needed to use Input is to simplify the future use of what I'm making.  I didn't want to have to use an Event and an Input both for the same class.  I opted for complex now to make it simple for people to use later.

And I really didn't mean to sound like an ass earlier.

Pages: 1 2 [3] 4