Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 committed Jun 5, 2024
2 parents eb3e748 + 36b358f commit 703ea67
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 186 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- name: "Linux"
os: linux
script:
- npm install [email protected]
- npm run prepublish
- sudo apt-get install rpm
- electron-builder --publish=onTagOrDraft
Expand Down
2 changes: 1 addition & 1 deletion css/panels.css
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@
width: 144px;
flex-shrink: 0;
background-color: var(--color-back);
z-index: 4;
z-index: 6;
border-bottom: 1px solid var(--color-border);
height: calc(100% + 1px);
}
Expand Down
176 changes: 0 additions & 176 deletions js/animations/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1794,180 +1794,4 @@ Interface.definePanels(function() {
'save_all_animations',
])
})

new Panel('variable_placeholders', {
icon: 'fas.fa-stream',
condition: {modes: ['animate']},
growable: true,
resizable: true,
default_position: {
slot: 'left_bar',
float_position: [0, 0],
float_size: [300, 400],
height: 400
},
component: {
name: 'panel-placeholders',
components: {VuePrismEditor},
data() { return {
text: '',
buttons: []
}},
methods: {
updateButtons() {
let old_values = {};
this.buttons.forEach(b => old_values[b.id] = b.value);
this.buttons.empty();

let text = this.text//.toLowerCase();
let matches = text.matchAll(/(slider|toggle|impulse)\(.+\)/gi);

for (let match of matches) {
let [type, content] = match[0].substring(0, match[0].length - 1).split(/\(/);
let [id, ...args] = content.split(/\(|, */);
id = id.replace(/['"]/g, '');
if (this.buttons.find(b => b.id == id)) return;

let variable = text.substring(0, match.index).match(/[\w.-]+ *= *$/);
variable = variable ? variable[0].replace(/[ =]+/g, '').replace(/^v\./i, 'variable.').replace(/^q\./i, 'query.').replace(/^t\./i, 'temp.').replace(/^c\./i, 'context.') : undefined;

if (type == 'slider') {
this.buttons.push({
type,
id,
value: old_values[id] || 0,
variable,
step: isNaN(args[0]) ? undefined : parseFloat(args[0]),
min: isNaN(args[1]) ? undefined : parseFloat(args[1]),
max: isNaN(args[2]) ? undefined : parseFloat(args[2])
})
} else if (type == 'toggle') {
this.buttons.push({
type,
id,
value: old_values[id] || 0,
variable,
})
} else if (type == 'impulse') {
this.buttons.push({
type,
id,
value: 0,
variable,
duration: parseFloat(args[0]) || 0.1
})
}
}
},
changeButtonValue(button, event) {
if (button.type == 'toggle') {
button.value = event.target.checked ? 1 : 0;
}
if (button.type == 'impulse') {
button.value = 1;
setTimeout(() => {
button.value = 0;
}, Math.clamp(button.duration, 0, 1) * 1000);
}
if (button.variable) {
delete Animator.MolangParser.variables[button.variable];
}
Animator.preview();
},
slideButton(button, e1) {
convertTouchEvent(e1);
let last_event = e1;
let started = false;
let move_calls = 0;
let last_val = 0;
let total = 0;
let clientX = e1.clientX;
function start() {
started = true;
if (!e1.touches && last_event == e1 && e1.target.requestPointerLock) e1.target.requestPointerLock();
}

function move(e2) {
convertTouchEvent(e2);
if (!started && Math.abs(e2.clientX - e1.clientX) > 5) {
start()
}
if (started) {
if (e1.touches) {
clientX = e2.clientX;
} else {
let limit = move_calls <= 2 ? 1 : 100;
clientX += Math.clamp(e2.movementX, -limit, limit);
}
let val = Math.round((clientX - e1.clientX) / 45);
let difference = (val - last_val);
if (!difference) return;
if (button.step) {
difference *= button.step;
} else {
difference *= canvasGridSize(e2.shiftKey || Pressing.overrides.shift, e2.ctrlOrCmd || Pressing.overrides.ctrl);
}


button.value = Math.clamp(Math.roundTo((parseFloat(button.value) || 0) + difference, 4), button.min, button.max);

last_val = val;
last_event = e2;
total += difference;
move_calls++;

Animator.preview()
Blockbench.setStatusBarText(trimFloatNumber(total));
}
}
function off(e2) {
if (document.exitPointerLock) document.exitPointerLock()
removeEventListeners(document, 'mousemove touchmove', move);
removeEventListeners(document, 'mouseup touchend', off);
}
addEventListeners(document, 'mouseup touchend', off);
addEventListeners(document, 'mousemove touchmove', move);
},
autocomplete(text, position) {
let test = Animator.autocompleteMolang(text, position, 'placeholders');
return test;
}
},
watch: {
text(text) {
if (Project && typeof text == 'string') {
Project.variable_placeholders = text;
this.updateButtons();
Project.variable_placeholder_buttons.replace(this.buttons);
}
}
},
template: `
<div style="flex-grow: 1; display: flex; flex-direction: column; overflow: visible;">
<ul id="placeholder_buttons">
<li v-for="button in buttons" :key="button.id" :class="{placeholder_slider: button.type == 'slider'}" @click="button.type == 'impulse' && changeButtonValue(button, $event)" :buttontype="button.type">
<i v-if="button.type == 'impulse'" class="material-icons">play_arrow</i>
<input v-if="button.type == 'toggle'" type="checkbox" class="tab_target" :value="button.value == 1" @change="changeButtonValue(button, $event)" :id="'placeholder_button_'+button.id">
<numeric-input v-if="button.type == 'slider'" class="dark_bordered tab_target" :step="button.step" :min="button.min" :max="button.max" v-model="button.value" @input="changeButtonValue(button, $event)" />
<label :for="'placeholder_button_'+button.id" @mousedown="slideButton(button, $event)" @touchstart="slideButton(button, $event)">{{ button.id }}</label>
</li>
</ul>
<p>${tl('panel.variable_placeholders.info')}</p>
<vue-prism-editor
id="var_placeholder_area"
class="molang_input tab_target capture_tab_key"
v-model="text"
language="molang"
:autocomplete="autocomplete"
:line-numbers="false"
style="flex-grow: 1;"
onkeyup="Animator.preview()"
/>
</div>
`
}
})
})
1 change: 1 addition & 0 deletions js/animations/animation_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ Interface.definePanels(function() {
if (document.exitPointerLock) document.exitPointerLock()
removeEventListeners(document, 'mousemove touchmove', move);
removeEventListeners(document, 'mouseup touchend', off);
Blockbench.setStatusBarText();
}
addEventListeners(document, 'mouseup touchend', off);
addEventListeners(document, 'mousemove touchmove', move);
Expand Down
4 changes: 4 additions & 0 deletions js/interface/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,10 @@ const Settings = {
settings.brush_opacity_modifier.set('none');
settings.brush_size_modifier.set('none');
})
let date = new Date();
if (date.getMonth() >= 5 && date.getDate() >= 13) {
settings.bedrock_uv_rotations.set(true);
}
},
setupProfiles() {
if (localStorage.getItem('settings_profiles') != null) {
Expand Down
Loading

0 comments on commit 703ea67

Please sign in to comment.