From 25cf6faf4440a2600ee9a8c113d170687ddfb917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Mon, 16 May 2022 15:32:56 +0200 Subject: [PATCH 2/2] - Implement basic counters functionality to ruledit diff --git a/tools/ruledit/Makefile.am b/tools/ruledit/Makefile.am index a85f8c116e..bd6601ca2c 100644 --- a/tools/ruledit/Makefile.am +++ b/tools/ruledit/Makefile.am @@ -38,6 +38,7 @@ MOC_FILES = \ meta_requirers_dlg.cpp \ meta_ruledit_qt.cpp \ meta_tab_building.cpp \ + meta_tab_counters.cpp \ meta_tab_enablers.cpp \ meta_tab_extras.cpp \ meta_tab_good.cpp \ @@ -60,6 +61,8 @@ freeciv_ruledit_SOURCES = \ effect_edit.h \ tab_building.cpp \ tab_building.h \ + tab_counters.cpp \ + tab_counters.h \ tab_enablers.cpp \ tab_enablers.h \ tab_extras.cpp \ diff --git a/tools/ruledit/ruledit_qt.cpp b/tools/ruledit/ruledit_qt.cpp index e9780a4d3f..8c6439aa26 100644 --- a/tools/ruledit/ruledit_qt.cpp +++ b/tools/ruledit/ruledit_qt.cpp @@ -46,6 +46,7 @@ #include "req_vec_fix.h" #include "ruledit.h" #include "tab_building.h" +#include "tab_counters.h" #include "tab_enablers.h" #include "tab_extras.h" #include "tab_good.h" @@ -187,6 +188,8 @@ void ruledit_gui::setup(QWidget *central_in) stack->addTab(multipliers, QString::fromUtf8(R__("Multipliers"))); nation = new tab_nation(this); stack->addTab(nation, QString::fromUtf8(R__("Nations"))); + counter = new tab_counter(this); + stack->addTab(counter, QString::fromUtf8(R__("Counters"))); edit_layout->addWidget(stack); @@ -250,6 +253,7 @@ void ruledit_gui::launch_now() extras->refresh(); multipliers->refresh(); terrains->refresh(); + counter->refresh(); main_layout->setCurrentIndex(1); } else { display_msg(R__("Ruleset loading failed!")); diff --git a/tools/ruledit/ruledit_qt.h b/tools/ruledit/ruledit_qt.h index 38ec8e1c0c..643ff9b4ee 100644 --- a/tools/ruledit/ruledit_qt.h +++ b/tools/ruledit/ruledit_qt.h @@ -30,6 +30,7 @@ class QStackedLayout; class requirers_dlg; class tab_building; +class tab_counter; class tab_good; class tab_gov; class tab_misc; @@ -130,6 +131,7 @@ signals: QStackedLayout *main_layout; tab_building *bldg; + tab_counter *counter; tab_misc *misc; tab_tech *tech; tab_unit *unit; diff --git a/tools/ruledit/tab_counters.h b/tools/ruledit/tab_counters.h new file mode 100644 index 0000000000..6e96ed3d06 --- /dev/null +++ b/tools/ruledit/tab_counters.h @@ -0,0 +1,70 @@ +/*********************************************************************** + Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ + +#ifndef FC__TAB_COUNTER_H +#define FC__TAB_COUNTER_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +// Qt +#include + +// common +#include "counters.h" + +class QCheckBox; +class QGridLayout; +class QLabel; +class QLineEdit; +class QListWidget; +class QMenu; +class QToolButton; + +class ruledit_gui; + +class tab_counter : public QWidget +{ + Q_OBJECT + + public: + explicit tab_counter(ruledit_gui *ui_in); + void refresh(); + static void techs_to_menu(QMenu *fill_menu); + static QString counter_name(struct counter *padv); + + private: + ruledit_gui *ui; + + QLineEdit *name; + QLineEdit *rname; + + QListWidget *counter_list; + + struct counter *selected; + + private slots: + void update_counter_info(struct counter *counter); + void name_given(); + void select_counter(); + void add_now(); + void delete_now(); + void same_name_toggle(bool checked); + void edit_effects(); + bool initialize_new_counter(struct counter *padv); + //QMenu *prepare_counter_button(QToolButton *button, enum tech_req rn); +}; + + +#endif // FC__TAB_TECH_H -- 2.36.1