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 May 13, 2024
2 parents 1363178 + eebfed9 commit 299cf71
Show file tree
Hide file tree
Showing 31 changed files with 100 additions and 65 deletions.
5 changes: 5 additions & 0 deletions css/window.css
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@
color: var(--color-bright_ui_text);
opacity: 0.8;
}
@media (max-height: 400px) {
#mobile_menu_bar {
top: 0;
}
}

/* Tab Bar */
#tab_bar {
Expand Down
2 changes: 1 addition & 1 deletion js/interface/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function buildForm(dialog) {
let select_input = new Interface.CustomElements.SelectInput(form_id, {
options: data.options,
value: data.value || data.default,
onChange() {
onInput() {
dialog.updateFormValues();
}
});
Expand Down
9 changes: 6 additions & 3 deletions js/interface/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ Interface.CustomElements.SelectInput = function(id, data) {
let options = typeof data.options == 'function' ? data.options() : data.options;
let value = data.value || data.default || Object.keys(options)[0];
let select = Interface.createElement('bb-select', {id, class: 'half', value: value}, getNameFor(options[value]));
function setKey(key, options) {
function setKey(key, options, input_event) {
if (!options) {
options = typeof data.options == 'function' ? data.options() : data.options;
}
Expand All @@ -766,6 +766,9 @@ Interface.CustomElements.SelectInput = function(id, data) {
if (typeof data.onChange == 'function') {
data.onChange(value);
}
if (input_event && typeof data.onInput == 'function') {
data.onInput(value, input_event);
}
}
select.addEventListener('click', function(event) {
if (Menu.closed_in_this_click == id) return this;
Expand All @@ -779,8 +782,8 @@ Interface.CustomElements.SelectInput = function(id, data) {
icon: val.icon || ((value == key) ? 'far.fa-dot-circle' : 'far.fa-circle'),
color: val.color,
condition: val.condition,
click: (e) => {
setKey(key, options);
click: (context, event) => {
setKey(key, options, event || 1);
}
})
}
Expand Down
32 changes: 22 additions & 10 deletions js/interface/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ function handleMenuOverflow(node) {
function offset(amount) {
let top = parseInt(node.style.top);
let offset = top - $(node).offset().top;
let top_gap = 26;
if (Blockbench.isMobile && Menu.open instanceof BarMenu) {
top_gap = window.innerHeight > 400 ? 106 : 56;
}
top = Math.clamp(
top + amount,
window.innerHeight - node.clientHeight + offset,
offset + 26
offset + top_gap
);
node.style.top = `${top}px`;
}
Expand Down Expand Up @@ -100,17 +104,21 @@ class Menu {
}
}

let window_height = window.innerHeight - 26;
let top_gap = 26;
if (Blockbench.isMobile && this instanceof BarMenu) {
top_gap = window.innerHeight > 400 ? 106 : 56;
}
let window_height = window.innerHeight - top_gap;

if (el_height > window_height) {
childlist.css('margin-top', '0').css('top', '0')
childlist.css('top', (-childlist.offset().top + 26) + 'px')
childlist.css('top', (-childlist.offset().top + top_gap) + 'px')
handleMenuOverflow(childlist);

} else if (offset.top + el_height > window_height) {
childlist.css('margin-top', 26-childlist.height() + 'px')
if (childlist.offset().top < 26) {
childlist.offset({top: 26})
childlist.css('margin-top', top_gap-childlist.height() + 'px')
if (childlist.offset().top < top_gap) {
childlist.offset({top: top_gap})
}
}
}
Expand Down Expand Up @@ -510,9 +518,13 @@ class Menu {
let content_list = typeof this.structure == 'function' ? this.structure(context) : this.structure;
populateList(content_list, ctxmenu, this.options.searchable);

var el_width = ctxmenu.width()
var el_height = ctxmenu.height()
let window_height = window.innerHeight - 26;
let el_width = ctxmenu.width()
let el_height = ctxmenu.height()
let top_gap = 26;
if (Blockbench.isMobile && this instanceof BarMenu) {
top_gap = window.innerHeight > 400 ? 106 : 56;
}
let window_height = window.innerHeight - top_gap;

if (position && position.clientX !== undefined) {
var offset_left = position.clientX
Expand Down Expand Up @@ -553,7 +565,7 @@ class Menu {
offset_top = window_height - el_height;
}
}
offset_top = Math.max(offset_top, 26);
offset_top = Math.max(offset_top, top_gap);

ctxmenu.css('left', offset_left+'px')
ctxmenu.css('top', offset_top +'px')
Expand Down
11 changes: 3 additions & 8 deletions js/interface/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,8 @@ const CustomTheme = {
CustomTheme.updateColors();
},
loadThumbnailStyles() {
let split_regex;
try {
// Soft fail for iOS 16.3 and older
split_regex = eval('/(?<!\\[[^\\]]*),(?![^\\[]*\\])|(?<!"[^"]*),(?![^"]*")/g')
} catch (err) {
return;
}
let split_regex = (isApp || window.chrome) ? new RegExp('(?<!\\[[^\\]]*),(?![^\\[]*\\])|(?<!"[^"]*),(?![^"]*")', 'g') : null;
if (!split_regex) return;
let thumbnailStyles = '\n';
const style = document.createElement('style');
document.head.appendChild(style);
Expand Down Expand Up @@ -497,7 +492,7 @@ const CustomTheme = {
}
}
Merge.string(app, theme, 'css');
theme.thumbnail ??= '';
if (!theme.thumbnail) theme.thumbnail = '';
Merge.string(app, theme, 'thumbnail');
this.updateColors();
this.updateSettings();
Expand Down
4 changes: 4 additions & 0 deletions js/io/formats/bbmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,11 @@ var codec = new Codec('project', {
}

if (model.skin_model) {
let elements_before = Outliner.elements.slice();
Codecs.skin_model.rebuild(model.skin_model);
for (let element of Outliner.elements) {
if (!elements_before.includes(element)) new_elements.push(element);
}
}
let adjust_uv = !Format.per_texture_uv_size || !imported_format?.per_texture_uv_size;
if (model.elements) {
Expand Down
2 changes: 1 addition & 1 deletion js/modeling/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ BARS.defineActions(function() {
new BarSelect('rotation_space', {
condition: {modes: ['edit', 'animate', 'pose'], tools: ['rotate_tool']},
category: 'transform',
value: 'parent',
value: 'local',
options: {
global: 'action.transform_space.global',
parent: 'action.transform_space.parent',
Expand Down
23 changes: 11 additions & 12 deletions js/outliner/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,27 +454,26 @@ class Group extends OutlinerNode {
}})
}},
{name: 'menu.cube.texture', icon: 'collections', condition: () => Format.per_group_texture, children() {
function applyTexture(texture_value, undo_message) {
let affected_groups = Group.all.filter(g => g.selected);
Undo.initEdit({outliner: true});
for (let group of affected_groups) {
group.texture = texture_value;
}
Undo.finishEdit(undo_message);
Canvas.updateAllFaces();
}
let arr = [
{icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click(group) {
Undo.initEdit({group: group});
group.texture = '';
Undo.finishEdit('Unassign texture from group');
group.forEachChild(child => {
if (child.preview_controller?.updateFaces) child.preview_controller.updateFaces(child);
})
applyTexture('', 'Unassign texture from group');
}}
]
Texture.all.forEach(t => {
arr.push({
name: t.name,
icon: (t.mode === 'link' ? t.img : t.source),
click(group) {
Undo.initEdit({group: group});
group.texture = t.uuid;
Undo.finishEdit('Apply texture to group');
group.forEachChild(child => {
if (child.preview_controller?.updateFaces) child.preview_controller.updateFaces(child);
})
applyTexture(t.uuid, 'Apply texture to group');
}
})
})
Expand Down
27 changes: 18 additions & 9 deletions js/outliner/mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ class Mesh extends OutlinerElement {
var scope = this;
if (faces === true) {
var sides = Object.keys(this.faces);
} else if (faces === undefined) {
} else if (!faces) {
var sides = this.getSelectedFaces()
} else {
var sides = faces
Expand Down Expand Up @@ -872,21 +872,23 @@ class Mesh extends OutlinerElement {
}
}})
}},
{name: 'menu.cube.texture', icon: 'collections', condition: () => !Format.single_texture, children: function() {
{name: 'menu.cube.texture', icon: 'collections', condition: () => !Format.single_texture, children() {
var arr = [
{icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click: function(cube) {
cube.forSelected(function(obj) {
obj.applyTexture(false, true)
{icon: 'crop_square', name: Format.single_texture_default ? 'menu.cube.texture.default' : 'menu.cube.texture.blank', click(mesh) {
let all_faces = BarItems.selection_mode.value != 'face' || Mesh.selected[0]?.getSelectedFaces().length == 0;
mesh.forSelected((obj) => {
obj.applyTexture(false, all_faces)
}, 'texture blank')
}}
]
Texture.all.forEach(function(t) {
Texture.all.forEach((t) => {
arr.push({
name: t.name,
icon: (t.mode === 'link' ? t.img : t.source),
click: function(cube) {
cube.forSelected(function(obj) {
obj.applyTexture(t, true)
click(mesh) {
let all_faces = BarItems.selection_mode.value != 'face' || Mesh.selected[0]?.getSelectedFaces().length == 0;
mesh.forSelected((obj) => {
obj.applyTexture(t, all_faces)
}, 'apply texture')
}
})
Expand Down Expand Up @@ -1153,12 +1155,19 @@ new NodePreviewController(Mesh, {
? [tex.getUVWidth(), tex.getUVHeight()]
: [Project.texture_width, Project.texture_height];

let first_values;
face.vertices.forEach((key, i) => {
let u = (face.uv[key] ? face.uv[key][0] : 0) / uv_size[0];
let v = (face.uv[key] ? face.uv[key][1] : 0) / uv_size[1];
if (stretch > 1) {
v = (v + frame) / stretch;
}
// Fix grainy visuals when UV all in one point
if (!first_values) {
first_values = [u, v];
} else if (first_values[0] == u && first_values[1] == v) {
i < 2 ? u += 0.00005 : v += 0.00005;
}
uv_array.push(u, 1-v);
})
}
Expand Down
7 changes: 6 additions & 1 deletion js/plugin_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,12 @@ BARS.defineActions(function() {
return pureMarked(about);
},
reduceLink(url) {
return url.replace('https://', '').substring(0, 50)+'...';
url = url.replace('https://', '').replace(/\/$/, '');
if (url.length > 50) {
return url.substring(0, 50)+'...';
} else {
return url;
}
},
printDate(input_date) {
return getDateDisplay(input_date).short;
Expand Down
2 changes: 1 addition & 1 deletion js/preview/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ const Screencam = {
vars.recording = true;
vars.loop = setInterval(() => {
if (vars.animation && options.play) {
Timeline.setTime(vars.interval*vars.frames / 1000);
Timeline.setTime((Timeline.playback_speed/100) * vars.interval*vars.frames / 1000);
Animator.preview(true);
}
vars.frames++;
Expand Down
2 changes: 1 addition & 1 deletion js/texturing/textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ class Texture {
}
});
groups = groups.filter(g => g instanceof Group);
let affected_elements = [];
affected_elements = [];
Undo.initEdit({outliner: true});
groups.forEach(group => {
group.texture = this.uuid;
Expand Down
3 changes: 3 additions & 0 deletions js/undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ class UndoSystem {
if ((save.outliner || save.group) && Format.bone_rig) {
Canvas.updateAllBones();
}
if (save.outliner && Format.per_group_texture) {
Canvas.updateAllFaces();
}
if (Modes.animate) {
Animator.preview();
}
Expand Down
2 changes: 1 addition & 1 deletion lang/cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Einzelbild hinzufügen",
"dialog.animated_texture_editor.resize_frames": "Bildgröße ändern...",
"dialog.animated_texture_editor.apply": "Anwenden",
"dialog.add_primitive.shape.rounded_cuboid": "Quader mit Kanten",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Kantenbreite",
"dialog.change_animation_speed.speed": "Geschwindigkeit",
"dialog.change_animation_speed.adjust_snapping": "Einrastintervall anpassen",
Expand Down
2 changes: 1 addition & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down
2 changes: 1 addition & 1 deletion lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@
"dialog.animated_texture_editor.add_frame": "Add Frame",
"dialog.animated_texture_editor.resize_frames": "Resize Frames...",
"dialog.animated_texture_editor.apply": "Apply",
"dialog.add_primitive.shape.rounded_cuboid": "Cuboid with Edges",
"dialog.add_primitive.shape.beveled_cuboid": "Beveled Cuboid",
"dialog.add_primitive.edge_size": "Edge Size",
"dialog.change_animation_speed.speed": "Speed",
"dialog.change_animation_speed.adjust_snapping": "Adjust Snapping",
Expand Down

0 comments on commit 299cf71

Please sign in to comment.