Skip to content

Commit 26d8ce7

Browse files
committed
Added status bar showing theme status. Added check for vdv/splash/brand to validate the theme is available
1 parent 8ca337b commit 26d8ce7

File tree

3 files changed

+259
-7
lines changed

3 files changed

+259
-7
lines changed

src/apim.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
raise Exception("Must be using Python 3.4 or up")
77
# QT Imports
88
try:
9-
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QHBoxLayout, QLabel, QFileDialog, QGroupBox, QMessageBox, QComboBox, QScrollArea, QSizePolicy, QTabWidget, QLineEdit
9+
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QHBoxLayout, QLabel, QFileDialog, QGroupBox, QMessageBox, QComboBox, QScrollArea, QSizePolicy, QTabWidget, QLineEdit, QStatusBar
1010
from PyQt5.QtGui import QDoubleValidator, QRegExpValidator
1111
from PyQt5.QtCore import QRegExp, Qt
1212
from functools import partial
@@ -19,7 +19,7 @@
1919
# local imports
2020
from asbuilt import AsBuilt
2121
from encoder import print_bits_known_de07_08, ItemEncoder, print_duplicates
22-
from statics import JumpTables, Fields
22+
from statics import JumpTables, Fields, ThemeConfig
2323
# global imports
2424
import argparse
2525

@@ -143,11 +143,15 @@ def launch_picker(self):
143143
self.button_save_as = QPushButton("Save as ...") if self.button_save_as is None else self.button_save_as
144144
self.button_save_as.clicked.connect(self.save_file_as)
145145
self.button_save.clicked.connect(self.save)
146+
self.syncversion = QComboBox()
147+
self.syncversion.addItems(["3.0-3.2", "3.4"])
148+
self.syncversion.setCurrentIndex(1)
146149

147150
self.button_group_layout.addWidget(self.button_open)
148151
self.button_group_layout.addWidget(self.button_save)
149152
self.button_group_layout.addWidget(self.button_save_as)
150153
self.button_group_layout.addWidget(self.button_exit)
154+
self.button_group_layout.addWidget(self.syncversion)
151155
self.button_group.setLayout(self.button_group_layout)
152156

153157
## Block group
@@ -231,7 +235,7 @@ def launch_picker(self):
231235
setup_layout.addWidget(scroll_area)
232236
setup.setLayout(setup_layout)
233237

234-
items = self.encoder.QtItemList(x, self.asbuilt, self.textblocks[x-1])
238+
items = self.encoder.QtItemList(x, self.asbuilt, self.textblocks[x-1], self.themechange)
235239
for item in items:
236240
block_items_layout.addLayout(item)
237241
self.tab.append(setup)
@@ -249,8 +253,26 @@ def launch_picker(self):
249253
self.picker_window.setLayout(self.picker_layout)
250254
self.current_window = self.picker_window
251255
#self.picker_window.setSizePolicy(QSizePolicy.Expanding)
256+
self.statusBar = QStatusBar()
257+
self.picker_layout.addWidget(self.statusBar)
258+
self.statusBar.showMessage("")
252259
self.picker_window.show()
253260

261+
def themechange(self):
262+
263+
animation = int(self.textblocks[1][2].text(), 16)
264+
theme = int(self.textblocks[2][2].text(), 16)
265+
brand = (int(self.textblocks[0][5].text(), 16) & 0b11100000) >> 5
266+
267+
#print(theme, animation, brand, self.syncversion.currentText())
268+
matches = ThemeConfig.validate(brand, theme, animation, version=self.syncversion.currentText())
269+
270+
message = "No themes found matching configuration!" if len(matches) == 0 else matches[0] if len(matches) == 1 else "Found %d themes: %s" % (len(matches), "".join(matches))
271+
self.statusBar.showMessage(message)
272+
#print(matches)
273+
#f = ThemeConfig.validate()
274+
275+
254276
def launch_qt(self):
255277
self.app = QApplication([])
256278
self.app.setStyle('Fusion')
@@ -263,6 +285,7 @@ def launch_qt(self):
263285
self.button_exit = QPushButton("Exit")
264286
self.button_exit.clicked.connect(sys.exit)
265287

288+
266289
self.main_layout.addWidget(self.button_open)
267290
self.main_layout.addWidget(self.button_exit)
268291

src/encoder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def byte_loc_string(self, i, bits):
450450
def __init__(self):
451451
self.items = [Fields.block(block) for block in range(1, 10)]
452452

