DELTA
SVN   ±#±#€±#/***********************************************************************
 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 <QLabel>
#include <QLineEdit>
#include <QMenu>
#include <QPushButton>

// utility
#include "fcintl.h"

// common
#include "effects.h"

// ruledit
#include "ruledit.h"
#include "validity.h"

#include "effect_edit.h"

/**************************************************************************
  Setup effect_edit object
**************************************************************************/
effect_edit::effect_edit(ruledit_gui *ui_in, QString target,
                         struct universal *filter_in) : QDialog()
{
  QVBoxLayout *main_layout = new QVBoxLayout(this);
  QGridLayout *effect_edit_layout = new QGridLayout();
  QHBoxLayout *active_layout = new QHBoxLayout();
  QPushButton *close_button;
  QMenu *menu;
  QLabel *lbl;
  enum effect_type eff;

  ui = ui_in;
  selected = nullptr;
  filter = *filter_in;

  list_widget = new QListWidget(this);
  effects = effect_list_new();

  connect(list_widget, SIGNAL(itemSelectionChanged()), this, SLOT(select_effect()));
  main_layout->addWidget(list_widget);

  lbl = new QLabel(R__("Type:"));
  active_layout->addWidget(lbl, 0, 0);
  edit_type_button = new QToolButton();
  menu = new QMenu();
  edit_type_button->setToolButtonStyle(Qt::ToolButtonTextOnly);
  edit_type_button->setPopupMode(QToolButton::MenuButtonPopup);
  connect(menu, SIGNAL(triggered(QAction *)), this, SLOT(effect_type_menu(QAction *)));
  edit_type_button->setMenu(menu);
  for (eff = (enum effect_type)0; eff < EFT_COUNT;
       eff = (enum effect_type)(eff + 1)) {
    menu->addAction(effect_type_name(eff));
  }
  active_layout->addWidget(edit_type_button, 1, 0);

  main_layout->addLayout(active_layout);

  close_button = new QPushButton(QString::fromUtf8(R__("Close")), this);
  connect(close_button, SIGNAL(pressed()), this, SLOT(close_now()));
  effect_edit_layout->addWidget(close_button, 0, 0);

  refresh();

  main_layout->addLayout(effect_edit_layout);

  setLayout(main_layout);
  setWindowTitle(target);
}

/**************************************************************************
  Effect edit destructor
**************************************************************************/
effect_edit::~effect_edit()
{
  effect_list_destroy(effects);
}

/**************************************************************************
  Callback to fill effects list from iterate_effect_cache()
**************************************************************************/
static bool effect_list_fill_cb(struct effect *peffect, void *data)
{
  struct effect_list_fill_data *cbdata = (struct effect_list_fill_data *)data;

  if (cbdata->filter == nullptr) {
    // Look for empty req lists.
    if (requirement_vector_size(&peffect->reqs) == 0) {
      cbdata->edit->add_effect_to_list(peffect, cbdata);
    }
  } else if (universal_in_req_vec(cbdata->filter, &peffect->reqs)) {
    cbdata->edit->add_effect_to_list(peffect, cbdata);
  }

  return true;
}

/**************************************************************************
  Refresh the information.
**************************************************************************/
void effect_edit::refresh()
{
  struct effect_list_fill_data cb_data;

  list_widget->clear();
  effect_list_clear(effects);
  cb_data.filter = &filter;
  cb_data.edit = this;
  cb_data.num = 0;

  iterate_effect_cache(effect_list_fill_cb, &cb_data);

  fill_active();
}

/**************************************************************************
  Add entry to effect list.
**************************************************************************/
void effect_edit::add_effect_to_list(struct effect *peffect,
                                     struct effect_list_fill_data *data)
{
  char buf[512];
  QListWidgetItem *item;

  fc_snprintf(buf, sizeof(buf), _("Effect #%d: %s"),
              data->num, effect_type_name(peffect->type));

