add more cheating-related rules
This commit is contained in:
@@ -42,7 +42,8 @@ static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
|
||||
std::shared_ptr<UINode> create_debug_panel(
|
||||
Engine* engine,
|
||||
Level* level,
|
||||
Player* player
|
||||
Player* player,
|
||||
bool allowDebugCheats
|
||||
) {
|
||||
auto panel = std::make_shared<Panel>(glm::vec2(300, 200), glm::vec4(5.0f), 2.0f);
|
||||
panel->setId("hud.debug-panel");
|
||||
@@ -162,16 +163,20 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||
box->setTextSupplier([=]() {
|
||||
return util::to_wstring(player->getPosition()[ax], 2);
|
||||
});
|
||||
box->setTextConsumer([=](const std::wstring& text) {
|
||||
try {
|
||||
glm::vec3 position = player->getPosition();
|
||||
position[ax] = std::stoi(text);
|
||||
player->teleport(position);
|
||||
} catch (std::exception& _){
|
||||
}
|
||||
});
|
||||
box->setOnEditStart([=](){
|
||||
boxRef->setText(std::to_wstring(static_cast<int>(player->getPosition()[ax])));
|
||||
if (allowDebugCheats) {
|
||||
box->setTextConsumer([=](const std::wstring& text) {
|
||||
try {
|
||||
glm::vec3 position = player->getPosition();
|
||||
position[ax] = std::stoi(text);
|
||||
player->teleport(position);
|
||||
} catch (std::exception& _){
|
||||
}
|
||||
});
|
||||
}
|
||||
box->setOnEditStart([=]() {
|
||||
boxRef->setText(
|
||||
std::to_wstring(static_cast<int>(player->getPosition()[ax]))
|
||||
);
|
||||
});
|
||||
box->setSize(glm::vec2(230, 27));
|
||||
|
||||
@@ -188,13 +193,13 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||
util::lfill(std::to_wstring(minute), 2, L'0');
|
||||
return L"time: "+timeString;
|
||||
}));
|
||||
{
|
||||
if (allowDebugCheats) {
|
||||
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 1.0f, 0.005f, 8);
|
||||
bar->setSupplier([&]() {return worldInfo.daytime;});
|
||||
bar->setConsumer([&](double val) {worldInfo.daytime = val;});
|
||||
panel->add(bar);
|
||||
}
|
||||
{
|
||||
if (allowDebugCheats) {
|
||||
auto bar = std::make_shared<TrackBar>(0.0f, 1.0f, 0.0f, 0.005f, 8);
|
||||
bar->setSupplier([&]() {return worldInfo.fog;});
|
||||
bar->setConsumer([&](double val) {worldInfo.fog = val;});
|
||||
|
||||
Reference in New Issue
Block a user