This commit is contained in:
OLDREDSTONE
2025-06-01 11:35:11 +08:00
commit 318bbf3be2
423 changed files with 13900 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
/*!
* docsify-copy-code
* v3.0.0
* https://github.com/jperasmus/docsify-copy-code
* (c) 2017-2023 JP Erasmus <jperasmus11@gmail.com>
* MIT license
*/
!function(){"use strict";function e(o){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(o)}!function(e,o){void 0===o&&(o={});var t=o.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css","top"===t&&n.firstChild?n.insertBefore(c,n.firstChild):n.appendChild(c),c.styleSheet?c.styleSheet.cssText=e:c.appendChild(document.createTextNode(e))}}(".docsify-copy-code-button,.docsify-copy-code-button>span{cursor:pointer;transition:all .25s ease}.docsify-copy-code-button{background:grey;background:var(--theme-color,grey);border:0;border-radius:0;color:#fff;font-size:1em;opacity:0;outline:0;overflow:visible;padding:.65em .8em;position:absolute;right:0;top:0;z-index:1}.docsify-copy-code-button>span{background:inherit;border-radius:3px;pointer-events:none}.docsify-copy-code-button>.error,.docsify-copy-code-button>.success{font-size:.825em;opacity:0;padding:.5em .65em;position:absolute;right:0;top:50%;transform:translateY(-50%);z-index:-100}.docsify-copy-code-button.error>.error,.docsify-copy-code-button.success>.success{opacity:1;right:100%;transform:translate(-25%,-50%)}.docsify-copy-code-button:focus,pre:hover .docsify-copy-code-button{opacity:1}.docsify-copy-code-button>[aria-live]{height:1px;left:-10000px;overflow:hidden;position:absolute;top:auto;width:1px}"),document.querySelector('link[href*="docsify-copy-code"]')&&console.warn("[Deprecation] Link to external docsify-copy-code stylesheet is no longer necessary."),window.DocsifyCopyCodePlugin={init:function(){return function(e,o){e.ready((function(){console.warn("[Deprecation] Manually initializing docsify-copy-code using window.DocsifyCopyCodePlugin.init() is no longer necessary.")}))}}},window.$docsify=window.$docsify||{},window.$docsify.plugins=[function(o,t){var n={buttonText:"Copy to clipboard",errorText:"Error",successText:"Copied"};o.doneEach((function(){var o=Array.from(document.querySelectorAll("pre[data-lang]"));t.config.copyCode&&Object.keys(n).forEach((function(o){var c=t.config.copyCode[o];"string"==typeof c?n[o]=c:"object"===e(c)&&Object.keys(c).some((function(e){var t=location.href.indexOf(e)>-1;return n[o]=t?c[e]:n[o],t}))}));var c=['<button class="docsify-copy-code-button">','<span class="label">'.concat(n.buttonText,"</span>"),'<span class="error" aria-hidden="hidden">'.concat(n.errorText,"</span>"),'<span class="success" aria-hidden="hidden">'.concat(n.successText,"</span>"),'<span aria-live="polite"></span>',"</button>"].join("");o.forEach((function(e){e.insertAdjacentHTML("beforeend",c)}))})),o.mounted((function(){var e=document.querySelector(".content");e&&e.addEventListener("click",(function(e){if(e.target.classList.contains("docsify-copy-code-button")){var o="BUTTON"===e.target.tagName?e.target:e.target.parentNode,t=document.createRange(),c=o.parentNode.querySelector("code"),i=o.querySelector("[aria-live]"),r=window.getSelection();t.selectNode(c),r&&(r.removeAllRanges(),r.addRange(t));try{document.execCommand("copy")&&(o.classList.add("success"),i.innerText=n.successText,setTimeout((function(){o.classList.remove("success"),i.innerText=""}),1e3))}catch(e){console.error("docsify-copy-code: ".concat(e)),o.classList.add("error"),i.innerText=n.errorText,setTimeout((function(){o.classList.remove("error"),i.innerText=""}),1e3)}(r=window.getSelection())&&("function"==typeof r.removeRange?r.removeRange(t):"function"==typeof r.removeAllRanges&&r.removeAllRanges())}}))}))}].concat(window.$docsify.plugins||[])}();
//# sourceMappingURL=docsify-copy-code.min.js.map
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+45
View File
@@ -0,0 +1,45 @@
const plugin = (hook, vm) => {
hook.init(() => {
const style = document.createElement('style')
style.setAttribute('type', 'text/css');
style.innerHTML = `
.imagetip {
position: absolute;
z-index: 9999;
display: none;
border: 1px solid #ccc;
background-color: #fff;
padding: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
`
document.head.appendChild(style);
});
hook.doneEach(() => {
const images = document.querySelectorAll('img:not([src*="data:image"])');
const imagetip = document.createElement('div');
imagetip.className = 'imagetip';
document.body.appendChild(imagetip);
images.forEach((img) => {
img.addEventListener('mouseover', (e) => {
imagetip.style.display = 'block';
imagetip.innerHTML = `<img src="${img.src}" style="max-width: 300px; max-height: 300px;" />`;
imagetip.style.left = `${e.pageX + 10}px`;
imagetip.style.top = `${e.pageY + 10}px`;
});
img.addEventListener('mousemove', (e) => {
imagetip.style.left = `${e.pageX + 10}px`;
imagetip.style.top = `${e.pageY + 10}px`;
});
img.addEventListener('mouseout', () => {
imagetip.style.display = 'none';
});
});
});
}
import plugin from './plugin';
if (!window.$docsify) {
window.$docsify = {};
}
window.$docsify.plugins = (window.$docsify.plugins || []).concat(plugin);
+132
View File
@@ -0,0 +1,132 @@
var node, tips;
var currentImageIndex;
var isHidingTips = false;
var show = true;
var anim;
var tipTexts = [""];
function showOtto(callback) {
node.style.opacity = 1;
anim = node.animate([
{ bottom: "-100%", transform: "rotate(-30deg)", easing: "cubic-bezier(0.16, 1, 0.3, 1)", offset: 0 },
{ bottom: 0, offset: 1 },
], 750);
anim.onfinish = function () {
if (callback) {
callback();
}
}
}
function hideOtto(callback) {
anim = node.animate([
{ bottom: 0, transform: "rotate(0deg)", easing: "cubic-bezier(0.7, 0, 0.84, 0)", offset: 0 },
{ bottom: "-100%", transform: "rotate(-30deg)", offset: 1 },
], 750);
anim.onfinish = function () {
node.style.opacity = 0;
if (callback) {
callback();
}
}
}
window.onload = function () {
fetch("tips.json").then(response => response.json()).then(data => {
tipTexts = data;
});
addOtto(document);
showOtto()
}
window.$docsify.onLightDarkModeChange = function () {
if (show) {
if (anim.playState != "running")
hideOtto(() => {
image.src = getCurrentImage();
showOtto();
});
}
else
image.src = getCurrentImage();
}
window.$docsify.onOttoShow = function () {
if (!anim.playState || anim.playState != "finished") {
return;
}
show = !show;
if (show) {
showOtto();
} else {
hideOtto();
}
}
function addOtto(document) {
node = document.createElement("div");
node.className = "otto";
image = document.createElement("img");
image.src = getCurrentImage();
image.alt = "Otto";
tips = document.createElement("div");
tips.className = "tips";
tips.style.opacity = 0;
tips.style.transition = "transform 0.5s";
node.appendChild(tips);
node.appendChild(image);
node.addEventListener("click", clickOtto);
document.body.appendChild(node);
}
function clickOtto() {
switch (anim.playState) {
case "running":
if (isHidingTips) {
return;
}
isHidingTips = true;
anim.pause();
temp = anim;
anim = tips.animate([
{ transform: "translateY(0) rotate(0deg)", opacity: 100, offset: 0.5, easing: "ease-in" },
{ transform: "translateY(-10px) rotate(-3deg)", opacity: 0 }
], 400);
anim.onfinish = function () {
temp.cancel();
tips.innerHTML = randomTips();
isHidingTips = false;
playTips();
}
break;
case "paused":
break;
case "finished":
tips.innerHTML = randomTips();
playTips();
break;
}
}
function playTips() {
anim = tips.animate([
{ transform: "translateY(-10px) rotate(3deg)", opacity: 0, offset: 0, easing: "ease-out" },
{ transform: "translateY(0) rotate(0deg)", opacity: 100, offset: 0.1 },
{ transform: "translateY(0) rotate(0deg)", opacity: 100, offset: 0.9, easing: "ease-in" },
{ transform: "translateY(-10px) rotate(-3deg)", opacity: 0, offset: 1 }
], 4000);
anim.onfinish = function () {
}
}
function randomTips() {
return tipTexts[Math.floor(Math.random() * tipTexts.length)];
}
function getCurrentImage() {
currentImageIndex = window.$docsify.currentThemeModeIndex;
switch (currentImageIndex) {
case 0: //light
return "/images/otto-rd2.png";
case 1: //dark
return "/images/otto-rd2-xmas-compressed.png";
case 2: //default
return "/images/otto-wyym.png";
}
}
+995
View File
@@ -0,0 +1,995 @@
"use strict";
var tilePosition = {
"events": {
"sounds": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "SetCrotchetsPerBar_1", "position": [0, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_2", "position": [1, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_3", "position": [2, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_4", "position": [3, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_5", "position": [4, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_6", "position": [5, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_7", "position": [6, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_8", "position": [7, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_9", "position": [8, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar", "position": [9, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_1", "position": [0, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_2", "position": [1, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_3", "position": [2, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_4", "position": [3, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_5", "position": [4, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_6", "position": [5, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_7", "position": [6, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_8", "position": [7, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_9", "position": [8, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_10", "position": [9, 2, 1, 1] },
{ "name": "PlaySong", "position": [0, 3, 2, 1] },
{ "name": "PlaySound", "position": [2, 3, 1, 1] },
{ "name": "SetBeatsPerMinute", "position": [3, 3, 1, 1] },
{ "name": "SetClapSounds", "position": [4, 3, 1, 1] },
{ "name": "SetHeartExplodeVolume", "position": [5, 3, 1, 1] },
{ "name": "SetHeartExplodeInterval", "position": [6, 3, 1, 1] },
{ "name": "SetGameSound", "position": [7, 3, 1, 1] },
{ "name": "SetBeatSound", "position": [8, 3, 1, 1] },
{ "name": "SetCountingSound", "position": [9, 3, 1, 1] },
{ "name": "SayReadyGetSetGo_Rea", "position": [1, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Dy", "position": [2, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Get", "position": [3, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Set", "position": [4, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Go", "position": [5, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Ready", "position": [10, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_And", "position": [10, 1, 1, 1] },
{ "name": "SayReadyGetSetGo_GetSetGo", "position": [11, 0, 3, 1] },
{ "name": "SayReadyGetSetGo_GetSetOne", "position": [11, 1, 3, 1] },
{ "name": "SayReadyGetSetGo_Stop", "position": [14, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_AndStop", "position": [14, 1, 1, 1] },
{ "name": "SayReadyGetSetGo_ReaDyGetSetGo", "position": [10, 2, 5, 1] },
{ "name": "SayReadyGetSetGo_ReaDyGetSetOne", "position": [10, 3, 5, 1] },
{ "name": "Comment", "position": [15, 0, 1, 1] }
],
"rows": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "SetOneshotWave", "position": [1, 0, 1, 1] }
],
"actions": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "SetTheme", "position": [1, 0, 1, 1] },
{ "name": "SetVFXPreset", "position": [2, 0, 1, 1] },
{ "name": "SetBackgroundColor", "position": [3, 0, 1, 1] },
{ "name": "SetForeground", "position": [4, 0, 1, 1] },
{ "name": "SetSpeed", "position": [5, 0, 1, 1] },
{ "name": "Flash", "position": [6, 0, 1, 1] },
{ "name": "CustomFlash", "position": [7, 0, 1, 1] },
{ "name": "NewWindowDance", "position": [8, 0, 1, 1] },
{ "name": "MoveCamera", "position": [0, 1, 1, 1] },
{ "name": "PulseCamera", "position": [1, 1, 1, 1] },
{ "name": "TextExplosion", "position": [2, 1, 1, 1] },
{ "name": "ShowDialogue", "position": [3, 1, 1, 1] },
{ "name": "ShowStatusSign", "position": [4, 1, 1, 1] },
{ "name": "FloatingText", "position": [5, 1, 1, 1] },
{ "name": "AdvanceText", "position": [6, 1, 0.5, 1] },
{ "name": "ChangePlayersRows", "position": [7, 1, 1, 1] },
{ "name": "Comment", "position": [8, 1, 1, 1] },
{ "name": "FinishLevel", "position": [0, 2, 1, 1] },
{ "name": "Stutter", "position": [1, 2, 1, 1] },
{ "name": "HideRow", "position": [2, 2, 1, 1] },
{ "name": "MoveRow", "position": [3, 2, 1, 1] },
{ "name": "PlayExpression", "position": [4, 2, 1, 1] },
{ "name": "TintRows", "position": [5, 2, 1, 1] },
{ "name": "BassDrop", "position": [6, 2, 1, 1] },
{ "name": "ShakeScreen", "position": [7, 2, 1, 1] },
{ "name": "FlipScreen", "position": [0, 3, 1, 1] },
{ "name": "InvertColors", "position": [1, 3, 1, 1] },
{ "name": "ShowHands", "position": [2, 3, 1, 1] },
{ "name": "PaintHands", "position": [3, 3, 1, 1] },
{ "name": "SetHandOwner", "position": [4, 3, 1, 1] },
{ "name": "SetPlayStyle", "position": [5, 3, 1, 1] },
{ "name": "TagAction", "position": [6, 3, 1, 1] },
{ "name": "CallCustomMethod", "position": [7, 3, 1, 1] }
],
"decorations": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "PlayAnimation", "position": [1, 0, 1, 1] },
{ "name": "Tint", "position": [0, 1, 1, 1] },
{ "name": "Comment", "position": [1, 1, 1, 1] },
{ "name": "SetVisible", "position": [0, 2, 1, 1] },
{ "name": "Move", "position": [0, 3, 1, 1] }
],
"rooms": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "MoveRoom", "position": [0, 1, 1, 1] },
{ "name": "FadeRoom", "position": [0, 2, 1, 1] },
{ "name": "MaskRoom", "position": [0, 3, 1, 1] },
{ "name": "ShowRooms", "position": [1, 0, 1, 4] },
{ "name": "ReorderRooms", "position": [2, 0, 1, 4] },
{ "name": "SetRoomContentMode", "position": [3, 0, 1, 1] },
{ "name": "SetRoomPerspective", "position": [3, 1, 1, 1] },
{ "name": "Comment", "position": [3, 2, 1, 1] }
],
"custom": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "Comment", "position": [0, 1, 1, 1] }
],
"beatsSpecial": [
"AddClassicBeat",
"AddOneshotBeat",
"AddFreeTimeBeat",
"PulseFreeTimeBeat",
"SetRowXs"
]
}
};
function loadRDView() {
window.RDViewRender = RDViewRender;
}
class Color {
constructor(red, green, blue, alpha) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
;
}
var EventType;
(function (EventType) {
EventType["sounds"] = "sounds";
EventType["rows"] = "rows";
EventType["actions"] = "actions";
EventType["decorations"] = "decorations";
EventType["rooms"] = "rooms";
EventType["custom"] = "custom";
})(EventType || (EventType = {}));
var BeatsSpecial;
(function (BeatsSpecial) {
BeatsSpecial[BeatsSpecial["AddClassicBeat"] = 0] = "AddClassicBeat";
BeatsSpecial[BeatsSpecial["AddFreeTimeBeat"] = 1] = "AddFreeTimeBeat";
BeatsSpecial[BeatsSpecial["PulseFreeTimeBeat"] = 2] = "PulseFreeTimeBeat";
BeatsSpecial[BeatsSpecial["AddOneshotBeat"] = 3] = "AddOneshotBeat";
BeatsSpecial[BeatsSpecial["SetRowXs"] = 4] = "SetRowXs";
})(BeatsSpecial || (BeatsSpecial = {}));
var EventCondition;
(function (EventCondition) {
EventCondition["true"] = "true";
EventCondition["false"] = "false";
EventCondition["both"] = "both";
})(EventCondition || (EventCondition = {}));
class RDViewWindow {
constructor() {
this.Objects = [];
this.Row = 4;
this.Column = 8;
this.Scale = 1;
}
}
class RDEvent {
constructor() {
this.SubType = EventType.custom;
this.BeatType = undefined;
this.Width = 1;
this.Height = 1;
this.EventX = 0;
this.EventY = 0;
this.Style = { Beat: 0, Y: 0 };
}
}
class RDDescription {
constructor() {
this.Width = 4;
this.Lines = [];
}
}
class RDDescriptionLine {
constructor() {
this.BoxCount = 1;
this.IconCount = 0;
this.Items = [];
}
}
class RDDescriptionText {
constructor() {
this.Text = "";
}
}
class RDDescriptionBox {
constructor() {
this.Items = [];
}
}
class RDDescriptionBoxInput {
constructor() {
this.Tips = "";
this.Text = "";
}
}
class RDDescriptionBoxScroll {
constructor() {
this.Scroll = 0;
}
}
class RDDescriptionBoxButton {
constructor() {
this.Text = "";
}
}
class RDDescriptionBoxSelect {
constructor() {
this.Items = [];
this.SelectedIndex = 0;
}
}
class RDDescriptionIcon {
}
class RDStyle {
constructor() {
this.Beat = 0;
this.Y = 0;
}
}
class RDBeatStyle {
constructor() {
this.OneshotBeatSubType = [];
this.RowXs = '------';
}
}
var RDOneshotBeatSubType;
(function (RDOneshotBeatSubType) {
RDOneshotBeatSubType[RDOneshotBeatSubType["Freezeshot"] = 0] = "Freezeshot";
RDOneshotBeatSubType[RDOneshotBeatSubType["Burnshot"] = 1] = "Burnshot";
RDOneshotBeatSubType[RDOneshotBeatSubType["Skipshot"] = 2] = "Skipshot";
RDOneshotBeatSubType[RDOneshotBeatSubType["Subdivision"] = 3] = "Subdivision";
})(RDOneshotBeatSubType || (RDOneshotBeatSubType = {}));
class RDGroup {
constructor() {
this.Width = 1;
this.Height = 1;
this.Outline = new Color(255, 0, 0, 255);
this.Style = new RDStyle();
this.ClickStyle = new RDStyle();
this.Children = [];
}
}
function RDViewRender(lang, code) {
const lines = code.split('\n');
const window = new RDViewWindow();
var objs = [];
try {
window.Objects = ReadObjs(code);
}
catch (error) {
return errorHtml(`${error}`);
}
const args = lang.split(/\s+/g);
if (1 < args.length && args.length <= 4) {
if (args[1]) {
window.Column = parseInt(args[1]);
}
if (args[2]) {
window.Row = parseInt(args[2]);
}
if (args[3]) {
window.Scale = parseFloat(args[3]);
}
}
return ConstructObjs(window);
}
function errorHtml(message = "") {
return `<div class="RDView" style="--row:1;--column:0;"><div class="event actions" style="--beat:0;--y:0"><div class="description" style="--width:12;">${message.length ? `${message}` : ""}</div></div></div>`;
}
function ReadObjs(line) {
const objs = [];
var reader = new Reader(line);
while (!reader.IsEnd()) {
var event;
try {
const type = reader.ReadSymbol().toLowerCase();
event = ReadType(type);
}
catch (e) {
event = new RDEvent();
}
if (event instanceof RDEvent) {
reader.TestRead('.', true);
const name = reader.ReadSymbol();
var collection;
switch (event.SubType) {
case EventType.sounds:
collection = tilePosition.events.sounds;
break;
case EventType.rows:
collection = tilePosition.events.rows;
switch (name) {
case 'AddClassicBeat':
event.BeatType = BeatsSpecial.AddClassicBeat;
break;
case 'AddFreeTimeBeat':
event.BeatType = BeatsSpecial.AddFreeTimeBeat;
break;
case 'PulseFreeTimeBeat':
event.BeatType = BeatsSpecial.PulseFreeTimeBeat;
break;
case 'AddOneshotBeat':
event.BeatType = BeatsSpecial.AddOneshotBeat;
break;
case 'SetRowXs':
event.BeatType = BeatsSpecial.SetRowXs;
break;
default:
break;
}
break;
case EventType.actions:
collection = tilePosition.events.actions;
break;
case EventType.decorations:
collection = tilePosition.events.decorations;
break;
case EventType.rooms:
collection = tilePosition.events.rooms;
break;
case EventType.custom:
collection = tilePosition.events.custom;
break;
default:
collection = tilePosition.events.custom;
break;
}
const pos = collection.filter(i => i.name.toLowerCase() === name.toLowerCase())[0];
if (pos) {
event.EventX = pos.position[0];
event.EventY = pos.position[1];
event.Width = pos.position[2];
event.Height = pos.position[3];
}
try {
event.Style.Beat = reader.ReadFloat();
}
catch (e) { }
try {
event.Style.Y = reader.ReadInt();
}
catch (e) { }
if (reader.TestPeek('[')) {
const pairString = reader.ReadQuoted('[', ']');
const keyvalues = new Reader(pairString, reader).ReadPairs();
ReadProperties(reader, event, keyvalues);
}
reader.TestRead(';', true);
}
else if (event instanceof RDGroup) {
try {
event.Style.Beat = reader.ReadFloat();
}
catch (e) { }
try {
event.Style.Y = reader.ReadInt();
}
catch (e) { }
try {
event.Width = reader.ReadFloat();
}
catch (e) { }
try {
event.Height = reader.ReadInt();
}
catch (e) { }
try {
event.Outline = reader.ReadColor();
}
catch (e) { }
if (reader.TestPeek('[')) {
const pairString = reader.ReadQuoted('[', ']');
const keyvalues = new Reader(pairString, reader).ReadPairs();
ReadProperties(reader, event, keyvalues);
}
if (reader.TestPeek('{')) {
const pairString = reader.ReadQuoted('{', '}');
const objs2 = ReadObjs(pairString);
event.Children = objs2;
}
reader.TestRead(';', true);
}
objs.push(event);
}
return objs;
}
function IsEmptyOrSpace(string) {
return (string) ? /\s/.test(string) : false;
}
class Reader {
constructor(string, reader = undefined) {
this.position = 0;
this.line = 0;
this.offl = 0;
this.offp = 0;
this.string = string;
if (reader) {
this.offl = reader.line;
this.offp = reader.position;
}
}
;
IsEnd() {
this.JumpSpace();
return this.position >= this.string.length;
}
JumpSpace() {
while (IsEmptyOrSpace(this.string[this.position])) {
if (this.string[this.position] === '\n') {
this.line++;
}
this.position++;
}
}
Peek() {
this.JumpSpace();
return this.string[this.position];
}
TestPeek(str, allowThrow = false) {
this.JumpSpace();
var c = this.string.substring(this.position, this.position + str.length);
if (c === str) {
return true;
}
else {
if (allowThrow) {
throw new Error(`Expecting a string '${str}' but got '${c}': ${this.GetPositionDescription()}.`);
}
else {
return false;
}
}
}
TestRead(str, allowThrow = false) {
this.JumpSpace();
var c = this.string.substring(this.position, this.position + str.length);
if (c === str) {
this.position++;
return true;
}
else {
if (allowThrow) {
throw new Error(`Expecting a char '${str}' but got '${c}': ${this.GetPositionDescription()}.`);
}
else {
return false;
}
}
}
ReadChar() {
var c = this.string[this.position];
if (c === '\n') {
this.line++;
}
this.position++;
return c;
}
ReadSymbol() {
var _a;
this.JumpSpace();
var name = (_a = this.string.substring(this.position).match(/^\w+/)) === null || _a === void 0 ? void 0 : _a[0];
if (name) {
this.position += name.length;
return name;
}
throw new Error(`Expecting a key but missing: ${this.GetPositionDescription()}.`);
}
ReadColor() {
var _a;
this.JumpSpace();
var color = (_a = this.string.substring(this.position).match(/^#[0-9A-Fa-f]{3}([0-9A-Fa-f]{1}([0-9A-Fa-f]{2}([0-9A-Fa-f]{2})?)?)?/)) === null || _a === void 0 ? void 0 : _a[0].substring(1);
if (!color) {
throw new Error(`Expecting a color but missing: ${this.GetPositionDescription()}`);
}
var result;
switch (color.length) {
case 3:
result = new Color(parseInt(color.substring(0, 1), 16) * 16, parseInt(color.substring(1, 2), 16) * 16, parseInt(color.substring(2, 3), 16) * 16, 255);
break;
case 4:
result = new Color(parseInt(color.substring(0, 1), 16) * 16, parseInt(color.substring(1, 2), 16) * 16, parseInt(color.substring(2, 3), 16) * 16, parseInt(color.substring(3, 4), 16) * 16);
break;
case 6:
result = new Color(parseInt(color.substring(0, 2), 16), parseInt(color.substring(2, 4), 16), parseInt(color.substring(4, 6), 16), 255);
break;
case 8:
result = new Color(parseInt(color.substring(0, 2), 16), parseInt(color.substring(2, 4), 16), parseInt(color.substring(4, 6), 16), parseInt(color.substring(6, 8), 16));
break;
default:
result = new Color(255, 0, 0, 255);
break;
}
this.position += color.length + 1;
return result;
}
ReadInt() {
var _a;
this.JumpSpace();
var name = (_a = this.string.substring(this.position).match(/^[+-]?[0-9]+/)) === null || _a === void 0 ? void 0 : _a[0];
if (name) {
this.position += name.length;
return parseInt(name);
}
throw new Error(`Expecting an int but missing: ${this.GetPositionDescription()}.`);
}
ReadFloat() {
var _a;
this.JumpSpace();
var name = (_a = this.string.substring(this.position).match(/^[+-]?([0-9]*[.])?[0-9]+/)) === null || _a === void 0 ? void 0 : _a[0];
if (name) {
this.position += name.length;
return parseFloat(name);
}
throw new Error(`Expecting a float but missing: ${this.GetPositionDescription()}.`);
}
ReadPairs(separator = ',', equals = '=') {
var pairs = [];
var flag = !this.IsEnd();
while (flag) {
if (this.IsEnd()) {
break;
}
const index = this.position + this.offp;
const name = this.ReadSymbol();
this.TestRead(equals, true);
const value = this.ReadWhileNotEnd([separator]);
pairs.push({ Key: name, Value: value, Index: index });
if (flag = !this.IsEnd()) {
this.TestRead(separator, true);
}
}
return pairs;
}
ReadWhileNotEnd(ends = [',', ']']) {
var str = '';
while (!(this.position >= this.string.length) && !ends.find(i => this.string.startsWith(i, this.position))) {
str += this.string[this.position];
this.position++;
}
return str.trim();
}
ReadQuoted(left, right) {
this.JumpSpace();
var level = 0;
var result = '';
if (this.string.startsWith(left, this.position)) {
level++;
this.position += left.length;
}
else {
throw new Error(`Cannot find the left half "${left}": ${this.GetPositionDescription()}`);
}
while (!(this.position >= this.string.length) && level > 0) {
if (this.string.startsWith(left, this.position)) {
level++;
this.position += left.length;
result += left;
}
if (this.string.startsWith(right, this.position)) {
level--;
this.position += right.length;
if (level === 0) {
return result;
}
else {
result += right;
}
}
result += this.string[this.position];
this.position++;
}
throw new Error(`Cannot find the right half "${right}": ${this.GetPositionDescription()}`);
}
GetPositionDescription(position = undefined) {
const s = this.string.split('\n');
var curp = this.offp;
var line = this.offl;
if (position !== undefined) {
while (curp + s[line].length + 1 < position - this.offp) {
curp += s[line].length + 1;
line += 1;
}
}
else {
curp += s.slice(0, this.line).reduce((sum, i) => sum + i.length + 1, 0);
line += this.line;
position = this.position;
}
return `<br>at "${s[line]}".`; //, at ${line + 1}:${position - curp}`;
}
}
function FindValue(pairs, key) {
const finded = pairs.find(i => i.Key === key);
if (finded) {
return finded;
}
return undefined;
}
function ReadType(typename) {
var t = EventType.custom;
var event;
switch (typename[0]) {
case 'e':
event = new RDEvent();
switch (typename[1]) {
case 's':
t = EventType.sounds;
break;
case 'b':
t = EventType.rows;
break;
case 'a':
t = EventType.actions;
break;
case 'd':
t = EventType.decorations;
break;
case 'r':
t = EventType.rooms;
break;
case 'c':
t = EventType.custom;
break;
default:
t = EventType.custom;
}
event.SubType = t;
break;
case 'g':
event = new RDGroup();
break;
default:
event = new RDEvent();
}
return event;
}
function ReadProperties(reader, event, pairs) {
var _a, _b, _c, _d, _e, _f;
if (event instanceof RDGroup) {
if (value = FindValue(pairs, "hue")) {
try {
event.Style.Hue = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "brightness")) {
try {
event.Style.Brightness = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "grayscale")) {
try {
event.Style.Grayscale = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "opacity")) {
try {
event.Style.Opacity = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "offset")) {
reader = new Reader(value.Value);
(_a = event.ClickStyle) !== null && _a !== void 0 ? _a : (event.ClickStyle = new RDStyle());
try {
event.ClickStyle.Beat = reader.ReadFloat();
}
catch (e) { }
try {
event.ClickStyle.Y = reader.ReadInt();
}
catch (e) { }
try {
event.ClickOutline = reader.ReadColor();
}
catch (e) { }
}
if (value = FindValue(pairs, "offset_hue")) {
(_b = event.ClickStyle) !== null && _b !== void 0 ? _b : (event.ClickStyle = new RDStyle());
event.ClickStyle.Hue = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_brightness")) {
(_c = event.ClickStyle) !== null && _c !== void 0 ? _c : (event.ClickStyle = new RDStyle());
event.ClickStyle.Brightness = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_grayscale")) {
(_d = event.ClickStyle) !== null && _d !== void 0 ? _d : (event.ClickStyle = new RDStyle());
event.ClickStyle.Grayscale = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_opacity")) {
(_e = event.ClickStyle) !== null && _e !== void 0 ? _e : (event.ClickStyle = new RDStyle());
event.ClickStyle.Opacity = parseFloat(value.Value);
}
}
else if (event instanceof RDEvent) {
var value;
if (value = FindValue(pairs, "if")) {
if (["true", "false", "both"].find(i => i === (value === null || value === void 0 ? void 0 : value.Value))) {
event.Condition = value.Value === "true" ? EventCondition.true :
value.Value === "false" ? EventCondition.false : EventCondition.both;
}
else {
throw new Error(`Expecting "true", "false" or "both", but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "tag")) {
event.Tag = value.Value === "true" ? true : false;
}
if (value = FindValue(pairs, "hue")) {
event.Style.Hue = parseFloat(value.Value);
}
if (value = FindValue(pairs, "brightness")) {
event.Style.Brightness = parseFloat(value.Value);
}
if (value = FindValue(pairs, "grayscale")) {
event.Style.Grayscale = parseFloat(value.Value);
}
if (value = FindValue(pairs, "opacity")) {
event.Style.Opacity = parseFloat(value.Value);
}
(_f = event.ClickStyle) !== null && _f !== void 0 ? _f : (event.ClickStyle = new RDStyle());
if (value = FindValue(pairs, "offset")) {
reader = new Reader(value.Value);
try {
event.ClickStyle.Beat = reader.ReadFloat();
}
catch (e) { }
try {
event.ClickStyle.Y = reader.ReadInt();
}
catch (e) { }
}
if (value = FindValue(pairs, "offset_hue")) {
event.ClickStyle.Hue = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_brightness")) {
event.ClickStyle.Brightness = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_grayscale")) {
event.ClickStyle.Grayscale = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_opacity")) {
event.ClickStyle.Opacity = parseFloat(value.Value);
}
if (event.BeatType !== undefined) {
event.BeatStyle = new RDBeatStyle();
if (value = FindValue(pairs, "tick")) {
event.BeatStyle.Tick = parseFloat(value.Value);
}
switch (event.BeatType) {
case BeatsSpecial.AddClassicBeat:
if (value = FindValue(pairs, "swing")) {
event.BeatStyle.Swing = parseFloat(value.Value);
}
if (value = FindValue(pairs, "hold")) {
event.BeatStyle.Hold = parseFloat(value.Value);
}
break;
case BeatsSpecial.AddFreeTimeBeat:
if (value = FindValue(pairs, "pulse")) {
event.BeatStyle.Pulse = parseFloat(value.Value);
}
if (value = FindValue(pairs, "hold")) {
event.BeatStyle.Hold = parseFloat(value.Value);
}
break;
case BeatsSpecial.PulseFreeTimeBeat:
if (value = FindValue(pairs, "pulse")) {
event.BeatStyle.Pulse = parseFloat(value.Value);
}
if (value = FindValue(pairs, "hold")) {
event.BeatStyle.Hold = parseFloat(value.Value);
}
break;
case BeatsSpecial.SetRowXs:
if ((value = FindValue(pairs, "rowxs"))) {
if (value.Value.match(/^[-x]{6}$/)) {
event.BeatStyle.RowXs = value.Value;
}
else {
throw new Error(`Expect a string of length 6, consisting of "x" and "-", instead of "${value === null || value === void 0 ? void 0 : value.Value}".`);
}
}
break;
case BeatsSpecial.AddOneshotBeat:
if (value = FindValue(pairs, "type")) {
const types = value.Value.split(/\s+/);
var illegal;
if ((illegal = types.filter(i => {
![
"freezeshot",
"burnshot",
"skipshot",
"subdivision"
].includes(i);
})).length) {
throw new Error(`Expecting "freezeshot", "burnshot", "skipshot" or "subdivision", but find ${illegal.map(i => `"${i}"`).join(', ')}.`);
}
else {
types.map(i => {
var _a, _b, _c, _d;
switch (i) {
case "freezeshot":
(_a = event.BeatStyle) === null || _a === void 0 ? void 0 : _a.OneshotBeatSubType.push(RDOneshotBeatSubType.Freezeshot);
break;
case "burnshot":
(_b = event.BeatStyle) === null || _b === void 0 ? void 0 : _b.OneshotBeatSubType.push(RDOneshotBeatSubType.Burnshot);
break;
case "skipshot":
(_c = event.BeatStyle) === null || _c === void 0 ? void 0 : _c.OneshotBeatSubType.push(RDOneshotBeatSubType.Skipshot);
break;
case "subdivision":
(_d = event.BeatStyle) === null || _d === void 0 ? void 0 : _d.OneshotBeatSubType.push(RDOneshotBeatSubType.Subdivision);
break;
}
});
}
}
if (value = FindValue(pairs, "interval")) {
event.BeatStyle.Interval = parseFloat(value.Value);
}
if ((value = FindValue(pairs, "delay"))
&& event.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Freezeshot)) {
event.BeatStyle.Delay = parseFloat(value.Value);
}
if ((value = FindValue(pairs, "subdivision"))
&& event.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Subdivision)) {
event.BeatStyle.Subdivision = parseFloat(value.Value);
}
if (value = FindValue(pairs, "loop")) {
event.BeatStyle.Loop = parseInt(value.Value);
}
break;
default:
break;
}
}
}
}
function ConstructObjs(window) {
var html = `<div class="RDViewContent" style="--column:${window.Column};--row:${window.Row};--scale:${window.Scale};">`
+ `<div class="RDView" style="--column:${window.Column};--row:${window.Row};--scale:${window.Scale};">`;
for (var obj of window.Objects) {
html += ConstructDivObject(obj);
}
html += `</div></div>`;
return html;
}
function ConstructDivObject(obj) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
if (obj instanceof RDEvent) {
return `<div class="event ${obj.BeatType === undefined ? `${obj.SubType}` : 'beat'}"style="${ConstructCssPropertiesIfExists(new Map([
['beat', obj.Style.Beat],
['y', obj.Style.Y],
['event-x', obj.EventX],
['event-y', obj.EventY],
['event-width', obj.Width],
['event-height', obj.Height],
['hue', obj.Style.Hue],
['brightness', obj.Style.Brightness],
['grayscale', obj.Style.Grayscale],
['opacity', obj.Style.Opacity],
['offset-beat', (_a = obj.ClickStyle) === null || _a === void 0 ? void 0 : _a.Beat],
['offset-y', (_b = obj.ClickStyle) === null || _b === void 0 ? void 0 : _b.Y],
['offset-hue', (_c = obj.ClickStyle) === null || _c === void 0 ? void 0 : _c.Hue],
['offset-brightness', (_d = obj.ClickStyle) === null || _d === void 0 ? void 0 : _d.Brightness],
['offset-grayscale', (_e = obj.ClickStyle) === null || _e === void 0 ? void 0 : _e.Grayscale],
['offset-opacity', (_f = obj.ClickStyle) === null || _f === void 0 ? void 0 : _f.Opacity],
['tick', (_g = obj.BeatStyle) === null || _g === void 0 ? void 0 : _g.Tick],
['delay', (_h = obj.BeatStyle) === null || _h === void 0 ? void 0 : _h.Delay],
['interval', (_j = obj.BeatStyle) === null || _j === void 0 ? void 0 : _j.Interval],
['subdivision', (_k = obj.BeatStyle) === null || _k === void 0 ? void 0 : _k.Subdivision],
['hold', (_l = obj.BeatStyle) === null || _l === void 0 ? void 0 : _l.Hold],
['pulse', (_m = obj.BeatStyle) === null || _m === void 0 ? void 0 : _m.Pulse],
['swing', (_o = obj.BeatStyle) === null || _o === void 0 ? void 0 : _o.Swing],
['loop', (_p = obj.BeatStyle) === null || _p === void 0 ? void 0 : _p.Loop],
]))}">${ConstructSubDiv([obj.Condition !== undefined, `condition-${obj.Condition}`, () => ''], [obj.Tag === true, `tag`, () => ''], [obj.BeatType === BeatsSpecial.AddClassicBeat, `classicbeat`, () => {
var result = '';
for (var i = 0; i < 6; i++) {
result += `<div></div>`;
}
return result;
}], [obj.BeatType === BeatsSpecial.AddFreeTimeBeat, `add freetime`, () => { return ''; }], [obj.BeatType === BeatsSpecial.PulseFreeTimeBeat, `pulse freetime`, () => ''], [((_q = obj.BeatStyle) === null || _q === void 0 ? void 0 : _q.Loop) !== undefined && obj.BeatStyle.Loop > 0, `loop`, () => {
var _a, _b;
var result = '';
for (var i = 0; i < ((_b = (_a = obj.BeatStyle) === null || _a === void 0 ? void 0 : _a.Loop) !== null && _b !== void 0 ? _b : 0); i++) {
result += `<div></div>`;
}
return result;
}], [obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Freezeshot), `freezeshots`, () => {
var _a, _b;
var result = '';
for (var i = 0; i < ((_b = (_a = obj.BeatStyle) === null || _a === void 0 ? void 0 : _a.Loop) !== null && _b !== void 0 ? _b : 0) + 1; i++) {
result += `<div></div>`;
}
return result;
}], [obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Burnshot), `burnshots`, () => {
var _a, _b;
var result = '';
for (var i = 0; i < ((_b = (_a = obj.BeatStyle) === null || _a === void 0 ? void 0 : _a.Loop) !== null && _b !== void 0 ? _b : 0) + 1; i++) {
result += `<div></div>`;
}
return result;
}], [obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Subdivision), `subdivisions`, () => {
var _a, _b, _c, _d;
var result = '';
for (var l = 0; l < ((_b = (_a = obj.BeatStyle) === null || _a === void 0 ? void 0 : _a.Loop) !== null && _b !== void 0 ? _b : 0) + 1; l++) {
result += `<div class="subdivision">`;
for (var i = 0; i < ((_d = (_c = obj.BeatStyle) === null || _c === void 0 ? void 0 : _c.Subdivision) !== null && _d !== void 0 ? _d : 1); i++) {
result += `<div></div>`;
}
result += `</div>`;
}
return result;
}], [obj.BeatType === BeatsSpecial.SetRowXs, `row-xs`, () => {
var _a;
var result = '';
for (var i = 0; i < 6; i++) {
result += (((_a = obj.BeatStyle) === null || _a === void 0 ? void 0 : _a.RowXs[i]) === 'x') ? `<div class="x"></div>` : `<div></div>`;
}
return result;
}], [(obj.BeatType === BeatsSpecial.AddClassicBeat || obj.BeatType === BeatsSpecial.AddFreeTimeBeat || obj.BeatType === BeatsSpecial.PulseFreeTimeBeat) && ((_s = (_r = obj.BeatStyle) === null || _r === void 0 ? void 0 : _r.Hold) !== null && _s !== void 0 ? _s : 0) > 0, `holdbeat`, () => ''], [obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Skipshot), `skipshot`, () => ''])}</div>`;
}
else if (obj instanceof RDGroup) {
return `<div class="event group"style="${ConstructCssPropertiesIfExists(new Map([
['group-beat', obj.Style.Beat],
['group-y', obj.Style.Y],
['group-width', obj.Width],
['group-height', obj.Height],
['group-hue', obj.Style.Hue],
['group-brightness', obj.Style.Brightness],
['group-grayscale', obj.Style.Grayscale],
['group-opacity', obj.Style.Opacity],
['group-outline', ToHex(obj.Outline)],
['group-offset-beat', obj.ClickStyle.Beat],
['group-offset-y', obj.ClickStyle.Y],
['group-offset-hue', obj.ClickStyle.Hue],
['group-offset-brightness', obj.ClickStyle.Brightness],
['group-offset-grayscale', obj.ClickStyle.Grayscale],
['group-offset-opacity', obj.ClickStyle.Opacity],
['group-offset-outline', ToHex((_t = obj.ClickOutline) !== null && _t !== void 0 ? _t : obj.Outline)],
]))}">${obj.Children.map(i => ConstructDivObject(i)).join('')}</div>`;
}
else {
return '';
}
}
function ConstructCssPropertiesIfExists(pairs) {
var result = '';
for (const [key, value] of pairs) {
result += value !== undefined ? `--${key}:${value};` : ``;
}
return result;
}
function ConstructCssProperties(pairs) {
var result = '';
for (const [key, value] of pairs) {
result += `--${key}:${value};`;
}
return result;
}
function ConstructSubDiv(...pairs) {
var result = '';
for (const [key, name, func] of pairs) {
result += key ? `<div class="${name}">${func()}</div>` : ``;
}
return result;
}
function ToHex(color) {
const hex = parseInt(color.red.toFixed(0)).toString(16).padStart(2, '0') +
parseInt(color.green.toFixed(0)).toString(16).padStart(2, '0') +
parseInt(color.blue.toFixed(0)).toString(16).padStart(2, '0') +
parseInt(color.alpha.toFixed(0)).toString(16).padStart(2, '0');
return '#' + hex;
}
window.loadRDView = loadRDView;
+986
View File
@@ -0,0 +1,986 @@
var tilePosition = {
"events": {
"sounds": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "SetCrotchetsPerBar_1", "position": [0, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_2", "position": [1, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_3", "position": [2, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_4", "position": [3, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_5", "position": [4, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_6", "position": [5, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_7", "position": [6, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_8", "position": [7, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar_9", "position": [8, 1, 1, 1] },
{ "name": "SetCrotchetsPerBar", "position": [9, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_1", "position": [0, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_2", "position": [1, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_3", "position": [2, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_4", "position": [3, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_5", "position": [4, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_6", "position": [5, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_7", "position": [6, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_8", "position": [7, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_9", "position": [8, 2, 1, 1] },
{ "name": "SayReadyGetSetGo_10", "position": [9, 2, 1, 1] },
{ "name": "PlaySong", "position": [0, 3, 2, 1] },
{ "name": "PlaySound", "position": [2, 3, 1, 1] },
{ "name": "SetBeatsPerMinute", "position": [3, 3, 1, 1] },
{ "name": "SetClapSounds", "position": [4, 3, 1, 1] },
{ "name": "SetHeartExplodeVolume", "position": [5, 3, 1, 1] },
{ "name": "SetHeartExplodeInterval", "position": [6, 3, 1, 1] },
{ "name": "SetGameSound", "position": [7, 3, 1, 1] },
{ "name": "SetBeatSound", "position": [8, 3, 1, 1] },
{ "name": "SetCountingSound", "position": [9, 3, 1, 1] },
{ "name": "SayReadyGetSetGo_Rea", "position": [1, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Dy", "position": [2, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Get", "position": [3, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Set", "position": [4, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Go", "position": [5, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_Ready", "position": [10, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_And", "position": [10, 1, 1, 1] },
{ "name": "SayReadyGetSetGo_GetSetGo", "position": [11, 0, 3, 1] },
{ "name": "SayReadyGetSetGo_GetSetOne", "position": [11, 1, 3, 1] },
{ "name": "SayReadyGetSetGo_Stop", "position": [14, 0, 1, 1] },
{ "name": "SayReadyGetSetGo_AndStop", "position": [14, 1, 1, 1] },
{ "name": "SayReadyGetSetGo_ReaDyGetSetGo", "position": [10, 2, 5, 1] },
{ "name": "SayReadyGetSetGo_ReaDyGetSetOne", "position": [10, 3, 5, 1] },
{ "name": "Comment", "position": [15, 0, 1, 1] }
],
"rows": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "SetOneshotWave", "position": [1, 0, 1, 1] }
],
"actions": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "SetTheme", "position": [1, 0, 1, 1] },
{ "name": "SetVFXPreset", "position": [2, 0, 1, 1] },
{ "name": "SetBackgroundColor", "position": [3, 0, 1, 1] },
{ "name": "SetForeground", "position": [4, 0, 1, 1] },
{ "name": "SetSpeed", "position": [5, 0, 1, 1] },
{ "name": "Flash", "position": [6, 0, 1, 1] },
{ "name": "CustomFlash", "position": [7, 0, 1, 1] },
{ "name": "NewWindowDance", "position": [8, 0, 1, 1] },
{ "name": "MoveCamera", "position": [0, 1, 1, 1] },
{ "name": "PulseCamera", "position": [1, 1, 1, 1] },
{ "name": "TextExplosion", "position": [2, 1, 1, 1] },
{ "name": "ShowDialogue", "position": [3, 1, 1, 1] },
{ "name": "ShowStatusSign", "position": [4, 1, 1, 1] },
{ "name": "FloatingText", "position": [5, 1, 1, 1] },
{ "name": "AdvanceText", "position": [6, 1, 0.5, 1] },
{ "name": "ChangePlayersRows", "position": [7, 1, 1, 1] },
{ "name": "Comment", "position": [8, 1, 1, 1] },
{ "name": "FinishLevel", "position": [0, 2, 1, 1] },
{ "name": "Stutter", "position": [1, 2, 1, 1] },
{ "name": "HideRow", "position": [2, 2, 1, 1] },
{ "name": "MoveRow", "position": [3, 2, 1, 1] },
{ "name": "PlayExpression", "position": [4, 2, 1, 1] },
{ "name": "TintRows", "position": [5, 2, 1, 1] },
{ "name": "BassDrop", "position": [6, 2, 1, 1] },
{ "name": "ShakeScreen", "position": [7, 2, 1, 1] },
{ "name": "FlipScreen", "position": [0, 3, 1, 1] },
{ "name": "InvertColors", "position": [1, 3, 1, 1] },
{ "name": "ShowHands", "position": [2, 3, 1, 1] },
{ "name": "PaintHands", "position": [3, 3, 1, 1] },
{ "name": "SetHandOwner", "position": [4, 3, 1, 1] },
{ "name": "SetPlayStyle", "position": [5, 3, 1, 1] },
{ "name": "TagAction", "position": [6, 3, 1, 1] },
{ "name": "CallCustomMethod", "position": [7, 3, 1, 1] }
],
"decorations": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "PlayAnimation", "position": [1, 0, 1, 1] },
{ "name": "Tint", "position": [0, 1, 1, 1] },
{ "name": "Comment", "position": [1, 1, 1, 1] },
{ "name": "SetVisible", "position": [0, 2, 1, 1] },
{ "name": "Move", "position": [0, 3, 1, 1] }
],
"rooms": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "MoveRoom", "position": [0, 1, 1, 1] },
{ "name": "FadeRoom", "position": [0, 2, 1, 1] },
{ "name": "MaskRoom", "position": [0, 3, 1, 1] },
{ "name": "ShowRooms", "position": [1, 0, 1, 4] },
{ "name": "ReorderRooms", "position": [2, 0, 1, 4] },
{ "name": "SetRoomContentMode", "position": [3, 0, 1, 1] },
{ "name": "SetRoomPerspective", "position": [3, 1, 1, 1] },
{ "name": "Comment", "position": [3, 2, 1, 1] }
],
"custom": [
{ "name": "Empty", "position": [0, 0, 1, 1] },
{ "name": "Comment", "position": [0, 1, 1, 1] }
],
"beatsSpecial": [
"AddClassicBeat",
"AddOneshotBeat",
"AddFreeTimeBeat",
"PulseFreeTimeBeat",
"SetRowXs"
]
}
}
function loadRDView() {
(window as any).RDViewRender = RDViewRender;
}
class Color {
readonly red: number;
readonly green: number;
readonly blue: number;
readonly alpha: number;
constructor(red: number, green: number, blue: number, alpha: number) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
};
}
enum EventType {
sounds = "sounds",
rows = "rows",
actions = "actions",
decorations = "decorations",
rooms = "rooms",
custom = "custom",
}
enum BeatsSpecial {
AddClassicBeat,
AddFreeTimeBeat,
PulseFreeTimeBeat,
AddOneshotBeat,
SetRowXs,
}
enum EventCondition {
true = "true",
false = "false",
both = "both",
}
class RDViewWindow {
Objects: (RDEvent | RDGroup)[] = [];
Row: number = 4;
Column: number = 8;
Scale: number = 1;
}
class RDEvent {
SubType: EventType = EventType.custom;
BeatType?: BeatsSpecial = undefined;
BeatStyle?: RDBeatStyle;
Width: number = 1;
Height: number = 1;
EventX: number = 0;
EventY: number = 0;
Style: RDStyle = { Beat: 0, Y: 0 };
ClickStyle?: RDStyle;
Condition?: EventCondition;
Tag?: boolean;
Description?: RDDescription;
}
class RDDescription {
Width: number = 4;
Lines: RDDescriptionLine[] = [];
}
class RDDescriptionLine {
BoxCount: number = 1;
IconCount: number = 0;
Items: (RDDescriptionText | RDDescriptionBox | RDDescriptionIcon)[] = [];
}
class RDDescriptionText {
Middle?: boolean;
Hoverable?: boolean;
FGray?: boolean;
Highlight?: boolean;
Text: string = "";
}
class RDDescriptionBox {
Items: (RDDescriptionBoxButton | RDDescriptionBoxInput | RDDescriptionBoxScroll | RDDescriptionBoxSelect)[] = [];
}
class RDDescriptionBoxInput {
Tips?: string = "";
Middle?: boolean;
FGray?: boolean;
BlackBack?: boolean;
Highlight?: boolean;
Text: string = "";
}
class RDDescriptionBoxScroll {
Scroll: number = 0;
}
class RDDescriptionBoxButton {
Middle?: boolean;
Active?: boolean;
GrayBack?: boolean;
Highlight?: boolean;
Text: string = "";
}
class RDDescriptionBoxSelect {
Items: string[] = [];
SelectedIndex: number = 0;
}
class RDDescriptionIcon {
}
class RDStyle {
Beat: number = 0;
Y: number = 0;
Brightness?: number;
Hue?: number;
Grayscale?: number;
Opacity?: number;
}
class RDBeatStyle {
Tick?: number;
OneshotBeatSubType: RDOneshotBeatSubType[] = [];
Interval?: number;
Delay?: number;
Subdivision?: number;
Swing?: number;
Hold?: number;
Pulse?: number;
RowXs: string = '------';
Loop?: number;
}
enum RDOneshotBeatSubType {
Freezeshot,
Burnshot,
Skipshot,
Subdivision,
}
class RDGroup {
Width: number = 1;
Height: number = 1;
Outline: Color = new Color(255, 0, 0, 255);
Style: RDStyle = new RDStyle();
ClickStyle: RDStyle = new RDStyle();
ClickOutline?: Color;
Children: (RDEvent | RDGroup)[] = [];
}
function RDViewRender(lang: string, code: string): string {
const lines: string[] = code.split('\n');
const window: RDViewWindow = new RDViewWindow();
var objs: (RDEvent | RDGroup)[] = [];
try {
window.Objects = ReadObjs(code);
} catch (error) {
return errorHtml(`${error}`);
}
const args = lang.split(/\s+/g);
if (1 < args.length && args.length <= 4) {
if (args[1]) {
window.Column = parseInt(args[1]);
}
if (args[2]) {
window.Row = parseInt(args[2]);
}
if (args[3]) {
window.Scale = parseFloat(args[3]);
}
}
return ConstructObjs(window);
}
function errorHtml(message: string = ""): string {
return `<div class="RDView" style="--row:1;--column:0;"><div class="event actions" style="--beat:0;--y:0"><div class="description" style="--width:12;">${message.length ? `${message}` : ""}</div></div></div>`;
}
function ReadObjs(line: string): (RDEvent | RDGroup)[] {
const objs: (RDEvent | RDGroup)[] = [];
var reader = new Reader(line);
while (!reader.IsEnd()) {
var event: (RDEvent | RDGroup);
try {
const type = reader.ReadSymbol().toLowerCase();
event = ReadType(type);
}
catch (e) {
event = new RDEvent();
}
if (event instanceof RDEvent) {
reader.TestRead('.', true);
const name = reader.ReadSymbol();
var collection;
switch (event.SubType) {
case EventType.sounds:
collection = tilePosition.events.sounds;
break;
case EventType.rows:
collection = tilePosition.events.rows;
switch (name) {
case 'AddClassicBeat':
event.BeatType = BeatsSpecial.AddClassicBeat;
break;
case 'AddFreeTimeBeat':
event.BeatType = BeatsSpecial.AddFreeTimeBeat;
break;
case 'PulseFreeTimeBeat':
event.BeatType = BeatsSpecial.PulseFreeTimeBeat;
break;
case 'AddOneshotBeat':
event.BeatType = BeatsSpecial.AddOneshotBeat;
break;
case 'SetRowXs':
event.BeatType = BeatsSpecial.SetRowXs;
break;
default:
break;
}
break;
case EventType.actions:
collection = tilePosition.events.actions;
break;
case EventType.decorations:
collection = tilePosition.events.decorations;
break;
case EventType.rooms:
collection = tilePosition.events.rooms;
break;
case EventType.custom:
collection = tilePosition.events.custom;
break;
default:
collection = tilePosition.events.custom;
break;
}
const pos = collection.filter(i => i.name.toLowerCase() === name.toLowerCase())[0];
if (pos) {
event.EventX = pos.position[0];
event.EventY = pos.position[1];
event.Width = pos.position[2];
event.Height = pos.position[3];
}
try { event.Style.Beat = reader.ReadFloat(); } catch (e) { }
try { event.Style.Y = reader.ReadInt(); } catch (e) { }
if (reader.TestPeek('[')) {
const pairString: string = reader.ReadQuoted('[', ']');
const keyvalues = new Reader(pairString, reader).ReadPairs();
ReadProperties(reader, event, keyvalues);
}
reader.TestRead(';', true);
}
else if (event instanceof RDGroup) {
try { event.Style.Beat = reader.ReadFloat(); } catch (e) { }
try { event.Style.Y = reader.ReadInt(); } catch (e) { }
try { event.Width = reader.ReadFloat(); } catch (e) { }
try { event.Height = reader.ReadInt(); } catch (e) { }
try { event.Outline = reader.ReadColor(); } catch (e) { }
if (reader.TestPeek('[')) {
const pairString: string = reader.ReadQuoted('[', ']');
const keyvalues = new Reader(pairString, reader).ReadPairs();
ReadProperties(reader, event, keyvalues);
}
if (reader.TestPeek('{')) {
const pairString: string = reader.ReadQuoted('{', '}');
const objs2 = ReadObjs(pairString);
event.Children = objs2;
}
reader.TestRead(';', true);
}
objs.push(event);
}
return objs;
}
interface KeyValuePair {
Index: number;
Key: string;
Value: string;
}
function IsEmptyOrSpace(string: string): boolean {
return (string) ? /\s/.test(string) : false;
}
class Reader {
private string: string;
private position: number = 0;
private line: number = 0;
private offl: number = 0;
private offp: number = 0;
constructor(string: string, reader: Reader | undefined = undefined) {
this.string = string;
if (reader) {
this.offl = reader.line;
this.offp = reader.position;
}
};
public IsEnd(): boolean {
this.JumpSpace();
return this.position >= this.string.length;
}
private JumpSpace(): void {
while (IsEmptyOrSpace(this.string[this.position])) {
if (this.string[this.position] === '\n') {
this.line++;
}
this.position++;
}
}
public Peek(): string {
this.JumpSpace();
return this.string[this.position];
}
public TestPeek(str: string, allowThrow: boolean = false): boolean {
this.JumpSpace();
var c = this.string.substring(this.position, this.position + str.length);
if (c === str) {
return true;
}
else {
if (allowThrow) {
throw new Error(`Expecting a string '${str}' but got '${c}': ${this.GetPositionDescription()}.`);
}
else {
return false;
}
}
}
public TestRead(str: string, allowThrow: boolean = false): boolean {
this.JumpSpace();
var c = this.string.substring(this.position, this.position + str.length);
if (c === str) {
this.position++;
return true;
}
else {
if (allowThrow) {
throw new Error(`Expecting a char '${str}' but got '${c}': ${this.GetPositionDescription()}.`);
}
else {
return false;
}
}
}
public ReadChar(): string {
var c = this.string[this.position];
if (c === '\n') {
this.line++;
}
this.position++;
return c;
}
public ReadSymbol(): string {
this.JumpSpace();
var name = this.string.substring(this.position).match(/^\w+/)?.[0];
if (name) {
this.position += name.length;
return name;
}
throw new Error(`Expecting a key but missing: ${this.GetPositionDescription()}.`);
}
public ReadColor(): Color {
this.JumpSpace();
var color = this.string.substring(this.position).match(/^#[0-9A-Fa-f]{3}([0-9A-Fa-f]{1}([0-9A-Fa-f]{2}([0-9A-Fa-f]{2})?)?)?/)?.[0].substring(1);
if (!color) {
throw new Error(`Expecting a color but missing: ${this.GetPositionDescription()}`);
}
var result: Color;
switch (color.length) {
case 3:
result = new Color(
parseInt(color.substring(0, 1), 16) * 16,
parseInt(color.substring(1, 2), 16) * 16,
parseInt(color.substring(2, 3), 16) * 16,
255
);
break;
case 4:
result = new Color(
parseInt(color.substring(0, 1), 16) * 16,
parseInt(color.substring(1, 2), 16) * 16,
parseInt(color.substring(2, 3), 16) * 16,
parseInt(color.substring(3, 4), 16) * 16
);
break;
case 6:
result = new Color(
parseInt(color.substring(0, 2), 16),
parseInt(color.substring(2, 4), 16),
parseInt(color.substring(4, 6), 16),
255
);
break;
case 8:
result = new Color(
parseInt(color.substring(0, 2), 16),
parseInt(color.substring(2, 4), 16),
parseInt(color.substring(4, 6), 16),
parseInt(color.substring(6, 8), 16)
);
break;
default:
result = new Color(255, 0, 0, 255);
break;
}
this.position += color.length + 1;
return result;
}
public ReadInt(): number {
this.JumpSpace();
var name = this.string.substring(this.position).match(/^[+-]?[0-9]+/)?.[0];
if (name) {
this.position += name.length;
return parseInt(name);
}
throw new Error(`Expecting an int but missing: ${this.GetPositionDescription()}.`);
}
public ReadFloat(): number {
this.JumpSpace();
var name = this.string.substring(this.position).match(/^[+-]?([0-9]*[.])?[0-9]+/)?.[0];
if (name) {
this.position += name.length;
return parseFloat(name);
}
throw new Error(`Expecting a float but missing: ${this.GetPositionDescription()}.`);
}
public ReadPairs(separator: string = ',', equals: string = '='): KeyValuePair[] {
var pairs: KeyValuePair[] = [];
var flag: boolean = !this.IsEnd();
while (flag) {
if (this.IsEnd()) {
break;
}
const index = this.position + this.offp;
const name = this.ReadSymbol();
this.TestRead(equals, true);
const value = this.ReadWhileNotEnd([separator]);
pairs.push({ Key: name, Value: value, Index: index });
if (flag = !this.IsEnd()) {
this.TestRead(separator, true);
}
}
return pairs;
}
public ReadWhileNotEnd(ends: string[] = [',', ']']): string {
var str: string = '';
while (!(this.position >= this.string.length) && !ends.find(i => this.string.startsWith(i, this.position))) {
str += this.string[this.position];
this.position++;
}
return str.trim();
}
public ReadQuoted(left: string, right: string): string {
this.JumpSpace();
var level: number = 0;
var result = '';
if (this.string.startsWith(left, this.position)) { level++; this.position += left.length; }
else { throw new Error(`Cannot find the left half "${left}": ${this.GetPositionDescription()}`); }
while (!(this.position >= this.string.length) && level > 0) {
if (this.string.startsWith(left, this.position)) {
level++;
this.position += left.length;
result += left;
}
if (this.string.startsWith(right, this.position)) {
level--;
this.position += right.length;
if (level === 0) {
return result;
}
else {
result += right;
}
}
result += this.string[this.position];
this.position++;
}
throw new Error(`Cannot find the right half "${right}": ${this.GetPositionDescription()}`);
}
public GetPositionDescription(position: number | undefined = undefined): string {
const s = this.string.split('\n');
var curp: number = this.offp;
var line: number = this.offl;
if (position !== undefined) {
while (curp + s[line].length + 1 < position - this.offp) {
curp += s[line].length + 1;
line += 1;
}
}
else {
curp += s.slice(0, this.line).reduce((sum, i) => sum + i.length + 1, 0);
line += this.line;
position = this.position;
}
return `<br>at "${s[line]}".`;//, at ${line + 1}:${position - curp}`;
}
}
function FindValue(pairs: KeyValuePair[], key: string): KeyValuePair | undefined {
const finded = pairs.find(i => i.Key === key);
if (finded) {
return finded;
}
return undefined;
}
function ReadType(typename: string): (RDEvent | RDGroup) {
var t: EventType = EventType.custom;
var event: RDEvent | RDGroup;
switch (typename[0]) {
case 'e':
event = new RDEvent();
switch (typename[1]) {
case 's':
t = EventType.sounds;
break;
case 'b':
t = EventType.rows;
break;
case 'a':
t = EventType.actions;
break;
case 'd':
t = EventType.decorations;
break;
case 'r':
t = EventType.rooms;
break;
case 'c':
t = EventType.custom;
break;
default:
t = EventType.custom;
}
event.SubType = t;
break;
case 'g':
event = new RDGroup();
break;
default:
event = new RDEvent();
}
return event;
}
function ReadProperties(reader: Reader, event: RDEvent | RDGroup, pairs: KeyValuePair[]) {
if (event instanceof RDGroup) {
if (value = FindValue(pairs, "hue")) {
try {
event.Style.Hue = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "brightness")) {
try {
event.Style.Brightness = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "grayscale")) {
try {
event.Style.Grayscale = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "opacity")) {
try {
event.Style.Opacity = parseFloat(value.Value);
}
catch (e) {
throw new Error(`Expecting a number, but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "offset")) {
reader = new Reader(value.Value);
event.ClickStyle ??= new RDStyle();
try { event.ClickStyle.Beat = reader.ReadFloat(); } catch (e) { }
try { event.ClickStyle.Y = reader.ReadInt(); } catch (e) { }
try { event.ClickOutline = reader.ReadColor(); } catch (e) { }
}
if (value = FindValue(pairs, "offset_hue")) {
event.ClickStyle ??= new RDStyle();
event.ClickStyle.Hue = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_brightness")) {
event.ClickStyle ??= new RDStyle();
event.ClickStyle.Brightness = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_grayscale")) {
event.ClickStyle ??= new RDStyle();
event.ClickStyle.Grayscale = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_opacity")) {
event.ClickStyle ??= new RDStyle();
event.ClickStyle.Opacity = parseFloat(value.Value);
}
}
else if (event instanceof RDEvent) {
var value: KeyValuePair | undefined;
if (value = FindValue(pairs, "if")) {
if (["true", "false", "both"].find(i => i === value?.Value)) {
event.Condition = value.Value === "true" ? EventCondition.true :
value.Value === "false" ? EventCondition.false : EventCondition.both;
}
else {
throw new Error(`Expecting "true", "false" or "both", but find "${value.Value}".`);
}
}
if (value = FindValue(pairs, "tag")) {
event.Tag = value.Value === "true" ? true : false;
}
if (value = FindValue(pairs, "hue")) {
event.Style.Hue = parseFloat(value.Value);
}
if (value = FindValue(pairs, "brightness")) {
event.Style.Brightness = parseFloat(value.Value);
}
if (value = FindValue(pairs, "grayscale")) {
event.Style.Grayscale = parseFloat(value.Value);
}
if (value = FindValue(pairs, "opacity")) {
event.Style.Opacity = parseFloat(value.Value);
}
event.ClickStyle ??= new RDStyle();
if (value = FindValue(pairs, "offset")) {
reader = new Reader(value.Value);
try { event.ClickStyle.Beat = reader.ReadFloat(); } catch (e) { }
try { event.ClickStyle.Y = reader.ReadInt(); } catch (e) { }
}
if (value = FindValue(pairs, "offset_hue")) {
event.ClickStyle.Hue = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_brightness")) {
event.ClickStyle.Brightness = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_grayscale")) {
event.ClickStyle.Grayscale = parseFloat(value.Value);
}
if (value = FindValue(pairs, "offset_opacity")) {
event.ClickStyle.Opacity = parseFloat(value.Value);
}
if (event.BeatType !== undefined) {
event.BeatStyle = new RDBeatStyle();
if (value = FindValue(pairs, "tick")) {
event.BeatStyle.Tick = parseFloat(value.Value);
}
switch (event.BeatType) {
case BeatsSpecial.AddClassicBeat:
if (value = FindValue(pairs, "swing")) {
event.BeatStyle.Swing = parseFloat(value.Value);
}
if (value = FindValue(pairs, "hold")) {
event.BeatStyle.Hold = parseFloat(value.Value);
}
break;
case BeatsSpecial.AddFreeTimeBeat:
if (value = FindValue(pairs, "pulse")) {
event.BeatStyle.Pulse = parseFloat(value.Value);
}
if (value = FindValue(pairs, "hold")) {
event.BeatStyle.Hold = parseFloat(value.Value);
}
break;
case BeatsSpecial.PulseFreeTimeBeat:
if (value = FindValue(pairs, "pulse")) {
event.BeatStyle.Pulse = parseFloat(value.Value);
}
if (value = FindValue(pairs, "hold")) {
event.BeatStyle.Hold = parseFloat(value.Value);
}
break;
case BeatsSpecial.SetRowXs:
if ((value = FindValue(pairs, "rowxs"))) {
if (value.Value.match(/^[-x]{6}$/)) {
event.BeatStyle.RowXs = value.Value;
}
else {
throw new Error(`Expect a string of length 6, consisting of "x" and "-", instead of "${value?.Value}".`);
}
}
break;
case BeatsSpecial.AddOneshotBeat:
if (value = FindValue(pairs, "type")) {
const types: string[] = value.Value.split(/\s+/);
var illegal: string[] | undefined;
if ((illegal = types.filter(i => {
![
"freezeshot",
"burnshot",
"skipshot",
"subdivision"
].includes(i);
})).length) {
throw new Error(`Expecting "freezeshot", "burnshot", "skipshot" or "subdivision", but find ${illegal.map(i => `"${i}"`).join(', ')}.`);
}
else {
types.map(i => {
switch (i) {
case "freezeshot":
event.BeatStyle?.OneshotBeatSubType.push(RDOneshotBeatSubType.Freezeshot);
break;
case "burnshot":
event.BeatStyle?.OneshotBeatSubType.push(RDOneshotBeatSubType.Burnshot);
break;
case "skipshot":
event.BeatStyle?.OneshotBeatSubType.push(RDOneshotBeatSubType.Skipshot);
break;
case "subdivision":
event.BeatStyle?.OneshotBeatSubType.push(RDOneshotBeatSubType.Subdivision);
break;
}
});
}
}
if (value = FindValue(pairs, "interval")){
event.BeatStyle.Interval = parseFloat(value.Value);
}
if ((value = FindValue(pairs, "delay"))
&& event.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Freezeshot)) {
event.BeatStyle.Delay = parseFloat(value.Value);
}
if ((value = FindValue(pairs, "subdivision"))
&& event.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Subdivision)) {
event.BeatStyle.Subdivision = parseFloat(value.Value);
}
if (value = FindValue(pairs, "loop")) {
event.BeatStyle.Loop = parseInt(value.Value);
}
break;
default:
break;
}
}
}
}
function ConstructObjs(window: RDViewWindow) {
var html: string = `<div class="RDViewContent" style="--column:${window.Column};--row:${window.Row};--scale:${window.Scale};">`
+`<div class="RDView" style="--column:${window.Column};--row:${window.Row};--scale:${window.Scale};">`;
for (var obj of window.Objects) {
html += ConstructDivObject(obj);
}
html += `</div></div>`;
return html;
}
function ConstructDivObject(obj: RDEvent | RDGroup): string {
if (obj instanceof RDEvent) {
return `<div class="event ${obj.BeatType === undefined ? `${obj.SubType}` : 'beat'}"style="${ConstructCssPropertiesIfExists(
new Map<string, any>([
['beat', obj.Style.Beat],
['y', obj.Style.Y],
['event-x', obj.EventX],
['event-y', obj.EventY],
['event-width', obj.Width],
['event-height', obj.Height],
['hue', obj.Style.Hue],
['brightness', obj.Style.Brightness],
['grayscale', obj.Style.Grayscale],
['opacity', obj.Style.Opacity],
['offset-beat', obj.ClickStyle?.Beat],
['offset-y', obj.ClickStyle?.Y],
['offset-hue', obj.ClickStyle?.Hue],
['offset-brightness', obj.ClickStyle?.Brightness],
['offset-grayscale', obj.ClickStyle?.Grayscale],
['offset-opacity', obj.ClickStyle?.Opacity],
['tick', obj.BeatStyle?.Tick],
['delay', obj.BeatStyle?.Delay],
['interval', obj.BeatStyle?.Interval],
['subdivision', obj.BeatStyle?.Subdivision],
['hold', obj.BeatStyle?.Hold],
['pulse', obj.BeatStyle?.Pulse],
['swing', obj.BeatStyle?.Swing],
['loop', obj.BeatStyle?.Loop],
]))
}">${ConstructSubDiv(
[obj.Condition !== undefined, `condition-${obj.Condition}`, () => ''],
[obj.Tag === true, `tag`, () => ''],
[obj.BeatType === BeatsSpecial.AddClassicBeat, `classicbeat`, () => {
var result: string = '';
for (var i = 0; i < 6; i++) {
result += `<div></div>`;
}
return result;
}],
[obj.BeatType === BeatsSpecial.AddFreeTimeBeat, `add freetime`, () => {return '';}],
[obj.BeatType === BeatsSpecial.PulseFreeTimeBeat, `pulse freetime`, () => ''],
[obj.BeatStyle?.Loop !== undefined && obj.BeatStyle.Loop > 0, `loop`, () => {
var result: string = '';
for (var i = 0; i < (obj.BeatStyle?.Loop ?? 0); i++) {
result += `<div></div>`;
}
return result;
}],
[obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Freezeshot), `freezeshots`, () => {
var result: string = '';
for (var i = 0; i < (obj.BeatStyle?.Loop ?? 0) + 1; i++) {
result += `<div></div>`;
}
return result;
}],
[obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Burnshot), `burnshots`, () => {
var result: string = '';
for (var i = 0; i < (obj.BeatStyle?.Loop ?? 0) + 1; i++) {
result += `<div></div>`;
}
return result;
}],
[obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Subdivision), `subdivisions`, () => {
var result: string = '';
for(var l = 0; l < (obj.BeatStyle?.Loop ?? 0) + 1; l++){
result += `<div class="subdivision">`;
for (var i = 0; i < (obj.BeatStyle?.Subdivision ?? 1); i++) {
result += `<div></div>`;
}
result += `</div>`;
}
return result;
}],
[obj.BeatType === BeatsSpecial.SetRowXs, `row-xs`, () => {
var result: string = '';
for (var i = 0; i < 6; i++) {
result += (obj.BeatStyle?.RowXs[i] === 'x') ? `<div class="x"></div>` : `<div></div>`;
}
return result;
}],
[(obj.BeatType === BeatsSpecial.AddClassicBeat || obj.BeatType === BeatsSpecial.AddFreeTimeBeat || obj.BeatType === BeatsSpecial.PulseFreeTimeBeat) && (obj.BeatStyle?.Hold ?? 0) > 0, `holdbeat`, () => ''],
[obj.BeatType === BeatsSpecial.AddOneshotBeat && obj.BeatStyle !== undefined && obj.BeatStyle.OneshotBeatSubType.includes(RDOneshotBeatSubType.Skipshot), `skipshot`, () => ''],
)}</div>`;
}
else if (obj instanceof RDGroup) {
return `<div class="event group"style="${ConstructCssPropertiesIfExists(
new Map<string, any>([
['group-beat', obj.Style.Beat],
['group-y', obj.Style.Y],
['group-width', obj.Width],
['group-height', obj.Height],
['group-hue', obj.Style.Hue],
['group-brightness', obj.Style.Brightness],
['group-grayscale', obj.Style.Grayscale],
['group-opacity', obj.Style.Opacity],
['group-outline', ToHex(obj.Outline)],
['group-offset-beat', obj.ClickStyle.Beat],
['group-offset-y', obj.ClickStyle.Y],
['group-offset-hue', obj.ClickStyle.Hue],
['group-offset-brightness', obj.ClickStyle.Brightness],
['group-offset-grayscale', obj.ClickStyle.Grayscale],
['group-offset-opacity', obj.ClickStyle.Opacity],
['group-offset-outline', ToHex(obj.ClickOutline??obj.Outline)],
])
)}">${obj.Children.map(i => ConstructDivObject(i)).join('')}</div>`;
}
else { return ''; }
}
function ConstructCssPropertiesIfExists(pairs: Map<string, any>): string {
var result: string = '';
for (const [key, value] of pairs) {
result += value !== undefined ? `--${key}:${value};` : ``;
}
return result;
}
function ConstructCssProperties(pairs: Map<string, any>): string {
var result: string = '';
for (const [key, value] of pairs) {
result += `--${key}:${value};`;
}
return result;
}
function ConstructSubDiv(...pairs: [shouldDo: boolean, name: string, func: () => string][]) {
var result: string = '';
for (const [key, name, func] of pairs) {
result += key ? `<div class="${name}">${func()}</div>` : ``;
}
return result;
}
function ToHex(color: Color) {
const hex =
parseInt(color.red.toFixed(0)).toString(16).padStart(2, '0') +
parseInt(color.green.toFixed(0)).toString(16).padStart(2, '0') +
parseInt(color.blue.toFixed(0)).toString(16).padStart(2, '0') +
parseInt(color.alpha.toFixed(0)).toString(16).padStart(2, '0');
return '#' + hex;
}
(window as any).loadRDView = loadRDView;
+1
View File
File diff suppressed because one or more lines are too long
+207
View File
@@ -0,0 +1,207 @@
let curx = 0;
let cury = 0;
let rowx;
let columny;
let positions = {
"c1": { "x": 64, "name": "第一拍" },
"c2": { "x": 88, "name": "第单发拍" },
"c3": { "x": 112, "name": "第三拍" },
"c4": { "x": 136, "name": "第四拍" },
"c5": { "x": 160, "name": "第五拍" },
"c6": { "x": 184, "name": "第六拍" },
"c7": { "x": 249, "name": "第普通拍" },
"ccharacter": { "x": 35, "name": "角色" },
"ccenter": { "x": 176, "name": "中心" },
"cheart": { "x": 317, "name": "心" },
"r1": { "y": 162, "name": "四轨时的第一轨" },
"r2": { "y": 141, "name": "三轨时的第一轨" },
"r3": { "y": 120, "name": "二轨时的第一轨/四轨时的第二轨" },
"r4": { "y": 99, "name": "一轨时的第一轨/三轨时的第二轨" },
"r5": { "y": 78, "name": "二轨时的第二轨/四轨时的第三轨" },
"r6": { "y": 57, "name": "三轨时的第三轨" },
"r7": { "y": 36, "name": "四轨时的第四轨" },
}
function themePosition() {
let theme_positions = document.getElementById("theme-positions");
if (!theme_positions) return;
let perx = theme_positions.querySelector(".per>span.x");
let pery = theme_positions.querySelector(".per>span.y");
let pxx = theme_positions.querySelector(".px>span.x");
let pxy = theme_positions.querySelector(".px>span.y");
let infobox = theme_positions.querySelector(".infobox");
let selectbox = theme_positions.querySelector(".selectbox");
let other = theme_positions.querySelector(".other");
perx.innerText = "100%";
pery.innerText = "100%";
pxx.innerText = "352px";
pxy.innerText = "198px";
infobox.style.right = "calc(10px)";
infobox.style.top = "calc(10px)";
selectbox.style.left = "50%";
selectbox.style.bottom = "50%";
selectbox.style.width = "0";
selectbox.style.height = "0";
other.innerText = "";
theme_positions.addEventListener("mouseenter", function (event) {
});
theme_positions.addEventListener("mousemove", function (event) {
let x = event.clientX - theme_positions.getBoundingClientRect().left;
let y = event.clientY - theme_positions.getBoundingClientRect().top;
let width = theme_positions.offsetWidth;
let height = theme_positions.offsetHeight;
let x_percent = parseFloat(((x / width) * 100).toFixed(2));
let y_percent = parseFloat(((y / height) * 100).toFixed(2));
x = parseFloat((x_percent * 3.52).toFixed(0));
y = parseFloat((y_percent * 1.98).toFixed(0));
rowx = null;
columny = null;
for (let key in positions) {
if (positions[key].x !== null && Math.abs(x - positions[key].x) < 5)
rowx = positions[key].x;
if (positions[key].y !== null && Math.abs(y - positions[key].y) < 5)
columny = positions[key].y;
}
if (rowx) {
perx.innerText = (rowx / 3.52).toFixed(2) + "%"
perx.classList.add("c")
pxx.innerText = rowx + "px"
pxx.classList.add("c")
}
else {
perx.innerText = x_percent.toFixed(2) + "%"
perx.classList.remove("c")
pxx.innerText = x + "px"
pxx.classList.remove("c")
}
if (columny) {
pery.innerText = (100 - columny / 1.98).toFixed(2) + "%"
pery.classList.add("c")
pxy.innerText = 198 - columny + "px"
pxy.classList.add("c")
}
else {
pery.innerText = (100 - y_percent).toFixed(2) + "%"
pery.classList.remove("c")
pxy.innerText = 198 - y + "px"
pxy.classList.remove("c")
}
infobox.style.right = "calc(" + (100 - x_percent) + "% + 10px)";
infobox.style.top = "calc(" + (y_percent) + "% + 10px)";
selectbox.style.left = rowx ? (rowx / 3.52 - 3.41) + "%" : columny ? "0" : "calc(" + x_percent + "% - 3px";
selectbox.style.bottom = columny ? (100 - columny / 1.98 - 5.305) + "%" : rowx ? "0" : "calc(" + (100 - y_percent) + "% - 3px)";
selectbox.style.width = rowx ? "6.82%" : columny ? "100%" : "6px";
selectbox.style.height = columny ? "10.61%" : rowx ? "100%" : "6px";
let rowname = rowx ? positions[Object.keys(positions).find(key => positions[key].x === rowx)].name : "";
let columnname = columny ? positions[Object.keys(positions).find(key => positions[key].y === columny)].name : "";
theme_positions.querySelector(".other").innerText = rowname && columnname ? columnname + "上的" + rowname : rowname ? rowname : columnname ? columnname : "";
});
theme_positions.addEventListener("mouseleave", function (event) {
perx.innerText = "100%";
pery.innerText = "100%";
pxx.innerText = "352px";
pxy.innerText = "198px";
infobox.style.right = "calc(10px)";
infobox.style.top = "calc(10px)";
selectbox.style.left = "50%";
selectbox.style.bottom = "50%";
selectbox.style.width = "0";
selectbox.style.height = "0";
perx.classList.remove("c")
pery.classList.remove("c")
pxx.classList.remove("c")
pxy.classList.remove("c")
other.innerText = "";
});
}
function rdview() {
let rdview = document.getElementsByClassName("rdview")[0];
if (!rdview) return;
let rdcanvas = rdview.querySelector(".canvas");
let textarea = rdview.querySelector("textarea.area");
let number = rdview.querySelector(".number");
const textareaStyles = window.getComputedStyle(textarea);
[
'fontFamily', 'fontSize', 'fontWeight',
'letterSpacing', 'lineHeight', 'padding',
].forEach(property => {
number.style[property] = textareaStyles[property];
});
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const font = `${textareaStyles.fontSize} ${textareaStyles.fontFamily}`;
context.font = font;
function calcStringLines(sentence, width) {
if (!width) return 0;
const words = sentence.split('');
let lineCount = 0;
let currentLine = '';
for (let i = 0; i < words.length; i++) {
const wordWidth = context.measureText(words[i]).width;
const lineWidth = context.measureText(currentLine).width;
if (lineWidth + wordWidth > width) {
lineCount++;
currentLine = words[i];
} else {
currentLine += words[i];
}
}
if (currentLine.trim() !== '') lineCount++;
return lineCount;
}
function calcLines() {
const lines = textarea.value.split('\n');
const textareaWidth = textarea.getBoundingClientRect().width;
const textareaScrollWidth = textareaWidth - textarea.clientWidth;
const parseNumber = (v) => v.endsWith('px') ? parseInt(v.slice(0, -2), 10) : 0;
const textareaPaddingLeft = parseNumber(textareaStyles.paddingLeft);
const textareaPaddingRight = parseNumber(textareaStyles.paddingRight);
const textareaContentWidth = textareaWidth - textareaPaddingLeft - textareaPaddingRight - textareaScrollWidth;
const numLines = lines.map(lineString => calcStringLines(lineString, textareaContentWidth));
let lineNumbers = [];
let i = 1;
while (numLines.length > 0) {
const numLinesOfSentence = numLines.shift();
lineNumbers.push(i);
if (numLinesOfSentence > 1) {
Array(numLinesOfSentence - 1)
.fill('')
.forEach((_) => lineNumbers.push(''));
}
i++;
}
return lineNumbers;
}
function initLineNumbers() {
const lines = calcLines();
const lineDoms = Array.from({
length: lines.length,
}, (_, i) => `<div>${lines[i] || '&nbsp;'}</div>`);
number.innerHTML = lineDoms.join('');
}
function initCanvas() {
const lang = textarea.value.split('\n')[0]
const code = textarea.value.split('\n').slice(1).join('\n')
rdcanvas.innerHTML = RDViewRender(lang, code)
}
initCanvas()
initLineNumbers()
textarea.addEventListener('input', initLineNumbers);
textarea.addEventListener('input', initCanvas);
}
window.$docsify.plugins = [].concat(window.$docsify.plugins, function (hook) {
hook.doneEach(function () {
themePosition();
rdview();
document.documentElement.scrollTop = document.body.scrollTop = 0;
});
});
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="_图层_1" data-name="图层_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 24 24">
<!-- Generator: Adobe Illustrator 29.0.0, SVG Export Plug-In . SVG Version: 2.1.0 Build 186) -->
<defs>
<style>
.st0 {
fill: none;
stroke: #040000;
stroke-miterlimit: 10;
stroke-width: .8px;
}
</style>
</defs>
<path class="st0" d="M17.5,12.9c0,1-.1,1.8-1,1.8s-1.6-.8-1.6-1.8.7-1.8,1.6-1.8,1,.8,1,1.8Z"/>
<path class="st0" d="M17.5,19.1c0,1-.1,1.8-1,1.8s-1.6-.8-1.6-1.8.7-1.8,1.6-1.8,1,.8,1,1.8Z"/>
<path class="st0" d="M6.7,9.4c-.8-.6-1.3-3.4-1.2-3.8,0-.3,2.9-.3,3.4-.1"/>
<path class="st0" d="M12.6,4.2c.2-.3,2.2-2.2,2.7-2.2s1.2,3.2,1.3,3.8"/>
<path class="st0" d="M9.9,16.7c.3-.8,1.1-1.1,1.5-1.1,1.3,0,2.9-.4,4.3-1.2"/>
<path class="st0" d="M8.7,21.6c0,0,0,.2,0,.3-.1.5.4,1.2,1,1.4,2.5.8,7.2-1,7.2-1"/>
<path class="st0" d="M12.7,18.2c0,.8,0,1-.3,1.6"/>
<path class="st0" d="M11.3,20.3c.3-.2.6-.4,1.1-.5.9-.2,2-.5,2.5-.6,0,0,0-.1,0-.2,0-1,.7-1.8,1.6-1.8s.2,0,.3,0v-2.9c0,0-.2,0-.3,0-.3,0-.5,0-.7-.2-.4-.2-.7-.6-.8-1.1,0-.1,0-.3,0-.4,0-1,.7-1.8,1.6-1.8s.2,0,.3,0"/>
<path class="st0" d="M16.5,5.9s0,5.2,0,5.2c-.6-.5-.8-1.1-1.2-1.7,0,0,0-.1-.1-.2-.1-.2-.2-.4-.3-.5,0,0-.1-.2-.2-.3-.1-.2-.2-.4-.3-.6h0c0-.1,0-.1,0-.2,0-.1-.1-.2-.2-.3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.1-.1-.2-.2-.3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.2,0,.6,2.6.3,2.8-.2.2-.8-.5-.8-.5,0,0,.1.7,0,1-.1.2-2,1-2.4,1.1,0,0,0,0,0,0-.4,0-.9-.7-.9-.7,0,0-.1,1-.3,1s0,0,0,0c-.2-.1-1.6-3.1-1.5-2.1,0,.5.8,2.5,1.3,5,.2,1,.3,2,.4,3,0,1.5,0,3-.5,4.3-.3.2-.5.3-.7.4,0,0-.1,0-.2.1-.2,0-.3.1-.7.2.4-5.2-1.7-9-1.5-12.2,0-2,1.1-3.4,2.1-4.4.6-.5,1.2-.9,1.7-1.1.6-.3,1.6-.4,2.7-.3,1.4,0,2.9.5,3.7,1.5,0,0,.1.1.2.2,0,.1.2.3.3.4Z"/>
<path class="st0" d="M16.8,11.1s0,0,0,0c0,0-.2,0-.3,0-.9,0-1.6.8-1.6,1.8s0,.3,0,.4,0,0,0,0c-.4.2-.8.4-1.2.6-1.5.6-3.1.5-4.2-.2s0,0,0,0c-.5-2.5-1.2-4.5-1.3-5,0-1,1.3,2,1.5,2.1,0,0,0,0,0,0,.2,0,.3-.8.3-.9s0,0,0,0c0,.1.5.8.9.7,0,0,0,0,0,0,.4-.2,2.2-.9,2.4-1.1.1-.2,0-.8,0-.9s0,0,0,0c0,.1.5.6.7.4.2-.2-.6-2.9-.3-2.8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0s0,0,0,0c0,0,0,0,0,0,0,0,.1.2.2.3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.1.2.2.3,0,0,0,0,0,0h0c0,.3.2.4.3.6,0,0,.1.2.2.3,0,.2.2.3.3.5,0,0,0,.1.1.2.3.6.7,1.2,1.2,1.9Z"/>
<path class="st0" d="M16.8,11.1c.4.1.6.5.6,1.1,0,.2,0,.4,0,.7,0,.4,0,.7,0,1,0,.4-.3.6-.6.7v2.9c.5.2.7.8.7,1.5,0,0,0,.1,0,.2,0,.8-.1,1.5-.7,1.7v3.1"/>
<line class="st0" x1="16.8" y1="11.1" x2="16.8" y2="1.4"/>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

