Skip to content

Commit

Permalink
NWN: Add back the ingame GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Mar 20, 2014
1 parent adfbb95 commit e5c702d
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 145 deletions.
12 changes: 12 additions & 0 deletions src/engines/nwn/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ noinst_HEADERS = \
gui/options/videoadv.h \
gui/options/resolution.h \
gui/chargen/chargen.h \
gui/ingame/charinfo.h \
gui/ingame/compass.h \
gui/ingame/ingame.h \
gui/ingame/main.h \
gui/ingame/partyleader.h \
gui/ingame/quickbar.h \
gui/ingame/quickchat.h \
$(EMPTY)

libnwn_la_SOURCES = \
Expand Down Expand Up @@ -114,5 +120,11 @@ libnwn_la_SOURCES = \
gui/options/videoadv.cpp \
gui/options/resolution.cpp \
gui/chargen/chargen.cpp \
gui/ingame/charinfo.cpp \
gui/ingame/compass.cpp \
gui/ingame/ingame.cpp \
gui/ingame/main.cpp \
gui/ingame/partyleader.cpp \
gui/ingame/quickbar.cpp \
gui/ingame/quickchat.cpp \
$(EMPTY)
22 changes: 11 additions & 11 deletions src/engines/nwn/gui/ingame/compass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
#include "common/util.h"

#include "graphics/graphics.h"
#include "graphics/camera.h"
#include "graphics/cameraman.h"

#include "graphics/aurora/modelnode.h"
#include "graphics/aurora/model.h"
#include "graphics/aurora/model_nwn.h"

#include "engines/nwn/gui/widgets/panel.h"

