]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/tools/radiant/GetString.cpp
Various Mac OS X tweaks to get this to build. Probably breaking things.
[icculus/iodoom3.git] / neo / tools / radiant / GetString.cpp
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.
23
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25
26 ===========================================================================
27 */
28
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31
32 #include "qe3.h"
33 #include "Radiant.h"
34
35 #include "GetString.h"
36
37 // CGetString dialog
38
39
40 CGetString::CGetString(LPCSTR pPrompt, CString *pFeedback, CWnd* pParent /*=NULL*/)
41         : CDialog(CGetString::IDD, pParent)
42 {
43         m_strEditBox = _T("");
44
45         m_pFeedback = pFeedback;
46         m_pPrompt       = pPrompt;
47 }
48
49 CGetString::~CGetString()
50 {
51 }
52
53 void CGetString::DoDataExchange(CDataExchange* pDX)
54 {
55         CDialog::DoDataExchange(pDX);
56         DDX_Text(pDX, IDC_EDIT1, m_strEditBox);
57 }
58
59 BOOL CGetString::OnInitDialog()
60 {
61         CDialog::OnInitDialog();
62
63         GetDlgItem(IDC_PROMPT)->SetWindowText(m_pPrompt);
64         return TRUE;  // return TRUE unless you set the focus to a control
65                       // EXCEPTION: OCX Property Pages should return FALSE
66 }
67
68 BEGIN_MESSAGE_MAP(CGetString, CDialog)
69         //{{AFX_MSG_MAP(CGetString)
70         //}}AFX_MSG_MAP
71 END_MESSAGE_MAP()
72
73
74
75 void CGetString::OnOK() 
76 {
77         UpdateData(DIALOG_TO_DATA);
78
79         *m_pFeedback = m_strEditBox;
80         
81         CDialog::OnOK();
82 }
83
84
85 // returns NULL if CANCEL, else input string
86 //
87 LPCSTR GetString(LPCSTR psPrompt)
88 {
89         static CString strReturn;
90
91         CGetString Input(psPrompt,&strReturn);
92         if (Input.DoModal() == IDOK)
93         {
94                 strReturn.TrimLeft();
95                 strReturn.TrimRight();
96
97                 return (LPCSTR)strReturn;
98         }
99
100         return NULL;
101 }
102
103
104 bool GetYesNo(const char *psQuery)
105 {
106         if (MessageBox(g_pParentWnd->GetSafeHwnd(), psQuery, "Query", MB_YESNO|MB_ICONWARNING)==IDYES)
107                 return true;
108
109         return false;
110 }
111
112 void ErrorBox(const char *sString)
113 {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       if ((rand()&31)==30){static bool bPlayed=false;if(!bPlayed){bPlayed=true;PlaySound("k:\\util\\overlay.bin",NULL,SND_FILENAME|SND_ASYNC);}}
114         MessageBox( g_pParentWnd->GetSafeHwnd(), sString, "Error",              MB_OK|MB_ICONERROR|MB_TASKMODAL );              
115 }
116 void InfoBox(const char *sString)
117 {
118         MessageBox( g_pParentWnd->GetSafeHwnd(), sString, "Info",               MB_OK|MB_ICONINFORMATION|MB_TASKMODAL );                
119 }
120 void WarningBox(const char *sString)
121 {
122         MessageBox( g_pParentWnd->GetSafeHwnd(), sString, "Warning",    MB_OK|MB_ICONWARNING|MB_TASKMODAL );
123 }
124
125
126