+190
View File
@@ -0,0 +1,190 @@
/*
* @Author: pikapikapikaori pikapikapi_kaori@icloud.com
* @Date: 2023-04-30 12:57:52
* @LastEditors: pikapikapikaori pikapikapi_kaori@icloud.com
* @LastEditTime: 2023-05-05 22:29:02
* @FilePath: /pikapikapi-blog/docs/utils/countWords.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// default values
var switchLightDarkModeOptions = {
useSwitchMode: true,
top: 130,
right: 26,
svgColor: '#7d7b75',
}
window.$docsify.currentThemeModeIndex = 2;
// Docsify plugin functions
function plugin(hook, vm) {
if (!switchLightDarkModeOptions.useSwitchMode) {
return
}
let themeModes = ['light', 'dark', 'auto',]
let currentThemeModeIndex = 2
hook.mounted(function () {
// let lightTheme = Docsify.dom.findAll('[href="/style/light.css"]')[0]
// let darkTheme = Docsify.dom.findAll('[href="/style/dark.css"]')[0]
var switchSpan = document.createElement('span')
switchSpan.id = 'switchLightDarkModeDivBeforeArticle'
switchSpan.style.position = 'fixed'
switchSpan.style.right = switchLightDarkModeOptions.right.toString() + 'px'
switchSpan.style.top = switchLightDarkModeOptions.top.toString() + 'px'
const lightModeIconXml = '<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="' + switchLightDarkModeOptions.svgColor + '"><path d="M12 18a6 6 0 100-12 6 6 0 000 12zM22 12h1M12 2V1M12 23v-1M20 20l-1-1M20 4l-1 1M4 20l1-1M4 4l1 1M1 12h1" stroke="' + switchLightDarkModeOptions.svgColor + '" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'
const darkModeIconXml = '<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="' + switchLightDarkModeOptions.svgColor + '"><path d="M3 11.507a9.493 9.493 0 0018 4.219c-8.507 0-12.726-4.22-12.726-12.726A9.494 9.494 0 003 11.507z" stroke="' + switchLightDarkModeOptions.svgColor + '" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'
const autoModeIconXml = '<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="' + switchLightDarkModeOptions.svgColor + '"><path d="M3 15c2.483 0 4.345-3 4.345-3s1.862 3 4.345 3c2.482 0 4.965-3 4.965-3s2.483 3 4.345 3M3 20c2.483 0 4.345-3 4.345-3s1.862 3 4.345 3c2.482 0 4.965-3 4.965-3s2.483 3 4.345 3M19 10a7 7 0 10-14 0" stroke="' + switchLightDarkModeOptions.svgColor + '" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'
const zoomInIconXml = '<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" viewBox="0 0 24 24" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg" color="' + switchLightDarkModeOptions.svgColor + '"><path d="M8 11h3m3 0h-3m0 0V8m0 3v3M17 17l4 4M3 11a8 8 0 1016 0 8 8 0 00-16 0z" stroke="' + switchLightDarkModeOptions.svgColor + '" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'
const zoomOutIconXml = '<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" viewBox="0 0 24 24" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg" color="' + switchLightDarkModeOptions.svgColor + '"><path d="M17 17l4 4M3 11a8 8 0 1016 0 8 8 0 00-16 0zM8 11h6" stroke="' + switchLightDarkModeOptions.svgColor + '" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'
const zoomDefaultIconXml = '<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="' + switchLightDarkModeOptions.svgColor + '"><path d="M12 19a7 7 0 100-14 7 7 0 000 14zM12 19v2M5 12H3M12 5V3M19 12h2" stroke="' + switchLightDarkModeOptions.svgColor + '" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'
const ottoIconXml = `
<?xml version="1.0" encoding="UTF-8"?>
<svg width="26px" height="30px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 24 24" color="` + switchLightDarkModeOptions.svgColor + `" stroke="` + switchLightDarkModeOptions.svgColor + `" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path class="st0" d="M17.5,12.9c0,1-.1,1.8-1,1.8s-1.6-.8-1.6-1.8.7-1.8,1.6-1.8,1,.8,1,1.8Z"/>
<path class="st0" d="M17.5,19.1c0,1-.1,1.8-1,1.8s-1.6-.8-1.6-1.8.7-1.8,1.6-1.8,1,.8,1,1.8Z"/>
<path class="st0" d="M6.7,9.4c-.8-.6-1.3-3.4-1.2-3.8,0-.3,2.9-.3,3.4-.1"/>
<path class="st0" d="M12.6,4.2c.2-.3,2.2-2.2,2.7-2.2s1.2,3.2,1.3,3.8"/>
<path class="st0" d="M9.9,16.7c.3-.8,1.1-1.1,1.5-1.1,1.3,0,2.9-.4,4.3-1.2"/>
<path class="st0" d="M8.7,21.6c0,0,0,.2,0,.3-.1.5.4,1.2,1,1.4,2.5.8,7.2-1,7.2-1"/>
<path class="st0" d="M12.7,18.2c0,.8,0,1-.3,1.6"/>
<path class="st0" d="M11.3,20.3c.3-.2.6-.4,1.1-.5.9-.2,2-.5,2.5-.6,0,0,0-.1,0-.2,0-1,.7-1.8,1.6-1.8s.2,0,.3,0v-2.9c0,0-.2,0-.3,0-.3,0-.5,0-.7-.2-.4-.2-.7-.6-.8-1.1,0-.1,0-.3,0-.4,0-1,.7-1.8,1.6-1.8s.2,0,.3,0"/>
<path class="st0" d="M16.5,5.9s0,5.2,0,5.2c-.6-.5-.8-1.1-1.2-1.7,0,0,0-.1-.1-.2-.1-.2-.2-.4-.3-.5,0,0-.1-.2-.2-.3-.1-.2-.2-.4-.3-.6h0c0-.1,0-.1,0-.2,0-.1-.1-.2-.2-.3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.1-.1-.2-.2-.3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0-.2,0,.6,2.6.3,2.8-.2.2-.8-.5-.8-.5,0,0,.1.7,0,1-.1.2-2,1-2.4,1.1,0,0,0,0,0,0-.4,0-.9-.7-.9-.7,0,0-.1,1-.3,1s0,0,0,0c-.2-.1-1.6-3.1-1.5-2.1,0,.5.8,2.5,1.3,5,.2,1,.3,2,.4,3,0,1.5,0,3-.5,4.3-.3.2-.5.3-.7.4,0,0-.1,0-.2.1-.2,0-.3.1-.7.2.4-5.2-1.7-9-1.5-12.2,0-2,1.1-3.4,2.1-4.4.6-.5,1.2-.9,1.7-1.1.6-.3,1.6-.4,2.7-.3,1.4,0,2.9.5,3.7,1.5,0,0,.1.1.2.2,0,.1.2.3.3.4Z"/>
<path class="st0" d="M16.8,11.1s0,0,0,0c0,0-.2,0-.3,0-.9,0-1.6.8-1.6,1.8s0,.3,0,.4,0,0,0,0c-.4.2-.8.4-1.2.6-1.5.6-3.1.5-4.2-.2s0,0,0,0c-.5-2.5-1.2-4.5-1.3-5,0-1,1.3,2,1.5,2.1,0,0,0,0,0,0,.2,0,.3-.8.3-.9s0,0,0,0c0,.1.5.8.9.7,0,0,0,0,0,0,.4-.2,2.2-.9,2.4-1.1.1-.2,0-.8,0-.9s0,0,0,0c0,.1.5.6.7.4.2-.2-.6-2.9-.3-2.8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0s0,0,0,0c0,0,0,0,0,0,0,0,.1.2.2.3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.1.2.2.3,0,0,0,0,0,0h0c0,.3.2.4.3.6,0,0,.1.2.2.3,0,.2.2.3.3.5,0,0,0,.1.1.2.3.6.7,1.2,1.2,1.9Z"/>
<path class="st0" d="M16.8,11.1c.4.1.6.5.6,1.1,0,.2,0,.4,0,.7,0,.4,0,.7,0,1,0,.4-.3.6-.6.7v2.9c.5.2.7.8.7,1.5,0,0,0,.1,0,.2,0,.8-.1,1.5-.7,1.7v3.1"/>
<line class="st0" x1="16.8" y1="11.1" x2="16.8" y2="1.4"/>
</svg>
`
let setThemeMode = function (currentTheme) {
switch (currentTheme) {
case 'light':
// lightTheme.disabled = false
// darkTheme.disabled = true
document.body.classList.remove('dark')
document.body.classList.add('light')
switchSpan.innerHTML = lightModeIconXml
break
case 'dark':
// lightTheme.disabled = true
// darkTheme.disabled = false
document.body.classList.remove('light')
document.body.classList.add('dark')
switchSpan.innerHTML = darkModeIconXml
break
case 'auto':
var isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
// lightTheme.disabled = isDarkMode
// darkTheme.disabled = !isDarkMode
if (isDarkMode) {
document.body.classList.remove('light')
document.body.classList.add('dark')
}
else {
document.body.classList.remove('dark')
document.body.classList.add('light')
}
switchSpan.innerHTML = autoModeIconXml
break
}
}
setThemeMode(themeModes[currentThemeModeIndex])
let preferredThemeChangeEventListenerFunction = function () {
if (currentThemeModeIndex === 2) {
setThemeMode(themeModes[currentThemeModeIndex])
}
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', preferredThemeChangeEventListenerFunction)
switchSpan.onclick = function (e) {
if (currentThemeModeIndex === 2) {
currentThemeModeIndex = 0
}
else {
currentThemeModeIndex ++
}
window.$docsify.currentThemeModeIndex = currentThemeModeIndex
window.$docsify.onLightDarkModeChange();
setThemeMode(themeModes[currentThemeModeIndex])
}
document.body.appendChild(switchSpan)
var zoomInSpan = document.createElement('span')
zoomInSpan.id = 'zoomInSpan'
zoomInSpan.style.position = 'fixed'
zoomInSpan.style.right = switchLightDarkModeOptions.right.toString() + 'px'
zoomInSpan.style.top = (switchLightDarkModeOptions.top + 35).toString() + 'px'
zoomInSpan.innerHTML = zoomInIconXml
var zoomOutSpan = document.createElement('span')
zoomOutSpan.id = 'zoomOutSpan'
zoomOutSpan.style.position = 'fixed'
zoomOutSpan.style.right = switchLightDarkModeOptions.right.toString() + 'px'
zoomOutSpan.style.top = (switchLightDarkModeOptions.top + 70).toString() + 'px'
zoomOutSpan.innerHTML = zoomOutIconXml
var zoomDefaultSpan = document.createElement('span')
zoomDefaultSpan.id = 'zoomDefaultSpan'
zoomDefaultSpan.style.position = 'fixed'
zoomDefaultSpan.style.right = switchLightDarkModeOptions.right.toString() + 'px'
zoomDefaultSpan.style.top = (switchLightDarkModeOptions.top + 105).toString() + 'px'
zoomDefaultSpan.innerHTML = zoomDefaultIconXml
var ottoSpan = document.createElement('span')
ottoSpan.id = 'ottoSpan'
ottoSpan.style.position = 'fixed'
ottoSpan.style.right = switchLightDarkModeOptions.right.toString() + 'px'
ottoSpan.style.top = (switchLightDarkModeOptions.top + 140).toString() + 'px'
ottoSpan.innerHTML = ottoIconXml
let defaultSize = 1.0
let currentSize = defaultSize
function set(targetSize) {
document.body.style.zoom = targetSize
document.body.style.cssText += '; -moz-transform: scale(' + targetSize + ');-moz-transform-origin: 0 0; '
}
function showOtto(show) {
window.$docsify.onOttoShow(show)
}
zoomInSpan.onclick = function () {
currentSize = currentSize + 0.1
set(currentSize)
}
zoomOutSpan.onclick = function () {
currentSize = currentSize - 0.1
set(currentSize)
}
zoomDefaultSpan.onclick = function () {
currentSize = defaultSize
set(currentSize)
}
ottoSpan.onclick = function () {
showOtto()
}
document.body.appendChild(zoomInSpan)
document.body.appendChild(zoomOutSpan)
document.body.appendChild(zoomDefaultSpan)
document.body.appendChild(ottoSpan)
})
}
// Docsify plugin options
window.$docsify['switchLightDarkMode'] = Object.assign(
switchLightDarkModeOptions,
window.$docsify['switchLightDarkMode']
)
window.$docsify.plugins = [].concat(plugin, window.$docsify.plugins)
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es2015",
"lib": [
"es2017",
"dom"
],
"module": "es6",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"files": [
"rdview.ts"
],
}
+1
View File
@@ -0,0 +1 @@
{"root":["./rdview.ts","./rdviewtag.ts","./rdviewreader.ts","./rdviewconstructor.ts"],"version":"5.7.2"}
File diff suppressed because one or more lines are too long
+16
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long