taobin_project/xml/menu_new_layout_gen.py
2022-05-19 11:03:07 +07:00

465 lines
17 KiB
Python

if current_file_name == "page_catalog_group_recommend.skt":
touch_less_gen = True
else:
touch_less_gen = False
out_xml('<FrameScroll> \r\n')
if touch_less_gen == True:
out_xml('<Max> 16 </Max>\r\n')
out_xml('<X> 10 </X>\r\n')
out_xml('<Y> 497 </Y>\r\n')
out_xml('<Width> 1080 </Width>\r\n')
out_xml('<ScrollHeight> "auto" </ScrollHeight>\r\n')
out_xml('<Scroll> "Vertical" </Scroll>\r\n')
out_xml('<Column> 4 </Column>\r\n')
out_xml('<Script>\r\n')
print("current_file_name " + current_file_name)
if touch_less_gen == False:
out_xml('\t Var block_index_override = 0\r\n')
out_xml('\t Var block_index_move = 0\r\n')
else:
out_xml('\t Var block_index_override = 4\r\n')
out_xml('\t Var block_index_move = 1\r\n')
out_xml('\tIf Seeker = "curr" Then\r\n')
out_xml('\t\tVar TouchLessStg = "Enable"\r\n')
out_xml('\t\tVar TouchLessQrStg = "Enable"\r\n')
out_xml('\tElse\r\n')
out_xml('\t\tVar TouchLessStg = "Disable"\r\n')
out_xml('\t\tVar TouchLessQrStg = "Invisible"\r\n')
out_xml('\tEndIf\r\n')
out_xml('\tIf WebAppShow = "Invisible" Then\r\n')
out_xml('\t\tVar TouchLessStg = "Disable"\r\n')
out_xml('\t\tVar TouchLessQrStg = "Invisible"\r\n')
out_xml('\tEndIf\r\n')
out_xml('</Script>\r\n')
pd_code_available = '##-##-##-####'
count = 0
count_test = 0
if touch_less_gen == True:
out_xml( '<Block>\r\n')
out_xml('\t<MarginLeft> 33 </MarginLeft>\r\n')
out_xml('\t<MarginTop> 22 </MarginTop>\r\n')
out_xml('\t<Width> 225 </Width>\r\n')
out_xml('\t<Height> 296 </Height>\r\n')
out_xml('\t<State> "Enable" </State> \r\n')
out_xml('\t<Image>\r\n')
out_xml('\t<X> 0 </X>\r\n')
out_xml('\t<Y> 0 </Y>\r\n')
out_xml('\t<State> TouchLessStg </State> \r\n')
out_xml('\t<Filename> Var( DirImage + "/touch_less_order.png" )</Filename>\r\n')
out_xml('\t<FilenameDisable> Var( DirImage + "/touch_less_order_db.png" )</FilenameDisable>\r\n')
out_xml('\t</Image>\r\n')
out_xml('\t<QRCode>\r\n')
out_xml('\t<X> 40 </X>\r\n')
out_xml('\t<Y> 153 </Y>\r\n')
out_xml('\t<Width> 150 </Width>\r\n')
out_xml('\t<Color> "0xeae6e1" </Color>\r\n')
out_xml('\t<QRColor> "0x513C2F" </Color>\r\n')
out_xml('\t<Height> 150 </Height>\r\n')
#out_xml('\t<State> TouchLessQrStg </State>\r\n')
#out_xml('\t<Service> "Herr" </Service>\r\n')
out_xml('\t<State> TouchLessQrStg </State>\r\n')
out_xml('\t<Service> testservice </Service>\r\n')
out_xml('\t</QRCode>\r\n')
out_xml('</Block>\r\n')
out_xml('; menu_new_list '+ str(len(menu_new_list))+'\r\n')
for spl in menu_new_list:
#product_code = s
menu_img = spl[7]
out_xml( '\t; '+ spl[4] + ' ' + spl[5] + ' ' + spl[6]+ ' \r\n')
out_xml( '<Block>\r\n')
out_xml('\t<MarginLeft> 33 </MarginLeft>\r\n')
out_xml('\t<MarginTop> 22 </MarginTop>\r\n')
out_xml('\t<Width> 225 </Width>\r\n')
out_xml('\t<Height> 296 </Height>\r\n')
str_con = ""
if spl[4] != '-':
str_con += spl[4] + '.Button,'
if spl[5] != '-':
str_con += spl[5] + '.Button,'
if spl[6] != '-':
str_con += spl[6] + '.Button,'
if touch_less_gen == True:
str_con += "Disable=Invisible"
out_xml( '\t<State> Flag( '+ str_con + ') </State> \r\n')
pd_code_1 = spl[4]
pd_stage1 = '$' + spl[4] + '.Button'
if spl[4] == "-" or len(spl[4]) == 0 :
pd_code_1 = pd_code_available
pd_stage1 = '"Disable2"'
pd_code_2 = spl[5]
pd_stage2 = '$' + spl[5] + '.Button'
if spl[5] == "-" or len(spl[5]) == 0:
pd_code_2 = pd_code_available
pd_stage2 = '"Disable2"'
pd_code_3 = spl[6]
pd_stage3 = '$' + spl[6] + '.Button'
if spl[6] == "-" or len(spl[6]) == 0:
pd_code_3 = pd_code_available
pd_stage3 = '"Disable2"'
out_xml( '\t<Button>\r\n')
out_xml( '\t<State> Flag( '+ str_con + ') </State> \r\n')
out_xml( '\t<Filename> "' + new_default_dir + '/'+ menu_img +'" </Filename>\r\n')
out_xml( '\t<FilenamePress> "' + new_default_dir_press + '/'+ menu_img +'" </FilenamePress>\r\n')
out_xml( '\t<FilenameDisable> "' + new_default_dir_disable + '/'+ menu_img +'" </FilenameDisable>\r\n')
out_xml( '\t<Sound> "/mnt/sdcard/coffeevending/wav/click.wav" </Sound>\r\n')
out_xml( '\t<Volume> SoundVolume </Volume>\r\n')
out_xml( '\t<EventOnClick> \r\n')
# Default
out_xml( '\t\tVar NameDrink = "' + spl[1].replace("\\n", " ") + '"\r\n')
out_xml( '\t\tVar NameDrinkTH = "' + spl[0].replace("\\n", " ") + '"\r\n')
out_xml( '\t\tVar DrinkDescriptionTH = "' + spl[2].replace("\\n", " ") + '"\r\n')
out_xml( '\t\tVar DrinkDescription = "' + spl[3].replace("\\n", " ") + '"\r\n')
out_xml( '\t\tVar PictureDrink = "' + new_default_dir2 + '" + \"' + menu_img + '\"\r\n')
out_xml( '\t\tVar OpenFromXML = CurrentXMLFileName2\r\n')
out_xml( '\t\tVar PriceD1 = $' + spl[4] + '.Price\r\n')
out_xml( '\t\tVar PriceD2 = $' + spl[5] + '.Price\r\n')
out_xml( '\t\tVar PriceD3 = $' + spl[6] + '.Price\r\n')
out_xml( '\t\tVar PD_CODE1 = "' + pd_code_1 + '"\r\n')
out_xml( '\t\tVar PD_CODE2 = "' + pd_code_2 + '"\r\n')
out_xml( '\t\tVar PD_CODE3 = "' + pd_code_3 + '"\r\n')
out_xml( '\t\tVar PD_STAGE_1 = ' + pd_stage1 + '\r\n')
out_xml( '\t\tVar PD_STAGE_2 = ' + pd_stage2 + '\r\n')
out_xml( '\t\tVar PD_STAGE_3 = ' + pd_stage3 + '\r\n')
out_xml( '\t\tVar SelectCountDrinkType = 0\r\n')
out_xml( '\t\tVar DefaultDrinkType = 0\r\n')
out_xml( '\t\tIf PD_STAGE_1 = "Enable" Then\r\n')
out_xml( '\t\t\tVar SelectCountDrinkType = SelectCountDrinkType + 1\r\n')
out_xml( '\t\t\tVar DefaultDrinkType = 1\r\n')
out_xml( '\t\tEndIf\r\n')
out_xml( '\t\tIf PD_STAGE_2 = "Enable" Then\r\n')
out_xml( '\t\t\tVar SelectCountDrinkType = SelectCountDrinkType + 1\r\n')
out_xml( '\t\t\tVar DefaultDrinkType = 2\r\n')
out_xml( '\t\tEndIf\r\n')
out_xml( '\t\tIf PD_STAGE_3 = "Enable" Then\r\n')
out_xml( '\t\t\tVar SelectCountDrinkType = SelectCountDrinkType + 1\r\n')
out_xml( '\t\t\tVar DefaultDrinkType = 3\r\n')
out_xml( '\t\tEndIf\r\n')
out_xml( '\t\tIf PD_STAGE_2 = "Enable" Then\r\n')
#out_xml( '\t\t\tVar PD_STAGE_2 = "Enable"\r\n')
out_xml( '\t\t\tTopping "Load" "'+ spl[5] +'"\r\n')
out_xml( '\t\tElse\r\n')
out_xml( '\t\t\tIf PD_STAGE_1 = "Enable" Then\r\n')
#out_xml( '\t\t\t\tVar PD_STAGE_1 = "Enable"\r\n')
out_xml( '\t\t\tTopping "Load" "'+ spl[4] +'"\r\n')
out_xml( '\t\t\tElse\r\n')
#out_xml( '\t\t\t\tVar PD_STAGE_3 = "Enable"\r\n')
out_xml( '\t\t\tTopping "Load" "'+ spl[6] +'"\r\n')
out_xml( '\t\t\tEndIf\r\n')
out_xml( '\t\tEndIf\r\n')
out_xml( '\t\tVar menu_name_eng_hot = $' + pd_code_1 + '.NameE\r\n')
out_xml( '\t\tVar menu_desc_eng_hot = $' + pd_code_1 + '.descriptionE\r\n')
out_xml( '\t\tVar menu_name_thai_hot = $' + pd_code_1 + '.Name\r\n')
out_xml( '\t\tVar menu_desc_thai_hot = $' + pd_code_1 + '.description\r\n')
out_xml( '\t\t\r\n')
out_xml( '\t\tVar menu_name_eng_cold = $' + pd_code_2 + '.NameE\r\n')
out_xml( '\t\tVar menu_desc_eng_cold = $' + pd_code_2 + '.descriptionE\r\n')
out_xml( '\t\tVar menu_name_thai_cold = $' + pd_code_2 + '.Name\r\n')
out_xml( '\t\tVar menu_desc_thai_cold = $' + pd_code_2 + '.description\r\n')
out_xml( '\t\t\r\n')
out_xml( '\t\tVar menu_name_eng_blender = $' + pd_code_3 + '.NameE\r\n')
out_xml( '\t\tVar menu_desc_eng_blender = $' + pd_code_3 + '.descriptionE\r\n')
out_xml( '\t\tVar menu_name_thai_blender = $' + pd_code_3 + '.Name\r\n')
out_xml( '\t\tVar menu_desc_thai_blender = $' + pd_code_3 + '.description\r\n')
out_xml( '\t\t\r\n')
out_xml( '\t\tDEBUGVAR PD_STAGE_1\r\n')
out_xml( '\t\tDEBUGVAR PD_STAGE_2\r\n')
out_xml( '\t\tDEBUGVAR PD_STAGE_3\r\n')
out_xml( '\t\t\r\n')
out_xml( '\t\t\r\n')
out_xml( '\t\tOpen "ROOT/taobin_project/xml/page_topping_select4.xml"\r\n')
out_xml( '\t\t\r\n')
out_xml( '\t</EventOnClick>\r\n')
out_xml( '\t</Button>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 16 </X>\r\n')
out_xml( '\t<Y> 164 </Y>\r\n')
out_xml( '\t<Size> 24 </Size>\r\n')
out_xml( '\t<Width>220</Width>\r\n')
out_xml( '\t<Mode> "multi2" </Mode>\r\n')
out_xml( '\t<Font> KanitMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0x322B26 </Color>\r\n')
out_xml( '\t<State> showthaiText </State>\r\n')
out_xml( '\t<Value> "' + spl[0].replace("\\n", "\n") + '" </Value>\r\n')
out_xml( '\t</Text>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 16 </X>\r\n')
out_xml( '\t<Y> 220 </Y>\r\n')
out_xml( '\t<Size> 14 </Size>\r\n')
out_xml( '\t<Width>220</Width>\r\n')
out_xml( '\t<Font> KanitMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0x6F5F51 </Color>\r\n')
out_xml( '\t<State> showthaiText </State>\r\n')
out_xml( '\t<Value> "' + spl[2].replace("\\n", "\n") + '" </Value>\r\n')
out_xml( '\t</Text>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 16 </X>\r\n')
out_xml( '\t<Y> 164 </Y>\r\n')
out_xml( '\t<Size> 22 </Size>\r\n')
out_xml( '\t<Width>220</Width>\r\n')
out_xml( '\t<Mode> "multi2" </Mode>\r\n')
out_xml( '\t<Font> KanitMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0x322B26 </Color>\r\n')
out_xml( '\t<State> showengText </State>\r\n')
out_xml( '\t<Value> "' + spl[1].replace("\\n", "\n") + '" </Value>\r\n')
out_xml( '\t</Text>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 16 </X>\r\n')
out_xml( '\t<Y> 220 </Y>\r\n')
out_xml( '\t<Size> 14 </Size>\r\n')
out_xml( '\t<Width>220</Width>\r\n')
out_xml( '\t<Font> KanitMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0x6F5F51 </Color>\r\n')
out_xml( '\t<State> showengText </State>\r\n')
out_xml( '\t<Value> "' + spl[3].replace("\\n", "\n") + '" </Value>\r\n')
out_xml( '\t</Text>\r\n')
out_xml( '\t<Image>\r\n')
out_xml( '\t<X> 16 </X>\r\n')
out_xml( '\t<Y> 264 </Y>\r\n')
out_xml( '\t<Filename> Var( DirImage2 + "option_deactive.png" ) </Filename>\r\n')
out_xml( '\t</Image>\r\n')
ice_tab_hot_show = True
shw = "$" + spl[4] + ".Button"
if spl[4] == "-" :
shw = '"Invisible"'
ice_tab_hot_show = False
if len(spl[4]) == 0 :
shw = '"Invisible"'
ice_tab_hot_show = False
out_xml( '\t<Image>\r\n')
out_xml( '\t<X> 16 </X>\r\n')
out_xml( '\t<Y> 264 </Y>\r\n')
out_xml( '\t<State> ' + shw + ' </State>\r\n')
out_xml( '\t<Filename> Var( DirImage2 + "hot.png" ) </Filename>\r\n')
out_xml( '\t<FilenameDisable> Var( DirImage2 + "hot_db.png" ) </FilenameDisable>\r\n')
out_xml( '\t</Image>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 50 </X>\r\n')
out_xml( '\t<Y> 265 </Y>\r\n')
out_xml( '\t<Size> 14 </Size>\r\n')
out_xml( '\t<Width>220</Width>\r\n')
out_xml( '\t<Font> KanitMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0x6F5F51 </Color>\r\n')
out_xml( '\t<ColorDisable> 0xEAE6E1 </ColorDisable>\r\n')
out_xml( '\t<State> ' + shw + ' </State>\r\n')
out_xml( '\t<Value> Var( "฿" + $' + spl[4] + '.Price ) </Value>\r\n')
out_xml( '\t</Text>\r\n')
ice_tab_ice_show = True
shw = "$" + spl[5] + ".Button"
if spl[5] == "-" :
shw = '"Invisible"'
ice_tab_ice_show = False
if len(spl[5]) == 0 :
shw = '"Invisible"'
ice_tab_ice_show = False
out_xml( '\t<Image>\r\n')
out_xml( '\t<X> 81 </X>\r\n')
out_xml( '\t<Y> 264 </Y>\r\n')
out_xml( '\t<Filename> Var( DirImage2 + "cold.png" ) </Filename>\r\n')
out_xml( '\t<FilenameDisable> Var( DirImage2 + "cold_db.png" ) </FilenameDisable>\r\n')
out_xml( '\t<State> ' + shw + ' </State>\r\n')
out_xml( '\t</Image>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 115 </X>\r\n')
out_xml( '\t<Y> 265 </Y>\r\n')
out_xml( '\t<Size> 14 </Size>\r\n')
out_xml( '\t<Width>220</Width>\r\n')
out_xml( '\t<Font> KanitMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0x6F5F51 </Color>\r\n')
out_xml( '\t<ColorDisable> 0xEAE6E1 </ColorDisable>\r\n')
out_xml( '\t<State> ' + shw + ' </State>\r\n')
out_xml( '\t<Value> Var( "฿" + $' + spl[5] + '.Price ) </Value>\r\n')
out_xml( '\t</Text>\r\n')
ice_tab_blend_show = True
shw = "$" + spl[6] + ".Button"
if spl[6] == "-" :
shw = '"Invisible"'
ice_tab_blend_show = False
if len(spl[6]) == 0 :
shw = '"Invisible"'
ice_tab_blend_show = False
out_xml( '\t<Image>\r\n')
out_xml( '\t<X> 146 </X>\r\n')
out_xml( '\t<Y> 264 </Y>\r\n')
out_xml( '\t<Filename> Var( DirImage2 + "blend.png" ) </Filename>\r\n')
out_xml( '\t<FilenameDisable> Var( DirImage2 + "blend_db.png" ) </FilenameDisable>\r\n')
out_xml( '\t<State> ' + shw + ' </State>\r\n')
out_xml( '\t</Image>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 183 </X>\r\n')
out_xml( '\t<Y> 265 </Y>\r\n')
out_xml( '\t<Size> 14 </Size>\r\n')
out_xml( '\t<Width>220</Width>\r\n')
out_xml( '\t<Font> KanitMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0x6F5F51 </Color>\r\n')
out_xml( '\t<ColorDisable> 0xEAE6E1 </ColorDisable>\r\n')
out_xml( '\t<State> ' + shw + ' </State>\r\n')
out_xml( '\t<Value> Var( "฿" + $' + spl[6] + '.Price ) </Value>\r\n')
out_xml( '\t</Text>\r\n')
out_xml( '\t<Image>\r\n')
out_xml( '\t<X> 81 </X>\r\n')
out_xml( '\t<Y> 264 </Y>\r\n')
out_xml( '\t<State> \r\n')
out_xml( '\t\teval( \r\n')
out_xml( '\t\tIf ICE_PROCESS_STATUS = 2 Then\r\n')
out_xml( '\t\t\r\n')
if ice_tab_hot_show == True:
out_xml( '\t\t\tSTRCONTAIN "LOW" $' + pd_code_1 + '.TAG tag_is_low\r\n')
out_xml( '\t\t\tIf tag_is_low = "true" Then\r\n')
out_xml( '\t\t\t\tVar ice_tab_process_show = "Disable"\r\n')
out_xml( '\t\t\rElse\n')
out_xml( '\t\t\t\tVar ice_tab_process_show = "Enable"\r\n')
out_xml( '\t\t\tEndIf\r\n')
else:
out_xml( '\t\t\tVar ice_tab_process_show = "Disable"\r\n')
out_xml( '\t\t\r\n')
out_xml( '\t\tElse\r\n')
out_xml( '\t\t\tVar ice_tab_process_show = "Invisible"\r\n')
out_xml( '\t\tEndIf\r\n')
out_xml( '\t\tVar return = ice_tab_process_show\r\n')
out_xml( '\t\t)\r\n')
out_xml( '\t</State>\r\n')
out_xml( '\t<Filename> "ROOT/taobin_project/image/drink_option/ice_tab_unavalible.png" </Filename>\r\n')
out_xml( '\t<FilenameDisable> "ROOT/taobin_project/image/drink_option/ice_tab_unavalible_dis.png" </FilenameDisable>\r\n')
out_xml( '\t</Image>\r\n')
#out_xml( '\t<Image>\r\n')
#out_xml( '\t<X> 49 </X>\r\n')
#out_xml( '\t<Y> 117 </Y>\r\n')
#out_xml( '\t<State> \r\n')
#out_xml( '\t\teval( \r\n')
#out_xml( '\t\t\tSTRCONTAIN "ERR" $' + pd_code_1 + '.TAG tag1_is_disable\r\n')
#out_xml( '\t\t\tSTRCONTAIN "ERR" $' + pd_code_2 + '.TAG tag2_is_disable\r\n')
#out_xml( '\t\t\tSTRCONTAIN "ERR" $' + pd_code_3 + '.TAG tag3_is_disable\r\n')
#out_xml( '\t\t\tDEBUGVAR $' + pd_code_1 + '.TAG\r\n')
#out_xml( '\t\t\tDEBUGVAR $' + pd_code_2 + '.TAG\r\n')
#out_xml( '\t\t\tDEBUGVAR $' + pd_code_3 + '.TAG\r\n')
#out_xml( '\t\t\tVar return = "Enable"\r\n')
#out_xml( '\t\t\tIf tag1_is_disable = "false" Then\r\n')
#out_xml( '\t\t\t\tVar return = "Invisible"\r\n')
#out_xml( '\t\t\tEndIf\r\n')
#out_xml( '\t\t\tIf tag2_is_disable = "false" Then\r\n')
#out_xml( '\t\t\t\tVar return = "Invisible"\r\n')
#out_xml( '\t\t\tEndIf\r\n')
#out_xml( '\t\t\tIf tag3_is_disable = "false" Then\r\n')
#out_xml( '\t\t\t\tVar return = "Invisible"\r\n')
#out_xml( '\t\t\tEndIf\r\n')
#out_xml( '\t\t)\r\n')
#out_xml( '\t</State>\r\n')
#out_xml( '\t<Filename> "ROOT/taobin_project/image//img_menu_err.png" </Filename>\r\n')
#out_xml( '\t</Image>\r\n')
out_xml( '\t<Text>\r\n')
out_xml( '\t<X> 84 </X>\r\n')
out_xml( '\t<Y> 266 </Y>\r\n')
out_xml( '\t<Size> 10 </Size>\r\n')
out_xml( '\t<Font> OpunMediumTTF </Font>\r\n')
out_xml( '\t<Color> 0xDE794E </Color>\r\n')
out_xml( '\t<State> ice_tab_process_show </State>\r\n')
out_xml( '\t<Value> ice_show_open </Value>\r\n')
out_xml( '\t</Text>\r\n')
out_xml( '</Block>\r\n')
count_test = count_test + 1
#if count_test > 8 :
# break
out_xml('</FrameScroll>\r\n')
out_xml('; Cart\r\n')
out_xml('<Button>\r\n')
out_xml('<X> 915 </X>\r\n')
out_xml('<Y> 1769 </Y>\r\n')
out_xml('<State> showCart </State>\r\n')
out_xml('<Filename> cart_image_bn </Filename>\r\n')
out_xml('<FilenamePress> cart_image_bp </FilenamePress>\r\n')
out_xml('<Sound> "/mnt/sdcard/coffeevending/wav/click.wav" </Sound>\r\n')
out_xml('<Volume> SoundVolume </Volume>\r\n')
out_xml('<EventClick> \r\n')
out_xml('\tOpen "ROOT/taobin_project/xml/page_payment_multi.xml"\r\n')
out_xml('</EventClick>\r\n')
out_xml('</Button>\r\n')