| 1706 | } |
| 1707 | |
| 1708 | static bool ConScreenShot(std::span<std::string_view> argv) |
| 1709 | { |
| 1710 | if (argv.empty()) { |
| 1711 | IConsolePrint(CC_HELP, "Create a screenshot of the game. Usage: 'screenshot [viewport | normal | big | giant | heightmap | minimap] [no_con] [size <width> <height>] [<filename>]'."); |
| 1712 | IConsolePrint(CC_HELP, " 'viewport' (default) makes a screenshot of the current viewport (including menus, windows)."); |
| 1713 | IConsolePrint(CC_HELP, " 'normal' makes a screenshot of the visible area."); |
| 1714 | IConsolePrint(CC_HELP, " 'big' makes a zoomed-in screenshot of the visible area."); |
| 1715 | IConsolePrint(CC_HELP, " 'giant' makes a screenshot of the whole map."); |
| 1716 | IConsolePrint(CC_HELP, " 'heightmap' makes a heightmap screenshot of the map that can be loaded in as heightmap."); |
| 1717 | IConsolePrint(CC_HELP, " 'minimap' makes a top-viewed minimap screenshot of the whole world which represents one tile by one pixel."); |
| 1718 | IConsolePrint(CC_HELP, " 'no_con' hides the console to create the screenshot (only useful in combination with 'viewport')."); |
| 1719 | IConsolePrint(CC_HELP, " 'size' sets the width and height of the viewport to make a screenshot of (only useful in combination with 'normal' or 'big')."); |
| 1720 | IConsolePrint(CC_HELP, " A filename ending in # will prevent overwriting existing files and will number files counting upwards."); |
| 1721 | return true; |
| 1722 | } |
| 1723 | |
| 1724 | if (argv.size() > 7) return false; |
| 1725 | |
| 1726 | ScreenshotType type = SC_VIEWPORT; |
| 1727 | uint32_t width = 0; |
| 1728 | uint32_t height = 0; |
| 1729 | std::string name{}; |
| 1730 | uint32_t arg_index = 1; |
| 1731 | |
| 1732 | if (argv.size() > arg_index) { |
| 1733 | if (argv[arg_index] == "viewport") { |
| 1734 | type = SC_VIEWPORT; |
| 1735 | arg_index += 1; |
| 1736 | } else if (argv[arg_index] == "normal") { |
| 1737 | type = SC_DEFAULTZOOM; |
| 1738 | arg_index += 1; |
| 1739 | } else if (argv[arg_index] == "big") { |
| 1740 | type = SC_ZOOMEDIN; |
| 1741 | arg_index += 1; |
| 1742 | } else if (argv[arg_index] == "giant") { |
| 1743 | type = SC_WORLD; |
| 1744 | arg_index += 1; |
| 1745 | } else if (argv[arg_index] == "heightmap") { |
| 1746 | type = SC_HEIGHTMAP; |
| 1747 | arg_index += 1; |
| 1748 | } else if (argv[arg_index] == "minimap") { |
| 1749 | type = SC_MINIMAP; |
| 1750 | arg_index += 1; |
| 1751 | } |
| 1752 | } |
| 1753 | |
| 1754 | if (argv.size() > arg_index && argv[arg_index] == "no_con") { |
| 1755 | if (type != SC_VIEWPORT) { |
| 1756 | IConsolePrint(CC_ERROR, "'no_con' can only be used in combination with 'viewport'."); |
| 1757 | return true; |
| 1758 | } |
| 1759 | IConsoleClose(); |
| 1760 | arg_index += 1; |
| 1761 | } |
| 1762 | |
| 1763 | if (argv.size() > arg_index + 2 && argv[arg_index] == "size") { |
| 1764 | /* size <width> <height> */ |
| 1765 | if (type != SC_DEFAULTZOOM && type != SC_ZOOMEDIN) { |
nothing calls this directly
no test coverage detected