diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index caa03cfba..063e8a90e 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -132,7 +132,7 @@ if (BUILD_SUPPORTED) DFHACK_PLUGIN(jobutils jobutils.cpp) DFHACK_PLUGIN(lair lair.cpp) DFHACK_PLUGIN(liquids liquids.cpp Brushes.h LINK_LIBRARIES lua) - DFHACK_PLUGIN(manipulator manipulator.cpp LINK_LIBRARIES lua) + DFHACK_PLUGIN(manipulator manipulator.cpp) DFHACK_PLUGIN(mode mode.cpp) #DFHACK_PLUGIN(misery misery.cpp) DFHACK_PLUGIN(mousequery mousequery.cpp) diff --git a/plugins/lua/manipulator.lua b/plugins/lua/manipulator.lua deleted file mode 100644 index a6dec63b0..000000000 --- a/plugins/lua/manipulator.lua +++ /dev/null @@ -1,17 +0,0 @@ -local _ENV = mkmodule('plugins.manipulator') - ---[[ - - Native functions: - - * isEnabled() - * setEnabled(bool) - * has_column(name) - * add_column(name, allow_column, allow_format, column_header, format_spec, format_desc) - * remove_column(name) - * list_columns() - ---]] - - -return _ENV diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index bf7ca6206..17c3a6594 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -5,8 +5,6 @@ #include #include #include -#include -#include #include #include #include @@ -515,91 +513,6 @@ bool sortBySelected (const UnitInfo *d1, const UnitInfo *d2) return descending ? (d1->selected > d2->selected) : (d1->selected < d2->selected); } -class ManipulatorColumn { -public: - typedef string(*callback)(df::unit*); - ManipulatorColumn(bool allow_column, bool allow_format, - string column_header = "", - string format_spec = "", - string format_desc = "") - :allow_column(allow_column), allow_format(allow_format), - column_header(column_header), format_spec(format_spec), format_desc(format_desc) - { } - bool allow_column; - bool allow_format; - string column_header; - string format_spec; - string format_desc; -}; - -class ManipulatorColumnList : public std::map { -public: - bool contains(string key) { return find(key) != end(); } - void remove(string key) { if (contains(key)) erase(key); } -}; - -ManipulatorColumnList column_list; - -bool has_column (string id) { return column_list.contains(id); } - -bool add_column (string id, bool allow_column, bool allow_format, - string column_header, string format_spec, string format_desc) -{ - if (!column_list.contains(id)) - { - ManipulatorColumn col(allow_column, allow_format, column_header, format_spec, format_desc); - column_list.insert(std::pair(id, col)); - return true; - } - return false; -} - -bool remove_column (string id) -{ - if (column_list.contains(id)) - { - column_list.remove(id); - return true; - } - return false; -} - -static int list_columns (lua_State *L) -{ - lua_newtable(L); - int clist_idx = lua_gettop(L); - int i = 1; - for (auto it = column_list.begin(); it != column_list.end(); ++it) - { - lua_newtable(L); - int col_idx = lua_gettop(L); - std::string foo = it->first; - std::string format_spec = it->second.format_spec; - #define set_field(key) Lua::SetField(L, it->second.key, col_idx, #key) - set_field(allow_column); - set_field(allow_format); - set_field(column_header); - set_field(format_spec); - set_field(format_desc); - #undef set_field - lua_rawseti(L, -2, i); - i++; - } - return 1; -} - -DFHACK_PLUGIN_LUA_FUNCTIONS { - DFHACK_LUA_FUNCTION(has_column), - DFHACK_LUA_FUNCTION(add_column), - DFHACK_LUA_FUNCTION(remove_column), - DFHACK_LUA_END -}; - -DFHACK_PLUGIN_LUA_COMMANDS { - DFHACK_LUA_COMMAND(list_columns), - DFHACK_LUA_END -}; - template class StringFormatter { public: