first iteration of interface refactoring
This commit is contained in:
parent
807162bb0f
commit
38cde0d571
BIN
rc/pause.png
Normal file
BIN
rc/pause.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
rc/play.png
Normal file
BIN
rc/play.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
rc/step.png
Normal file
BIN
rc/step.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
rc/stop.png
Normal file
BIN
rc/stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
@ -39,6 +39,10 @@
|
|||||||
<file>rc/radio_unchecked_disabled.png</file>
|
<file>rc/radio_unchecked_disabled.png</file>
|
||||||
<file>rc/radio_unchecked_focus.png</file>
|
<file>rc/radio_unchecked_focus.png</file>
|
||||||
<file>rc/radio_unchecked.png</file>
|
<file>rc/radio_unchecked.png</file>
|
||||||
|
<file>rc/play.png</file>
|
||||||
|
<file>rc/step.png</file>
|
||||||
|
<file>rc/stop.png</file>
|
||||||
|
<file>rc/pause.png</file>
|
||||||
<file>rc/PixelWars.png</file>
|
<file>rc/PixelWars.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="qdarkstyle">
|
<qresource prefix="qdarkstyle">
|
||||||
|
@ -38,16 +38,16 @@ struct Action
|
|||||||
COMMUNICATE
|
COMMUNICATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Com com_data;
|
||||||
Type type;
|
Type type;
|
||||||
Dir dir;
|
Dir dir;
|
||||||
Com com_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Info
|
struct Info
|
||||||
{
|
{
|
||||||
virtual bool getSuccess() const = 0;
|
virtual bool getSuccess() const = 0;
|
||||||
virtual PixelType getInventory() const = 0;
|
virtual PixelType getInventory() const = 0;
|
||||||
virtual const Com& getCom() const = 0;
|
virtual const Com* getCom() const = 0;
|
||||||
virtual PixelType getNear(Dir d) const = 0;
|
virtual PixelType getNear(Dir d) const = 0;
|
||||||
virtual int getInfo(Dir d) const = 0;
|
virtual int getInfo(Dir d) const = 0;
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,7 @@ void Dude::move(Dir d)
|
|||||||
|
|
||||||
void Dude::receiveComData(Dir dir, const char *data)
|
void Dude::receiveComData(Dir dir, const char *data)
|
||||||
{
|
{
|
||||||
|
m_receivedComData = true;
|
||||||
m_com_data.flag = dir;
|
m_com_data.flag = dir;
|
||||||
memcpy(m_com_data.data, data, COM_SIZE);
|
memcpy(m_com_data.data, data, COM_SIZE);
|
||||||
}
|
}
|
||||||
@ -44,6 +45,7 @@ void Dude::receiveComData(Dir dir, const char *data)
|
|||||||
void Dude::update(BehaviorFunction func)
|
void Dude::update(BehaviorFunction func)
|
||||||
{
|
{
|
||||||
func(&m_action, m_memory, (Info*)this);
|
func(&m_action, m_memory, (Info*)this);
|
||||||
|
m_receivedComData = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelType Dude::getNear(Dir d) const
|
PixelType Dude::getNear(Dir d) const
|
||||||
|
@ -6,17 +6,18 @@
|
|||||||
class Dude : public Info
|
class Dude : public Info
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
Action m_action; // action containing output com data
|
||||||
|
Com m_com_data; // input com data
|
||||||
Coord m_pos;
|
Coord m_pos;
|
||||||
|
char m_memory[DUDE_MEMORY_SIZE];
|
||||||
Map *p_map;
|
Map *p_map;
|
||||||
int m_team;
|
int m_team;
|
||||||
bool m_dead;
|
bool m_dead;
|
||||||
bool m_success;
|
bool m_success;
|
||||||
|
bool m_receivedComData;
|
||||||
PixelType m_inventory;
|
PixelType m_inventory;
|
||||||
PixelType m_under;
|
PixelType m_under;
|
||||||
int m_underResCount;
|
int m_underResCount;
|
||||||
char m_memory[DUDE_MEMORY_SIZE];
|
|
||||||
Action m_action; // action containing output com data
|
|
||||||
Com m_com_data; // input com data
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Dude(const Coord &_pos, Map *_map, int &_team);
|
Dude(const Coord &_pos, Map *_map, int &_team);
|
||||||
@ -32,7 +33,7 @@ public:
|
|||||||
|
|
||||||
virtual bool getSuccess() const { return m_success; }
|
virtual bool getSuccess() const { return m_success; }
|
||||||
virtual PixelType getInventory() const { return m_inventory; }
|
virtual PixelType getInventory() const { return m_inventory; }
|
||||||
virtual const Com& getCom() const { return m_com_data; }
|
virtual const Com* getCom() const { return m_receivedComData ? &m_com_data : nullptr; }
|
||||||
virtual PixelType getNear(Dir d) const;
|
virtual PixelType getNear(Dir d) const;
|
||||||
virtual int getInfo(Dir d) const;
|
virtual int getInfo(Dir d) const;
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
p_simu(NULL),
|
p_simu(NULL),
|
||||||
m_simSpeed(500),
|
|
||||||
m_simSpeedChanged(false),
|
m_simSpeedChanged(false),
|
||||||
m_paused(false)
|
m_paused(false)
|
||||||
{
|
{
|
||||||
@ -27,6 +26,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->flatSphereSlider, SIGNAL(valueChanged(int)), ui->drawWidget, SLOT(repaint()));
|
connect(ui->flatSphereSlider, SIGNAL(valueChanged(int)), ui->drawWidget, SLOT(repaint()));
|
||||||
connect(ui->surfaceRatioSlider, SIGNAL(valueChanged(int)), ui->drawWidget, SLOT(repaint()));
|
connect(ui->surfaceRatioSlider, SIGNAL(valueChanged(int)), ui->drawWidget, SLOT(repaint()));
|
||||||
connect(ui->pauseButton, SIGNAL(toggled(bool)), this, SLOT(pauseSimu(bool)));
|
connect(ui->pauseButton, SIGNAL(toggled(bool)), this, SLOT(pauseSimu(bool)));
|
||||||
|
changeSimSpeed(ui->simSpeedSlider->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -55,7 +55,7 @@ void MainWindow::openSimuDialog()
|
|||||||
void MainWindow::changeSimSpeed(int newSpeed)
|
void MainWindow::changeSimSpeed(int newSpeed)
|
||||||
{
|
{
|
||||||
m_simSpeedChanged = true;
|
m_simSpeedChanged = true;
|
||||||
m_simSpeed = ui->simSpeedSlider->maximum()-newSpeed;
|
m_simSpeed = ui->simSpeedSlider->maximum()+20-newSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateSimu()
|
void MainWindow::updateSimu()
|
||||||
|
@ -60,217 +60,232 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="dockWidgetContents">
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>0</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolBox" name="toolBox">
|
<widget class="QWidget" name="widget_2" native="true">
|
||||||
<property name="currentIndex">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<number>0</number>
|
<property name="leftMargin">
|
||||||
</property>
|
<number>5</number>
|
||||||
<widget class="QWidget" name="page_5">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>260</width>
|
|
||||||
<height>346</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<property name="topMargin">
|
||||||
<string>Settings</string>
|
<number>5</number>
|
||||||
</attribute>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<property name="rightMargin">
|
||||||
<item>
|
<number>5</number>
|
||||||
<widget class="QLabel" name="label">
|
</property>
|
||||||
<property name="text">
|
<property name="bottomMargin">
|
||||||
<string>Spherical / Flat</string>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="spacing">
|
||||||
</item>
|
<number>8</number>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QSlider" name="flatSphereSlider">
|
<item row="4" column="0">
|
||||||
<property name="enabled">
|
<widget class="QLabel" name="label_3">
|
||||||
<bool>true</bool>
|
<property name="text">
|
||||||
</property>
|
<string>Simulation Speed</string>
|
||||||
<property name="layoutDirection">
|
</property>
|
||||||
<enum>Qt::LeftToRight</enum>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="maximum">
|
<item row="10" column="0" colspan="3">
|
||||||
<number>100</number>
|
<spacer name="verticalSpacer">
|
||||||
</property>
|
<property name="orientation">
|
||||||
<property name="singleStep">
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0" colspan="3">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Advanced</string>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="pageStep">
|
<property name="topMargin">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="orientation">
|
<property name="rightMargin">
|
||||||
<enum>Qt::Horizontal</enum>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="tickPosition">
|
<property name="bottomMargin">
|
||||||
<enum>QSlider::TicksBelow</enum>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="tickInterval">
|
<item row="0" column="0">
|
||||||
<number>10</number>
|
<widget class="QLabel" name="label">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>Spherical / Flat</string>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QLabel" name="label_2">
|
</item>
|
||||||
<property name="text">
|
<item row="0" column="1">
|
||||||
<string>surface ratio</string>
|
<widget class="QSlider" name="flatSphereSlider">
|
||||||
</property>
|
<property name="enabled">
|
||||||
</widget>
|
<bool>true</bool>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
<property name="layoutDirection">
|
||||||
<widget class="QSlider" name="surfaceRatioSlider">
|
<enum>Qt::LeftToRight</enum>
|
||||||
<property name="enabled">
|
</property>
|
||||||
<bool>true</bool>
|
<property name="maximum">
|
||||||
</property>
|
<number>100</number>
|
||||||
<property name="minimum">
|
</property>
|
||||||
<number>0</number>
|
<property name="singleStep">
|
||||||
</property>
|
<number>5</number>
|
||||||
<property name="maximum">
|
</property>
|
||||||
<number>100</number>
|
<property name="pageStep">
|
||||||
</property>
|
<number>5</number>
|
||||||
<property name="singleStep">
|
</property>
|
||||||
<number>10</number>
|
<property name="orientation">
|
||||||
</property>
|
<enum>Qt::Horizontal</enum>
|
||||||
<property name="pageStep">
|
</property>
|
||||||
<number>10</number>
|
<property name="tickPosition">
|
||||||
</property>
|
<enum>QSlider::TicksBelow</enum>
|
||||||
<property name="value">
|
</property>
|
||||||
<number>50</number>
|
<property name="tickInterval">
|
||||||
</property>
|
<number>10</number>
|
||||||
<property name="orientation">
|
</property>
|
||||||
<enum>Qt::Horizontal</enum>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="tickPosition">
|
<item row="1" column="0">
|
||||||
<enum>QSlider::TicksBelow</enum>
|
<widget class="QLabel" name="label_2">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="tickInterval">
|
<string>surface ratio</string>
|
||||||
<number>10</number>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
<item row="1" column="1">
|
||||||
<item>
|
<widget class="QSlider" name="surfaceRatioSlider">
|
||||||
<widget class="QLabel" name="label_3">
|
<property name="enabled">
|
||||||
<property name="text">
|
<bool>true</bool>
|
||||||
<string>Simulation Speed</string>
|
</property>
|
||||||
</property>
|
<property name="minimum">
|
||||||
</widget>
|
<number>0</number>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
<property name="maximum">
|
||||||
<widget class="QSlider" name="simSpeedSlider">
|
<number>100</number>
|
||||||
<property name="enabled">
|
</property>
|
||||||
<bool>true</bool>
|
<property name="singleStep">
|
||||||
</property>
|
<number>10</number>
|
||||||
<property name="minimum">
|
</property>
|
||||||
<number>100</number>
|
<property name="pageStep">
|
||||||
</property>
|
<number>10</number>
|
||||||
<property name="maximum">
|
</property>
|
||||||
<number>2000</number>
|
<property name="value">
|
||||||
</property>
|
<number>50</number>
|
||||||
<property name="singleStep">
|
</property>
|
||||||
<number>100</number>
|
<property name="orientation">
|
||||||
</property>
|
<enum>Qt::Horizontal</enum>
|
||||||
<property name="pageStep">
|
</property>
|
||||||
<number>100</number>
|
<property name="tickPosition">
|
||||||
</property>
|
<enum>QSlider::TicksBelow</enum>
|
||||||
<property name="value">
|
</property>
|
||||||
<number>2000</number>
|
<property name="tickInterval">
|
||||||
</property>
|
<number>10</number>
|
||||||
<property name="sliderPosition">
|
</property>
|
||||||
<number>2000</number>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="orientation">
|
</layout>
|
||||||
<enum>Qt::Horizontal</enum>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="invertedAppearance">
|
<item row="7" column="1" colspan="2">
|
||||||
<bool>false</bool>
|
<widget class="QLabel" name="populationLabel">
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="invertedControls">
|
<string>0</string>
|
||||||
<bool>false</bool>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="tickPosition">
|
</item>
|
||||||
<enum>QSlider::TicksBelow</enum>
|
<item row="4" column="1" colspan="2">
|
||||||
</property>
|
<widget class="QSlider" name="simSpeedSlider">
|
||||||
<property name="tickInterval">
|
<property name="enabled">
|
||||||
<number>100</number>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="minimum">
|
||||||
</item>
|
<number>0</number>
|
||||||
<item>
|
</property>
|
||||||
<spacer name="verticalSpacer">
|
<property name="maximum">
|
||||||
<property name="orientation">
|
<number>980</number>
|
||||||
<enum>Qt::Vertical</enum>
|
</property>
|
||||||
</property>
|
<property name="singleStep">
|
||||||
<property name="sizeHint" stdset="0">
|
<number>10</number>
|
||||||
<size>
|
</property>
|
||||||
<width>20</width>
|
<property name="pageStep">
|
||||||
<height>40</height>
|
<number>10</number>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="value">
|
||||||
</spacer>
|
<number>980</number>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
<property name="sliderPosition">
|
||||||
</widget>
|
<number>980</number>
|
||||||
<widget class="QWidget" name="page_6">
|
</property>
|
||||||
<property name="geometry">
|
<property name="orientation">
|
||||||
<rect>
|
<enum>Qt::Horizontal</enum>
|
||||||
<x>0</x>
|
</property>
|
||||||
<y>0</y>
|
<property name="invertedAppearance">
|
||||||
<width>260</width>
|
<bool>false</bool>
|
||||||
<height>346</height>
|
</property>
|
||||||
</rect>
|
<property name="invertedControls">
|
||||||
</property>
|
<bool>false</bool>
|
||||||
<attribute name="label">
|
</property>
|
||||||
<string>Stats</string>
|
<property name="tickPosition">
|
||||||
</attribute>
|
<enum>QSlider::TicksBelow</enum>
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
</property>
|
||||||
<item row="1" column="0">
|
<property name="tickInterval">
|
||||||
<widget class="QLabel" name="label_5">
|
<number>100</number>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Date</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="5" column="1" colspan="2">
|
||||||
</item>
|
<widget class="QLabel" name="dateLabel">
|
||||||
<item row="1" column="1">
|
<property name="text">
|
||||||
<widget class="QLabel" name="dateLabel">
|
<string>0</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>0</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="7" column="0">
|
||||||
</item>
|
<widget class="QLabel" name="label_6">
|
||||||
<item row="2" column="0">
|
<property name="text">
|
||||||
<widget class="QLabel" name="label_6">
|
<string>Population</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Population</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="5" column="0">
|
||||||
</item>
|
<widget class="QLabel" name="label_5">
|
||||||
<item row="2" column="1">
|
<property name="text">
|
||||||
<widget class="QLabel" name="populationLabel">
|
<string>Date</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>0</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="8" column="0" colspan="3">
|
||||||
</item>
|
<widget class="Line" name="line">
|
||||||
</layout>
|
<property name="orientation">
|
||||||
</widget>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -301,19 +316,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="stopButton">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>STOP</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pauseButton">
|
<widget class="QPushButton" name="pauseButton">
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user