Page 1 of 1

Real "Delete" Button. At Save Menu.

Posted: Thu Apr 03, 2014 12:37 pm
by dyrarendy
Well, I didn't see someone use "Delete" button for Delete Saving Game Data.
Or ... Correct me if im wrong. and sorry.

Whatever, i add a button code for "Delete" that can Help "User" delete data and free up spaces.
Without do "Overwrites".

Its Just a Simple Logics, and .. its really simple.

This code from my game :

Code: Select all

##############################################################################
# Save, Load
#

screen file_picker :
       
    $ config.thumbnail_height  = 480
    $ config.thumbnail_width = 700

    default current_file = 0
    if current_file != 0:
        add FileScreenshot(current_file) xalign 0.15 yalign 0.30

    frame:
        area (850, 45, 400, 600)
        style "file_picker_frame"
        viewport:
            scrollbars "vertical"
            mousewheel True
            has vbox
            $ rows = 10
            # Display fifty file slots, numbered 1 - 10.
            for i in range(1, rows + 1):

              if delete == True :
                    button:
                            action FileDelete(i)
                            hovered SetScreenVariable("current_file", i)
                            unhovered SetScreenVariable("current_file", 0)
                            xfill True
                            has hbox
                            $ file_name = FileSlotName(i, rows)
                            $ file_time = FileTime(i, empty=_("{color=#00FF00}Kosong{/color}"))
                            text "=================================={vspace=3}File no : [file_name]{vspace=3}{space=145}[file_time!t]{vspace=3}=================================="

              else :
                    button:
                            action FileAction(i)
                            hovered SetScreenVariable("current_file", i)
                            unhovered SetScreenVariable("current_file", 0)
                            xfill True
                            has hbox
                            $ file_name = FileSlotName(i, rows)
                            $ file_time = FileTime(i, empty=_("{space=147}{color=#00FF00}Kosong{/color}"))
                            text "=================================={vspace=3}File no : [file_name]{vspace=3}{space=145}[file_time!t]{vspace=3}=================================="
                            key "save_delete" action FileDelete(i)

screen save:

    # This ensures that any other menu screen is replaced.
    tag menu
    $ delete = False
    use navigationsave
    use file_picker

screen load:

    # This ensures that any other menu screen is replaced.
    tag menu
    $ delete = False
    use navigationsave
    use file_picker

screen delete:

    # This ensures that any other menu screen is replaced.
    tag menu
    $ delete = True
    use navigationsave
    use file_picker

init -2:
    style file_picker_frame is menu_frame
    style file_picker_nav_button is small_button
    style file_picker_nav_button_text is small_button_text
    style file_picker_button is large_button
    style file_picker_text is large_button_text
The Menu :

Code: Select all

screen navigationsave:

    # The background of the game menu.
    window:
        style "gm_root"

    # The various buttons.
    frame:
        style_group "gm_nav"
        xalign .22
        yalign .94
        has vbox
        textbutton _("{size=+5}Manual{/size}") action FilePage(1)
        textbutton _("{size=+5}Automatic{/size}") action FilePage("auto")
        textbutton _("{size=+5}Back{/size}") action Return()
    frame:
        style_group "gm_nav"
        xalign .37
        yalign .94
        has vbox
        textbutton _("{size=+5}Save{/size}") action ShowMenu("save")
        textbutton _("{size=+5}Continue{/size}") action ShowMenu("load")
        textbutton _("{size=+5}Delete{/size}") action ShowMenu("delete")
    frame:
        xalign .96
        yalign .96
        has hbox
        textbutton _("◄"):
              action FilePagePrevious()

        for i in range(1, 8):
              textbutton str(i):
                    action FilePage(i)

        textbutton _("►"):
              action FilePageNext()

init -2:
    # Make all game menu navigation buttons the same size.
    style gm_nav_button:
        size_group "gm_nav"
U can use menu navigation, or create new menu like me "navigationsave".


The "Key" :

Code: Select all

action FileDelete(i)
Well, try this.

Oh yes, Ignore this code :
( its just a style )

Code: Select all

==================================

And, If u try to delete and then pop up menu like :
"Are you sure wanna quit ?"
(Y) U will delete file save
(N) No action tough.

Actually, Its because :

Code: Select all

screen yesno_prompt:
Solution is U Must Edit "screen yesno_prompt"
( Example : I'm replacing "Are you sure wanna quit ?" with "Are you sure ?". )

Oh, one left..
You Can delete All Saves Games, From All Pages include Automatic Save Pages, and Quick Save Pages.

Re: Real "Delete" Button. At Save Menu.

Posted: Fri Apr 04, 2014 8:42 am
by tiya_nofurita
Hey thanks, it doesn't work perfectly as I blindly copy paste your code but after several attempts fixed the errors manually (mostly because wrong indentation), it works :D. Maybe I'm going to messing around with imagemaps next.
saveloadscreenattempt.png

Re: Real "Delete" Button. At Save Menu.

Posted: Fri Apr 04, 2014 10:16 am
by dyrarendy
The wrong indentation is because "spacing" or "tabs"

Nice one... keep it up.

Re: Real "Delete" Button. At Save Menu.

Posted: Sat Apr 05, 2014 8:11 am
by tiya_nofurita
Yay successfully implement with Imagemap.
Thank you once again!
screenshot0003.png

Re: Real "Delete" Button. At Save Menu.

Posted: Thu Apr 10, 2014 4:14 am
by dyrarendy
that was nice imagemaps.. 8)

Re: Real "Delete" Button. At Save Menu.

Posted: Sat Oct 04, 2014 11:36 am
by Galaxious
This seriously worked. Oh my gosh, thank you so much!

Re: Real "Delete" Button. At Save Menu.

Posted: Sun Sep 04, 2022 4:17 am
by Andredron
viewtopic.php?p=555185#p555185
Slightly updated the code