453-
def QtItemList(self, block, asbuilt, bitfields):
453+
def QtItemList(self, block, asbuilt, bitfields, themechange):
454454
qtitems = []
455455
prevbyte = -1
456456
for item in Fields.block(block):
@@ -507,6 +507,8 @@ def QtItemList(self, block, asbuilt, bitfields):
507507
option.setMaximumWidth(400)
508508
option.setCurrentIndex(value)
509509
option.currentIndexChanged.connect(partial(combo_change, option, item, bitfields[item['byte']]))
510+
if 'theme' in item:
511+
option.currentIndexChanged.connect(partial(themechange))
510512
layout.addWidget(label)
511513
layout.addWidget(option)
512514
if unit is not None:

src/statics.py

Lines changed: 230 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,10 @@ def block(cls, block):
658658
'items': 4 ,
659659
'type': 'mask',
660660
'0': 'Ford',
661-
'1': 'Reserved (not used in 3.4)',
661+
'1': 'Ford Timeless / Reserved (3.4)',
662662
'2': 'Lincoln',
663663
'3': 'Configurable Splash Screen (not used in 3.4)',
664+
'theme': True,
664665
},
665666
{
666667
'name': 'Hybrid (HEV)',
@@ -1048,13 +1049,14 @@ def block(cls, block):
10481049
'type': 'ascii',
10491050
},
10501051
{
1051-
'name': 'Splash Screen, also sets some themes',
1052+
'name': 'Splash Screen / Startup Animation',
10521053
'index': 72,
10531054
'byte': 2,
10541055
'bit': 0,
10551056
'size': 8,
10561057
'type': 'table',
10571058
'table': '__SS',
1059+
'theme': True,
10581060
},
10591061
{
10601062
'name': 'Vehicle Style',
@@ -1710,13 +1712,14 @@ def block(cls, block):
17101712
'table': '___V',
17111713
},
17121714
{
1713-
'name': 'Visual Design Variants',
1715+
'name': 'Visual Design Variants / Sync visual Theme',
17141716
'index': 131,
17151717
'byte': 2,
17161718
'bit': 0,
17171719
'size': 8,
17181720
'type': 'table',
17191721
'table': '_VDV',
1722+
'theme': True
17201723
},
17211724
{
17221725
'name': 'Drive Type',
@@ -3775,6 +3778,230 @@ def block(cls, block):
37753778
},
37763779
]
37773780

