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
| 1098 | // Returns true if got new name, false if cancelled. |
| 1099 | // the data in buf not changed if cancel is pressed |
| 1100 | bool InputSoundName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { |
| 1101 | if (len > (PAGENAME_LEN - 1)) |
| 1102 | len = PAGENAME_LEN - 1; |
| 1103 | |
| 1104 | char *tempbuf = (char *)mem_malloc(len); |
| 1105 | |
| 1106 | strncpy(tempbuf, buf, len - 1); |
| 1107 | tempbuf[len - 1] = '\0'; |
| 1108 | |
| 1109 | try_again: |
| 1110 | |
| 1111 | if (!InputString(tempbuf, len, title, prompt, wnd)) { |
| 1112 | mem_free(tempbuf); |
| 1113 | return 0; |
| 1114 | } |
| 1115 | |
| 1116 | if (FindSoundName(tempbuf) != -1) { |
| 1117 | OutrageMessageBox("The name you specified is already in use. Enter another name."); |
| 1118 | goto try_again; |
| 1119 | } |
| 1120 | |
| 1121 | strcpy(buf, tempbuf); |
| 1122 | mem_free(tempbuf); |
| 1123 | |
| 1124 | return 1; |
| 1125 | } |
| 1126 | |
| 1127 | void CWorldSoundsDialog::OnSoundChangeName() { |
| 1128 | int n = D3EditState.current_sound; |
no test coverage detected