1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
18 #include "fc_prehdrs.h"
23 #ifdef FREECIV_MSWINDOWS
28 #include "fc_cmdline.h"
35 #include "fc_cmdhelp.h"
36 #include "fc_interface.h"
44 #include "tools_fc_interface.h"
48 #include "ruledit_qt.h"
52 static int re_parse_cmdline(int argc
, char *argv
[]);
54 struct ruledit_arguments reargs
;
56 /**************************************************************************
57 Main entry point for freeciv-ruledit
58 **************************************************************************/
59 int main(int argc
, char **argv
)
61 enum log_level loglevel
= LOG_NORMAL
;
64 /* Load win32 post-crash debugger */
65 #ifdef FREECIV_MSWINDOWS
66 # ifndef FREECIV_NDEBUG
67 if (LoadLibrary("exchndl.dll") == NULL
) {
69 fprintf(stderr
, "exchndl.dll could not be loaded, no crash debugger\n");
70 # endif /* FREECIV_DEBUG */
72 # endif /* FREECIV_NDEBUG */
73 #endif /* FREECIV_MSWINDOWS */
78 (void) bindtextdomain("freeciv-ruledit", get_locale_dir());
81 init_character_encodings(FC_DEFAULT_DATA_ENCODING
, FALSE
);
83 bind_textdomain_codeset("freeciv-ruledit", get_internal_encoding());
86 registry_module_init();
88 log_init(NULL
, loglevel
, NULL
, NULL
, -1);
90 /* Initialize command line arguments. */
91 reargs
.ruleset
= NULL
;
93 ui_options
= re_parse_cmdline(argc
, argv
);
95 if (ui_options
!= -1) {
100 /* Reset aifill to zero */
101 game
.info
.aifill
= 0;
106 /* Initialize the fc_interface functions needed to understand rules. */
107 fc_interface_init_tool();
109 if (comments_load()) {
110 ruledit_qt_run(ui_options
, argv
);
114 log_error(R__("Failed to load comments.txt"));
118 registry_module_close();
123 /* Clean up command line arguments. */
124 cmdline_option_values_free();
129 /**************************************************************************
130 Parse freeciv-ruledit commandline.
131 **************************************************************************/
132 static int re_parse_cmdline(int argc
, char *argv
[])
135 bool ui_separator
= FALSE
;
142 argv
[1 + ui_options
] = argv
[i
];
144 } else if (is_option("--help", argv
[i
])) {
145 struct cmdhelp
*help
= cmdhelp_new(argv
[0]);
147 cmdhelp_add(help
, "h", "help",
148 R__("Print a summary of the options"));
149 cmdhelp_add(help
, "v", "version",
150 R__("Print the version number"));
151 cmdhelp_add(help
, "r",
152 /* TRANS: argument (don't translate) VALUE (translate) */
153 R__("ruleset RULESET"),
154 R__("Ruleset to use as the starting point."));
155 /* The function below prints a header and footer for the options.
156 * Furthermore, the options are sorted. */
157 cmdhelp_display(help
, TRUE
, TRUE
, TRUE
);
158 cmdhelp_destroy(help
);
161 } else if (is_option("--version", argv
[i
])) {
162 fc_fprintf(stderr
, "%s \n", freeciv_name_version());
165 } else if ((option
= get_option_malloc("--ruleset", argv
, &i
, argc
, true))) {
166 if (reargs
.ruleset
) {
167 fc_fprintf(stderr
, R__("Can only edit one ruleset at a time.\n"));
169 reargs
.ruleset
= option
;
171 } else if (is_option("--", argv
[i
])) {
174 fc_fprintf(stderr
, R__("Unrecognized option: \"%s\"\n"), argv
[i
]);
184 /**************************************************************************
185 Show widget if experimental features enabled, hide otherwise
186 **************************************************************************/
187 void show_experimental(QWidget
*wdg
)
189 #ifdef RULEDIT_EXPERIMENTAL