doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GetString.cpp
Go to the documentation of this file.
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 
50 {
51 }
52 
53 void CGetString::DoDataExchange(CDataExchange* pDX)
54 {
55  CDialog::DoDataExchange(pDX);
56  DDX_Text(pDX, IDC_EDIT1, m_strEditBox);
57 }
58 
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 
CMainFrame * g_pParentWnd
Definition: MainFrm.cpp:73
void InfoBox(const char *sString)
Definition: GetString.cpp:116
virtual ~CGetString()
Definition: GetString.cpp:49
virtual void DoDataExchange(CDataExchange *pDX)
Definition: GetString.cpp:53
void WarningBox(const char *sString)
Definition: GetString.cpp:120
#define BOOL
Definition: mprintf.c:71
CString m_strEditBox
Definition: GetString.h:52
virtual BOOL OnInitDialog()
Definition: GetString.cpp:59
#define NULL
Definition: Lib.h:88
LPCSTR GetString(LPCSTR psPrompt)
Definition: GetString.cpp:87
#define DIALOG_TO_DATA
Definition: Radiant.h:76
LPCSTR m_pPrompt
Definition: GetString.h:54
CString * m_pFeedback
Definition: GetString.h:53
CGetString(LPCSTR pPrompt, CString *pFeedback, CWnd *pParent=NULL)
Definition: GetString.cpp:40
#define TRUE
Definition: mprintf.c:69
void ErrorBox(const char *sString)
Definition: GetString.cpp:112
bool GetYesNo(const char *psQuery)
Definition: GetString.cpp:104
#define IDC_EDIT1
#define IDC_PROMPT