Skip to content

Commit

Permalink
Closes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
xNWP committed Dec 20, 2018
1 parent 9ba36a8 commit 88a9833
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 6 deletions.
5 changes: 4 additions & 1 deletion res/c4d_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ enum
STR_USER_SETTINGS_ERROR,
STR_ASK_AUTO_UPDATE,
STR_VERSION_UPTODATE,
STR_VERSION_OUTDATED
STR_VERSION_OUTDATED,
STR_USE_GLOBAL_POSROT,
ID_USE_GLOBAL_POSROT,
STR_SETTINGS
};

#endif // !HLL_C4D_SYMBOLS_H__
2 changes: 2 additions & 0 deletions res/strings_en-US/c4d_strings.str
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ STRINGTABLE
STR_ASK_AUTO_UPDATE "Would you like HLAELiveLink to automatically check for updates?";
STR_VERSION_UPTODATE "You are using the latest version of HLAELiveLink!";
STR_VERSION_OUTDATED "An update for HLAELiveLink is available, would you link to download it now?";
STR_USE_GLOBAL_POSROT "Use Global Position/Rotation";
STR_SETTINGS "Settings";
}
2 changes: 1 addition & 1 deletion source/hll_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define HLL_GLOBALS_H__

#define HLL_VERSION_MAJOR 1
#define HLL_VERSION_MINOR 0
#define HLL_VERSION_MINOR 1

#define ID_HLAELIVELINK 1050016

Expand Down
60 changes: 56 additions & 4 deletions source/hll_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,30 @@ Bool HLL::Gui::InitValues()
setting = xml_map["settings.user.pollrate"_s];
if (setting->GetValue().IsPopulated())
g_HLL_PollRate = setting->GetValue();

// Use Global Coords
setting = xml_map["settings.user.globalcoords"_s];
if (setting->GetValue().IsPopulated())
{
if (setting->GetValue() == "true")
{
g_HLL_UseGlobalCoords = true;
}
else
{
g_HLL_UseGlobalCoords = false;
}
}
}

// Create Menu
MenuFlushAll();

MenuSubBegin(GeLoadString(STR_SETTINGS));
MenuAddString(ID_USE_GLOBAL_POSROT, GeLoadString(STR_USE_GLOBAL_POSROT));
MenuInitString(ID_USE_GLOBAL_POSROT, true, g_HLL_UseGlobalCoords);
MenuSubEnd();

MenuSubBegin(GeLoadString(STR_UPDATE));
MenuAddString(CHECK_FOR_UPDATES, GeLoadString(STR_CHECK_FOR_UPDATES));
MenuInitString(CHECK_FOR_UPDATES, true, g_HLL_CheckForUpdates);
Expand Down Expand Up @@ -186,6 +205,13 @@ Bool HLL::Gui::InitValues()
Bool HLL::Gui::Command(Int32 id, const BaseContainer &msg)
{
// Called when GUI is interacted with.
if (id == ID_USE_GLOBAL_POSROT)
{
g_HLL_UseGlobalCoords = !g_HLL_UseGlobalCoords;
MenuInitString(ID_USE_GLOBAL_POSROT, true, g_HLL_UseGlobalCoords);
return true;
}

if (id == CHECK_FOR_UPDATE_NOW)
{
String link;
Expand Down Expand Up @@ -433,8 +459,18 @@ Bool HLL::Gui::Command(Int32 id, const BaseContainer &msg)
}
else
{
Vector pos = g_HLL_OCamera->GetRelPos();
Vector rot = g_HLL_OCamera->GetRelRot();
Vector pos, rot;
if (g_HLL_UseGlobalCoords)
{
auto m = g_HLL_OCamera->GetMg();
pos = m.off;
rot = MatrixToHPB(m, ROTATIONORDER::HPB);
}
else
{
pos = g_HLL_OCamera->GetRelPos();
rot = g_HLL_OCamera->GetRelRot();
}

CameraObject *co = static_cast<CameraObject*>(g_HLL_OCamera);
GeData ft;
Expand Down Expand Up @@ -642,8 +678,18 @@ Bool HLL::Gui::CoreMessage(Int32 id, const BaseContainer &msg)
rot = Vector(DegToRad(-rot.z), DegToRad(-rot.y), DegToRad(-rot.x));
rot = Maths::RHToLHRotation(rot);

g_HLL_OCamera->SetRelPos(pos);
g_HLL_OCamera->SetRelRot(rot);
if (g_HLL_UseGlobalCoords)
{
auto m = HPBToMatrix(rot, ROTATIONORDER::HPB);
m.off = pos;
g_HLL_OCamera->SetMg(m);
}
else
{
g_HLL_OCamera->SetRelPos(pos);
g_HLL_OCamera->SetRelRot(rot);
}

g_HLL_OCamera->SetParameter(CAMERAOBJECT_FOV, DegToRad(g_ServerThread->GetFov()), DESCFLAGS_SET::NONE);
maxon::ExecuteOnMainThread([]() {DrawViews(DRAWFLAGS::ONLY_ACTIVE_VIEW | DRAWFLAGS::NO_THREAD | DRAWFLAGS::NO_REDUCTION | DRAWFLAGS::STATICBREAK); }, false);
}
Expand Down Expand Up @@ -725,6 +771,12 @@ void HLL::Gui::DestroyWindow()
// Pollrate
xml_file["settings.user.pollrate"_s]->SetValue(g_HLL_PollRate);

// Global Coords
if (g_HLL_UseGlobalCoords)
xml_file["settings.user.globalcoords"_s]->SetValue("true");
else
xml_file["settings.user.globalcoords"_s]->SetValue("false");

// Write changes
maxon::IoXmlParser::WriteDocument(u, xResult.GetValue(), true, nullptr);
}
Expand Down
1 change: 1 addition & 0 deletions source/hll_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace HLL
static String g_HLL_PollRate;
static Bool g_HLL_CheckForUpdates = false;
static Bool g_HLL_UpdateChecked = false;
static Bool g_HLL_UseGlobalCoords = true;

static BaseObject *g_HLL_OCamera;
static Int32 g_HLL_ActiveClient;
Expand Down
1 change: 1 addition & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Bool PluginStart()
user->AddChild("hostname"_s);
user->AddChild("port"_s);
user->AddChild("pollrate"_s);
user->AddChild("globalcoords"_s);

// Write To File
maxon::Url u("file:///" + userFile.GetString());
Expand Down

0 comments on commit 88a9833

Please sign in to comment.