implemented main window
This commit is contained in:
1 parent
a11ce3005c
commit
5d5a502976
11 files changed
+2876
-37
No files matched your search
@@ -35,7 +35,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -47,15 +47,32 @@ MainScreen::MainScreen(QWidget *parent) : DrawDlg(parent)
|
||||
mainScreen = this;
|
||||
IsoEngine::init([](int emix) { return initEnemyModel(emix); });
|
||||
|
||||
mainScreenZoomToCity = [this](int loc, bool nextUnitOnClose, int showEvent) {
|
||||
Q_UNUSED(nextUnitOnClose);
|
||||
Q_UNUSED(showEvent);
|
||||
// TODO: needs the real main map (not ported yet) to actually
|
||||
// scroll/focus the view - just opens the city dialog for now.
|
||||
cityDlg().showNewContent(WindowMode::Persistent, loc, 0);
|
||||
return true;
|
||||
// Unlike the dialogs, the main screen is a normal resizable window.
|
||||
setWindowFlag(Qt::FramelessWindowHint, false);
|
||||
setWindowTitle(QStringLiteral("C-evo"));
|
||||
setMinimumSize(800, 480);
|
||||
resize(800, 480);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
onCloseQuery = [this] {
|
||||
// TODO: when not closable, idle and playing, the original resigns (mResign.Click).
|
||||
return m_closable;
|
||||
};
|
||||
|
||||
m_mainMap = std::make_unique<IsoEngine::IsoMap>();
|
||||
m_noMap = std::make_unique<IsoEngine::IsoMap>();
|
||||
m_noMapPanel = std::make_unique<IsoEngine::IsoMap>();
|
||||
m_miniMap = std::make_unique<MiniMap>();
|
||||
m_panel.canvas().font().assign(UniFont[static_cast<std::size_t>(FontType::Small)]);
|
||||
m_topBar.canvas().font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||
m_offscreen.canvas().font().assign(UniFont[static_cast<std::size_t>(FontType::Small)]);
|
||||
createControls();
|
||||
|
||||
mainScreenZoomToCity = [this](int loc, bool nextUnitOnClose, int showEvent) {
|
||||
return zoomToCity(loc, nextUnitOnClose, showEvent);
|
||||
};
|
||||
mainScreenCityClosed = [this](int activateUix, bool stepFocus, bool selectFocus) {
|
||||
cityClosed(activateUix, stepFocus, selectFocus);
|
||||
};
|
||||
mainScreenCityClosed = [](int, bool, bool) {};
|
||||
mainScreenUpdateViews = [this](bool updateCityScreen) { updateViews(updateCityScreen); };
|
||||
mainScreenRepaintAll = [this] { repaintAll(); };
|
||||
mainScreenDipCall = [this](int command) { return dipCall(command); };
|
||||
@@ -396,18 +413,28 @@ int MainScreen::offerCall(TOffer &offer)
|
||||
void MainScreen::updateViews(bool updateCityScreen)
|
||||
{
|
||||
ClientTools::sumCities(taxSum, scienceSum);
|
||||
// TODO: needs PanelPaint/the real main map (not ported yet).
|
||||
panelPaint();
|
||||
listDlg().ecoChange();
|
||||
natStatDlg().ecoChange();
|
||||
if (updateCityScreen)
|
||||
cityDlg().smartUpdateContent();
|
||||
}
|
||||
|
||||
void MainScreen::setAIName(int, const QString &)
|
||||
void MainScreen::setAIName(int p, const QString &name)
|
||||
{
|
||||
// TODO: AILogo[]/GetAppSharePath() (per-player AI logo bitmap) - not
|
||||
// ported, no consumer reads it yet either (main window/panel not
|
||||
// ported); no-op for now.
|
||||
auto &logo = m_aiLogo[static_cast<std::size_t>(p)];
|
||||
if (name.isEmpty()) {
|
||||
logo.reset();
|
||||
return;
|
||||
}
|
||||
if (!logo)
|
||||
logo = std::make_unique<Dpi::Bitmap>();
|
||||
const QString fileName = getAppSharePath(name + QLatin1String(PngExt));
|
||||
if (!QFileInfo::exists(fileName)) {
|
||||
logo.reset();
|
||||
return;
|
||||
}
|
||||
logo->loadFromFile(fileName);
|
||||
}
|
||||
|
||||
bool MainScreen::contactRefused(int p, const QString &item)
|
||||
@@ -437,9 +464,11 @@ bool MainScreen::contactRefused(int p, const QString &item)
|
||||
void MainScreen::getTribeList()
|
||||
{
|
||||
unusedTribeFiles.clear();
|
||||
const QDir dir(localizedFilePath(QStringLiteral("Tribes")));
|
||||
const QString ext = QLatin1String(CevoTribeExt);
|
||||
const QStringList files = dir.entryList({QLatin1Char('*') + ext}, QDir::Files, QDir::Name);
|
||||
const QStringList filter = {QLatin1Char('*') + ext};
|
||||
QStringList files = QDir(localizedFilePath(QStringLiteral("Tribes"))).entryList(filter, QDir::Files, QDir::Name);
|
||||
if (files.isEmpty()) // a localization may only translate some of the tribes
|
||||
files = QDir(getAppSharePath(QStringLiteral("Tribes"))).entryList(filter, QDir::Files, QDir::Name);
|
||||
for (const QString &file : files) {
|
||||
const QString baseName = file.left(file.length() - ext.length());
|
||||
QString name;
|
||||
@@ -547,11 +576,23 @@ void MainScreen::initModule()
|
||||
unusedTribeFiles.clear();
|
||||
Tribes::hGrStdUnits = loadGraphicSet(QStringLiteral("StdUnits") + QLatin1String(PngExt));
|
||||
initSmallImp();
|
||||
m_verticalScrollBar = std::make_unique<PVScrollBar>(this);
|
||||
m_verticalScrollBar->scrollBar()->hide();
|
||||
connect(m_verticalScrollBar.get(), &PVScrollBar::updated, this, [this] {
|
||||
// Do not scroll with the mouse wheel to and above the max value.
|
||||
if (m_verticalScrollBar->position() > m_verticalScrollBar->max() - 1)
|
||||
m_verticalScrollBar->setPosition(std::max(0, m_verticalScrollBar->max() - 1));
|
||||
panelPaint();
|
||||
updateNow();
|
||||
});
|
||||
if (ClientTools::g.lx > 0)
|
||||
resizeControls();
|
||||
}
|
||||
|
||||
void MainScreen::doneModule()
|
||||
{
|
||||
unusedTribeFiles.clear();
|
||||
m_verticalScrollBar.reset();
|
||||
}
|
||||
|
||||
void MainScreen::rememberPeaceViolation()
|
||||
|
||||
Reference in new issue
Block a user