Skip to content
Open
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
27 changes: 24 additions & 3 deletions src/screens/gm/gameMasterScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,35 @@ GameMasterScreen::GameMasterScreen(RenderLayer* render_layer)
box_selection_overlay->layout.fill_width = false;
box_selection_overlay->hide();

pause_button = new GuiToggleButton(this, "PAUSE_BUTTON", tr("button", "Pause"), [](bool value) {
if (!value)
pause_button = new GuiToggleButton(this, "PAUSE_BUTTON", tr("button", "Pause"), [this](bool value) {
if (!value) {
engine->setGameSpeed(1.0f);
slow_button->setValue(false);
}
else
{
engine->setGameSpeed(0.0f);
slow_button->setValue(false);
}
});
pause_button->setValue(engine->getGameSpeed() == 0.0f)->setPosition(20, 20, sp::Alignment::TopLeft)->setSize(250, 50);
slow_button = new GuiToggleButton(this, "SLOW_BUTTON", tr("button", "Slow"), [this](bool value) {
if (!value) {
engine->setGameSpeed(1.0f);
pause_button->setValue(false);
}
else
{
engine->setGameSpeed(0.1f);
pause_button->setValue(false);
}
});
slow_button->setValue(false)->setPosition(300, 20, sp::Alignment::TopLeft)->setSize(250, 50);

intercept_comms_button = new GuiToggleButton(this, "INTERCEPT_COMMS_BUTTON", tr("button", "Intercept all comms"), [](bool value) {
gameGlobalInfo->intercept_all_comms_to_gm = value;
});
intercept_comms_button->setValue(gameGlobalInfo->intercept_all_comms_to_gm)->setTextSize(20)->setPosition(300, 20, sp::Alignment::TopLeft)->setSize(200, 25);
intercept_comms_button->setValue(gameGlobalInfo->intercept_all_comms_to_gm)->setTextSize(20)->setPosition(580, 20, sp::Alignment::TopLeft)->setSize(200, 25);

faction_selector = new GuiSelector(this, "FACTION_SELECTOR", [this](int index, string value) {
for (auto obj : targets.getTargets())
Expand Down Expand Up @@ -478,6 +495,10 @@ void GameMasterScreen::update(float delta)
// Track selection indices to determine "*mixed*" state.
std::unordered_map<string, size_t> selection_info_index;

// Update pause button
slow_button->setValue(engine->getGameSpeed() == 0.1f);
pause_button->setValue(engine->getGameSpeed() == 0.0f);

// List position if only one entity is selected.
if (targets.getTargets().size() == 1)
{
Expand Down
1 change: 1 addition & 0 deletions src/screens/gm/gameMasterScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class GameMasterScreen : public GuiCanvas, public Updatable
GuiButton* player_comms_hail;
GuiButton* global_message_button;
GuiToggleButton* pause_button;
GuiToggleButton* slow_button;
GuiToggleButton* intercept_comms_button;
GuiButton* tweak_button;
GuiRadarZoomSlider* zoom_slider;
Expand Down
27 changes: 27 additions & 0 deletions src/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,21 @@ static bool luaIsGamePaused()
return engine->getGameSpeed() == 0.0f;
}

static void luaSlowGame()
{
engine->setGameSpeed(0.1f);
}

static void luaUnslowGame()
{
engine->setGameSpeed(1.0f);
}

static bool luaIsGameSlowed()
{
return engine->getGameSpeed() == 0.1f;
}

static void luaPlaySoundFile(string filename)
{
int n = filename.rfind(".");
Expand Down Expand Up @@ -1405,6 +1420,18 @@ bool setupScriptEnvironment(sp::script::Environment& env)
/// Returns true if the game is paused.
/// Example: local is_paused = isGamePaused()
env.setGlobal("isGamePaused", &luaIsGamePaused);
/// void slowGame()
/// Slows down the game to 10% game speed.
/// Example: slowGame()
env.setGlobal("slowGame", &luaSlowGame);
/// void unslowGame()
/// Restores the normal game speed.
/// Example: unslowGame()
env.setGlobal("unslowGame", &luaUnslowGame);
/// bool isGameSlowed()
/// Returns true if the game was slowed down by slowGame.
/// Example: local is_slowed = isGameSlowed()
env.setGlobal("isGameSlowed", &luaIsGameSlowed);
/// void playSoundFile(string filename)
/// Plays the given audio file on the server.
/// Paths are relative to the resources/ directory.
Expand Down
Loading