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
| 1998 | // Returns true if got new name, false if cancelled. |
| 1999 | // the data in buf not changed if cancel is pressed |
| 2000 | bool InputTextureName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { |
| 2001 | char *tempbuf = (char *)mem_malloc(len); |
| 2002 | |
| 2003 | strcpy(tempbuf, buf); |
| 2004 | |
| 2005 | try_again: |
| 2006 | |
| 2007 | if (!InputString(tempbuf, len, title, prompt, wnd)) { |
| 2008 | mem_free(tempbuf); |
| 2009 | return 0; |
| 2010 | } |
| 2011 | |
| 2012 | if (FindTextureName(tempbuf) != -1) { |
| 2013 | OutrageMessageBox("The name you specified is already in use. Enter another name."); |
| 2014 | goto try_again; |
| 2015 | } |
| 2016 | |
| 2017 | strcpy(buf, tempbuf); |
| 2018 | mem_free(tempbuf); |
| 2019 | |
| 2020 | return 1; |
| 2021 | } |
| 2022 | |
| 2023 | void CWorldTexturesDialog::OnTextureChangeName() { |
| 2024 | int n = D3EditState.texdlg_texture; |
no test coverage detected