mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-26 09:44:40 +00:00
fix menu of levels
This commit is contained in:
parent
c3453d63df
commit
7a32ce13c4
@ -30,6 +30,8 @@ QByteArray ClientApp::initTheme() {
|
||||
ClientApp::ClientApp() {
|
||||
_engine = new Engine();
|
||||
_menu = new MainMenuModel();
|
||||
|
||||
connect(_menu, &MainMenuModel::sigNewGame, this , &ClientApp::start);
|
||||
}
|
||||
|
||||
ClientApp::~ClientApp() {
|
||||
|
@ -28,9 +28,9 @@ struct WordlData {
|
||||
/**
|
||||
* @brief The ClientApp class This is main class of the Game engine.
|
||||
*/
|
||||
class SNAKEPROJECT_EXPORT ClientApp
|
||||
class SNAKEPROJECT_EXPORT ClientApp : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClientApp();
|
||||
virtual ~ClientApp();
|
||||
|
@ -46,6 +46,9 @@ const IWorldItem *IWorld::getItem(int id) const {
|
||||
|
||||
bool IWorld::init() {
|
||||
|
||||
if (isInit())
|
||||
return true;
|
||||
|
||||
_worldRules = initWorldRules();
|
||||
_hdrMap = initHdrBackGround();
|
||||
_player = initPlayer();
|
||||
@ -54,9 +57,12 @@ bool IWorld::init() {
|
||||
|
||||
setCameraReleativePosition(initCameraPosition());
|
||||
|
||||
if (!_worldRules->size())
|
||||
if (!_worldRules->size()) {
|
||||
deinit();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
worldChanged(*_worldRules->begin());
|
||||
|
||||
return true;
|
||||
@ -71,12 +77,24 @@ void IWorld::clearItems() {
|
||||
}
|
||||
|
||||
void IWorld::deinit() {
|
||||
delete _player;
|
||||
if (_player) {
|
||||
delete _player;
|
||||
_player = nullptr;
|
||||
}
|
||||
|
||||
if (_worldRules) {
|
||||
delete _worldRules;
|
||||
_worldRules = nullptr;
|
||||
}
|
||||
|
||||
if (_userInterface) {
|
||||
delete _userInterface;
|
||||
_userInterface = nullptr;
|
||||
}
|
||||
|
||||
clearItems();
|
||||
_hdrMap = "";
|
||||
|
||||
delete _worldRules;
|
||||
}
|
||||
|
||||
void IWorld::generateGround() {
|
||||
@ -124,6 +142,10 @@ IControl *IWorld::userInterface() const {
|
||||
return _userInterface;
|
||||
}
|
||||
|
||||
bool IWorld::isInit() const {
|
||||
return _userInterface && _player && _worldRules;
|
||||
}
|
||||
|
||||
void IWorld::setCameraReleativePosition(const QVector3D &newCameraReleativePosition) {
|
||||
if (_cameraReleativePosition == newCameraReleativePosition)
|
||||
return;
|
||||
|
@ -154,6 +154,12 @@ public:
|
||||
*/
|
||||
IControl *userInterface() const;
|
||||
|
||||
/**
|
||||
* @brief isInit This method return true if the object initialized correctly else false.
|
||||
* @return true if the object initialized correctly else false.
|
||||
*/
|
||||
bool isInit() const;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief sigGameFinished This signal emit when game are finished
|
||||
@ -185,6 +191,11 @@ protected:
|
||||
void setCameraReleativePosition(const QVector3D &newCameraReleativePosition);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief init This method initialize world object.
|
||||
* @note If object alredy initalize then this method do nothing.
|
||||
* @return
|
||||
*/
|
||||
bool init();
|
||||
void deinit();
|
||||
|
||||
|
@ -36,7 +36,6 @@ Item {
|
||||
onClicked: {
|
||||
selectLvl.open()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MainMenuButton {
|
||||
@ -47,7 +46,6 @@ Item {
|
||||
settingsPopUp.open();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MainMenuButton {
|
||||
@ -92,19 +90,19 @@ Item {
|
||||
source: SelectLvlView {
|
||||
id: view
|
||||
model: item1.model ? item1.model.availableLvlsModel: null
|
||||
|
||||
onStart: {
|
||||
if (!item1.model)
|
||||
return;
|
||||
|
||||
item1.model.newGame(view.selectedLvl)
|
||||
}
|
||||
}
|
||||
|
||||
standardButtons: Dialog.Cancel | Dialog.Ok
|
||||
modal: false;
|
||||
width: 12 * metrix.controlPtMaterial
|
||||
height: 8 * metrix.controlPtMaterial;
|
||||
|
||||
onAccepted: {
|
||||
if (!item1.model)
|
||||
return;
|
||||
|
||||
item1.model.newGame(view.selectedLvl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,54 @@
|
||||
import QtQuick 2.15
|
||||
import ViewSolutionsModule 1.0
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Controls.Material 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
ListView {
|
||||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
property alias model: list.model
|
||||
property string selectedLvl: ""
|
||||
orientation: ListView.Horizontal
|
||||
clip: true
|
||||
|
||||
delegate: ImageView {
|
||||
property var data : modelData
|
||||
signal start(var lvlName)
|
||||
|
||||
source: data.image
|
||||
text: data.name
|
||||
ListView {
|
||||
id: list
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
orientation: ListView.Horizontal
|
||||
clip: true
|
||||
|
||||
width: root.height * 1.5
|
||||
height: root.height * 0.9
|
||||
delegate: ImageView {
|
||||
property var data : modelData
|
||||
hoverColor: "#90f6ff"
|
||||
selectedColor: "#90f6ff"
|
||||
|
||||
onClicked: {
|
||||
selectedLvl = text
|
||||
source: data.image
|
||||
text: data.name
|
||||
|
||||
width: list.height * 1.5
|
||||
height: list.height * 0.9
|
||||
selected: selectedLvl === data.name
|
||||
|
||||
onClicked: {
|
||||
selectedLvl = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
|
||||
Layout.alignment: Layout.right
|
||||
|
||||
text: qsTr("Start")
|
||||
enabled: selectedLvl.length
|
||||
|
||||
onClicked: {
|
||||
root.start(selectedLvl)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -23,17 +23,6 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Scene</name>
|
||||
<message>
|
||||
<source>lvl long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>general long: </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsView</name>
|
||||
<message>
|
||||
|
@ -14,7 +14,7 @@ IPlayer *World::initPlayer() const {
|
||||
}
|
||||
|
||||
WorldRule *World::initWorldRules() const {
|
||||
return {};
|
||||
return new WorldRule{};
|
||||
}
|
||||
|
||||
QString World::initHdrBackGround() const {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 792627a1dd1723882c33fef13bb6dfdb4330df48
|
||||
Subproject commit 9a94f1fd90b8c2a918242dd73315a0ad80b59b84
|
Loading…
x
Reference in New Issue
Block a user