Author: sveinung
Date: Fri Nov 13 06:38:08 2015
New Revision: 30591

URL: http://svn.gna.org/viewcvs/freeciv?rev=30591&view=rev
Log:
ruledit: take ruleset as an argument

See patch #6586

Modified:
    branches/S2_6/tools/ruledit/ruledit.cpp
    branches/S2_6/tools/ruledit/ruledit.h
    branches/S2_6/tools/ruledit/ruledit_qt.cpp

Modified: branches/S2_6/tools/ruledit/ruledit.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/ruledit.cpp?rev=30591&r1=30590&r2=30591&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/ruledit.cpp     (original)
+++ branches/S2_6/tools/ruledit/ruledit.cpp     Fri Nov 13 06:38:08 2015
@@ -40,6 +40,8 @@
 
 static int re_parse_cmdline(int argc, char *argv[]);
 
+struct ruledit_arguments reargs;
+
 /**************************************************************************
   Main entry point for freeciv-ruledit
 **************************************************************************/
@@ -74,6 +76,9 @@
 
   log_init(NULL, loglevel, NULL, NULL, -1);
 
+  /* Initialize command line arguments. */
+  reargs.ruleset = NULL;
+
   ui_options = re_parse_cmdline(argc, argv);
 
   if (ui_options != -1) {
@@ -97,6 +102,11 @@
   free_libfreeciv();
   free_nls();
 
+  /* Clean up command line arguments. */
+  if (reargs.ruleset) {
+    FC_FREE(reargs.ruleset);
+  }
+
   return EXIT_SUCCESS;
 }
 
@@ -110,6 +120,8 @@
   int ui_options = 0;
 
   while (i < argc) {
+    char *option;
+
     if (ui_separator) {
       argv[1 + ui_options] = argv[i];
       ui_options++;
@@ -120,6 +132,10 @@
                   R__("Print a summary of the options"));
       cmdhelp_add(help, "v", "version",
                   R__("Print the version number"));
+      cmdhelp_add(help, "r",
+                  /* TRANS: argument (don't translate) VALUE (translate) */
+                  R__("ruleset RULESET"),
+                  R__("Ruleset to use as the starting point."));
       /* The function below prints a header and footer for the options.
        * Furthermore, the options are sorted. */
       cmdhelp_display(help, TRUE, TRUE, TRUE);
@@ -130,6 +146,12 @@
       fc_fprintf(stderr, "%s \n", freeciv_name_version());
 
       exit(EXIT_SUCCESS);
+    } else if ((option = get_option_malloc("--ruleset", argv, &i, argc))) {
+      if (reargs.ruleset) {
+        log_error(_("Can only edit one ruleset at a time."));
+      } else {
+        reargs.ruleset = option;
+      }
     } else if (is_option("--", argv[i])) {
       ui_separator = TRUE;
     } else {

Modified: branches/S2_6/tools/ruledit/ruledit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/ruledit.h?rev=30591&r1=30590&r2=30591&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/ruledit.h       (original)
+++ branches/S2_6/tools/ruledit/ruledit.h       Fri Nov 13 06:38:08 2015
@@ -15,4 +15,11 @@
 
 void show_experimental(QWidget *wdg);
 
+struct ruledit_arguments {
+  /* Ruleset name. Is NULL if not specified. */
+  char *ruleset;
+};
+
+extern struct ruledit_arguments reargs;
+
 #endif /* FC__RULEDIT_H */

Modified: branches/S2_6/tools/ruledit/ruledit_qt.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/ruledit_qt.cpp?rev=30591&r1=30590&r2=30591&view=diff
==============================================================================
--- branches/S2_6/tools/ruledit/ruledit_qt.cpp  (original)
+++ branches/S2_6/tools/ruledit/ruledit_qt.cpp  Fri Nov 13 06:38:08 2015
@@ -145,7 +145,11 @@
   rs_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
   preload_layout->addWidget(rs_label);
   ruleset_select = new QLineEdit(central);
-  ruleset_select->setText(GAME_DEFAULT_RULESETDIR);
+  if (reargs.ruleset) {
+    ruleset_select->setText(reargs.ruleset);
+  } else {
+    ruleset_select->setText(GAME_DEFAULT_RULESETDIR);
+  }
   connect(ruleset_select, SIGNAL(returnPressed()),
           this, SLOT(launch_now()));
   preload_layout->addWidget(ruleset_select);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to