Permalink
Browse files

Tweaked mouse-brick-behaviour in leveleditor.

  • Loading branch information...
1 parent d473b85 commit 5fc258f3aa5eeef78d9d482301351571074baa34 @DusteDdk committed Jun 7, 2012
Showing with 34 additions and 20 deletions.
  1. +21 −12 leveleditor.c
  2. +13 −8 pointer.c
View
@@ -117,20 +117,22 @@ void editorRemoveBrickUnderCursor()
int runEditor(SDL_Surface* screen)
{
- //We detect if the "preview" brick on the left is clicked, we do this now so we can reset the click so that it does not hit the board
SDL_Rect selBrickRect;
- selBrickRect.x = HSCREENW-125;
- selBrickRect.y = HSCREENH-85;
- selBrickRect.w = selBrickRect.x+20;
- selBrickRect.h = selBrickRect.y+20;
- if( isBoxClicked(&selBrickRect) && teleState==0 )
- {
- editorState=EDITOR_BRICKS_SELECTION;
- resetMouseBtn();
- }
if( editorState == EDITOR_MAIN )
{
+ //We detect if the "preview" brick on the left is clicked, we do this now so we can reset the click so that it does not hit the board
+ selBrickRect.x = HSCREENW-125;
+ selBrickRect.y = HSCREENH-85;
+ selBrickRect.w = selBrickRect.x+20;
+ selBrickRect.h = selBrickRect.y+20;
+ //Also, we can only click it if a teleport destination is not being placed.
+ if( isBoxClicked(&selBrickRect) && teleState==0 )
+ {
+ editorState=EDITOR_BRICKS_SELECTION;
+ resetMouseBtn();
+ }
+
//Handle movement
if(getButton(C_UP))
{
@@ -381,10 +383,17 @@ int runEditor(SDL_Surface* screen)
selBrickRect.w = selBrickRect.x+20;
selBrickRect.h = selBrickRect.y+20;
- if( isBoxClicked(&selBrickRect) )
+
+ //We set bricks on mouseover, this way we get the description too (maybe punch a hole in the dots where the text is?)
+ if( isPointerInBox(&selBrickRect) )
{
- resetMouseBtn();
selBrick=bnum;
+ }
+
+ //We continue back to the main editor
+ if( isPointerClicked() )
+ {
+ resetMouseBtn();
editorState=EDITOR_MAIN;
}
View
@@ -40,7 +40,7 @@ void initPointer(SDL_Surface* screen)
ptrBackRect.x=0;
ptrBackRect.y=0;
ptrBackRect.w=ptrBackImg->w;
- ptrBackRect.h=ptrBackImg->h;
+ ptrBackRect.h=ptrBackImg->h;
memset( &inpPointer, 0, sizeof(inpPointerState_t) );
inpPointer.timeSinceMoved=POINTER_SHOW_TIMEOUT;
@@ -84,17 +84,22 @@ int_fast8_t isPointerClicked()
return(0);
}
+int_fast8_t isPointerInBox( SDL_Rect& r )
+{
+ if( r->x < inpPointer.vpX && r->w > inpPointer.vpX && r->y < inpPointer.vpY && r->h > inpPointer.vpY )
+ {
+ inpPointer.isDown=0;
+ inpPointer.downTime=1;
+ inpPointer.hitABox=1;
+ return(1);
+ }
+}
+
int_fast8_t isBoxClicked( SDL_Rect* r )
{
if( isPointerClicked() )
{
- if( r->x < inpPointer.vpX && r->w > inpPointer.vpX && r->y < inpPointer.vpY && r->h > inpPointer.vpY )
- {
- inpPointer.isDown=0;
- inpPointer.downTime=1;
- inpPointer.hitABox=1;
- return(1);
- }
+ return( isPointerInBox(r));
}
return(0);
}

0 comments on commit 5fc258f

Please sign in to comment.