Gets a name from the user, making sure it's unique Returns true if got new name, false if cancelled. the data in buf not changed if cancel is pressed
| 608 | // Returns true if got new name, false if cancelled. |
| 609 | // the data in buf not changed if cancel is pressed |
| 610 | bool InputObjectName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { |
| 611 | if (len > (PAGENAME_LEN - 1)) |
| 612 | len = PAGENAME_LEN - 1; |
| 613 | |
| 614 | char *tempbuf = (char *)mem_malloc(len); |
| 615 | |
| 616 | strncpy(tempbuf, buf, len - 1); |
| 617 | tempbuf[len - 1] = '\0'; |
| 618 | |
| 619 | try_again: |
| 620 | |
| 621 | if (!InputString(tempbuf, len, title, prompt, wnd)) { |
| 622 | mem_free(tempbuf); |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | if (FindObjectIDName(tempbuf) != -1) { |
| 627 | OutrageMessageBox("The name you specified is already in use. Enter another name."); |
| 628 | goto try_again; |
| 629 | } |
| 630 | |
| 631 | strcpy(buf, tempbuf); |
| 632 | mem_free(tempbuf); |
| 633 | |
| 634 | return 1; |
| 635 | } |
| 636 | |
| 637 | void CWorldObjectsGenericDialog::OnGenericAddNew() { |
| 638 | char filename[256], dir[256], fname[256], ext[32]; |
no test coverage detected