Changeset 2103 for trunk/lomefc2/me_predicates.lua
- Timestamp:
- 07/03/10 22:24:43 (19 months ago)
- File:
-
- 1 edited
-
trunk/lomefc2/me_predicates.lua (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lomefc2/me_predicates.lua
r2078 r2103 983 983 }, 984 984 985 -- ============================================================= 986 -- WARNING: keep these four decorations at the end of the list. 987 -- ============================================================= 988 { 989 name = "op_startGroup", 990 fields = {}, 991 decoration = "(" 992 }, 993 { 994 name = "op_stopGroup", 995 fields = {}, 996 decoration = ")" 997 }, 998 { 999 name = "op_and", 1000 fields = {}, 1001 decoration = " and " 1002 }, 1003 { 1004 name = "op_or", 1005 fields = {}, 1006 decoration = " or " 1007 }, 1008 }; 1009 1010 1011 cdata = { 1012 1013 predicates = { 1014 op_startGroup = _("("), 1015 op_stopGroup = _(")"), 1016 op_and = _("and"), 1017 op_or = _("or"), 985 1018 986 -- for tests987 {988 name = "getLoInterface",989 fields = {990 }991 },992 };993 994 995 cdata = {996 997 predicates = {998 1019 c_unit_alive = _("UNIT ALIVE"), 999 1020 c_unit_damaged = _("UNIT DAMAGED"), … … 1035 1056 1036 1057 c_file_exits = _("FILE EXISTS"), 1037 1038 1039 1040 1041 -- getLoInterface = _("GET LO INTERFACE"),1042 1058 }, 1043 1059 … … 1085 1101 for _tmp, v in ipairs(rules) do 1086 1102 local item = U.addListBoxItem(list, getRuleAsText(v, cdata), nil, v) 1087 1088 if v.operator == "or" then 1103 local color 1104 if v.decoration then 1105 if v.decoration == "(" or v.decoration == ")" then 1106 color = Color.red 1107 else 1108 color = Color.blue 1109 end 1089 1110 local theme = item:getTheme() 1090 theme.normalTheme.text.color = Color.red1091 theme.selectedTheme.text.color = Color.red1111 theme.normalTheme.text.color = color 1112 theme.selectedTheme.text.color = color 1092 1113 item:setTheme(theme) 1093 1114 end … … 1102 1123 function getRuleAsText(rule, cdata) 1103 1124 local ruleDescr = rule.predicate 1104 local str = getPredicateName(ruleDescr, cdata) .. ' (' 1105 1106 local first = true 1107 local needComma = false 1108 for _tmp, field in ipairs(ruleDescr.fields) do 1109 if needComma then 1110 str = str .. ', ' 1111 else 1112 needComma = true 1125 local str = getPredicateName(ruleDescr, cdata) 1126 if not ruleDescr.decoration then 1127 str = str .. ' (' 1128 local first = true 1129 local needComma = false 1130 for _tmp, field in ipairs(ruleDescr.fields) do 1131 if needComma then 1132 str = str .. ', ' 1133 else 1134 needComma = true 1135 end 1136 1137 local text 1138 if field.displayFunc then 1139 text = field.displayFunc(cdata, rule[field.id]) 1140 else 1141 text = tostring(rule[field.id]) 1142 end 1143 1144 if first and ruleDescr.firstValueAsName then 1145 str = text .. ' (' 1146 needComma = false 1147 else 1148 str = str .. text 1149 end 1150 1151 first = false 1113 1152 end 1114 1153 1115 local text 1116 if field.displayFunc then 1117 text = field.displayFunc(cdata, rule[field.id]) 1118 else 1119 text = tostring(rule[field.id]) 1120 end 1121 1122 if first and ruleDescr.firstValueAsName then 1123 str = text .. ' (' 1124 needComma = false 1125 else 1126 str = str .. text 1127 end 1128 1129 first = false 1130 end 1131 1132 str = str .. ')' 1133 return str 1154 str = str .. ')' 1155 end 1156 return str 1134 1157 end 1135 1158 … … 1378 1401 -- copy default values from rule descriptions 1379 1402 function setRuleDefaults(rule, descr) 1403 -- Remove decoration field if it exists 1404 if rule.decoration then 1405 rule.decoration = nil 1406 end 1407 1408 -- Insert/Remove decoration according to the rule type 1409 if descr.decoration then 1410 rule.decoration = descr.decoration 1411 elseif rule.decoration then 1412 rule.decoration = nil 1413 end 1414 1380 1415 for _tmp, v in ipairs(descr.fields) do 1381 1416 if not rule[v.id] then … … 1496 1531 1497 1532 for i = 1, #toRemove do 1533 base.print("invalid rule" ) 1498 1534 table.remove(rulesList, toRemove[i] - (i - 1)) 1499 1535 end
Note: See TracChangeset
for help on using the changeset viewer.
