Skip to content

Commit

Permalink
NWN: Add back the legal billboard
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Mar 21, 2014
1 parent 4b267c2 commit 389f9d8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/engines/nwn/gui/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ MainMenu::MainMenu(Module &module) : _module(&module), _charType(0), _new(0), _m

if (hasXP1) {
WidgetPanel *xp1 = new WidgetPanel(*this, "TextXP1", "ctl_xp1_text");
xp1->setPosition(124.0, 0.00, -50.0);
xp1->setPosition(124.0, 0.00, -250.0);
addWidget(xp1);
}

if (hasXP2) {
WidgetPanel *xp2 = new WidgetPanel(*this, "TextXP2", "ctl_xp2_text");
xp2->setPosition(124.0, -147.0, -50.0);
xp2->setPosition(124.0, -147.0, -250.0);
addWidget(xp2);
}

Expand Down
75 changes: 75 additions & 0 deletions src/engines/nwn/nwn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
#include "aurora/talkman.h"

#include "graphics/cursorman.h"
#include "graphics/guiman.h"

#include "graphics/aurora/sceneman.h"
#include "graphics/aurora/fontman.h"
#include "graphics/aurora/fps.h"
#include "graphics/aurora/model_nwn.h"

#include "sound/sound.h"

Expand All @@ -53,6 +55,7 @@
#include "engines/aurora/resources.h"

#include "engines/nwn/nwn.h"
#include "engines/nwn/model.h"
#include "engines/nwn/module.h"

#include "engines/nwn/gui/main/main.h"
Expand Down Expand Up @@ -398,6 +401,63 @@ void NWNEngine::stopMenuMusic() {
SoundMan.stopChannel(_menuMusic);
}

bool NWNEngine::legalFadeIn(Graphics::Aurora::Model_NWN *legal) {
if (EventMan.quitRequested() || !legal)
return true;

GUIMan.setAutoUpdate(true);

legal->fade(Graphics::kFadeDirectionIn, 1.0, false);
legal->setVisible(true);

bool aborted = false;
uint32 start = EventMan.getTimestamp();
while ((EventMan.getTimestamp() - start) < 1000) {
Events::Event event;
while (EventMan.pollEvent(event))
if (event.type == Events::kEventMouseDown)
aborted = true;

if (aborted || EventMan.quitRequested())
break;

EventMan.delay(10);
}

return aborted || EventMan.quitRequested();
}

void NWNEngine::legalShow(Graphics::Aurora::Model_NWN *legal, bool aborted) {
if(!legal)
return;

uint32 start = EventMan.getTimestamp();
bool fadeOut = false;
while (!EventMan.quitRequested() && !aborted) {
Events::Event event;

// Mouse click => abort
while (EventMan.pollEvent(event))
if (event.type == Events::kEventMouseDown)
aborted = true;
if (aborted)
break;

if (!fadeOut && (EventMan.getTimestamp() - start) >= 5000) {
legal->fade(Graphics::kFadeDirectionOut, 1.0, false);
fadeOut = true;
}

// Display and fade-out time's up
if ((EventMan.getTimestamp() - start) >= 6000)
break;
}

legal->setVisible(false);
GUIMan.setAutoUpdate(false);
GUIMan.update();
}

void NWNEngine::mainMenuLoop() {
playMenuMusic();

Expand All @@ -406,16 +466,31 @@ void NWNEngine::mainMenuLoop() {

Module module;

Graphics::Aurora::Model_NWN *legal = createGUIModel("load_legal");
legal->setPosition(0.0, 0.0, -200.0);
GUIMan.addRenderable(legal);

while (!EventMan.quitRequested()) {
GUI *mainMenu = new MainMenu(module);

EventMan.flushEvents();

// Fade in, show and fade out the legal billboard
bool abortLegal = legalFadeIn(legal);
mainMenu->setVisible(true);
legalShow(legal, abortLegal);

mainMenu->run();
mainMenu->setVisible(false);

delete mainMenu;

if (legal) {
GUIMan.removeRenderable(legal);
delete legal;
legal = 0;
}

if (EventMan.quitRequested())
break;

Expand Down
9 changes: 9 additions & 0 deletions src/engines/nwn/nwn.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ namespace Common {
class FileList;
}

namespace Graphics {
namespace Aurora {
class Model_NWN;
}
}

namespace Engines {

namespace NWN {
Expand Down Expand Up @@ -114,6 +120,9 @@ class NWNEngine : public Engines::Engine {
void stopMenuMusic();

void mainMenuLoop();

bool legalFadeIn(Graphics::Aurora::Model_NWN *legal);
void legalShow(Graphics::Aurora::Model_NWN *legal, bool aborted);
};

} // End of namespace NWN
Expand Down

0 comments on commit 389f9d8

Please sign in to comment.