| 1687 | } |
| 1688 | |
| 1689 | static int gui_autoDFAnnouncement(lua_State *state) |
| 1690 | { |
| 1691 | bool rv; // success |
| 1692 | df::announcement_infost *r = Lua::GetDFObject<df::announcement_infost>(state, 1); |
| 1693 | |
| 1694 | if (r) |
| 1695 | { |
| 1696 | string message = luaL_checkstring(state, 2); |
| 1697 | rv = Gui::autoDFAnnouncement(*r, message); |
| 1698 | } |
| 1699 | else |
| 1700 | { |
| 1701 | df::coord pos; |
| 1702 | int color = 0; |
| 1703 | bool bright = false, is_sparring = false; |
| 1704 | df::unit *unit_a = NULL, *unit_d = NULL; |
| 1705 | |
| 1706 | auto type = (df::announcement_type)lua_tointeger(state, 1); |
| 1707 | Lua::CheckDFAssign(state, &pos, 2); |
| 1708 | string message = luaL_checkstring(state, 3); |
| 1709 | |
| 1710 | switch (lua_gettop(state)) |
| 1711 | { |
| 1712 | default: |
| 1713 | case 8: |
| 1714 | is_sparring = lua_toboolean(state, 8); |
| 1715 | case 7: |
| 1716 | unit_d = Lua::CheckDFObject<df::unit>(state, 7); |
| 1717 | case 6: |
| 1718 | unit_a = Lua::CheckDFObject<df::unit>(state, 6); |
| 1719 | case 5: |
| 1720 | bright = lua_toboolean(state, 5); |
| 1721 | case 4: |
| 1722 | color = lua_tointeger(state, 4); |
| 1723 | case 3: |
| 1724 | break; |
| 1725 | } |
| 1726 | |
| 1727 | switch (lua_gettop(state)) |
| 1728 | { // Use the defaults in Gui.h |
| 1729 | default: |
| 1730 | case 8: |
| 1731 | rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit_a, unit_d, is_sparring); |
| 1732 | break; |
| 1733 | case 7: |
| 1734 | rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit_a, unit_d); |
| 1735 | break; |
| 1736 | case 6: |
| 1737 | rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit_a); |
| 1738 | break; |
| 1739 | case 5: |
| 1740 | rv = Gui::autoDFAnnouncement(type, pos, message, color, bright); |
| 1741 | break; |
| 1742 | case 4: |
| 1743 | rv = Gui::autoDFAnnouncement(type, pos, message, color); |
| 1744 | break; |
| 1745 | case 3: |
| 1746 | rv = Gui::autoDFAnnouncement(type, pos, message); |
nothing calls this directly
no test coverage detected