Menus APP

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
mplacona
Posts: 28
Joined: Tue Aug 07, 2007 7:07 am

Menus APP

Post by mplacona »

Hi Guys, I'm creating a menu for an HB I'm currently developing and got stuck in one thing.

I wanna create a very large menu coming from an array (may have 50+ items) and would like to be able to display it in one go on the screen, and let the user scroll over it showing a selector over the item selected, just like IRSHELL when it displays the list of remote controls.

Actually I'm having two probs.

First is that I can't seem to be able to create a char array the same way I create an int array like

Code: Select all

int myArr = {1,2,3,4,5};
If I do the same with char, the program won't compile

And second is that I have no idea about how to make my list scroll when the users uses up and down arrows as well as how to know which position I have to show my selector. I guess I can figure ou the position by getting the last position plus x pixels. But the scrolling thing, I have no idea how to do.

Can anyone help me on that? Even if it's pointing me out to some code samples?

Thanks,

Marcos
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Re: Menus APP

Post by crazyc »

Code: Select all

int myArr = {1,2,3,4,5};
You should probably define that as an array like int myArr[5];
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

Scrolling?
Smooth scrolling?
Silky smooth scrolling? chek out Academic Aid 2.3. Want it like dat?
Vincent_M
Posts: 73
Joined: Tue Apr 03, 2007 4:16 am

Post by Vincent_M »

The best way to do this would be implement a linked list. The reason to go with a linked list is because the number of different items in your list will change making the number of elements in your linked list not static. However, an array would be every bit useful if you have a limit of the number of (possibly different kinds) items. Let's say that you can only hold up to 100 different kinds of items, or that you can only hold up to 100 items, you'll make an array of 100 items. I would make an sItem structure to contain the definition of what your items can do (like have a name, possibly quantity, an int-typed ID to tell what kind of item it is with macros, etc). Then, you would have an array of sItems. The size of the array would be the max amount of items you can have.

For example, your item structure could look something similar like this:

Code: Select all

struct sItem
{
     char name[16];
     int id;
     int quantity;

     sItem() {
          sprintf(name, " ");
          id = -1;
          quantity = 0;
     }
};
No, notice how I set 'id' to -1. You can treat the array of item's as slots. If there isn't an item in your slot, you just set the number to -1, and if there is, then set the id to the number of the corresponding type of the item it is. You can setup a list of macros to determine the type of items you use.

I'd go into more specifics, but it's getting late here. I might have the source code to my inventory system still too. I'll check on that.
Post Reply