http://www.codeproje...ing-raphook-dll
This demo's opengl overlays in action.
In theory - button clicks on a 'button' are basically just button clicks within a region defined by x,y start positions and length and height to calculate a hit box.
That in mind - simple Win32 hooks could be used to apply functionality to any button clicks that occur in a particular region.
Eg:
Draw a button at
3,4
Which extends by 1,1 in both length and height.
When a User clicks : the Win32 hook fires
We evaluate the position of the click:
Was it within the 3,4 and 4,5 start and end positions?
If yes: Display the button depressed image (update the overlay code to display new graphic)
Return to normal display when mouse button is released.
Execute whatever functionality the button was meant to do
If no: do nothing
Using this methodology - a framework could in theory be created.
I am a .Net developer, so I envision everything in .Net code.
I am imagining some sort of friendly API along the lines of
GUIOverlay gui = new GUIOverlay("nwmain");
GUIButton ActivateAbilityX = new GUIButton();
ActivateAbilityX.DefaultImage = Resources.GetButtonImage();
ActivateAbilityX.DepressedImage = Resources.GetButtonPressedImage();
ActivateAbilityX.OnClick += new AbilityXExecute();
ActivateAbilityX.Position = new Point(3,4);
ActivateAbilityX.Height = 1.00;
ActivateAbilityX.Length = 2.00;
gui.AddButtonToGui(ActivateAbilityX);
The code above - if wrote appropriately, could be made in such a way that it registers the X,Y / length and height as a hitbox.
When a click is done in that region - it will execute the AbilityX Method.
The only tricky part is getting the Overlay to update in relation to the users clicking.
You would need to have a bridge between the Overlay hook in nwn / OpenGL, and the Win32 hooks.
The Overlay is effectively 'drawing' the GUI , including your static elements rapidly in a loop
You need to alert that Overlay loop that your custom content in the overlay has been updated.
Eg: Remove previous image, and update with the new image.
When the mouse click is released - go back to the default image.
I think if it were made in such a way that the Overlay code was constantly checking the 'state' of the GUIOverlay class for that process, and then the WIn32 hooks for mouse and keyboard just altered the content within that GUIOverlay class instance - then it would be a step closer to artifical gui element creation.