Freeciv21
Develop your civilization from humble roots to a global empire
luaconsole.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9  */
10 
11 #include "luaconsole.h"
12 // Qt
13 #include <QFileDialog>
14 #include <QString>
15 // utility
16 #include "shared.h"
17 // common
18 #include "featured_text.h"
19 #include "luaconsole_g.h"
20 // client
21 #include "chatline.h"
22 #include "fc_client.h"
23 #include "script_client.h"
24 
25 QString qlua_filename;
26 
30 void luaconsole_dialog_popup(bool raise)
31 { // lua output is in chat
32 }
33 
37 bool luaconsole_dialog_is_open(void) { return true; }
38 
43 
48 void real_luaconsole_append(const char *astring,
49  const struct text_tag_list *tags)
50 {
51  real_output_window_append(astring, tags);
52 }
53 
58 {
59  QString str;
60 
61  str = QString(_("Lua scripts")) + QStringLiteral(" (*.lua)");
62  qlua_filename = QFileDialog::getOpenFileName(
63  king()->central_wdg, _("Load lua script"), QDir::homePath(), str);
64  if (!qlua_filename.isEmpty()) {
65  script_client_do_file(qlua_filename.toLocal8Bit().constData());
66  }
67 }
68 
73 {
74  if (!qlua_filename.isEmpty()) {
75  script_client_do_file(qlua_filename.toLocal8Bit().constData());
76  }
77 }
void real_output_window_append(const QString &astring, const text_tag_list *tags)
Appends the string to the chat output window.
Definition: chatline.cpp:881
class fc_client * king()
Return fc_client instance.
Definition: gui_main.cpp:58
#define _(String)
Definition: fcintl.h:50
QString qlua_filename
Definition: luaconsole.cpp:25
bool luaconsole_dialog_is_open(void)
Return true if the lua console is open.
Definition: luaconsole.cpp:37
void qload_lua_script()
Load and execute lua script.
Definition: luaconsole.cpp:57
void real_luaconsole_append(const char *astring, const struct text_tag_list *tags)
Appends the string to the chat output window.
Definition: luaconsole.cpp:48
void real_luaconsole_dialog_update(void)
Update the lua console.
Definition: luaconsole.cpp:42
void luaconsole_dialog_popup(bool raise)
Popup the lua console inside the main-window, and optionally raise it.
Definition: luaconsole.cpp:30
void qreload_lua_script()
Reload last lua script.
Definition: luaconsole.cpp:72
bool script_client_do_file(const char *filename)
Parse and execute the script at filename.