Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Schurade committed Dec 6, 2020
1 parent 7a88e74 commit 8c442d4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 55 deletions.
11 changes: 3 additions & 8 deletions src/gui/aggregatorloadgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include "../base/io.h"

#include <QDebug>

#include <QDateTime>
#include <QDebug>
#include <QDir>
Expand All @@ -33,10 +31,8 @@
#include <QJsonValue>
#include <QStandardPaths>


AggregatorLoadGame::AggregatorLoadGame( QObject* parent )
{

}

AggregatorLoadGame::~AggregatorLoadGame()
Expand All @@ -45,7 +41,7 @@ AggregatorLoadGame::~AggregatorLoadGame()

void AggregatorLoadGame::onRequestKingdoms()
{
QString sfolder = QStandardPaths::writableLocation( QStandardPaths::DocumentsLocation ) + "/My Games/Ingnomia/save/";
QString sfolder = QStandardPaths::writableLocation( QStandardPaths::DocumentsLocation ) + "/My Games/Ingnomia/save/";

m_kingdomList.clear();

Expand Down Expand Up @@ -111,14 +107,14 @@ void AggregatorLoadGame::onRequestSaveGames( const QString path )
GuiSaveInfo gsi;

gsi.folder = path + "/" + sdir;
gsi.dir = sdir;
gsi.dir = sdir;

QJsonDocument jd;
IO::loadFile( gsi.folder + "/game.json", jd );
QJsonArray ja = jd.array();
QVariantMap vm = ja.toVariantList().first().toMap();

gsi.version = IO::versionString( gsi.folder );
gsi.version = IO::versionString( gsi.folder );
gsi.compatible = true;

if ( !IO::saveCompatible( gsi.folder ) )
Expand All @@ -129,7 +125,6 @@ void AggregatorLoadGame::onRequestSaveGames( const QString path )

gsi.name = vm.value( "kingdomName" ).toString();


QFile file( gsi.folder + "/game.json" );
QFileInfo fi( file );
gsi.date = fi.lastModified().toString();
Expand Down
19 changes: 9 additions & 10 deletions src/gui/aggregatorloadgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@

struct GuiSaveInfo
{
QString name;
QString folder;
QString dir;
QString version;
QString date;
bool compatible = true;
QString name;
QString folder;
QString dir;
QString version;
QString date;
bool compatible = true;
};

Q_DECLARE_METATYPE( GuiSaveInfo )


class AggregatorLoadGame : public QObject
{
Q_OBJECT
Expand All @@ -42,13 +41,13 @@ class AggregatorLoadGame : public QObject

private:
QList<GuiSaveInfo> m_kingdomList;
QList<GuiSaveInfo> m_gameList;
QList<GuiSaveInfo> m_gameList;

public slots:
void onRequestKingdoms();
void onRequestSaveGames( const QString path );
void onRequestSaveGames( const QString path );

signals:
void signalKingdoms( const QList<GuiSaveInfo>& kingdoms );
void signalSaveGames( const QList<GuiSaveInfo>& kingdoms );
void signalSaveGames( const QList<GuiSaveInfo>& kingdoms );
};
9 changes: 4 additions & 5 deletions src/gui/xaml/LoadGameModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "LoadGameModel.h"
#include "loadgameproxy.h"

#include "../../base/io.h"
#include "loadgameproxy.h"

#include <NsApp/Application.h>
#include <NsCore/Log.h>
Expand All @@ -42,7 +42,6 @@ SaveItem::SaveItem( QString name, QString path, QString dir, QString version, QS
_version = version.toStdString().c_str();
_date = date.toStdString().c_str();
_compatible = compatible;

}

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -75,7 +74,7 @@ void LoadGameModel::updateSavedKingdoms( const QList<GuiSaveInfo>& kingdoms )
{
_savedKingdoms->Clear();

for( const auto& gsk : kingdoms )
for ( const auto& gsk : kingdoms )
{
_savedKingdoms->Add( MakePtr<SaveItem>( gsk.name, gsk.folder, "", gsk.version, gsk.date ) );
}
Expand All @@ -92,7 +91,7 @@ void LoadGameModel::updateSaveGames( const QList<GuiSaveInfo>& saveGames )
{
_savedGames->Clear();

for( const auto& gsi : saveGames )
for ( const auto& gsi : saveGames )
{
_savedGames->Add( MakePtr<SaveItem>( gsi.name, gsi.folder, gsi.dir, gsi.version, gsi.date, gsi.compatible ) );
}
Expand Down Expand Up @@ -146,7 +145,7 @@ const NoesisApp::DelegateCommand* LoadGameModel::GetLoadGame() const

void LoadGameModel::OnLoadGame( BaseComponent* param )
{
qDebug() << "OnLoadGame";
qDebug() << "OnLoadGame";
if ( _selectedGame )
{
qDebug() << _selectedGame->_path.Str();
Expand Down
2 changes: 0 additions & 2 deletions src/gui/xaml/LoadGameModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class LoadGameModel final : public NoesisApp::NotifyPropertyChangedBase
void SetSelectedGame( SaveItem* item );
SaveItem* GetSelectedGame() const;



NoesisApp::DelegateCommand _loadGame;

Noesis::Ptr<Noesis::ObservableCollection<SaveItem>> _savedKingdoms;
Expand Down
7 changes: 3 additions & 4 deletions src/gui/xaml/ProxyMainView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
*/
#include "ProxyMainView.h"

#include "../eventconnector.h"
#include "../aggregatorsettings.h"
#include "../aggregatorloadgame.h"

#include "../aggregatorsettings.h"
#include "../eventconnector.h"
#include "ViewModel.h"

ProxyMainView::ProxyMainView( QObject* parent ) :
Expand Down Expand Up @@ -70,4 +69,4 @@ void ProxyMainView::onUIScale( float value )
void ProxyMainView::requestLoadScreenUpdate()
{
emit signalRequestLoadScreenUpdate();
}
}
6 changes: 3 additions & 3 deletions src/gui/xaml/ProxyMainView.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ProxyMainView : public QObject

void setParent( IngnomiaGUI::ViewModel* parent );

void requestLoadScreenUpdate();
void requestLoadScreenUpdate();

private:
IngnomiaGUI::ViewModel* m_parent = nullptr;
Expand All @@ -40,8 +40,8 @@ private slots:
void onWindowSize( int w, int h );
void onKeyEsc();

void onUIScale( float value );
void onUIScale( float value );

signals:
void signalRequestLoadScreenUpdate();
void signalRequestLoadScreenUpdate();
};
6 changes: 3 additions & 3 deletions src/gui/xaml/ViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ViewModel::ViewModel()
_showMainMenu = true;
_showGameGUI = false;
_ingame = false;
m_scale = qMax( 1.0f, Config::getInstance().get( "uiscale" ).toFloat() );
m_scale = qMax( 1.0f, Config::getInstance().get( "uiscale" ).toFloat() );
setWindowSize( 1920, 1080 );
}

Expand Down Expand Up @@ -352,7 +352,7 @@ void ViewModel::OnBack( BaseComponent* )
SetState( State::Main );
}
_showMainMenu = true;
_showGameGUI = false;
_showGameGUI = false;
OnPropertyChanged( "ShowMainMenu" );
OnPropertyChanged( "ShowGameGui" );
GameManager::getInstance().setShowMainMenu( true );
Expand Down Expand Up @@ -380,7 +380,7 @@ void ViewModel::OnResume( BaseComponent* )
{
SetState( State::GameRunning );
_showMainMenu = false;
_showGameGUI = true;
_showGameGUI = true;
OnPropertyChanged( "ShowMainMenu" );
OnPropertyChanged( "ShowGameGui" );
GameManager::getInstance().setShowMainMenu( false );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/xaml/ViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ViewModel final : public NoesisApp::NotifyPropertyChangedBase
void OnResume( BaseComponent* param );
void OnFadeInCompleted( BaseComponent* params );
void OnPause( BaseComponent* params );

State GetState() const;
void SetState( State value );

Expand All @@ -119,7 +119,7 @@ class ViewModel final : public NoesisApp::NotifyPropertyChangedBase
NoesisApp::DelegateCommand _backToMain;
NoesisApp::DelegateCommand _resume;
NoesisApp::DelegateCommand _fadeInCompleted;

State _state;
NewGameModel _newGameModel;

Expand Down
20 changes: 10 additions & 10 deletions src/gui/xaml/loadgameproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ LoadGameProxy::LoadGameProxy( QObject* parent ) :
QObject( parent )
{
connect( this, &LoadGameProxy::signalRequestKingdoms, EventConnector::getInstance().aggregatorLoadGame(), &AggregatorLoadGame::onRequestKingdoms, Qt::QueuedConnection );
connect( this, &LoadGameProxy::signalRequestSaveGames, EventConnector::getInstance().aggregatorLoadGame(), &AggregatorLoadGame::onRequestSaveGames, Qt::QueuedConnection );
connect( this, &LoadGameProxy::signalRequestSaveGames, EventConnector::getInstance().aggregatorLoadGame(), &AggregatorLoadGame::onRequestSaveGames, Qt::QueuedConnection );

connect( EventConnector::getInstance().aggregatorLoadGame(), &AggregatorLoadGame::signalKingdoms, this, &LoadGameProxy::onKingdoms, Qt::QueuedConnection );
connect( EventConnector::getInstance().aggregatorLoadGame(), &AggregatorLoadGame::signalSaveGames, this, &LoadGameProxy::onSaveGames, Qt::QueuedConnection );
connect( EventConnector::getInstance().aggregatorLoadGame(), &AggregatorLoadGame::signalKingdoms, this, &LoadGameProxy::onKingdoms, Qt::QueuedConnection );
connect( EventConnector::getInstance().aggregatorLoadGame(), &AggregatorLoadGame::signalSaveGames, this, &LoadGameProxy::onSaveGames, Qt::QueuedConnection );
}

void LoadGameProxy::setParent( IngnomiaGUI::LoadGameModel* parent )
Expand All @@ -38,26 +38,26 @@ void LoadGameProxy::setParent( IngnomiaGUI::LoadGameModel* parent )

void LoadGameProxy::requestKingdoms()
{
emit signalRequestKingdoms();
emit signalRequestKingdoms();
}

void LoadGameProxy::onKingdoms( const QList<GuiSaveInfo>& kingdoms )
{
if( m_parent )
if ( m_parent )
{
m_parent->updateSavedKingdoms( kingdoms );
m_parent->updateSavedKingdoms( kingdoms );
}
}

void LoadGameProxy::requestSaveGames( const QString path )
{
emit signalRequestSaveGames( path );
emit signalRequestSaveGames( path );
}

void LoadGameProxy::onSaveGames( const QList<GuiSaveInfo>& saveGames )
{
if( m_parent )
if ( m_parent )
{
m_parent->updateSaveGames( saveGames );
m_parent->updateSaveGames( saveGames );
}
}
}
14 changes: 6 additions & 8 deletions src/gui/xaml/loadgameproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ class LoadGameProxy : public QObject
LoadGameProxy( QObject* parent = nullptr );
void setParent( IngnomiaGUI::LoadGameModel* parent );

void requestKingdoms();
void requestSaveGames( const QString path );
void requestKingdoms();
void requestSaveGames( const QString path );

private:
IngnomiaGUI::LoadGameModel* m_parent = nullptr;



private slots:
void onKingdoms( const QList<GuiSaveInfo>& kingdoms );
void onSaveGames( const QList<GuiSaveInfo>& saveGames );
void onKingdoms( const QList<GuiSaveInfo>& kingdoms );
void onSaveGames( const QList<GuiSaveInfo>& saveGames );

signals:
void signalRequestKingdoms();
void signalRequestSaveGames( const QString path );
void signalRequestSaveGames( const QString path );
};

0 comments on commit 8c442d4

Please sign in to comment.