Fix stuff (#4)

* Update Lua API.rst

* Update Gui.h

* Update Gui.cpp

* Update LuaApi.cpp
develop
Ryan Williams 2022-05-01 22:53:53 -07:00 committed by GitHub
parent c89baa5e33
commit f565de88e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 21 deletions

@ -1007,18 +1007,17 @@ Fortress mode
* ``dfhack.gui.pauseRecenter(pos[,pause])`` * ``dfhack.gui.pauseRecenter(pos[,pause])``
``dfhack.gui.pauseRecenter(x,y,z[,pause])`` ``dfhack.gui.pauseRecenter(x,y,z[,pause])``
Same as ``resetDwarfmodeView``, but also recenter if ``x`` isn't ``-30000``, Same as ``resetDwarfmodeView``, but also recenter if ``x`` isn't ``-30000``, and respects
and respects RECENTER_INTERFACE_SHUTDOWN_MS (the delay before input is recognized when a recenter occurs) in DF's init.txt. RECENTER_INTERFACE_SHUTDOWN_MS (the delay before input is recognized when a recenter occurs) in DF's init.txt.
* ``dfhack.gui.recenterViewscreen(pos[,zoom])`` * ``dfhack.gui.recenterViewscreen(pos[,zoom])``
``dfhack.gui.recenterViewscreen(x,y,z[,zoom])`` ``dfhack.gui.recenterViewscreen(x,y,z[,zoom])``
``dfhack.gui.recenterViewscreen([zoom])`` ``dfhack.gui.recenterViewscreen([zoom])``
Recenter the view on a position using a specific zoom type. If no position is Recenter the view on a position using a specific zoom type. If no position is given,
given, recenter on ``df.global.cursor``. Zoom types are ``df.report_zoom_type`` recenter on ``df.global.cursor``. Zoom types are ``df.report_zoom_type`` (0 = Generic, 1 = Item, 2 = Unit),
(0 = Generic, 1 = Item, 2 = Unit), where ``Generic`` skips recentering and where ``Generic`` skips recentering and enforces valid view bounds (the same as x = -30000,) ``Item`` brings
enforces valid view bounds (the same as x = -30000,) ``Item`` brings the position onscreen, and ``Unit`` centers the screen on the position. the position onscreen without centering, and ``Unit`` centers the screen on the position. Default zoom type is Item.
Default zoom type is Item.
* ``dfhack.gui.revealInDwarfmodeMap(pos)`` * ``dfhack.gui.revealInDwarfmodeMap(pos)``
@ -1090,12 +1089,13 @@ Announcements
operations accordingly. The units are used to call ``addCombatReportAuto``. operations accordingly. The units are used to call ``addCombatReportAuto``.
* ``dfhack.gui.autoDFAnnouncement(report,text[,log_failures])`` * ``dfhack.gui.autoDFAnnouncement(report,text[,log_failures])``
``dfhack.gui.autoDFAnnouncement(type,pos,text,color[,is_bright,unit1,unit2,not_sparring,log_failures])`` ``dfhack.gui.autoDFAnnouncement(type,pos,text,color[,is_bright,unit1,unit2,is_sparring,log_failures])``
Takes a ``df.report_init`` (see: https://github.com/DFHack/df-structures/blob/master/df.announcements.xml#L451) and a string and processes them just like DF does. Takes a ``df.report_init`` (see: https://github.com/DFHack/df-structures/blob/master/df.announcements.xml#L451)
Sometimes this means the announcement won't occur. Set ``log_failures`` to ``true`` to and a string and processes them just like DF does. Sometimes this means the announcement won't occur.
log the reason why to the dfhack console (e.g., unrevealed map or wrong gamemode.) Set ``log_failures`` to ``true`` to log the reason why to the dfhack console (e.g., unrevealed map or wrong gamemode.)
Can also be built from parameters instead of a ``report_init``. Setting ``not_sparring`` to ``false`` means it will be added to sparring logs (if applicable) rather than hunting or combat. Can also be built from parameters instead of a ``report_init``. Setting ``is_sparring`` to ``true`` means the report
will be added to sparring logs (if applicable) rather than hunting or combat.
Other Other
~~~~~ ~~~~~

@ -1525,7 +1525,7 @@ static int gui_autoDFAnnouncement(lua_State *state)
{ {
df::coord pos; df::coord pos;
int color; int color;
bool bright, sparring, log_failures; bool bright, is_sparring, log_failures;
df::unit *unit1, *unit2; df::unit *unit1, *unit2;
auto type = (df::announcement_type)lua_tointeger(state, 1); auto type = (df::announcement_type)lua_tointeger(state, 1);
@ -1538,7 +1538,7 @@ static int gui_autoDFAnnouncement(lua_State *state)
case 9: case 9:
log_failures = lua_toboolean(state, 9); log_failures = lua_toboolean(state, 9);
case 8: case 8:
sparring = lua_toboolean(state, 8); is_sparring = lua_toboolean(state, 8);
case 7: case 7:
unit2 = Lua::CheckDFObject<df::unit>(state, 7); unit2 = Lua::CheckDFObject<df::unit>(state, 7);
case 6: case 6:
@ -1555,10 +1555,10 @@ static int gui_autoDFAnnouncement(lua_State *state)
{ // Use the defaults in Gui.h { // Use the defaults in Gui.h
default: default:
case 9: case 9:
rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2, sparring, log_failures); rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2, is_sparring, log_failures);
break; break;
case 8: case 8:
rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2, sparring); rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2, is_sparring);
break; break;
case 7: case 7:
rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2); rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2);

