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.

DarkBASIC Professional Discussion / I just can't get this menu working right...

Author
Message
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 8th Mar 2008 23:04
Hey guys, I hope you all could help me out here because I'm completely stuck.

I found some neat menu code done by Mistral found here:
http://forum.thegamecreators.com/?m=forum_view&t=98882&b=6

It's probably the nicest menu code I've seen around here with limitless sub menu's. Anyway, I've taken it and incorporated a double click function for my needs. Since the right mouse button is currently used to drag my camera around, I had to make it double click so I could still maintain the control scheme I wanted.

Ok... but here's the problem, it just isn't working right! You can't pick an item on the menu and you can't make the menu disappear by clicking off. It just pops up and doesn't do anything. Also, after the first double click, a single click will be enough to use the menu... which isn't what it's suppose to do BAH.

I worked on this damned menu code for roughly six hours yesterday and two hours today and I'm completely stumped and frustrated. If you guys could help me out, I would sure be grateful. Also, if I can get this fixed, it will be included in the next release of Tersculpt along with Object Placement! So there is a benefit

I suggest downloading mistrals code and seeing how it works, and then looking at mine. Here is mine:



Thanks guys

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 9th Mar 2008 04:23
bump

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Mar 2008 07:13
Been trying to see how your double click function works,but can not seem to get it to do as you are hoping.

here's what I've tried to work out what was going on,I may have change to much and that why it running wrong or I have not change the right bit to make it work right.

As you said the above works Ok before you wanted your double right click.





Dark Physics makes any hot drink go cold.
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Mar 2008 07:31
well I think it does as you want try puuting the bit I change into your code and see what happends.





Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 9th Mar 2008 14:12 Edited at: 9th Mar 2008 23:03
Hey HowDo! Thanks, that brings it closer to what it needs to do!

Try this out (I just put the menu back in from what you did) and it's almost there I think. It just needs to stay open with a double click, allow me to pick whats on the menu and then close after I pick it or click off the menu.



I'll take another look at it when I get home today. That was a big help already

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 9th Mar 2008 23:47 Edited at: 9th Mar 2008 23:47
Still no dice. I don't understand why the W)*@$ menu won't stay up! It just flashes! Everything is perfect except that. I've spent yet another day chasing my tail with this menu code. I play the concept of the loop over and over in my head and it all makes sense, but when it actually is run it doesn't work.

Updated Code:


Anyone?

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Mar 2008 00:51
had another look try replacing this line

