// This is the main constructor.
PropertiesDialog::PropertiesDialog(QWidget *parent, const QVector<QString> Qheader, const QString sourceInput, const QString targetInput) : QDialog(parent) {
  // We first set up the standard elements of the interface, which are only two labels and two buttons.
  sourceLabel = new QLabel(sourceInput);
  targetLabel = new QLabel(targetInput);
  saveCloseButton = new QPushButton(tr("Save and Close"));
  cancelButton = new QPushButton(tr("Cancel"));

  // We dynamically create two lists of checkboxes as well, which represent potential properties.
  // Only variables that were not already selected as source and target nodes are included as options.
  QVectorIterator<QString> it(Qheader);
  while (it.hasNext()) {
    QPointer<QCheckBox> tempBoxOne = new QCheckBox(it.peekNext(), this);
    QPointer<QCheckBox> tempBoxTwo = new QCheckBox(it.next(), this);
    if (tempBoxOne->text() != sourceInput && tempBoxOne->text() != targetInput) {
      sourceVector.push_back(tempBoxOne);
    } else {
      delete tempBoxOne;
    }
    if (tempBoxTwo->text() != targetInput && tempBoxTwo->text() != sourceInput) {
      targetVector.push_back(tempBoxTwo);
      if (sourceInput == targetInput) {
	tempBoxTwo->setEnabled(false);
      }
    } else {
      delete tempBoxTwo;
    }
  }
  
  // We then set up the signals. Basically, save and close is the only signal that will send information from the properties dialog
  // to the main dialog.
  connect(saveCloseButton, SIGNAL(clicked()), this, SLOT(saveAndClose()));
  connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); // In case the user decides not to set properties.
  
  // Then we create our layout. 
  QPointer<QVBoxLayout> mainLayout = new QVBoxLayout;
  QPointer<QHBoxLayout> mainBodyLayout = new QHBoxLayout;
  QPointer<QVBoxLayout> mainBodyLeft = new QVBoxLayout;
  QPointer<QVBoxLayout> mainBodyRight = new QVBoxLayout;

  mainBodyLeft->addWidget(sourceLabel);
  QVectorIterator<QPointer<QCheckBox> > sI(sourceVector);
  while (sI.hasNext()) {
    mainBodyLeft->addWidget(sI.next());
  }
  
  mainBodyRight->addWidget(targetLabel);
  QVectorIterator<QPointer<QCheckBox> > tI(targetVector);
  while (tI.hasNext()) {
    mainBodyRight->addWidget(tI.next());
  }
  
  mainBodyLayout->addLayout(mainBodyLeft);
  mainBodyLayout->addLayout(mainBodyRight);
  mainLayout->addLayout(mainBodyLayout);
  QPointer<QHBoxLayout> lowerLayout = new QHBoxLayout;
  lowerLayout->addWidget(saveCloseButton);
  lowerLayout->addWidget(cancelButton);
  mainLayout->addLayout(lowerLayout);

  setLayout(mainLayout);
  setWindowTitle(tr("Set Properties"));
  setFixedHeight(sizeHint().height());
  // And that finishes our constructor
}
Ejemplo n.º 2
0
EditCharacterDialog::EditCharacterDialog(void)
{
    QPointer<QGridLayout> edit_info = new QGridLayout;
    QPointer<QVBoxLayout> vlay = new QVBoxLayout;

    // First allow the 6 stats to be edited
    // Strength
    QPointer<QLabel>  str_label = new QLabel("Strength");
    QPointer<QSpinBox> str_spinner = new QSpinBox;
    str_spinner->setRange(3,118);
    str_spinner->setValue(p_ptr->stat_base_cur[A_STR]);
    edit_info->addWidget(str_label, 1, 0);
    edit_info->addWidget(str_spinner, 1, 1);

    // Intelligence
    QPointer<QLabel>  int_label = new QLabel("Intelligence");
    QPointer<QSpinBox> int_spinner = new QSpinBox;
    int_spinner->setRange(3,118);
    int_spinner->setValue(p_ptr->stat_base_cur[A_INT]);
    edit_info->addWidget(int_label, 2, 0);
    edit_info->addWidget(int_spinner, 2, 1);

    // Wisdom
    QPointer<QLabel>  wis_label = new QLabel("Wisdom");
    QPointer<QSpinBox> wis_spinner = new QSpinBox;
    wis_spinner->setRange(3,118);
    wis_spinner->setValue(p_ptr->stat_base_cur[A_WIS]);
    edit_info->addWidget(wis_label, 3, 0);
    edit_info->addWidget(wis_spinner, 3, 1);

    // Dexterity
    QPointer<QLabel>  dex_label = new QLabel("Dexterity");
    QPointer<QSpinBox> dex_spinner = new QSpinBox;
    dex_spinner->setRange(3,118);
    dex_spinner->setValue(p_ptr->stat_base_cur[A_DEX]);
    edit_info->addWidget(dex_label, 4, 0);
    edit_info->addWidget(dex_spinner, 4, 1);

    // Constitution
    QPointer<QLabel>  con_label = new QLabel("Constitution");
    QPointer<QSpinBox> con_spinner = new QSpinBox;
    con_spinner->setRange(3,118);
    con_spinner->setValue(p_ptr->stat_base_cur[A_CON]);
    edit_info->addWidget(con_label, 5, 0);
    edit_info->addWidget(con_spinner, 5, 1);

    // Charisma
    QPointer<QLabel>  chr_label = new QLabel("Charisma");
    QPointer<QSpinBox> chr_spinner = new QSpinBox;
    chr_spinner->setRange(3,118);
    chr_spinner->setValue(p_ptr->stat_base_cur[A_CHR]);
    edit_info->addWidget(chr_label, 6, 0);
    edit_info->addWidget(chr_spinner, 6, 1);

    // Gold
    QPointer<QLabel>  gold_label = new QLabel("Gold");
    QPointer<QSpinBox> gold_spinner = new QSpinBox;
    gold_spinner->setRange(0,500000000);
    gold_spinner->setValue(p_ptr->au);
    gold_spinner->setSingleStep(1000000);
    edit_info->addWidget(gold_label, 7, 0);
    edit_info->addWidget(gold_spinner, 7, 1);

    // Experience
    QPointer<QLabel>  exp_label = new QLabel("Experience");
    QPointer<QSpinBox> exp_spinner = new QSpinBox;
    exp_spinner->setRange(0,10000000);
    exp_spinner->setValue(p_ptr->max_exp);
    exp_spinner->setSingleStep(10000);
    edit_info->addWidget(exp_label, 8, 0);
    edit_info->addWidget(exp_spinner, 8, 1);

        // Experience
    QPointer<QLabel>  fame_label = new QLabel("Fame");
    QPointer<QSpinBox> fame_spinner = new QSpinBox;
    fame_spinner->setRange(0,5000);
    fame_spinner->setValue(p_ptr->q_fame);
    fame_spinner->setSingleStep(100);
    edit_info->addWidget(fame_label, 9, 0);
    edit_info->addWidget(fame_spinner, 9, 1);

    QPointer<QPushButton> close_button = new QPushButton(tr("&Close"));
    connect(close_button, SIGNAL(clicked()), this, SLOT(close()));

    vlay->addLayout(edit_info);
    vlay->addStretch();
    vlay->addWidget(close_button);

    setLayout(vlay);

    setWindowTitle(tr("Character Edit Screen"));
    this->exec();

    p_ptr->stat_base_cur[A_STR] = p_ptr->stat_base_max[A_STR] = str_spinner->value();
    p_ptr->stat_base_cur[A_INT] = p_ptr->stat_base_max[A_INT] = int_spinner->value();
    p_ptr->stat_base_cur[A_WIS] = p_ptr->stat_base_max[A_WIS] = wis_spinner->value();
    p_ptr->stat_base_cur[A_DEX] = p_ptr->stat_base_max[A_DEX] = dex_spinner->value();
    p_ptr->stat_base_cur[A_CON] = p_ptr->stat_base_max[A_CON] = con_spinner->value();
    p_ptr->stat_base_cur[A_CHR] = p_ptr->stat_base_max[A_CHR] = chr_spinner->value();
    p_ptr->au = gold_spinner->value();
    p_ptr->max_exp = p_ptr->exp = exp_spinner->value();
    check_experience();
    p_ptr->q_fame = fame_spinner->value();


        /* Combine and Reorder the pack (later) */
    p_ptr->notice |= (PN_COMBINE | PN_REORDER | PN_SORT_QUIVER);

    /* Update stuff */
    p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);

    /* Fully update the visuals */
    p_ptr->update |= (PU_FORGET_VIEW | PU_UPDATE_VIEW | PU_MONSTERS);

    /* Redraw everything */
    p_ptr->redraw |= (PR_STATUSBAR | PR_SIDEBAR_PL | PR_MAP | PR_WIN_INVENTORY | PR_WIN_EQUIPMENT |
                      PR_MESSAGES | PR_WIN_MON_RECALL | PR_WIN_OBJ_RECALL | PR_WIN_MESSAGES |
                      PR_WIN_OBJLIST | PR_WIN_FEAT_RECALL);

    handle_stuff();
}
Ejemplo n.º 3
0
EditObjectDialog::EditObjectDialog(void)
{


    object_type *o_ptr;
    int item;

    /* Get an item */
    QString q = "Choose an item to edit. ";
    QString s = "You have no eligible items.";
    /* Only accept legal items. */
    item_tester_hook = item_tester_hook_not_artifact;

    if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | USE_QUIVER))) return;

    /* Get the item (in the pack) */
    if (item >= 0)
    {
        o_ptr = &inventory[item];
    }

    /* Get the item (on the floor) */
    else
    {
        o_ptr = &o_list[0 - item];
    }

    QPointer<QVBoxLayout> vlay = new QVBoxLayout;

    QPointer<QGridLayout> edit_info = new QGridLayout;

    QPointer<QLabel>  obj_label = new QLabel(QString("<b><big>Editing %1</big></b>") .arg(object_desc(o_ptr, ODESC_PREFIX | ODESC_FULL)));
    obj_label->setAlignment(Qt::AlignCenter);

    vlay->addWidget(obj_label);

    // Edit quantity
    QPointer<QLabel>  quant_label = new QLabel("Edit quantity");
    QPointer<QSpinBox> quant_spinner = new QSpinBox;
    quant_spinner->setRange(1,MAX_STACK_SIZE);
    quant_spinner->setValue(o_ptr->number);
    edit_info->addWidget(quant_label, 1, 0);
    edit_info->addWidget(quant_spinner, 1, 1);

    // Pval
    QPointer<QLabel>  pval_label = new QLabel("Edit pval");
    QPointer<QSpinBox> pval_spinner = new QSpinBox;
    pval_spinner->setRange(-99,99);
    pval_spinner->setValue(o_ptr->pval);
    edit_info->addWidget(pval_label, 2, 0);
    edit_info->addWidget(pval_spinner, 2, 1);
    if (!o_ptr->is_wieldable())
    {
        pval_label->hide();
        pval_spinner->hide();
    }

    // To-hit
    QPointer<QLabel>  to_h_label = new QLabel("Edit To-Hit");
    QPointer<QSpinBox> to_h_spinner = new QSpinBox;
    to_h_spinner->setRange(-99,99);
    to_h_spinner->setValue(o_ptr->to_h);
    edit_info->addWidget(to_h_label, 3, 0);
    edit_info->addWidget(to_h_spinner, 3, 1);

    if (!o_ptr->is_wieldable() && !o_ptr->is_ammo())
    {
        to_h_label->hide();
        to_h_spinner->hide();
    }

    // To-damage
    QPointer<QLabel>  to_d_label = new QLabel("Edit To-Dam");
    QPointer<QSpinBox> to_d_spinner = new QSpinBox;
    to_d_spinner->setRange(-99,99);
    to_d_spinner->setValue(o_ptr->to_d);
    edit_info->addWidget(to_d_label, 4, 0);
    edit_info->addWidget(to_d_spinner, 4, 1);
    if (!o_ptr->is_wieldable() && !o_ptr->is_ammo())
    {
        to_h_label->hide();
        to_h_spinner->hide();
        to_d_label->hide();
        to_d_spinner->hide();
    }

    // Armor Class
    QPointer<QLabel>  to_ac_label = new QLabel("Edit Armor Class");
    QPointer<QSpinBox> to_ac_spinner = new QSpinBox;
    to_ac_spinner->setRange(-99,99);
    to_ac_spinner->setValue(o_ptr->to_d);
    edit_info->addWidget(to_ac_label, 5, 0);
    edit_info->addWidget(to_ac_spinner, 5, 1);
    if (!o_ptr->is_wieldable())
    {
        to_ac_label->hide();
        to_ac_spinner->hide();
    }


    QPointer<QPushButton> close_button = new QPushButton(tr("&Close"));
    connect(close_button, SIGNAL(clicked()), this, SLOT(close()));


    vlay->addLayout(edit_info);
    vlay->addStretch();
    vlay->addWidget(close_button);

    setLayout(vlay);
    setWindowTitle("Object Editor");
    this->exec();

    o_ptr->number = quant_spinner->value();
    o_ptr->pval = pval_spinner->value();
    o_ptr->to_h = to_h_spinner->value();
    o_ptr->to_d = to_d_spinner->value();
    o_ptr->to_a = to_ac_spinner->value();

    /* Combine and Reorder the pack (later) */
    p_ptr->notice |= (PN_COMBINE | PN_REORDER | PN_SORT_QUIVER);

    /* Update stuff */
    p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);

    handle_stuff();
}
Ejemplo n.º 4
0
WizardModeDialog::WizardModeDialog(void)
{
    int row = 0;

    // Paranoia
    if (!p_ptr->playing) return;

    if (!p_ptr->is_wizard)
    {
        QString prompt = color_string(QString ("<b><big>You are about to use 'Wizard Mode' commands.</big></b><br><br>"), TERM_RED);
        prompt.append("Wizard Mode contains many powerful 'cheat' commands.  ");
        prompt.append("Your savefile will be marked as a wizard mode character and will not be scored.<br><br>");
        prompt.append("Really use Wizard Mode?");
        if (!get_check(prompt)) return;
        p_ptr->is_wizard = TRUE;
    }

    main_prompt = new QLabel(QString("<b><big>Please select a command</big></b><br>"));
    main_prompt->setAlignment(Qt::AlignCenter);

    QPointer<QVBoxLayout> vlay = new QVBoxLayout;

    vlay->addWidget(main_prompt);

    // Add the player related commands
    QPointer<QGridLayout> wizard_layout = new QGridLayout;

    player_section = new QLabel("<b>Player commands</b>");
    player_section->setAlignment(Qt::AlignCenter);
    wizard_layout->addWidget(player_section, row, 1);

    row++;

    // Add the "cure all" button
    QPointer<QPushButton> heal_button = new QPushButton("Heal Player");
    heal_button->setToolTip("Completely heal and restore the player.");
    connect(heal_button, SIGNAL(clicked()), this, SLOT(wiz_cure_all()));
    wizard_layout->addWidget(heal_button, row, 0);

    // Add the "know all" button
    QPointer<QPushButton> know_button = new QPushButton("Know All");
    know_button->setToolTip("Know everything about every feature, object, and monster in the game.");
    connect(know_button, SIGNAL(clicked()), this, SLOT(wiz_know_all()));
    wizard_layout->addWidget(know_button, row, 1);

    // Add the "jump" button
    QPointer<QPushButton> jump_button = new QPushButton("Jump To New Level");
    jump_button->setToolTip("Allow the player to instantly jump to any level in the dungeon.");
    connect(jump_button, SIGNAL(clicked()), this, SLOT(wiz_jump()));
    wizard_layout->addWidget(jump_button, row, 2);

    row++;

    // Add the "teleport_to_target" button
    QPointer<QPushButton> teleport_target_button = new QPushButton("Teleport To Targeted Spot");
    teleport_target_button->setToolTip("Teleports the player to a specified spot on the dungeon level.");
    connect(teleport_target_button, SIGNAL(clicked()), this, SLOT(wiz_teleport_to_target()));
    wizard_layout->addWidget(teleport_target_button, row, 0);

    // Add the "phase door" button
    QPointer<QPushButton> phase_door = new QPushButton("Phase Door");
    phase_door->setToolTip("Teleports the player to a random spot up to 10 squares away.");
    connect(phase_door, SIGNAL(clicked()), this, SLOT(wiz_phase_door()));
    wizard_layout->addWidget(phase_door, row, 1);

    // Add the "teleport" button
    QPointer<QPushButton> teleport = new QPushButton("Teleport");
    teleport->setToolTip("Teleports the player to a random spot up to 100 squares away.");
    connect(teleport, SIGNAL(clicked()), this, SLOT(wiz_teleport()));
    wizard_layout->addWidget(teleport, row, 2);

    row++;

    // Add the "edit character" button
    QPointer<QPushButton> edit_character = new QPushButton("Edit Character");
    edit_character->setToolTip("Edit character statistics, experience, gold, and fame.");
    connect(edit_character, SIGNAL(clicked()), this, SLOT(wiz_edit_character()));
    wizard_layout->addWidget(edit_character, row, 0);

    // Add the "know all" button
    QPointer<QPushButton> spoil_button = new QPushButton("Print Spoilers");
    spoil_button->setToolTip("Print out Spoilers for all Monsters, objects, artifacts, and terrain.");
    connect(spoil_button, SIGNAL(clicked()), this, SLOT(wiz_print_spoilers()));
    wizard_layout->addWidget(spoil_button, row, 1);

    row++;

    // Add the dungeon commands
    dungeon_section = new QLabel("<b>Dungeon commands</b>");
    dungeon_section->setAlignment(Qt::AlignCenter);
    wizard_layout->addWidget(dungeon_section, row, 1);

    row++;

    // Add the "summon" button
    QPointer<QPushButton> summon_button = new QPushButton("Summon Monster");
    summon_button->setToolTip("Summon one random monster.");
    connect(summon_button, SIGNAL(clicked()), this, SLOT(wiz_summon()));
    wizard_layout->addWidget(summon_button, row, 0);

    // Add the "banish" button
    QPointer<QPushButton> banish_button = new QPushButton("Banish Monsters");
    banish_button->setToolTip("Erase all monsters within 30 squares of player, except for uniques and quest monsters.");
    connect(banish_button, SIGNAL(clicked()), this, SLOT(wiz_banish()));
    wizard_layout->addWidget(banish_button, row, 1);

    // Add the "detect all monsters" button
    QPointer<QPushButton> display_mon_button = new QPushButton("Detect All Monsters");
    display_mon_button->setToolTip("Detect all monsters on the level.");
    connect(display_mon_button, SIGNAL(clicked()), this, SLOT(wiz_detect_all_monsters()));
    wizard_layout->addWidget(display_mon_button, row, 2);

    row++;

    // Add the "detection" button
    QPointer<QPushButton> detection = new QPushButton("Detection");
    detection->setToolTip("Cast the 'Detection' spell");
    connect(detection, SIGNAL(clicked()), this, SLOT(wiz_detection()));
    wizard_layout->addWidget(detection, row, 0);

    // Add the "magic mapping" button
    QPointer<QPushButton> magic_mapping = new QPushButton("Magic Mapping");
    magic_mapping->setToolTip("Cast the 'Magic Mapping' spell.");
    connect(magic_mapping, SIGNAL(clicked()), this, SLOT(wiz_magic_mapping()));
    wizard_layout->addWidget(magic_mapping, row, 1);

    // Add the "light dungeon" button
    QPointer<QPushButton> dungeon_light = new QPushButton("Light Dungeon");
    dungeon_light->setToolTip("Illuminate the entire dungeon level.");
    connect(dungeon_light, SIGNAL(clicked()), this, SLOT(wiz_level_light()));
    wizard_layout->addWidget(dungeon_light, row, 2);

    row++;

    // Add the "redraw dungeon" button
    QPointer<QPushButton> redraw_dungeon = new QPushButton("Redraw Dungeon");
    redraw_dungeon->setToolTip("Redraw a new dungeon level at the current depth.");
    connect(redraw_dungeon, SIGNAL(clicked()), this, SLOT(wiz_redraw_dungeon()));
    wizard_layout->addWidget(redraw_dungeon, row, 0);

    // Add the "make monster" button
    QPointer<QPushButton> make_monster = new QPushButton("Make Monster");
    make_monster->setToolTip("Attempt to make a monster of a specified monster race.");
    connect(make_monster, SIGNAL(clicked()), this, SLOT(wiz_create_monster()));
    wizard_layout->addWidget(make_monster, row, 1);

    // Add the "make feature" button
    QPointer<QPushButton> make_feature = new QPushButton("Make Feature");
    make_feature->setToolTip("Attempt to make a specified feature type.");
    connect(make_feature, SIGNAL(clicked()), this, SLOT(wiz_create_feature()));
    wizard_layout->addWidget(make_feature, row, 2);

    row++;

    // Add the object commands
    object_section = new QLabel("<b>Object commands</b>");
    object_section->setAlignment(Qt::AlignCenter);
    wizard_layout->addWidget(object_section, row, 1);

    row++;

    // Add the "mass create items" button
    QPointer<QPushButton> mass_create_items_button = new QPushButton("Create 25 Random Items");
    mass_create_items_button->setToolTip("Drop 25 randomly generated objects around the player.");
    connect(mass_create_items_button , SIGNAL(clicked()), this, SLOT(wiz_mass_create_items()));
    wizard_layout->addWidget(mass_create_items_button, row, 0);

    // Add the "create 1 random good item" button
    QPointer<QPushButton> create_good_item = new QPushButton("Create 1 Random Good Item");
    create_good_item->setToolTip("Drop one randomly created guaranteed good item by the player.");
    connect(create_good_item , SIGNAL(clicked()), this, SLOT(wiz_create_good_item()));
    wizard_layout->addWidget(create_good_item, row, 1);

    // Add the "create 1 random great item" button
    QPointer<QPushButton> create_great_item = new QPushButton("Create 1 Random Great Item");
    create_great_item->setToolTip("Drop one randomly created guaranteed great item by the player.");
    connect(create_great_item , SIGNAL(clicked()), this, SLOT(wiz_create_great_item()));
    wizard_layout->addWidget(create_great_item, row, 2);

    row++;

    // Add the "mass identify" button
    QPointer<QPushButton> mass_identify = new QPushButton("Mass Identify");
    mass_identify->setToolTip("Identify all objects the player has, as well as all objects within 5 squares.");
    connect(mass_identify, SIGNAL(clicked()), this, SLOT(wiz_mass_identify_items()));
    wizard_layout->addWidget(mass_identify, row, 0);

    // Add the "winner's kit" button
    QPointer<QPushButton> winners_kit = new QPushButton("Winner's kit");
    winners_kit->setToolTip("Create a set of artifacts suitable for winning the game.");
    connect(winners_kit, SIGNAL(clicked()), this, SLOT(wiz_winners_kit()));
    wizard_layout->addWidget(winners_kit, row, 1);

    // Add the "edit object" button
    QPointer<QPushButton> edit_object = new QPushButton("Edit Object");
    edit_object->setToolTip("Edit a non-artifact object.");
    connect(edit_object, SIGNAL(clicked()), this, SLOT(wiz_edit_object()));
    wizard_layout->addWidget(edit_object, row, 2);

    row++;

    // Add the "make artifact" button
    QPointer<QPushButton> create_artifact = new QPushButton("Create artifact");
    create_artifact->setToolTip("Create an artifact.");
    connect(create_artifact, SIGNAL(clicked()), this, SLOT(wiz_create_artifact()));
    wizard_layout->addWidget(create_artifact, row, 0);

    // Add the "make objecct" button
    QPointer<QPushButton> create_object = new QPushButton("Create object");
    create_object->setToolTip("Create a normal object.");
    connect(create_object, SIGNAL(clicked()), this, SLOT(wiz_create_object()));
    wizard_layout->addWidget(create_object, row, 1);

    vlay->addLayout(wizard_layout);

    buttons = new QDialogButtonBox(QDialogButtonBox::Cancel);
    connect(buttons, SIGNAL(rejected()), this, SLOT(close()));
    vlay->addStretch();
    vlay->addWidget(buttons);

    setLayout(vlay);
    setWindowTitle(tr("Wizard Mode Menu"));

    this->exec();
}