PIXI Controls: Round displayable values and remove non persent bars

This commit is contained in:
OleSTEEP 2024-02-20 23:14:26 +03:00
parent 8dc514f6cc
commit a29c9c9b24
2 changed files with 22 additions and 42 deletions

View file

@ -836,9 +836,9 @@ Window_OmoMenuOptionsONSControls.prototype.makeOptionsList = function () {
// Get Text // Get Text
//var text = LanguageManager.getPluginText('optionsMenu', 'audio'); //var text = LanguageManager.getPluginText('optionsMenu', 'audio');
var text = { var text = {
buttonsScale: {help: "Change on-screen controls scale.", text: "CONTROLS SCALE", isBar: true, persent: true, minValue: 0, maxValue: 500}, buttonsScale: {help: "Change on-screen controls scale.", text: "CONTROLS SCALE", isBar: true, minValue: 0, maxValue: 500},
buttonsOpacity: {help: "Change on-screen controls opacity.", text: "CONTROLS OPACITY", isBar: true, persent: true, minValue: 0, maxValue: 100}, buttonsOpacity: {help: "Change on-screen controls opacity.", text: "CONTROLS OPACITY", isBar: true, minValue: 0, maxValue: 100},
safeArea: {help: "Change safe area size for on-screen controls.", text: "SAFE AREA", isBar: true, persent: true, minValue: 10, maxValue: 100}, safeArea: {help: "Change safe area size for on-screen controls.", text: "SAFE AREA", isBar: true, minValue: 10, maxValue: 100},
editMenu: {help: "Press Left or Right button on DPad, to open menu.", text: "OPEN EDIT MODE", isBar: false} editMenu: {help: "Press Left or Right button on DPad, to open menu.", text: "OPEN EDIT MODE", isBar: false}
} }
// Get Config // Get Config
@ -855,11 +855,7 @@ Window_OmoMenuOptionsONSControls.prototype.makeOptionsList = function () {
var data = text[name]; var data = text[name];
// Add Option // Add Option
if (data.isBar) { if (data.isBar) {
if (data.persent) { this._optionsList.push({ header: data.text + ':', config: name, option: ConfigManager.ONSConfig[name] * 100, helpText: data.help, isBar: data.isBar, minValue: data.minValue, maxValue: data.maxValue });
this._optionsList.push({ header: data.text + ':', config: name, option: ConfigManager.ONSConfig[name] * 100, helpText: data.help, isBar: data.isBar, persent: data.persent, minValue: data.minValue, maxValue: data.maxValue });
} else {
this._optionsList.push({ header: data.text + ':', config: name, option: ConfigManager.ONSConfig[name], helpText: data.help, isBar: data.isBar, persent: data.persent, minValue: data.minValue, maxValue: data.maxValue });
}
} else { } else {
this._optionsList.push({ header: data.text, config: name, helpText: data.help, isBar: data.isBar}); this._optionsList.push({ header: data.text, config: name, helpText: data.help, isBar: data.isBar});
} }
@ -879,7 +875,7 @@ Window_OmoMenuOptionsONSControls.prototype.drawItem = function (index) {
this.contents.drawText(data.header, rect.x + 50, rect.y, rect.width, 24); this.contents.drawText(data.header, rect.x + 50, rect.y, rect.width, 24);
// Update option bar // Update option bar
if (data.isBar) { if (data.isBar) {
this.updateOptionBar(index, data.option, data.persent); this.updateOptionBar(index, data.option);
} }
}; };
}; };
@ -907,7 +903,7 @@ Window_OmoMenuOptionsONSControls.prototype.cursorRight = function (wrap) {
var rate = Input.isLongPressed('right') ? 5 : 5 var rate = Input.isLongPressed('right') ? 5 : 5
data.option = Math.min(data.option + rate, data.maxValue); data.option = Math.min(data.option + rate, data.maxValue);
if (data.isBar) { if (data.isBar) {
this.updateOptionBar(this.index(), data.option, data.persent); this.updateOptionBar(this.index(), data.option);
} else { } else {
ONSControls.openEditMode(); ONSControls.openEditMode();
} }
@ -926,7 +922,7 @@ Window_OmoMenuOptionsONSControls.prototype.cursorLeft = function (wrap) {
var rate = Input.isLongPressed('left') ? 5 : 5 var rate = Input.isLongPressed('left') ? 5 : 5
data.option = Math.max(data.option - rate, data.minValue); data.option = Math.max(data.option - rate, data.minValue);
if (data.isBar) { if (data.isBar) {
this.updateOptionBar(this.index(), data.option, data.persent); this.updateOptionBar(this.index(), data.option);
} else { } else {
ONSControls.openEditMode(); ONSControls.openEditMode();
} }
@ -935,7 +931,7 @@ Window_OmoMenuOptionsONSControls.prototype.cursorLeft = function (wrap) {
//============================================================================= //=============================================================================
// * Update option bar // * Update option bar
//============================================================================= //=============================================================================
Window_OmoMenuOptionsONSControls.prototype.updateOptionBar = function (index, option, persent) { Window_OmoMenuOptionsONSControls.prototype.updateOptionBar = function (index, option) {
// Get Data // Get Data
var data = this._optionsList[index]; var data = this._optionsList[index];
// Get Back and Front Sprite // Get Back and Front Sprite
@ -946,15 +942,9 @@ Window_OmoMenuOptionsONSControls.prototype.updateOptionBar = function (index, op
var rect = this.itemRect(index); var rect = this.itemRect(index);
rect.x += 415; rect.y += 27; rect.width = 100; rect.height = 40; rect.x += 415; rect.y += 27; rect.width = 100; rect.height = 40;
this.contents.clearRect(rect.x, rect.y, rect.width, rect.height); this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
if (persent) { this.contents.drawText(Math.round(option) + '%', rect.x, rect.y, rect.width, rect.height, 'right');
this.contents.drawText(option + '%', rect.x, rect.y, rect.width, rect.height, 'right');
// Set Option // Set Option
ConfigManager.ONSConfig[data.config] = option / 100; ConfigManager.ONSConfig[data.config] = option / 100;
} else {
this.contents.drawText(Math.round(option) + 'px', rect.x, rect.y, rect.width, rect.height, 'right');
// Set Option
ConfigManager.ONSConfig[data.config] = option;
}
ConfigManager.ONSConfig.updateData(); ConfigManager.ONSConfig.updateData();
}; };
//============================================================================= //=============================================================================

View file

@ -836,9 +836,9 @@ Window_OmoMenuOptionsONSControls.prototype.makeOptionsList = function () {
// Get Text // Get Text
//var text = LanguageManager.getPluginText('optionsMenu', 'audio'); //var text = LanguageManager.getPluginText('optionsMenu', 'audio');
var text = { var text = {
buttonsScale: {help: "Изменить размер наэкранных кнопок управления.", text: "РАЗМЕР УПРАВЛЕНИЯ", isBar: true, persent: true, minValue: 0, maxValue: 500}, buttonsScale: {help: "Изменить размер наэкранных кнопок управления.", text: "РАЗМЕР УПРАВЛЕНИЯ", isBar: true, minValue: 0, maxValue: 500},
buttonsOpacity: {help: "Изменить прозрачность наэкранных кнопок управления.", text: "ПРОЗРАЧНОСТЬ УПРАВЛЕНИЯ", isBar: true, persent: true, minValue: 0, maxValue: 100}, buttonsOpacity: {help: "Изменить прозрачность наэкранных кнопок управления.", text: "ПРОЗРАЧНОСТЬ УПРАВЛЕНИЯ", isBar: true, minValue: 0, maxValue: 100},
safeArea: {help: "Изменить размер безопасной области для управления.", text: "БЕЗОПАСНАЯ ОБЛАСТЬ", isBar: true, persent: true, minValue: 10, maxValue: 100}, safeArea: {help: "Изменить размер безопасной области для управления.", text: "БЕЗОПАСНАЯ ОБЛАСТЬ", isBar: true, minValue: 10, maxValue: 100},
editMenu: {help: "Нажмите кнопку влево или вправо, чтобы открыть меню.", text: "ОТКРЫТЬ МЕНЮ НАСТРОЕК", isBar: false} editMenu: {help: "Нажмите кнопку влево или вправо, чтобы открыть меню.", text: "ОТКРЫТЬ МЕНЮ НАСТРОЕК", isBar: false}
} }
// Get Config // Get Config
@ -855,11 +855,7 @@ Window_OmoMenuOptionsONSControls.prototype.makeOptionsList = function () {
var data = text[name]; var data = text[name];
// Add Option // Add Option
if (data.isBar) { if (data.isBar) {
if (data.persent) { this._optionsList.push({ header: data.text + ':', config: name, option: ConfigManager.ONSConfig[name] * 100, helpText: data.help, isBar: data.isBar, minValue: data.minValue, maxValue: data.maxValue });
this._optionsList.push({ header: data.text + ':', config: name, option: ConfigManager.ONSConfig[name] * 100, helpText: data.help, isBar: data.isBar, persent: data.persent, minValue: data.minValue, maxValue: data.maxValue });
} else {
this._optionsList.push({ header: data.text + ':', config: name, option: ConfigManager.ONSConfig[name], helpText: data.help, isBar: data.isBar, persent: data.persent, minValue: data.minValue, maxValue: data.maxValue });
}
} else { } else {
this._optionsList.push({ header: data.text, config: name, helpText: data.help, isBar: data.isBar}); this._optionsList.push({ header: data.text, config: name, helpText: data.help, isBar: data.isBar});
} }
@ -879,7 +875,7 @@ Window_OmoMenuOptionsONSControls.prototype.drawItem = function (index) {
this.contents.drawText(data.header, rect.x + 50, rect.y, rect.width, 24); this.contents.drawText(data.header, rect.x + 50, rect.y, rect.width, 24);
// Update option bar // Update option bar
if (data.isBar) { if (data.isBar) {
this.updateOptionBar(index, data.option, data.persent); this.updateOptionBar(index, data.option);
} }
}; };
}; };
@ -907,7 +903,7 @@ Window_OmoMenuOptionsONSControls.prototype.cursorRight = function (wrap) {
var rate = Input.isLongPressed('right') ? 5 : 5 var rate = Input.isLongPressed('right') ? 5 : 5
data.option = Math.min(data.option + rate, data.maxValue); data.option = Math.min(data.option + rate, data.maxValue);
if (data.isBar) { if (data.isBar) {
this.updateOptionBar(this.index(), data.option, data.persent); this.updateOptionBar(this.index(), data.option);
} else { } else {
ONSControls.openEditMode(); ONSControls.openEditMode();
} }
@ -926,7 +922,7 @@ Window_OmoMenuOptionsONSControls.prototype.cursorLeft = function (wrap) {
var rate = Input.isLongPressed('left') ? 5 : 5 var rate = Input.isLongPressed('left') ? 5 : 5
data.option = Math.max(data.option - rate, data.minValue); data.option = Math.max(data.option - rate, data.minValue);
if (data.isBar) { if (data.isBar) {
this.updateOptionBar(this.index(), data.option, data.persent); this.updateOptionBar(this.index(), data.option);
} else { } else {
ONSControls.openEditMode(); ONSControls.openEditMode();
} }
@ -935,7 +931,7 @@ Window_OmoMenuOptionsONSControls.prototype.cursorLeft = function (wrap) {
//============================================================================= //=============================================================================
// * Update option bar // * Update option bar
//============================================================================= //=============================================================================
Window_OmoMenuOptionsONSControls.prototype.updateOptionBar = function (index, option, persent) { Window_OmoMenuOptionsONSControls.prototype.updateOptionBar = function (index, option) {
// Get Data // Get Data
var data = this._optionsList[index]; var data = this._optionsList[index];
// Get Back and Front Sprite // Get Back and Front Sprite
@ -946,15 +942,9 @@ Window_OmoMenuOptionsONSControls.prototype.updateOptionBar = function (index, op
var rect = this.itemRect(index); var rect = this.itemRect(index);
rect.x += 415; rect.y += 27; rect.width = 100; rect.height = 40; rect.x += 415; rect.y += 27; rect.width = 100; rect.height = 40;
this.contents.clearRect(rect.x, rect.y, rect.width, rect.height); this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
if (persent) { this.contents.drawText(Math.round(option) + '%', rect.x, rect.y, rect.width, rect.height, 'right');
this.contents.drawText(option + '%', rect.x, rect.y, rect.width, rect.height, 'right');
// Set Option // Set Option
ConfigManager.ONSConfig[data.config] = option / 100; ConfigManager.ONSConfig[data.config] = option / 100;
} else {
this.contents.drawText(Math.round(option) + 'px', rect.x, rect.y, rect.width, rect.height, 'right');
// Set Option
ConfigManager.ONSConfig[data.config] = option;
}
ConfigManager.ONSConfig.updateData(); ConfigManager.ONSConfig.updateData();
}; };
//============================================================================= //=============================================================================