-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'developing' into music
- Loading branch information
Showing
26 changed files
with
603 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/Client/Games/TerminalMinigameView/terminal_minigame_view.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#include "terminal_minigame_view.h" | ||
|
||
#include <QFontDatabase> | ||
|
||
#include "src/Client/InputController/input_names.h" | ||
|
||
TerminalMinigameView::TerminalMinigameView(QWidget* parent) | ||
: QWidget(parent), | ||
static_text_(new QLabel(this)), | ||
needed_text_(new QLabel(this)), | ||
entered_text_(new QLabel(this)), | ||
available_keys_(new QLabel(this)), | ||
layout_(new QGridLayout(this)) { | ||
QString family = | ||
QFontDatabase::applicationFontFamilies(QFontDatabase::addApplicationFont( | ||
"../Resources/Fonts/Fairfax.ttf")).at(0); | ||
auto font = QFont(family); | ||
font.setPointSize(36); | ||
|
||
static_text_->setStyleSheet("QLabel {color : #20C20E; }"); | ||
static_text_->setFont(font); | ||
needed_text_->setStyleSheet("QLabel {color : lightgray; }"); | ||
needed_text_->setFont(font); | ||
entered_text_->setStyleSheet("QLabel {color : #20C20E; }"); | ||
entered_text_->setFont(font); | ||
available_keys_->setStyleSheet("QLabel {color : #20C20E; }"); | ||
available_keys_->setFont(font); | ||
|
||
layout_->addWidget(static_text_, 0, 0, Qt::AlignBottom | Qt::AlignLeft); | ||
layout_->addWidget(needed_text_, 1, 0, Qt::AlignBottom | Qt::AlignLeft); | ||
layout_->addWidget(entered_text_, 1, 0, Qt::AlignBottom | Qt::AlignLeft); | ||
layout_->addWidget(available_keys_, 2, 0, Qt::AlignBottom | Qt::AlignLeft); | ||
|
||
layout_->setRowStretch(0, 1); | ||
layout_->setRowStretch(1, 1); | ||
layout_->setRowStretch(2, 12); | ||
|
||
setLayout(layout_); | ||
repaint(); | ||
} | ||
|
||
void TerminalMinigameView::PaintBackground(QPainter* painter) { | ||
painter->save(); | ||
|
||
auto width = size().width(); | ||
auto height = size().width(); | ||
|
||
painter->setBrush(QColorConstants::Black); | ||
painter->setPen(QColorConstants::Black); | ||
painter->drawRect(0, 0, width, height); | ||
|
||
painter->setBrush(QColor(32, 194, 14)); | ||
painter->drawRect(0, 0, width * (remaining_time_ * 1.0 / total_time_), 10); | ||
|
||
painter->restore(); | ||
} | ||
|
||
void TerminalMinigameView::paintEvent(QPaintEvent* event) { | ||
QPainter painter(this); | ||
PaintBackground(&painter); | ||
} | ||
|
||
void TerminalMinigameView::InitializeView( | ||
const minigame_responses::MinigameResponse& response) { | ||
auto& initial_response = response.initial_terminal_respone(); | ||
total_time_ = response.remaining_time(); | ||
remaining_time_ = total_time_; | ||
|
||
needed_text_->setText( | ||
text_prefix_ + QString::fromStdString(initial_response.text())); | ||
|
||
QString available_keys = "Available keys: "; | ||
|
||
for (const auto& id : initial_response.available_buttons_id()) { | ||
QString temp = input::InputNameToString(static_cast<input::Name>(id)); | ||
temp.remove(0, 1); | ||
available_keys += "\"" + temp + "\","; | ||
} | ||
available_keys.remove(available_keys.size() - 1, 1); | ||
|
||
available_keys_->setText(available_keys); | ||
|
||
repaint(); | ||
} | ||
|
||
void TerminalMinigameView::UpdateView( | ||
const minigame_responses::MinigameResponse& response) { | ||
remaining_time_ = response.remaining_time(); | ||
|
||
auto& game_response = response.terminal_response(); | ||
entered_text_->setText( | ||
text_prefix_ + QString::fromStdString(game_response.entered_text())); | ||
|
||
repaint(); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Client/Games/TerminalMinigameView/terminal_minigame_view.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <QWidget> | ||
#include <QPainter> | ||
#include <QLabel> | ||
#include <QGridLayout> | ||
|
||
#include "Protobuf/minigame_responses.pb.h" | ||
|
||
class TerminalMinigameView : public QWidget{ | ||
Q_OBJECT | ||
public: | ||
explicit TerminalMinigameView(QWidget* parent = nullptr); | ||
|
||
void InitializeView(const minigame_responses::MinigameResponse& response); | ||
void UpdateView(const minigame_responses::MinigameResponse& response); | ||
|
||
private: | ||
QLabel* static_text_; | ||
QLabel* needed_text_; | ||
QLabel* entered_text_; | ||
QLabel* available_keys_; | ||
|
||
QGridLayout* layout_; | ||
|
||
const QString text_prefix_ = "user@spaceship:~/ "; | ||
|
||
uint64_t total_time_ = 1; | ||
uint64_t remaining_time_ = 1; | ||
|
||
void PaintBackground(QPainter* painter); | ||
void paintEvent(QPaintEvent* event) override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ using MinigameId = uint64_t; | |
enum class MinigameType { | ||
kNone = 0, | ||
|
||
kSample = 1, | ||
kTerminal = 1, | ||
|
||
kLast | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.