Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ArxGame: Implement quick level transitions
Level transitions can be configured to either happen immediately or to
be activated using the jump key binding.

Implements: feature request #105
  • Loading branch information
dscharrer committed Oct 26, 2017
1 parent 8d66681 commit c43bbb9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/core/ArxGame.cpp
Expand Up @@ -1261,7 +1261,12 @@ void ArxGame::doFrame() {
}

// Are we being teleported ?
if(!TELEPORT_TO_LEVEL.empty() && CHANGE_LEVEL_ICON == ChangeLevelNow) {
if(!TELEPORT_TO_LEVEL.empty() && CHANGE_LEVEL_ICON != NoChangeLevel
&& (CHANGE_LEVEL_ICON == ChangeLevelNow
|| config.input.quickLevelTransition == ChangeLevelImmediately
|| (config.input.quickLevelTransition == JumpToChangeLevel
&& GInput->actionPressed(CONTROLS_CUST_JUMP)))) {
// TODO allow binding the same key to multiple actions so that we can have a separate binding for this
benchmark::begin(benchmark::LoadLevel);
LogDebug("teleport to " << TELEPORT_TO_LEVEL << " " << TELEPORT_TO_POSITION << " " << TELEPORT_TO_ANGLE);
CHANGE_LEVEL_ICON = NoChangeLevel;
Expand Down
7 changes: 6 additions & 1 deletion src/core/Config.cpp
Expand Up @@ -79,7 +79,8 @@ const int
mouseAcceleration = 0,
migration = Config::OriginalAssets,
quicksaveSlots = 3,
bufferSize = 0;
bufferSize = 0,
quickLevelTransition = JumpToChangeLevel;

const bool
fullscreen = true,
Expand Down Expand Up @@ -231,6 +232,7 @@ const std::string
autoDescription = "auto_description",
borderTurning = "border_turning",
useAltRuneRecognition = "use_alt_rune_recognition",
quickLevelTransition = "quick_level_transition",
allowConsole = "allow_console";

// Input key options
Expand Down Expand Up @@ -460,6 +462,7 @@ bool Config::save() {
writer.writeKey(Key::autoDescription, input.autoDescription);
writer.writeKey(Key::borderTurning, input.borderTurning);
writer.writeKey(Key::useAltRuneRecognition, input.useAltRuneRecognition);
writer.writeKey(Key::quickLevelTransition, int(input.quickLevelTransition));
if(input.allowConsole) {
// Only write this if true so that switching from release to debug builds enables the console
writer.writeKey(Key::allowConsole, input.allowConsole);
Expand Down Expand Up @@ -597,6 +600,8 @@ bool Config::init(const fs::path & file) {
input.autoDescription = reader.getKey(Section::Input, Key::autoDescription, Default::autoDescription);
input.borderTurning = reader.getKey(Section::Input, Key::borderTurning, Default::borderTurning);
input.useAltRuneRecognition = reader.getKey(Section::Input, Key::useAltRuneRecognition, Default::useAltRuneRecognition);
int quickLevelTransition = reader.getKey(Section::Input, Key::quickLevelTransition, Default::quickLevelTransition);
input.quickLevelTransition = QuickLevelTransition(glm::clamp(quickLevelTransition, 0, 2));
input.allowConsole = reader.getKey(Section::Input, Key::allowConsole, Default::allowConsole);

// Get action key settings
Expand Down
7 changes: 7 additions & 0 deletions src/core/Config.h
Expand Up @@ -90,6 +90,12 @@ enum UIScaleFilter {
UIFilterBilinear = 1
};

enum QuickLevelTransition {
NoQuickLevelTransition = 0,
JumpToChangeLevel = 1,
ChangeLevelImmediately = 2,
};

struct ActionKey {

explicit ActionKey(InputKeyId key_0 = UNUSED,
Expand Down Expand Up @@ -189,6 +195,7 @@ class Config {
bool rawMouseInput;
bool borderTurning;
bool useAltRuneRecognition;
QuickLevelTransition quickLevelTransition;
bool allowConsole;

} input;
Expand Down

0 comments on commit c43bbb9

Please sign in to comment.