Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do Not Merge] Pencil2D ASCII Edition #1208

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add 8-bit background music
Song Name: Electric City
Artist: Jazzcat
Remixed by: Dippy
License: CC-BY-NC-SA
  • Loading branch information
scribblemaniac committed Apr 1, 2019
commit 0430eb3439f911a07641a2816dc1c06bd05076fd
1 change: 1 addition & 0 deletions app/data/app.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<file>icons/new/arrow-horizontal.png</file>
<file>icons/new/arrow-selectmove.png</file>
<file>icons/new/arrow-vertical.png</file>
<file>audio/electric-city.wav</file>
</qresource>
<qresource prefix="/app">
<file>icons/onion-blue.png</file>
Expand Down
Binary file added app/data/audio/electric-city.wav
Binary file not shown.
42 changes: 34 additions & 8 deletions app/src/consolewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "ui_consolewindow.h"

#include <QRegularExpression>
#include <QMediaPlaylist>
#include <QMediaPlayer>

#include "mainwindow2.h"

Expand All @@ -20,6 +22,14 @@ ConsoleWindow::ConsoleWindow(QWidget *parent) :
ui->prompt->setFocus();

mMainWindow = new MainWindow2(this);

// Play music
QMediaPlaylist *playlist = new QMediaPlaylist();
playlist->addMedia(QUrl("qrc:/audio/electric-city.wav"));
playlist->setPlaybackMode(QMediaPlaylist::Loop);
mSpeaker = new QMediaPlayer();
mSpeaker->setPlaylist(playlist);
mSpeaker->play();
}

ConsoleWindow::~ConsoleWindow()
Expand All @@ -31,22 +41,38 @@ bool ConsoleWindow::eventFilter(QObject *watched, QEvent *event)
{
if (watched == ui->prompt)
{
if (event->type() == QEvent::FocusIn)
{
ui->promptPrefix->setStyleSheet("border:none;background:rgba(0,255,0,0.25);");
ui->prompt->setStyleSheet("border:none;background:rgba(0,255,0,0.25);");
}
else if (event->type() == QEvent::FocusOut)
if (event->type() == QEvent::FocusOut)
{
ui->promptPrefix->setStyleSheet("border:none;background:transparent;");
ui->prompt->setStyleSheet("border:none;background:transparent;");
// Keep focus on prompt
ui->prompt->setFocus();
}
}
return false;
}

void ConsoleWindow::runCommand()
{
// Handle exiting the splash screen
if (mIsOnSplash)
{
// Remove title
ui->title->hide();
// Remove logo
ui->console->clear();

// Clear prompt
ui->prompt->setText("");
// Make prompt editable
ui->prompt->setReadOnly(false);

// Show help text
// TODO

// Prevent this code from being run again
mIsOnSplash = false;
return;
}

// Get command
QString command = ui->prompt->text().trimmed();
// Clean command for robustness
Expand Down
3 changes: 3 additions & 0 deletions app/src/consolewindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ConsoleWindow;
}

class MainWindow2;
class QMediaPlayer;

class ConsoleWindow : public QMainWindow
{
Expand All @@ -27,6 +28,8 @@ private slots:
Ui::ConsoleWindow *ui;

MainWindow2 *mMainWindow;
QMediaPlayer *mSpeaker;
bool mIsOnSplash = true;
};

#endif // CONSOLEWINDOW_H
12 changes: 9 additions & 3 deletions app/ui/consolewindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</font>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>Pencil2D ASCII Version</string>
</property>
<property name="styleSheet">
<string notr="true">color:limegreen;background:black;</string>
Expand All @@ -39,7 +39,7 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="title">
<property name="font">
<font>
<family>Courier New</family>
Expand Down Expand Up @@ -134,6 +134,9 @@
<pointsize>18</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background:rgba(0,255,0,0.25);</string>
</property>
<property name="text">
<string>&gt; </string>
</property>
Expand All @@ -148,11 +151,14 @@
</font>
</property>
<property name="styleSheet">
<string notr="true">border:none;background:transparent;</string>
<string notr="true">border:none;background:rgba(0,255,0,0.25);</string>
</property>
<property name="text">
<string>Press enter to begin</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand Down