Feature #618 » 0037-Ruledit-Add-edit_gov-dialog.patch
| common/government.c | ||
|---|---|---|
|
requirement_vector_init(&pgovern->reqs);
|
||
|
pgovern->changed_to_times = 0;
|
||
|
pgovern->ruledit_disabled = FALSE;
|
||
|
pgovern->ruledit_dlg = NULL;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| common/government.h | ||
|---|---|---|
|
Government_type_id item_number;
|
||
|
struct name_translation name;
|
||
|
bool ruledit_disabled;
|
||
|
void *ruledit_dlg;
|
||
|
char graphic_str[MAX_LEN_NAME];
|
||
|
char graphic_alt[MAX_LEN_NAME];
|
||
|
struct requirement_vector reqs;
|
||
| meson.build | ||
|---|---|---|
|
moc_headers: [
|
||
|
'tools/ruledit/conversion_log.h',
|
||
|
'tools/ruledit/edit_extra.h',
|
||
|
'tools/ruledit/edit_gov.h',
|
||
|
'tools/ruledit/edit_impr.h',
|
||
|
'tools/ruledit/edit_tech.h',
|
||
|
'tools/ruledit/edit_terrain.h',
|
||
| ... | ... | |
|
executable('freeciv-ruledit',
|
||
|
'tools/ruledit/conversion_log.cpp',
|
||
|
'tools/ruledit/edit_extra.cpp',
|
||
|
'tools/ruledit/edit_gov.cpp',
|
||
|
'tools/ruledit/edit_impr.cpp',
|
||
|
'tools/ruledit/edit_tech.cpp',
|
||
|
'tools/ruledit/edit_terrain.cpp',
|
||
| tools/ruledit/Makefile.am | ||
|---|---|---|
|
MOC_FILES = \
|
||
|
meta_conversion_log.cpp \
|
||
|
meta_edit_extra.cpp \
|
||
|
meta_edit_gov.cpp \
|
||
|
meta_edit_impr.cpp \
|
||
|
meta_edit_tech.cpp \
|
||
|
meta_edit_terrain.cpp \
|
||
| ... | ... | |
|
conversion_log.h \
|
||
|
edit_extra.cpp \
|
||
|
edit_extra.h \
|
||
|
edit_gov.cpp \
|
||
|
edit_gov.h \
|
||
|
edit_impr.cpp \
|
||
|
edit_impr.h \
|
||
|
edit_tech.cpp \
|
||
| tools/ruledit/edit_gov.cpp | ||
|---|---|---|
|
/***********************************************************************
|
||
|
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.
|
||
|
***********************************************************************/
|
||
|
#ifdef HAVE_CONFIG_H
|
||
|
#include <fc_config.h>
|
||
|
#endif
|
||
|
// Qt
|
||
|
#include <QGridLayout>
|
||
|
#include <QLineEdit>
|
||
|
#include <QPushButton>
|
||
|
// common
|
||
|
#include "government.h"
|
||
|
// ruledit
|
||
|
#include "helpeditor.h"
|
||
|
#include "ruledit.h"
|
||
|
#include "ruledit_qt.h"
|
||
|
#include "edit_gov.h"
|
||
|
/**********************************************************************//**
|
||
|
Setup edit_gov object
|
||
|
**************************************************************************/
|
||
|
edit_gov::edit_gov(ruledit_gui *ui_in, struct government *gov_in) : values_dlg()
|
||
|
{
|
||
|
QHBoxLayout *main_layout = new QHBoxLayout(this);
|
||
|
QGridLayout *gov_layout = new QGridLayout();
|
||
|
QLabel *label;
|
||
|
QPushButton *button;
|
||
|
int row;
|
||
|
ui = ui_in;
|
||
|
gov = gov_in;
|
||
|
setWindowTitle(QString::fromUtf8(government_rule_name(gov)));
|
||
|
row = 0;
|
||
|
label = new QLabel(QString::fromUtf8(R__("Graphics tag")));
|
||
|
label->setParent(this);
|
||
|
gfx_tag = new QLineEdit(this);
|
||
|
connect(gfx_tag, SIGNAL(returnPressed()), this, SLOT(gfx_tag_given()));
|
||
|
gov_layout->addWidget(label, row, 0);
|
||
|
gov_layout->addWidget(gfx_tag, row++, 1);
|
||
|
label = new QLabel(QString::fromUtf8(R__("Alt graphics tag")));
|
||
|
label->setParent(this);
|
||
|
gfx_tag_alt = new QLineEdit(this);
|
||
|
connect(gfx_tag_alt, SIGNAL(returnPressed()), this, SLOT(gfx_tag_alt_given()));
|
||
|
gov_layout->addWidget(label, row, 0);
|
||
|
gov_layout->addWidget(gfx_tag_alt, row++, 1);
|
||
|
button = new QPushButton(QString::fromUtf8(R__("Helptext")), this);
|
||
|
connect(button, SIGNAL(pressed()), this, SLOT(helptext()));
|
||
|
gov_layout->addWidget(button, row++, 1);
|
||
|
refresh();
|
||
|
main_layout->addLayout(gov_layout);
|
||
|
setLayout(main_layout);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
User is closing dialog.
|
||
|
**************************************************************************/
|
||
|
void edit_gov::closeEvent(QCloseEvent *cevent)
|
||
|
{
|
||
|
close_help();
|
||
|
// Save values from text fields.
|
||
|
gfx_tag_given();
|
||
|
gfx_tag_alt_given();
|
||
|
gov->ruledit_dlg = nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Refresh the information.
|
||
|
**************************************************************************/
|
||
|
void edit_gov::refresh()
|
||
|
{
|
||
|
gfx_tag->setText(gov->graphic_str);
|
||
|
gfx_tag_alt->setText(gov->graphic_alt);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
User entered new graphics tag.
|
||
|
**************************************************************************/
|
||
|
void edit_gov::gfx_tag_given()
|
||
|
{
|
||
|
QByteArray tag_bytes = gfx_tag->text().toUtf8();
|
||
|
sz_strlcpy(gov->graphic_str, tag_bytes);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
User entered new alternative graphics tag.
|
||
|
**************************************************************************/
|
||
|
void edit_gov::gfx_tag_alt_given()
|
||
|
{
|
||
|
QByteArray tag_bytes = gfx_tag_alt->text().toUtf8();
|
||
|
sz_strlcpy(gov->graphic_alt, tag_bytes);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
User pressed helptext button
|
||
|
**************************************************************************/
|
||
|
void edit_gov::helptext()
|
||
|
{
|
||
|
open_help(&gov->helptext);
|
||
|
}
|
||
| tools/ruledit/edit_gov.h | ||
|---|---|---|
|
/***********************************************************************
|
||
|
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__EDIT_GOV_H
|
||
|
#define FC__EDIT_GOV_H
|
||
|
#ifdef HAVE_CONFIG_H
|
||
|
#include <fc_config.h>
|
||
|
#endif
|
||
|
// Qt
|
||
|
#include <QDialog>
|
||
|
// ruledit
|
||
|
#include "values_dlg.h"
|
||
|
class QGridLayout;
|
||
|
class QLineEdit;
|
||
|
class ruledit_gui;
|
||
|
class edit_gov : public values_dlg
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
explicit edit_gov(ruledit_gui *ui_in, struct government *gov_in);
|
||
|
void refresh();
|
||
|
private:
|
||
|
ruledit_gui *ui;
|
||
|
struct government *gov;
|
||
|
QLineEdit *gfx_tag;
|
||
|
QLineEdit *gfx_tag_alt;
|
||
|
protected:
|
||
|
void closeEvent(QCloseEvent *cevent);
|
||
|
private slots:
|
||
|
void gfx_tag_given();
|
||
|
void gfx_tag_alt_given();
|
||
|
void helptext();
|
||
|
};
|
||
|
#endif // FC__EDIT_GOV_H
|
||
| tools/ruledit/tab_gov.cpp | ||
|---|---|---|
|
#include "government.h"
|
||
|
// ruledit
|
||
|
#include "edit_gov.h"
|
||
|
#include "ruledit.h"
|
||
|
#include "ruledit_qt.h"
|
||
|
#include "validity.h"
|
||
| ... | ... | |
|
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||
|
QGridLayout *gov_layout = new QGridLayout();
|
||
|
QLabel *label;
|
||
|
QPushButton *effects_button;
|
||
|
QPushButton *add_button;
|
||
|
QPushButton *delete_button;
|
||
|
QPushButton *reqs_button;
|
||
|
QPushButton *button;
|
||
|
int row = 0;
|
||
|
ui = ui_in;
|
||
|
selected = 0;
|
||
| ... | ... | |
|
rname = new QLineEdit(this);
|
||
|
rname->setText(R__("None"));
|
||
|
connect(rname, SIGNAL(returnPressed()), this, SLOT(name_given()));
|
||
|
gov_layout->addWidget(label, 0, 0);
|
||
|
gov_layout->addWidget(rname, 0, 2);
|
||
|
gov_layout->addWidget(label, row, 0);
|
||
|
gov_layout->addWidget(rname, row++, 2);
|
||
|
label = new QLabel(QString::fromUtf8(R__("Name")));
|
||
|
label->setParent(this);
|
||
| ... | ... | |
|
name = new QLineEdit(this);
|
||
|
name->setText(R__("None"));
|
||
|
connect(name, SIGNAL(returnPressed()), this, SLOT(name_given()));
|
||
|
gov_layout->addWidget(label, 1, 0);
|
||
|
gov_layout->addWidget(same_name, 1, 1);
|
||
|
gov_layout->addWidget(name, 1, 2);
|
||
|
gov_layout->addWidget(label, row, 0);
|
||
|
gov_layout->addWidget(same_name, row, 1);
|
||
|
gov_layout->addWidget(name, row++, 2);
|
||
|
reqs_button = new QPushButton(QString::fromUtf8(R__("Requirements")), this);
|
||
|
connect(reqs_button, SIGNAL(pressed()), this, SLOT(edit_reqs()));
|
||
|
gov_layout->addWidget(reqs_button, 2, 2);
|
||
|
button = new QPushButton(QString::fromUtf8(R__("Edit Values")), this);
|
||
|
connect(button, SIGNAL(pressed()), this, SLOT(edit_now()));
|
||
|
gov_layout->addWidget(button, row++, 2);
|
||
|
effects_button = new QPushButton(QString::fromUtf8(R__("Effects")), this);
|
||
|
connect(effects_button, SIGNAL(pressed()), this, SLOT(edit_effects()));
|
||
|
gov_layout->addWidget(effects_button, 3, 2);
|
||
|
button = new QPushButton(QString::fromUtf8(R__("Requirements")), this);
|
||
|
connect(button, SIGNAL(pressed()), this, SLOT(edit_reqs()));
|
||
|
gov_layout->addWidget(button, row++, 2);
|
||
|
add_button = new QPushButton(QString::fromUtf8(R__("Add Government")), this);
|
||
|
connect(add_button, SIGNAL(pressed()), this, SLOT(add_now()));
|
||
|
gov_layout->addWidget(add_button, 4, 0);
|
||
|
show_experimental(add_button);
|
||
|
button = new QPushButton(QString::fromUtf8(R__("Effects")), this);
|
||
|
connect(button, SIGNAL(pressed()), this, SLOT(edit_effects()));
|
||
|
gov_layout->addWidget(button, row++, 2);
|
||
|
delete_button = new QPushButton(QString::fromUtf8(R__("Remove this Government")), this);
|
||
|
connect(delete_button, SIGNAL(pressed()), this, SLOT(delete_now()));
|
||
|
gov_layout->addWidget(delete_button, 4, 2);
|
||
|
show_experimental(delete_button);
|
||
|
button = new QPushButton(QString::fromUtf8(R__("Add Government")), this);
|
||
|
connect(button, SIGNAL(pressed()), this, SLOT(add_now()));
|
||
|
gov_layout->addWidget(button, row, 0);
|
||
|
show_experimental(button);
|
||
|
button = new QPushButton(QString::fromUtf8(R__("Remove this Government")), this);
|
||
|
connect(button, SIGNAL(pressed()), this, SLOT(delete_now()));
|
||
|
gov_layout->addWidget(button, row++, 2);
|
||
|
show_experimental(button);
|
||
|
refresh();
|
||
|
update_gov_info(nullptr);
|
||
| ... | ... | |
|
selected->ruledit_disabled = true;
|
||
|
if (selected->ruledit_dlg != nullptr) {
|
||
|
((edit_gov *)selected->ruledit_dlg)->done(0);
|
||
|
}
|
||
|
refresh();
|
||
|
update_gov_info(nullptr);
|
||
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
User requested government edit dialog
|
||
|
**************************************************************************/
|
||
|
void tab_gov::edit_now()
|
||
|
{
|
||
|
if (selected != nullptr) {
|
||
|
if (selected->ruledit_dlg == nullptr) {
|
||
|
edit_gov *edit = new edit_gov(ui, selected);
|
||
|
edit->show();
|
||
|
selected->ruledit_dlg = edit;
|
||
|
} else {
|
||
|
((edit_gov *)selected->ruledit_dlg)->raise();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Initialize new government for use.
|
||
|
**************************************************************************/
|
||
| tools/ruledit/tab_gov.h | ||
|---|---|---|
|
void select_gov();
|
||
|
void add_now();
|
||
|
void delete_now();
|
||
|
void edit_now();
|
||
|
void same_name_toggle(bool checked);
|
||
|
void edit_reqs();
|
||
|
void edit_effects();
|
||
- « Previous
- 1
- 2
- Next »