设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 84|回复: 0

[转载发布] 808PrintScreen MV

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Simple and light plugin for MV to let the user take screenshots from the game.
    This is a regular screenshot picture where everything on screen will be saved on the image. Different from OrangeMapShot that will only save the map.

    Assign your desired screenshot key in the parameters and decide if you want to see a notification on screen or not when the screenshot is saved.

    Screenshots will be saved in the screenshots folder at the root of the game directory. The folder will be created automatically.

    By default the plugin stops working and display a warning when there are 999 images in the screenshots folder.


    Name the file 808PrintScreen.js
    Spoiler: Code
                    JavaScript:       
    1. //==============================================================================
    2. //  808PrintScreen
    3. //==============================================================================
    4. // File: 808PrintScreen.js
    5. // v1.0
    6. // 7th Sep 2024
    7. //==============================================================================
    8. /*:
    9. * @plugindesc v1.0 Allows taking screenshots by pressing a specified key and saving them to the 'screenshots' folder. Optionally displays a notification on screen.
    10. * @author mugen808
    11. * @param Screenshot Key
    12. * @desc The key to press for taking a screenshot. Default: F7
    13. * @default F7
    14. * @param Screenshot Notification
    15. * @type boolean
    16. * @desc Whether to display a screenshot notification on screen. Default: true
    17. * @default true
    18. * @help
    19. *==============================================================================
    20. *  808PrintScreen
    21. *==============================================================================
    22. *
    23. * This plugin enables taking screenshots of the game by pressing a specified
    24. * key. Screenshots are saved in a 'screenshots' folder in the game directory.
    25. *
    26. * -Available keys:
    27. *   F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, A, B, C, D, E, F, G, H,
    28. *   I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6,
    29. *   7, 8, 9, Shift, Ctrl, Alt, Space, Enter, Escape, Left, Up, Right, Down,
    30. *   PrintScreen.
    31. *
    32. *
    33. * By default, a notification will be displayed on the screen when a screenshot
    34. * is taken. This can be deactivate in the plugin parameters.
    35. *
    36. * The screenshot will still be logged in the console regardless of the
    37. * notification setting.
    38. *
    39. * -Parameters:
    40. *   Screenshot Key: The key to press for taking a screenshot (default: F7).
    41. *
    42. *   Screenshot Notification: Whether to display a notification on the screen
    43. *   (default: true).
    44. *
    45. *
    46. *==============================================================================
    47. *  Terms
    48. *==============================================================================
    49. *
    50. * Free to use. Redistribution not permitted.
    51. *
    52. *..............................................................................
    53. */
    54. (function() {
    55.     const fs = require('fs');
    56.     const path = require('path');
    57.     const parameters = PluginManager.parameters('808PrintScreen');
    58.     const screenshotKey = parameters['Screenshot Key'] || 'F7';
    59.     const screenshotNotification = String(parameters['Screenshot Notification'] || 'false').toLowerCase() === 'true';
    60.     function getKeyCode(keyName) {
    61.         const keyCodes = {
    62.             'F1': 112, 'F2': 113, 'F3': 114, 'F4': 115, 'F5': 116, 'F6': 117, 'F7': 118, 'F8': 119, 'F9': 120, 'F10': 121, 'F11': 122, 'F12': 123,
    63.             'A': 65, 'B': 66, 'C': 67, 'D': 68, 'E': 69, 'F': 70, 'G': 71, 'H': 72, 'I': 73, 'J': 74, 'K': 75, 'L': 76, 'M': 77, 'N': 78, 'O': 79, 'P': 80, 'Q': 81, 'R': 82, 'S': 83, 'T': 84, 'U': 85, 'V': 86, 'W': 87, 'X': 88, 'Y': 89, 'Z': 90,
    64.             '0': 48, '1': 49, '2': 50, '3': 51, '4': 52, '5': 53, '6': 54, '7': 55, '8': 56, '9': 57,
    65.             'Shift': 16, 'Ctrl': 17, 'Alt': 18, 'Space': 32, 'Enter': 13, 'Escape': 27, 'Left': 37, 'Up': 38, 'Right': 39, 'Down': 40,
    66.             'PrintScreen': 44
    67.         };
    68.         return keyCodes[keyName] || null;
    69.     }
    70.     const keyCode = getKeyCode(screenshotKey);
    71.     if (keyCode === null) {
    72.         throw new Error(`Invalid key: ${screenshotKey}`);
    73.     }
    74.     Input.keyMapper[keyCode] = 'screenshot';
    75.     let screenshotQueue = [];
    76.     let screenshotTimeout = null;
    77.     function getNextFileName(dirPath) {
    78.         for (let i = 1; i <= 999; i++) { // limit of screenshot files in the folder
    79.             const fileName = `img${String(i).padStart(3, '0')}.png`;
    80.             const filePath = path.join(dirPath, fileName);
    81.             if (!fs.existsSync(filePath)) {
    82.                 return fileName;
    83.             }
    84.         }
    85.         return null;  // No available file names
    86.     }
    87.     function takeScreenshot() {
    88.         const dirPath = path.join(process.cwd(), 'screenshots');
    89.         if (!fs.existsSync(dirPath)) {
    90.             fs.mkdirSync(dirPath);
    91.         }
    92.         const fileName = getNextFileName(dirPath);
    93.         if (!fileName) {
    94.             console.error('Screenshot limit reached. Please delete some screenshots and try again.');
    95.             if (screenshotNotification) {
    96.                 displayScreenshotText('Screenshot limit reached. Please delete some screenshots and try again.');
    97.             }
    98.             return;
    99.         }
    100.         const filePath = path.join(dirPath, fileName);
    101.         const bitmap = Graphics._canvas.toDataURL('image/png').replace(/^data:image\/png;base64,/, "");
    102.         fs.writeFile(filePath, bitmap, 'base64', function(err) {
    103.             if (err) {
    104.                 console.error('Failed to save screenshot:', err);
    105.             } else {
    106.                 console.log('Screenshot saved as', fileName);
    107.                 if (screenshotNotification) {
    108.                     displayScreenshotText(fileName);
    109.                 }
    110.             }
    111.         });
    112.     }
    113.     function displayScreenshotText(message) {
    114.         const text = new PIXI.Text(`Screenshot ${message}`, { fontFamily: 'Arial', fontSize: 12, fill: 'white' });
    115.         text.x = Graphics.width - text.width - 10;
    116.         text.y = 10 + screenshotQueue.length * 20;
    117.         SceneManager._scene.addChild(text);
    118.         screenshotQueue.push(text);
    119.         setTimeout(() => {
    120.             SceneManager._scene.removeChild(text);
    121.             screenshotQueue.shift();
    122.             updateScreenshotQueue();
    123.         }, 2150);
    124.     }
    125.     function updateScreenshotQueue() {
    126.         screenshotQueue.forEach((text, index) => {
    127.             text.y = 10 + index * 20;
    128.         });
    129.     }
    130.     const alias_SceneManager_update = SceneManager.update;
    131.     SceneManager.update = function() {
    132.         alias_SceneManager_update.call(this);
    133.         if (Input.isTriggered('screenshot')) {
    134.             if (!screenshotTimeout) {
    135.                 takeScreenshot();
    136.                 screenshotTimeout = setTimeout(() => {
    137.                     screenshotTimeout = null;
    138.                 }, 200);
    139.             }
    140.         }
    141.     };
    142. })();
    复制代码







    本贴来自国际rpgmaker官方论坛作者:mugen808处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/808printscreen-mv.171735/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 02:33 , Processed in 0.084448 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表