Expand All @@ -43,9 +42,6 @@ namespace Engines {

namespace NWN {

// TODO: The compass "needle" is hidden by directions disk.
// This seems to be a Z-order problem, should be fixed
// alongside the transparency problem once I've revamped models...
CompassWidget::CompassWidget(::Engines::GUI &gui, const Common::UString &tag) :
ModelWidget(gui, tag, "ctl_compass") {
}
Expand All @@ -56,10 +52,12 @@ CompassWidget::~CompassWidget() {
// TODO: The disk rotation should feel more "natural", i.e. it should
// be more sluggish.
void CompassWidget::setRotation(float x, float y, float z) {
/*
_model->setRotation(-x, 0.0, 0.0);
Graphics::Aurora::ModelNode *pointer = _model->getNode("cmp_pointer");
if (pointer)
pointer->setRotation(0.0, 0.0, y);
*/
}


Expand All @@ -68,10 +66,10 @@ Compass::Compass(float position) {

WidgetPanel *panel = new WidgetPanel(*this, "CompassPanel", "pnl_compass");

float panelWidth = panel->getWidth ();
float panelHeight = panel->getHeight();
float panelWidth = floor(panel->getWidth ());
float panelHeight = floor(panel->getHeight());

panel->setPosition(- panelWidth, position, 0.0);
panel->setPosition(- panelWidth + 1.0, position - 1.0, 0.0);

addWidget(panel);

Expand All @@ -80,7 +78,7 @@ Compass::Compass(float position) {

_compass = new CompassWidget(*this, "Compass");

_compass->setPosition(- (panelWidth / 2.0), position + (panelHeight / 2.0), -100.0);
_compass->setPosition(floor(- (panelWidth / 2.0)), floor(position + (panelHeight / 2.0)), 10.0);

addWidget(_compass);

Expand All @@ -95,13 +93,15 @@ void Compass::callbackActive(Widget &widget) {
}

void Compass::notifyResized(int oldWidth, int oldHeight, int newWidth, int newHeight) {
setPosition(newWidth / 2.0, - (newHeight / 2.0), -10.0);
setPosition(newWidth / 2.0, - (newHeight / 2.0), -400.0);
}

void Compass::notifyCameraMoved() {
/*
const float *orientation = CameraMan.getOrientation();
_compass->setRotation(orientation[0] + 90.0, orientation[1], orientation[2]);
*/
}

} // End of namespace NWN
Expand Down
46 changes: 22 additions & 24 deletions src/engines/nwn/gui/ingame/ingame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "common/error.h"

#include "graphics/graphics.h"

#include "engines/nwn/creature.h"

#include "engines/nwn/gui/ingame/ingame.h"
Expand All @@ -37,7 +39,7 @@
#include "engines/nwn/gui/ingame/quickchat.h"
#include "engines/nwn/gui/ingame/compass.h"
#include "engines/nwn/gui/ingame/partyleader.h"
#include "engines/nwn/gui/ingame/dialog.h"
//#include "engines/nwn/gui/ingame/dialog.h"

namespace Engines {

Expand All @@ -56,13 +58,13 @@ IngameGUI::IngameGUI(Module &module) : _module(&module), _lastCompassChange(0) {
_lastPartyMemberChange.resize(1);
_lastPartyMemberChange[0] = 0;

_dialog = 0;
//_dialog = 0;
}

IngameGUI::~IngameGUI() {
hide();
setVisible(false);

delete _dialog;
//delete _dialog;

for (std::vector<CharacterInfo *>::iterator p = _party.begin(); p != _party.end(); ++p)
delete *p;
Expand All @@ -75,43 +77,35 @@ IngameGUI::~IngameGUI() {
}

int IngameGUI::showMain() {
_main->show();
_main->setVisible(true);
int code = _main->run();
_main->hide();
_main->setVisible(false);

return code;
}

void IngameGUI::show() {
_quickbar->show();
_quickchat->show();
_compass->show();

for (std::vector<CharacterInfo *>::iterator p = _party.begin(); p != _party.end(); ++p)
(*p)->show();

if (_dialog)
_dialog->show();
}
void IngameGUI::setVisible(bool visible) {
LOCK_FRAME();

void IngameGUI::hide() {
if (_dialog)
_dialog->hide();
_quickbar->setVisible(visible);
_quickchat->setVisible(visible);
_compass->setVisible(visible);

for (std::vector<CharacterInfo *>::iterator p = _party.begin(); p != _party.end(); ++p)
(*p)->hide();
(*p)->setVisible(visible);

_compass->hide();
_quickchat->hide();
_quickbar->hide();
//if (_dialog)
//_dialog->setVisible(visible);
}

void IngameGUI::addEvent(const Events::Event &event) {
/*
// The dialog takes preference
if (_dialog) {
_dialog->addEvent(event);
return;
}
*/

for (std::vector<CharacterInfo *>::iterator p = _party.begin(); p != _party.end(); ++p)
(*p)->addEvent(event);
Expand All @@ -122,13 +116,15 @@ void IngameGUI::addEvent(const Events::Event &event) {
}

void IngameGUI::processEventQueue() {
/*
// The dialog takes preference
if (_dialog) {
if (_dialog->processEventQueue() != 0)
stopConversation();
return;
}
*/

for (std::vector<CharacterInfo *>::iterator p = _party.begin(); p != _party.end(); ++p)
(*p)->processEventQueue();
Expand Down Expand Up @@ -181,6 +177,7 @@ void IngameGUI::updatePartyMember(uint partyMember, const Creature &creature, bo
_lastPartyMemberChange[partyMember] = lastPartyMemberChange;
}

/*
bool IngameGUI::hasRunningConversation() const {
return _dialog != 0;
}
Expand Down Expand Up @@ -218,6 +215,7 @@ void IngameGUI::stopConversation() {
_dialog = 0;
}
*/

} // End of namespace NWN

Expand Down
16 changes: 8 additions & 8 deletions src/engines/nwn/gui/ingame/ingame.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CharacterInfo;
class Quickbar;
class Quickchat;
class Compass;
class Dialog;
//class Dialog;

/** The NWN ingame GUI elements. */
class IngameGUI {
Expand All @@ -65,8 +65,8 @@ class IngameGUI {

int showMain(); ///< Show the ingame main menu.

void show(); ///< Show the ingame GUI elements.
void hide(); ///< Hide the ingame GUI elements.
/** Show/Hide the ingame GUI elements. */
void setVisible(bool visible);

void addEvent(const Events::Event &event);
void processEventQueue();
Expand All @@ -78,13 +78,13 @@ class IngameGUI {
void updatePartyMember(uint partyMember, const Creature &creature, bool force = false);

/** Do we have a currently running conversation? */
bool hasRunningConversation() const;
//bool hasRunningConversation() const;

/** Start a conversation. */
bool startConversation(const Common::UString &conv,
Creature &pc, Object &obj, bool playHello = true);
//bool startConversation(const Common::UString &conv,
// Creature &pc, Object &obj, bool playHello = true);
/** Stop a conversation. */
void stopConversation();
//void stopConversation();

private:
Module *_module;
Expand All @@ -95,7 +95,7 @@ class IngameGUI {
Quickchat *_quickchat; ///< The quick chat.
Compass *_compass; ///< The compass.

Dialog *_dialog; ///< The current dialog.
//Dialog *_dialog; ///< The current dialog.

/** The time the compass was changed last. */
uint32 _lastCompassChange;
Expand Down
35 changes: 22 additions & 13 deletions src/engines/nwn/gui/ingame/partyleader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,25 @@ PartyLeader::PartyLeader(Module &module) : _module(&module),

WidgetPanel *playerPanel = new WidgetPanel(*this, "LeaderPanel", "pnl_party_bar");

playerPanel->setPosition(- playerPanel->getWidth(), 0.0, 0.0);
playerPanel->setPosition(floor(- playerPanel->getWidth()) + 2.0, 0.0, 0.0);

addWidget(playerPanel);


// Buttons

float buttonsX = - playerPanel->getWidth () + 4.0;
float buttonsY = - playerPanel->getHeight() + 57.0;
float buttonsX = - floor(playerPanel->getWidth ()) + 5.0;
float buttonsY = - floor(playerPanel->getHeight()) + 58.0;

for (int i = 0; i < 8; i++) {
WidgetButton *button = new WidgetButton(*this, kButtonTags[i], kButtonModels[i]);

button->setTooltip(TalkMan.getString(kButtonTooltips[i]));
button->setTooltipPosition(0.0, -10.0, -1.0);
//button->setTooltip(TalkMan.getString(kButtonTooltips[i]));
//button->setTooltipPosition(0.0, -10.0, -1.0);

const float x = buttonsX + ((i / 4) * 36.0);
const float y = buttonsY - ((i % 4) * 18.0);
const float z = -100.0;
const float x = floor(buttonsX + ((i / 4) * 36.0));
const float y = floor(buttonsY - ((i % 4) * 18.0));
const float z = 1.0;

button->setPosition(x, y, z);

Expand All @@ -100,8 +100,8 @@ PartyLeader::PartyLeader(Module &module) : _module(&module),
_portrait =
new PortraitWidget(*this, "LeaderPortrait", "gui_po_nwnlogo_", Portrait::kSizeMedium);

_portrait->setPosition(-67.0, -103.0, -100.0);
_portrait->setTooltipPosition(-50.0, 50.0, -1.0);
_portrait->setPosition(-67.0, -3.0, 1.0);
//_portrait->setTooltipPosition(-50.0, 50.0, -1.0);

addWidget(_portrait);

Expand All @@ -111,7 +111,7 @@ PartyLeader::PartyLeader(Module &module) : _module(&module),
_health = new QuadWidget(*this, "LeaderHealthbar", "", 0.0, 0.0, 6.0, 100.0);

_health->setColor(1.0, 0.0, 0.0, 1.0);
_health->setPosition(-76.0, -103.0, -100.0);
_health->setPosition(-76.0, -3.0, 1.0);

addWidget(_health);

Expand Down Expand Up @@ -152,7 +152,14 @@ void PartyLeader::setHealth(int32 current, int32 max) {
if (_maxHP > 0)
barLength = CLIP(((float) current) / ((float) max), 0.0f, 1.0f) * 100.0;

_health->setHeight(barLength);
float oldHeight = _health->getHeight();
float oldWidth = _health->getWidth();

float healthX, healthY, healthZ;
_health->getPosition(healthX, healthY, healthZ);

_health->setSize(floor(oldWidth), floor(barLength));
_health->setPosition(floor(healthX), floor(healthY - oldHeight + barLength), healthZ);

updatePortraitTooltip();
}
Expand All @@ -167,15 +174,17 @@ void PartyLeader::callbackActive(Widget &widget) {
}

void PartyLeader::updatePortraitTooltip() {
/*
Common::UString tooltip =
Common::UString::sprintf("%s %d/%d\n%s",
_name.c_str(), _currentHP, _maxHP, _area.c_str());
_portrait->setTooltip(tooltip);
*/
}

void PartyLeader::notifyResized(int oldWidth, int oldHeight, int newWidth, int newHeight) {
setPosition(newWidth / 2.0, newHeight / 2.0, -10.0);
setPosition(newWidth / 2.0, newHeight / 2.0, -400.0);
}

} // End of namespace NWN
Expand Down

0 comments on commit e5c702d

Please sign in to comment.