3781+
class ThemeConfig():
3782+
# checks themeconfig
3783+
themes = [
3784+
"Ford Classic", #0
3785+
"Ford Timeless", #1
3786+
"Lincoln Classic", #2
3787+
"Lincoln Timeless", #3
3788+
"Ford GT (no longer used in 3.4)" #4
3789+
"?", #5
3790+
"?",
3791+
"10L Theme", #7
3792+
"10P Theme" #8
3793+
]
3794+
3795+
config_3_4 = {
3796+
"ford-my20":
3797+
{
3798+
"brand": 0,
3799+
"theme": 0,
3800+
"animation": -1,
3801+
"comment": "Maps to Classic theme but animation might not work"
3802+
},
3803+
"ford-my20-2":
3804+
{
3805+
"brand": 0,
3806+
"theme": 0,
3807+
"animation": 8,
3808+
"comment": "Maps to Classic theme but animation is Vignale Classis"
3809+
},
3810+
"ford-my20-3":
3811+
{
3812+
"brand": 0,
3813+
"theme": 1,
3814+
"animation": -1,
3815+
"comment": "Maps to Classic theme but animation might not work"
3816+
},
3817+
"ford-raptor":
3818+
{
3819+
"brand": 0,
3820+
"theme": 1,
3821+
"animation": 5,
3822+
"comment": None
3823+
},
3824+
"ford-mustang":
3825+
{
3826+
"brand": 0,
3827+
"theme": 1,
3828+
"animation": 6,
3829+
"comment": "Usethemeid is set to 0"
3830+
},
3831+
"ford-evo":
3832+
{
3833+
"brand": 0,
3834+
"theme": 0,
3835+
"animation": 16,
3836+
"comment": None
3837+
},
3838+
"ford-shelby":
3839+
{
3840+
"brand": 0,
3841+
"theme": 1,
3842+
"animation": 7,
3843+
"comment": "Usethemeid is set to 0"
3844+
},
3845+
"ford-vignale":
3846+
{
3847+
"brand": 0,
3848+
"theme": 1,
3849+
"animation": 8,
3850+
"comment": "Usethemeid is set to 0"
3851+
},
3852+
"ford-shelbyR":
3853+
{
3854+
"brand": 0,
3855+
"theme": 1,
3856+
"animation": 9,
3857+
"comment": "Usethemeid is set to 0"
3858+
},
3859+
"ford-st":
3860+
{
3861+
"brand": 0,
3862+
"theme": 1,
3863+
"animation": 11,
3864+
},
3865+
"ford-rs":
3866+
{
3867+
"brand": 0,
3868+
"theme": 1,
3869+
"animation": 12,
3870+
"comment": "Usethemeid is set to 0"
3871+
},
3872+
"ford-my20-former-gt-theme":
3873+
{
3874+
"brand": 0,
3875+
"theme": 4,
3876+
"animation": 13,
3877+
"comment": "Some versions do not function with this theme!",
3878+
"warning": True
3879+
},
3880+
"lincoln-U520":
3881+
{
3882+
"brand": 2,
3883+
"theme": 2,
3884+
"animation": 20,
3885+
"comment": "Marked as obsolete"
3886+
},
3887+
"ford-10p-my20":
3888+
{
3889+
"brand": 0,
3890+
"theme": 8,
3891+
"animation": -1,
3892+
"comment": "Animation change might not work"
3893+
},
3894+
"lincoln-my20":
3895+
{
3896+
"brand": 2,
3897+
"theme": 2,
3898+
"animation": -1,
3899+
"comment": "Marked as obsolete, animation might not work"
3900+
},
3901+
"lincoln-blacklabel":
3902+
{
3903+
"brand": 2,
3904+
"theme": 2,
3905+
"animation": 3,
3906+
"comment": "Usethemeid is set to 3"
3907+
},
3908+
"lincoln-presidential":
3909+
{
3910+
"brand": 2,
3911+
"theme": 2,
3912+
"animation": 4,
3913+
"comment": "Usethemeid is set to 3"
3914+
},
3915+
"lincoln-my20":
3916+
{
3917+
"brand": 2,
3918+
"theme": 3,
3919+
"animation": -1,
3920+
"comment": "Animation might not work, used to be lincoln-next"
3921+
},
3922+
"lincoln-my20-2":
3923+
{
3924+
"brand": 2,
3925+
"theme": 3,
3926+
"animation": 3,
3927+
"comment": "Obsolete is set used to be D544-blacklabel"
3928+
},
3929+
"lincoln-continental":
3930+
{
3931+
"brand": 2,
3932+
"theme": 3,
3933+
"animation": 14,
3934+
"comment": None
3935+
},
3936+
"lincoln-10L-my20":
3937+
{
3938+
"brand": 2,
3939+
"theme": 7,
3940+
"animation": -1,
3941+
"comment": "Animation might not work"
3942+
},
3943+
"lincoln-U611":
3944+
{
3945+
"brand": 2,
3946+
"theme": 7,
3947+
"animation": 17,
3948+
"comment": None
3949+
},
3950+
"ford-10P-st":
3951+
{
3952+
"brand": 0,
3953+
"theme": 8,
3954+
"animation": 11,
3955+
"comment": None
3956+
},
3957+
"ford-U625":
3958+
{
3959+
"brand": 0,
3960+
"theme": 0,
3961+
"animation": 18,
3962+
"comment": None
3963+
},
3964+
"ford-10P-U625":
3965+
{
3966+
"brand": 0,
3967+
"theme": 8,
3968+
"animation": 18,
3969+
"comment": None
3970+
},
3971+
"lincoln-CX483":
3972+
{
3973+
"brand": 2,
3974+
"theme": 3,
3975+
"animation": 19,
3976+
"comment": None
3977+
},
3978+
"lincoln-U540":
3979+
{
3980+
"brand": 2,
3981+
"theme": 3,
3982+
"animation": 20,
3983+
"comment": None
3984+
},
3985+
"ford-CX430":
3986+
{
3987+
"brand": 0,
3988+
"theme": 0,
3989+
"animation": 23,
3990+
"comment": None
3991+
},
3992+
}
3993+
3994+
@classmethod
3995+
def validate(cls, brand, theme, animation, version="3.4"):
3996+
matches = []
3997+
if version == "3.4":
3998+
for k,v in cls.config_3_4.items():
3999+
if (v['brand'] == brand and v['theme'] == theme and v['animation'] == -1) or (v['brand'] == brand and v['theme'] == theme and v['animation'] == animation):
4000+
matches.append("Found theme '%s'. %s" % (k, "" if v['comment'] is None else v['comment']))
4001+
else:
4002+
pass
4003+
return matches
4004+
37784005
class CCTypes():
37794006
ENUM = 1
37804007
FLAG = 2

0 commit comments

Comments
 (0)