Skip to content

Commit

Permalink
setup menu bar
Browse files Browse the repository at this point in the history
  • Loading branch information
fengshuo2004 committed May 5, 2020
1 parent c67ad45 commit 9d29e94
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 13 deletions.
13 changes: 6 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,34 @@

<!-- This HTML file is truly ugly. -->

<h1>Scratch 3 项目转换器 <span style="float: right;"><object data="Scratchcat2.svg" type="image/svg+xml"></object></span></h1>
<h1>Scratch 3 项目转换器 <span style="float: right;"><object data="resources/Scratchcat2.svg" type="image/svg+xml"></object></span></h1>
<h3><em>将一个Scratch项目转换为HTML文件</em></h3>
<p>本程序可将您的Scratch项目打包成一个能在浏览器里独立运行的HTML文件。</p>
<p>生成的HTML文件会比较大,因为这个文件包含了整个Scratch引擎和项目里的造型和声音素材。</p>
<p>转换完的项目会自动运行,所以没有绿旗和停止按钮。</p>
<p>云变量会保存在<u title="您在Scratch以外使用cookie还是得遵守隐私法律!">电脑本地</u>且允许存储字符串值,方便用来保存游戏数据。</p>
<p><label class="container"><input type="radio" name="upload-mode" value="id" checked><span class="checkmark"></span> 项目ID: <input type="number" placeholder="项目ID" value="284516654" id="id"> (Scratch官网上项目网址最后面的一串数字)</label></p>
<p><label class="container"><input type="radio" name="upload-mode" value="file"><span class="checkmark"></span> 上传项目(sb3)文件: <input type="file" id="file" accept=".sb,.sb2,.sb3"></label></p>
<fieldset>
<legend>选项</legend>
<fieldset style="border: 1px solid white; border-radius: 6px">
<legend>&nbsp;&nbsp;选项&nbsp;&nbsp;</legend>
<p><label for="title">项目名称: </label><input type="text" placeholder="项目名称" value="Zombie Cube Escape!" id="title"> (浏览器窗口标题)</p>
<p><label for="username">用户名的取值: </label><input type="text" placeholder="用户名" value="griffpatch" id="username"> (“用户名”积木块的返回值)</p>
<table style="border:none">
<tr>
<td style="padding-right: 8px;"><label class="switch"><input type="checkbox" id="compatibility" checked><span class="slider"></span></label> 启用<u title="像Scratch 2.0版一样强制将项目限速在30FPS以下">兼容模式</u></td>
<td class="seperate"><label class="switch"><input type="checkbox" id="turbo"><span class="slider"></span></label> 启用<a href="https://en.scratch-wiki.info/wiki/Turbo_Mode">加速模式</a></td>
<td style="padding-right: 8px;"><label class="switch"><input type="checkbox" id="compatibility" checked><span class="slider"></span></label> 启用<u title="像Scratch 2.0一样强制将项目限速在30FPS以下">兼容模式</u></td>
<td class="seperate"><label class="switch"><input type="checkbox" id="turbo"><span class="slider"></span></label> 启用<a href="https://en.scratch-wiki.info/wiki/Turbo_Mode" target="_blank">加速模式</a></td>
<td class="seperate"><label class="switch"><input type="checkbox" id="progress" checked><span class="slider"></span></label> 显示加载进度条</td>
<td class="seperate"><label class="switch"><input type="checkbox" id="fullscreen" checked><span class="slider"></span></label> 显示全屏按钮</td>
</tr>
</table>
<p><label class="switch"><input type="checkbox" id="use-colour"><span class="slider"></span></label> 自定义变量、链表监视器颜色: <input type="color" id="monitor-colour" value="#ff8c1a"> (如果不选,将默认使用半透明黑色。)</p>
<p><label class="switch"><input type="checkbox" id="wider"><span class="slider"></span></label> 本项目使用<a href="https://sheeptester.github.io/scratch-gui/16-9/">16比9宽屏模式</a></label></p>
<p><label class="switch"><input type="checkbox" id="wider"><span class="slider"></span></label> 本项目使用<a href="https://sheeptester.github.io/scratch-gui/?width=640&height=360" target="_blank">16比9宽屏模式</a></label></p>
</fieldset>
<p>
<button id="load-no-minify">转换▶</button>
</p>
<textarea id="error" rows="8" cols="80" placeholder="状态输出" readonly></textarea>

<p>原作者为 <a href="https://scratch.mit.edu/users/Sheep_maker/">Sheep_maker</a> 本程序使用了 <a href="https://github.com/LLK/scratch-vm/">scratch-vm</a>, <a href="http://danml.com/download.html">download.js</a> 及它们的依赖。 MIT开源许可</p>
<script type="text/javascript">
function removePercentSection(str, key) {
/*
Expand Down
96 changes: 90 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,103 @@
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const _app = electron.app;
const _BrowserWindow = electron.BrowserWindow;
const _Menu = electron.Menu;

// 保持一个对于 window 对象的全局引用,不然,当 JavaScript 被 GC,
// window 会被自动地关闭
var mainWindow = null;

// ========== Menu Bar ==========
const template = [
{
label: "视图",
submenu: [
{
label: "放大",
accelerator: "CmdOrCtrl+=",
role: "zoomin"
},
{
label: "缩小",
accelerator: "CmdOrCtrl+-",
role: "zoomout"
},
{
label: "重置缩放级别",
accelerator: "CmdOrCtrl+0",
role: "resetzoom"
}
]
},
{
label: "关于",
submenu: [
{
label: "原作者SheepTester...",
click(){
electron.shell.openExternal("https://sheeptester.github.io/");
}
},
{
label: "Scratch虚拟机...",
click(){
electron.shell.openExternal("https://github.com/LLK/scratch-vm/");
}
},
{
label: "DownloadJS...",
click() {
electron.shell.openExternal("http://danml.com/download.html");
}
},
{
label: "Electron...",
click() {
electron.shell.openExternal("https://www.electronjs.org/");
}
},
{
label: "MIT开源软件许可证...",
click() {
electron.shell.openItem('LICENSE');
}
}
]
}
]

if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{
label: '退出',
accelerator: 'CmdOrCtrl+Q',
click() {
app.quit();
}
}
]
});
}


// 当所有窗口被关闭了,退出。
app.on('window-all-closed', function () {
_app.on('window-all-closed', function () {
// 在 OS X 上,通常用户在明确地按下 Cmd + Q 之前
// 应用会保持活动状态
if (process.platform != 'darwin') {
app.quit();
_app.quit();
}
});

// 当 Electron 完成了初始化并且准备创建浏览器窗口的时候
// 这个方法就被调用
app.on('ready', function () {
_app.on('ready', function () {
const appMenu = _Menu.buildFromTemplate(template);
_Menu.setApplicationMenu(appMenu);
// 创建浏览器窗口。
mainWindow = new BrowserWindow({ width: 750, height: 920 , icon:"resources/icon.png"});
mainWindow = new _BrowserWindow({ width: 750, height: 890 , icon:"resources/icon.png"});

// 加载应用的 index.html
mainWindow.loadURL('file://' + __dirname + '/index.html');
Expand All @@ -31,4 +109,10 @@ app.on('ready', function () {
// 但这次不是。
mainWindow = null;
});

// Links open in your default browser
mainWindow.webContents.on('new-window', function (e, url) {
e.preventDefault();
electron.shell.openExternal(url);
});
});

0 comments on commit 9d29e94

Please sign in to comment.