main window and many fixes

This commit is contained in:
Geoffray Levasseur committed 2026-11-04 17:35:34 +01:00
1 parent 80c329a697
commit 69700f8b65
18 files changed
+3280 -95

No files matched your search

+54 -36
View File
@@ -35,6 +35,7 @@
#include "Cevo/Protocol.h"
#include "ClientTools.h"
#include "Diagram.h"
#include "Global.h"
#include "Term.h"
#include "Tribes.h"
#include "UnitStat.h"
@@ -61,6 +62,7 @@ MessgExDlg *instance = nullptr;
MessgExDlg::MessgExDlg(QWidget *parent) : BaseMessgDlg(parent), ui(new Ui::MessgExDlg)
{
ui->setupUi(this);
initButtons();
iconKind = MessageIconKind::None;
centerTo = 0;
openSound.clear();
@@ -132,7 +134,14 @@ void MessgExDlg::keyPressEvent(QKeyEvent *event)
void MessgExDlg::showEvent(QShowEvent *event)
{
BaseMessgDlg::showEvent(event);
setWindowTitle(tr("Message"));
prepareLayout();
}
// Sizes and arranges the dialog for its content; also called before show() because some window systems
// ignore geometry changes made once the window is mapped.
void MessgExDlg::prepareLayout()
{
setWindowTitle(phrases.lookup(QStringLiteral("TITLE_MESSAGE")));
if (iconKind == MessageIconKind::EnemyArmy)
Term::initAllEnemyModels();
@@ -155,26 +164,24 @@ void MessgExDlg::showEvent(QShowEvent *event)
}
ui->removeBtn->move(width() - 38, ui->removeBtn->y());
// TODO: needs Phrases[] (StringTables.pas, not ported yet) - plain
// English literals until localization is ported.
switch (kind) {
case MessageKind::YesNo:
case MessageKind::YesNoCancel:
ui->button1->setCaption(tr("Yes"));
ui->button2->setCaption(tr("No"));
ui->button1->setCaption(phrases.lookup(QStringLiteral("BTN_YES")));
ui->button2->setCaption(phrases.lookup(QStringLiteral("BTN_NO")));
break;
case MessageKind::OkCancel:
case MessageKind::OkCancelRemove:
ui->button1->setCaption(tr("OK"));
ui->button2->setCaption(tr("Cancel"));
ui->button1->setCaption(phrases.lookup(QStringLiteral("BTN_OK")));
ui->button2->setCaption(phrases.lookup(QStringLiteral("BTN_CANCEL")));
break;
default:
ui->button1->setCaption(tr("OK"));
ui->button2->setCaption(tr("Info"));
ui->button1->setCaption(phrases.lookup(QStringLiteral("BTN_OK")));
ui->button2->setCaption(phrases.lookup(QStringLiteral("BTN_INFO")));
break;
}
ui->button3->setCaption(tr("Cancel"));
ui->removeBtn->setToolTip(tr("Delete saved game"));
ui->button3->setCaption(phrases.lookup(QStringLiteral("BTN_CANCEL")));
ui->removeBtn->setToolTip(phrases.lookup(QStringLiteral("BTN_DELGAME")));
switch (iconKind) {
case MessageIconKind::Imp:
@@ -248,7 +255,7 @@ void MessgExDlg::showEvent(QShowEvent *event)
Dpi::ModalResult MessgExDlg::showModal()
{
setWindowTitle(tr("Message"));
prepareLayout();
if (Term::gameMode == cMovie) {
movieCancelled = false;
show();
@@ -514,49 +521,60 @@ void setInstance(MessgExDlg *dlg)
instance = dlg;
}
namespace {
MessgExDlg *current()
{
return instance ? instance : Term::mainScreenMessgExDlg();
}
} // namespace
void soundMessageEx(const QString &simpleText, const QString &soundItem)
{
if (!instance)
MessgExDlg *dlg = current();
if (!dlg)
return;
instance->messageText = simpleText;
instance->openSound = soundItem;
instance->kind = MessageKind::Ok;
instance->showModal();
dlg->messageText = simpleText;
dlg->openSound = soundItem;
dlg->kind = MessageKind::Ok;
dlg->showModal();
}
void tribeMessage(int p, const QString &simpleText, const QString &soundItem)
{
if (!instance)
MessgExDlg *dlg = current();
if (!dlg)
return;
instance->openSound = soundItem;
instance->messageText = simpleText;
instance->kind = MessageKind::Ok;
instance->iconKind = MessageIconKind::Tribe;
instance->iconIndex = p;
instance->showModal();
dlg->openSound = soundItem;
dlg->messageText = simpleText;
dlg->kind = MessageKind::Ok;
dlg->iconKind = MessageIconKind::Tribe;
dlg->iconIndex = p;
dlg->showModal();
}
Dpi::ModalResult simpleQuery(MessageKind queryKind, const QString &simpleText, const QString &soundItem)
{
if (!instance)
MessgExDlg *dlg = current();
if (!dlg)
return Dpi::ModalResult::None;
instance->messageText = simpleText;
instance->openSound = soundItem;
instance->kind = queryKind;
return instance->showModal();
dlg->messageText = simpleText;
dlg->openSound = soundItem;
dlg->kind = queryKind;
return dlg->showModal();
}
void contextMessage(const QString &simpleText, const QString &soundItem, Help::LinkCategory contextKind,
int contextNo)
{
if (!instance)
MessgExDlg *dlg = current();
if (!dlg)
return;
instance->messageText = simpleText;
instance->openSound = soundItem;
instance->kind = MessageKind::OkHelp;
instance->helpKind = contextKind;
instance->helpNo = contextNo;
instance->showModal();
dlg->messageText = simpleText;
dlg->openSound = soundItem;
dlg->kind = MessageKind::OkHelp;
dlg->helpKind = contextKind;
dlg->helpNo = contextNo;
dlg->showModal();
}
} // namespace MessgEx