Customizing a menu

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Gear
Miko-Class Veteran
Posts: 764
Joined: Tue Apr 05, 2011 10:15 pm
Projects: Tempestus Sum
Organization: Xenokos Interactive
IRC Nick: Gear
Skype: Skye.Gear
Location: Grand Prairie, TX
Contact:

Customizing a menu

#1 Post by Gear » Sat Jun 29, 2013 4:30 am

Somehow, I knew it would come to this.

The person who agreed to do my UI hasn't contacted me in a very long time, so I thought, "Hey, Gear, let's do our own UI!"

Yeah, this is turning into a mistake.

I used the tutorial on the wiki to put this little gem together:

Code: Select all

screen preferences:
    init -2 python:
        layout.imagemap_preferences(
            "ui/options/ground.jpg",
            "ui/options/idle.jpg",
            "ui/options/hover.jpg",
            "ui/options/selected_idle.jpg",
            "ui/options/selected_hover.jpg",
            [
                (34, 188, 131, 21, "Window"),
                (18, 218, 162, 20, "Fullscreen"),
                (1098, 185, 63, 25, "All"),
                (1096, 217, 71, 23, "None"),
                #(180, 300, 318, 339, "Joystick"),
                (738, 193, 191, 25, "Seen Messages"),
                (741, 224, 183, 25, "All Messages"),
                (738, 280, 191, 24, "Begin Skipping"),
                (361, 187, 176, 24, "Stop Skipping"),
                (360, 217, 177, 23, "Keep Skipping"),
                #(725, 181, 790, 213, "Sound Test"),

                (51, 627, 222, 16, "Music Volume"),
                (329, 627, 222, 17, "Sound Volume"),
                (629, 627, 224, 17, "Voice Volume"),
                #(318, 287, 542, 321, "Auto-Forward Time"),
                (968, 627, 221, 17, "Text Speed"),

                # Also define the game menu buttons.
                (13, 396, 147, 29, "Return"),
                (452, 395, 205, 33, "Save Game"),
                (683, 394, 209, 31, "Load Game"),
                (189, 395, 237, 30, "Preferences"),
                (918, 394, 215, 34, "Main Menu"),
                (1158, 392, 98, 38, "Quit"),
                ])
End result? Bam. Being that I am not good at this programming stuff, I don't even know where to start on the error. Can anyone give me a little insight? Please?
The best reason to get up in the morning is to outdo yourself: to do it better than you've ever done it before. But if you haven't done it better by nightfall... look at your globe and pick a spot: it's always morning somewhere.

User avatar
ShippoK
Veteran
Posts: 348
Joined: Wed Mar 28, 2012 8:59 pm
Projects: Eyes of Gold (In-Progress)
Organization: (Red Moon)
Location: Glorious Nippon (A.K.A the USA)
Contact:

Re: Customizing a menu

#2 Post by ShippoK » Sat Jun 29, 2013 4:52 am

That method is very old and it doesn't work so much for older versions. (Last I heard anyway).
Why not try the imagemap way.

Ex.

Code: Select all

# Preferences
#
# Screen that allows the user to change the preferences.
# http://www.renpy.org/doc/html/screen_special.html#prefereces
screen preferences:

    tag menu
    use navigation

    imagemap:
        ground 'prefsteststart.png'
        idle 'prefsteststart.png'
        hover 'prefstestwhite.png'
        selected_idle 'prefstestwhite.png'
        selected_hover 'prefstestinvert.png'

        hotspot (585, 44, 160, 44) clicked Preference("display", "fullscreen")
        hotspot (386, 44, 160, 44) clicked Preference("display", "window")
        hotspot (175, 386, 112, 34) clicked Preference("transitions", "all")
        hotspot (37, 386, 112, 34) clicked Preference("transitions", "none")
        hotspot (389, 260, 160, 44) action Preference('after choices', 'stop')
        hotspot (586, 260, 160, 44) action Preference('after choices', 'skip')
        hotspot (389, 154, 160, 44) action Preference('skip', 'seen')
        hotspot (587, 154, 160, 44) action Preference('skip', 'all')
        hotbar (23, 31, 266, 10) value Preference("music volume")
        hotbar (23, 92, 266, 10) value Preference("sound volume")
        hotbar (667, 535, 161, 20) value Preference("voice volume")
        hotbar (23, 152, 266, 10) value Preference("text speed")
        hotbar (23, 213, 266, 10) value Preference('auto-forward time') 

        hotspot (10, 543, 127, 57) action Return()
        hotspot (139, 543, 127, 57) action ShowMenu('save') activate_sound "Buttonexit.mp3"
        hotspot (275, 543, 127, 57) action ShowMenu('load') activate_sound "Buttonexit.mp3"
        hotspot (422, 543, 127, 57) action ShowMenu('preferences') activate_sound "Buttonexit.mp3"
        hotspot (553, 543, 127, 57) action MainMenu()
        hotspot (670, 543, 127, 57) action Quit()
 
