1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

Added initial version of start game UI

This commit is contained in:
Ivan Savenko 2024-11-24 17:33:25 +00:00
parent 4d08ac92fb
commit d46eadab79
7 changed files with 914 additions and 60 deletions

View File

@ -15,6 +15,7 @@ set(launcher_SRCS
modManager/imageviewer_moc.cpp
modManager/chroniclesextractor.cpp
settingsView/csettingsview_moc.cpp
startGame/StartGameTab.cpp
firstLaunch/firstlaunch_moc.cpp
main.cpp
helper.cpp
@ -46,6 +47,7 @@ set(launcher_HEADERS
modManager/imageviewer_moc.h
modManager/chroniclesextractor.h
settingsView/csettingsview_moc.h
startGame/StartGameTab.h
firstLaunch/firstlaunch_moc.h
mainwindow_moc.h
languages.h
@ -63,6 +65,7 @@ set(launcher_FORMS
settingsView/csettingsview_moc.ui
firstLaunch/firstlaunch_moc.ui
mainwindow_moc.ui
startGame/StartGameTab.ui
updatedialog_moc.ui
)

View File

@ -47,7 +47,6 @@ void MainWindow::computeSidePanelSizes()
ui->modslistButton,
ui->settingsButton,
ui->aboutButton,
ui->startEditorButton,
ui->startGameButton
};
@ -82,7 +81,6 @@ MainWindow::MainWindow(QWidget * parent)
ui->modslistButton->setIcon(QIcon{":/icons/menu-mods.png"});
ui->settingsButton->setIcon(QIcon{":/icons/menu-settings.png"});
ui->aboutButton->setIcon(QIcon{":/icons/about-project.png"});
ui->startEditorButton->setIcon(QIcon{":/icons/menu-editor.png"});
ui->startGameButton->setIcon(QIcon{":/icons/menu-game.png"});
#ifndef VCMI_MOBILE
@ -110,7 +108,7 @@ MainWindow::MainWindow(QWidget * parent)
bool h3DataFound = CResourceHandler::get()->existsResource(ResourcePath("DATA/GENRLTXT.TXT"));
if (h3DataFound && setupCompleted)
ui->tabListWidget->setCurrentIndex(TabRows::MODS);
ui->tabListWidget->setCurrentIndex(TabRows::START);
else
enterSetup();
@ -147,7 +145,6 @@ void MainWindow::detectPreferredLanguage()
void MainWindow::enterSetup()
{
ui->startGameButton->setEnabled(false);
ui->startEditorButton->setEnabled(false);
ui->settingsButton->setEnabled(false);
ui->aboutButton->setEnabled(false);
ui->modslistButton->setEnabled(false);
@ -160,13 +157,18 @@ void MainWindow::exitSetup()
writer->Bool() = true;
ui->startGameButton->setEnabled(true);
ui->startEditorButton->setEnabled(true);
ui->settingsButton->setEnabled(true);
ui->aboutButton->setEnabled(true);
ui->modslistButton->setEnabled(true);
ui->tabListWidget->setCurrentIndex(TabRows::MODS);
}
void MainWindow::switchToStartTab()
{
ui->startGameButton->setEnabled(true);
ui->tabListWidget->setCurrentIndex(TabRows::START);
}
void MainWindow::switchToModsTab()
{
ui->startGameButton->setEnabled(true);
@ -196,8 +198,7 @@ MainWindow::~MainWindow()
void MainWindow::on_startGameButton_clicked()
{
hide();
startGame({});
switchToStartTab();
}
void MainWindow::on_startEditorButton_clicked()

View File

@ -40,6 +40,7 @@ class MainWindow : public QMainWindow
SETTINGS = 1,
SETUP = 2,
ABOUT = 3,
START = 4,
};
public:
@ -55,6 +56,7 @@ public:
void enterSetup();
void exitSetup();
void switchToModsTab();
void switchToStartTab();
protected:
void changeEvent(QEvent * event) override;

View File

@ -180,55 +180,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="startEditorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>5</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Map Editor</string>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="startGameButton">
<property name="sizePolicy">
@ -251,7 +202,6 @@
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -265,16 +215,19 @@
</size>
</property>
<property name="checkable">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
@ -292,12 +245,13 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>3</number>
<number>4</number>
</property>
<widget class="CModListView" name="modlistView"/>
<widget class="CSettingsView" name="settingsView"/>
<widget class="FirstLaunchView" name="setupView"/>
<widget class="AboutProjectView" name="aboutView"/>
<widget class="StartGameTab" name="startGameView"/>
</widget>
</item>
</layout>
@ -329,6 +283,12 @@
<header>aboutProject/aboutproject_moc.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>StartGameTab</class>
<extends>QWidget</extends>
<header>startGame/StartGameTab.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -0,0 +1,32 @@
#include "StartGameTab.h"
#include "ui_StartGameTab.h"
#include "../mainwindow_moc.h"
#include "../main.h"
StartGameTab::StartGameTab(QWidget * parent)
: QWidget(parent)
, ui(new Ui::StartGameTab)
{
ui->setupUi(this);
}
StartGameTab::~StartGameTab()
{
delete ui;
}
MainWindow * StartGameTab::getMainWindow()
{
foreach(QWidget *w, qApp->allWidgets())
if(QMainWindow* mainWin = qobject_cast<QMainWindow*>(w))
return dynamic_cast<MainWindow *>(mainWin);
return nullptr;
}
void StartGameTab::on_buttonPlay_clicked()
{
getMainWindow()->hide();
startGame({});
}

View File

@ -0,0 +1,29 @@
#ifndef STARTGAMETAB_H
#define STARTGAMETAB_H
#include <QWidget>
namespace Ui
{
class StartGameTab;
}
class MainWindow;
class StartGameTab : public QWidget
{
Q_OBJECT
MainWindow * getMainWindow();
public:
explicit StartGameTab(QWidget * parent = nullptr);
~StartGameTab();
private slots:
void on_buttonPlay_clicked();
private:
Ui::StartGameTab * ui;
};
#endif // STARTGAMETAB_H

View File

@ -0,0 +1,827 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StartGameTab</class>
<widget class="QWidget" name="StartGameTab">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>757</width>
<height>372</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,1,1">
<item row="0" column="2">
<widget class="QToolButton" name="buttonPreset">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Preset %1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="buttonGameFiles">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Game Data Files</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>206</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="1,0,0,0,0,0,0">
<item row="3" column="0">
<widget class="QPushButton" name="buttonPresetImport">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Import from Clipboard</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="buttonPresetExport">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Export to Clipboard</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="buttonPresetNew">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Create New Preset</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="comboBoxModPresets">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<item>
<property name="text">
<string>Current Preset</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="buttonPresetDelete">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Delete Current Preset</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="buttonEngine">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QScrollArea" name="scrollArea_2">
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>342</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="7" column="0">
<widget class="QLabel" name="labelMissingFiles">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Unsupported or corrupted game data detected!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelChronicles">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Heroes Chronicles:
0/8 installed</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="buttonMissingVideoHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="buttonMissingSoundtrackHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="buttonInstallTranslation">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Install Translation</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="buttonInstallTranslationHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="buttonActivateTranslationHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelMissingSoundtrack">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>No soundtrack detected!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="buttonMissingFilesHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelMissingCampaigns">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Armaggedon's Blade campaigns are missing!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="buttonHelpImportFiles">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="buttonChroniclesHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelMissingVideo">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>No video files detected!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="buttonMissingCampaignsHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="buttonActivateTranslation">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Activate Translation</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="buttonImportFiles">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Import files</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="buttonUpdateMods">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Update %1 mods</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="buttonUpdateModsHelp">
<property name="minimumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QScrollArea" name="scrollArea_3">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>206</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="6" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelUpdateAvailable">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Update to %1 available</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="buttonUpdateCheck">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Check For Updates</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="buttonOpenDownloads">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Go to Downloads Page</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="buttonOpenChangelog">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Go to Changelog Page</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelUpdateNotFound">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>You are using the latest version</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>9</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonGameResume">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>Resume</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonGameStart">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string>Play</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonGameEditor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>Editor</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>