multiple intricate implementations

This commit is contained in:
Geoffray Levasseur committed 2026-11-04 11:41:01 +01:00
1 parent 7aa4ea4425
commit 77690cbd96
109 files changed
+2045 -56

No files matched your search

+47 -4
View File
@@ -29,6 +29,9 @@
#include "Log.h"
#include "ui_Log.h"
#include "localplayer/ClientTools.h"
#include "localplayer/Tribes.h"
#include <QActionGroup>
#include <QKeyEvent>
#include <QMenu>
@@ -64,10 +67,7 @@ LogDlg::LogDlg(QWidget *parent) : Dpi::Form(parent), ui(new Ui::LogDlg)
logPopup->addAction(ui->actionSlot);
logPopup->addAction(ui->actionClear);
connect(ui->actionSlot, &QAction::triggered, this, [] {
// TODO: needs G.Difficulty[]/Tribe[].TPhrase("SHORTNAME") (Global.pas/
// Tribes.pas, not ported yet) - deferred until those units exist.
});
connect(ui->actionSlot, &QAction::triggered, this, [this] { listSlots(); });
connect(ui->actionClear, &QAction::triggered, ui->list, &QPlainTextEdit::clear);
}
@@ -76,6 +76,49 @@ LogDlg::~LogDlg()
delete ui;
}
void LogDlg::clear()
{
ui->list->clear();
}
void LogDlg::setSlotItemVisible(bool visible)
{
ui->actionSlot->setVisible(visible);
}
void LogDlg::listSlots()
{
// Player slot numbers as laid out around the start screen's 3x3 grid.
static constexpr int SlotNo[3][3] = { { 8, 1, 2 }, { 7, 0, 3 }, { 6, 5, 4 } };
const auto shortName = [](int p) {
const auto &tribe = Tribes::tribe[static_cast<std::size_t>(p)];
return tribe ? tribe->tPhrase(QStringLiteral("SHORTNAME")) : QString();
};
for (int y = 0; y < 3; ++y) {
QString s = QStringLiteral("| ");
for (int x = 0; x < 3; ++x) {
const int slot = SlotNo[y][x];
const int difficulty = ClientTools::g.Difficulty[slot];
if (difficulty == 0) {
s += QStringLiteral("SUP |");
} else if (difficulty < 0) {
s += QStringLiteral("--- |");
} else {
if (slot >= 6 && slot <= 8) { // check multi control
if (ClientTools::g.Difficulty[slot + 3] >= 0)
s += shortName(slot + 3) + QLatin1Char('+');
if (ClientTools::g.Difficulty[slot + 6] >= 0)
s += shortName(slot + 6) + QLatin1Char('+');
}
s += shortName(slot) + QStringLiteral(" | ");
}
}
ui->list->appendPlainText(s);
}
QScrollBar *vBar = ui->list->verticalScrollBar();
vBar->setValue(vBar->maximum());
}
void LogDlg::setMaxLevel(int value, int checkedIndex)
{
maxLevel = value;