1 /**********************************************************************
2  *
3  *   FreeDoko a Doppelkopf-Game
4  *
5  *   Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders
6  *
7  *   This program is free software; you can redistribute it and/or
8  *   modify it under the terms of the GNU General Public License as
9  *   published by the Free Software Foundation; either version 2 of
10  *   the License, or (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *   You can find this license in the file 'gpl.txt'.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  *   MA  02111-1307  USA
22  *
23  *  Contact:
24  *    Diether Knof dknof@posteo.de
25  *
26  **********************************************************************/
27 
28 #include "constants.h"
29 
30 #ifdef USE_UI_TEXT
31 
32 #include "general.h"
33 
34 #include "../../basetypes.h"
35 #include "../../misc/translations.h"
36 #include "../../utils/string.h"
37 
38 namespace UI_TEXT_NS {
39 
40   /**
41    **
42    ** constructor
43    **
44    ** @param    ui	pointer to the ui
45    **
46    **
47    **
48    **
49    **/
General(UI_Text * const ui)50     UI_Text::General::General(UI_Text* const ui) :
51       ui(ui)
52     { }
53 
54   /**
55    **
56    ** destructor
57    **
58    **
59    **
60    **
61    **
62    **/
~General()63     UI_Text::General::~General()
64     { }
65 
66   /**
67    **
68    ** interprets the line read by the ui
69    **
70    **
71    ** @return   whether the line was interpreted
72    **
73    **
74    **
75    ** @todo	mostly all
76    **
77    **/
78     bool
interpret_line()79       UI_Text::General::interpret_line()
80       {
81 	// whether the line has been interpreted
82 	bool interpreted = false;
83 
84 	if ((this->ui->line.size() > 0)
85 	    && (this->ui->line[0] == '!')) {
86 	  // system call
87 	  (void)::system(string(this->ui->line, 1).c_str());
88 	  interpreted = true;
89 	} else if (this->ui->iskeyword("quit")) {
90 	  ::game_status = GameStatus::quit;
91 	  interpreted = true;
92 #ifndef RELEASE
93 	} else if (String::word_first(this->ui->line)
94 		   == "trans") {
95 	  string text = this->ui->line;
96 	  String::word_first_remove_with_blanks(text);
97 	  COUT << ::translator.name() << ": " << ::translation(text) << endl;
98 	  interpreted = true;
99 #endif
100 	} // if (line == ...)
101 
102 	return interpreted;
103       } // bool UI_Text::General::interpret_line()
104 
105 } // namespace UI_TEXT_NS
106 
107 #endif // #ifdef USE_UI_TEXT
108