Skip to content

Commit

Permalink
v0.11.3
Browse files Browse the repository at this point in the history
- you can now drag files into bridge. to open them
- you can now properly open files with bridge
- fixed plugin installation
- spawn_entity + rideable is now a warning instead of an error
- button to toggle chrome dev tools in production
  • Loading branch information
solvedDev committed Apr 5, 2019
1 parent d33f891 commit f917136
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 31 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bridge",
"productName": "bridge.",
"version": "0.11.2",
"version": "0.11.3",
"author": "solvedDev <[email protected]>",
"description": "A powerful add-on editor",
"license": null,
Expand All @@ -19,7 +19,7 @@
"postinstall": ""
},
"build": {
"productName": "bridge",
"productName": "bridge.",
"appId": "solved.editor.bridge",
"directories": {
"output": "build"
Expand Down
4 changes: 2 additions & 2 deletions src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<% if (htmlWebpackPlugin.options.nodeModules) { %>
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
<script>
require('module').globalPaths.push('<%= htmlWebpackPlugin.options.nodeModules.replace(/\\/g, '\\\\') %>')
require("module").globalPaths.push("<%= htmlWebpackPlugin.options.nodeModules.replace(/\\/g, '\\\\') %>")
</script>
<% } %>
</head>
<body>
<div id="app"></div>
<!-- Set `__static` path to static files in production -->
<script>
if(process.env.NODE_ENV !== "development") window.__static = require('path').join(__dirname, "/static").replace(/\\/g, "\\\\")
if(process.env.NODE_ENV !== "development") window.__static = require("path").join(__dirname, "/static").replace(/\\/g, "\\\\")
</script>

<!-- webpack builds are automatically injected -->
Expand Down
10 changes: 9 additions & 1 deletion src/main/communicator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { ipcMain } from "electron";
import { dialog } from "electron";
import fs from "fs";
import path from "path";
import DirToJSON from "dir-to-json";
const base_path = `C:/Users/${process.env.USERNAME}/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/`;
const behavior_path = base_path + "development_behavior_packs/";

// ipcMain.on("getOpenedWithData", event => {
// let data = null;
// if(process.platform === "win32" && process.env.NODE_ENV !== "development" && process.argv.length >= 2) {
// let to_open = process.argv[1];
// data = to_open;
// }
// event.returnValue = data
// });

ipcMain.on("getProjects", (event, args) => {
fs.readdir(base_path + "development_behavior_packs", (err, files) => {
if(err) console.log(err);
Expand Down
38 changes: 31 additions & 7 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, ipcMain, Menu } from 'electron'
import { app, BrowserWindow, ipcMain, Menu } from "electron";
import "./communicator.js";
import "./Discord";

Expand Down Expand Up @@ -41,6 +41,7 @@ function createWindow () {
mainWindow.webContents.on('did-finish-load', () => {
if(loadingWindow) {
mainWindow.setPosition(...loadingWindow.getPosition());
// mainWindow.toggleDevTools();
loadingWindow.close();
mainWindow.show();
}
Expand Down Expand Up @@ -77,23 +78,46 @@ function createSplashScreen() {
});
}

app.on('ready', () => {
createWindow();
createSplashScreen();
})
function openFile(file) {
mainWindow.webContents.send("openFile", file)
}

const quit = app.makeSingleInstance((argv) => {
// Someone tried to run a second instance, we should focus our window.
if(loadingWindow) {
if(loadingWindow.isMinimized()) loadingWindow.restore();
loadingWindow.focus();
} else if(mainWindow) {
if(mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}

console.log(argv);
openFile(argv[1]);
});

if (quit && process.argv.length >= 2 && process.env.NODE_ENV !== "development") {
app.quit();
} else {
app.on('ready', () => {
createWindow();
createSplashScreen();
});
}

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
})
});

app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
})
});

ipcMain.on("toggleDevTools", function() { mainWindow.toggleDevTools(); });