Hope that helps.
Much Appreciated for those who took the Survey!

Image Image
Eyes of Gold [BL (Suspense) (+18)] IN-PROGRESS
Alternate Online [(Friendship) (+10)] ON-HOLD
DeviantART• •[Honest critique] - 'Honesty is its own reward.'

pwisaguacate
Veteran
Posts: 356
Joined: Mon Mar 11, 2013 11:03 pm
Contact:

Re: Customizing a menu

#3 Post by pwisaguacate » Sat Jun 29, 2013 5:13 am

An init can't be indented.

User avatar
Gear
Miko-Class Veteran
Posts: 764
Joined: Tue Apr 05, 2011 10:15 pm
Projects: Tempestus Sum
Organization: Xenokos Interactive
IRC Nick: Gear
Skype: Skye.Gear
Location: Grand Prairie, TX
Contact:

Re: Customizing a menu

#4 Post by Gear » Sat Jun 29, 2013 5:54 am

ShippoK - I tried adapting my code to the style you provided, but there was a problem with the 'value' for the sliders. The game claimed that 'value' was not an acceptable piece of code. Then I changed it to 'action' and the game actually started, but attempting to click on the slider resulted in:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 153, in script
  File "renpy/common/00start.rpy", line 157, in python
  File "renpy/common/_layout/screen_main_menu.rpym", line 11, in script
TypeError: 'MixerValue' object is not callable

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\bootstrap.py", line 254, in bootstrap
    renpy.main.main()
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\main.py", line 328, in main
    run(restart)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\main.py", line 90, in run
    renpy.execution.run_context(True)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\execution.py", line 509, in run_context
    context.run()
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\ast.py", line 718, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00start.rpy", line 157, in <module>
    renpy.call_in_new_context("_main_menu")
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\game.py", line 369, in call_in_new_context
    renpy.execution.run_context(False)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\execution.py", line 509, in run_context
    context.run()
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\ast.py", line 718, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 11, in <module>
    $ ui.interact()
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\core.py", line 1853, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\core.py", line 2392, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\transition.py", line 45, in event
    return self.new_widget.event(ev, x, y, st) # E1101
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\screen.py", line 319, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\layout.py", line 749, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\behavior.py", line 625, in event
    rv = run(self.clicked)
  File "C:\Program Files (x86)\renpy-6.14.0-sdk\renpy\display\behavior.py", line 211, in run
    return var(*args, **kwargs)
TypeError: 'MixerValue' object is not callable

Windows-7-6.1.7601-SP1
Ren'Py 6.15.4.320
The Time Stones 2.0
EEP! Making progress, but it doesn't quite work yet.

@pwisaguacate - If I don't indent the init code, I get an error: http://puu.sh/3qXPP.jpg
The best reason to get up in the morning is to outdo yourself: to do it better than you've ever done it before. But if you haven't done it better by nightfall... look at your globe and pick a spot: it's always morning somewhere.

pwisaguacate
Veteran
Posts: 356
Joined: Mon Mar 11, 2013 11:03 pm
Contact:

Re: Customizing a menu

#5 Post by pwisaguacate » Sat Jun 29, 2013 7:10 am

Gear wrote:ShippoK - I tried adapting my code to the style you provided, but there was a problem with the 'value' for the sliders. The game claimed that 'value' was not an acceptable piece of code. Then I changed it to 'action' and the game actually started, but attempting to click on the slider resulted in:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 153, in script
  File "renpy/common/00start.rpy", line 157, in python
  File "renpy/common/_layout/screen_main_menu.rpym", line 11, in script
TypeError: 'MixerValue' object is not callable
Hotbars are supposed to use value instead of action. I'm not sure exactly how you're running into the first problem since the imagemap script ShippoK works for me. Maybe you somehow did something funky?

User avatar
Gear
Miko-Class Veteran
Posts: 764
Joined: Tue Apr 05, 2011 10:15 pm
Projects: Tempestus Sum
Organization: Xenokos Interactive
IRC Nick: Gear
Skype: Skye.Gear
Location: Grand Prairie, TX
Contact:

Re: Customizing a menu

#6 Post by Gear » Mon Jul 01, 2013 4:51 am

I most certainly did do something funky -- I didn't transcribe the code correctly because I was being lazy when I was reading.

It works TECHNICALLY now, but now when I hover over a slider, it shows the "hover" image rather than either following the mouse or leaving it at the current setting. Do I need to do something different with a hotbar in an imagemap than I do with other items?
The best reason to get up in the morning is to outdo yourself: to do it better than you've ever done it before. But if you haven't done it better by nightfall... look at your globe and pick a spot: it's always morning somewhere.

Post Reply

Who is online

Users browsing this forum: Google [Bot]