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.

Dark GDK / DGDK.net, implementing some kind of event handler

Author
Message
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 20th Jun 2007 15:12 Edited at: 19th Aug 2007 17:11
First off this is really any experiment, and may end up as nothing depending if it is feasible.

One of the things that normal .net projects have are events based on things like someone moving a mouse over a button, clicking a button etc.

Unfortunately due to the nature of DGDK, this doesn't "Exist" for things like mouse clicks etc. So one of my plans is to try and implement a DGDK.net event system. What this may well consist of is a thread that runs which monitors various things and raising events etc.

To start with I am only planning on doing mouse related things in 2d and to do this, there needs to be some kind of way of zoning off sections of the screen.

For this I will create a Zone Class

To start with this class only handles the mouse enter/leave events



I am trying to work out the best way to update the mouse coordinates in this object. One of my ideas is to create a "Mouse" object that is shared by all objects which raises a "MouseChanged" even causing all objects that use it to re-check if they are triggered by the new coordinates.

As you can see I am in early days of trying to think about this. Any advice etc is welcome.

Cheers,

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 20th Jun 2007 17:06 Edited at: 20th Jun 2007 18:17
This remembers me of the first days working on LightUI...
Although it was changed to Sprite Collision instead of Zones (as it is only working with sprites). Ok, but what you're doing seems correct to me so far, as it was proved working for me while doing some preliminary work on LightUI.

The problem will begin when working with 3D objects, and also what kind of events will you want implemented.
One of the problems is that DGDK.NET does not have classes to objects, so where will you add the events? (For me is not being a problem as LightEngine has them all as classes).

I was willing to do some investigating on this and other things like Design Time components (as was pointed by kenjar some time ago), but unfortunately I've struggling my time.

Anyway, I like what I see by far, and I hope to see more of it in the future. You can contact me if you want (email, msn, forums, irc: dgdk-net@jd.devhat.net). But it's good so far

Best regards,
Thiago
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 22nd Jun 2007 17:34
Sounds like something I can use
I will look on it and see what I can do with it

Niels Henriksen
Working on a (MMO)RPG right now in DarkEngine
http://www.tigernet.dk - Send SMS to mobile online (will come in english soon)
Red Ocktober
20
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 26th Jun 2007 15:23
hey guys... i did something very similar to what you're talking about with a similiar c api (3Impact), using MS Vis Studio c++ and also VB.net... so it should be just as simple implementing with the GDK and/or GDK.net...

look here... http://msdn2.microsoft.com/en-us/library/ee2k0a7d.aspx

it's very straight forward to implement... i hope this is of some help...

--Mike
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 19th Aug 2007 15:16 Edited at: 19th Aug 2007 16:33
As kbessa mentioned I've hit problems with the above as I want to create zones on the fly so I've decided to do this via another route.

I've created myself a MessageCenter class library (Well I created it for another project) So I thought I'd share.

The library is attached (Source) in a VS2008 beta 2. It consists of 3 main classes...

Firstly the message class (This will be passed between threads using the .net event system)



You should create a queue of type message for the main thread. And synclock access to the queue to avoid thread issues.

Finally the core PostOffice code which does the work of receiving and sending messages.



