About Store Forum Documentation Contact

Post Reply 
Pop & Lock GUI Movement
Author Message
TBJokers Offline

Post: #1
Pop & Lock GUI Movement
Title might be misleading as I do not know of an official name of the system.

user interfaces in Esenthel can easily be moved outside of the screen rectangle, can also be lost this way. A lot of games out there has a pop || lock and some also has them both activated.

Pop GUI Movement
A User Interface can be moved outside of the screen rectangle.
A User Interface will be moved back into screen rectangle once movement button is released. *IF the User Interface is moved outside*

Lock GUI Movement
Treat the screen rectangle as walls for the user interfaces.
A User Interface may and should never reach outside of the screen rectangle.

This I have accomplished by extending the Window class. But I believe these should be implemented and be used by flags set by the user. I.e (GUI_MS_LOCK & GUI_MS_POP)

    Vec2 right, left; right = screenRect().rd(); left = screenRect().lu();
Pop GUI Movement
        float newPositionX, newPositionY;
        //Check if the area is outside of the screen.
        newPositionX = (left.x < -D.w()) ? -D.w() : (right.x > D.w()) ? D.w() : pos().x;
        newPositionY = (left.y >  D.h()) ?  D.h() : (right.y <-D.h()) ?-D.h() : pos().y;

        //Add size to co-ordinates
        if(newPositionX != pos().x && newPositionX > 0)newPositionX -= screenRect().w();
        if(newPositionY != pos().y && newPositionY < 0)newPositionY += screenRect().h();

        //Set position back into screen

Lock GUI Movement
    if(Gui.msLit() ==& T && Ms.dragging()){
        unsigned int x, y;
        //Check if at a corner       -1 = No negative delta movement... 1 = No positive delta movement
        x = (left.x <= -D.w()) ? -1 : (right.x >=  D.w()) ?  1 : 0;
        y = (left.y >=  D.h()) ?  1 : (right.y <= -D.h()) ? -1 : 0;

        Vec2 moveDelta = Ms.dc();
        //Set delta to 0 according to movement flags x & y
        if(moveDelta.x < 0){
            if(x == -1) moveDelta.x = 0;
            if(x ==  1) moveDelta.x = 0;
        if(moveDelta.y < 0){
            if(y == -1) moveDelta.y = 0;
            if(y ==  1) moveDelta.y = 0;

        //Move window

Small feature does not take long to implement, yet pretty nice. Just putting the idea out there..

Best regards TBJokers.
(This post was last modified: 01-14-2014 01:32 PM by TBJokers.)
01-14-2014 01:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ozmodian Offline

Post: #2
RE: Pop & Lock GUI Movement
That is great TB, thanks as always for sharing.
01-14-2014 06:08 PM
Find all posts by this user Quote this message in a reply
Post Reply