Exemple #1
0
        public void renderPreview(Library.LevelData obj, double x, double y, BitmapData target)
        {
            BitmapData bitmapData = Level.getLevelBitmapData(obj.map, Level.ROOM_WIDTH, Level.ROOM_HEIGHT);
            var        p          = new Point(x, y);

            target.copyPixels(bitmapData, bitmapData.rect, p);
        }
Exemple #2
0
 public void writeSourceToTarget()
 {
     if (targetLevel == null)
     {
         targetLevel = LevelData.saveObject(Level.ROOM_WIDTH, Level.ROOM_HEIGHT);
     }
     confirmDialog(confirmWrite);
 }
Exemple #3
0
 public void deleteLevelDialog()
 {
     Library.levels[sourceId] = null;
     sourceLevel = null;
     if (Library.saveUserLevelsCallback != null)
     {
         Library.saveUserLevelsCallback();
     }
     UIManager.closeDialog();
 }
Exemple #4
0
 public void swapLevels()
 {
     if (targetLevel == null)
     {
         return;
     }
     Library.levels[sourceId] = (Library.LevelData)targetLevel;
     Library.levels[targetId] = (Library.LevelData)sourceLevel;
     sourceLevel = Library.levels[sourceId];
     targetLevel = Library.levels[targetId];
     sourceId   ^= targetId;
     targetId   ^= sourceId;
     sourceId   ^= targetId;
     if (Library.saveUserLevelsCallback != null)
     {
         Library.saveUserLevelsCallback();
     }
 }
Exemple #5
0
 private void levelPressed()
 {
     if (!game.editing)
     {
         int    n   = uiManager.lastButton.id + firstLevel;
         String str = (n < 10 ? "0" : "") + n;
         game.setNextGame(Room.PUZZLE, n);
         game.transition.begin(game.initLevel, Transition.DEFAULT_TRANSITION_TICKS, Transition.DEFAULT_TRANSITION_TICKS, str, 15);
     }
     else
     {
         buttonInHand = uiManager.lastButton;
         sourceId     = buttonInHand.id + firstLevel;
         sourceLevel  = Library.levels[sourceId];
         targetLevel  = null;
         prevButtonX  = uiManager.lastButton.x;
         prevButtonY  = uiManager.lastButton.y;
     }
 }
Exemple #6
0
 private void levelReleased()
 {
     if (buttonInHand != null)
     {
         buttonInHand.x = prevButtonX;
         buttonInHand.y = prevButtonY;
         int        i;
         BlitButton overButton;
         int        x = (int)(Game.WIDTH * 0.5 - renderer.levelMovePanelBlit.width * 0.5);
         int        y = (int)(Game.HEIGHT * 0.5 - renderer.levelMovePanelBlit.height * 0.5);
         for (i = 0; i < uiManager.buttonsOver.length; i++)
         {
             overButton = uiManager.buttonsOver[i];
             if (overButton != buttonInHand)
             {
                 if (overButton.targetId > 0)
                 {
                     int step = renderer.cancelButtonBlit.width + 1;
                     UIManager.openDialog(
                         new Array <Point> {
                         new Point(x, y),
                         new Point(x + 3, y + 3),
                         new Point(x + 3 + (step * 1), y + 3),
                         new Point(x + 3 + (step * 2), y + 3),
                         new Point(x + 3 + (step * 3), y + 3),
                         new Point(x + 3 + (step * 4), y + 3)
                     },
                         new Array <BlitRect> {
                         renderer.levelMovePanelBlit,
                         renderer.cancelButtonBlit,
                         renderer.insertBeforeButtonBlit,
                         renderer.insertAfterButtonBlit,
                         renderer.swapButtonBlit,
                         renderer.saveButtonBlit
                     },
                         new Array <Action> {
                         null,
                         UIManager.closeDialog,
                         insertBefore,
                         insertAfter,
                         swapLevels,
                         writeSourceToTarget
                     },
                         game.selectSound
                         );
                     // swap init
                     targetId                     = firstLevel + overButton.id;
                     targetLevel                  = Library.levels[targetId];
                     overButton.over              = false;
                     buttonInHand.over            = false;
                     buttonInHand                 = null;
                     uiManager.buttonsOver.length = 0;
                     return;
                 }
                 else
                 {
                     if (overButton == backButton)
                     {
                         confirmDialog(deleteLevelDialog);
                     }
                     else if (overButton == rightButton)
                     {
                         targetId = sourceId + PAGE_LEVELS;
                         insertAfter();
                     }
                     else if (overButton == leftButton)
                     {
                         targetId = sourceId - PAGE_LEVELS;
                         insertBefore();
                     }
                 }
             }
         }
         buttonInHand = null;
     }
     if (game.editing && uiManager.lastButton.heldCount > 0)
     {
         int    n   = uiManager.lastButton.id + firstLevel;
         String str = (n < 10 ? "0" : "") + n;
         game.setNextGame(Room.PUZZLE, n);
         game.transition.begin(game.initLevel, Transition.DEFAULT_TRANSITION_TICKS, Transition.DEFAULT_TRANSITION_TICKS, str, 30);
     }
 }