diff options
| author | Alexander Gavrilov | 2012-09-29 17:21:49 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-09-29 17:21:49 +0400 |
| commit | 62cde96724622a08f9dd6d4bf83f1763a02fd9df (patch) | |
| tree | 99862f565d7d8e30ab054a3ff01a35aab5044669 /library | |
| parent | 48da06ec371421a48f801f6da1add6e437ccfa06 (diff) | |
| download | dfhack-62cde96724622a08f9dd6d4bf83f1763a02fd9df.tar.gz dfhack-62cde96724622a08f9dd6d4bf83f1763a02fd9df.tar.bz2 dfhack-62cde96724622a08f9dd6d4bf83f1763a02fd9df.tar.xz | |
Add a script to reclassify 'individual choice' weapons based on unit skill.
Diffstat (limited to 'library')
| -rw-r--r-- | library/lua/utils.lua | 21 | ||||
| -rw-r--r-- | library/modules/Gui.cpp | 31 |
2 files changed, 52 insertions, 0 deletions
diff --git a/library/lua/utils.lua b/library/lua/utils.lua index 9fa473ed..b46363cd 100644 --- a/library/lua/utils.lua +++ b/library/lua/utils.lua @@ -361,6 +361,27 @@ function insert_or_update(vector,item,field,cmp) return added,cur,pos end +-- Binary search and erase +function erase_sorted_key(vector,key,field,cmp) + local cur,found,pos = binsearch(vector,key,field,cmp) + if found then + if df.isvalid(vector) then + vector:erase(pos) + else + table.remove(vector, pos) + end + end + return found,cur,pos +end + +function erase_sorted(vector,item,field,cmp) + local key = item + if field and item then + key = item[field] + end + return erase_sorted_key(vector,key,field,cmp) +end + -- Calls a method with a string temporary function call_with_string(obj,methodname,...) return dfhack.with_temp_object( diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 21156ac0..2afb3620 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -347,6 +347,37 @@ DEFINE_GET_FOCUS_STRING_HANDLER(layer_military) break; } + case df::viewscreen_layer_militaryst::Equip: + { + focus += "/" + enum_item_key(screen->equip.mode); + + switch (screen->equip.mode) + { + case df::viewscreen_layer_militaryst::T_equip::Customize: + { + if (screen->equip.edit_mode < 0) + focus += "/View"; + else + focus += "/" + enum_item_key(screen->equip.edit_mode); + break; + } + case df::viewscreen_layer_militaryst::T_equip::Uniform: + break; + case df::viewscreen_layer_militaryst::T_equip::Priority: + { + if (screen->equip.prio_in_move >= 0) + focus += "/Move"; + else + focus += "/View"; + break; + } + } + + static const char *lists[] = { "/Squads", "/Positions", "/Choices" }; + focus += lists[cur_list]; + break; + } + default: break; } |
