getKeyDisplay: use enabler::GetKeyDisplay()

develop
lethosor 2017-12-25 20:14:11 -05:00
parent 0332a5c25a
commit 4d5c7c5927
2 changed files with 1 additions and 29 deletions

@ -372,12 +372,6 @@ bool Screen::hasActiveScreens(Plugin *plugin)
} }
#ifdef _LINUX #ifdef _LINUX
// Link to the libgraphics class directly:
class DFHACK_EXPORT enabler_inputst {
public:
std::string GetKeyDisplay(int binding);
};
class DFHACK_EXPORT renderer { class DFHACK_EXPORT renderer {
unsigned char *screen; unsigned char *screen;
long *screentexpos; long *screentexpos;
@ -418,15 +412,6 @@ public:
virtual bool get_mouse_coords(int &x, int &y) { return false; } virtual bool get_mouse_coords(int &x, int &y) { return false; }
virtual bool uses_opengl(); virtual bool uses_opengl();
}; };
#else
struct less_sz {
bool operator() (const string &a, const string &b) const {
if (a.size() < b.size()) return true;
if (a.size() > b.size()) return false;
return a < b;
}
};
static std::map<df::interface_key,std::set<string,less_sz> > *keydisplay = NULL;
#endif #endif
void init_screen_module(Core *core) void init_screen_module(Core *core)
@ -435,26 +420,13 @@ void init_screen_module(Core *core)
renderer tmp; renderer tmp;
if (!strict_virtual_cast<df::renderer>((virtual_ptr)&tmp)) if (!strict_virtual_cast<df::renderer>((virtual_ptr)&tmp))
cerr << "Could not fetch the renderer vtable." << std::endl; cerr << "Could not fetch the renderer vtable." << std::endl;
#else
if (!core->vinfo->getAddress("keydisplay", keydisplay))
keydisplay = NULL;
#endif #endif
} }
string Screen::getKeyDisplay(df::interface_key key) string Screen::getKeyDisplay(df::interface_key key)
{ {
#ifdef _LINUX
auto enabler = (enabler_inputst*)df::global::enabler;
if (enabler) if (enabler)
return enabler->GetKeyDisplay(key); return enabler->GetKeyDisplay(key);
#else
if (keydisplay)
{
auto it = keydisplay->find(key);
if (it != keydisplay->end() && !it->second.empty())
return *it->second.begin();
}
#endif
return "?"; return "?";
} }

@ -1 +1 @@
Subproject commit f04f55feaae9e234d88373cdf4491bde5fa346ef Subproject commit 559c23baa06f68d62a0ba674669389273bfcfb97