0 votes
by (1.1k points)
retagged by

Just a little doubt, how to do something like a save menu with both load-save options?

E.g.

 

2 Answers

+2 votes
by (63.1k points)
selected by
 
Best answer

Something like this will work but it's messy and probably not perfect.

$(document).on(':dialogopen', function () {
    setTimeout(function () {
        if ($('#ui-dialog-body').hasClass('saves')) {
            var loadBtns = $('#ui-dialog-body.saves button.load').toArray();
            loadBtns.forEach( function (el) {
                var $load = $(el);
                var slot = Number($load.attr('id').split('-')[2]);
                $load
                    .before($(document.createElement('button'))
                            .wiki('Save')
                            .addClass('ui-close')
                            .ariaClick({ label : 'Overwrite Slot ' + (slot + 1) }, function () {
                                Save.slots.save(slot);
                            }));
            });
            $('#ui-dialog-body.saves button.delete').ariaClick( function () {
                $(document).trigger(':dialogopen');
            });
        }
    }, Engine.minDomActionDelay);
});

Edit: fixed errors.

0 votes
by (44.7k points)
That's the standard SugarCube "Saves" dialog in that image.

You didn't say what story format you're using, but if it's SugarCube, then you already have that.
by (1.1k points)

Sorry, that was corrected. And the default save menu of mine is like this...

Print

by (159k points)

@HiEv 

That's the standard SugarCube "Saves" dialog in that image.

Actually it's not, each slot has being given an extra Save option so that the end-user can "save over" the current data without needing to use that slot's Delete option first.

@Annum

As I understand things the layout/contents of the standard Save Dialog is (re)generated each time that dialog is shown. So to modify it's functionally "on the fly" there would need to be some sort of notification event between the time that dialog's content has been generated and the time that dialog is show to the end-user, and I personally don't know of such an event.

This would mean you would need to construct your own custom Save dialog, which I believe is possible using the Dialog API combined with information like that found in the Save Settings section of the Config API and the functionallity of the Save API.

...