if double_click(clickDelay#)

with this

if double_click(clickDelay#)<>0

did a Google on double click only found one that you are using and that was only suppose to work in DBC, all the other did not work correctly or not of much help eg: no code.

But I think the above might get it a bit nearer.

Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 10th Mar 2008 01:11
I had Van B take a look at why that double click code didn't work in DBP and only in DBC. He fixed it, and it's the one I'm using above, so it doesn't matter. It had something to do with declaring globals near the top and I think one other thing but I forget. Thanks for looking into it though, your very thorough

I'm still fruitless *sigh*. However, I think it has something to do with the it constantly looping through the menu code... is there a way to stop the loop (except the sync?) until I've made my selection in the menu? I'm not even sure this is the problem to be honest...

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Mar 2008 01:24
Got control value to exit function if it is a one so as not to run it. Make control global



Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 10th Mar 2008 02:17 Edited at: 10th Mar 2008 02:39
Didn't change anything for me... I don't think?

EDIT: Nevermind, I see what did it did. Thanks for that

The double click function should be perfect now I think right? Do you think it's the double click function not allowing the menu to stay up after a double click? Or do you think it's the menu code?

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Reality Forgotten
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Wichita Falls TX
Posted: 10th Mar 2008 10:21
I would not use a double click function, I would use a keystate() and a mouseclick() at the same time or just simply rely on the ketstate() to do what you want it to.

Cheers,
Dave


HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Mar 2008 13:18
Sid Sinister would not know as I have not run your code as its means me downloading the other plugin you are using. however I think we sovled the double click, just need a way of saying keep menu going until something is picked then close.

cheers

Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 10th Mar 2008 13:47
@Reality Forgotten: Eh, either way it produces the same results. Plus the double click function is working fine, it's just either a variable in the function itself to keep the menu open until a selection has been made, or more likely a problem down in the menu code.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Mar 2008 15:10
try putting all global at the being of your code and not in an if statement, as putting a global in a function makes it only available to that function and none of the others.

global cmr as integer
global cmi as integer
global cma as integer
global mhc as integer
global cmc as integer

if the above menu was for DBC then it might all work differently plus if you are using 6.7-80 then global works differently (I think).

When debugging I end up putting lots of print variable in my code its messy but allows you see if your getting the result you were after.

your almost there, keeping going, I think we can see the light at the end of the tunnel,( Nop someone with more work )

Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 10th Mar 2008 16:53
No other function needs those globals though... I don't think. I'll put em' up top and experiment with putting different variables in though.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 11th Mar 2008 06:52 Edited at: 11th Mar 2008 06:57
Haha!

Almost there! I caught the bug finally! The only problem left now is that when you select an option in the menu it works sometimes and not others. It's weird, almost like it's randomized. I'm still working on it, but I was so excited I thought I'd share



Changes made were setting cmi=0 instead of 1 and a few loop things. I also had to make the mouse position value = itself while the menu was turned on so it would drag the menu around the screen while I select an option. The mouse variable is different for selecting than it is choosing the position to open the menu, thats why I able to freeze one and still use the mouse to select.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Mar 2008 13:38
caved in and loaded Cloggy's dll , can now see what you mean by sometime it works and sometime it don't, Think it might have to do with something that calls the messagebox but not found out how it gets a call to go there as only just started looking there.

Question is are you going to continue using that or make the menus do what they say when clicked?

will post code as I have it now but it might confuse you as I have add bit all over, most should be up by the left side to make it a bit easrier to see.




Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 11th Mar 2008 17:30
Hmm, it's still doing it. I don't plan on using the message box, so I think I'll take it out and have it do something else to see if it's still doing that. If it isn't the problem it's going to be another 'fun' filled day of debugging lol.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Mar 2008 17:44
Yes , try and get thee menu system to report back that you click menu Item x every time, then you will know its ok, I think messagebox is not doing it job every time, maybe to do with loading the DLL each time.

have fun.

Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 11th Mar 2008 19:38
Message box seems to be fine, it's somewhere else. I swapped out the messagebox function code for a few different print commands and it worked just as the message box did.

Also, I made it so the menu stays up after a double click by switching cma and control to 1 down where you had it clear around line 307. What's odd is it gave me the error in reverse lol. I could keep selected the options and message boxes came up, but the menu didn't stay up like it was suppose to. I wonder what that means?

Like I said, the message box appears to be fine. I also just loaded the dll once to see if that was the issue, but it operated fine, minus the bug lol.

It has to be in the context menu clickk (cmc) or maybe the cma... maybe it's clearing to fast on some clicks, making it so the command doesn't get it's turn?

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Mar 2008 20:01
This might help in slowing down the code put sync which your are not using yet to sync rate 10, sort of puts code into slow motion.



Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 11th Mar 2008 20:09
Lol, I did as you said with the sync and I'm not sure if it helped or if it hurt. Have you seen the result?



The menu doesn't even come up when you slow it down that far, until you click the mouse button over where you click. And then the message box will come up (you have to click the button blindly) and the menu will flicker once. Odd? Is this due to sync or is this the reason?

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Mar 2008 21:27
I think it hurt! as I could not get anything to go.

ok let do a re-cap , we know if you use the original menu code it worked ok.

We now know that the double click does as we what.

check that we have found all the globals for the original menu code.

then put the original code in plus the new double click code and see where it goes, want to see what might happen.

now I am off to find the original menu code and have a go at doing the above.

Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 11th Mar 2008 21:32
See my first post up at the top for the original menu. It's done by mistral.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 11th Mar 2008 21:42
Well tried what I said and now it very weird, two click and sometimes the menu list comes up then when you click on a menu item it clears but then you need three clicks to get it back.

Like you I am now lost, could do with a fresh mind on this.

Anyone else like to jump in and help!

Dark Physics makes any hot drink go cold.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 12th Mar 2008 00:39
Indeed, a fresh set of eyes on this would be greatly welcomed.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 12th Mar 2008 06:14
*bump* come on guys, I know people are reading this.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 12th Mar 2008 15:11
OK, I'm going to have a go, but it won't be till later so i'll report back later with my findings. Wish me luck
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 12th Mar 2008 17:15
Wow! I was expecting some help, but I was NOT expecting to get THE GOD OF MENU MAKING! Thanks a bunch Sasuke, if you can solve this, you'd be even more of a hero than you already are

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 13th Mar 2008 06:30
Did you get a chance to look at it yet sasuke? Just wondering

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Mar 2008 13:34 Edited at: 13th Mar 2008 14:27
Yes I did and here's my results:

I tried for hours working out how your double click function ties into the menu and why it acted randomly, but got know where. So I had to create a new double click function and solved the problem, I even made a tiny demo. I added basically what you said in your first post, hope this helps.

Controls:
Left mouse click: click to select menu element and click menu off.
Right mouse click: double click to open menu and hold when menus not active to move the camera.
Up, Down, Left, Right or WASD to move camera.
Mousemove to rotate camera.

And the Code:


THE GOD OF MENU MAKING!...(a bit, just kidding), I'm more the god of problem solving, but thanks for the commemt Sid
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 13th Mar 2008 14:08
I don't have either of those plug-ins. Most people only bump a post to keep it on the first page, not to force people to respond. If you get no response, its probably because people are unable, or unwilling to assist you. In my case, I don't have the plug-ins, and that is alot of code to wade through to find something that you have overlooked. However...

mouseclick will return the current mouse button states. In your double click function, you call it multiple times. Call it once, save that in a variable, and use that in the function.
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Mar 2008 14:23 Edited at: 13th Mar 2008 14:26
That's what my function does or did you miss my post:

HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 13th Mar 2008 14:25
Now that Sasuke has got it going, I can see way our attempt was not working, it was trying to do it all from the main do loop, when in fact it was looping in the draw menu loop.

Well done Sasuke for sorting out.

@jinzai
I have tried Cloggy's dll before, but when I down loaded this time was nice an easy, and looks like it might be a good one to have.


cheers.

Dark Physics makes any hot drink go cold.
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Mar 2008 14:32
Thanks HowDo, cool thing is I've got a new double click function, you never know what you might learn when you try to help.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 13th Mar 2008 14:35 Edited at: 13th Mar 2008 14:35
@Sasuke : I saw your post, but you said you couldn't fix his function, and I assumed that he still wanted to do that.

A common theme repeated daily here is that people don't understand how their code works when it does, and why it doesn't otherwise. They put a band-aid on it, and call DBPro broken. In the long run, you learn more by fixing the problem, not blaming the tool.

@HowDo - That is the problem. These progs are event driven, and that kind of coding is procedural. This is why menus and dialogs are modal in Windows for the most part. If the mouse clicking and its states are handled in the main loop, things would be easier to control, and act more consistently. (Also, you don't have to sit in a routine, not updating the screen.)
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Mar 2008 14:41
Yeah, I spent hour trying to figure out how that code came to be and couldn't understand why or how it got so confusing. In the end I just replaced it with mine, but looking back, it would be easy to sort out.
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 13th Mar 2008 14:48
Sasuke, your fresh look at it, sure solved the problem, if you could make it stand alone code, stick your function in code snippets then if anyone needs a right double click function they have one ready to go.

cheers.

Dark Physics makes any hot drink go cold.
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 13th Mar 2008 15:22
Great idea and it's in code snippets now.

Update:
Just remember that timer() doesn't return a float, so I changed all the timer based varibles to dwords.

The updated function, more accurate:
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 13th Mar 2008 21:48
Sasuke!!! The God of Menu! Thanks a ton man, your my hero for this. Your amazing at this stuff! Keep an eye on Tersculpt in program annoucements during the next week. Now that this menu code is done, I can finally implement it into Tersculpt and get some neat object placement stuff going. It's an open source gig, so I'm crediting everyone who helps out (and mistral, who designed the unlimited context menu I'm using). HowDo, that means you too. Your contributions did help to bring the problem out and expose it, sasuke did great on cleanup.

I can't tell you how frustrating and time consuming this menu has been the last week and a half. It feels so good to be done with this, what a pain.

I put in the update to the doubleclick function you made (the one you said it more accurate). I also added in what I think my menu layout will be like so you can see what I have in mind for the object placement commands for the Tersculpt editor.




The only annoying but with that is the arrows showing the sub menu's aren't aligned anymore. I'm over it though. I can save that bug for a rainy day lol.

With this menu system that mistral designed, you can have limitless sub menu's. Just add as many as you want during MenuSetup() and your good to go.

Thanks again for the help you guys, and like I said, keep an eye on Tersculpt during the next week as it will get some nice object placement updates.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 14th Mar 2008 07:27
Just so I don't have to make another thread about it...

Do any of you know of a problem with setting the display resolution and cloggy's dll working together? For some reason, when I set the display resolution when trying to use this menu, it won't work.

Ideas?

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-
HowDo
22
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 14th Mar 2008 11:08
display resolution becomes an awkward sod if not used at the very beginning, as once you change it every thing you had load needs to be re load if possible.

Had this problem when trying to make smoke, I load everything I needed first but because I change the screen resolution after I had loaded the image for the smoke all I got was blocks of color, not the image.

hope that helps, other options welcome.

Dark Physics makes any hot drink go cold.
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 14th Mar 2008 14:15 Edited at: 14th Mar 2008 14:19
Haha, during my playing with that menu, which I have to say is very similar to mine but simpler cause of D3Dfunc(I wish I had used it now) I noticed what your talking about with the arrows and edited it.

At line 342 change:


To:


Changing display resolution, hmm... nope, I can't think of anything.
Sid Sinister
20
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 14th Mar 2008 18:07
@HowDo: Hmm, I tried putting it as the very first thing and it still doesn't work. I'll have to add this bug to the running list of bugs for Tersculpt as it seems this might be more work than just moving a command lol. Either that or I'll open up a new thread at one point.

@Sasuke: Wow, I would have never looked there to fix that lol. You're good at finding a needle in a hair stack! Thanks man, that fixed it just fine =]

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
-Computer Animation Major @Baker.edu-

Login to post a reply

Server time is: 2025-08-08 17:40:52
Your offset time is: 2025-08-08 17:40:52