final ports and first fixes

This commit is contained in:
Geoffray Levasseur committed 2026-11-04 11:55:54 +01:00
1 parent 77690cbd96
commit 6f3556009a
23 files changed
+2302 -41

No files matched your search

+173
View File
@@ -0,0 +1,173 @@
// This file is part of c-evo-evo.
//
// This software is governed by the CeCILL license under French law and
// abiding by the rules of distribution of free software. You can use,
// modify and/or redistribute the software under the terms of the CeCILL
// license as circulated by CEA, CNRS and INRIA at the following URL
// "http://www.cecill.info".
//
// As a counterpart to the access to the source code and rights to copy,
// modify and redistribute granted by the license, users are provided only
// with a limited warranty and the software's author, the holder of the
// economic rights, and the successive licensors have only limited
// liability.
//
// In this respect, the user's attention is drawn to the risks associated
// with loading, using, modifying and/or developing or reproducing the
// software by the user in light of its specific status of free software,
// that may mean that it is complicated to manipulate, and that also
// therefore means that it is reserved for developers and experienced
// professionals having in-depth computer knowledge. Users are therefore
// encouraged to load and test the software's suitability as regards their
// requirements in conditions enabling the security of their systems and/or
// data to be ensured and, more generally, to use and operate it in the
// same conditions as regards security.
//
// The fact that you are presently reading this means that you have had
// knowledge of the CeCILL license and that you accept its terms.
#pragma once
#include "Back.h"
#include "Brain.h"
#include "Cevo/CevoBaseWin.h"
#include "Cevo/FileList.h"
#include "Languages.h"
#include "MiniMap.h"
#include <QPoint>
#include <array>
#include <memory>
#include <vector>
class QMenu;
QT_BEGIN_NAMESPACE
namespace Ui {
class StartDlg;
}
QT_END_NAMESPACE
namespace Cevo {
class ButtonC;
class DirectDlg;
// Equivalent of Start.pas's TStartDlg: the start screen - tabs for the main
// menu, the map editor, new games and earlier games, with the player slot
// setup, difficulty/world options, the map preview and the Start button.
class StartDlg : public BufferedDrawDlg {
Q_OBJECT
public:
enum class Page { StartRandom, StartMap, NoLoad, Load, EditRandom, EditMap, Main };
enum class Tab { Main, Map, NewGame, PreviousGame };
enum class MainAction { Config, Manual, Credits, AIDev, Web, None };
explicit StartDlg(DirectDlg *direct, QWidget *parent = nullptr);
~StartDlg() override;
Background *background() const { return m_background.get(); }
Languages &languages() { return m_languages; }
// Called by DirectDlg when a game ends or a map was edited.
void updateFormerGames();
void updateMaps(bool selectLastMap);
protected:
void offscreenPaint() override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
bool eventFilter(QObject *watched, QEvent *event) override;
private:
struct PlayerSlot {
ButtonC *diffUpBtn = nullptr;
ButtonC *diffDownBtn = nullptr;
ButtonC *multiBtn = nullptr;
bool offerMultiple = false;
};
// Persisted settings (Registry in the original, QSettings here).
void loadConfig();
void saveConfig();
void loadLanguages();
void loadAiBrainsPictures();
void updateInterface();
void showSettings();
void updateMusic();
void drawAction(int y, int iconIndex, const QString &headerItem, const QString &textItem);
void paintInfo();
void changePage(Page newPage);
void changeTab(Tab newTab);
void smartInvalidate(int x0, int y0, int x1, int y1, bool invalidateTab0 = false);
void applyPageVisibility();
void unlistBackupFile(QString fileName);
// The list shown on the current tab.
FileList &currentFileList();
FileItem *selectedFileItem();
void initPopup(int playerIndex);
void offerBrain(QMenu &menu, Brain *brain, int fixedLines);
void brainClicked(int brainIndex);
void startClicked();
void listClicked();
void listSelectionChanged();
void renameClicked();
void deleteClicked();
void diffClicked(QWidget *sender);
void multiClicked(QWidget *sender);
void up1Clicked();
void down1Clicked();
void up2Clicked();
void down2Clicked();
void customizeClicked();
void autoDiffUpClicked();
void autoDiffDownClicked();
void autoEnemyUpClicked();
void autoEnemyDownClicked();
void replayClicked();
int m_worldSize = 0;
int m_startLandMass = 0;
int m_maxTurn = 800;
int m_autoEnemies = 8;
int m_autoDiff = 1;
int m_multiControl = 0;
Page m_page = Page::Main;
Tab m_showTab = Tab::NewGame;
Tab m_tab = Tab::NewGame;
int m_diff0 = 2;
Brain *m_brainDefault = nullptr;
int m_mapLandTiles = 0;
int m_mapStartPositions = 0;
int m_loadTurn = 0;
int m_lastTurn = 0; // last turn of the selected former game
int m_slotAvailable = -1;
int m_playerPopupIndex = -1; // slot concerned by the brain context menu
std::array<int, 4> m_listIndex{};
QString m_mapFileName;
FileList m_formerGames;
FileList m_maps;
std::array<PlayerSlot, 9> m_playerSlots;
std::vector<MainAction> m_actionsOffered;
MainAction m_selectedAction = MainAction::None;
bool m_turnValid = false;
bool m_tracking = false;
QString m_defaultAI;
QString m_lastGame;
QString m_lastMap;
DirectDlg *m_direct;
std::unique_ptr<Background> m_background;
Dpi::Bitmap m_emptyPicture;
MiniMap m_miniMap;
Languages m_languages;
Ui::StartDlg *ui;
};
} // namespace Cevo