Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions data/forms/moreoptions.form
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<size width="250" height="16"/>
</label>
</checkbox> -->
<!-- Left side -->
<checkbox id="DEBUGVIS_TOGGLE">
<position x="40" y="316"/>
<size width="270" height="16"/>
Expand Down Expand Up @@ -122,6 +123,18 @@
<size width="250" height="16"/>
</label>
</checkbox>
<!-- Right side -->
<checkbox id="MOUSEGRAB_TOGGLE">
<position x="311" y="316"/>
<size width="270" height="16"/>
<image>BUTTON_CHECKBOX_FALSE</image>
<imagechecked>BUTTON_CHECKBOX_TRUE</imagechecked>
<label text="Toggle mouse grab">
<position x="24" y="0"/>
<font>smalfont</font>
<size width="270" height="16"/>
</label>
</checkbox>
<label id="CITYLIST_NAME">
<position x="305" y="70"/>
<font>smalfont</font>
Expand Down
11 changes: 8 additions & 3 deletions framework/framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,7 @@ void Framework::displayInitialise()
SDL_GetWindowSize(p->window, &width, &height);
p->windowSize = {width, height};

auto mouseCapture = Options::mouseCaptureOption.get();
SDL_SetWindowMouseGrab(p->window, mouseCapture ? SDL_TRUE : SDL_FALSE);
SDL_SetRelativeMouseMode(mouseCapture ? SDL_TRUE : SDL_FALSE);
setMouseGrab();

// FIXME: Scale is currently stored as an integer in 1/100 units (ie 100 is 1.0 == same
// size)
Expand Down Expand Up @@ -1117,6 +1115,13 @@ void Framework::showToolTip(sp<Image> image, const Vec2<int> &position)
p->toolTipPosition = position;
}

void Framework::setMouseGrab()
{
auto mouseCapture = Options::mouseCaptureOption.get();
SDL_SetWindowMouseGrab(p->window, mouseCapture ? SDL_TRUE : SDL_FALSE);
SDL_SetRelativeMouseMode(mouseCapture ? SDL_TRUE : SDL_FALSE);
}

UString Framework::textGetClipboard()
{
UString str;
Expand Down
2 changes: 2 additions & 0 deletions framework/framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class Framework
void toolTipTimerCallback(unsigned int interval, void *data);
void showToolTip(sp<Image> image, const Vec2<int> &position);

void setMouseGrab();

UString textGetClipboard();

void threadPoolTaskEnqueue(std::function<void()> task);
Expand Down
7 changes: 7 additions & 0 deletions game/ui/general/moreoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ void MoreOptions::begin()
// TODO: Implement vanilla mode
// menuform->findControlTyped<CheckBox>("VANILLA_TOGGLE")
// ->setChecked(config().getBool("Options.Misc.VanillaToggle"));
// Left side
menuform->findControlTyped<CheckBox>("DEBUGVIS_TOGGLE")
->setChecked(config().getBool("OpenApoc.NewFeature.DebugCommandsVisible"));
menuform->findControlTyped<CheckBox>("SCROLLSOUND_TOGGLE")
Expand All @@ -579,6 +580,9 @@ void MoreOptions::begin()
->setChecked(config().getBool("OpenApoc.NewFeature.EnableAgentTemplates"));
menuform->findControlTyped<CheckBox>("SEEDRNG_TOGGLE")
->setChecked(config().getBool("OpenApoc.NewFeature.SeedRng"));
// Right side
menuform->findControlTyped<CheckBox>("MOUSEGRAB_TOGGLE")
->setChecked(config().getBool("Framework.MouseCapture"));
}

void MoreOptions::pause() {}
Expand All @@ -602,6 +606,9 @@ void MoreOptions::finish()
menuform->findControlTyped<CheckBox>("TEMPLATES_TOGGLE")->isChecked());
config().set("OpenApoc.NewFeature.SeedRng",
menuform->findControlTyped<CheckBox>("SEEDRNG_TOGGLE")->isChecked());
config().set("Framework.MouseCapture",
menuform->findControlTyped<CheckBox>("MOUSEGRAB_TOGGLE")->isChecked());
fw().setMouseGrab();
saveLists();
}

Expand Down