How can i make my own graphical menu using sdl?

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 4548 Views - Last Post: 25 September 2010 - 11:34 AM Rate Topic: -----

#1 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 01:54 AM

Does anyone know of a way I can make a simple list-type menu using sdl?
Also, how to have my program automatically create and delete an array of objects being pointed to by a pointer.
I'm running this on my psp by the way.

Is This A Good Question/Topic? 0
  • +

Replies To: How can i make my own graphical menu using sdl?

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 05:02 AM

Question One (about SDL)
Read and enjoy
http://www.sdltutori...utorial-basics/

Question Two (dynamic array of objects)
So you are writing in C++? (basing this guess on the use of the term objects - your don't bother to tell us what you are writing in)
While you can do all this with dynamic arrays and pointers as though you were still in C days there is no need to do so in C++ unless you are doing something particularly interesting.
Share your code on this interesting problem you are part-way though.
Or have you just read the words 'dynamic array' and 'pointer' and thought using them would help in your question without being completely sure what they meant or how you might use them?
Demonstrate what the story is here and show us what you have done so far so we can help you better.
Was This Post Helpful? 1
  • +
  • -

#3 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 08:08 AM

Sorry it took me so long to post but, this is how far I've gotten but I don't know what to do next:
class mi{   
             char name[256];
             int x;
             int y;
             int width;
             int height;
              mi(char nameval[256],int xpos,int ypos,int widthval,int heightval){
                     this->name[256] = nameval[];
                     this->x = xpos;
                     this->y = ypos;
                     this->width = widthval;
                     this->height = heightval;
                     }
             int display(char nameval[256],int xpos,int ypos,int widthval,int heightval){
                     this->name[256] = nameval[];
                     this->x = xpos;
                     this->y = ypos;
                     this->width = widthval;
                     this->height = heightval;
                     )
         };



and I mean an array of objects being pointed to a single pointer
is this:

mi* pmitem = new mi[];
//(mi = menu item and pmitem = pointer of menu items)



I know the above code works because I tried it before on different project.

Anyway, what I am doing is to display menu items on the screen. I need a way to delete them when they don't need to be used any more.
I also need to create objects on the fly for things like file browsing, browsing music, pictures etc..., automatically so my PSP wouldn't run out of memory quickly
I am using c++ and I am using sdl for the PSP on the PSP
Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 08:17 AM

Well writing "PSP" in very large font certainly helped a lot in making your posts clearer (or maybe not).

Is this what you are casting about for?
http://msdn.microsof...y/h6227113.aspx
Was This Post Helpful? 1
  • +
  • -

#5 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 08:24 AM

Well, that solves my first problem but how can I create objects on the fly for file browsing? 5
Was This Post Helpful? 0
  • +
  • -

#6 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 08:27 AM

new?
http://www-numi.fnal...x_crib/new.html

http://publib.boulde...rc05cplr199.htm

This post has been edited by janotte: 25 September 2010 - 08:30 AM

Was This Post Helpful? 1
  • +
  • -

#7 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 08:56 AM

Okay, but how can I make code that automatically assigns objects to files and folders?
Was This Post Helpful? 0
  • +
  • -

#8 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 09:01 AM

View Postwaratte, on 26 September 2010 - 12:56 AM, said:

Okay, but how can I make code that automatically assigns objects to files and folders?


I don't know what that means.

Expand on your thinking on what classes you are thinking of creating and how that relates to files and folders.

Do you want to have a class "Folder"?
Is that what you are driving at?

I'm not at all sure what you are saying/asking.

EDIT
You do realise that on my browser your sig block is a huge grey square of nonsense?
It's pointless and makes your postings harder to read.
I strongly urge you to get rid of it.

This post has been edited by janotte: 25 September 2010 - 09:04 AM

Was This Post Helpful? 1
  • +
  • -

#9 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 09:33 AM

I am making a class of menu items.
Some of the objects are constant (files, apps, games,etc...) and others need to be created automatically so that I can show files and folders correctly.

for example:
class menu_item{
...blah blah
}

menu_item pmenu_item = new menu_item(blah blah....)[];
//constants
menu_item games(...);
menu_item apps(...);
menu_item now playing(...);
menu_item database(...);
//and so on
int assign_objects_to_a_file_or_folder(...){
/*code that browses inside of a directory and assigns all of the
files and folders it sees to an object
*/
}



I don't need to know how to browse a directory but how to assign objects to the files and folders it found.
Was This Post Helpful? 0
  • +
  • -

#10 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 09:48 AM

So what you mean is you need a menu_item per file name or directory name? Let's say you had 10 files, you would then have 10 menu_item objects? There's something for this. It's called an array. You already were going down this route.

Here's what I recommend you do. Use a vector. It's much easier to work with vectors. Vectors are a contiguous collection of objects like arrays, but much easier to work with.

If you do persist on going the array route, please review your material on arrays. Code like mi* pmitem = new mi[]; makes no sense. What does mi[] mean? You can't have an array of unknown size. The size must be specified (so if you had 10 files, you would have to create an array of size 10).
Was This Post Helpful? 1
  • +
  • -

#11 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 09:54 AM

Thanks, never knew vectors even existed!
Also, "mi* pmitem = new mi[];" was just an example, I know that I should state how big it is and if you read what I posted up there you would see that "mi" is short for "menu_item".
Was This Post Helpful? 0
  • +
  • -

#12 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 09:57 AM

So you are going to have a singleton class "Menu" and that instance 'has a' instance of the class "Folder" and an instance of that class 'has a' instance of the class "File"?

Does that make sense?

Are we using the word "object" in the same way?

This is the stuff I am talking about but I am not at all sure we are talking the same language here.
http://www.desy.de/g...orial/node6.htm

Apologies if I am missing what you are saying.
I am overdue for bed so hopefully someone with a brain working better than mine will take things on from here.
Was This Post Helpful? 0
  • +
  • -

#13 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 10:27 AM

Quote

So you are going to have a singleton class "Menu" and that instance 'has a' instance of the class "Folder" and an instance of that class 'has a' instance of the class "File"?


No, there is only one class, "mi" which is short for menu item.

This post has been edited by waratte: 25 September 2010 - 10:29 AM

Was This Post Helpful? 0
  • +
  • -

#14 waratte  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 27-August 10

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 10:56 AM

Quote

Here's what I recommend you do. Use a vector. It's much easier to work with vectors. Vectors are a contiguous collection of objects like arrays, but much easier to work with.


How do I access object data with a vector of objects?
Was This Post Helpful? 0
  • +
  • -

#15 Mohanddo  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 50
  • Joined: 07-July 09

Re: How can i make my own graphical menu using sdl?

Posted 25 September 2010 - 11:01 AM

View Postwaratte, on 25 September 2010 - 09:56 AM, said:

Quote

Here's what I recommend you do. Use a vector. It's much easier to work with vectors. Vectors are a contiguous collection of objects like arrays, but much easier to work with.


How do I access object data with a vector of objects?

Just like you would with arrays.

You could also use at(position) instead of the [] operator.

This post has been edited by Mohanddo: 25 September 2010 - 11:03 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2