Compare commits

...

2 Commits

Author SHA1 Message Date
Beu 88221039bb update class name 2023-09-27 22:02:49 +02:00
Beu e986454f80 add permission check 2023-09-27 21:54:58 +02:00
3 changed files with 20 additions and 2 deletions

View File

@ -3,6 +3,7 @@ uint S_NbOfLinksInCache = 5;
const string C_LinksCache = "LinksCache.txt";
bool G_PermissionIssueNotified = false;
string G_QuickURL = "";
bool G_PressEnter = false;
bool G_WasEditing = false;
@ -10,6 +11,8 @@ bool G_WasEditing = false;
array<string> G_LinksCache;
void Main() {
if (!hasPermissions()) return;
trace("Loading links cache");
string filepath = IO::FromStorageFolder(C_LinksCache);
IO::File file(filepath);
@ -21,6 +24,8 @@ void Main() {
}
void RenderMenuMain() {
if (!hasPermissions()) return;
if (!G_PressEnter && UI::BeginMenu("\\$cf9" + Icons::ExternalLink + "\\$z Quick Link Opener##QuickLinkOpenerMenu")) {
G_QuickURL = UI::InputText("###quickURL", G_QuickURL, G_PressEnter, UI::InputTextFlags::EnterReturnsTrue + UI::InputTextFlags::CallbackAlways, UI::InputTextCallback(ITCB));
@ -48,6 +53,7 @@ void ITCB(UI::InputTextCallbackData@ d) {
}
void LoadLink(string _Url, bool _NewUrl) {
if (!hasPermissions()) return;
if (_Url == "") return;
string parsedURL = "";
@ -78,3 +84,15 @@ void LoadLink(string _Url, bool _NewUrl) {
CTrackMania@ app = cast<CTrackMania>(GetApp());
app.ManiaPlanetScriptAPI.OpenLink(parsedURL, CGameManiaPlanetScriptAPI::ELinkType::ManialinkBrowser);
}
bool hasPermissions() {
if (Permissions::PlayPublicClubRoom()) return true;
if (!G_PermissionIssueNotified) {
G_PermissionIssueNotified = true;
string msg = "Missing permissions: you need to be able to play on public room to use this plugin.";
warn(msg);
UI::ShowNotification(Meta::ExecutingPlugin().Name, msg, vec4(.9, .5, .3, .2), 15000);
}
return false;
}

View File

@ -1,6 +1,6 @@
[meta]
name = "TMWT Interfaces Remover"
category = "TMWT"
version = "1.3"
version = "1.4"
siteid = 318

View File

@ -1,4 +1,4 @@
const string C_Class_UIModules = 'component-modelibs-uimodules-module';
const string C_Class_UIModules = 'component-cmgame-uimodules-module';
const string C_Id_TMWT_LiveRanking = 'TMWTCommon_LiveRanking';
const string C_Id_TMWT_Header = 'TMWTCommon_Header';
const string C_Id_TMWC2023_LiveRanking = 'TMWC2023_LiveRanking';