Commit 7a471443 authored by Gerhard Stein's avatar Gerhard Stein

Started to change the process pipeline a bit, passing intro into another

class
parent e2a5a9d4
......@@ -21,7 +21,7 @@ public:
virtual ~GsEngine() {}
/**
* @brief start Usually this is started before anything else but still after construction.
* @brief start Usually this is started before anything else but still after the construction.
*/
virtual void start() = 0;
......
#include <graphics/GsGraphics.h>
#include <base/video/CVideoDriver.h>
#include "GsProgressbar.h"
GsProgressBar::GsProgressBar()
......@@ -14,4 +18,12 @@ void GsProgressBar::processLogic()
void GsProgressBar::processRender(const GsRect<float> &RectDispCoordFloat)
{
// TODO: Rendering of the progress bar
// Transform to the display coordinates
GsRect<float> displayRect = mRect;
displayRect.transform(RectDispCoordFloat);
SDL_Rect lRect = displayRect.SDLRect();
// Now lets draw the text of the list control
GsFont &Font = gGraphics.getFont(mFontID);
Font.drawFontCentered(gVideoDriver.getBlitSurface(), "Doing some Progress", lRect.x, lRect.w, lRect.y, false);
}
......@@ -14,6 +14,7 @@
#include <widgets/GsBanner.h>
#include <widgets/GsButton.h>
#include <widgets/GsText.h>
#include <widgets/GsProgressbar.h>
#include <graphics/GsGraphics.h>
#include <base/utils/FindFile.h>
#include <base/utils/StringUtils.h>
......@@ -478,6 +479,8 @@ void CGameLauncher::setupDownloadDialog()
mpDownloadDialog->addControl(new CGUIText("Downloading..."), GsRect<float>(0.0f, 0.0f, 1.0f, 0.05f));
mpDownloadDialog->addControl(new GsProgressBar, GsRect<float>(0.1f, 0.2f, 0.8f, 0.1f));
mpDownloadDialog->addControl(new GsButton( "< Back", new CloseBoxEvent() ), GsRect<float>(0.4f, 0.85f, 0.2f, 0.05f) );
//mpDownloadDialog->addControl(new GsButton( "< Back", new GMQuit() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );
}
......
......@@ -21,6 +21,13 @@
dreams::DreamsEngine *gDreamsEngine;
enum GameState
{
INTRO_TEXT, // The famous screen where hardware is detected and some notes about the versions are told
INTRO_SCREEN // Within the gameloop it will show the intro screen of the dreams game
} gGameState = INTRO_TEXT;
// TODO: Ugly wrapper for the refkeen variables used. It serves as interface to C. Might be improved in future.
extern "C"
{
......@@ -176,6 +183,15 @@ namespace dreams
{
struct SwitchSceneEvent : CEvent
{
SwitchSceneEvent(GsEngine *ptr) :
mpEnginePtr( std::unique_ptr<GsEngine>(ptr) ) {}
std::unique_ptr<GsEngine> mpEnginePtr;
};
// Mapping the strings of the filenames to the pointers where we store the embedded data
std::map< std::string, unsigned int > gOffsetMap;
......@@ -280,6 +296,10 @@ bool extractEmbeddedFilesIntoMemory(const BE_GameVerDetails_T &gameVerDetails)
}
DreamsEngine::~DreamsEngine()
{
SDL_DestroySemaphore( gpRenderLock );
......@@ -337,17 +357,17 @@ bool DreamsEngine::loadResources()
void InitGame()
{
id0_int_t i;
MM_Startup();
#if 0
id0_int_t i;
/*#if 0
// Handle piracy screen...
//
movedata(FP_SEG(PIRACY),(id0_unsigned_t)PIRACY,0xb800,displayofs,4000);
while (BE_ST_BiosScanCode(0) != sc_Return);
//while ((bioskey(0)>>8) != sc_Return);
#endif
#endif*/
#if GRMODE == EGAGR
if (mminfo.mainmem < 335l*1024)
......@@ -406,8 +426,10 @@ void InitGame()
CA_MarkGrChunk(STARTFONTM);
CA_MarkGrChunk(STARTTILE8);
CA_MarkGrChunk(STARTTILE8M);
for (i=KEEN_LUMP_START;i<=KEEN_LUMP_END;i++)
CA_MarkGrChunk(i);
for ( id0_int_t j=KEEN_LUMP_START ; j<=KEEN_LUMP_END ; j++)
{
CA_MarkGrChunk(j);
}
#ifdef REFKEEN_VER_KDREAMS_CGA_ALL
CA_CacheMarks (NULL);
......@@ -419,35 +441,55 @@ void InitGame()
MM_SetLock (&grsegs[STARTFONTM],true);
MM_SetLock (&grsegs[STARTTILE8],true);
MM_SetLock (&grsegs[STARTTILE8M],true);
for (i=KEEN_LUMP_START;i<=KEEN_LUMP_END;i++)
MM_SetLock (&grsegs[i],true);
for ( id0_int_t j=KEEN_LUMP_START ; j<=KEEN_LUMP_END ; j++)
{
MM_SetLock (&grsegs[j],true);
}
setupAudio();
fontcolor = WHITE;
RefKeen_FillObjStatesWithDOSPointers(); // Saved games compatibility
US_FinishTextScreen();
}
RefKeen_FillObjStatesWithDOSPointers(); // Saved games compatibility
void DreamsDosIntro::start()
{
InitGame();
}
void DreamsDosIntro::pumpEvent(const CEvent *evPtr)
{
void DreamsEngine::GameLoop()
}
void DreamsDosIntro::ponder(const float deltaT)
{
if( gInput.getPressedAnyCommand() )
{
//gEventManager.add( new SwitchSceneEvent(new ) );
// If we press any switch to the next section -> where Dreams is really loaded into CGA/EGA mode and show the intro screen
gInput.flushAll();
gGameState = INTRO_SCREEN;
}
}
void DreamsDosIntro::render()
{
// TODO: We should pipe this function to another thread,
// so the main thread is kept free for
// all the other lower functions defined through the GsKit.
// TODO: Create Thread Object here!
//mpThread = DemoLoop();
}
void DreamsEngine::GameLoop()
{
struct GameLoopAction : public Action
{
int handle()
{
gDreamsForceClose = 0;
InitGame();
{
VW_SetScreenMode (GRMODE);
VW_ClearVideo (BLACK);
DemoLoop();
......@@ -459,7 +501,7 @@ void DreamsEngine::GameLoop()
};
mpPlayLoopAction.reset( new GameLoopAction );
mpPlayLoopThread.reset(threadPool->start(mpPlayLoopAction.get(), "Dreams Gameloop"));
mpPlayLoopThread.reset( threadPool->start(mpPlayLoopAction.get(), "Dreams Gameloop"));
}
......@@ -505,8 +547,6 @@ void DreamsEngine::applyScreenMode()
}
void DreamsEngine::start()
{
// Global for the legacy refkeen code.
......@@ -532,6 +572,12 @@ void DreamsEngine::start()
//InitGame();
//DemoLoop();
//kdreams_exe_main();
mpScene.reset( new DreamsDosIntro );
gGameState = INTRO_TEXT;
mpScene->start();
}
bool mResourcesLoaded = false;
......@@ -544,6 +590,8 @@ void DreamsEngine::pumpEvent(const CEvent *evPtr)
{
mResourcesLoaded = true;
}
mpScene->pumpEvent(evPtr);
}
void DreamsEngine::ponder(const float deltaT)
......@@ -561,13 +609,17 @@ void DreamsEngine::ponder(const float deltaT)
}
// Change that mGameState stuff to have more depth in the code
if(mGameState == INTRO_TEXT) // Where the shareware test is shown
// Change that gGameState stuff to have more depth in the code
if(gGameState == INTRO_TEXT) // Where the shareware test is shown
{
// If we press any switch to the next section -> where Dreams is really loaded into CGA/EGA mode and show the intro screen
gInput.flushAll();
mGameState = INTRO_SCREEN;
GameLoop();
mpScene->ponder(deltaT);
}
else
{
if(!mpPlayLoopThread)
{
GameLoop();
}
}
}
......@@ -577,6 +629,8 @@ void DreamsEngine::render()
// Lock Rendering
SDL_SemWait( gpRenderLock );
mpScene->render();
if(mChangeMode)
{
applyScreenMode();
......
......@@ -12,6 +12,34 @@ namespace dreams
{
class DreamsDosIntro : public GsEngine
{
virtual ~DreamsDosIntro() {}
/**
* @brief start Usually this is started before anything else but still after the construction.
*/
void start();
/**
* @brief pumpEvent Events like user closes windows or mouse presses are processed here.
* @param evPtr
*/
void pumpEvent(const CEvent *evPtr);
/**
* @brief ponder Logic cycle run usually at 120 LPS
* @param deltaT how much time of logic to do
*/
void ponder(const float deltaT);
/**
* @brief render Everything that needs to be rendered representing the current state of the object
*/
void render();
};
class DreamsEngine : public GameEngine
{
public:
......@@ -72,12 +100,6 @@ public:
private:
enum GameState
{
INTRO_TEXT, // The famous screen where hardware is detected and some notes about the versions are told
INTRO_SCREEN // Within the gameloop it will show the intro screen of the dreams game
} mGameState = INTRO_TEXT;
std::unique_ptr<Action> mpPlayLoopAction;
std::unique_ptr<ThreadPoolItem> mpPlayLoopThread;
......@@ -85,6 +107,12 @@ private:
* @brief mChangeMode An integer that triggers internal resolution change
*/
int mChangeMode = 0; // 0 means nothing, any other value sets the mode before
/**
* @brief mpScene A flexible pointer to a class instance in which different functionalities can projected
*/
std::unique_ptr<GsEngine> mpScene;
};
}
......
......@@ -1055,10 +1055,12 @@ IN_Ack(void)
LastScan = sc_None;
if (MousePresent)
{
while (INL_GetMouseButtons())
{
BE_ST_ShortSleep();
}
}
/*for (i = 0;i < MaxJoys;i++)
if (JoysPresent[i])
while (IN_GetJoyButtonsDB(i))
......
......@@ -750,13 +750,13 @@ US_FinishTextScreen(void)
{
// Change Loading... to Press a Key
// USL_ScreenDraw(29,22," Ready - Press a Key ",0x9a);
USL_ScreenDraw(30, 18, "Ready - Press a Key",0xCE);
USL_ScreenDraw(30, 18, "Ready - Press a Key",0xCE);
if (!tedlevel)
/*if (!tedlevel)
{
IN_ClearKeysDown();
IN_Ack();
}
}*/
//IN_ClearKeysDown();
//USL_ClearTextScreen();
......
......@@ -383,7 +383,7 @@ extern int gDreamsForceClose;
void Quit (const id0_char_t *error)
{
gDreamsForceClose = true;
gDreamsForceClose = 1;
ShutdownId ();
if (error && *error)
{
......
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