  item = new QListWidgetItem(QString::fromUtf8(buf));
  list_widget->insertItem(data->num++, item);
  effect_list_append(effects, peffect);
  if (selected == peffect) {
    item->setSelected(true);
  }
}

/**************************************************************************
  User pushed close button
**************************************************************************/
void effect_edit::close_now()
{
  done(0);
}

/**************************************************************************
  User selected effect from the list.
**************************************************************************/
void effect_edit::select_effect()
{
  int i = 0;

  effect_list_iterate(effects, peffect) {
    QListWidgetItem *item = list_widget->item(i++);

    if (item != nullptr && item->isSelected()) {
      selected = peffect;
      fill_active();
      return;
    }
  } effect_list_iterate_end;
}

/**************************************************************************
  Fill active menus from selected effect.
**************************************************************************/
void effect_edit::fill_active()
{
  if (selected != nullptr) {
    edit_type_button->setText(effect_type_name(selected->type));
  }
}

/**************************************************************************
  User selected type for the effect.
**************************************************************************/
void effect_edit::effect_type_menu(QAction *action)
{
  enum effect_type type = effect_type_by_name(action->text().toUtf8().data(),
                                              fc_strcasecmp);

  if (selected != nullptr) {
    selected->type = type;
  }

  refresh();
}
ENDREP
DELTA 35457 236 20
SVN  ÂÈ93„k ˆ
 Ž „1‡• ‰Œ&€g 9•? p–y ©'˜j P@š @‰ €‚EÁ}effect_edit.h"  QPushButton *effecteffects_button = new QPushButton(QString::fromUtf8(R__("Effects")), this);
  connect(effects_button, SIGNAL(pressed()), this, SLOT(edit_effects()));
  bldg_layout->addWidget(effects_button, 3, 2);
  show_experimental(effects_button44ser wants to edit effects
**********/
void tab_building::edit_effects()
{
  if (selected != nullptr) {
    effect_edit *e_edit;
    struct universal uni;

    uni.value.building = selected;
    uni.kind = VUT_IMPROVEMENT;

    e_edit = new effect_edit(ui, QString::fromUtf8(improvement_rule_name(selected)),
                             &uni);

    e_ENDREP
DELTA 25037 6100 4273
SVN  ¡#Ã G  ˆtF· u‰€t G ³ YŒn€ƒ ‚‹n€‚ {?† /‘:† g’i† i”P€„N –e† u˜€c ‚š9Œ ‚BœJ† Ÿ† b *ˆ š9€‚T š9€‚F š9€‚D š9€‚J 	š9€‚6 š9€‚:¡bool universal_in_req_vec(const struct universal *uni,
struct effect_list_cb_data
{
  bool needed;
  struct universal *uni;
  requirers_cb cb;
  void *requirers_data;
};

****
  Callback to check if effect needs universal.effect_list_universal_needed_cb(struct effect *peffect,
                                            void *data)
{
  struct effect_list_cb_data *cbdata = (struct effect_list_cb_data *)data;

  if (universal_in_req_vec(cbdata->uni, &peffect->reqs)) {
    cbdata->cb(R__("Effect"), cbdata->requirers_data);
    cbdata->needed = TRUE;
  }

  /* Always continue to next until all effects checked */
  return TRU,
                                void *data)
{
  bool needed = FALSE;
  bool needed_by_music_style = FALSE;
  int i;
  struct effect_list_cb_data cb_data;

  disaster_type_iterate(pdis) {
    if (universal_in_req_vec(uni, &pdis->reqs)) {
      cb(disaster_rule_name(pdis), data, data, data, data, data);
      needed = TRUE;
    }
  } extra_type_iterate_end;

  goods_type_iterate(pgood) {
    if (universal_in_req_vec(uni, &pgood->reqs)) {
      cb(goods_rule_name(pgood), data);
      needed = TRUE;
    }
  } goods_type_iterate_end;

  action_iterate(act) {
    action_enabler_list_iterate(action_enablers_for_action(act), enabler) {
      if (universal_in_req_vec(uni, &(enabler->actor_reqs))
          || universal_in_req_vec(uni, &(enabler->target_reqs))) {
        cb(R__("Action Enabler"), data);
        needed = TRUE;
      }
    } action_enabler_list_iterate_end;
  } action, data, data);
    needed = TRUE;
  }

  cb_data.needed = FALSE;
  cb_data.uni = uni;
  cb_data.cb = cb;
  cb_data.requirers_data = data;

  iterate_effect_cache(effect_list_universal_needed_cb, &cb_data);
  needed |= cb_data.needed;, void *data, data, data, data);building
**************************************************************************/
bool is_building_needed(struct impr_type *pimpr, requirers_cb cb,
                        void *data)
{
  struct universal uni = { .value.building = pimpr, .kind = VUT_IMPROVEMENT };
  bool needed = FALSE;

  needed |= is_universal_needed(&uni, cb, data);unit type
**************************************************************************/
bool is_utype_needed(struct unit_type *ptype, requirers_cb cb,
                     void *data)
{
  struct universal uni = { .value.utype = ptype, .kind = VUT_UTYPE };
  bool needed = FALSE;

  needed |= is_universal_needed(&uni, cb, data);goods type
**************************************************************************/
bool is_good_needed(struct goods_type *pgood, requirers_cb cb,
                    void *data)
{
  struct universal uni = { .value.good = pgood, .kind = VUT_GOOD };
  bool needed = FALSE;

  needed |= is_universal_needed(&uni, cb, data);extra type
**************************************************************************/
bool is_extra_needed(struct extra_type *pextra, requirers_cb cb,
                     void *data)
{
  struct universal uni = { .value.extra = pextra, .kind = VUT_EXTRA };
  bool needed = FALSE;

  needed |= is_universal_needed(&uni, cb, data);rrain type
**************************************************************************/
bool is_terrain_needed(struct terrain *pterr, requirers_cb cb, void *data)
{
  struct universal uni = { .value.terrain = pterr, .kind = VUT_TERRAIN };
  bool needed = FALSE;

  needed |= is_universal_needed(&uni, cb, data);government
**************************************************************************/
bool is_government_needed(struct government *pgov, requirers_cb cb, void *data)
{
  struct universal uni = { .value.govern = pgov, .kind = VUT_GOVERNMENT };
  bool needed = FALSE;

  needed |= is_universal_needed(&uni, cb, dataENDREP
DELTA
SVN   ZZ€Z/***********************************************************************
 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__EFFECT_EDIT_H
#define FC__EFFECT_EDIT_H

#ifdef HAVE_CONFIG_H
#include <fc_config.h>
#endif

// Qt
#include <QDialog>
#include <QListWidget>
#include <QToolButton>

// common
#include "requirements.h"

class ruledit_gui;

struct effect_list_fill_data
{
  struct universal *filter;
  class effect_edit *edit;
  int num;
};

class effect_edit : public QDialog
{
  Q_OBJECT

  public:
    explicit effect_edit(ruledit_gui *ui_in, QString target,
                         struct universal *filter_in);
    ~effect_edit();
    void refresh();
    void add(const char *msg);
    void add_effect_to_list(struct effect *peffect,
                            struct effect_list_fill_data *data);

  private:
    ruledit_gui *ui;

    QListWidget *list_widget;
    struct universal filter;
    struct effect_list *effects;

    struct effect *selected;

    QToolButton *edit_type_button;

  private slots:
    void select_effect();
    void fill_active();
    void close_now();

    void effect_type_menu(QAction *action);
};

#endif // FC__EFFECT_EDIT_H
ENDREP
DELTA 35414 9949 89
SVN  D* … ‹ ƒ[„sŸ †}ˆGeffect_editeffect_edit.cpp	\
		effect_editENDREP
DELTA 33766 664 38
SVN  Œ9ŒR Œ ”'Œ    void edit_effectENDREP
DELTA 35414 10064 64
SVN  ‹CŒ>y †! €y …$†bool universal_in_req_vec(const struct universal *uni,
                          const struct requirement_vector *preqs);ENDREP
id: sso.5js.r35496/13068
type: file
pred: sso.5js.r35414/10154
count: 27
text: 35496 12736 69 2054 30589e6d6a2bf10055706f80c942ccf3
cpath: /trunk/tools/ruledit/Makefile.am
copyroot: 21464 /trunk/tools

id: 30wc.5js.r35496/13270
type: file
count: 0
text: 35496 0 6321 6307 c285eb268f566eb2e400ab02309893ea
cpath: /trunk/tools/ruledit/effect_edit.cpp
copyroot: 21464 /trunk/tools

id: 30we.5js.r35496/13447
type: file
count: 0
text: 35496 10955 1768 1754 2e9316ae6a6fdbb1340c668f4ea37695
cpath: /trunk/tools/ruledit/effect_edit.h
copyroot: 21464 /trunk/tools

id: 1dyi.5js.r35496/13626
type: file
pred: 1dyi.5js.r35457/480
count: 11
text: 35496 6334 682 9273 15afc3e6e3038b61a568cc7c040791e3
props: 26905 28755 34 0 25e6c2f7558b7484000d4d090dea5b92
cpath: /trunk/tools/ruledit/tab_building.cpp
copyroot: 21464 /trunk/tools

id: 1dyk.5js.r35496/13890
type: file
pred: 1dyk.5js.r33766/989
count: 6
text: 35496 12832 39 1618 b6e6443ea04f43ff224a8ec362a6226c
props: 26905 30284 34 0 25e6c2f7558b7484000d4d090dea5b92
cpath: /trunk/tools/ruledit/tab_building.h
copyroot: 21464 /trunk/tools

id: 1402.5js.r35496/14151
type: file
pred: 1402.5js.r35414/11232
count: 16
text: 35496 7042 3884 8593 280c76654589767d64c7f414ca22862d
props: 26905 29369 34 0 25e6c2f7558b7484000d4d090dea5b92
cpath: /trunk/tools/ruledit/validity.c
copyroot: 21464 /trunk/tools

id: 1404.5js.r35496/14412
type: file
pred: 1404.5js.r35414/11492
count: 9
text: 35496 12897 143 1598 f9c520c815a924e3e48251e5c2bb154d
props: 26905 30593 34 0 25e6c2f7558b7484000d4d090dea5b92
cpath: /trunk/tools/ruledit/validity.h
copyroot: 21464 /trunk/tools

PLAIN
K 11
Makefile.am
V 25
file sso.5js.r35496/13068
K 14
edit_utype.cpp
V 25
file 1rko.5js.r28755/6535
K 12
edit_utype.h
V 25
file 1rkq.5js.r28755/6969
K 15
effect_edit.cpp
V 26
file 30wc.5js.r35496/13270
K 13
effect_edit.h
V 26
file 30we.5js.r35496/13447
K 12
req_edit.cpp
V 24
file 2kh2.5js.r35457/282
K 10
req_edit.h
V 25
file 2kh4.5js.r33805/1024
K 17
requirers_dlg.cpp
V 25
file 1942.5js.r28689/3697
K 15
requirers_dlg.h
V 26
file 1944.5js.r26905/32801
K 11
ruledit.cpp
V 23
file ssq.5m2.r33573/397
K 9
ruledit.h
V 24
file uyp.5js.r30587/1335
K 14
ruledit_qt.cpp
V 25
file uyr.5js.r35414/10355
K 12
ruledit_qt.h
V 25
file uys.5js.r35414/10614
K 16
tab_building.cpp
V 26
file 1dyi.5js.r35496/13626
K 14
tab_building.h
V 26
file 1dyk.5js.r35496/13890
K 16
tab_enablers.cpp
V 24
file 2phs.5js.r35457/740
K 14
tab_enablers.h
V 25
file 2phu.5js.r34072/1369
K 14
tab_extras.cpp
V 24
file 306c.5js.r35457/942
K 12
tab_extras.h
V 26
file 306e.5js.r35378/11545
K 12
tab_good.cpp
V 25
file 2kbx.5js.r35457/1143
K 10
tab_good.h
V 25
file 2kbz.5js.r33034/5373
K 11
tab_gov.cpp
V 25
file 2on5.5js.r35457/1341
K 9
tab_gov.h
V 26
file 2on7.5js.r33677/11642
K 12
tab_misc.cpp
V 24
file vcq.5js.r33814/8865
K 10
tab_misc.h
V 23
file vcs.5js.r32535/877
K 14
tab_nation.cpp
V 26
file 18bk.5js.r27597/11731
K 12
tab_nation.h
V 26
file 18bm.5js.r26905/29111
K 12
tab_tech.cpp
V 24
file vct.5js.r32632/3549
K 10
tab_tech.h
V 24
file vcu.5js.r32632/3809
K 16
tab_terrains.cpp
V 26
file 30eu.5js.r35414/10873
K 14
tab_terrains.h
V 26
file 30ew.5js.r35414/11053
K 12
tab_unit.cpp
V 25
file 1ej0.5js.r32632/4061
K 10
tab_unit.h
V 25
file 1ej2.5js.r32632/4323
K 12
univ_value.c
V 26
file 2nmz.5js.r33984/24519
K 12
univ_value.h
V 25
file 2nn1.5js.r33589/3674
K 10
validity.c
V 26
file 1402.5js.r35496/14151
K 10
validity.h
V 26
file 1404.5js.r35496/14412
END
ENDREP
id: ssm.5js.r35496/16518
type: dir
pred: ssm.5js.r35457/3278
count: 257
text: 35496 14672 1833 0 9c6e6a2695d0769d299beabecace99f9
props: 28036 0 261 0 b91e205c4bde11780878927c1dda815f
cpath: /trunk/tools/ruledit
copyroot: 21464 /trunk/tools

PLAIN
K 11
Makefile.am
V 23
file 4pk.5js.r35247/307
K 11
civmanual.c
V 24
file 2m5.5jt.r35318/7973
K 10
download.c
V 24
file 4pl.5js.r34830/6275
K 10
download.h
V 23
file 4pm.5js.r33670/464
K 9
modinst.c
V 23
file bj7.5js.r34951/444
K 9
modinst.h
V 24
file 76i.5js.r35242/9980
K 7
mpcli.c
V 24
file y74.5js.r34830/7008
K 11
mpcmdline.c
V 25
file 73v.5js.r33059/41788
K 11
mpcmdline.h
V 25
file 73w.5js.r26905/37695
K 6
mpdb.c
V 24
file bjc.5js.r34830/7253
K 6
mpdb.h
V 24
file bje.5js.r34830/7497
K 12
mpgui_gtk3.c
V 23
file 4pn.5ln.r35247/495
K 12
mpgui_gtk4.c
V 23
file 4pn.5yz.r35249/361
K 12
mpgui_qt.cpp
V 24
file a65.5js.r34830/8005
K 10
mpgui_qt.h
V 24
file a67.5js.r28930/1822
K 19
mpgui_qt_worker.cpp
V 23
file vuz.5js.r27625/957
K 17
mpgui_qt_worker.h
V 25
file vv1.5js.r26905/38877
K 7
ruledit
V 24
dir ssm.5js.r35496/16518
K 8
ruleup.c
V 24
file 2hyw.5js.r35380/627
K 8
ruleutil
V 26
dir 2hlr.5js.r35369/107268
END
ENDREP
id: 4pj.5js.r35496/17694
type: dir
pred: 4pj.5js.r35457/4452
count: 500
text: 35496 16760 921 0 3f24ee4e50435e7fa998b438d34f5731
props: 28036 1369 325 0 931541cd07e52416301ed56de9c70dfc
cpath: /trunk/tools
copyroot: 21464 /trunk/tools

PLAIN
K 9
ABOUT-NLS
V 24
file fu.5ck.r33136/31347
K 7
AUTHORS
V 24
file 5u.5ck.r22143/14016
K 7
COPYING
V 22
file 1h.5ck.r29454/952
K 9
ChangeLog
V 26
file 6l.5ck.r34755/9472461
K 7
INSTALL
V 21
file 6.5ck.r35375/156
K 11
Makefile.am
V 21
file 59.5ck.r35284/44
K 4
NEWS
V 24
file 6m.5ck.r25634/30702
K 6
README
V 20
file 7.0.r4421/96382
K 2
ai
V 21
dir 8.5ck.r35492/3196
K 10
autogen.sh
V 23
file 12o.5ck.r34768/471
K 9
bootstrap
V 23
dir 2p5.5ck.r35328/4637
K 6
client
V 21
dir d.5ck.r35470/5169
K 6
common
V 21
dir p.5ck.r35474/6682
K 12
configure.ac
V 24
file 149.5ck.r35468/4930
K 4
data
V 22
dir w.5ck.r35488/33688
K 12
dependencies
V 23
dir 2yu.5ck.r35264/1941
K 3
doc
V 23
dir k7.5ck.r35459/11145
K 10
fc_version
V 25
file 2lo.5en.r35393/33864
K 11
gen_headers
V 23
dir 1hsw.5ck.r34605/792
K 3
lua
V 24
dir 2c5e.5ck.r31919/4841
K 2
m4
V 23
dir 12p.5ck.r35297/2434
K 7
scripts
V 24
dir 2yo.5ck.r34765/41493
K 6
server
V 21
dir z.5ck.r35492/9172
K 5
tests
V 22
dir 2g9.5ck.r32361/591
K 5
tools
V 24
dir 4pj.5js.r35496/17694
K 12
translations
V 26
dir t0a.5ck.r35466/4287037
K 7
utility
V 23
dir 1c.5ck.r35447/30261
K 7
windows
V 23
dir 2eu.5x1.r35448/1922
END
ENDREP
id: 3.5ck.r35496/19102
type: dir
pred: 3.5ck.r35492/10569
count: 22717
text: 35496 17930 1159 0 c4893977627058d1bd6f05003accef2f
props: 28036 14655 292 0 9e1d5de0253c723466868990c52c129f
cpath: /trunk
copyroot: 15280 /trunk

PLAIN
K 8
branches
V 20
dir 1.0.r35495/10527
K 4
tags
V 19
dir 2.0.r34572/6701
K 5
trunk
V 22
dir 3.5ck.r35496/19102
K 7
website
V 20
dir 3ge.0.r35333/548
END
ENDREP
id: 0.0.r35496/19493
type: dir
pred: 0.0.r35495/10849
count: 35496
text: 35496 19327 153 0 82b1026eaf70c698bf8ebda2bf8d7654
cpath: /
copyroot: 0 /

sso.5js.t35495-1 modify true false /trunk/tools/ruledit/Makefile.am

_3.5js.t35495-1 add true false /trunk/tools/ruledit/effect_edit.cpp

_5.5js.t35495-1 add true false /trunk/tools/ruledit/effect_edit.h

1dyi.5js.t35495-1 modify true false /trunk/tools/ruledit/tab_building.cpp

1dyk.5js.t35495-1 modify true false /trunk/tools/ruledit/tab_building.h

1402.5js.t35495-1 modify true false /trunk/tools/ruledit/validity.c

1404.5js.t35495-1 modify true false /trunk/tools/ruledit/validity.h


19493 19641
