Skip to content

Commit edc234d

Browse files
authored
Merge pull request #25 from IPdotSetAF/14-date-and-clock-style
14 date and clock style
2 parents 319eff2 + 29894c7 commit edc234d

File tree

3 files changed

+107
-50
lines changed

3 files changed

+107
-50
lines changed

SucroseProperties.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
"items": [
240240
"None",
241241
"Horizontal",
242+
"Stacked",
242243
"Vertical"
243244
]
244245
},
@@ -371,6 +372,16 @@
371372
"type": "checkbox",
372373
"value": false
373374
},
375+
"ui_date_style": {
376+
"text": "Style",
377+
"type": "dropdown",
378+
"value": 0,
379+
"items": [
380+
"Horizontal",
381+
"Stacked",
382+
"Vertical"
383+
]
384+
},
374385
"ui_date_delimiter": {
375386
"type": "dropdown",
376387
"text": "Date Delimiter",
@@ -383,11 +394,6 @@
383394
"/"
384395
]
385396
},
386-
"ui_date_orientation": {
387-
"text": "Vertical Orientation",
388-
"type": "checkbox",
389-
"value": false
390-
},
391397
"ui_date_scale": {
392398
"max": 10,
393399
"min": 0,

js/index.js

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ window.onload = function () {
6363
ui_day_positionX: 0,
6464
ui_day_positionY: 0,
6565
ui_date_date: "0",
66-
ui_date_orientation: false,
66+
ui_date_style: "0",
6767
ui_date_year: "2",
6868
ui_date_order: "0",
6969
ui_date_monthName: false,
@@ -202,7 +202,7 @@ window.onload = function () {
202202
dateFolder.add(options, "ui_date_monthName").name("Month Name").onChange(updateMask);
203203
dateFolder.add(options, "ui_date_allCaps").name("All CAPS").onChange(updateMask);
204204
dateFolder.add(options, "ui_date_delimiter", optionsToDict(config.general.properties.ui_date_delimiter.options)).name("Delimiter").onChange(updateMask);
205-
dateFolder.add(options, "ui_date_orientation").name("Vertical Orientation").onChange(updateMask);
205+
dateFolder.add(options, "ui_date_style", optionsToDict(config.general.properties.ui_date_style.options)).name("Style").onChange(updateMask);
206206
dateFolder.add(options, "ui_date_scale").min(0).max(10).step(1).name("Scale").onChange(updateMask);
207207
const datePositionFolder = dateFolder.addFolder("Position");
208208
datePositionFolder.add(options, "ui_date_positionX").min(-100).max(100).step(1).name("X").onChange(updateMask);
@@ -346,8 +346,8 @@ window.onload = function () {
346346
options.ui_date_date = properties.ui_date_date.value;
347347
updateTime();
348348
}
349-
if (properties.ui_date_orientation)
350-
options.ui_date_orientation = properties.ui_date_orientation.value;
349+
if (properties.ui_date_style)
350+
options.ui_date_style = properties.ui_date_style.value;
351351
if (properties.ui_date_year)
352352
options.ui_date_year = properties.ui_date_year.value;
353353
if (properties.ui_date_order)
@@ -364,7 +364,7 @@ window.onload = function () {
364364
options.ui_date_positionX = properties.ui_date_positionx.value;
365365
if (properties.ui_date_positiony)
366366
options.ui_date_positionY = properties.ui_date_positiony.value;
367-
if (properties.ui_date_date || properties.ui_date_orientation || properties.ui_date_year ||
367+
if (properties.ui_date_date || properties.ui_date_style || properties.ui_date_year ||
368368
properties.ui_date_order || properties.ui_date_monthname || properties.ui_date_allcaps ||
369369
properties.ui_date_delimiter || properties.ui_date_scale || properties.ui_date_positionx
370370
|| properties.ui_date_positiony)
@@ -541,8 +541,8 @@ window.onload = function () {
541541
updateTime();
542542
updateMask();
543543
break;
544-
case "ui_date_orientation":
545-
options.ui_date_orientation = val.value;
544+
case "ui_date_style":
545+
options.ui_date_style = val.value;
546546
updateMask();
547547
break;
548548
case "ui_date_year":
@@ -725,6 +725,9 @@ window.onload = function () {
725725
hour = "0" + hour;
726726
if (minute < 10)
727727
minute = "0" + minute;
728+
729+
hour = hour.toString();
730+
minute = minute.toString();
728731
}
729732

730733
//MARK: Mask
@@ -750,22 +753,36 @@ window.onload = function () {
750753

751754
switch (options.ui_clock_clock) {
752755
case "1": {
756+
let clock = hour + ":" + minute;
753757
if (options.ui_clock_scale > 0) {
754758
let center = [Math.floor((columns - 17 * options.ui_clock_scale) / 2), Math.floor((rows - 5 * options.ui_clock_scale) / 2)];
755-
drawTextOnMask(hour + ":" + minute, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY, options.ui_clock_scale);
759+
drawTextOnMask(clock, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY, options.ui_clock_scale);
756760
} else {
757761
let center = [Math.floor((columns - 5) / 2), Math.floor((rows - 1) / 2)];
758-
drawTextOnMatrix(hour + ":" + minute, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY);
762+
drawTextOnMatrix(clock, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY);
759763
}
760764
break;
761765
}
762766
case "2": {
767+
let clock = hour + "\\n" + minute;
763768
if (options.ui_clock_scale > 0) {
764769
let center = [Math.floor((columns - 7 * options.ui_clock_scale) / 2), Math.floor((rows - 11 * options.ui_clock_scale) / 2)];
765-
drawTextOnMask(hour + "\\n" + minute, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY, options.ui_clock_scale);
770+
drawTextOnMask(clock, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY, options.ui_clock_scale);
766771
} else {
767772
let center = [Math.floor((columns - 2) / 2), Math.floor((rows - 2) / 2)];
768-
drawTextOnMatrix(hour + "\\n" + minute, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY);
773+
drawTextOnMatrix(clock, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY);
774+
}
775+
break;
776+
}
777+
case "3": {
778+
let h = hour.split("").join("\\n"), m = minute.split("").join("\\n");
779+
let clock = h + "\\n" + m;
780+
if (options.ui_clock_scale > 0) {
781+
let center = [Math.floor((columns - 3 * options.ui_clock_scale) / 2), Math.floor((rows - 23 * options.ui_clock_scale) / 2)];
782+
drawTextOnMask(clock, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY, options.ui_clock_scale);
783+
} else {
784+
let center = [Math.floor((columns - 1) / 2), Math.floor((rows - 4) / 2)];
785+
drawTextOnMatrix(clock, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY);
769786
}
770787
break;
771788
}
@@ -789,33 +806,48 @@ window.onload = function () {
789806
}
790807

791808
if (options.ui_date_date != "0") {
792-
var dateText = date.toString(), monthText, yearText = "", completeDate;
793-
if (dateText.length < 2)
794-
dateText = "0" + dateText;
809+
var text3 = date.toString(), text2, text1 = "", completeDate;
810+
if (text3.length < 2)
811+
text3 = "0" + text3;
795812
if (options.ui_date_monthName) {
796-
monthText = months[parseInt(options.ui_date_date) - 1][month - 1];
813+
text2 = months[parseInt(options.ui_date_date) - 1][month - 1];
797814
if (options.ui_date_allCaps)
798-
monthText = monthText.toUpperCase();
815+
text2 = text2.toUpperCase();
799816
} else {
800-
monthText = month.toString();
801-
if (monthText.length < 2)
802-
monthText = "0" + monthText;
817+
text2 = month.toString();
818+
if (text2.length < 2)
819+
text2 = "0" + text2;
803820
}
804821
switch (options.ui_date_year) {
805822
case "1": {
806-
yearText = year.toString().substring(2, 4);
823+
text1 = year.toString().substring(2, 4);
807824
break;
808825
}
809826
case "2": {
810-
yearText = year.toString();
827+
text1 = year.toString();
811828
break;
812829
}
813830
}
814831

815-
let delimiter = options.ui_date_orientation ? "" : dateDelimiters[parseInt(options.ui_date_delimiter)];
816-
completeDate = yearText + (yearText.length > 0 ? delimiter : "") + (options.ui_date_order == "0" ? monthText + delimiter + dateText : dateText + delimiter + monthText);
817-
if (options.ui_date_orientation)
818-
completeDate = completeDate.split("").join("\\n");
832+
if(options.ui_date_order == 1){
833+
let tmp = text2;
834+
text2 = text3;
835+
text3 = tmp;
836+
}
837+
838+
let delimiter = dateDelimiters[parseInt(options.ui_date_delimiter)];
839+
840+
switch (options.ui_date_style) {
841+
case "0":
842+
completeDate = (text1.length > 0 ? [text1, text2, text3] : [text2, text3]).join(delimiter);
843+
break;
844+
case "1":
845+
completeDate = (text1.length > 0 ? [text1, text2, text3] : [text2, text3]).join("\\n");
846+
break;
847+
case "2":
848+
completeDate = (text1 + text2 + text3).split("").join("\\n");
849+
break;
850+
}
819851

820852
if (options.ui_date_scale > 0) {
821853
let bb = getTextBoundingBox(completeDate, options.ui_date_scale);

project.json

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,12 @@
502502
"value" : "1"
503503
},
504504
{
505-
"label" : "Vertical",
505+
"label" : "Stacked",
506506
"value" : "2"
507+
},
508+
{
509+
"label" : "Vertical",
510+
"value" : "3"
507511
}
508512
],
509513
"order" : 130,
@@ -688,7 +692,7 @@
688692
},
689693
"ui_date_year" :
690694
{
691-
"condition" : "ui_date_date.value",
695+
"condition" : "ui_date_date.value != 0",
692696
"index" : 45,
693697
"options" :
694698
[
@@ -712,7 +716,7 @@
712716
},
713717
"ui_date_order" :
714718
{
715-
"condition" : "ui_date_date.value",
719+
"condition" : "ui_date_date.value != 0",
716720
"index" : 46,
717721
"options" :
718722
[
@@ -731,25 +735,49 @@
731735
"value" : "0"
732736
},
733737
"ui_date_monthname" : {
734-
"condition" : "ui_date_date.value",
738+
"condition" : "ui_date_date.value != 0",
735739
"index" : 47,
736740
"order" : 147,
737741
"text" : "Month Name",
738742
"type" : "bool",
739743
"value": false
740744
},
741745
"ui_date_allcaps" : {
742-
"condition" : "ui_date_date.value",
746+
"condition" : "ui_date_date.value != 0",
743747
"index" : 48,
744748
"order" : 148,
745749
"text" : "All CAPS",
746750
"type" : "bool",
747751
"value": false
748752
},
749-
"ui_date_delimiter" :
753+
"ui_date_style" :
750754
{
755+
"condition" : "ui_date_date.value != 0",
751756
"index" : 49,
752-
"condition" : "ui_date_date.value && !ui_date_orientation.value",
757+
"order" : 149,
758+
"options" :
759+
[
760+
{
761+
"label" : "Horizontal",
762+
"value" : "0"
763+
},
764+
{
765+
"label" : "Stacked",
766+
"value" : "1"
767+
},
768+
{
769+
"label" : "Vertical",
770+
"value" : "2"
771+
}
772+
],
773+
"text" : "Style",
774+
"type" : "combo",
775+
"value" : "0"
776+
},
777+
"ui_date_delimiter" :
778+
{
779+
"index" : 50,
780+
"condition" : "ui_date_date.value != 0 && ui_date_orientation.value == 0",
753781
"options" :
754782
[
755783
{
@@ -773,23 +801,14 @@
773801
"value" : "4"
774802
}
775803
],
776-
"order" : 149,
804+
"order" : 150,
777805
"text" : "Date Delimiter",
778806
"type" : "combo",
779807
"value" : "0"
780808
},
781-
"ui_date_orientation" :
782-
{
783-
"condition" : "ui_date_date.value",
784-
"index" : 50,
785-
"order" : 150,
786-
"text" : "Vertical Orientation",
787-
"type" : "bool",
788-
"value" : false
789-
},
790809
"ui_date_scale" :
791810
{
792-
"condition" : "ui_date_date.value",
811+
"condition" : "ui_date_date.value != 0",
793812
"fraction" : false,
794813
"index" : 51,
795814
"max" : 10,
@@ -801,7 +820,7 @@
801820
},
802821
"ui_date_positionx" :
803822
{
804-
"condition" : "ui_date_date.value",
823+
"condition" : "ui_date_date.value != 0",
805824
"fraction" : false,
806825
"index" : 52,
807826
"max" : 100,
@@ -813,7 +832,7 @@
813832
},
814833
"ui_date_positiony" :
815834
{
816-
"condition" : "ui_date_date.value",
835+
"condition" : "ui_date_date.value != 0",
817836
"fraction" : false,
818837
"index" : 53,
819838
"max" : 100,

0 commit comments

Comments
 (0)