Custom user menu
12 posts • Page 1 of 1
Custom user menu
Finally... mouse clickable user custom menu phunlet available.
TAB is default activation key, but sure you can reassign it.
How to use:
0) Load phunlet
It use collision group G so place it right (or change collideSet if you need to)
1) Create your menu as list variable:
[Title_string, Width_int, ItemCount_int, [item1_string, item2_string...], [item1_action, item2_action...]]
2) Call scene.my.menuOpen(menu, pos) in yellow laser onLaserHit event
That's all!
If you want make sub menu, you must do exactly the same - declare sub-menu variable and fill it with items, then call this menu from "parent" menu item action. To set correct pos for submenu you can use scene.my.subMenuPos(selected_item) function.
TAB is default activation key, but sure you can reassign it.
How to use:
0) Load phunlet
It use collision group G so place it right (or change collideSet if you need to)
1) Create your menu as list variable:
[Title_string, Width_int, ItemCount_int, [item1_string, item2_string...], [item1_action, item2_action...]]
2) Call scene.my.menuOpen(menu, pos) in yellow laser onLaserHit event
That's all!
If you want make sub menu, you must do exactly the same - declare sub-menu variable and fill it with items, then call this menu from "parent" menu item action. To set correct pos for submenu you can use scene.my.subMenuPos(selected_item) function.
- Code: Select all
Scene.my.menuDefault := ["Menu", 7, 2, ["Change color...", "Exit menu"], [{scene.my.menuOpen(scene.my.colorMenu, scene.my.subMenuPos(1))}, {scene.my.menuClose}]];
Scene.my.colorMenu := ["Set menu colors", 10, 5, ["White", "Dark gray", "Orange", "Ocean", "Night city"], [{
Scene.my.menuColor = Scene.my.menuTheme(0);
scene.my.menuClose
}, {
Scene.my.menuColor = Scene.my.menuTheme(1);
scene.my.menuClose
}, {
Scene.my.menuColor = Scene.my.menuTheme(2);
scene.my.menuClose
}, {
Scene.my.menuColor = Scene.my.menuTheme(3);
scene.my.menuClose
}, {
Scene.my.menuColor = Scene.my.menuTheme(4);
scene.my.menuClose
}]];
Last edited by Kilinich on Tue Jan 25, 2011 2:31 pm, edited 3 times in total.
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Custom user menu
So... the question is - do you want check-boxes and radio-buttons? 
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Custom user menu
I've test "dynamic" menu variable and it works fine, for example if you need some of menu items must be inactive depends on variable - no problem:
- Code: Select all
scene.my.var := 2;
scene.my.active := (txt, isActive) => {isActive ? txt : "<markup><s>"+txt+"</s></markup>"};
scene.my.liveMenu := {["Dynamic menu example", 12, 1, [scene.my.active("var is big", scene.my.var > 3)], [{scene.my.menuClose}]]};
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Custom user menu
Radio-buttons all the way!
This is awesome!! Thanks for sharing!
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Custom user menu
I saved it as a phunlet, and it won't work.
What I did was:
Open the phunlet, fix it to the background
Copy and paste the menu-code (code in the first post) into the console and press enter
press the tab key to test the phunlet; nothing happened.
What am I doing wrong?
What I did was:
Open the phunlet, fix it to the background
Copy and paste the menu-code (code in the first post) into the console and press enter
press the tab key to test the phunlet; nothing happened.
What am I doing wrong?
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Custom user menu
TC42 wrote:I saved it as a phunlet, and it won't work.
What am I doing wrong?
Did you run the simulator?
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Custom user menu
Yes, the sim was running when I tried to use it.
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Custom user menu
Reset config.
Check console for errors.
Check console for errors.
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Custom user menu
I reset my config (using the in-game reset)
Console said this when I loaded up the phunlet
When I pressed the tab key, the console didn't say anything, but the yellow laser did fire.
Console said this when I loaded up the phunlet
- Code: Select all
Loading Algodoo/scenes/phunlets/UserMenu.phz...
-- Warning: Failed to evaluate: scene.my.mainLaser, Cannot find identifier "mainLaser" in "my"
-- Warning: Caught Exception: Not an integer, source\script\Attributes.hpp:169: void script::TAttrib<int>::CalcValueFromObject(void)
-- Warning: maxRays was bound to bad type. Restoring to last known value.
-- Warning: Failed to evaluate: scene.my.menuLaser, Cannot find identifier "menuLaser" in "my"
Imported phunlet Algodoo/scenes/phunlets/UserMenu.phz
When I pressed the tab key, the console didn't say anything, but the yellow laser did fire.
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Custom user menu
TC42 wrote:I reset my config (using the in-game reset)
Console said this when I loaded up the phunlet
- Code: Select all
Loading Algodoo/scenes/phunlets/UserMenu.phz...
-- Warning: Failed to evaluate: scene.my.mainLaser, Cannot find identifier "mainLaser" in "my"
-- Warning: Caught Exception: Not an integer, source\script\Attributes.hpp:169: void script::TAttrib<int>::CalcValueFromObject(void)
-- Warning: maxRays was bound to bad type. Restoring to last known value.
-- Warning: Failed to evaluate: scene.my.menuLaser, Cannot find identifier "menuLaser" in "my"
Imported phunlet Algodoo/scenes/phunlets/UserMenu.phz
When I pressed the tab key, the console didn't say anything, but the yellow laser did fire.
Damn, who told you to SAVE it as phunlet from algodoo - it just erase scene.my section.
Save it to phunlet folder from browser!
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Custom user menu
Ohhhhh. That would explain it. Thanks!! 
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
12 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest





