mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-29 02:41:44 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
bb980d2cad | |||
102c796c69 | |||
2f7218d165 | |||
b07318e07f | |||
70a8fc9866 |
@ -1,5 +1,5 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 3.1.4
|
// @version 3.1.5
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Better xCloud
|
// @name Better xCloud
|
||||||
// @namespace https://github.com/redphx
|
// @namespace https://github.com/redphx
|
||||||
// @version 3.1.4
|
// @version 3.1.5
|
||||||
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
// @description Improve Xbox Cloud Gaming (xCloud) experience
|
||||||
// @author redphx
|
// @author redphx
|
||||||
// @license MIT
|
// @license MIT
|
||||||
@ -14,7 +14,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const SCRIPT_VERSION = '3.1.4';
|
const SCRIPT_VERSION = '3.1.5';
|
||||||
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
||||||
|
|
||||||
const ENABLE_XCLOUD_LOGGER = false;
|
const ENABLE_XCLOUD_LOGGER = false;
|
||||||
@ -1335,6 +1335,7 @@ const Translations = {
|
|||||||
"tr-TR": "Bu özellik çevrimiçi oyunlarda sizi hile yapıyormuşsunuz gibi gösterebilir",
|
"tr-TR": "Bu özellik çevrimiçi oyunlarda sizi hile yapıyormuşsunuz gibi gösterebilir",
|
||||||
"uk-UA": "Використання цієї функції під час гри онлайн може розглядатися як шахрайство",
|
"uk-UA": "Використання цієї функції під час гри онлайн може розглядатися як шахрайство",
|
||||||
"vi-VN": "Sử dụng chức năng này khi chơi trực tuyến có thể bị xem là gian lận",
|
"vi-VN": "Sử dụng chức năng này khi chơi trực tuyến có thể bị xem là gian lận",
|
||||||
|
"zh-CN": "游玩在线游戏时,使用此功能可能被视为作弊。",
|
||||||
},
|
},
|
||||||
"mouse-and-keyboard": {
|
"mouse-and-keyboard": {
|
||||||
"de-DE": "Maus & Tastatur",
|
"de-DE": "Maus & Tastatur",
|
||||||
@ -2479,8 +2480,10 @@ const Translations = {
|
|||||||
"ja-JP": "タッチコントロールレイアウト",
|
"ja-JP": "タッチコントロールレイアウト",
|
||||||
"pt-BR": "Layout do controle por toque",
|
"pt-BR": "Layout do controle por toque",
|
||||||
"ru-RU": "Расположение сенсорных кнопок",
|
"ru-RU": "Расположение сенсорных кнопок",
|
||||||
|
"tr-TR": "Dokunmatik kontrol şeması",
|
||||||
"uk-UA": "Розташування сенсорного керування",
|
"uk-UA": "Розташування сенсорного керування",
|
||||||
"vi-VN": "Bố cục điều khiển cảm ứng",
|
"vi-VN": "Bố cục điều khiển cảm ứng",
|
||||||
|
"zh-CN": "触摸控制布局",
|
||||||
},
|
},
|
||||||
"touch-controller": {
|
"touch-controller": {
|
||||||
"de-DE": "Touch-Controller",
|
"de-DE": "Touch-Controller",
|
||||||
@ -3498,53 +3501,51 @@ class TouchController {
|
|||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getCustomLayouts(xboxTitleId) {
|
static #dispatchLayouts(data) {
|
||||||
const dispatchLayouts = data => {
|
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
||||||
BxEvent.dispatch(window, BxEvent.CUSTOM_TOUCH_LAYOUTS_LOADED, {
|
data: data,
|
||||||
data: data,
|
});
|
||||||
});
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
static getCustomLayouts(xboxTitleId, retries) {
|
||||||
xboxTitleId = '' + xboxTitleId;
|
xboxTitleId = '' + xboxTitleId;
|
||||||
if (xboxTitleId in TouchController.#customLayouts) {
|
if (xboxTitleId in TouchController.#customLayouts) {
|
||||||
dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
TouchController.#dispatchLayouts(TouchController.#customLayouts[xboxTitleId]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = 'https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/touch-layouts/';
|
retries = retries || 1;
|
||||||
if (USE_DEV_TOUCH_LAYOUT) {
|
if (retries > 2) {
|
||||||
url += `dev/${xboxTitleId}.json`;
|
TouchController.#customLayouts[xboxTitleId] = null;
|
||||||
} else {
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
url += `${xboxTitleId}.json`;
|
setTimeout(() => TouchController.#dispatchLayouts(null), 1000);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const baseUrl = `https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/touch-layouts${USE_DEV_TOUCH_LAYOUT ? '/dev' : ''}`;
|
||||||
|
const url = `${baseUrl}/${xboxTitleId}.json`;
|
||||||
|
|
||||||
|
// Get layout info
|
||||||
NATIVE_FETCH(url)
|
NATIVE_FETCH(url)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
// Normalize data
|
const layouts = {};
|
||||||
const schema_version = json.schema_version || 1;
|
|
||||||
let layout;
|
|
||||||
try {
|
|
||||||
if (schema_version === 1) {
|
|
||||||
json.layouts = {
|
|
||||||
default: {
|
|
||||||
name: 'Default',
|
|
||||||
content: json.layout,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
json.default_layout = 'default';
|
|
||||||
delete json.layout;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
|
json.layouts.forEach(async file => {
|
||||||
|
const layoutUrl = `${baseUrl}/layouts/${file}.json`;
|
||||||
|
const json = await (await NATIVE_FETCH(layoutUrl)).json();
|
||||||
|
Object.assign(layouts, json.layouts);
|
||||||
|
});
|
||||||
|
|
||||||
|
json.layouts = layouts;
|
||||||
TouchController.#customLayouts[xboxTitleId] = json;
|
TouchController.#customLayouts[xboxTitleId] = json;
|
||||||
|
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
// Wait for BX_EXPOSED.touch_layout_manager
|
||||||
setTimeout(() => dispatchLayouts(json), 1000);
|
setTimeout(() => TouchController.#dispatchLayouts(json), 1000);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
TouchController.#customLayouts[xboxTitleId] = null;
|
// Retry
|
||||||
// Wait for BX_EXPOSED.touch_layout_manager
|
TouchController.getCustomLayouts(xboxTitleId, retries + 1);
|
||||||
setTimeout(() => dispatchLayouts(null), 1000);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3588,6 +3589,24 @@ class TouchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static setup() {
|
static setup() {
|
||||||
|
// Function for testing touch control
|
||||||
|
window.BX_EXPOSED.test_touch_control = content => {
|
||||||
|
const { touch_layout_manager } = window.BX_EXPOSED;
|
||||||
|
|
||||||
|
touch_layout_manager && touch_layout_manager.changeLayoutForScope({
|
||||||
|
type: 'showLayout',
|
||||||
|
scope: '' + GAME_XBOX_TITLE_ID,
|
||||||
|
subscope: 'base',
|
||||||
|
layout: {
|
||||||
|
id: 'System.Standard',
|
||||||
|
displayName: 'Custom',
|
||||||
|
layoutFile: {
|
||||||
|
content: content,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const $fragment = document.createDocumentFragment();
|
const $fragment = document.createDocumentFragment();
|
||||||
const $style = document.createElement('style');
|
const $style = document.createElement('style');
|
||||||
$fragment.appendChild($style);
|
$fragment.appendChild($style);
|
||||||
|
Reference in New Issue
Block a user