@ -131,7 +131,7 @@ namespace DFHack
// Process an announcement exactly like DF would, which might result in no announcement // Process an announcement exactly like DF would, which might result in no announcement
DFHACK_EXPORT int autoDFAnnouncement(df::report_init r, std::string message); DFHACK_EXPORT int autoDFAnnouncement(df::report_init r, std::string message);
DFHACK_EXPORT int autoDFAnnouncement(df::report_init r, std::string message, bool log_failures); DFHACK_EXPORT int autoDFAnnouncement(df::report_init r, std::string message, bool log_failures);
DFHACK_EXPORT int autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true, df::unit *unit1 = NULL, df::unit *unit2 = NULL, bool sparring = false, bool log_failures = false); DFHACK_EXPORT int autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true, df::unit *unit1 = NULL, df::unit *unit2 = NULL, bool is_sparring = false, bool log_failures = false);
/* /*
* Cursor and window coords * Cursor and window coords

@ -1831,7 +1831,7 @@ int Gui::autoDFAnnouncement(df::report_init r, string message)
{ {
if (r.unit1 != NULL) if (r.unit1 != NULL)
{ {
if (r.flags.bits.sparring) // TODO: flags.sparring is inverted if (r.flags.bits.hostile_combat)
success |= addCombatReport(r.unit1, unit_report_type::Combat, new_report_index); success |= addCombatReport(r.unit1, unit_report_type::Combat, new_report_index);
else if (r.unit1->job.current_job != NULL && r.unit1->job.current_job->job_type == job_type::Hunt) else if (r.unit1->job.current_job != NULL && r.unit1->job.current_job->job_type == job_type::Hunt)
success |= addCombatReport(r.unit1, unit_report_type::Hunting, new_report_index); success |= addCombatReport(r.unit1, unit_report_type::Hunting, new_report_index);
@ -1841,7 +1841,7 @@ int Gui::autoDFAnnouncement(df::report_init r, string message)
if (r.unit2 != NULL) if (r.unit2 != NULL)
{ {
if (r.flags.bits.sparring) // TODO: flags.sparring is inverted if (r.flags.bits.hostile_combat)
success |= addCombatReport(r.unit2, unit_report_type::Combat, new_report_index); success |= addCombatReport(r.unit2, unit_report_type::Combat, new_report_index);
else if (r.unit2->job.current_job != NULL && r.unit2->job.current_job->job_type == job_type::Hunt) else if (r.unit2->job.current_job != NULL && r.unit2->job.current_job->job_type == job_type::Hunt)
success |= addCombatReport(r.unit2, unit_report_type::Hunting, new_report_index); success |= addCombatReport(r.unit2, unit_report_type::Hunting, new_report_index);
@ -1923,7 +1923,7 @@ int Gui::autoDFAnnouncement(df::report_init r, string message, bool log_failures
return rv; return rv;
} }
int Gui::autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color, bool bright, df::unit *unit1, df::unit *unit2, bool sparring, bool log_failures) int Gui::autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color, bool bright, df::unit *unit1, df::unit *unit2, bool is_sparring, bool log_failures)
{ {
auto r = df::report_init(); auto r = df::report_init();
r.type = type; r.type = type;
@ -1932,7 +1932,7 @@ int Gui::autoDFAnnouncement(df::announcement_type type, df::coord pos, std::stri
r.pos = pos; r.pos = pos;
r.unit1 = unit1; r.unit1 = unit1;
r.unit2 = unit2; r.unit2 = unit2;
r.flags.bits.sparring = !sparring; // TODO: inverted r.flags.bits.hostile_combat = !is_sparring;
if (Maps::isValidTilePos(pos)) if (Maps::isValidTilePos(pos))
r.zoom_type = report_zoom_type::Unit; r.zoom_type = report_zoom_type::Unit;