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

+43 -15
View File
@@ -31,16 +31,14 @@
//
// PORT STATUS: served so far - cDebugMessage, cShowNego, cInitModule,
// cReleaseModule, cHelpOnly/cStartHelp/cStartCredits, cNewGame/cLoadGame/
// cMovie/cNewMap, cGetReady/cReplay, cBreakGame, the pure message commands
// (cShowCancelTreaty*, cShowSupportAllianceAgainst, cShowPeaceViolation,
// cShowMissionResult, cShowShipChange, cShowGreatLibTech), cShowEndContact
// and the client exclusive commands. Still missing because they need
// InitTurn()/the main map and panel (not ported): cShowGame, cTurn/
// cResume/cContinue/cMovieTurn/cMovieEndTurn, cEditMap, scContact and
// scDipStart..scDipBreak, cShowUnitChanged/CityChanged/AfterMove/
// AfterAttack/Moving/Capturing/Attacking, cRefreshDebugMap. Screen-only
// side effects inside the served commands (button visibility, panel
// repaint, sounds) are marked TODO.
// cMovie/cNewMap, cGetReady/cReplay, cBreakGame, cShowGame, cShowTurnChange,
// cTurn/cResume/cContinue, cMovieTurn/cMovieEndTurn, cEditMap, scContact,
// scDipStart..scDipBreak, the pure message commands (cShowCancelTreaty*,
// cShowSupportAllianceAgainst, cShowPeaceViolation, cShowMissionResult,
// cShowShipChange, cShowGreatLibTech), cShowEndContact and the client
// exclusive commands. Still missing because they need MoveUnit/ShowMove
// (not ported): cShowUnitChanged/CityChanged/AfterMove/AfterAttack/Moving/
// Capturing/Attacking, cRefreshDebugMap.
#include "Term.MainScreen.h"
@@ -50,6 +48,7 @@
#include "Cevo/CmdList.h"
#include "Global.h"
#include "Messg.h"
#include "Sound.h"
#include "Tribes.h"
#include <QApplication>
@@ -137,7 +136,6 @@ void initPersistentData(PersistentData &data)
void MainScreen::client(int command, int newPlayer, void *data)
{
qWarning("TMPDEBUG client(%x, %d)", command, newPlayer);
TNewGameData &g = ClientTools::g;
const auto intData = [data] { return *static_cast<int *>(data); };
const auto isLocalSession = [] { return !ClientTools::isMultiPlayerGame(); };
@@ -302,7 +300,8 @@ void MainScreen::client(int command, int newPlayer, void *data)
return;
case cBreakGame:
// TODO: SaveSettings() needs the settings store (not ported).
saveSettings();
saveConfig();
if (m_cityDlg)
m_cityDlg->closeAction = CityScreen::CityCloseAction::None;
applyToVisibleForms(FormAction::Close);
@@ -339,7 +338,15 @@ void MainScreen::client(int command, int newPlayer, void *data)
canvas.brush().setStyle(Qt::NoBrush);
canvas.end();
}
show();
if (fullScreen) {
m_restoredBounds = termBounds;
m_formFullScreen = true;
showFullScreen();
} else {
m_formFullScreen = false;
setGeometry(termBounds);
show();
}
updateNow();
resizeControls();
m_repaintOnResize = true;
@@ -449,7 +456,6 @@ void MainScreen::client(int command, int newPlayer, void *data)
m_eot->setVisible(false);
helpDlg().difficulty = 0;
m_brushType = fGrass;
// TODO: UpdateInterface (mFillMap.Enabled) belongs to the menus, which are not ported.
m_brushLoc = -1;
m_edited = false;
IsoEngine::unFocus = -1;
@@ -502,13 +508,24 @@ void MainScreen::client(int command, int newPlayer, void *data)
receivedOffer = *static_cast<TOffer *>(data);
initAllEnemyModels();
}
// TODO: the sounds played for scDipStart/scDipCancelTreaty/scDipAccept (sound is not ported).
if (command == scDipStart)
Sound::play(QStringLiteral("CONTACT_%1").arg(ClientTools::myRO->Attitude[dipMem[static_cast<std::size_t>(newPlayer)].pContact]));
else if (command == scDipCancelTreaty)
Sound::play(QStringLiteral("CANCELTREATY"));
if (command == scDipAccept) { // remember delivered and received prices
DipMemEntry &mem = dipMem[static_cast<std::size_t>(ClientTools::me)];
for (int i = 0; i < mem.sentOffer.nDeliver; ++i)
mem.deliveredPrices.set(static_cast<std::size_t>(mem.sentOffer.Price[i] >> 24));
for (int i = 0; i < mem.sentOffer.nCost; ++i)
mem.receivedPrices.set(static_cast<std::size_t>(mem.sentOffer.Price[mem.sentOffer.nDeliver + i] >> 24));
bool isTreatyDeal = false;
for (int i = 0; i < receivedOffer.nDeliver + receivedOffer.nCost; ++i) {
if ((mem.sentOffer.Price[i] & opMask) == opTreaty) {
isTreatyDeal = true;
break;
}
}
Sound::play(isTreatyDeal ? QStringLiteral("NEWTREATY") : QStringLiteral("ACCEPTOFFER"));
}
negoDlg().start();
m_idle = true;
@@ -561,6 +578,17 @@ void MainScreen::client(int command, int newPlayer, void *data)
}
return;
case cShowUnitChanged:
case cShowCityChanged:
case cShowAfterMove:
case cShowAfterAttack:
case cShowMoving:
case cShowCapturing:
case cShowAttacking:
case cRefreshDebugMap:
clientShow(command, newPlayer, data);
return;
case cShowEndContact:
endNego();
return;