Revert "Expose manipulator columns to Lua"

This reverts commit 1d8b2d8cea.
develop
lethosor 2015-03-05 16:32:17 -05:00
parent 2549f116a0
commit be2349d67d
3 changed files with 1 additions and 105 deletions

@ -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)

@ -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

@ -5,8 +5,6 @@
#include <Export.h>
#include <PluginManager.h>
#include <MiscUtils.h>
#include <LuaTools.h>
#include <LuaWrapper.h>
#include <modules/Screen.h>
#include <modules/Translation.h>
#include <modules/Units.h>
@ -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<string, ManipulatorColumn> {
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<string, ManipulatorColumn>(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<typename T>
class StringFormatter {
public: