Commit 993bd449 authored by anotherguest's avatar anotherguest

Added support for continue yes/no scene. added to extra controls yes_no (for...

Added support for continue yes/no scene. added to extra controls yes_no (for extended config for ports), defaults to y, n keys.
parent 2bb81bfd
......@@ -52,7 +52,8 @@ Controls::Controls () {
keys[C_ESCAPE].key = SDLK_ESCAPE;
keys[C_STATS].key = SDLK_F9;
keys[C_PAUSE].key = SDLK_p;
keys[C_YES].key = SDLK_y;
keys[C_NO].key = SDLK_n;
#if defined(WIZ) || defined(GP2X)
buttons[C_UP].button = GP2X_BUTTON_UP;
buttons[C_DOWN].button = GP2X_BUTTON_DOWN;
......@@ -77,6 +78,8 @@ Controls::Controls () {
buttons[C_ESCAPE].button = -1;
buttons[C_STATS].button = -1;
buttons[C_PAUSE].button = -1;
buttons[C_YES].button = -1;
buttons[C_NO].button = -1;
#endif
buttons[C_SWIM].button = buttons[C_JUMP].button;
......@@ -96,6 +99,8 @@ Controls::Controls () {
axes[C_ESCAPE].axis = -1;
axes[C_STATS].axis = -1;
axes[C_PAUSE].axis = -1;
axes[C_YES].axis = -1;
axes[C_NO].axis = -1;
for (count = 0; count < CONTROLS; count++) {
......
......@@ -43,8 +43,10 @@
#define C_ESCAPE 9
#define C_STATS 10
#define C_PAUSE 11
#define C_YES 12
#define C_NO 13
// Size of those arrays
#define CONTROLS 12
#define CONTROLS 14
// Time interval
#define T_KEY 200
......
......@@ -6,7 +6,7 @@
* 23rd August 2005: Created scene.c
* 3rd February 2009: Created scene.h from parts of scene.c
* 3rd February 2009: Renamed scene.c to scene.cpp
* 27th March 2010: Created sceneload.cpp from parts of scene.cpp
* 27th March 2010: Created sceneload.cpp from parts of scene.cpp
*
* Part of the OpenJazz project
*
......@@ -33,7 +33,7 @@
#include "io/controls.h"
#include "io/gfx/font.h"
#include "io/gfx/paletteeffects.h"
#include "io/gfx/video.h"
#include "io/gfx/video.h"
/**
......@@ -50,45 +50,45 @@
*/
SceneImage::SceneImage (SceneImage *newNext) {
next = newNext;
next = newNext;
image = NULL;
}
SceneImage::~SceneImage () {
if (next) delete next;
if (next) delete next;
if (image) SDL_FreeSurface(image);
}
ScenePalette::ScenePalette (ScenePalette *newNext) {
next = newNext;
}
ScenePalette::~ScenePalette () {
if (next) delete next;
}
ScenePalette::ScenePalette (ScenePalette *newNext) {
next = newNext;
}
ScenePalette::~ScenePalette () {
if (next) delete next;
}
SceneText::SceneText() {
x = -1;
y = -1;
textRect.x = -1;
textRect.y = -1;
extraLineHeight = -1;
text = NULL;
shadowColour = 0;
}
SceneText::~SceneText() {
......@@ -98,13 +98,14 @@ SceneText::~SceneText() {
}
ScenePage::ScenePage() {
pageTime = 0;
nTexts = 0;
backgrounds = 0;
musicFile = NULL;
paletteIndex = 0;
askForYesNo = 0;
stopMusic = 0;
}
ScenePage::~ScenePage() {
......@@ -118,10 +119,10 @@ Scene::Scene (const char * fileName) {
File *file;
int loop;
nFonts = 0;
LOG("\nScene", fileName);
try {
file = new File(fileName, false);
......@@ -131,25 +132,25 @@ Scene::Scene (const char * fileName) {
throw e;
}
background = NULL;
background = NULL;
images = NULL;
palettes = NULL;
palettes = NULL;
file->seek(0x13, true); // Skip Digital Dimensions header
file->seek(ESignatureLength, true); // Skip Digital Dimensions header
signed long int dataOffset = file->loadInt(); //get offset pointer to first data block
scriptItems = file->loadShort(); // Get number of script items
scriptStarts = new signed long int[scriptItems];
pages = new ScenePage[scriptItems];
LOG("Scene: Script items", scriptItems);
for (loop = 0; loop < scriptItems; loop++) {
scriptStarts[loop] = file->loadInt();// Load offset to script
LOG("scriptStart", scriptStarts[loop]);
}
// Seek to datastart now
......@@ -157,17 +158,17 @@ Scene::Scene (const char * fileName) {
dataItems = file->loadShort() + 1; // Get number of data items
LOG("Scene: Data items", dataItems);
dataOffsets = new signed long int[dataItems];
for (loop = 0; loop < dataItems; loop++) {
dataOffsets[loop] = file->loadInt();// Load offset to script
LOG("dataOffsets", dataOffsets[loop]);
}
loadData(file);
loadScripts(file);
delete[] scriptStarts;
delete[] dataOffsets;
delete file;
......@@ -178,17 +179,17 @@ Scene::Scene (const char * fileName) {
Scene::~Scene () {
delete[] pages;
if (background) SDL_FreeSurface(background);
if (images) delete images;
delete[] pages;
if (background) SDL_FreeSurface(background);
if (images) delete images;
if (palettes) delete palettes;
}
int Scene::play () {
SDL_Rect dst;
......@@ -199,37 +200,46 @@ int Scene::play () {
int newpage = true;
SDL_Rect textRect = {0, 0, SW, SH};
clearScreen(0);
clearScreen(0);
while (true) {
if (loop(NORMAL_LOOP) == E_QUIT) return E_QUIT;
if (controls.release(C_ESCAPE)) return E_NONE;
if (controls.release(C_ESCAPE) || (controls.release(C_NO) && pages[sceneIndex].askForYesNo)) return E_NONE;
SDL_Delay(T_FRAME);
int upOrLeft = (controls.release(C_UP) || controls.release(C_LEFT));
if ((sceneIndex > 0 && upOrLeft) ||
controls.release(C_RIGHT) || controls.release(C_DOWN) || controls.release(C_ENTER) ||
int upOrLeft = 0;
int downOrRight = 0;
if(pages[sceneIndex].askForYesNo) {
// Should check for Y also
downOrRight = controls.release(C_ENTER) || controls.release(C_YES);;
} else {
upOrLeft = (controls.release(C_UP) || controls.release(C_LEFT));
downOrRight = (controls.release(C_RIGHT) || controls.release(C_DOWN) || controls.release(C_ENTER));
}
if ((sceneIndex > 0 && upOrLeft) ||
downOrRight ||
((globalTicks-lastTicks) >= pageTime * 1000 && pageTime != 256 && pageTime != 0)) {
if (upOrLeft) sceneIndex--;
else sceneIndex++;
if (sceneIndex == scriptItems) return E_NONE;
lastTicks = globalTicks;
// Get bg for this page
newpage = true;
pageTime = pages[sceneIndex].pageTime;
}
if (newpage) {
//paletteEffects = new FadeOutPaletteEffect(250, paletteEffects);
textRect.x = 0;
......@@ -237,48 +247,48 @@ int Scene::play () {
textRect.w = SW;
textRect.h = SH;
ScenePalette *palette = palettes;
while (palette && (palette->id != pages[sceneIndex].paletteIndex)) palette = palette->next;
if (palette) {
video.setPalette(palette->palette);
// Fade in from black
paletteEffects = new FadeInPaletteEffect(250, paletteEffects);
// Fade in from black
paletteEffects = new FadeInPaletteEffect(250, paletteEffects);
}
newpage = 0;
}
// First draw the backgrounds associated with this page
if (pages[sceneIndex].backgrounds > 0) {
for (int bg = 0; bg < pages[sceneIndex].backgrounds; bg++) {
image = images;
while (image && (image->id != pages[sceneIndex].bgIndex[bg]))
image = image->next;
while (image && (image->id != pages[sceneIndex].bgIndex[bg]))
image = image->next;
if (image) {
dst.x = pages[sceneIndex].bgX[bg] + ((canvasW - SW) >> 1);
dst.y = pages[sceneIndex].bgY[bg] + ((canvasH - SH) >> 1);
SDL_BlitSurface(image->image, NULL, canvas, &dst);
}
}
} else if (background) {
dst.x = (canvasW - SW) >> 1;
dst.y = (canvasH - SH) >> 1;
SDL_BlitSurface(background, NULL, canvas, &dst);
} else if (background) {
dst.x = (canvasW - SW) >> 1;
dst.y = (canvasH - SH) >> 1;
SDL_BlitSurface(background, NULL, canvas, &dst);
} else clearScreen(0);
......@@ -289,8 +299,8 @@ int Scene::play () {
for (int count = 0; count < pages[sceneIndex].nTexts; count++) {
SceneText *text = pages[sceneIndex].texts + count;
Font *font = NULL;
SceneText *text = pages[sceneIndex].texts + count;
Font *font = NULL;
int xOffset, yOffset;
for (int index = 0; index < nFonts; index++) {
......
......@@ -30,11 +30,20 @@
// Enums
enum
{
ESignatureLength = 0x13,
EScriptStartTag = 0x50,
EAnimationSoundList = 0x4C53,
EAnimationPlayList = 0x4C50
};
// These are the known script types
enum {
ESceneMusic = 0x2A,
ESceneYesNo = 0x23,
ESceneMusic = 0x2A,
ESceneStopMusic = 0x2D,
ESceneFadeType = 0x3F,
ESceneTextBlock = 0x40,
ESceneTextColour = 0x41,
......@@ -74,7 +83,7 @@ class SceneText {
int y;
SDL_Rect textRect;
int extraLineHeight;
int shadowColour;
SceneText ();
~SceneText ();
......@@ -94,7 +103,8 @@ class ScenePage {
int nTexts;
char* musicFile;
int paletteIndex;
int askForYesNo;
int stopMusic;
ScenePage();
~ScenePage();
......
......@@ -389,7 +389,8 @@ void Scene::loadScripts (File *f) {
/*int bgIndex = 0;*/
int textAlignment = 0;
int textFont = 0;
int textShadow = 0;
for(loop = 0; loop < scriptItems; loop++) {
LOG("\nParse Script", loop);
......@@ -401,7 +402,7 @@ void Scene::loadScripts (File *f) {
bool textRectValid = false;
f->seek(scriptStarts[loop], true); // Seek to data start
if (f->loadChar() == 0x50) { // Script tag
if (f->loadChar() == EScriptStartTag) { // Script tag
unsigned short int scriptid = f->loadShort();
LOG("Script id", scriptid);
......@@ -419,6 +420,14 @@ void Scene::loadScripts (File *f) {
switch(type) {
case ESceneYesNo:
{
pages[loop].askForYesNo = 1;
}break;
case ESceneStopMusic:
{
pages[loop].stopMusic = 1;
}break;
case ESceneAnimationSetting:
{
......@@ -446,7 +455,7 @@ void Scene::loadScripts (File *f) {
{
unsigned char fadein = f->loadChar();
LOG("ESceneFadeType", fadein);
LOG("ESceneFadeType", fadein);
}
......@@ -595,10 +604,8 @@ void Scene::loadScripts (File *f) {
case ESceneTextShadow:
{
unsigned short value = f->loadShort();
LOG("ESceneTextVAdjust", value);
textShadow = f->loadShort();
LOG("ESceneTextShadow", textShadow);
}
break;
......@@ -640,7 +647,6 @@ void Scene::loadScripts (File *f) {
case ESceneTextBlock:
{
unsigned char datalen = f->loadChar();
LOG("Text len", datalen);
......@@ -683,7 +689,8 @@ void Scene::loadScripts (File *f) {
text->alignment = textAlignment;
text->fontId = textFont;
text->shadowColour = textShadow;
if(textPosX != -1) {
text->x = textPosX;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment