use keyboard cursor

and adapt to a "bad" cursor not being equal to -30000 anymore
develop
Myk Taylor 2023-01-18 13:57:42 -08:00
parent 4183bace4d
commit eae2cec22f
No known key found for this signature in database
5 changed files with 12 additions and 12 deletions

@ -3,7 +3,7 @@ coord(uint16_t _x, uint16_t _y, uint16_t _z) : x(_x), y(_y), z(_z) {}
operator coord2d() const { return coord2d(x,y); } operator coord2d() const { return coord2d(x,y); }
bool isValid() const { return x != -30000; } bool isValid() const { return x >= 0; }
void clear() { x = y = z = -30000; } void clear() { x = y = z = -30000; }
bool operator==(const coord &other) const bool operator==(const coord &other) const

@ -1,6 +1,6 @@
coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {} coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {}
bool isValid() const { return x != -30000; } bool isValid() const { return x >= 0; }
void clear() { x = y = -30000; } void clear() { x = y = -30000; }
bool operator==(const coord2d &other) const bool operator==(const coord2d &other) const

@ -321,7 +321,7 @@ end
function pos2xyz(pos) function pos2xyz(pos)
if pos then if pos then
local x = pos.x local x = pos.x
if x and x ~= -30000 then if x and x >= 0 then
return x, pos.y, pos.z return x, pos.y, pos.z
end end
end end
@ -346,7 +346,7 @@ end
function pos2xy(pos) function pos2xy(pos)
if pos then if pos then
local x = pos.x local x = pos.x
if x and x ~= -30000 then if x and x >= 0 then
return x, pos.y return x, pos.y
end end
end end

@ -649,7 +649,7 @@ bool Gui::item_details_hotkey(df::viewscreen *top)
static bool has_cursor() static bool has_cursor()
{ {
return df::global::cursor && df::global::cursor->x != -30000; return Gui::getCursorPos().isValid();
} }
bool Gui::cursor_hotkey(df::viewscreen *top) bool Gui::cursor_hotkey(df::viewscreen *top)
@ -1720,7 +1720,7 @@ bool Gui::autoDFAnnouncement(df::report_init r, string message)
// Check if the announcement will actually be announced // Check if the announcement will actually be announced
if (*gamemode == game_mode::ADVENTURE) if (*gamemode == game_mode::ADVENTURE)
{ {
if (r.pos.x != -30000 && if (r.pos.x >= 0 &&
r.type != announcement_type::CREATURE_SOUND && r.type != announcement_type::CREATURE_SOUND &&
r.type != announcement_type::REGULAR_CONVERSATION && r.type != announcement_type::REGULAR_CONVERSATION &&
r.type != announcement_type::CONFLICT_CONVERSATION && r.type != announcement_type::CONFLICT_CONVERSATION &&
@ -2151,7 +2151,7 @@ bool Gui::getDesignationCoords (int32_t &x, int32_t &y, int32_t &z)
x = selection_rect->start_x; x = selection_rect->start_x;
y = selection_rect->start_y; y = selection_rect->start_y;
z = selection_rect->start_z; z = selection_rect->start_z;
return (x == -30000) ? false : true; return (x >= 0) ? false : true;
} }
bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t z) bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t z)

@ -281,12 +281,12 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCom
"autodump", "autodump",
"Teleport items marked for dumping to the keyboard cursor.", "Teleport items marked for dumping to the keyboard cursor.",
df_autodump, df_autodump,
Gui::dwarfmode_hotkey)); Gui::cursor_hotkey));
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"autodump-destroy-here", "autodump-destroy-here",
"Destroy items marked for dumping under the keyboard cursor.", "Destroy items marked for dumping under the keyboard cursor.",
df_autodump_destroy_here, df_autodump_destroy_here,
Gui::dwarfmode_hotkey)); Gui::cursor_hotkey));
/* you can no longer select items /* you can no longer select items
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"autodump-destroy-item", "autodump-destroy-item",
@ -346,12 +346,12 @@ static command_result autodump_main(color_ostream &out, vector <string> & parame
MapCache MC; MapCache MC;
int dumped_total = 0; int dumped_total = 0;
DFCoord pos_cursor; df::coord pos_cursor;
if(!destroy || here) if(!destroy || here)
{ {
pos_cursor = Gui::getMousePos(); pos_cursor = Gui::getCursorPos();
if (!pos_cursor.isValid()) { if (!pos_cursor.isValid()) {
out.printerr("Mouse cursor must be over a suitable map tile.\n"); out.printerr("Keyboard cursor must be over a suitable map tile.\n");
return CR_FAILURE; return CR_FAILURE;
} }
} }