From 2af7f215954c4a9de597f906c81e329a787cc1bc Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Sun, 12 Jun 2022 15:30:43 +0200 Subject: [PATCH] Added colored buttons --- Macro Deck Client.Android/Assets/client.js | 18 +++++++++++++++--- .../Properties/AndroidManifest.xml | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Macro Deck Client.Android/Assets/client.js b/Macro Deck Client.Android/Assets/client.js index 3d1ccc5..0940ba5 100644 --- a/Macro Deck Client.Android/Assets/client.js +++ b/Macro Deck Client.Android/Assets/client.js @@ -120,6 +120,7 @@ function connect(url) { var labels = document.getElementsByClassName("label"); for (var i = 0; i < actionButtons.length; i++) { actionButtons[i].style.backgroundImage = ''; + actionButtons[i].classList.toggle("btn-secondary", true); labels[i].style.backgroundImage = ''; } @@ -163,7 +164,13 @@ function connect(url) { button.style.backgroundImage = 'url(data:image/gif;base64,' + icon.IconBase64 + ')'; } else if (this.buttons[i].IconBase64) { button.style.backgroundImage = 'url(data:image/gif;base64,' + this.buttons[i].IconBase64 + ')'; - } + } + + button.classList.toggle("btn-secondary", !this.buttons[i].BackgroundColorHex); + + if (this.buttons[i].BackgroundColorHex) { + button.style.backgroundColor = this.buttons[i].BackgroundColorHex; + } } if (label) { @@ -215,6 +222,12 @@ function connect(url) { } else { button.style.backgroundImage = ''; } + + button.classList.toggle("btn-secondary", !obj.Buttons[0].BackgroundColorHex); + + if (obj.Buttons[0].BackgroundColorHex) { + button.style.backgroundColor = obj.Buttons[0].BackgroundColorHex; + } } var label = document.getElementById("label_" + obj.Buttons[0].Position_Y + "_" + obj.Buttons[0].Position_X); @@ -268,9 +281,8 @@ function generateGrid(columns, rows) { column.setAttribute("id", "col_" + i + "_" + j); column.classList.add("col"); column.classList.add("blockBox"); - var button = document.createElement("button"); + var button = document.createElement("div"); button.classList.add("action-button"); - button.classList.add("btn"); button.classList.toggle("btn-secondary", buttonBackground); button.setAttribute("id", i + "_" + j); $(button).bind('touchstart', function() { diff --git a/Macro Deck Client.Android/Properties/AndroidManifest.xml b/Macro Deck Client.Android/Properties/AndroidManifest.xml index 4457a0b..2bc8f00 100644 --- a/Macro Deck Client.Android/Properties/AndroidManifest.xml +++ b/Macro Deck Client.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - +