Commit 1504e15d authored by Felix Huther's avatar Felix Huther
Browse files

small problems with UI

parent de8e8116
#include "abstractui.h";
#include "abstractui.h"//;
AbstractUI::AbstractUI(Level *mCurrentLevel)
: mCurrentLevel(mCurrentLevel) {}
......
......@@ -3,13 +3,13 @@
Character::Character(std::string texture) {}
const std::string &Character::getTexture() const {
return texture;
return mTexture;
}
Tile *Character::getCurrentTile() const {
return currentTile;
return mCurrentTile;
}
void Character::setCurrentTile(Tile *currentTile) {
Character::currentTile = currentTile;
Character::mCurrentTile = currentTile;
}
#ifndef CHARACTER_H
#define CHARACTER_H
#include "controller.h"
#include <string>
class Tile;
......@@ -14,8 +15,9 @@ public:
//MEMBER VARIABLES
private:
std::string texture;
Tile* currentTile;
std::string mTexture;
Tile* mCurrentTile;
Controller* mController;
//GETTER AND SETTER
......
......@@ -4,3 +4,13 @@ Controller::Controller()
{
}
char Controller::getLastInput()
{
return lastInput;
}
void Controller::setLastInput(char newLastInput)
{
lastInput = newLastInput;
}
......@@ -8,6 +8,12 @@ public:
Controller();
virtual char askMoveFromUser() = 0 ;
char getLastInput();
void setLastInput(char newLastInput);
private:
char lastInput;
};
#endif // CONTROLLER_H
#include "ui_mainwindow.h"
#include "ui_dialog.h"
#include "graphicalui.h"
#include "qlabel.h"
#include "ui_dialog.h"
#include "ui_mainwindow.h"
#include <random>
//wird gebraucht um random boden zu erzeugen
......@@ -11,25 +11,25 @@ std::uniform_int_distribution<int> distribution(1,5);
GraphicalUi::GraphicalUi(Level *mCurrentLevel)
: AbstractUI(mCurrentLevel)
{
{
this->mStartbildschirm = new Dialog();
mStartbildschirm->getUi()->setupUi(mStartbildschirm);
mStartbildschirm->setStyleSheet("background-color:black;");
QPixmap enterButton;
QPixmap startScreen;
enterButton.load("../src/new_game_button.png");
startScreen.load("../src/startscreen.png");
mStartbildschirm->setEnterButton(enterButton);
mStartbildschirm->setStartHintergrund(startScreen);
QLabel* newGame = new QLabel("",mStartbildschirm->getUi()->NeuesSpiel);
newGame->setPixmap(mStartbildschirm->enterButton());
QLabel* background = new QLabel("",mStartbildschirm->getUi()->StartBild);
background->setPixmap(mStartbildschirm->startHintergrund());
{//STARTBILDSCHIRM
this->mStartbildschirm = new Dialog();
mStartbildschirm->getUi()->setupUi(mStartbildschirm);
mStartbildschirm->setStyleSheet("background-color:black;");
QPixmap enterButton;
QPixmap startScreen;
enterButton.load("../src/new_game_button.png");
startScreen.load("../src/startscreen.png");
mStartbildschirm->setEnterButton(enterButton);
mStartbildschirm->setStartHintergrund(startScreen);
QLabel* newGame = new QLabel("",mStartbildschirm->getUi()->NeuesSpiel);
newGame->setPixmap(mStartbildschirm->enterButton());
QLabel* background = new QLabel("",mStartbildschirm->getUi()->StartBild);
background->setPixmap(mStartbildschirm->startHintergrund());
}
//SPIELBILDSCHIRM
this->mSpielbildschirm = new MainWindow();
mSpielbildschirm->getUi()->setupUi(mSpielbildschirm);
mSpielbildschirm->setStyleSheet("background-color:black;");
......@@ -42,14 +42,12 @@ GraphicalUi::GraphicalUi(Level *mCurrentLevel)
mainBackground->setPixmap(mSpielbildschirm->getBackground());
mainBackground->setAlignment(Qt::AlignCenter);
//LEVEL STRUCTURE
QPixmap floors[5];
QPixmap mPortal[3];
QPixmap mWall;
QPixmap mDoorOpen;
QPixmap mDoorClosed;
QPixmap mPortal;
QPixmap mSwitch;
QPixmap mPit;
QPixmap mRamp;
......@@ -61,10 +59,14 @@ GraphicalUi::GraphicalUi(Level *mCurrentLevel)
floors[3].load("../src/floor/floor4.png");
floors[4].load("../src/floor/floor5.png");
mPortal[0].load("../src/portal/portal1.png");
mPortal[1].load("../src/portal/portal2.png");
mPortal[2].load("../src/portal/portal3.png");
mWall.load("../src/wall/wall1.png");
mDoorClosed.load("../src/doors/door1.png");
mDoorOpen.load("../src/doors/door2.png");
mPortal.load("../src/portal/portal1.png");
mSwitch.load("../src/switch.png");
mPit.load("../src/pit.png");
mRamp.load("../src/ramp.png");
......@@ -97,7 +99,9 @@ GraphicalUi::GraphicalUi(Level *mCurrentLevel)
}
else if(typeid(*item) == typeid(Portal)){
tmp->setPixmap(mPortal);
Portal* portalPointer = static_cast<Portal*>(item);
tmp->setPixmap(mPortal[portalPointer->getPortalType()-1]);
}
else if(typeid(*item) == typeid(Switch)){
tmp->setPixmap(mSwitch);
......@@ -116,13 +120,36 @@ GraphicalUi::GraphicalUi(Level *mCurrentLevel)
isCLosed ? tmp->setPixmap(mDoorClosed) : tmp->setPixmap(mDoorOpen);
}
else tmp->setPixmap(mWall);
mSpielbildschirm->getUi()->gridLayout->addWidget(tmp,row,col,Qt::AlignCenter);//respresent wall
/*tmp->setPixmap(empty);
tmp->setScaledContents(true);
ui->gridLayout->addWidget(tmp,row+1,col,Qt::AlignCenter);*/
mSpielbildschirm->getUi()->gridLayout->addWidget(tmp,row,col,Qt::AlignCenter);
}
}
//BUTTON STRUCTURE
QPixmap MoveButtons[9];
MoveButtons[0].load("../src/arrows/arrow_up_left");
MoveButtons[1].load("../src/arrows/arrow_up");
MoveButtons[2].load("../src/arrows/arrow_up_right");
MoveButtons[3].load("../src/arrows/arrow_left");
MoveButtons[4].load("../src/arrows/arrow_skip");
MoveButtons[5].load("../src/arrows/arrow_right");
MoveButtons[6].load("../src/arrows/arrow_down_left");
MoveButtons[7].load("../src/arrows/arrow_down");
MoveButtons[8].load("../src/arrows/arrow_down_right");
mSpielbildschirm->getUi()->col1->setIcon(MoveButtons[0]);// Button_Q->setIcon(MoveButtons[0]);
// mSpielbildschirm->getUi()->Button_W->setIcon(MoveButtons[1]);
// mSpielbildschirm->getUi()->Button_E->setIcon(MoveButtons[2]);
// mSpielbildschirm->getUi()->Button_A->setIcon(MoveButtons[3]);
// mSpielbildschirm->getUi()->Button_S->setIcon(MoveButtons[4]);
// mSpielbildschirm->getUi()->Button_D->setIcon(MoveButtons[5]);
// mSpielbildschirm->getUi()->Button_Y->setIcon(MoveButtons[6]);
// mSpielbildschirm->getUi()->Button_X->setIcon(MoveButtons[7]);
// mSpielbildschirm->getUi()->Button_C->setIcon(MoveButtons[8]);
......@@ -145,4 +172,5 @@ void GraphicalUi::draw(Level *pLevel)
char GraphicalUi::askMoveFromUser()
{
return '0';
}
#ifndef GRAPHICALUI_H
#define GRAPHICALUI_H
#include "mainwindow.h"
#include "controller.h"
#include "abstractui.h"
#include "dialog.h"
#include "mainwindow.h"
class GraphicalUi : public Controller,public AbstractUI
class GraphicalUi : public Controller, public AbstractUI
{
public:
GraphicalUi(Level *mCurrentLevel);
......
......@@ -124,20 +124,22 @@ void Level::setStructure() {
mLevel.at(i).push_back(switchPointer);
}
// PLACES PORTAL
// PLACES PORTAL TYPE 1
else if((i == 4 && j == 4) || (i == 8 && j == 8))
{
Tile* portalOne;
Tile* portalTwo;
int portalType = 1;
if(i == 4)
{
portalOne = new Portal(stfloor,nullptr,pos,nullptr);
portalOne = new Portal(stfloor,nullptr,pos,nullptr,portalType);
mLevel.at(i).push_back(portalOne);
}
else
{
portalTwo = new Portal(stportal,nullptr,pos,portalOne);
portalTwo = new Portal(stportal,nullptr,pos,portalOne,portalType);
Portal* portalPointer = static_cast<Portal*>(portalOne);
portalPointer->setDestPortal(portalTwo);
......@@ -145,6 +147,28 @@ void Level::setStructure() {
}
}
else if((i == 2 && j == 13) || (i == 8 && j == 33))
{
Tile* portalOne;
Tile* portalTwo;
int portalType = 2;
if(i == 2)
{
portalOne = new Portal(stfloor,nullptr,pos,nullptr,portalType);
mLevel.at(i).push_back(portalOne);
}
else
{
portalTwo = new Portal(stportal,nullptr,pos,portalOne,portalType);
Portal* portalPointer = static_cast<Portal*>(portalOne);
portalPointer->setDestPortal(portalTwo);
mLevel.at(i).push_back(portalTwo);
}
}
else //PLACES FLOOR
{
Tile* floorPointer= new Floor(stfloor, nullptr,pos);
......
......@@ -13,6 +13,8 @@ int main(int argc, char *argv[])
Level* level = new Level(10,35);
Character* myCharacter = new Character("metal");
level->placeCharacter(myCharacter,Position2D(2,2));
......
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <iostream>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
......@@ -28,3 +29,59 @@ const QPixmap &MainWindow::getBackground() const
return mBackground;
}
void MainWindow::on_Button_A_clicked()
{
}
void MainWindow::on_Button_C_clicked()
{
}
void MainWindow::on_Button_D_clicked()
{
}
void MainWindow::on_Button_E_clicked()
{
}
void MainWindow::on_Button_Q_clicked()
{
}
void MainWindow::on_Button_S_clicked()
{
}
void MainWindow::on_Button_W_clicked()
{
}
void MainWindow::on_Button_X_clicked()
{
}
void MainWindow::on_Button_Y_clicked()
{
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "controller.h"
#include <QMainWindow>
QT_BEGIN_NAMESPACE
......@@ -21,6 +22,26 @@ public:
const QPixmap &getBackground() const;
private slots:
void on_Button_A_clicked();
void on_Button_C_clicked();
void on_Button_D_clicked();
void on_Button_E_clicked();
void on_Button_Q_clicked();
void on_Button_S_clicked();
void on_Button_W_clicked();
void on_Button_X_clicked();
void on_Button_Y_clicked();
private:
Ui::MainWindow *ui;
......
......@@ -6,51 +6,189 @@
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<height>700</height>
<width>1321</width>
<height>813</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>60</x>
<y>100</y>
<width>761</width>
<height>561</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout"/>
</widget>
<widget class="QLabel" name="background">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<height>700</height>
<x>10</x>
<y>10</y>
<width>1182</width>
<height>682</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QWidget" name="widget" native="true">
<widget class="QWidget" name="ButtonWidget" native="true">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>941</width>
<height>551</height>
<x>880</x>
<y>210</y>
<width>281</width>
<height>191</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="maximumSize">
<size>
<width>281</width>
<height>191</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout"/>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="QPushButton" name="Button_E">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="Button_Y">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="Button_S">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="Button_D">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="Button_X">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="Button_C">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="Button_Q">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="Button_A">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="Button_W">
<property name="text">
<string>PushButton</string>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<zorder>background</zorder>
<zorder>widget</zorder>
<zorder>ButtonWidget</zorder>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<width>1321</width>
<height>22</height>
</rect>
</property>
......