Mercurial > wow > reaction
comparison modules/State.lua @ 118:5c189f44e776
Fixed rule-select so that you can select rules for classes you're not currently playing.
Added "in a vehicle" rule
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 06 Feb 2009 21:32:32 +0000 |
parents | 410d036c43b2 |
children | d186e041ca14 |
comparison
equal
deleted
inserted
replaced
117:e2257bf1d717 | 118:5c189f44e776 |
---|---|
320 SetOverrideBindingClick(f, false, key, state, nil) -- state name is the virtual mouse button | 320 SetOverrideBindingClick(f, false, key, state, nil) -- state name is the virtual mouse button |
321 end | 321 end |
322 end | 322 end |
323 end | 323 end |
324 | 324 |
325 local playerClass = select(2, UnitClass("player")) | |
326 local function ClassFilter(...) | |
327 for i = 1, select('#',...) do | |
328 if playerClass == select(i,...) then | |
329 return false | |
330 end | |
331 end | |
332 return true | |
333 end | |
334 | |
325 -- As far as I can tell the macro clauses are NOT locale-specific. | 335 -- As far as I can tell the macro clauses are NOT locale-specific. |
336 -- 'filter' specifies whether rules should be omitted from execution. | |
337 -- 'true' indicates they should be filtered out. | |
326 local ruleformats = { | 338 local ruleformats = { |
327 stealth = "stealth", | 339 stealth = { format = "stealth", filter = ClassFilter("ROGUE","DRUID") }, |
328 nostealth = "nostealth", | 340 nostealth = { format = "nostealth", filter = ClassFilter("ROGUE","DRUID") }, |
329 shadowform = "form:1", | 341 shadowform = { format = "form:1", filter = ClassFilter("PRIEST") }, |
330 noshadowform = "noform", | 342 noshadowform = { format = "noform", filter = ClassFilter("PRIEST") }, |
331 pet = "pet", | 343 battle = { format = "stance:1", filter = ClassFilter("WARRIOR") }, |
332 nopet = "nopet", | 344 defensive = { format = "stance:2", filter = ClassFilter("WARRIOR") }, |
333 harm = "target=target,harm", | 345 berserker = { format = "stance:3", filter = ClassFilter("WARRIOR") }, |
334 help = "target=target,help", | 346 caster = { format = "form:0/2/4/5/6", filter = ClassFilter("DRUID") }, |
335 notarget = "target=target,noexists", | 347 bear = { format = "form:1", filter = ClassFilter("DRUID") }, |
336 focusharm = "target=focus,harm", | 348 cat = { format = "form:1", filter = ClassFilter("DRUID") }, |
337 focushelp = "target=focus,help", | 349 tree = { format = "form:5", filter = ClassFilter("DRUID") }, |
338 nofocus = "target=focus,noexists", | 350 moonkin = { format = "form:5", filter = ClassFilter("DRUID") }, |
339 raid = "group:raid", | 351 pet = { format = "pet" }, |
340 party = "group:party", | 352 nopet = { format = "nopet" }, |
341 solo = "nogroup", | 353 harm = { format = "target=target,harm" }, |
342 combat = "combat", | 354 help = { format = "target=target,help" }, |
343 nocombat = "nocombat", | 355 notarget = { format = "target=target,noexists" }, |
344 possess = "bonusbar:5", | 356 focusharm = { format = "target=focus,harm" }, |
357 focushelp = { format = "target=focus,help" }, | |
358 nofocus = { format = "target=focus,noexists" }, | |
359 raid = { format = "group:raid" }, | |
360 party = { format = "group:party" }, | |
361 solo = { format = "nogroup" }, | |
362 combat = { format = "combat" }, | |
363 nocombat = { format = "nocombat" }, | |
364 possess = { format = "bonusbar:5" }, | |
365 vehicle = { format = "target=vehicle,exists" }, | |
345 } | 366 } |
346 | 367 |
347 -- Have to do these shenanigans instead of hardcoding the stances/forms because the | 368 -- Have to do these shenanigans instead of hardcoding the stances/forms because the |
348 -- ordering varies if the character is missing a form. For warriors this is rarely | 369 -- ordering varies if the character is missing a form. For warriors this is rarely |
349 -- a problem (c'mon, who actually skips the level 10 def stance quest?) but for druids | 370 -- a problem (c'mon, who actually skips the level 10 def stance quest?) but for druids |
372 local travel = forms["Interface\\Icons\\Ability_Druid_TravelForm"] or 9 | 393 local travel = forms["Interface\\Icons\\Ability_Druid_TravelForm"] or 9 |
373 local tree = forms["Interface\\Icons\\Ability_Druid_TreeofLife"] or 9 | 394 local tree = forms["Interface\\Icons\\Ability_Druid_TreeofLife"] or 9 |
374 local moonkin = forms["Interface\\Icons\\Spell_Nature_ForceOfNature"] or 9 | 395 local moonkin = forms["Interface\\Icons\\Spell_Nature_ForceOfNature"] or 9 |
375 local flight = forms["Interface\\Icons\\Ability_Druid_FlightForm"] or 9 -- flight and swift flight share the same icon | 396 local flight = forms["Interface\\Icons\\Ability_Druid_FlightForm"] or 9 -- flight and swift flight share the same icon |
376 | 397 |
377 ruleformats.battle = "stance:1" | 398 ruleformats.defensive.format = format("stance:%d",defensive) |
378 ruleformats.defensive = format("stance:%d",defensive) | 399 ruleformats.berserker.format = format("stance:%d",berserker) |
379 ruleformats.berserker = format("stance:%d",berserker) | 400 ruleformats.caster.format = format("form:0/%d/%d/%d", aquatic, travel, flight) |
380 ruleformats.caster = format("form:0/%d/%d/%d",aquatic, travel, flight) | 401 ruleformats.bear.format = format("form:%d",bear) |
381 ruleformats.bear = format("form:%d",bear) | 402 ruleformats.cat.format = format("form:%d",cat) |
382 ruleformats.cat = format("form:%d",cat) | 403 ruleformats.tree.format = format("form:%d",tree) |
383 ruleformats.tree = format("form:%d",tree) | 404 ruleformats.moonkin.format = format("form:%d",moonkin) |
384 ruleformats.moonkin = format("form:%d",moonkin) | |
385 end | 405 end |
386 | 406 |
387 local function BuildRule(states) | 407 local function BuildRule(states) |
388 local rules = { } | 408 local rules = { } |
389 local default | 409 local default |
400 end | 420 end |
401 elseif type == "any" or type == "all" then | 421 elseif type == "any" or type == "all" then |
402 if c.values then | 422 if c.values then |
403 local clauses = { } | 423 local clauses = { } |
404 for key, value in pairs(c.values) do | 424 for key, value in pairs(c.values) do |
405 table.insert(clauses, ruleformats[key]) | 425 if ruleformats[key] and not ruleformats[key].filter then |
426 table.insert(clauses, ruleformats[key].format) | |
427 end | |
406 end | 428 end |
407 if #clauses > 0 then | 429 if #clauses > 0 then |
408 local sep = (type == "any") and "][" or "," | 430 local sep = (type == "any") and "][" or "," |
409 table.insert(rules, format("[%s] %s", table.concat(clauses,sep), state)) | 431 table.insert(rules, format("[%s] %s", table.concat(clauses,sep), state)) |
410 end | 432 end |
566 | 588 |
567 -- Options -- | 589 -- Options -- |
568 | 590 |
569 local CreateBarOptions, RegisterPropertyOptions | 591 local CreateBarOptions, RegisterPropertyOptions |
570 do | 592 do |
571 local playerClass = select(2, UnitClass("player")) | |
572 local function ClassCheck(...) | |
573 for i = 1, select('#',...) do | |
574 if playerClass == select(i,...) then | |
575 return false | |
576 end | |
577 end | |
578 return true | |
579 end | |
580 | |
581 -- pre-sorted by the order they should appear in | 593 -- pre-sorted by the order they should appear in |
582 local rules = { | 594 local rules = { |
583 -- rule hidden fields | 595 -- rule fields |
584 { "stance", ClassCheck("WARRIOR"), { {battle = L["Battle Stance"]}, {defensive = L["Defensive Stance"]}, {berserker = L["Berserker Stance"]} } }, | 596 { "stance", { {battle = L["Battle Stance"]}, {defensive = L["Defensive Stance"]}, {berserker = L["Berserker Stance"]} } }, |
585 { "form", ClassCheck("DRUID"), { {caster = L["Caster Form"]}, {bear = L["Bear Form"]}, {cat = L["Cat Form"]}, {tree = L["Tree of Life"]}, {moonkin = L["Moonkin Form"]} } }, | 597 { "form", { {caster = L["Caster Form"]}, {bear = L["Bear Form"]}, {cat = L["Cat Form"]}, {tree = L["Tree of Life"]}, {moonkin = L["Moonkin Form"]} } }, |
586 { "stealth", ClassCheck("ROGUE","DRUID"), { {stealth = L["Stealth"]}, {nostealth = L["No Stealth"]} } }, | 598 { "stealth", { {stealth = L["Stealth"]}, {nostealth = L["No Stealth"]} } }, |
587 { "shadow", ClassCheck("PRIEST"), { {shadowform = L["Shadowform"]}, {noshadowform = L["No Shadowform"]} } }, | 599 { "shadow", { {shadowform = L["Shadowform"]}, {noshadowform = L["No Shadowform"]} } }, |
588 { "pet", ClassCheck("HUNTER","WARLOCK"), { {pet = L["With Pet"]}, {nopet = L["Without Pet"]} } }, | 600 { "pet", { {pet = L["With Pet"]}, {nopet = L["Without Pet"]} } }, |
589 { "target", false, { {harm = L["Hostile Target"]}, {help = L["Friendly Target"]}, {notarget = L["No Target"]} } }, | 601 { "target", { {harm = L["Hostile Target"]}, {help = L["Friendly Target"]}, {notarget = L["No Target"]} } }, |
590 { "focus", false, { {focusharm = L["Hostile Focus"]}, {focushelp = L["Friendly Focus"]}, {nofocus = L["No Focus"]} } }, | 602 { "focus", { {focusharm = L["Hostile Focus"]}, {focushelp = L["Friendly Focus"]}, {nofocus = L["No Focus"]} } }, |
591 { "possess", false, { {possess = L["Mind Control"]} } }, | 603 { "possess", { {possess = L["Mind Control"]} } }, |
592 { "group", false, { {raid = L["Raid"]}, {party = L["Party"]}, {solo = L["Solo"]} } }, | 604 { "vehicle", { {vehicle = L["In a Vehicle"]} } }, |
593 { "combat", false, { {combat = L["In Combat"]}, {nocombat = L["Out of Combat"]} } }, | 605 { "group", { {raid = L["Raid"]}, {party = L["Party"]}, {solo = L["Solo"]} } }, |
606 { "combat", { {combat = L["In Combat"]}, {nocombat = L["Out of Combat"]} } }, | |
594 } | 607 } |
595 | 608 |
596 local ruleSelect = { } | 609 local ruleSelect = { } |
597 local ruleMap = { } | 610 local ruleMap = { } |
598 local optionMap = setmetatable({},{__mode="k"}) | 611 local optionMap = setmetatable({},{__mode="k"}) |
610 BOTTOMRIGHT = L["Bottom Right"], | 623 BOTTOMRIGHT = L["Bottom Right"], |
611 } | 624 } |
612 | 625 |
613 -- unpack rules table into ruleSelect and ruleMap | 626 -- unpack rules table into ruleSelect and ruleMap |
614 for _, c in ipairs(rules) do | 627 for _, c in ipairs(rules) do |
615 local rule, hidden, fields = unpack(c) | 628 local rule, fields = unpack(c) |
616 if not hidden then | 629 for _, field in ipairs(fields) do |
617 for _, field in ipairs(fields) do | 630 local key, label = next(field) |
618 local key, label = next(field) | 631 table.insert(ruleSelect, label) |
619 table.insert(ruleSelect, label) | 632 table.insert(ruleMap, key) |
620 table.insert(ruleMap, key) | |
621 end | |
622 end | 633 end |
623 end | 634 end |
624 | 635 |
625 local stateOptions = { | 636 local stateOptions = { |
626 ordering = { | 637 ordering = { |
979 -- be chosen arbitrarily. Otherwise, if selecting a new checkbox from the field-set, | 990 -- be chosen arbitrarily. Otherwise, if selecting a new checkbox from the field-set, |
980 -- it will be retained. | 991 -- it will be retained. |
981 local notified = false | 992 local notified = false |
982 if self:GetRuleField("type") == "all" then | 993 if self:GetRuleField("type") == "all" then |
983 for _, c in ipairs(rules) do | 994 for _, c in ipairs(rules) do |
984 local rule, hidden, fields = unpack(c) | 995 local rule, fields = unpack(c) |
985 local once = false | 996 local once = false |
986 if setkey then | 997 if setkey then |
987 for idx, field in ipairs(fields) do | 998 for idx, field in ipairs(fields) do |
988 if next(field) == setkey then | 999 if next(field) == setkey then |
989 once = true | 1000 once = true |