MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / InputObjectName

Function InputObjectName

editor/WorldObjectsGenericDialog.cpp:610–635  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

608// Returns true if got new name, false if cancelled.
609// the data in buf not changed if cancel is pressed
610bool 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
619try_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
637void CWorldObjectsGenericDialog::OnGenericAddNew() {
638 char filename[256], dir[256], fname[256], ext[32];

Callers 3

OnGenericAddNewMethod · 0.85
OnGenericChangeNameMethod · 0.85
OnGenericPasteMethod · 0.85

Calls 3

InputStringFunction · 0.85
FindObjectIDNameFunction · 0.85
OutrageMessageBoxFunction · 0.85

Tested by

no test coverage detected