messagesoverlay - Cleanup variable use for scrolling
parent
3c6eae9580
commit
b7f003eec6
|
|
@ -139,11 +139,6 @@ let drawScreen = function(ovr, title, titleFont, src, iconcolor, icon){
|
||||||
let showMessage = function(ovr, msg) {
|
let showMessage = function(ovr, msg) {
|
||||||
LOG("showMessage");
|
LOG("showMessage");
|
||||||
|
|
||||||
if (typeof msg.CanscrollDown === "undefined")
|
|
||||||
msg.CanscrollDown = false;
|
|
||||||
if (typeof msg.CanscrollUp === "undefined")
|
|
||||||
msg.CanscrollUp = false;
|
|
||||||
|
|
||||||
// Normal text message display
|
// Normal text message display
|
||||||
let title = msg.title,
|
let title = msg.title,
|
||||||
titleFont = settings.fontLarge,
|
titleFont = settings.fontLarge,
|
||||||
|
|
@ -266,25 +261,16 @@ let drawTriangleDown = function(ovr) {
|
||||||
let scrollUp = function(ovr) {
|
let scrollUp = function(ovr) {
|
||||||
let msg = eventQueue[0];
|
let msg = eventQueue[0];
|
||||||
LOG("up", msg);
|
LOG("up", msg);
|
||||||
if (typeof msg.FirstLine === "undefined")
|
|
||||||
msg.FirstLine = 0;
|
|
||||||
if (typeof msg.CanscrollUp === "undefined")
|
|
||||||
msg.CanscrollUp = false;
|
|
||||||
|
|
||||||
if (!msg.CanscrollUp) return;
|
if (!msg.CanscrollUp) return;
|
||||||
|
|
||||||
msg.FirstLine = msg.FirstLine > 0 ? msg.FirstLine - 1 : 0;
|
msg.FirstLine = msg.FirstLine > 0 ? msg.FirstLine - 1 : 0;
|
||||||
|
|
||||||
drawMessage(ovr, msg);
|
drawMessage(ovr, msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
let scrollDown = function(ovr) {
|
let scrollDown = function(ovr) {
|
||||||
let msg = eventQueue[0];
|
let msg = eventQueue[0];
|
||||||
LOG("down", msg);
|
LOG("down", msg);
|
||||||
if (typeof msg.FirstLine === "undefined")
|
|
||||||
msg.FirstLine = 0;
|
|
||||||
if (typeof msg.CanscrollDown === "undefined")
|
|
||||||
msg.CanscrollDown = false;
|
|
||||||
|
|
||||||
if (!msg.CanscrollDown) return;
|
if (!msg.CanscrollDown) return;
|
||||||
|
|
||||||
|
|
@ -309,7 +295,7 @@ let drawMessage = function(ovr, msg) {
|
||||||
ovr.setColor(ovr.theme.fg);
|
ovr.setColor(ovr.theme.fg);
|
||||||
ovr.setBgColor(ovr.theme.bg);
|
ovr.setBgColor(ovr.theme.bg);
|
||||||
|
|
||||||
if (typeof msg.FirstLine === "undefined") msg.FirstLine = 0;
|
if (msg.FirstLine === undefined) msg.FirstLine = 0;
|
||||||
|
|
||||||
let padding = eventQueue.length > 1 ? (eventQueue.length > 3 ? 7 : 5) : 3;
|
let padding = eventQueue.length > 1 ? (eventQueue.length > 3 ? 7 : 5) : 3;
|
||||||
|
|
||||||
|
|
@ -318,7 +304,7 @@ let drawMessage = function(ovr, msg) {
|
||||||
|
|
||||||
let maxTextHeight = ovr.getHeight() - yLine - padding;
|
let maxTextHeight = ovr.getHeight() - yLine - padding;
|
||||||
|
|
||||||
if (typeof msg.lines === "undefined") {
|
if (!msg.lines) {
|
||||||
let bodyFont = settings.fontBig;
|
let bodyFont = settings.fontBig;
|
||||||
ovr.setFont(bodyFont);
|
ovr.setFont(bodyFont);
|
||||||
msg.lines = wrapString(msg.body, ovr.getWidth() - 4 - padding);
|
msg.lines = wrapString(msg.body, ovr.getWidth() - 4 - padding);
|
||||||
|
|
@ -331,11 +317,12 @@ let drawMessage = function(ovr, msg) {
|
||||||
msg.bodyFont = bodyFont;
|
msg.bodyFont = bodyFont;
|
||||||
msg.lineHeights = [];
|
msg.lineHeights = [];
|
||||||
msg.lines.forEach((line, i) => {
|
msg.lines.forEach((line, i) => {
|
||||||
let metrics = ovr.stringMetrics(line);
|
msg.lineHeights[i] = getStringHeight(line);
|
||||||
msg.lineHeights[i] = Math.max(metrics.height, metrics.maxImageHeight);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG("Prepared message", msg);
|
||||||
|
|
||||||
ovr.setFont(msg.bodyFont);
|
ovr.setFont(msg.bodyFont);
|
||||||
ovr.setColor(ovr.theme.fg);
|
ovr.setColor(ovr.theme.fg);
|
||||||
ovr.setBgColor(ovr.theme.bg);
|
ovr.setBgColor(ovr.theme.bg);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue