Commit 4ef58f0f authored by nerrons's avatar nerrons

Fix: make extra/K12 dir work on all platforms

parent 1e9a6f3a
Pipeline #1656 failed with stage
in 0 seconds
......@@ -98,14 +98,14 @@
<div id="k12-frame" class="control-panel">
<button
id="k12-edit-button"
><img id="k12-edit-button-icon" src="./extra/K12/icons-large/perform.png"></button>
><img id="k12-edit-button-icon"></button>
<div id="k12-panel-toggles">
<button
id="k12-control-button"
><img id="k12-control-button-icon" src="./extra/K12/icons/control_on.png"></button>
><img id="k12-control-button-icon"></button>
<button
id="k12-sound-button"
><img id="k12-sound-button-icon" src="./extra/K12/icons/sound.png"></button>
><img id="k12-sound-button-icon"></button>
</div>
<div id="k12-buttons">
<div id="k12-buttons-control"></div>
......
......@@ -12,6 +12,7 @@ pdgui.skin.apply(window);
var l = pdgui.get_local_string;
var k12_mode = pdgui.get_k12_mode();
var k12_offset = pdgui.get_k12_offset();
var k12_dir = "file://" + pdgui.get_k12_dir();
function nw_window_focus_callback(name) {
pdgui.set_focused_patchwin(name);
......@@ -895,21 +896,23 @@ var canvas_events = (function() {
var k12frame = document.getElementById("k12-frame");
// add edit and control/sound buttons
document.getElementById("k12-edit-button").firstChild.src = k12_dir + "/icons-large/perform.png";
document.getElementById("k12-edit-button").onclick = function () {
// first change the button in case pd responds later than the "editmode" check
if (document.getElementById("patchsvg").classList.contains("editmode")) {
document.getElementById("k12-edit-button").firstElementChild.src =
"./extra/K12/icons-large/perform.png";
k12_dir + "/icons-large/perform.png";
document.getElementById("k12-edit-button").title =
"Start playing the patch you created!"
} else {
document.getElementById("k12-edit-button").firstElementChild.src =
"./extra/K12/icons-large/edit.png";
k12_dir + "/icons-large/edit.png";
document.getElementById("k12-edit-button").title =
"Start building your own patch!"
}
pdgui.pdsend(name, "editmode 0");
}
document.getElementById("k12-control-button").firstChild.src = k12_dir + "/icons/control_on.png";
document.getElementById("k12-control-button").onclick = function () {
if (k12frame.classList.contains("sound-panel")) {
k12frame.classList.remove("sound-panel");
......@@ -917,11 +920,12 @@ var canvas_events = (function() {
document.getElementById("k12-buttons-control").style.visibility = "visible";
document.getElementById("k12-buttons-sound").style.visibility = "hidden";
document.getElementById("k12-control-button").firstElementChild.src =
"./extra/K12/icons/control_on.png";
k12_dir + "/icons/control_on.png";
document.getElementById("k12-sound-button").firstElementChild.src =
"./extra/K12/icons/sound.png";
k12_dir + "/icons/sound.png";
}
}
document.getElementById("k12-sound-button").firstChild.src = k12_dir + "/icons/sound.png";
document.getElementById("k12-sound-button").onclick = function () {
if (k12frame.classList.contains("control-panel")) {
k12frame.classList.remove("control-panel");
......@@ -929,9 +933,9 @@ var canvas_events = (function() {
document.getElementById("k12-buttons-sound").style.visibility = "visible";
document.getElementById("k12-buttons-control").style.visibility = "hidden";
document.getElementById("k12-sound-button").firstElementChild.src =
"./extra/K12/icons/sound_on.png";
k12_dir + "/icons/sound_on.png";
document.getElementById("k12-control-button").firstElementChild.src =
"./extra/K12/icons/control.png";
k12_dir + "/icons/control.png";
}
}
......@@ -985,7 +989,7 @@ var canvas_events = (function() {
// set the icon for the button
var icon = document.createElement("img");
icon.className = "k12-button-icon";
icon.src = "./extra/K12/icons-large/" + fullname + ".png";
icon.src = k12_dir + "/icons-large/" + fullname + ".png";
button.appendChild(icon);
if (panel === "control") {
k12_control_buttons_div.appendChild(button);
......@@ -1592,10 +1596,10 @@ function nw_create_patch_window_menus(gui, w, name) {
// change button appearance first to avoid delays
var edit_button = document.getElementById("k12-edit-button");
if (document.getElementById("patchsvg").classList.contains("editmode")) {
edit_button.firstElementChild.src = "./extra/K12/icons-large/perform.png";
edit_button.firstElementChild.src = k12_dir + "/icons-large/perform.png";
edit_button.title = "Start playing the patch you created!"
} else {
edit_button.firstElementChild.src = "./extra/K12/icons-large/edit.png";
edit_button.firstElementChild.src = k12_dir + "/icons-large/edit.png";
edit_button.title = "Start building your own patch!"
}
}
......
......@@ -42,6 +42,13 @@ function gui_set_browser_config(doc_flag, path_flag, init_flag, helppath) {
function gui_set_lib_dir(dir) {
lib_dir = dir;
// This definitely shouldn't be here, but this seems to be the only safe
// place to run build_k12_xlet_tt() ensuring that lib_dir isn't undefined,
// if we are not modifying the C code.
if (k12_mode && !k12_xlet_tt_ready) {
k12_xlet_tt_ready = 1;
build_k12_xlet_tt();
}
}
exports.get_lib_dir = function() {
......@@ -343,31 +350,36 @@ var pd_myversion, // Pd version string
// 3: screen y
pd_colors = {}; // associative array of canvas color presets
var pd_filetypes = { ".pd": "Pd Files",
".pat":"Max Patch Files",
".mxt":"Max Text Files",
".mxb":"Max Binary Files",
".help":"Max Help Files"
};
exports.pd_filetypes = pd_filetypes;
// gets called once by index.js when initializing
exports.set_k12_mode = function (k12) {
k12_mode = k12; // set the global k12 variable
k12_offset = k12_mode ? -200 : 0;
if (k12_mode) {
post("K12 mode is on. K12 offset: " + k12_offset);
} else {
post("K12 mode is off");
}
}
exports.get_k12_mode = function () { return k12_mode; };
exports.get_k12_offset = function () { return k12_offset; };
exports.get_k12_demo_dir = function () {
return path.join(lib_dir, "extra/K12/demos");
var pd_filetypes = {
".pd": "Pd Files",
".pat":"Max Patch Files",
".mxt":"Max Text Files",
".mxb":"Max Binary Files",
".help":"Max Help Files"
};
exports.pd_filetypes = pd_filetypes;
// k12 related functions
// set_k12_mode gets called once by index.js when initializing
exports.set_k12_mode = function (k12) {
k12_mode = k12 ? 1 : 0; // set the global k12 variable
k12_offset = k12_mode ? -200 : 0;
if (k12_mode) {
post("K12 mode is on. K12 offset: " + k12_offset);
} else {
post("K12 mode is off");
}
popup_coords = [0,0];
}
exports.get_k12_mode = function () { return k12_mode; };
exports.get_k12_offset = function () { return k12_offset; };
function get_k12_dir() {
return path.join(lib_dir, "extra/K12");
}
exports.get_k12_dir = get_k12_dir;
exports.get_k12_demo_dir = function () {
return path.join(get_k12_dir(), "demos");
}
popup_coords = [0,0];
// Keycode vs Charcode: A Primer
// -----------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment