|
|
|
@ -1,23 +1,23 @@
|
|
|
|
|
//command-prompt a one line command entry at the top of the screen for quick commands
|
|
|
|
|
// command-prompt: A one-line command entry at the top of the screen for quick commands
|
|
|
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
|
#include <ColorText.h>
|
|
|
|
|
#include <Console.h>
|
|
|
|
|
#include <Export.h>
|
|
|
|
|
#include <PluginManager.h>
|
|
|
|
|
#include <ColorText.h>
|
|
|
|
|
|
|
|
|
|
#include <modules/Screen.h>
|
|
|
|
|
#include <modules/Gui.h>
|
|
|
|
|
#include <modules/Screen.h>
|
|
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "df/enabler.h"
|
|
|
|
|
#include "df/graphic.h"
|
|
|
|
|
#include "df/interface_key.h"
|
|
|
|
|
#include "df/ui.h"
|
|
|
|
|
#include "df/graphic.h"
|
|
|
|
|
#include "df/enabler.h"
|
|
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
|
using namespace df::enums;
|
|
|
|
@ -36,7 +36,9 @@ class prompt_ostream:public buffered_color_ostream
|
|
|
|
|
protected:
|
|
|
|
|
void flush_proxy();
|
|
|
|
|
public:
|
|
|
|
|
prompt_ostream(viewscreen_commandpromptst* parent):parent_(parent){}
|
|
|
|
|
prompt_ostream(viewscreen_commandpromptst* parent)
|
|
|
|
|
: parent_(parent)
|
|
|
|
|
{}
|
|
|
|
|
bool empty() { return buffer.empty(); }
|
|
|
|
|
};
|
|
|
|
|
class viewscreen_commandpromptst : public dfhack_viewscreen {
|
|
|
|
@ -57,7 +59,8 @@ public:
|
|
|
|
|
df::plant* getSelectedPlant() { return Gui::getAnyPlant(parent); }
|
|
|
|
|
|
|
|
|
|
std::string getFocusString() { return "commandprompt"; }
|
|
|
|
|
viewscreen_commandpromptst(std::string entry):submitted(false), is_response(false)
|
|
|
|
|
viewscreen_commandpromptst(std::string entry)
|
|
|
|
|
: submitted(false), is_response(false)
|
|
|
|
|
{
|
|
|
|
|
show_fps = gps->display_frames;
|
|
|
|
|
gps->display_frames = 0;
|
|
|
|
@ -161,7 +164,8 @@ void viewscreen_commandpromptst::render()
|
|
|
|
|
{
|
|
|
|
|
Screen::fillRect(Screen::Pen(' ', 7, 0), 0, i, dim.x, i);
|
|
|
|
|
std::string cur_line = it->second;
|
|
|
|
|
Screen::paintString(Screen::Pen(' ',it->first,0),0,i,cur_line.substr(0,cur_line.size()-1));
|
|
|
|
|
Screen::paintString(Screen::Pen(' ', it->first, 0), 0, i,
|
|
|
|
|
cur_line.substr(0, cur_line.size() - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -170,7 +174,7 @@ void viewscreen_commandpromptst::render()
|
|
|
|
|
Screen::fillRect(Screen::Pen(' ', 7, 0), 0, 0, dim.x, 0);
|
|
|
|
|
Screen::paintString(Screen::Pen(' ', 7, 0), 0, 0, "[DFHack]#");
|
|
|
|
|
std::string cursor = (frame < enabler->gfps / 2) ? "_" : " ";
|
|
|
|
|
if(cursor_pos < (dim.x - 10))
|
|
|
|
|
if (cursor_pos < dim.x - 10)
|
|
|
|
|
{
|
|
|
|
|
Screen::paintString(Screen::Pen(' ', 7, 0), 10, 0, entry);
|
|
|
|
|
if (int16_t(entry.size()) > dim.x - 10)
|
|
|
|
@ -333,8 +337,10 @@ bool hotkey_allow_all(df::viewscreen *top)
|
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
|
{
|
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
|
"command-prompt","Shows a command prompt on window.",show_prompt,hotkey_allow_all,
|
|
|
|
|
"command-prompt [entry] - shows a cmd prompt in df window. Entry is used for default prefix (e.g. ':lua')"
|
|
|
|
|
"command-prompt", "Shows a command prompt on window.",
|
|
|
|
|
show_prompt, hotkey_allow_all,
|
|
|
|
|
"command-prompt [entry] - shows a cmd prompt in df window."
|
|
|
|
|
" Entry is used for default prefix (e.g. ':lua')"
|
|
|
|
|
));
|
|
|
|
|
return CR_OK;
|
|
|
|
|
}
|
|
|
|
|