Skip to content

Commit

Permalink
Fixed Replace TTS playerlist position not working, added null check t…
Browse files Browse the repository at this point in the history
…o PrepareIcon
  • Loading branch information
ddakebono committed Apr 12, 2024
1 parent 64708b5 commit fea0c11
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
4 changes: 2 additions & 2 deletions BTKUILib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static class BuildInfo
public const string Name = "BTKUILib";
public const string Author = "BTK Development Team";
public const string Company = "BTK Development";
public const string Version = "2.1.1";
public const string Version = "2.1.2";
}

internal class BTKUILib : MelonMod
Expand All @@ -32,7 +32,7 @@ internal class BTKUILib : MelonMod
private Thread _mainThread;
private Page _mlPrefsPage;
private MultiSelection _playerListButtonStyle;
private string[] _playerListOptions = { "Tab Bar", "Replace TTS", "Replace Events" };
private string[] _playerListOptions = { "Tab Bar", "Right Bar", "Replace Events" };

public override void OnInitializeMelon()
{
Expand Down
25 changes: 25 additions & 0 deletions CohtmlUI/BTKUI.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
@import "bootstrap-grid.min.css";
#quickmenu-wrapper .btkUI-btn {
background-color: rgba(41, 41, 41, 0);
width: 150px;
height: 150px;
border-radius: 10px;
font-size: 36px;
text-align: center;
position: absolute;
left: 1280px;
top: 485px;
}
#quickmenu-wrapper .btkUI-btn:hover {
filter: brightness(75%);
}
#quickmenu-wrapper .btkUI-btn .icon {
background: url("mods/BTKUI/images/Multiuser.png");
background-size: cover;
background-repeat: no-repeat;
height: 150px;
width: 150px;
position: absolute;
margin-bottom: 100px;
padding: 10px;
z-index: 0;
}
#quickmenu-wrapper .quick-buttons-container {
left: 13px;
}
Expand Down
29 changes: 29 additions & 0 deletions CohtmlUI/BTKUI.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,35 @@
}

#quickmenu-wrapper {
.btkUI-btn {
background-color: rgba(41, 41, 41, 0);
width: 150px;
height: 150px;
border-radius: 10px;
font-size: 36px;
text-align: center;
position: absolute;
left: 1280px;
top: 485px;

&:hover {
filter: brightness(75%);
}

.icon {
background: url("images/Multiuser.png");
background-size: cover;
background-repeat: no-repeat;

height: 150px;
width: 150px;
position: absolute;
margin-bottom: 100px;
padding: 10px;
z-index: 0;
}
}

.quick-buttons-container{
left: 13px;
}
Expand Down
8 changes: 6 additions & 2 deletions CohtmlUI/mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ cvr.menu.prototype.BTKUI = {
btkBackFunc = this.btkBackFunction;
btkRootPageTarget = "";

menu.templates["btkUI-btn"] = {c: "btkUI-btn hide", s: [{c: "icon"}], x: "btkUI-pushPage", a:{"id" : "btkUI-UserMenuRightBar", "data-page": "btkUI-PlayerList"}};
menu.templates["btkUI-shared"] = {c: "btkUI-shared hide", s:[
{c: "container btk-popup-container hide", a: {"id": "btkUI-PopupConfirm"}, s:[
{c: "row", s: [
Expand Down Expand Up @@ -231,6 +232,7 @@ cvr.menu.prototype.BTKUI = {
menu.templates["btkUITab"] = {c: "col-md-2 tab", s:[{c: "tab-content", a:{"id":"btkUI-Tab-[TabName]-Image"}}], a:{"id":"btkUI-Tab-[TabName]", "tabTarget": "btkUI-[TabName]-[PageName]"}, x: "btkUI-TabChange"};
menu.templates["btkPlayerListEntry"] = {c:"col-3", s:[{c:"button-fullImage", x:"btkUI-SelectPlayer", s:[{c:"text", h:"[player-name]"}], a:{"id": "btkUI-PlayerButton-[player-id]-Icon","data-id": "[player-id]", "data-name": "[player-name]", "data-tooltip": "Open up the player options for [player-name]"}}], a:{"id": "btkUI-PlayerButton-[player-id]"}};

menu.templates["core-quickmenu"].l.push("btkUI-btn")
menu.templates["core-quickmenu"].l.push("btkUI-shared");
menu.templates["core-quickmenu"].l.push("btkUI-menu");

Expand Down Expand Up @@ -362,7 +364,9 @@ cvr.menu.prototype.BTKUI = {

switch(plButtonStyle){
case "Replace TTS":
let ttsElement = document.getElementsByClassName("button-tts");
case "Right Bar":
cvr("#btkUI-UserMenuRightBar").show();
/*let ttsElement = document.getElementsByClassName("button-tts");
if(ttsElement.length === 0){
console.error("Couldn't find TTS element! Unable to replace!");
Expand All @@ -381,7 +385,7 @@ cvr.menu.prototype.BTKUI = {
ttsElement.addEventListener("click", uiRefBTK.actions["btkUI-pushPage"]);
ttsElement.setAttribute("data-x", "btkUI-pushPage");
ttsElement.setAttribute("data-page", "btkUI-PlayerList");
ttsElement.setAttribute("data-tooltip", "Opens the UILib PlayerList");
ttsElement.setAttribute("data-tooltip", "Opens the UILib PlayerList");*/
break;
case "Replace Events":
let eventButton = document.getElementsByClassName("events");
Expand Down
6 changes: 6 additions & 0 deletions QuickMenuAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ public static Page GetMLPrefsPageByIdentifier(string prefsIdentifier)
/// <param name="resourceStream">Stream containing your image data</param>
public static void PrepareIcon(string modName, string iconName, Stream resourceStream)
{
if (resourceStream == null)
{
BTKUILib.Log.Error($"Mod {modName} attempted to prepare {iconName} but the resource stream was null! Yell at the mod author to fix this!");
return;
}

var directory = $"ChilloutVR_Data\\StreamingAssets\\Cohtml\\UIResources\\GameUI\\mods\\BTKUI\\images\\{modName}";

if (!Directory.Exists(directory))
Expand Down

0 comments on commit fea0c11

Please sign in to comment.