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 "sys/platform.h"
30 #include "ui/Window.h"
31 #include "ui/UserInterfaceLocal.h"
32
33 #include "ui/Winvar.h"
34
35 const char *VAR_GUIPREFIX = "gui::";
36 static const int VAR_GUIPREFIX_LEN = strlen(VAR_GUIPREFIX);
37
idWinVar()38 idWinVar::idWinVar() {
39 guiDict = NULL;
40 name = NULL;
41 eval = true;
42 }
43
~idWinVar()44 idWinVar::~idWinVar() {
45 delete[] name;
46 name = NULL;
47 }
48
SetGuiInfo(idDict * gd,const char * _name)49 void idWinVar::SetGuiInfo(idDict *gd, const char *_name) {
50 guiDict = gd;
51 SetName(_name);
52 }
53
54
Init(const char * _name,idWindow * win)55 void idWinVar::Init(const char *_name, idWindow *win) {
56 idStr key = _name;
57 guiDict = NULL;
58 int len = key.Length();
59 if (len > 5 && key[0] == 'g' && key[1] == 'u' && key[2] == 'i' && key[3] == ':') {
60 key = key.Right(len - VAR_GUIPREFIX_LEN);
61 SetGuiInfo( win->GetGui()->GetStateDict(), key );
62 win->AddUpdateVar(this);
63 } else {
64 Set(_name);
65 }
66 }
67
Set(const char * val)68 void idMultiWinVar::Set( const char *val ) {
69 for ( int i = 0; i < Num(); i++ ) {
70 (*this)[i]->Set( val );
71 }
72 }
73
Update(void)74 void idMultiWinVar::Update( void ) {
75 for ( int i = 0; i < Num(); i++ ) {
76 (*this)[i]->Update();
77 }
78 }
79
SetGuiInfo(idDict * dict)80 void idMultiWinVar::SetGuiInfo( idDict *dict ) {
81 for ( int i = 0; i < Num(); i++ ) {
82 (*this)[i]->SetGuiInfo( dict, (*this)[i]->c_str() );
83 }
84 }
85