Page 2 of 5
Posted: Wed Jul 30, 2008 2:33 pm
by untune
Hey Fluid Byte
Thanks for that, it's really cool... removing the Z element is cool because then it's easier to keep track of the render order simply by the position in the list, cuts out unnecessary info making things more complicated
I'm going to start thinking about how to encapsulate all this in functions... hopefully this will eventually be able to just slot into any other game project with ease
Cheers
Posted: Wed Jul 30, 2008 3:22 pm
by untune
Fluid Byte, sorry to bother you again
When you return the GUI_LASTID from the create window procedure, is this returning a pointer to the relevant window structure or to the element in the linked list?
Thanks
Posted: Wed Jul 30, 2008 4:52 pm
by Fluid Byte
untune wrote:Fluid Byte, sorry to bother you again
I do this for fun so you're welcome!
untune wrote:When you return the GUI_LASTID from the create window procedure, is this returning a pointer to the relevant window structure or to the element in the linked list?
It's the address of the element in the linked list. But you could use CopyMemory() for example (like I do) and recieve the data of the structure to a variable of that type (e.g. poop.GUI_WINDOW). The only difference is the addtional data in memory of the element wich stores the address to the next and previous element.
This demo shows how an element is constructed (from the manual):
Code: Select all
Structure Element
*Next.Element ; Pointer to next element in list or zero if at last element
*Previous.Element ; Pointer to previous element in list or zero if at first element
; The users data type which the list was created with will follow
; those two variables (which means the user data can be found at
; the address of the new element + 8
EndStructure
Posted: Wed Jul 30, 2008 9:06 pm
by untune
Fluid Byte
At long last after much messing and chopping and changing, I've managed to incorporate your codeinto my own functions and now I can select each panel properly...
A thousand thankyous..... "You are my master and i have your slave"
Hahaha, thanks mate
Posted: Wed Jul 30, 2008 9:21 pm
by Fluid Byte
Hehehe
Enjoy!

Posted: Mon Aug 04, 2008 1:56 pm
by untune
Hey all
Does anybody have any ideas on this - I'm just rewriting my input checking code and I want to be able to hold a mousebutton etc for the sake of dragging panels etc
So basically I've got a select statement that checks if a mousebutton is down, if it is, then it sets GUI_MOUSE_LBUTTON to #TRUE. If the button is up, it sets it to #FALSE.
Now obviously that's great for checking if it's being held but in a lot of cases I only want something to happen ONCE when a button is clicked, otherwise some things would loop for ages.
Does anybody know what I can do to make something happen once when a button is pressed?
Cheers
Posted: Mon Aug 04, 2008 2:03 pm
by untune
Jumped the gun a bit with this one, fixed it
Of course, any ideas are still appreciated

Posted: Mon Aug 04, 2008 2:25 pm
by Kaeru Gaman
something like buffering the previous value:
Code: Select all
GUI_MOUSE_LBUTTON_OLD = GUI_MOUSE_LBUTTON
GUI_MOUSE_LBUTTON = MouseButton(#PB_MouseButton_Left)
If GUI_MOUSE_LBUTTON = #True And GUI_MOUSE_LBUTTON_OLD = #False
; Click Action
EndIf
If GUI_MOUSE_LBUTTON = #True And GUI_MOUSE_LBUTTON_OLD = #True
; Drag Action
EndIf
If GUI_MOUSE_LBUTTON = #False And GUI_MOUSE_LBUTTON_OLD = #True
; Drop Action
EndIf
Posted: Tue Aug 05, 2008 1:23 pm
by untune
Cheers for that Kaeru, that's more or less what I implemented and it seems to work fine
Feast your peepers on the image below, I've not really experimented with strings before so I'm hoping someone can point me in the right direction - take a look at the title bar for the orange panel. It stretches out of it's boundary, but what I want is to dynamically adjust it so that it fits, for example, so it would read "PANEL #6: G..." or something like that.
Obviously this requires some measuring of the string to get it's pixel size and I'm not too sure what the best way to go about it is. Any ideas?
Thanks
Posted: Tue Aug 05, 2008 1:56 pm
by Kaeru Gaman
PB has implemented DDraw functions TextWidth and TextHeight.
a DDraw channel has to be open and the font in question has to be active.
Posted: Tue Aug 05, 2008 2:18 pm
by untune
Kaeru Gaman wrote:PB has implemented DDraw functions TextWidth and TextHeight.
a DDraw channel has to be open and the font in question has to be active.
Hehe, the only problem is that I'm using HGE to render and I'm not using PB's built in commands to do any drawing or input as of yet. This may change at some point but I'm keeping it all HGE for now, so I'm looking for theory behind it
Thanks for the suggestion though!

Posted: Tue Aug 05, 2008 2:27 pm
by Fluid Byte
It's possible to retrieve the text width with HGE too:
http://hge.relishgames.com/doc/html/hge ... width.html
Posted: Tue Aug 05, 2008 2:44 pm
by untune
Hehe I've not long since found that myself FB, cheers

I might put this particular problem on hold for the time being and concentrate on getting buttons etc all working... I think the next step is to figure out how to drag those panels around

Posted: Tue Aug 05, 2008 3:10 pm
by Fluid Byte
I will try to update my example to supoort window dragging ASAP!
Here's a little demo code showing how you could handle the string thingy:
Code: Select all
LoadFont(0,"System",10)
OpenWindow(0,0,0,320,240,"RESIZE ME!!",#WS_OVERLAPPEDWINDOW | 1)
SetWindowColor(0,#White)
Title$ = "Lorem ipsum dolor sit amet vater equat quad esperat."
tmpString$ = Title$
Length = Len(Title$)
Repeat
EventID = WaitWindowEvent()
StartDrawing(WindowOutput(0))
DrawingFont(FontID(0))
If TextWidth(Title$) > WindowWidth(0)
For c=0 To Length-1
Result$ = Left(Title$,Length - c)
If TextWidth(Result$) < WindowWidth(0)
tmpString$ = Left(Result$,Len(Result$) - 2) + "..." : Break
EndIf
Next
Else
tmpString$ = Title$
EndIf
Box(0,50,WindowWidth(0),25,#White)
DrawText(0,55,tmpString$,0)
Line(0,50,WindowWidth(0),0)
Line(0,75,WindowWidth(0),0)
StopDrawing()
Until EventID = #WM_CLOSE
It's using windows and it's ugly but is demonstrates the basic method and should be easily adaptable to use in HGE.
Posted: Tue Aug 05, 2008 3:12 pm
by untune
Haha, you're always one step ahead FB, what would I do without you
Cheers for that, I'll have a look at it now
