Skip to content

Commit

Permalink
Merge pull request #1 from RusJJ/main
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
sheakelso authored Jul 12, 2021
2 parents bf3e7cb + 92a9037 commit 0483d3e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
19 changes: 11 additions & 8 deletions src/FriendButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ UnityEngine::Color m_clrVerifiedColor = UnityEngine::Color(0.5f, 1.0f, 0.5f, 1.0
static bool IsVerified(std::string userID)
{
il2cpp_utils::getLogger().info("Checking if player is verified");
for(int i = 0; i < GorillaFriends::WebVerified::verifiedUserIds.size(); i++)
int listsize = GorillaFriends::WebVerified::verifiedUserIds.size();
for(int i = 0; i < listsize; ++i)
{
if(GorillaFriends::WebVerified::verifiedUserIds[i] == userID) return true;
}
Expand All @@ -37,7 +38,8 @@ static bool IsFriend(std::string userID)

static bool IsInFriendList(std::string userID)
{
for(int i = 0; i < GorillaFriends::WebVerified::m_listCurrentSessionFriends.size(); i++)
int listsize = GorillaFriends::WebVerified::m_listCurrentSessionFriends.size();
for(int i = 0; i < listsize; ++i)
{
if(GorillaFriends::WebVerified::m_listCurrentSessionFriends[i] == userID) return true;
}
Expand Down Expand Up @@ -77,7 +79,7 @@ void GorillaFriends::FriendButton::Update()
if(!IsInFriendList(to_utf8(csstrtostr(parentLine->linePlayer->UserId)))) GorillaFriends::WebVerified::m_listCurrentSessionFriends.push_back(to_utf8(csstrtostr(parentLine->linePlayer->UserId)));
parentLine->playerName->set_color(m_clrFriendColor);
isOn = true;
myText->set_text(onText);
//myText->set_text(onText);
UpdateColor();
}
else
Expand All @@ -104,13 +106,13 @@ void GorillaFriends::FriendButton::Update()
parentLine->playerName->set_color(UnityEngine::Color::get_white());
parentLine->playerVRRig->playerText->set_color(UnityEngine::Color::get_white());
}
myText->set_text(onText);
//myText->set_text(offText);
}
else
{
parentLine->playerName->set_color(m_clrFriendColor);
parentLine->playerVRRig->playerText->set_color(m_clrFriendColor);
myText->set_text(onText);
//myText->set_text(onText);
}
}
}
Expand All @@ -131,19 +133,20 @@ void GorillaFriends::FriendButton::OnTriggerEnter(UnityEngine::Collider* collide
GorillaFriends::WebVerified::m_listCurrentSessionFriends.push_back(to_utf8(csstrtostr(parentLine->linePlayer->UserId)));
UnityEngine::PlayerPrefs::SetInt(il2cpp_utils::createcsstr(to_utf8(csstrtostr(parentLine->linePlayer->UserId)) + "_friend"), 1);
parentLine->playerName->set_color(m_clrFriendColor);
myText->set_text(onText);
//myText->set_text(onText);
return;
}

for(int i = 0; i < GorillaFriends::WebVerified::m_listCurrentSessionFriends.size(); i++)
int listsize = GorillaFriends::WebVerified::m_listCurrentSessionFriends.size();
for(int i = 0; i < listsize; ++i)
{
if(GorillaFriends::WebVerified::m_listCurrentSessionFriends[i] == to_utf8(csstrtostr(parentLine->linePlayer->UserId)))
{
GorillaFriends::WebVerified::m_listCurrentSessionFriends.erase(GorillaFriends::WebVerified::m_listCurrentSessionFriends.begin() + i - 1);
}
}
UnityEngine::PlayerPrefs::SetInt(il2cpp_utils::createcsstr(to_utf8(csstrtostr(parentLine->linePlayer->UserId)) + "_friend"), 0);
myText->set_text(offText);
//myText->set_text(offText);

if(IsVerified(to_utf8(csstrtostr(parentLine->linePlayer->UserId))))
{
Expand Down
21 changes: 14 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ GorillaFriends::FriendButton* m_pFriendButtonController;

MAKE_HOOK_OFFSETLESS(GSB_Awake, void, GlobalNamespace::GorillaScoreBoard* self)
{
GorillaFriends::WebVerified::m_listCurrentSessionFriends.clear();
if(m_pScoreboardFriendBtn != nullptr)
{
// Friend Button prefab has been created, skip our code
GSB_Awake(self);
return;
}
// I think we dont need it here:
// GorillaFriends::WebVerified::m_listCurrentSessionFriends.clear();
getLogger().info("GSB_AWAKE");
auto transform = self->scoreBoardLinePrefab->get_transform();
int transformNum = transform->get_childCount();
for(int i = 0; i < transformNum; i++)
for(int i = 0; i < transformNum; ++i)
{
if(m_pScoreboardFriendBtn != nullptr)
{
GSB_Awake(self);
return;
}
getLogger().info("ooga");
auto t = transform->GetChild(i);
if(to_utf8(csstrtostr(t->get_name())) == "Mute Button")
Expand All @@ -104,14 +106,19 @@ MAKE_HOOK_OFFSETLESS(GSB_Awake, void, GlobalNamespace::GorillaScoreBoard* self)
m_pFriendButtonController->myText = controller->myText;
m_pFriendButtonController->myText->set_text(m_pFriendButtonController->offText);
m_pFriendButtonController->offMaterial = controller->offMaterial;
/* Maybe we need to instantiate onMaterial, please check */
m_pFriendButtonController->onMaterial = controller->onMaterial;
m_pFriendButtonController->onMaterial->set_color(UnityEngine::Color(0.8f, 0.5f, 0.9f, 1.0f));

UnityEngine::GameObject::Destroy(controller);
}
}
// We're added a Friend Button! Break our "for loop"
break;
}
}
// Call original function
GSB_Awake(self);
}

MAKE_HOOK_OFFSETLESS(PN_Disconnect, void, Photon::Pun::PhotonNetwork* self)
Expand Down

0 comments on commit 0483d3e

Please sign in to comment.