Skip to content

Commit

Permalink
KOTOR: All text button widgets now highlight on mouseover.
Browse files Browse the repository at this point in the history
This seems to be the behavior in the original game,
and simplifies the code.
  • Loading branch information
ImperatorPrime committed Aug 7, 2013
1 parent f46ed0a commit a6f4485
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 40 deletions.
7 changes: 0 additions & 7 deletions src/engines/kotor/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,6 @@ void GUI::addBackground(const Common::UString &background) {
addWidget(backPanel);
}

void GUI::setDefaultHighlighting(Graphics::Aurora::Highlightable *highlightable) {
highlightable->setHighlightable(true);
highlightable->setHighlightDelta(0, 0, 0, .05);
highlightable->setHighlightLowerBound(1, 1, 0, .2);
highlightable->setHighlightUpperBound(1, 1, 0, 1);
}

} // End of namespace KotOR

} // End of namespace Engines
2 changes: 0 additions & 2 deletions src/engines/kotor/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class GUI : public Engines::GUI {

void addBackground(const Common::UString &background);

void setDefaultHighlighting(Graphics::Aurora::Highlightable *highlightable);

private:
struct WidgetContext {
const Aurora::GFFStruct *strct;
Expand Down
9 changes: 0 additions & 9 deletions src/engines/kotor/gui/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ MainMenu::MainMenu(Module &module, bool isXbox) : _module(&module), _isXbox(isXb
load(isXbox ? "mainmenu" : "mainmenu16x12");

addBackground("back");
configureHighlighting();

_movies = 0;
_options = 0;
Expand All @@ -76,14 +75,6 @@ void MainMenu::createOptions() {

}

void MainMenu::configureHighlighting() {
setDefaultHighlighting(getButton("BTN_NEWGAME")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_LOADGAME")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_MOVIES")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_OPTIONS")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_EXIT")->getTextHighlightableComponent());
}

void MainMenu::initWidget(Widget &widget) {
// BioWare logo, the original game doesn't display it.
if (widget.getTag() == "LBL_BW") {
Expand Down
1 change: 0 additions & 1 deletion src/engines/kotor/gui/main/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class MainMenu : public GUI {

void createMovies();
void createOptions();
void configureHighlighting();
};

} // End of namespace KotOR
Expand Down
18 changes: 0 additions & 18 deletions src/engines/kotor/gui/main/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ OptionsMenu::OptionsMenu() {
_graphics = new OptionsGraphicsMenu();
_sound = new OptionsSoundMenu();

configureText();

}

OptionsMenu::~OptionsMenu() {
Expand All @@ -64,22 +62,6 @@ OptionsMenu::~OptionsMenu() {
delete _sound;
}

void OptionsMenu::configureText() {
setDefaultHighlighting(getButton("BTN_GAMEPLAY")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_FEEDBACK")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_AUTOPAUSE")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_GRAPHICS")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_SOUND")->getTextHighlightableComponent());
setDefaultHighlighting(getButton("BTN_BACK")->getTextHighlightableComponent());
}

void OptionsMenu::setDefaultHighlighting(Graphics::Aurora::Highlightable* highlightable) {
highlightable->setHighlightable(true);
highlightable->setHighlightDelta(0, 0, 0, .05);
highlightable->setHighlightLowerBound(1, 1, 0, .2);
highlightable->setHighlightUpperBound(1, 1, 0, 1);
}

void OptionsMenu::callbackActive(Widget &widget) {
if (widget.getTag() == "BTN_GAMEPLAY") {
sub(*_gameplay);
Expand Down
3 changes: 0 additions & 3 deletions src/engines/kotor/gui/main/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class OptionsMenu : public GUI {
private:
void adoptChanges();

void configureText();
void setDefaultHighlighting(Graphics::Aurora::Highlightable* highlightable);

GUI *_gameplay;
GUI *_feedback;
GUI *_autopause;
Expand Down
10 changes: 10 additions & 0 deletions src/engines/kotor/gui/widgets/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ WidgetButton::~WidgetButton() {

void WidgetButton::load(const Aurora::GFFStruct &gff) {
KotORWidget::load(gff);
if(getTextHighlightableComponent() != NULL) {
setDefaultHighlighting(getTextHighlightableComponent());
}
}

void WidgetButton::mouseUp(uint8 state, float x, float y) {
Expand Down Expand Up @@ -80,6 +83,13 @@ void WidgetButton::leave() {
}
}

void WidgetButton::setDefaultHighlighting(Graphics::Aurora::Highlightable *highlightable) {
highlightable->setHighlightable(true);
highlightable->setHighlightDelta(0, 0, 0, .05);
highlightable->setHighlightLowerBound(1, 1, 0, .2);
highlightable->setHighlightUpperBound(1, 1, 0, 1);
}

} // End of namespace KotOR

} // End of namespace Engines
2 changes: 2 additions & 0 deletions src/engines/kotor/gui/widgets/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class WidgetButton : public KotORWidget {
virtual void leave();

private:

void setDefaultHighlighting(Graphics::Aurora::Highlightable *highlightable);
Sound::ChannelHandle _sound;
float _unselectedR, _unselectedG, _unselectedB, _unselectedA;
};
Expand Down

0 comments on commit a6f4485

Please sign in to comment.