Пример #1
0
void
dumpPlanetType (FILE *out, int index, const PlanetFrame *planetType)
{
	int i;
	fprintf (out,
			"%s\n"
			"\tType: %s\n"
			"\tColor: %s\n"
			"\tSurface generation algoritm: %s\n"
			"\tTectonics: %s\n"
			"\tAtmosphere: %s\n"
			"\tDensity: %s\n"
			"\tElements:\n",
			planetTypeString (index),
			worldSizeString (PLANSIZE (planetType->Type)),
			bodyColorString (PLANCOLOR (planetType->Type)),
			worldGenAlgoString (PLANALGO (planetType->Type)),
			tectonicsString (planetType->BaseTectonics),
			atmosphereString (HINIBBLE (planetType->AtmoAndDensity)),
			densityString (LONIBBLE (planetType->AtmoAndDensity))
			);
	for (i = 0; i < NUM_USEFUL_ELEMENTS; i++)
	{
		const ELEMENT_ENTRY *entry;
		entry = &planetType->UsefulElements[i];
		if (entry->Density == 0)
			continue;
		fprintf(out, "\t\t0 to %d %s-quality (+%d) deposits of %s (%s)\n",
				DEPOSIT_QUANTITY (entry->Density),
				depositQualityString (DEPOSIT_QUALITY (entry->Density)),
				DEPOSIT_QUALITY (entry->Density) * 5,
				GAME_STRING (ELEMENTS_STRING_BASE + entry->ElementType),
				GAME_STRING (CARGO_STRING_BASE + 2 + ElementCategory (
				entry->ElementType))
			);
	}
	fprintf (out, "\n");
}
Пример #2
0
NewGameDialog::NewGameDialog(QWidget* parent)
    : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), m_minimum(3)
{
    setWindowTitle(tr("New Game"));

    QVBoxLayout* layout = new QVBoxLayout(this);

    QSettings settings;
    int previous_timer = settings.value("Board/TimerMode", Clock::Tanglet).toInt();

    // Create size buttons
    m_normal_size = new QToolButton(this);
    m_normal_size->setAutoExclusive(true);
    m_normal_size->setAutoRaise(true);
    m_normal_size->setCheckable(true);
    m_normal_size->setIconSize(QSize(64, 64));
    m_normal_size->setIcon(QPixmap(":/preview/normal.png"));
    m_normal_size->setText(Board::sizeToString(4));
    m_normal_size->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    connect(m_normal_size, SIGNAL(clicked()), this, SLOT(sizeChanged()));

    m_large_size = new QToolButton(this);
    m_large_size->setAutoExclusive(true);
    m_large_size->setAutoRaise(true);
    m_large_size->setCheckable(true);
    m_large_size->setIconSize(QSize(64, 64));
    m_large_size->setIcon(QPixmap(":/preview/large.png"));
    m_large_size->setText(Board::sizeToString(5));
    m_large_size->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    connect(m_large_size, SIGNAL(clicked()), this, SLOT(sizeChanged()));

    if (settings.value("Board/Size", 4).toInt() == 4) {
        m_normal_size->setChecked(true);
    } else {
        m_large_size->setChecked(true);
    }

    QHBoxLayout* size_buttons = new QHBoxLayout;
    size_buttons->setMargin(0);
    size_buttons->addStretch();
    size_buttons->addWidget(m_normal_size);
    size_buttons->addWidget(m_large_size);
    size_buttons->addStretch();
    layout->addLayout(size_buttons);
    layout->addSpacing(6);

    // Create word options
    m_density = new QComboBox(this);
    for (int i = 0; i < 4; ++i) {
        m_density->addItem(densityString(i));
    }
    m_density->setCurrentIndex(settings.value("Board/Density", 1).toInt());

    m_length = new QComboBox(this);
    for (int i = 0; i < 4; ++i) {
        m_length->addItem("");
    }
    connect(m_length, SIGNAL(currentIndexChanged(int)), this, SLOT(lengthChanged(int)));
    m_minimum = settings.value("Board/Minimum", 3).toInt();
    if (m_large_size->isChecked()) {
        --m_minimum;
    }
    m_length->setCurrentIndex(qBound(0, m_minimum - 3, 4));
    sizeChanged();

    QFormLayout* options_layout = new QFormLayout;
    options_layout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
    options_layout->setLabelAlignment(Qt::AlignRight | Qt::AlignVCenter);
    options_layout->addRow(tr("Amount of Words:"), m_density);
    options_layout->addRow(tr("Minimum Word Length:"), m_length);
    layout->addLayout(options_layout);
    layout->addSpacing(6);

    // Create timer buttons
    QSignalMapper* mapper = new QSignalMapper(this);
    connect(mapper, SIGNAL(mapped(int)), this, SLOT(timerChosen(int)));

    QList<TimerDescription> timers;
    for (int i = Clock::Tanglet; i < Clock::TotalTimers; ++i) {
        timers.append(i);
    }
    qSort(timers);
    foreach (const TimerDescription& timer, timers) {
        QCommandLinkButton* button = new QCommandLinkButton(timer.name(), timer.description(), this);
        button->setMinimumWidth(500);
        connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
        mapper->setMapping(button, timer.id());
        layout->addWidget(button);

        if (timer.id() == previous_timer) {
            button->setDefault(true);
            button->setFocus();
        }
    }