VgaGames4

VgaGames4 - dialog man-pages

[.. upper level ..]

# vg4->dialog->sysmenu()

Open a canvas-dialog for the system-menu.

SYNTAX
VG_BOOL vg4->dialog->sysmenu(const char *cvasdir, const struct VG_Position *posdst, struct VG_Hash *hvar, void *vdata, void (*cb_load)(const char *fname, void *vdata), void (*cb_save)(const char *fname, void *vdata), const char *startdir)
FUNCTION PARAMETERS

cvasdir | Directory to load canvasses from, or NULL = use system-canvasses
posdst | Canvas-position on window, or NULL = centered
hvar | Hash with variable-values (see vg4->canvas->load())
vdata | Arbitrary data, which is passed to the callback functions
cb_load | Callback-function for loading from file, or NULL = disable load-button Parameters: - fname: selected file, or NULL if startdir is NULL - vdata: arbitrary data
cb_save | Callback-function for saving to file, or NULL = disable save-button Parameters: - fname: selected file, or NULL if startdir is NULL - vdata: arbitrary data
startdir | Topmost directory to start selecting filename from - path: relative path from current directory - beginning with "~": path beginning from the HOME-directory - NULL: don't call vg4->dialog->file_select(), just the callback-functions

RETURN VALUE
Returns boolean: - VG_TRUE: OK - VG_FALSE: Got exit-request
DESCRIPTION
Open a canvas-dialog for the system-menu. This function just calls other dialog-functions according to the user-selection. This function uses following canvas-file (installed below share/vgagames4/canvas/) - sysmenu.top.cvas: Top-canvas The parameter hvar should contain following variables - key: top:title value: title of top-canvas - keys for dialog-functions with prefix of appropriate dialog-name, - "exit:" - "volume:" - "keydef:" - "windowsize:" - "winbright:" - "load:" - "save:" e.g. "keydef:press:title" for vg4->dialog->keydef() and canvas-file keydef.press.cvas If own canvas-files shall be used instead of the system-canvas-files, they must lay in cvasdir or cvasdir/sysmenu/ and have the same names as the system-canvas-files: - sysmenu.top.cvas - uses canvas-items: - [CV-TEXT] with name title: text for title - [CV-BUTTON] with name done: for returning - [CV-BUTTON] with name bt-exit: for clicking the exit-button, calling vg4->dialog->exit() - [CV-BUTTON] with name bt-volume: for clicking the volume-button, calling vg4->dialog->volume() - [CV-BUTTON] with name bt-keydef-kbd: for clicking the keyboard-redefining-button, calling vg4->dialog->keydef() for keyboard - [CV-BUTTON] with name bt-keydef-gc: for clicking the gamecontroller-redefining-button, calling vg4->dialog->keydef() for gamecontrollers - [CV-BUTTON] with name bt-windowsize: for clicking the windowsize-button, calling vg4->dialog->windowsize() - [CV-BUTTON] with name bt-winbright: for clicking the window-brightness-button, calling vg4->dialog->winbright() - [CV-BUTTON] with name bt-load: for clicking the load-button, calling vg4->dialog->file_select() and cb_load() - [CV-BUTTON] with name bt-save: for clicking the save-button, calling vg4->dialog->file_select() and cb_save() - uses variables: - key: title value: title of canvas
EXAMPLE

      extern void cb_load(const char *, void *);
      extern void cb_save(const char *, void *);

      struct VG_Hash *hvar;

      if (!vg4->audio->open(VG_AUDIO_FREQ_HIGH, VG_TRUE)) { VG_dest(); exit(1); }

      hvar = vg4->hash->create();

      /* set variables */
      vg4->hash->setstr(hvar, "top:title", "System-menu");
      vg4->hash->setstr(hvar, "exit:top:title", "Quit game?");
      vg4->hash->setstr(hvar, "volume:top:title", "Set audio volumes");
      vg4->hash->setstr(hvar, "keydef:top:title", "Key Redefinition");
      vg4->hash->setstr(hvar, "keydef:press:title", "Press key");
      vg4->hash->setstr(hvar, "windowsize:top:title", "Resize window");
      vg4->hash->setstr(hvar, "winbright:top:title", "Window brightness");
      vg4->hash->setstr(hvar, "load:top:title", "Load file");
      vg4->hash->setstr(hvar, "save:top:title", "Save file");
      vg4->hash->setstr(hvar, "save:input:title-dir", "Create new directory");
      vg4->hash->setstr(hvar, "save:input:title-file", "Create new file");
      vg4->hash->setstr(hvar, "save:overwrite:title", "Overwrite file?");

      /* execute dialog */
      if (!vg4->dialog->sysmenu(NULL, NULL, hvar, NULL, cb_load, cb_save, ".")) {
        /* exit request */
        VG_dest();
        exit(0);
      }

      vg4->hash->destroy(hvar);