I will post an example of it begin used in a while (I'm going to try to do a Zone example so it may take some time )

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"

Attachments

Login to view attachments
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 20th Aug 2007 16:29
I've been heavily re-writing this over the weekend and have now come up with a dgdkComponent to define things like buttons etc.

To start I am creating an interface and a base class to make sure certain things are there in the component

dgdkInterface.vb


dgdkComponent.vb


Next I've created a Button class based on the dgdkComponent class and overriding the methods that are relevant to the button:

dgdkButton.vb


Also a text box (Note all these classes are currently empty of the main code as this is just to demonstrate the principle)

dgdkTextBox.vb


As you can see in the below code, because certain functions are always there, the Event Thread can declare all objects as the base component and call the relevant functions when needed.



Obviously this will get refined as I go through the process of implementing it.

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 21st Aug 2007 19:08
Guess what, It's changed again

The Event thread will pass through key presses and mouse activity from dgdk.net into the components, and these components will handle these events themselves. The base of all components are dgdkComponent and other components must inherit from them. An example of the button component is shown below:



The code inside the MouseAction function check to see if the mouse is inside or not inside the button and see if the mouse is pressed or not. If needed it will send an event back to the User Interface thread saying for example Button Clicked.

Using this I can make a menu component out of button components which contains a collection of components that it uses.

All the event thread has to do is pass the mouse information to the Menu component, and the menu component passes the mouse information onto the individual components that make the menu.

It may sound complicated and I'm not sure about the performance impact of this but I hope to have a working example of this in the near future.

Anyone with ideas to improve this are greatly appreciated.

Once I've got this into a state where its usable I'll post all the source so others can use it.

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 23rd Aug 2007 15:15
I'm about to overhaul how Tyrannt handles media and use the same methods as I'm using with components.

Kbessa, was this how you started out with your LightEngine?

As I'm gradually changing things to be more object orientated. A lot of the procedural code is ending up as methods of the different objects.

E.g. I'm going to have a base class for media and then classes that inherit from those for sounds, bitmaps, sprites, images and 3d objects.

All this stuff is going to take time to do, but at the end of it, it should be much easier to plug things together to make the engine work and a lot easier to understand the code.

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 23rd Aug 2007 18:38
Jasuk, that's something like LightEngine.

LightEngine is all about classes and some inheritance, so you could probably use it by inheriting its classes and adding new functionalities you want, or you can start from ground up.

I will not say you will be reinventing the wheel for building it up again, as you may build a optimized base for your engine, while LightEngine has it all (as it is all-purpose like DGDK.NET).

I'm really waiting to see what you will come up with, as there are few developers doing great progress with DGDK.NET posting on these forums recently. My best wishes for your project.

Thiago
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 23rd Aug 2007 18:55
Thanks kBessa,

It's actually great fun implementing all this, I've got the development bug back again. (I've been dragged into WoW for far too long )

You're right about the optimisation for my engine. I'm planning to only add methods that are relevant to what I need to do. And when I need something new, I'll add the method then.

Currently I've got loads of storage mechanisms for holding all the different media elements and loads of static functions like CreateImage etc. I can see a lot of work ahead but a lot less and more organised code structure.

Once I've implemented the media code and created the message box, I'll post a new demo so peeps can see it in action . It may not look impressive, but it will be much easier to code and design from that point onwards.

I've now switched over to Visual Studio 2008 beta 2 and that is another thing that's making this a lot easier to use. They have done a great job (Epically on the VB side) with 2008. And I'm still only creating a .net 2.0 app at the end of it .

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th Sep 2007 04:50
Quote: "I'm really waiting to see what you will come up with, as there are few developers doing great progress with DGDK.NET posting on these forums recently. My best wishes for your project.
"


Here Here! I am curious how this will turn out also!

(though I wish there a few more C++ GDK'ers out here with us like me )

Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 11th Sep 2007 11:33
Quote: "
(though I wish there a few more C++ GDK'ers out here with us like me )
"

They just saw the light and started in .NET

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine
http://noggs.netopcom.dk/forum/default.asp - Forum for the game
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th Sep 2007 14:44
I admit I've been tempted - but there is nothing like having the option to write code that is compiling to only a couple assembly lines versus going through a hundred of them because everything you do is a decendant of a decendant of etc.

I'm probably sick here - I know that - but I think the extra work here and there is worth the extra throughput or raw speed.

BTW - I chuckled when I saw your post Niels - that was awesome.

jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 23rd Sep 2007 01:37
I've been working on the Event/Component system. I've come up with two components a Message Box and a Button An example of creating the message box is:



The above code send the message box creation to the DGDK thread which will add it to it's list, and update the mouse informaton to this component. The message box component had a button sub component which gets updated automatically when the mouse information gets sent to the message box. But for those curious, here is a small sample of it working:

http://www.tyranntrpg.org/Runtime.zip

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 30th Sep 2007 03:59
I've now implemented the menu component.

You can download an example of it here http://www.tyranntrpg.org/Runtime2.zip

An example of what it looks like is shown below:



The code to create the menu is:



This then send the menu object to the dgdk thread which handles everything from there.

The code in the dgdk Thread just needs to do this:



And it will initially draw the component on the screen as all components derive from a base class tyComponent which implements an interface which has RefreshDisplay.

The loop that controls the components is:



ProcessEvents will just check to see if there has been any new events sent to the thread

This works as another thing that the component interface honours is .MouseAction(MouseX, MouseY, MouseButton)

So it doesn't need to know what the type of component it is, it just knows that all components can do RefreshDisplay and MouseAction. This is making for much less code

Next it's onto a text box which is going to be slightly harder, but another thing the interface honours is KeyPress(ByVal key As Char).

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 30th Sep 2007 15:32
jasuk70

That's looking rather good if you don't mind my saying. kBessa was working on a UI plugin also, so maybe some nice visual ideas can be developed here.

Paul.

jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 8th Oct 2007 22:44
I've now managed to get the TextBox to work. This one took a bit longer. I spent most the time looking for a reliable way to input text and came up with the following solution.

I used the following routine to create a valid text hashtable as a look up place for valid key presses:



And a small routine to validate the keys pressed.



The main component routine now has the key information added to it. It uses the Entry function to read the keyboard, but unfortunatly it doesn't recognise the return key so I have used the ReturnKey function to work out if the return has been pressed.



The TextBox uses the following to process the key presses.



If you want to try it out then download this http://www.tyranntrpg.org/Runtime3.zip

You need to click in the box to be able to type.

And below shows it in action:



Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
RPDan
17
Years of Service
User Offline
Joined: 29th Apr 2007
Location:
Posted: 8th Oct 2007 22:51
I tried something like an event handler this last night. Basically I created a new thread to check for double clicks, and this accessed a pointer to a bollean that could then be used by the rest of the program for double clicks. But this is not a true event handler. Tomorrow I will probably try the same thing, but rather than it changing a boolean will make it start a function. That way, all the user will have to do is decide the function and the points in code they want it to be accessible or not. This could then to be rewritten to check for mousex(), mousey() and button clicks etc.

Login to post a reply

Server time is: 2024-11-16 20:06:12
Your offset time is: 2024-11-16 20:06:12