Skip to content

Commit

Permalink
KOTOR: Add saving/loading and defaults to all checkboxes in options
Browse files Browse the repository at this point in the history
To see the effects I also added state changing to the checkbox widget.
  • Loading branch information
fdde committed Oct 28, 2017
1 parent 5373d01 commit 04421f7
Show file tree
Hide file tree
Showing 17 changed files with 360 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/engines/kotor/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@ void GUI::addBackground(const Common::UString &background) {
_background->setType(background);
}

void GUI::setCheckBoxState(const Common::UString &tag, bool state) {
WidgetCheckBox &checkbox = *getCheckBox(tag, true);
checkbox.setState(state);
}

bool GUI::getCheckBoxState(const Common::UString &tag) {
WidgetCheckBox &checkbox = *getCheckBox(tag, true);
return checkbox.getState();
}

} // End of namespace KotOR

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

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

void setCheckBoxState(const Common::UString &tag, bool state);
bool getCheckBoxState(const Common::UString &tag);

private:
struct WidgetContext {
const Aurora::GFF3Struct *strct;
Expand Down
1 change: 1 addition & 0 deletions src/engines/kotor/gui/main/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void OptionsMenu::callbackActive(Widget &widget) {

void OptionsMenu::adoptChanges() {
dynamic_cast<OptionsGameplayMenu &>(*_gameplay).adoptChanges();
dynamic_cast<OptionsAutoPauseMenu &>(*_autopause).adoptChanges();
}


Expand Down
79 changes: 79 additions & 0 deletions src/engines/kotor/gui/options/autopause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* The auto pause menu.
*/

#include "src/common/configman.h"

#include "src/engines/aurora/widget.h"

#include "src/engines/kotor/gui/options/autopause.h"
Expand All @@ -47,18 +49,95 @@ OptionsAutoPauseMenu::~OptionsAutoPauseMenu() {

}

void OptionsAutoPauseMenu::show() {
GUI::show();

_endOfCombatRound = ConfigMan.getBool("endofcombatround", false);
setCheckBoxState("CB_ENDROUND", _endOfCombatRound);

_enemySighted = ConfigMan.getBool("enemysighted", false);
setCheckBoxState("CB_ENEMYSIGHTED", _enemySighted);

_mineSighted = ConfigMan.getBool("minesighted", false);
setCheckBoxState("CB_MINESIGHTED", _mineSighted);

_partyMemberDown = ConfigMan.getBool("partymemberdown", false);
setCheckBoxState("CB_PARTYKILLED", _partyMemberDown);

_actionMenuUsed = ConfigMan.getBool("actionmenuused", false);
setCheckBoxState("CB_ACTIONMENU", _actionMenuUsed);

_newTargetSelected = ConfigMan.getBool("newtargetselected", false);
setCheckBoxState("CB_TRIGGERS", _newTargetSelected);
}

void OptionsAutoPauseMenu::callbackActive(Widget &widget) {

if (widget.getTag() == "BTN_DEFAULT") {
_endOfCombatRound = false;
setCheckBoxState("CB_ENDROUND", _endOfCombatRound);

_enemySighted = false;
setCheckBoxState("CB_ENEMYSIGHTED", _enemySighted);

_mineSighted = false;
setCheckBoxState("CB_MINESIGHTED", _mineSighted);

_partyMemberDown = false;
setCheckBoxState("CB_PARTYKILLED", _partyMemberDown);

_actionMenuUsed = false;
setCheckBoxState("CB_ACTIONMENU", _actionMenuUsed);

_newTargetSelected = false;
setCheckBoxState("CB_TRIGGERS", _newTargetSelected);
}

if (widget.getTag() == "BTN_BACK") {
adoptChanges();
_returnCode = 1;
return;
}

if (widget.getTag() == "CB_ENDROUND") {
_endOfCombatRound = getCheckBoxState("CB_ENDROUND");
return;
}

if (widget.getTag() == "CB_ENEMYSIGHTED") {
_enemySighted = getCheckBoxState("CB_ENEMYSIGHTED");
return;
}

if (widget.getTag() == "CB_MINESIGHTED") {
_mineSighted = getCheckBoxState("CB_MINESIGHTED");
return;
}

if (widget.getTag() == "CB_PARTYKILLED") {
_partyMemberDown = getCheckBoxState("CB_PARTYKILLED");
return;
}

if (widget.getTag() == "CB_ACTIONMENU") {
_actionMenuUsed = getCheckBoxState("CB_ACTIONMENU");
return;
}

if (widget.getTag() == "CB_TRIGGERS") {
_newTargetSelected = getCheckBoxState("CB_TRIGGERS");
return;
}
}

void OptionsAutoPauseMenu::adoptChanges() {
ConfigMan.setBool("endofcombatround", _endOfCombatRound, true);
ConfigMan.setBool("enemysighted", _enemySighted, true);
ConfigMan.setBool("minesighted", _mineSighted, true);
ConfigMan.setBool("partymemberdown", _partyMemberDown, true);
ConfigMan.setBool("actionmenuused", _actionMenuUsed, true);
ConfigMan.setBool("newtargetselected", _newTargetSelected, true);
}

} // End of namespace KotOR

Expand Down
12 changes: 12 additions & 0 deletions src/engines/kotor/gui/options/autopause.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,20 @@ class OptionsAutoPauseMenu : public GUI {
OptionsAutoPauseMenu(::Engines::Console *console = 0);
~OptionsAutoPauseMenu();

virtual void show();

virtual void adoptChanges();

protected:
void callbackActive(Widget &widget);

private:
bool _endOfCombatRound;
bool _enemySighted;
bool _mineSighted;
bool _partyMemberDown;
bool _actionMenuUsed;
bool _newTargetSelected;
};

} // End of namespace KotOR
Expand Down
66 changes: 64 additions & 2 deletions src/engines/kotor/gui/options/gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,23 @@ OptionsGameplayMenu::~OptionsGameplayMenu() {
void OptionsGameplayMenu::show() {
GUI::show();

_difficulty = CLIP(ConfigMan.getInt("Difficulty Level", 0), 0, 2);
_difficulty = CLIP(ConfigMan.getInt("difficultylevel", 0), 0, 2);
updateDifficulty(_difficulty);

_autoLevelUp = ConfigMan.getBool("autolevelup", false);
setCheckBoxState("CB_LEVELUP", _autoLevelUp);

_mouseMove = ConfigMan.getBool("mousemove", false);
setCheckBoxState("CB_INVERTCAM", _mouseMove);

_autoSave = ConfigMan.getBool("autosave", false);
setCheckBoxState("CB_AUTOSAVE", _autoSave);

_reverseMinigameY = ConfigMan.getBool("reverseminigameyaxis", false);
setCheckBoxState("CB_REVERSE", _reverseMinigameY);

_combatMovement = ConfigMan.getBool("combatmovement", false);
setCheckBoxState("CB_DISABLEMOVE", _combatMovement);
}


Expand All @@ -87,24 +102,66 @@ void OptionsGameplayMenu::callbackActive(Widget &widget) {
}

if (widget.getTag() == "BTN_MOUSE") {
adoptChanges();
sub(*_mousesettings);
return;
}

if (widget.getTag() == "BTN_KEYMAP") {
adoptChanges();
sub(*_keyboardconfiguration);
return;
}

if (widget.getTag() == "BTN_DEFAULT") {
_difficulty = 1;
updateDifficulty(_difficulty);

_autoLevelUp = false;
setCheckBoxState("CB_LEVELUP", _autoLevelUp);

_mouseMove = false;
setCheckBoxState("CB_INVERTCAM", _mouseMove);

_autoSave = false;
setCheckBoxState("CB_AUTOSAVE", _autoSave);

_reverseMinigameY = false;
setCheckBoxState("CB_REVERSE", _reverseMinigameY);

_combatMovement = false;
setCheckBoxState("CB_DISABLEMOVE", _combatMovement);
}

if (widget.getTag() == "BTN_BACK") {
_returnCode = 1;
return;
}

if (widget.getTag() == "CB_LEVELUP") {
_autoLevelUp = getCheckBoxState("CB_LEVELUP");
return;
}

if (widget.getTag() == "CB_INVERTCAM") {
_mouseMove = getCheckBoxState("CB_INVERTCAM");
return;
}

if (widget.getTag() == "CB_AUTOSAVE") {
_autoSave = getCheckBoxState("CB_AUTOSAVE");
return;
}

if (widget.getTag() == "CB_REVERSE") {
_reverseMinigameY = getCheckBoxState("CB_REVERSE");
return;
}

if (widget.getTag() == "CB_DISABLEMOVE") {
_combatMovement = getCheckBoxState("CB_DISABLEMOVE");
return;
}
}

