Skip to content

Commit

Permalink
Plugins: Update API with more C++ style functions for VR
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 12, 2024
1 parent 96d62a7 commit ad3a2a2
Show file tree
Hide file tree
Showing 2 changed files with 357 additions and 16 deletions.
27 changes: 11 additions & 16 deletions examples/example_plugin/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,44 +513,39 @@ class ExamplePlugin : public uevr::Plugin {
void internal_frame() {
if (ImGui::Begin("Super Cool Plugin")) {
ImGui::Text("Hello from the super cool plugin!");
ImGui::Text("Snap turn: %i", API::get()->param()->vr->is_snap_turn_enabled());
ImGui::Text("Decoupled pitch: %i", API::get()->param()->vr->is_decoupled_pitch_enabled());
ImGui::Text("Snap turn: %i", API::VR::is_snap_turn_enabled());
ImGui::Text("Decoupled pitch: %i", API::VR::is_decoupled_pitch_enabled());
if (ImGui::Button("Toggle snap turn")) {
API::get()->param()->vr->set_snap_turn_enabled(!API::get()->param()->vr->is_snap_turn_enabled());
API::VR::set_snap_turn_enabled(!API::VR::is_snap_turn_enabled());
}

if (ImGui::Button("Toggle decoupled pitch")) {
API::get()->param()->vr->set_decoupled_pitch_enabled(!API::get()->param()->vr->is_decoupled_pitch_enabled());
API::VR::set_decoupled_pitch_enabled(!API::VR::is_decoupled_pitch_enabled());
}

if (ImGui::Button("Screw up world scale")) {
API::get()->param()->vr->set_mod_value("VR_WorldScale", "1.337");
API::VR::set_mod_value("VR_WorldScale", 1.337f);
}

if (ImGui::Button("Toggle GUI")) {
char buffer[256]{};
API::get()->param()->vr->get_mod_value("VR_EnableGUI", buffer, sizeof(buffer));

const auto enabled = std::string_view{buffer} == "true";

API::get()->param()->vr->set_mod_value("VR_EnableGUI", enabled ? "false" : "true");
const bool enabled = API::VR::get_mod_value<bool>("VR_EnableGUI");
API::VR::set_mod_value("VR_EnableGUI", !enabled);
}

static char input[256]{};
if (ImGui::InputText("Get mod value", input, sizeof(input))) {

}

char buffer[256]{};
API::get()->param()->vr->get_mod_value(input, buffer, sizeof(buffer));
ImGui::Text("Mod value: %s", buffer);
std::string mod_value = API::VR::get_mod_value<std::string>(input);
ImGui::Text("Mod value: %s", mod_value.c_str());

if (ImGui::Button("Save Config")) {
API::get()->param()->vr->save_config();
API::VR::save_config();
}

if (ImGui::Button("Reload Config")) {
API::get()->param()->vr->reload_config();
API::VR::reload_config();
}

if (ImGui::Button("Toggle UObjectHook disabled")) {
Expand Down
Loading

0 comments on commit ad3a2a2

Please sign in to comment.