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 #ifndef __WINVAR_H__ 30 #define __WINVAR_H__ 31 32 #include "framework/File.h" 33 #include "ui/Rectangle.h" 34 35 extern const char *VAR_GUIPREFIX; 36 37 class idWindow; 38 class idWinVar { 39 public: 40 idWinVar(); 41 virtual ~idWinVar(); 42 43 void SetGuiInfo(idDict *gd, const char *_name); GetName()44 const char *GetName() const { 45 if (name) { 46 if (guiDict && *name == '*') { 47 return guiDict->GetString(&name[1]); 48 } 49 return name; 50 } 51 return ""; 52 } SetName(const char * _name)53 void SetName(const char *_name) { 54 delete[] name; 55 name = NULL; 56 if (_name) { 57 name = new char[strlen(_name)+1]; 58 strcpy(name, _name); 59 } 60 } 61 62 idWinVar &operator=( const idWinVar &other ) { 63 guiDict = other.guiDict; 64 SetName(other.name); 65 return *this; 66 } 67 GetDict()68 idDict *GetDict() const { return guiDict; } NeedsUpdate()69 bool NeedsUpdate() { return (guiDict != NULL); } 70 71 virtual void Init(const char *_name, idWindow* win) = 0; 72 virtual void Set(const char *val) = 0; 73 virtual void Update() = 0; 74 virtual const char *c_str() const = 0; Size()75 virtual size_t Size() { size_t sz = (name) ? strlen(name) : 0; return sz + sizeof(*this); } 76 77 virtual void WriteToSaveGame( idFile *savefile ) = 0; 78 virtual void ReadFromSaveGame( idFile *savefile ) = 0; 79 80 virtual float x( void ) const = 0; 81 SetEval(bool b)82 void SetEval(bool b) { 83 eval = b; 84 } GetEval()85 bool GetEval() { 86 return eval; 87 } 88 89 protected: 90 idDict *guiDict; 91 char *name; 92 bool eval; 93 }; 94 95 class idWinBool : public idWinVar { 96 public: idWinBool()97 idWinBool() : idWinVar() {}; ~idWinBool()98 ~idWinBool() {}; Init(const char * _name,idWindow * win)99 virtual void Init(const char *_name, idWindow *win) { idWinVar::Init(_name, win); 100 if (guiDict) { 101 data = guiDict->GetBool(GetName()); 102 } 103 } 104 int operator==( const bool &other ) { return (other == data); } 105 bool &operator=( const bool &other ) { 106 data = other; 107 if (guiDict) { 108 guiDict->SetBool(GetName(), data); 109 } 110 return data; 111 } 112 idWinBool &operator=( const idWinBool &other ) { 113 idWinVar::operator=(other); 114 data = other.data; 115 return *this; 116 } 117 118 operator bool() const { return data; } 119 Set(const char * val)120 virtual void Set(const char *val) { 121 data = ( atoi( val ) != 0 ); 122 if (guiDict) { 123 guiDict->SetBool(GetName(), data); 124 } 125 } 126 Update()127 virtual void Update() { 128 const char *s = GetName(); 129 if ( guiDict && s[0] != '\0' ) { 130 data = guiDict->GetBool( s ); 131 } 132 } 133 c_str()134 virtual const char *c_str() const {return va("%i", data); } 135 136 // SaveGames WriteToSaveGame(idFile * savefile)137 virtual void WriteToSaveGame( idFile *savefile ) { 138 savefile->Write( &eval, sizeof( eval ) ); 139 savefile->Write( &data, sizeof( data ) ); 140 } ReadFromSaveGame(idFile * savefile)141 virtual void ReadFromSaveGame( idFile *savefile ) { 142 savefile->Read( &eval, sizeof( eval ) ); 143 savefile->Read( &data, sizeof( data ) ); 144 } 145 x(void)146 virtual float x( void ) const { return data ? 1.0f : 0.0f; }; 147 148 protected: 149 bool data; 150 }; 151 152 class idWinStr : public idWinVar { 153 public: idWinStr()154 idWinStr() : idWinVar() {}; ~idWinStr()155 ~idWinStr() {}; Init(const char * _name,idWindow * win)156 virtual void Init(const char *_name, idWindow *win) { 157 idWinVar::Init(_name, win); 158 if (guiDict) { 159 data = guiDict->GetString(GetName()); 160 } 161 } 162 int operator==( const idStr &other ) const { 163 return (other == data); 164 } 165 int operator==( const char *other ) const { 166 return (data == other); 167 } 168 idStr &operator=( const idStr &other ) { 169 data = other; 170 if (guiDict) { 171 guiDict->Set(GetName(), data); 172 } 173 return data; 174 } 175 idWinStr &operator=( const idWinStr &other ) { 176 idWinVar::operator=(other); 177 data = other.data; 178 return *this; 179 } 180 operator const char *() const { 181 return data.c_str(); 182 } 183 operator const idStr &() const { 184 return data; 185 } LengthWithoutColors()186 int LengthWithoutColors() { 187 if (guiDict && name && *name) { 188 data = guiDict->GetString(GetName()); 189 } 190 return data.LengthWithoutColors(); 191 } Length()192 int Length() { 193 if (guiDict && name && *name) { 194 data = guiDict->GetString(GetName()); 195 } 196 return data.Length(); 197 } RemoveColors()198 void RemoveColors() { 199 if (guiDict && name && *name) { 200 data = guiDict->GetString(GetName()); 201 } 202 data.RemoveColors(); 203 } c_str()204 virtual const char *c_str() const { 205 return data.c_str(); 206 } 207 Set(const char * val)208 virtual void Set(const char *val) { 209 data = val; 210 if ( guiDict ) { 211 guiDict->Set(GetName(), data); 212 } 213 } 214 Update()215 virtual void Update() { 216 const char *s = GetName(); 217 if ( guiDict && s[0] != '\0' ) { 218 data = guiDict->GetString( s ); 219 } 220 } 221 Size()222 virtual size_t Size() { 223 size_t sz = idWinVar::Size(); 224 return sz +data.Allocated(); 225 } 226 227 // SaveGames WriteToSaveGame(idFile * savefile)228 virtual void WriteToSaveGame( idFile *savefile ) { 229 savefile->Write( &eval, sizeof( eval ) ); 230 231 int len = data.Length(); 232 savefile->Write( &len, sizeof( len ) ); 233 if ( len > 0 ) { 234 savefile->Write( data.c_str(), len ); 235 } 236 } ReadFromSaveGame(idFile * savefile)237 virtual void ReadFromSaveGame( idFile *savefile ) { 238 savefile->Read( &eval, sizeof( eval ) ); 239 240 int len; 241 savefile->Read( &len, sizeof( len ) ); 242 if ( len > 0 ) { 243 data.Fill( ' ', len ); 244 savefile->Read( &data[0], len ); 245 } 246 } 247 248 // return wether string is emtpy x(void)249 virtual float x( void ) const { return data[0] ? 1.0f : 0.0f; }; 250 251 protected: 252 idStr data; 253 }; 254 255 class idWinInt : public idWinVar { 256 public: idWinInt()257 idWinInt() : idWinVar() {}; ~idWinInt()258 ~idWinInt() {}; Init(const char * _name,idWindow * win)259 virtual void Init(const char *_name, idWindow *win) { 260 idWinVar::Init(_name, win); 261 if (guiDict) { 262 data = guiDict->GetInt(GetName()); 263 } 264 } 265 int &operator=( const int &other ) { 266 data = other; 267 if (guiDict) { 268 guiDict->SetInt(GetName(), data); 269 } 270 return data; 271 } 272 idWinInt &operator=( const idWinInt &other ) { 273 idWinVar::operator=(other); 274 data = other.data; 275 return *this; 276 } 277 operator int () const { 278 return data; 279 } Set(const char * val)280 virtual void Set(const char *val) { 281 data = atoi(val);; 282 if (guiDict) { 283 guiDict->SetInt(GetName(), data); 284 } 285 } 286 Update()287 virtual void Update() { 288 const char *s = GetName(); 289 if ( guiDict && s[0] != '\0' ) { 290 data = guiDict->GetInt( s ); 291 } 292 } c_str()293 virtual const char *c_str() const { 294 return va("%i", data); 295 } 296 297 // SaveGames WriteToSaveGame(idFile * savefile)298 virtual void WriteToSaveGame( idFile *savefile ) { 299 savefile->Write( &eval, sizeof( eval ) ); 300 savefile->Write( &data, sizeof( data ) ); 301 } ReadFromSaveGame(idFile * savefile)302 virtual void ReadFromSaveGame( idFile *savefile ) { 303 savefile->Read( &eval, sizeof( eval ) ); 304 savefile->Read( &data, sizeof( data ) ); 305 } 306 307 // no suitable conversion x(void)308 virtual float x( void ) const { assert( false ); return 0.0f; }; 309 310 protected: 311 int data; 312 }; 313 314 class idWinFloat : public idWinVar { 315 public: idWinFloat()316 idWinFloat() : idWinVar() {}; ~idWinFloat()317 ~idWinFloat() {}; Init(const char * _name,idWindow * win)318 virtual void Init(const char *_name, idWindow *win) { 319 idWinVar::Init(_name, win); 320 if (guiDict) { 321 data = guiDict->GetFloat(GetName()); 322 } 323 } 324 idWinFloat &operator=( const idWinFloat &other ) { 325 idWinVar::operator=(other); 326 data = other.data; 327 return *this; 328 } 329 float &operator=( const float &other ) { 330 data = other; 331 if (guiDict) { 332 guiDict->SetFloat(GetName(), data); 333 } 334 return data; 335 } 336 operator float() const { 337 return data; 338 } Set(const char * val)339 virtual void Set(const char *val) { 340 data = atof(val); 341 if (guiDict) { 342 guiDict->SetFloat(GetName(), data); 343 } 344 } Update()345 virtual void Update() { 346 const char *s = GetName(); 347 if ( guiDict && s[0] != '\0' ) { 348 data = guiDict->GetFloat( s ); 349 } 350 } c_str()351 virtual const char *c_str() const { 352 return va("%f", data); 353 } 354 WriteToSaveGame(idFile * savefile)355 virtual void WriteToSaveGame( idFile *savefile ) { 356 savefile->Write( &eval, sizeof( eval ) ); 357 savefile->Write( &data, sizeof( data ) ); 358 } ReadFromSaveGame(idFile * savefile)359 virtual void ReadFromSaveGame( idFile *savefile ) { 360 savefile->Read( &eval, sizeof( eval ) ); 361 savefile->Read( &data, sizeof( data ) ); 362 } 363 x(void)364 virtual float x( void ) const { return data; }; 365 protected: 366 float data; 367 }; 368 369 class idWinRectangle : public idWinVar { 370 public: idWinRectangle()371 idWinRectangle() : idWinVar() {}; ~idWinRectangle()372 ~idWinRectangle() {}; Init(const char * _name,idWindow * win)373 virtual void Init(const char *_name, idWindow *win) { 374 idWinVar::Init(_name, win); 375 if (guiDict) { 376 idVec4 v = guiDict->GetVec4(GetName()); 377 data.x = v.x; 378 data.y = v.y; 379 data.w = v.z; 380 data.h = v.w; 381 } 382 } 383 384 int operator==( const idRectangle &other ) const { 385 return (other == data); 386 } 387 388 idWinRectangle &operator=( const idWinRectangle &other ) { 389 idWinVar::operator=(other); 390 data = other.data; 391 return *this; 392 } 393 idRectangle &operator=( const idVec4 &other ) { 394 data = other; 395 if (guiDict) { 396 guiDict->SetVec4(GetName(), other); 397 } 398 return data; 399 } 400 401 idRectangle &operator=( const idRectangle &other ) { 402 data = other; 403 if (guiDict) { 404 idVec4 v = data.ToVec4(); 405 guiDict->SetVec4(GetName(), v); 406 } 407 return data; 408 } 409 410 operator const idRectangle&() const { 411 return data; 412 } 413 x()414 float x() const { 415 return data.x; 416 } y()417 float y() const { 418 return data.y; 419 } w()420 float w() const { 421 return data.w; 422 } h()423 float h() const { 424 return data.h; 425 } Right()426 float Right() const { 427 return data.Right(); 428 } Bottom()429 float Bottom() const { 430 return data.Bottom(); 431 } ToVec4()432 idVec4 &ToVec4() { 433 static idVec4 ret; 434 ret = data.ToVec4(); 435 return ret; 436 } Set(const char * val)437 virtual void Set(const char *val) { 438 if ( strchr ( val, ',' ) ) { 439 sscanf( val, "%f,%f,%f,%f", &data.x, &data.y, &data.w, &data.h ); 440 } else { 441 sscanf( val, "%f %f %f %f", &data.x, &data.y, &data.w, &data.h ); 442 } 443 if (guiDict) { 444 idVec4 v = data.ToVec4(); 445 guiDict->SetVec4(GetName(), v); 446 } 447 } Update()448 virtual void Update() { 449 const char *s = GetName(); 450 if ( guiDict && s[0] != '\0' ) { 451 idVec4 v = guiDict->GetVec4( s ); 452 data.x = v.x; 453 data.y = v.y; 454 data.w = v.z; 455 data.h = v.w; 456 } 457 } 458 c_str()459 virtual const char *c_str() const { 460 return data.ToVec4().ToString(); 461 } 462 WriteToSaveGame(idFile * savefile)463 virtual void WriteToSaveGame( idFile *savefile ) { 464 savefile->Write( &eval, sizeof( eval ) ); 465 savefile->Write( &data, sizeof( data ) ); 466 } ReadFromSaveGame(idFile * savefile)467 virtual void ReadFromSaveGame( idFile *savefile ) { 468 savefile->Read( &eval, sizeof( eval ) ); 469 savefile->Read( &data, sizeof( data ) ); 470 } 471 472 protected: 473 idRectangle data; 474 }; 475 476 class idWinVec2 : public idWinVar { 477 public: idWinVec2()478 idWinVec2() : idWinVar() {}; ~idWinVec2()479 ~idWinVec2() {}; Init(const char * _name,idWindow * win)480 virtual void Init(const char *_name, idWindow *win) { 481 idWinVar::Init(_name, win); 482 if (guiDict) { 483 data = guiDict->GetVec2(GetName()); 484 } 485 } 486 int operator==( const idVec2 &other ) const { 487 return (other == data); 488 } 489 idWinVec2 &operator=( const idWinVec2 &other ) { 490 idWinVar::operator=(other); 491 data = other.data; 492 return *this; 493 } 494 495 idVec2 &operator=( const idVec2 &other ) { 496 data = other; 497 if (guiDict) { 498 guiDict->SetVec2(GetName(), data); 499 } 500 return data; 501 } x()502 float x() const { 503 return data.x; 504 } y()505 float y() const { 506 return data.y; 507 } Set(const char * val)508 virtual void Set(const char *val) { 509 if ( strchr ( val, ',' ) ) { 510 sscanf( val, "%f,%f", &data.x, &data.y ); 511 } else { 512 sscanf( val, "%f %f", &data.x, &data.y); 513 } 514 if (guiDict) { 515 guiDict->SetVec2(GetName(), data); 516 } 517 } 518 operator const idVec2&() const { 519 return data; 520 } Update()521 virtual void Update() { 522 const char *s = GetName(); 523 if ( guiDict && s[0] != '\0' ) { 524 data = guiDict->GetVec2( s ); 525 } 526 } c_str()527 virtual const char *c_str() const { 528 return data.ToString(); 529 } Zero()530 void Zero() { 531 data.Zero(); 532 } 533 WriteToSaveGame(idFile * savefile)534 virtual void WriteToSaveGame( idFile *savefile ) { 535 savefile->Write( &eval, sizeof( eval ) ); 536 savefile->Write( &data, sizeof( data ) ); 537 } ReadFromSaveGame(idFile * savefile)538 virtual void ReadFromSaveGame( idFile *savefile ) { 539 savefile->Read( &eval, sizeof( eval ) ); 540 savefile->Read( &data, sizeof( data ) ); 541 } 542 543 protected: 544 idVec2 data; 545 }; 546 547 class idWinVec4 : public idWinVar { 548 public: idWinVec4()549 idWinVec4() : idWinVar() {}; ~idWinVec4()550 ~idWinVec4() {}; Init(const char * _name,idWindow * win)551 virtual void Init(const char *_name, idWindow *win) { 552 idWinVar::Init(_name, win); 553 if (guiDict) { 554 data = guiDict->GetVec4(GetName()); 555 } 556 } 557 int operator==( const idVec4 &other ) const { 558 return (other == data); 559 } 560 idWinVec4 &operator=( const idWinVec4 &other ) { 561 idWinVar::operator=(other); 562 data = other.data; 563 return *this; 564 } 565 idVec4 &operator=( const idVec4 &other ) { 566 data = other; 567 if (guiDict) { 568 guiDict->SetVec4(GetName(), data); 569 } 570 return data; 571 } 572 operator const idVec4&() const { 573 return data; 574 } 575 x()576 float x() const { 577 return data.x; 578 } 579 y()580 float y() const { 581 return data.y; 582 } 583 z()584 float z() const { 585 return data.z; 586 } 587 w()588 float w() const { 589 return data.w; 590 } Set(const char * val)591 virtual void Set(const char *val) { 592 if ( strchr ( val, ',' ) ) { 593 sscanf( val, "%f,%f,%f,%f", &data.x, &data.y, &data.z, &data.w ); 594 } else { 595 sscanf( val, "%f %f %f %f", &data.x, &data.y, &data.z, &data.w); 596 } 597 if ( guiDict ) { 598 guiDict->SetVec4( GetName(), data ); 599 } 600 } Update()601 virtual void Update() { 602 const char *s = GetName(); 603 if ( guiDict && s[0] != '\0' ) { 604 data = guiDict->GetVec4( s ); 605 } 606 } c_str()607 virtual const char *c_str() const { 608 return data.ToString(); 609 } 610 Zero()611 void Zero() { 612 data.Zero(); 613 if ( guiDict ) { 614 guiDict->SetVec4(GetName(), data); 615 } 616 } 617 ToVec3()618 const idVec3 &ToVec3() const { 619 return data.ToVec3(); 620 } 621 WriteToSaveGame(idFile * savefile)622 virtual void WriteToSaveGame( idFile *savefile ) { 623 savefile->Write( &eval, sizeof( eval ) ); 624 savefile->Write( &data, sizeof( data ) ); 625 } ReadFromSaveGame(idFile * savefile)626 virtual void ReadFromSaveGame( idFile *savefile ) { 627 savefile->Read( &eval, sizeof( eval ) ); 628 savefile->Read( &data, sizeof( data ) ); 629 } 630 631 protected: 632 idVec4 data; 633 }; 634 635 class idWinVec3 : public idWinVar { 636 public: idWinVec3()637 idWinVec3() : idWinVar() {}; ~idWinVec3()638 ~idWinVec3() {}; Init(const char * _name,idWindow * win)639 virtual void Init(const char *_name, idWindow *win) { 640 idWinVar::Init(_name, win); 641 if (guiDict) { 642 data = guiDict->GetVector(GetName()); 643 } 644 } 645 int operator==( const idVec3 &other ) const { 646 return (other == data); 647 } 648 idWinVec3 &operator=( const idWinVec3 &other ) { 649 idWinVar::operator=(other); 650 data = other.data; 651 return *this; 652 } 653 idVec3 &operator=( const idVec3 &other ) { 654 data = other; 655 if (guiDict) { 656 guiDict->SetVector(GetName(), data); 657 } 658 return data; 659 } 660 operator const idVec3&() const { 661 return data; 662 } 663 x()664 float x() const { 665 return data.x; 666 } 667 y()668 float y() const { 669 return data.y; 670 } 671 z()672 float z() const { 673 return data.z; 674 } 675 Set(const char * val)676 virtual void Set(const char *val) { 677 sscanf( val, "%f %f %f", &data.x, &data.y, &data.z); 678 if (guiDict) { 679 guiDict->SetVector(GetName(), data); 680 } 681 } Update()682 virtual void Update() { 683 const char *s = GetName(); 684 if ( guiDict && s[0] != '\0' ) { 685 data = guiDict->GetVector( s ); 686 } 687 } c_str()688 virtual const char *c_str() const { 689 return data.ToString(); 690 } 691 Zero()692 void Zero() { 693 data.Zero(); 694 if (guiDict) { 695 guiDict->SetVector(GetName(), data); 696 } 697 } 698 WriteToSaveGame(idFile * savefile)699 virtual void WriteToSaveGame( idFile *savefile ) { 700 savefile->Write( &eval, sizeof( eval ) ); 701 savefile->Write( &data, sizeof( data ) ); 702 } ReadFromSaveGame(idFile * savefile)703 virtual void ReadFromSaveGame( idFile *savefile ) { 704 savefile->Read( &eval, sizeof( eval ) ); 705 savefile->Read( &data, sizeof( data ) ); 706 } 707 708 protected: 709 idVec3 data; 710 }; 711 712 class idWinBackground : public idWinStr { 713 public: idWinBackground()714 idWinBackground() : idWinStr() { 715 mat = NULL; 716 }; ~idWinBackground()717 ~idWinBackground() {}; Init(const char * _name,idWindow * win)718 virtual void Init(const char *_name, idWindow *win) { 719 idWinStr::Init(_name, win); 720 if (guiDict) { 721 data = guiDict->GetString(GetName()); 722 } 723 } 724 int operator==( const idStr &other ) const { 725 return (other == data); 726 } 727 int operator==( const char *other ) const { 728 return (data == other); 729 } 730 idStr &operator=( const idStr &other ) { 731 data = other; 732 if (guiDict) { 733 guiDict->Set(GetName(), data); 734 } 735 if (mat) { 736 if ( data == "" ) { 737 (*mat) = NULL; 738 } else { 739 (*mat) = declManager->FindMaterial(data); 740 } 741 } 742 return data; 743 } 744 idWinBackground &operator=( const idWinBackground &other ) { 745 idWinVar::operator=(other); 746 data = other.data; 747 mat = other.mat; 748 if (mat) { 749 if ( data == "" ) { 750 (*mat) = NULL; 751 } else { 752 (*mat) = declManager->FindMaterial(data); 753 } 754 } 755 return *this; 756 } 757 operator const char *() const { 758 return data.c_str(); 759 } 760 operator const idStr &() const { 761 return data; 762 } Length()763 int Length() { 764 if (guiDict) { 765 data = guiDict->GetString(GetName()); 766 } 767 return data.Length(); 768 } c_str()769 virtual const char *c_str() const { 770 return data.c_str(); 771 } 772 Set(const char * val)773 virtual void Set(const char *val) { 774 data = val; 775 if (guiDict) { 776 guiDict->Set(GetName(), data); 777 } 778 if (mat) { 779 if ( data == "" ) { 780 (*mat) = NULL; 781 } else { 782 (*mat) = declManager->FindMaterial(data); 783 } 784 } 785 } 786 Update()787 virtual void Update() { 788 const char *s = GetName(); 789 if ( guiDict && s[0] != '\0' ) { 790 data = guiDict->GetString( s ); 791 if (mat) { 792 if ( data == "" ) { 793 (*mat) = NULL; 794 } else { 795 (*mat) = declManager->FindMaterial(data); 796 } 797 } 798 } 799 } 800 Size()801 virtual size_t Size() { 802 size_t sz = idWinVar::Size(); 803 return sz +data.Allocated(); 804 } 805 SetMaterialPtr(const idMaterial ** m)806 void SetMaterialPtr( const idMaterial **m ) { 807 mat = m; 808 } 809 WriteToSaveGame(idFile * savefile)810 virtual void WriteToSaveGame( idFile *savefile ) { 811 savefile->Write( &eval, sizeof( eval ) ); 812 813 int len = data.Length(); 814 savefile->Write( &len, sizeof( len ) ); 815 if ( len > 0 ) { 816 savefile->Write( data.c_str(), len ); 817 } 818 } ReadFromSaveGame(idFile * savefile)819 virtual void ReadFromSaveGame( idFile *savefile ) { 820 savefile->Read( &eval, sizeof( eval ) ); 821 822 int len; 823 savefile->Read( &len, sizeof( len ) ); 824 if ( len > 0 ) { 825 data.Fill( ' ', len ); 826 savefile->Read( &data[0], len ); 827 } 828 if ( mat ) { 829 if ( len > 0 ) { 830 (*mat) = declManager->FindMaterial( data ); 831 } else { 832 (*mat) = NULL; 833 } 834 } 835 } 836 837 protected: 838 idStr data; 839 const idMaterial **mat; 840 }; 841 842 /* 843 ================ 844 idMultiWinVar 845 multiplexes access to a list if idWinVar* 846 ================ 847 */ 848 class idMultiWinVar : public idList< idWinVar * > { 849 public: 850 void Set( const char *val ); 851 void Update( void ); 852 void SetGuiInfo( idDict *dict ); 853 }; 854 855 #endif /* !__WINVAR_H__ */ 856