Set all the items within a given menu, with the given itemName, to the given text
| 1774 | |
| 1775 | // Set all the items within a given menu, with the given itemName, to the given text |
| 1776 | void Menu_SetItemText(const menuDef_t *menu,const char *itemName, const char *text) |
| 1777 | { |
| 1778 | itemDef_t *item; |
| 1779 | int j, count; |
| 1780 | |
| 1781 | if (!menu) // No menu??? |
| 1782 | { |
| 1783 | return; |
| 1784 | } |
| 1785 | |
| 1786 | count = Menu_ItemsMatchingGroup( (menuDef_t *) menu, itemName); |
| 1787 | |
| 1788 | for (j = 0; j < count; j++) |
| 1789 | { |
| 1790 | item = Menu_GetMatchingItemByNumber( (menuDef_t *) menu, j, itemName); |
| 1791 | if (item != NULL) |
| 1792 | { |
| 1793 | if (text[0] == '*') |
| 1794 | { |
| 1795 | item->cvar = text+1; |
| 1796 | // Just copying what was in ItemParse_cvar() |
| 1797 | if ( item->typeData) |
| 1798 | { |
| 1799 | editFieldDef_t *editPtr; |
| 1800 | editPtr = (editFieldDef_t*)item->typeData; |
| 1801 | editPtr->minVal = -1; |
| 1802 | editPtr->maxVal = -1; |
| 1803 | editPtr->defVal = -1; |
| 1804 | } |
| 1805 | } |
| 1806 | else |
| 1807 | { |
| 1808 | if (item->type == ITEM_TYPE_TEXTSCROLL ) |
| 1809 | { |
| 1810 | char cvartext[1024]; |
| 1811 | textScrollDef_t *scrollPtr = (textScrollDef_t*)item->typeData; |
| 1812 | if ( scrollPtr ) |
| 1813 | { |
| 1814 | scrollPtr->startPos = 0; |
| 1815 | scrollPtr->endPos = 0; |
| 1816 | } |
| 1817 | |
| 1818 | if (item->cvar) |
| 1819 | { |
| 1820 | DC->getCVarString(item->cvar, cvartext, sizeof(cvartext)); |
| 1821 | item->text = cvartext; |
| 1822 | } |
| 1823 | else |
| 1824 | { |
| 1825 | item->text = (char *) text; |
| 1826 | } |
| 1827 | |
| 1828 | Item_TextScroll_BuildLines ( item ); |
| 1829 | } |
| 1830 | else |
| 1831 | { |
| 1832 | item->text = (char *) text; |
| 1833 | } |
no test coverage detected