Project

General

Profile

Feature #326 » 0017-Ruledit-Add-initial-version-of-helpeditor.patch

S3_1 - Marko Lindqvist, 03/21/2024 08:09 PM

View differences:

meson.build
'tools/ruledit/edit_terrain.h',
'tools/ruledit/edit_utype.h',
'tools/ruledit/effect_edit.h',
'tools/ruledit/helpeditor.h',
'tools/ruledit/req_edit.h',
'tools/ruledit/req_vec_fix.h',
'tools/ruledit/requirers_dlg.h',
......
'tools/ruledit/edit_terrain.cpp',
'tools/ruledit/edit_utype.cpp',
'tools/ruledit/effect_edit.cpp',
'tools/ruledit/helpeditor.cpp',
'tools/ruledit/req_edit.cpp',
'tools/ruledit/requirers_dlg.cpp',
'tools/ruledit/req_vec_fix.cpp',
tools/ruledit/Makefile.am
MOC_FILES = \
meta_conversion_log.cpp \
meta_edit_extra.cpp \
meta_edit_extra.cpp \
meta_edit_impr.cpp \
meta_edit_terrain.cpp \
meta_edit_terrain.cpp \
meta_edit_utype.cpp \
meta_effect_edit.cpp \
meta_effect_edit.cpp \
meta_helpeditor.cpp \
meta_req_edit.cpp \
meta_req_vec_fix.cpp \
meta_requirers_dlg.cpp \
......
edit_utype.h \
effect_edit.cpp \
effect_edit.h \
helpeditor.cpp \
tab_achievement.cpp \
tab_achievement.h \
tab_building.cpp \
tools/ruledit/edit_impr.cpp
#include <QGridLayout>
#include <QLineEdit>
#include <QMenu>
#include <QPushButton>
#include <QSpinBox>
#include <QToolButton>
......
#include "improvement.h"
// ruledit
#include "helpeditor.h"
#include "ruledit.h"
#include "ruledit_qt.h"
#include "tab_tech.h"
......
QHBoxLayout *main_layout = new QHBoxLayout(this);
QGridLayout *impr_layout = new QGridLayout();
QLabel *label;
QPushButton *button;
QMenu *menu;
int row;
......
impr_layout->addWidget(label, row, 0);
impr_layout->addWidget(sound_tag_alt, row++, 1);
button = new QPushButton(QString::fromUtf8(R__("Helptext")), this);
connect(button, SIGNAL(pressed()), this, SLOT(helptext()));
impr_layout->addWidget(button, row++, 1);
for (int i = 0; i < IF_COUNT; i++) {
enum impr_flag_id flag = (enum impr_flag_id)i;
QCheckBox *check = new QCheckBox();
......
sz_strlcpy(impr->soundtag_alt, tag_bytes);
}
/**********************************************************************//**
User pressed helptext button
**************************************************************************/
void edit_impr::helptext()
{
helpeditor *editor = new helpeditor(impr->helptext);
editor->show();
}
tools/ruledit/edit_impr.h
void gfx_tag_alt_given();
void sound_tag_given();
void sound_tag_alt_given();
void helptext();
};
tools/ruledit/helpeditor.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 <QPushButton>
// utility
#include "fcintl.h"
#include "string_vector.h"
#include "helpeditor.h"
/**********************************************************************//**
Setup helpeditor object
**************************************************************************/
helpeditor::helpeditor(struct strvec *helptext_in) : QDialog()
{
QGridLayout *main_layout = new QGridLayout(this);
QPushButton *close_button;
int row = 0;
helptext = helptext_in;
area = new QTextEdit();
area->setParent(this);
area->setReadOnly(true);
main_layout->addWidget(area, row++, 0);
strvec_iterate(helptext, text) {
area->append(QString::fromUtf8(text));
area->append("\n\n");
} strvec_iterate_end;
close_button = new QPushButton(QString::fromUtf8(R__("Close")), this);
connect(close_button, SIGNAL(pressed()), this, SLOT(close_now()));
main_layout->addWidget(close_button, row++, 0);
setLayout(main_layout);
}
/**********************************************************************//**
User pushed close button
**************************************************************************/
void helpeditor::close_now()
{
done(0);
}
tools/ruledit/helpeditor.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__HELPEDITOR_H
#define FC__HELPEDITOR_H
#ifdef HAVE_CONFIG_H
#include <fc_config.h>
#endif
// Qt
#include <QDialog>
#include <QTextEdit>
class ruledit_gui;
class helpeditor : public QDialog
{
Q_OBJECT
public:
explicit helpeditor(struct strvec *helptext_in);
private:
struct strvec *helptext;
QTextEdit *area;
private slots:
void close_now();
};
#endif // FC__HELPEDITOR_H
(2-2/2)