Dropping single line menu support
This commit is contained in:
@@ -106,17 +106,14 @@
|
||||
if (!isDefined(mode) || mode == 0) {
|
||||
// return direct length
|
||||
return obj.length;
|
||||
} else if (mode == 1) {
|
||||
// return length of text property
|
||||
return obj.text.length;
|
||||
} else if (mode == 2) {
|
||||
// return the longest length in text2 array
|
||||
return Math.max(isDefinedNN(obj.text2[0]) ? obj.text2[0].length : 0, isDefinedNN(obj.text2[1]) ? obj.text2[1].length : 0);
|
||||
}
|
||||
// return the longest length in text2 array
|
||||
return Math.max(isDefinedNN(obj.text2[0]) ? obj.text2[0].length : 0, isDefinedNN(obj.text2[1]) ? obj.text2[1].length : 0);
|
||||
|
||||
}
|
||||
|
||||
function getAttribute(obj, attribute, isDouble) {
|
||||
var d = isDouble ? "2" : "";
|
||||
function getAttribute(obj, attribute) {
|
||||
var d = "2";
|
||||
var v = obj[attribute+d];
|
||||
if (isDefined(v))
|
||||
return v;
|
||||
@@ -140,7 +137,6 @@
|
||||
loaded: false,
|
||||
},
|
||||
obsolete : {},
|
||||
menuDouble : false
|
||||
},
|
||||
methods : {
|
||||
validateInput: function(valMap, id, mode) {
|
||||
@@ -170,16 +166,11 @@
|
||||
}
|
||||
},
|
||||
|
||||
constraintString: function(e, d) {
|
||||
constraintString: function(e) {
|
||||
var str = "";
|
||||
var delim = "";
|
||||
var v;
|
||||
if (!isDefined(d) || d == false) {
|
||||
d = "";
|
||||
} else {
|
||||
d = "2";
|
||||
}
|
||||
|
||||
d = "2";
|
||||
if (isDefinedNN(e.lenSum)) {
|
||||
str = "len("+(e.lenSum.fields+"").replace(/,/g," + ")+") -> ";
|
||||
e = e.lenSum;
|
||||
@@ -312,27 +303,12 @@
|
||||
|
||||
<h2>Menu Options</h2>
|
||||
<table class="data">
|
||||
<tr>
|
||||
<td class="label">Menu Type</td>
|
||||
<td class="value">
|
||||
<select v-model="current.menuDouble" v-on:change="current.menuDouble = current.menuDouble=='true'">
|
||||
<option value="false">Single-Line</option>
|
||||
<option value="true">Double-Line</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="menu in def.menuOptions" v-bind:class="validateInput(current.menuOptions, menu.id, (current.menuDouble ? 2 : 1))">
|
||||
<tr v-for="menu in def.menuOptions" v-bind:class="validateInput(current.menuOptions, menu.id, 2)">
|
||||
<td class="label"><div class="stringId">{{menu.id}}</div></td>
|
||||
<td class="value">
|
||||
<div v-bind:class="{hidden : current.menuDouble}">
|
||||
<div class="label">Menu Name (Single-Line)</div>
|
||||
<div class="constraint">{{constraintString(menu, current.menuDouble)}}</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].text}}</div>
|
||||
<div class="tran"><input type="text" v-model="current.menuOptions[menu.id].text" v-bind:class="{unchanged : current.menuOptions[menu.id].text == referent.menuOptions[menu.id].text, empty : current.menuOptions[menu.id].text == ''}"></div>
|
||||
</div>
|
||||
<div v-bind:class="{hidden : !current.menuDouble}">
|
||||
<div v-bind:class="{hidden : false}">
|
||||
<div class="label">Menu Name (Double-Line)</div>
|
||||
<div class="constraint">{{constraintString(menu, current.menuDouble)}}</div>
|
||||
<div class="constraint">{{constraintString(menu)}}</div>
|
||||
<div class="ref">{{referent.menuOptions[menu.id].text2}}</div>
|
||||
<div class="tran" v-bind:class="{unchanged : current.menuOptions[menu.id].text2[0] == referent.menuOptions[menu.id].text2[0] && current.menuOptions[menu.id].text2[1] == referent.menuOptions[menu.id].text2[1], empty : current.menuOptions[menu.id].text2[0] == '' || current.menuOptions[menu.id].text2[1] == ''}"><input type="text" v-model="current.menuOptions[menu.id].text2[0]"><input type="text" v-model="current.menuOptions[menu.id].text2[1]"></div>
|
||||
</div>
|
||||
|
||||
@@ -87,7 +87,6 @@
|
||||
cyrillicGlyphs: false,
|
||||
messages: {},
|
||||
characters: {},
|
||||
menuDouble : false,
|
||||
menuGroups: {},
|
||||
menuOptions: {}
|
||||
};
|
||||
@@ -109,7 +108,6 @@
|
||||
reMenuMode.lastIndex = 0;
|
||||
match = reMenuMode.exec(line);
|
||||
if (match) {
|
||||
lang.menuDouble = match[1] == 'DOUBLE';
|
||||
entryIndex = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -234,7 +232,6 @@
|
||||
if (!isDefined(entry)) {
|
||||
entry =
|
||||
{
|
||||
"text": "",
|
||||
"text2": ["", ""],
|
||||
"desc": ""
|
||||
}
|
||||
|
||||
@@ -167,11 +167,8 @@ def getLetterCounts(defs, lang):
|
||||
obj = lang['menuOptions']
|
||||
for mod in defs['menuOptions']:
|
||||
eid = mod['id']
|
||||
if lang['menuDouble']:
|
||||
textList.append(obj[eid]['text2'][0])
|
||||
textList.append(obj[eid]['text2'][1])
|
||||
else:
|
||||
textList.append(obj[eid]['text'])
|
||||
textList.append(obj[eid]['text2'][0])
|
||||
textList.append(obj[eid]['text2'][1])
|
||||
|
||||
obj = lang['menuGroups']
|
||||
for mod in defs['menuGroups']:
|
||||
@@ -369,14 +366,6 @@ def writeLanguage(languageCode, defs, f):
|
||||
c) + "\"," + "//{} \n".format(c)))
|
||||
f.write(to_unicode("};\n\n"))
|
||||
|
||||
# ----- Menu Options
|
||||
|
||||
# Menu type
|
||||
f.write(
|
||||
to_unicode(
|
||||
"const enum ShortNameType SettingsShortNameType = SHORT_NAME_" +
|
||||
("DOUBLE" if lang['menuDouble'] else "SINGLE") + "_LINE;\n"))
|
||||
|
||||
# ----- Writing SettingsDescriptions
|
||||
obj = lang['menuOptions']
|
||||
f.write(to_unicode("const char* SettingsShortNames[][2] = {\n"))
|
||||
@@ -388,19 +377,14 @@ def writeLanguage(languageCode, defs, f):
|
||||
if 'feature' in mod:
|
||||
f.write(to_unicode("#ifdef " + mod['feature'] + "\n"))
|
||||
f.write(to_unicode(" /* ["+"{:02d}".format(index)+"] " + eid.ljust(maxLen)[:maxLen] + " */ "))
|
||||
if lang['menuDouble']:
|
||||
f.write(
|
||||
to_unicode(
|
||||
"{ \"" +
|
||||
convStr(symbolConversionTable, (obj[eid]['text2'][0])) +
|
||||
"\", \"" +
|
||||
convStr(symbolConversionTable, (obj[eid]['text2'][1])) +
|
||||
"\" }," + "//{} \n".format(obj[eid]['text2'])))
|
||||
else:
|
||||
f.write(
|
||||
to_unicode("{ \"" +
|
||||
convStr(symbolConversionTable, (obj[eid]['text'])) +
|
||||
"\" }," + "//{} \n".format(obj[eid]['text'])))
|
||||
f.write(
|
||||
to_unicode(
|
||||
"{ \"" +
|
||||
convStr(symbolConversionTable, (obj[eid]['text2'][0])) +
|
||||
"\", \"" +
|
||||
convStr(symbolConversionTable, (obj[eid]['text2'][1])) +
|
||||
"\" }," + "//{} \n".format(obj[eid]['text2'])))
|
||||
|
||||
if 'feature' in mod:
|
||||
f.write(to_unicode("#endif\n"))
|
||||
index = index + 1
|
||||
|
||||
@@ -9,16 +9,12 @@
|
||||
#define TRANSLATION_H_
|
||||
#include "unit.h"
|
||||
#include "stdint.h"
|
||||
enum ShortNameType {
|
||||
SHORT_NAME_SINGLE_LINE = 1, SHORT_NAME_DOUBLE_LINE = 2,
|
||||
};
|
||||
extern const uint8_t USER_FONT_12[];
|
||||
extern const uint8_t USER_FONT_6x8[];
|
||||
/*
|
||||
* When SettingsShortNameType is SHORT_NAME_SINGLE_LINE
|
||||
* use SettingsShortNames as SettingsShortNames[16][1].. second column undefined
|
||||
*/
|
||||
extern const enum ShortNameType SettingsShortNameType;
|
||||
extern const char *SettingsShortNames[28][2];
|
||||
extern const char *SettingsDescriptions[28];
|
||||
extern const char *SettingsMenuEntries[4];
|
||||
|
||||
@@ -230,12 +230,6 @@ const menuitem advancedMenu[] = {
|
||||
{ NULL, NULL, NULL } // end of menu marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
static void printShortDescriptionSingleLine(uint32_t shortDescIndex) {
|
||||
OLED::setFont(0);
|
||||
OLED::setCharCursor(0, 0);
|
||||
OLED::print(SettingsShortNames[shortDescIndex][0]);
|
||||
}
|
||||
|
||||
static void printShortDescriptionDoubleLine(uint32_t shortDescIndex) {
|
||||
OLED::setFont(1);
|
||||
OLED::setCharCursor(0, 0);
|
||||
@@ -254,11 +248,7 @@ static void printShortDescriptionDoubleLine(uint32_t shortDescIndex) {
|
||||
static void printShortDescription(uint32_t shortDescIndex,
|
||||
uint16_t cursorCharPosition) {
|
||||
// print short description (default single line, explicit double line)
|
||||
if (SettingsShortNameType == SHORT_NAME_DOUBLE_LINE) {
|
||||
printShortDescriptionDoubleLine(shortDescIndex);
|
||||
} else {
|
||||
printShortDescriptionSingleLine(shortDescIndex);
|
||||
}
|
||||
printShortDescriptionDoubleLine(shortDescIndex);
|
||||
|
||||
// prepare cursor for value
|
||||
OLED::setFont(0);
|
||||
|
||||
Reference in New Issue
Block a user