Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Dialog skip command and display

  • Loading branch information...
commit b61607ea52c3a23d7e15074e572c8fdfa153d91a 1 parent 04687fc
@is06 authored
View
BIN  bin/resource/hud/window/dialog_back.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 bin/resource/text/fre-FR/MAP_ALPHA_ZONE.ist
@@ -1,5 +1,5 @@
norya_time_and_space=Hors du temps et de l'espace,\nje suis condamné à errer.
-norya_wonder=J'en suis à me demander si je n'ai pas été trop arrogant.
-norya_pride=Cette même arrogance qui a conduit mes semblables à l'extinction.
-norya_pride2=Je l'ai sous-estimé. Cette négligence est impardonnable.
+norya_wonder=J'en suis à me demander si je n'ai pas été\ntrop arrogant.
+norya_pride=Cette même arrogance qui a conduit mes\nsemblables à l'extinction.
+norya_pride2=Je l'ai sous-estimé. Cette négligence\nest impardonnable.
norya_price=Et j'en paye le prix.
View
4 bin/settings.ini
@@ -4,8 +4,8 @@
unlock=1
[display]
-width=640
-height=480
+width=1280
+height=720
depth=32
fullscreen=0
vsync=0
View
1  include/engine/Dialog.h
@@ -22,6 +22,7 @@ class Dialog
string getMessage(u16 index);
const string& getIdentifier() const;
+ u16 getMessageCount();
private:
u16 currentNumber;
View
9 include/engine/DialogInterface.h
@@ -15,7 +15,7 @@ using namespace std;
class DialogInterface
{
public:
- DialogInterface(const string& filePath, Translation* translation);
+ DialogInterface(const string& filePath, Translation* translation, Keyboard* kb);
~DialogInterface();
void render();
@@ -30,10 +30,17 @@ class DialogInterface
void loadDialogData(const string& fullPath);
void createMessage(const string& dialogIdentifier, u16 messageNumber=0);
+ bool messageDisplaying;
+ bool messageFinished;
+ bool dialogFinished;
+
u16 currentMessageNumber;
+ string currentDialogIdentifier;
map<string, Dialog> dialogList;
Text* currentMessageText;
+ Picture* backWindow;
Translation* currentTranslation;
+ Keyboard* keyboard;
};
#endif
View
3  include/gui/Text.h
@@ -33,6 +33,8 @@ class Text : public Hud
void show();
void hide();
void setOpacity(u8 value);
+ void skip();
+ bool finished();
private:
TextFont* font;
@@ -50,6 +52,7 @@ class Text : public Hud
f32 leftBound;
f32 rightBound;
TextAlignment currentAlign;
+ bool textFinished;
Timer* speedTimer;
};
View
1  include/gui/menus/gameplay/GameplayMenu.h
@@ -56,7 +56,6 @@ class GameplayMenu : public Hud
Menu* sectionMenu;
PlayerState* stateInfo;
GameTimeCounter* gameplayTime;
- Keyboard* keyboard;
//DigitCounter* moneyCounter;
// Sub menus
View
4 include/scene/Scene.h
@@ -32,6 +32,8 @@ class Scene
void fadeIn(f32 speed = 1.5f, FadeColor color = FADE_COLOR_BLACK);
void fadeOut(f32 speed = 3.0f, FadeColor color = FADE_COLOR_BLACK);
+ const video::SColor& getBackBufferColor() const;
+
Camera* getActiveCamera();
ShadowProcessor* getShadowProcessor();
@@ -57,6 +59,8 @@ class Scene
ShadowProcessor* shadows;
+ video::SColor backBufferColor;
+
f32 timeElapsed;
f32 startTime;
f32 speedFactor;
View
4 src/Game.cpp
@@ -114,7 +114,7 @@ void Game::run()
if (speedFactor > 1.0f) speedFactor = 1.0f; // Limit min 1fps
if (speedFactor < 0.0f) speedFactor = 0.0f; // Limit max fps (infinite) negative = reversed movements
- videoDriver->beginScene(true, true, video::SColor(255, 0, 0, 0));
+ videoDriver->beginScene(true, true, currentScene->getBackBufferColor());
// Main events
currentScene->events();
@@ -142,7 +142,7 @@ void Game::run()
speedFactor = 1.0f / framerate;
- videoDriver->beginScene(true, true, video::SColor(255, 255, 255, 255));
+ videoDriver->beginScene(true, true, currentScene->getBackBufferColor());
// Main events
currentScene->events();
View
5 src/engine/Dialog.cpp
@@ -35,6 +35,11 @@ const string& Dialog::getIdentifier() const
return currentIdentifier;
}
+u16 Dialog::getMessageCount()
+{
+ return messageList.size();
+}
+
string Dialog::getMessage(u16 index)
{
return messageList[index];
View
61 src/engine/DialogInterface.cpp
@@ -7,17 +7,26 @@ is06.com. Permissions beyond the scope of this license may be available at
#include "../../include/ref/core.h"
#include "../../include/Game.h"
+#include "../../include/Keyboard.h"
#include "../../include/Translation.h"
#include "../../include/gui/Text.h"
+#include "../../include/gui/Picture.h"
#include "../../include/engine/DialogInterface.h"
using namespace std;
+using namespace irr;
/**
*
*/
-DialogInterface::DialogInterface(const string& filePath, Translation* translation)
+DialogInterface::DialogInterface(const string& filePath, Translation* translation, Keyboard* kb)
{
+ keyboard = kb;
+
+ messageDisplaying = false;
+ messageFinished = false;
+ dialogFinished = false;
+
if (!translation) {
Game::fatalError(ERRCODE_60);
}
@@ -26,6 +35,8 @@ DialogInterface::DialogInterface(const string& filePath, Translation* translatio
currentMessageNumber = 0;
currentMessageText = NULL;
+ backWindow = new Picture(0, Game::screenPos.bottom + 68, 1280, 136, "resource/hud/window/dialog_back.png");
+
string fullPath = "resource/text/";
switch (Game::getCurrentLocale()) {
@@ -49,8 +60,42 @@ DialogInterface::DialogInterface(const string& filePath, Translation* translatio
*/
void DialogInterface::render()
{
+ // Background of dialog
+ backWindow->render();
+
+ // Text
if (currentMessageText) {
currentMessageText->render();
+
+ // Dialog finished
+ if (!dialogFinished && messageFinished && currentMessageNumber >= dialogList[currentDialogIdentifier].getMessageCount() - 1) {
+ cout << "dialog finished" << endl;
+ dialogFinished = true;
+ }
+
+ if (messageDisplaying && currentMessageText->finished()) {
+ messageDisplaying = false;
+ messageFinished = true;
+ cout << "message finished" << endl;
+ }
+
+ // Display all message quickly
+ if (messageDisplaying && keyboard->pressed(KEY_SPACE, EVENT_ONCE)) {
+ cout << "skipping message" << endl;
+ currentMessageText->skip();
+ messageDisplaying = false;
+ messageFinished = true;
+ }
+
+ // Go to next message (only if entirely displayed)
+ if (messageFinished && keyboard->pressed(KEY_SPACE, EVENT_ONCE)) {
+ cout << "go to next message" << endl;
+ messageFinished = false;
+ messageDisplaying = true;
+ if (!dialogFinished) {
+ nextMessage();
+ }
+ }
}
}
@@ -107,7 +152,9 @@ void DialogInterface::loadDialogData(const string& fullPath)
*/
void DialogInterface::start(const string& dialogIdentifier)
{
+ currentDialogIdentifier = dialogIdentifier;
createMessage(dialogIdentifier, 0);
+ messageDisplaying = true;
}
/**
@@ -115,11 +162,7 @@ void DialogInterface::start(const string& dialogIdentifier)
*/
void DialogInterface::createMessage(const string& dialogIdentifier, u16 messageNumber)
{
- //cout << "Dialog identifier: " << dialogIdentifier << endl;
- cout << "Try to create dialog message '" << dialogList[dialogIdentifier].getMessage(messageNumber) << "'" << endl;
-
- currentMessageText = new Text(dialogList[dialogIdentifier].getMessage(messageNumber), 0, Game::screenPos.bottom + 100, FONT_STANDARD_48, 25);
- //currentMessageText->setAlign(TEXT_ALIGN_CENTER);
+ currentMessageText = new Text(dialogList[dialogIdentifier].getMessage(messageNumber), -350, Game::screenPos.bottom + 100, FONT_STANDARD_48, 25);
}
/**
@@ -127,7 +170,9 @@ void DialogInterface::createMessage(const string& dialogIdentifier, u16 messageN
*/
void DialogInterface::nextMessage()
{
-
+ delete currentMessageText;
+ currentMessageNumber++;
+ createMessage(currentDialogIdentifier, currentMessageNumber);
}
/**
@@ -151,5 +196,5 @@ bool DialogInterface::finished()
*/
DialogInterface::~DialogInterface()
{
-
+ delete backWindow;
}
View
62 src/gui/Text.cpp
@@ -19,6 +19,7 @@ using namespace irr;
*/
Text::Text(const string& str, f32 x, f32 y, FontStyle style, u8 speed) : Hud()
{
+ textFinished = false;
textStr = str;
currentSize = 48;
currentSpeed = speed;
@@ -102,9 +103,18 @@ void Text::nextChar()
if (currentDisplayChar < currentTextLength) {
charList[currentDisplayChar].show();
}
+ if (!textFinished && currentDisplayChar >= (currentTextLength - 1)) {
+ textFinished = true;
+ }
currentDisplayChar++;
}
+void Text::skip()
+{
+ currentSpeed = 0;
+ show();
+}
+
/**
* Create character list by updating every tiles
*/
@@ -113,32 +123,41 @@ void Text::updateTiles()
charList.clear();
currentCharPos = pos;
currentTextLength = 0;
+ bool escapeCharacter = false;
const char* cs = textStr.c_str();
u8 nextUtf8Table = 0;
for (u16 i = 0; i < textStr.size(); i++) {
- if (cs[i] == '\n') {
- currentLineNumber++;
- lineWidthList[currentLineNumber] = 0;
- currentCharPos.X = pos.X;
- currentCharPos.Y -= (currentSize - (currentSize / 8));
+ if (escapeCharacter) {
+ if (cs[i] == 'n') {
+ currentLineNumber++;
+ lineWidthList[currentLineNumber] = 0;
+ currentCharPos.X = pos.X;
+ currentCharPos.Y -= (currentSize - (currentSize / 8));
+ escapeCharacter = false;
+ }
} else {
- // The first byte is 110xxxxx: this means the character is stored with two bytes (utf-8)
- // Thanks to Christopho (https://github.com/christopho) for this trick
- if ((cs[i] & 0xE0) == 0xC0) {
- // Multi-byte utf-8 character found!
- nextUtf8Table = cs[i];
+ if (cs[i] == '\\') {
+ escapeCharacter = true;
+ continue;
} else {
- if (!nextUtf8Table) {
- // Standard character
- charList.push_back(TextChar(cs[i], currentCharPos.X, currentCharPos.Y, currentSize, font, (currentSpeed == 0)));
+ // The first byte is 110xxxxx: this means the character is stored with two bytes (utf-8)
+ // Thanks to Christopho (https://github.com/christopho) for this trick
+ if ((cs[i] & 0xE0) == 0xC0) {
+ // Multi-byte utf-8 character found!
+ nextUtf8Table = cs[i];
} else {
- // Extended utf-8 character
- charList.push_back(TextChar(cs[i], currentCharPos.X, currentCharPos.Y, currentSize, font, (currentSpeed == 0), nextUtf8Table));
- nextUtf8Table = 0;
+ if (!nextUtf8Table) {
+ // Standard character
+ charList.push_back(TextChar(cs[i], currentCharPos.X, currentCharPos.Y, currentSize, font, (currentSpeed == 0)));
+ } else {
+ // Extended utf-8 character
+ charList.push_back(TextChar(cs[i], currentCharPos.X, currentCharPos.Y, currentSize, font, (currentSpeed == 0), nextUtf8Table));
+ nextUtf8Table = 0;
+ }
+ currentTextLength++;
+ lineWidthList[currentLineNumber] += currentSize;
+ //cout << "width (" << currentLineNumber << ") => " << currentSize << endl;
}
- currentTextLength++;
- lineWidthList[currentLineNumber] += currentSize;
- //cout << "width (" << currentLineNumber << ") => " << currentSize << endl;
}
}
}
@@ -196,6 +215,11 @@ void Text::setOpacity(u8 value)
}
}
+bool Text::finished()
+{
+ return textFinished;
+}
+
/**
*
*/
View
4 src/map/MAP_ALPHA_ZONE.cpp
@@ -26,6 +26,8 @@ using namespace irr;
*/
MAP_ALPHA_ZONE::MAP_ALPHA_ZONE() : SceneGameplay()
{
+ backBufferColor = video::SColor(255, 255, 255, 255);
+
// Local Translations
sceneTranslations = new Translation("MAP_ALPHA_ZONE.ist");
@@ -51,7 +53,7 @@ MAP_ALPHA_ZONE::MAP_ALPHA_ZONE() : SceneGameplay()
//lt = new OmniLight();
// Dialogs
- dialog = new DialogInterface("MAP_ALPHA_ZONE.isd", sceneTranslations);
+ dialog = new DialogInterface("MAP_ALPHA_ZONE.isd", sceneTranslations, keyboard);
// Glow shader example
//glowShader = new PostRenderGlow();
View
7 src/scene/Scene.cpp
@@ -48,6 +48,8 @@ Scene::Scene()
debugInfo = Game::getDebugGUI()->addStaticText(L"", core::recti(core::vector2di(0, 0), core::vector2di(200, 20)), false, false, 0, 0, false);
debugInfo->setOverrideColor(video::SColor(255, 255, 255, 255));
+
+ backBufferColor = video::SColor(255, 0, 0, 0);
}
/**
@@ -181,6 +183,11 @@ ShadowProcessor* Scene::getShadowProcessor()
return shadows;
}
+const video::SColor& Scene::getBackBufferColor() const
+{
+ return backBufferColor;
+}
+
/**
* This destructor removes interfaces and flushes texture and mesh cache
*/
Please sign in to comment.
Something went wrong with that request. Please try again.