void OptionsGameplayMenu::updateDifficulty(int difficulty) {
Expand All @@ -128,7 +185,12 @@ void OptionsGameplayMenu::updateDifficulty(int difficulty) {
}

void OptionsGameplayMenu::adoptChanges() {
ConfigMan.setInt("Difficulty Level", _difficulty, true);
ConfigMan.setInt("difficultylevel", _difficulty, true);
ConfigMan.setBool("autolevelup", _autoLevelUp, true);
ConfigMan.setBool("mousemove", _mouseMove, true);
ConfigMan.setBool("autosave", _autoSave, true);
ConfigMan.setBool("reverseminigameyaxis", _reverseMinigameY, true);
ConfigMan.setBool("combatmovement", _combatMovement, true);
}

} // End of namespace KotOR
Expand Down
5 changes: 5 additions & 0 deletions src/engines/kotor/gui/options/gameplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class OptionsGameplayMenu : public GUI {

private:
int _difficulty;
bool _autoLevelUp;
bool _mouseMove;
bool _autoSave;
bool _reverseMinigameY;
bool _combatMovement;

void updateDifficulty(int difficulty);

Expand Down
33 changes: 33 additions & 0 deletions src/engines/kotor/gui/options/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* The graphics menu.
*/

#include "src/common/configman.h"

#include "src/engines/aurora/widget.h"

#include "src/engines/kotor/gui/options/graphics.h"
Expand All @@ -46,21 +48,52 @@ OptionsGraphicsMenu::OptionsGraphicsMenu(::Engines::Console *console) : GUI(cons
OptionsGraphicsMenu::~OptionsGraphicsMenu() {
}

void OptionsGraphicsMenu::show() {
GUI::show();

_shadows = ConfigMan.getBool("shadows", false);
setCheckBoxState("CB_SHADOWS", _shadows);

_grass = ConfigMan.getBool("grass", false);
setCheckBoxState("CB_GRASS", _grass);
}

void OptionsGraphicsMenu::callbackActive(Widget &widget) {

if (widget.getTag() == "BTN_ADVANCED") {
adoptChanges();
sub(*_advanced);
return;
}

if (widget.getTag() == "BTN_DEFAULT") {
_shadows = false;
setCheckBoxState("CB_SHADOWS", _shadows);

_grass = false;
setCheckBoxState("CB_GRASS", _grass);
}

if (widget.getTag() == "BTN_BACK") {
adoptChanges();
_returnCode = 1;
return;
}

if (widget.getTag() == "CB_SHADOWS") {
_shadows = getCheckBoxState("CB_SHADOWS");
return;
}

if (widget.getTag() == "CB_GRASS") {
_grass = getCheckBoxState("CB_GRASS");
return;
}
}

void OptionsGraphicsMenu::adoptChanges() {
ConfigMan.setBool("shadows", _shadows, false);
ConfigMan.setBool("grass", _grass, false);
}

} // End of namespace KotOR
Expand Down
7 changes: 7 additions & 0 deletions src/engines/kotor/gui/options/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ class OptionsGraphicsMenu : public GUI {
OptionsGraphicsMenu(::Engines::Console *console = 0);
~OptionsGraphicsMenu();

virtual void show();

virtual void adoptChanges();

protected:
void callbackActive(Widget &widget);

private:
bool _shadows;
bool _grass;

Common::ScopedPtr<GUI> _advanced;
};

Expand Down

0 comments on commit 04421f7

Please sign in to comment.