/**
* Auto Updater
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/plugin_install/CloudPlugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<script>
import fs from "fs";
import mkdirp from "mkdirp";
import { APP_VERSION } from "../../scripts/constants";
import { APP_VERSION, BASE_PATH } from "../../scripts/constants";
import * as VersionUtils from "../../scripts/VersionUtils";
export default {
Expand Down Expand Up @@ -93,7 +93,7 @@ export default {
return this.installed_plugins[i] ? this.installed_plugins[i].version != this.plugin.version : false;
},
base_path() {
return this.$store.state.TabSystem.base_path + this.$store.state.Explorer.project + "/bridge";
return BASE_PATH + this.$store.state.Explorer.project + "/bridge";
},
is_compatible() {
return !VersionUtils.greaterThan(this.plugin.min_app_version || APP_VERSION, APP_VERSION);
Expand Down
48 changes: 38 additions & 10 deletions src/renderer/scripts/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,30 @@ import { ipcRenderer } from "electron";
import Cache from "./utilities/Cache.js";
import JSONTree from "./editor/JsonTree.js";
import ProblemIterator from "./editor/problems/Problems.js";
import LoadingWindow from "../windows/LoadingWindow";

function getPath(path) {
return BASE_PATH + path;
}

document.addEventListener("dragover", event => {
event.preventDefault();
});
document.addEventListener("drop", event => {
let win = new LoadingWindow("save-file").show();
event.preventDefault();
let files = event.dataTransfer.files;
setTimeout(() => {
for(let file of files) {
FILE_SYSTEM.open(file.path, () => win.close());
}

}, 100);
});
ipcRenderer.on("openFile", (event, path) => {
FILE_SYSTEM.open(path);
});

class FileSystem {
constructor() {
this.Cache = new Cache();
Expand Down Expand Up @@ -48,22 +67,35 @@ class FileSystem {
ipcRenderer.send("saveAsFileDialog", { path, content });
}

open(path) {
open(path, cb) {
this.Cache.get(path)
.then((cache) =>
cache.content ?
this.addAsTab(path, cache.content, cache.format_version) :
fs.readFile(path, (err, data) => {
if(err) throw err;
this.addAsTab(path, data.toString(), 0, data);

if(typeof cb === "function") cb();
})
)
.catch((err) => {
console.log("[OPEN] Not opened from cache", err);
fs.readFile(path, (err, data) => {
if(err) throw err;
this.addAsTab(path, data.toString(), 0, data);
});
console.log("[OPEN] Not opened from cache", err, );
if(fs.statSync(path).isFile()) {
fs.readFile(path, (err, data) => {
if(err) throw err;
this.addAsTab(path, data.toString(), 0, data);

if(typeof cb === "function") cb();
});
} else {
fs.readdir(path, (err, files) => {
if(err) throw err;
setTimeout(() => {
files.forEach((file, i, arr) => this.open(path + "\\" + file, arr.length - 1 === i ? cb : undefined));
}, 1);
});
}
});
}
addAsTab(path, data, format_version=0, raw_data) {
Expand All @@ -85,8 +117,4 @@ class FileSystem {
}

const FILE_SYSTEM = new FileSystem();
ipcRenderer.on("openFile", (event, path) => {
FILE_SYSTEM.open(path);
});

export default FILE_SYSTEM;
2 changes: 1 addition & 1 deletion src/renderer/scripts/constants/app_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
* Version number is in a dedicated file because it's also used by the main thread.
* Otherwise, any changes to the main constant file would completely restart "bridge." (in development mode).
*/
export default "v0.11.2";
export default "v0.11.3";
7 changes: 2 additions & 5 deletions src/renderer/store/modules/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import Store from "../index";
import Vue from "vue";
import fs from "fs";
import DirToJSON from "dir-to-json";

import Runtime from "../../scripts/plugins/Runtime";
import detachObj from "../../scripts/detachObj";
import CodeMirror from "codemirror";
import { BASE_PATH } from "../../scripts/constants";

const state = {
installed_plugins: [],
Expand Down Expand Up @@ -63,7 +60,7 @@ const mutations = {
},
refreshAllPlugins(state, load_dir=false) {
if(load_dir) {
DirToJSON(state.cache.base_path + state.current_loaded_project, (err, files) => {
DirToJSON(BASE_PATH + state.current_loaded_project, (err, files) => {
if(err) console.log(err);

Store.commit("setPluginCache", {
Expand Down
10 changes: 9 additions & 1 deletion src/renderer/windows/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fs from "fs";
import AddSnippetWindow from "./AddSnippet";
import Snippets from "./Snippets";
import ProblemIterator from "../scripts/editor/problems/Problems";
import { ipcRenderer } from "electron";

class ReactiveListEntry {
constructor(text, parent, watch_key, index) {
Expand Down Expand Up @@ -256,11 +257,18 @@ export default class SettingsWindow extends TabWindow {
title: "Developer Mode"
},
content: [
{
type: "button",
text: "Toggle Dev Tools",
color: "warning",
is_rounded: true,
action: () => ipcRenderer.send("toggleDevTools")
},
new ReactiveSwitch(this, "is_dev_mode", {
color: "error",
text: "Asserts",
key: `settings.dev.tab.${Math.random()}`
})
})
]
});

Expand Down
26 changes: 26 additions & 0 deletions static/auto_completions/_RP/entity/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"format_version": "$general.format_version",
"minecraft:client_entity": {
"description": {
"identifier": "$general.entity_identifier",
"materials": {
"$placeholder": {}
},
"textures": {
"$placeholder": {}
},
"geometry": {
"$placeholder": {}
},
"scripts": {
"scale": "$general.decimal",
"pre_animation": {
"$dynamic.list.next_index": {}
},
"animate": {
"$dynamic.list.next_index": {}
}
}
}
}
}
1 change: 1 addition & 0 deletions static/data/problems.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

{
"bridge:two_incompatible": {
"is_warning": true,
"first": "minecraft:rideable",
"second": "minecraft:spawn_entity",
"error_message": "Entities being ridden cannot use minecraft:spawn_entity"
Expand Down

0 comments on commit f917136

Please sign in to comment.