Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Moving Menus and make items adjust when the screen size is changed

Author
Message
TommyWat
12
Years of Service
User Offline
Joined: 6th Nov 2012
Location:
Posted: 6th Nov 2012 23:23
I don't know if this has been posted before but i couldn't find it.

What i want to know is how i can make a menu that when a button is clicked it moves and shows more buttons.

Also i would like to know how i can make the text and the buttons adjust size when the screen size is changed
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Nov 2012 06:01
Not sure where you'd want to move a button to while clicking on any sort of interface, but maybe this snippet will give you some ideas of approach.




"You're not going crazy. You're going sane in a crazy world!" ~Tick
Mr909
12
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 8th Nov 2012 23:23
Not Drag-and-drop, Phaelax. Think cascading menus: Click one item, the first tree slides over and makes room for a new tree, which then expands. Or at least that's what I think he means.
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 9th Nov 2012 05:52
I like the zones in Matrix1 Utilities. I've only used them recently for the first time, but am seriously considering them as the back bone for my games 2d UI.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Nov 2012 03:36
My example wasn't "drag-and-drop".

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Mr909
12
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 10th Nov 2012 19:47
Yeah, sorry bout that. Misread it, I wasn't getting much sleep that night. My apologies buddy. But still, it would help even me if you could get that menu code of yours to show the entire tree up until that point, or do some cascading like (I believe)
TommyWat
12
Years of Service
User Offline
Joined: 6th Nov 2012
Location:
Posted: 12th Nov 2012 01:20
cascading more more like what i want,
the idea is have the main buttons on the right had side of the screen and when one is clicked it move to the left hand side and more buttons apper in the middle of the screen


i don't have any code for the button at the mo to
TommyWat
12
Years of Service
User Offline
Joined: 6th Nov 2012
Location:
Posted: 12th Nov 2012 11:32
Mr909, I used your code as a guide and came up with this,



But all 3 buttons are appearing in the same place even tho i said for the to appear in different places any help plz?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Nov 2012 19:47
Look at your drawButton() function. You may have called your function to draw them at different places, but nowhere does the code actually use the numbers you supply it.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
TommyWat
12
Years of Service
User Offline
Joined: 6th Nov 2012
Location:
Posted: 12th Nov 2012 21:11
I've sorted the menu out now, got it working partly, but no one answered my question about make them adjust to resolution change.
Mr909
12
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 12th Nov 2012 23:24 Edited at: 12th Nov 2012 23:31
Here. Since I was so awestruck that someone chose MY code to base their project around, of all things, I decided to go ahead and implement some small tweaks. Nothing much, really. It fixes the issue you mentioned, and builds some additional button structure for you to look at/toy with. Currently, the DrawButton accepts two new arguments, basewidth and baseheight, that modify the button's actual width/height to a proportion of the screen size to a normal 640*480 display. For a button that is 100 wide and 20 tall at 640*480, the call would be DrawButton(x,y,100,20). Simple, eh? I thought so.

If you need anything else, just ask.



EDIT: Here's my line of thinking for a very primitive version of a cascade, in a way that'll probably irk Phaelax to no end, seeing as the entire thing is hardcoded. For simple menus though, it ought to be great.

-Create a variable to know what level of the tree we're on.
-Create a variable to know which branch node we're on, I.E. new game, settings, etc.
-Reconstruct my code so that buttons are only highlight-able if they are in the current level, probably by dividing them into DrawButton and DrawDummyButton.
-Change bx for each button based on what level it's on. If you want them to slide smoothly, you'll need something like my Core Math Regulate code, which is below:

TommyWat
12
Years of Service
User Offline
Joined: 6th Nov 2012
Location:
Posted: 13th Nov 2012 17:45
thx for the response mr909 bu would you be able to rephrase that using this code.



Mr909
12
Years of Service
User Offline
Joined: 2nd Jun 2012
Location:
Posted: 13th Nov 2012 21:06
I could, but if there is one thing I'm not good at wrapping my head around, it's stylistic issues.

Here's what I can tell you, structure wise.

The functions you're needing, for what I believe would be a sensible method "Select_Button" or "Move_Button", just the mouseover check I mentioned. Move_Button would involve more global variables than you should need. The movement is for a button_is_pressed() check that is NOT part of the draw check I included, but instead inside the main loop. You want to create:

main_menu_target_bx
main_menu_target_by
main_menu_current_bx
main_menu_current_by

Or somesuch, then regulate the bx and by. The button_is_pressed check should turn your buttons to dummy buttons and then set the target bx to something different.

Like I said, I would rephrase, but I'm not sure if it's structurally correct. Just play with my code until you find a way that blends well with your parameters/style.

Login to post a reply

Server time is: 2024-11-23 17:36:14
Your offset time is: 2024-11-23 17:36:14