#pragma name "Level Only" #pragma description "Hides all players and HUD elements for cleaner screenshots. Hold left mouse button to move camera. F11 to take thumbnail screenshot. F8 to take thumbnail video." //If your game crashes, you ran out of memory; try making one or both of these two numbers bigger: const uint framerateDivisor = 1 << 3; //must be a power of two const uint resolutionDivisor = 5; //Defaults to the thumbnail size used by level-voting mutators const uint thumbnailWidth = 200; const uint thumbnailHeight = 150; bool WasPressingF11 = false; enum GIFState { None, AskYesNo, Recording, Done = Recording + 1024 / framerateDivisor } int CurrentGifState = GIFState::None; string GifFilename; jjANIMATION@ GifAnimation; bool onDrawScore(jjPLAYER@, jjCANVAS@) { return true; } bool onDrawHealth(jjPLAYER@, jjCANVAS@) { return true; } bool onDrawLives(jjPLAYER@, jjCANVAS@) { return true; } bool onDrawGameModeHUD(jjPLAYER@, jjCANVAS@) { return true; } void onPlayerDraw(jjPLAYERDRAW& draw) { draw.sprite = false; draw.airboardPuff = false; draw.flag = TEAM::NEUTRAL; draw.gunFlash = false; draw.invincibility = false; draw.lightType = LIGHT::NONE; draw.morphingExplosions = false; draw.name = false; draw.shield[SHIELD::FIRE] = false; draw.shield[SHIELD::WATER] = false; draw.shield[SHIELD::PLASMA] = false; draw.shield[SHIELD::LASER] = false; draw.sugarRush = false; draw.trail = false; draw.player.idle = 0; } void HideChat() { for (uint i = 0; i < 8; ++i) jjAlert(""); } void onPlayer(jjPLAYER@ play) { if (CurrentGifState >= GIFState::Recording) { play.cameraFreeze( (jjLayerWidth[4] * 32 + jjSin(CurrentGifState * framerateDivisor) * (jjLayerWidth[4] * 32 - jjSubscreenWidth)) / 2, (jjLayerHeight[4] * 32 + jjCos(CurrentGifState * framerateDivisor) * (jjLayerHeight[4] * 32 - jjSubscreenHeight)) / 2, true,true ); } else if (jjKey[1]) { play.cameraFreeze( jjMouseX * (jjLayerWidth[4] * 32 - jjSubscreenWidth) / jjSubscreenWidth + jjSubscreenWidth / 2, jjMouseY * (jjLayerHeight[4] * 32 - jjSubscreenHeight) / jjSubscreenHeight + jjSubscreenHeight / 2, true,true ); } else play.cameraUnfreeze(true); } void onMain() { switch (CurrentGifState) { case GIFState::None: if (jjKey[0x7A]) { if (!WasPressingF11 && jjTakeScreenshot("levelonlymut")) { jjAddObject(0,-1000,-1000, 0,CREATOR::OBJECT, behavior: function(obj) { if (obj.state == STATE::START) { //wait one gametick for *usrWantScreenshot to be processed obj.state = STATE::DELAYEDSTART; HideChat(); } else { HideChat(); string thumbFilename; jjCOLORMAP("Jazz2_as-levelonlymut.png", threshold:0).resize(thumbnailWidth,thumbnailHeight).save(thumbFilename = ("thumb-" + jjLevelFileName.substr(0,jjLevelFileName.length - 4) + ".png")); jjAlert("Screenshot saved with filename " + thumbFilename); obj.delete(); } }); } WasPressingF11 = true; } else { WasPressingF11 = false; if (jjKey[0x77]) CurrentGifState = GIFState::AskYesNo; } break; case GIFState::AskYesNo: if (jjKey['Y'[0]]) { CurrentGifState = GIFState::Recording; uint customSetID = 0; while (jjAnimSets[ANIM::CUSTOM[customSetID]] != 0) customSetID += 1; @GifAnimation = jjAnimations[jjAnimSets[ANIM::CUSTOM[customSetID]].allocate(array={1024 / framerateDivisor})]; } else if (jjKey['N'[0]]) { CurrentGifState = GIFState::None; } break; case GIFState::Done: if (jjKey[0xD]) //enter CurrentGifState = GIFState::None; break; default: //recording if (jjTakeScreenshot("levelonlymut")) { jjAddObject(0,-1000,-1000, 0,CREATOR::OBJECT, behavior: function(obj) { if (obj.state == STATE::START) { //wait one gametick for *usrWantScreenshot to be processed obj.state = STATE::DELAYEDSTART; HideChat(); } else { HideChat(); jjPIXELMAP(jjCOLORMAP("Jazz2_as-levelonlymut.png", threshold:0)).resize(jjResolutionWidth/resolutionDivisor, jjResolutionHeight/resolutionDivisor).save(jjAnimFrames[GifAnimation + CurrentGifState - GIFState::Recording]); if (++CurrentGifState == GIFState::Done) { GifAnimation.fps = 1500 / GifAnimation.frameCount; GifAnimation.save(GifFilename = ("preview-" + jjLevelFileName.substr(0,jjLevelFileName.length - 4) + ".gif")); } obj.delete(); } }); } break; } } bool onDrawAmmo(jjPLAYER@, jjCANVAS@ canvas) { if (CurrentGifState == GIFState::AskYesNo || CurrentGifState == GIFState::Done) { canvas.drawRectangle(0,0, jjSubscreenWidth, jjSubscreenHeight, 0); array strings; if (CurrentGifState == GIFState::AskYesNo) { strings = {"Record preview video?", "(Takes ~2 minutes)", "Press \\1Y\\6 or \\2N"}; } else { strings = {"Video saved as", GifFilename, "Press |Enter"}; } const int yDiff = jjSubscreenHeight / 8; int yPos = jjSubscreenHeight / 2 - yDiff; for (uint i = 0; i < 3; ++i, yPos += yDiff) canvas.drawString(0x8000, yPos, strings[i], STRING::MEDIUM); } return true; }