Permalink
Browse files

Editor overrides items under cursor instead of blocking placement.

  • Loading branch information...
1 parent 78c7504 commit 06b11017bbcb8664244bb22712ea8d75d25f2427 @DusteDdk committed Jun 5, 2012
Showing with 48 additions and 40 deletions.
  1. +46 −40 leveleditor.c
  2. +2 −0 menu.c
View
86 leveleditor.c
@@ -86,6 +86,22 @@ void editorFileName(const char* fn)
strcpy(fileName,fn);
}
+void editorRemoveBrickUnderCursor()
+{
+ if(pf.board[cur.x][cur.y])
+ {
+ free(pf.board[cur.x][cur.y]);
+ pf.board[cur.x][cur.y]=0;
+ changed=1;
+ }
+
+ //teleport?
+ teleRemoveFromList(pf.levelInfo->teleList,cur.x,cur.y);
+
+ boardSetWalls(&pf);
+}
+
+
int runEditor(SDL_Surface* screen)
{
@@ -140,53 +156,43 @@ int runEditor(SDL_Surface* screen)
if(getButton(C_BTNX))
{
- resetBtn(C_BTNX);
- if(!pf.board[cur.x][cur.y])
+ resetBtn(C_BTNX);
+
+ //If it's empty and we are not placing a teledestination, remove brick at cursor
+ if(pf.board[cur.x][cur.y] && !(selBrick==TELESRC && teleState!=0) )
+ {
+ editorRemoveBrickUnderCursor();
+ }
+
+ if(selBrick==TELESRC)
{
- if(selBrick==TELESRC)
+ if(teleState==0)
{
- if(teleState==0)
- {
- //Save source pos
- teleSrcPos[0] = cur.x;
- teleSrcPos[1] = cur.y;
- teleState++;
- } else {
- //Add to list
- teleAddToList( pf.levelInfo->teleList, teleSrcPos[0], teleSrcPos[1], cur.x, cur.y );
- //Reset state
- teleState=0;
- }
+ //Save source pos
+ teleSrcPos[0] = cur.x;
+ teleSrcPos[1] = cur.y;
+ teleState++;
} else {
- pf.board[cur.x][cur.y]=malloc(sizeof(brickType));
+ //Add to list
+ teleAddToList( pf.levelInfo->teleList, teleSrcPos[0], teleSrcPos[1], cur.x, cur.y );
+ //Reset state
+ teleState=0;
+ }
+ } else {
+ pf.board[cur.x][cur.y]=malloc(sizeof(brickType));
- pf.board[cur.x][cur.y]->type=selBrick;
- if(selBrick==STDWALL || selBrick==GLUE || selBrick==ONEWAYLEFT || selBrick==ONEWAYRIGHT)
- {
- boardSetWalls(&pf);
- }
- pf.board[cur.x][cur.y]->pxx=cur.x*20+boardOffsetX;
- pf.board[cur.x][cur.y]->pxy=cur.y*20+boardOffsetY;
- } //Not a teleport
- } //Empty brick
- changed=1;
- }
+ pf.board[cur.x][cur.y]->type=selBrick;
+ boardSetWalls(&pf);
+ pf.board[cur.x][cur.y]->pxx=cur.x*20+boardOffsetX;
+ pf.board[cur.x][cur.y]->pxy=cur.y*20+boardOffsetY;
+ } //Not a teleport
+ changed=1;
+ }
if(getButton(C_BTNY))
{
- resetBtn(C_BTNY);
- if(pf.board[cur.x][cur.y])
- {
- free(pf.board[cur.x][cur.y]);
- pf.board[cur.x][cur.y]=0;
- changed=1;
- }
-
- //teleport?
- teleRemoveFromList(pf.levelInfo->teleList,cur.x,cur.y);
-
- boardSetWalls(&pf);
-
+ resetBtn(C_BTNY);
+ editorRemoveBrickUnderCursor();
}
if(getButton(C_BTNSELECT))
View
2 menu.c
@@ -842,6 +842,8 @@ int runMenu(SDL_Surface* screen)
case menuStateUserLevels:
starField(screen, 1);
fireWorks(screen);
+ resetMouseBtn();
+
txtWave(screen, FONTMEDIUM, STR_MENU_LVLEDIT_HEADLINE, HSCREENW, HSCREENH-105, &rot);
menuMaxY=getNumUserLevels()+1;

0 comments on commit 06b1101

Please sign in to comment.