menu

Bug #632490 reported by Josh Brown
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snakes
Confirmed
High
Unassigned

Bug Description

We need a main menu for our program so that we can access options/settings through the program itself.

This is required by:
  * Option for color using curses API (bug #632345)
  * Option to have 'mirrored' walls (bug #645955)
  * allow user to specify board size (bug #632334)

Tags: feature ui
Josh Brown (joshbrown)
Changed in snakes-game:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Tom Bell (bushbaby2511) wrote :

Code example in bug #632325 not working fully but gives an idea of a selection mechanism.

Revision history for this message
Tom Bell (bushbaby2511) wrote :

Here's the fully working code (could be expanded..)

Revision history for this message
Josh Brown (joshbrown) wrote :

I was thinking of a horizontal menu that would leave space for highscores below it. I'm trying to emphasize simplicity by having all the controls in *one* menu. I've got some code forming but it's not running yet. Once I get something working I'll post it up here.

summary: - have some kind of program options that the user can set
+ menu
description: updated
Josh Brown (joshbrown)
tags: added: feature
tags: added: ui
Revision history for this message
Tom Bell (bushbaby2511) wrote :

I'm working on a Menu API that's in it's final stages which should fit the requirements and be very extensible. As soon as it becomes workable i'll push to a branch and link it here

Revision history for this message
Josh Brown (joshbrown) wrote :

Even though I haven't got any working code, I've posted what I do have
up on Launchpad, in the hope that if it never gets used in the project
it might be helpful to you.

lp:~joshbrown/snakes-game/menu

Revision history for this message
Tom Bell (bushbaby2511) wrote :

Thanks for this! much appreciated. As a concept, Is the bar across the top what you're looking for? With the data relating to screen size etc? Prehaps a more formal layout should be drawn up.. as far as my code is going the attachment gives a general idea of how it is to work.

Notes regarding file:

I'm not sure whether a drop-down Options dialog would be more suitable to give more space for Highscores when options are not being accessed.. As far as the rest is shaping up, the General selection mechanism and toggling for Option items in the submenu is working. I'm working on the scrolling currently. The API is easy-to-use with a few functions required for complete control:

The following code is all that's needed for a menu to be setup:

menu = SnakeMenu(screen)
    playgame = menu.new_head("Play Game")
    optionsm = menu.new_head("Options")
    menu.new_sub(optionsm,"ValueA")
    menu.new_sub(optionsm,"ValueB")
    quitgame = menu.new_head("Quit",quit)
    while True:
        c = screen.getch()
        if c == curses.KEY_LEFT: menu.move_left()
        elif c == curses.KEY_RIGHT: menu.move_right()
        elif c == curses.KEY_UP: menu.move_up()
        elif c == curses.KEY_DOWN: menu.move_down()
        else: pass

Each item has option to connect to a function as shown in quitgame and the parenting is shown with the ValueA and ValueB submenu items.

The move_left/right/up/down() functions control all redrawing and internals such that the above code works in an Event-based way.

The API can be initiated with an optional Style parameter which could later be extended to accomodate more styles etc.

Please let me know if this is suitable or i've gone a little overboard, I started coding and it just kept coming and coming! :)

Regards

Tom Bell

Revision history for this message
Josh Brown (joshbrown) wrote :

Tom, I think a one-line menu (i.e. no dropdowns) would be best. It is up to discussion weather we have multiple pages for menus, but for now I think a single line will suffice. I've tried to create a new blueprint for this feature, but it doesn't seem to have gone well: https://blueprints.launchpad.net/snakes-game/+spec/menu

I think you're right: we need to clarify exactly how we want the menu to function and appear before implementing it. Since you haven't posted your code, I don't know exactly how your menu will work. Thanks for working on it anyway though.

Revision history for this message
Tom Bell (bushbaby2511) wrote :

Code is here for inspection (still a work in progress): https://code.launchpad.net/~bushbaby2511/snakes-game/testing

Regards

Tom Bell

Josh Brown (joshbrown)
Changed in snakes-game:
milestone: none → 2.0
Revision history for this message
Josh Brown (joshbrown) wrote :

Since this is still in the planning stages, it shouldn't be marked as 'Triaged'.

Changed in snakes-game:
status: Triaged → Confirmed
Revision history for this message
Josh Brown (joshbrown) wrote :

Right, here's my idea for a layout. What do you think?

Revision history for this message
Tom Bell (bushbaby2511) wrote :

This looks good to me, the pycurses library has issues with grabbing the ENTER (CARRIGE RETURN) key so prehaps another selection mechanism could be implemented. http://docs.python.org/library/curses.html#curses.version is a list of possible keys and their reliability. Reliable internet access will be a few more days coming but i can start working on the code again.

Revision history for this message
Josh Brown (joshbrown) wrote : Re: [Bug 632490] Re: menu

That's great, hope everything went well. I think we'll almost be ready
for our first release once we get the game packaged, unless there's
anything that you think should be changed first?

As for the ENTER key being unreliable, I'm sure using another key would
be fine - perhaps the UP/DOWN keys?

On Tue, 2010-09-21 at 16:16 +0000, Tom Bell wrote:
> This looks good to me, the pycurses library has issues with grabbing the
> ENTER (CARRIGE RETURN) key so prehaps another selection mechanism could
> be implemented.
> http://docs.python.org/library/curses.html#curses.version is a list of
> possible keys and their reliability. Reliable internet access will be a
> few more days coming but i can start working on the code again.

Josh Brown (joshbrown)
description: updated
Revision history for this message
Josh Brown (joshbrown) wrote :

In the future it looks like we might acquire quite a few settings, maybe we should have a separate menu for options?

Revision history for this message
Josh Brown (joshbrown) wrote :

Since this is a requirement by many bugs, I am increasing the status.

description: updated
Changed in snakes-game:
importance: Medium → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.