d_list_proc(3alleg4)

πŸ’… d_list_proc β€” bestie edition

okay so real talk, this is from the Allegro manual, and it's about a little dialog thing called d_list_proc. It's a dialog procedure that implements a list box object πŸŽ€ β€” part of the Allegro game programming library, iykyk.


✨ SYNOPSIS ✨

#include <allegro.h>

int d_list_proc(int msg, DIALOG *d, int c);

πŸ¦‹ DESCRIPTION πŸ¦‹

It's giving list box object. πŸ’– What that means is: your user can scroll through a whole list of items, and pick one β€” either by clicking on it, or with the arrow keys. Both work, no cap.

If the D_EXIT flag is set, then double clicking on a list item closes the dialog. Iconic behaviour honestly.

Here's the tea on where everything lives:

  • d1 β€” holds the index of the item that's currently selected πŸ‘‘
  • d2 β€” used to store how far it has scrolled through the list
  • dp β€” points to a function that gets called to obtain info about the contents of the list

That function in dp should follow this form, fr fr:

char *foobar(int index, int *list_size);

How it works, step by step bestie:

  • If index is zero or positive, the function should return a pointer to the string that's to be displayed at position index in the list. ✨
  • If index is negative, it should return NULL, and list_size should be set to the number of items in the list.

🌸 MULTIPLE SELECTION LISTBOX 🌸

Wanna let your user pick more than one thing? Obsessed. Do this:

Set the dp2 field to an array of byte flags indicating the selection state of each list item β€” non-zero means that entry is selected. πŸ’…

⚠️ bestie this is the important bit: this table must be at least as big as the number of objects in the list! Not smaller. Do not play with this. 😭

🫢 SEE ALSO 🫢


that's the whole vibe 🌈 this page was living in Allegro version 4.4.3, mwah πŸ’œ stay hydrated, read your man pages, periodt. πŸŽ€