Compare commits
3 Commits
652bd5fe1a
...
master
Author | SHA1 | Date | |
---|---|---|---|
34a83bd71e | |||
2d4257b010 | |||
55c5952258 |
@ -2,7 +2,7 @@
|
|||||||
name = "Countdown Mover"
|
name = "Countdown Mover"
|
||||||
author = "Beu"
|
author = "Beu"
|
||||||
category = "Overlay"
|
category = "Overlay"
|
||||||
version = "1.2"
|
version = "1.3"
|
||||||
siteid = 431
|
siteid = 431
|
||||||
|
|
||||||
[script]
|
[script]
|
||||||
|
@ -25,7 +25,6 @@ class HookCustomizableModuleEvents: MLHook::HookMLEventsByType {
|
|||||||
super(C_MLID_UIModuleUpdate);
|
super(C_MLID_UIModuleUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// override this method to avoid reload crash?
|
|
||||||
void OnEvent(MLHook::PendingEvent@ Event) override {
|
void OnEvent(MLHook::PendingEvent@ Event) override {
|
||||||
trace("CustomizableModule updated");
|
trace("CustomizableModule updated");
|
||||||
G_Update = true;
|
G_Update = true;
|
||||||
@ -64,7 +63,7 @@ void OnSettingsChanged() {
|
|||||||
|
|
||||||
void Main() {
|
void Main() {
|
||||||
@HookEvents = HookCustomizableModuleEvents();
|
@HookEvents = HookCustomizableModuleEvents();
|
||||||
MLHook::RegisterMLHook(HookEvents, C_MLID_UIModuleUpdate + "_Update", false);
|
MLHook::RegisterMLHook(HookEvents, C_MLID_UIModuleUpdate + "_Update", true);
|
||||||
MLHook::InjectManialinkToPlayground(C_MLID_UIModuleUpdate, C_ML_UIModuleUpdate, true);
|
MLHook::InjectManialinkToPlayground(C_MLID_UIModuleUpdate, C_ML_UIModuleUpdate, true);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
30
MapValidator/Source/Games/MP4.as
Normal file
30
MapValidator/Source/Games/MP4.as
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#if MP4
|
||||||
|
CGameCtnEditorFree@ getEditor() {
|
||||||
|
return cast<CGameCtnEditorFree>(GetApp().Editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGameCtnChallenge@ getMap() {
|
||||||
|
return cast<CGameCtnChallenge>(GetApp().RootMap);;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getAuthorTime(CGameCtnChallenge@ _Map) {
|
||||||
|
return _Map.TMObjective_AuthorTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAuthorTime(CGameCtnChallenge@ _Map, uint _AuthorTime) {
|
||||||
|
_Map.TMObjective_AuthorTime = _AuthorTime;
|
||||||
|
|
||||||
|
// Remove the map UID, the game will generate it again when saving
|
||||||
|
_Map.IdName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValidationStatus(CGameCtnEditorFree@ _Editor) {
|
||||||
|
CGameEditorPluginMapMapType@ pluginmaptype = cast<CGameEditorPluginMapMapType>(_Editor.PluginMapType);
|
||||||
|
if (pluginmaptype is null) return;
|
||||||
|
pluginmaptype.ValidationStatus = CGameEditorPluginMapMapType::EValidationStatus::Validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetWarning() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
#endif
|
27
MapValidator/Source/Games/TMNEXT.as
Normal file
27
MapValidator/Source/Games/TMNEXT.as
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#if TMNEXT
|
||||||
|
CGameCtnEditorFree@ getEditor() {
|
||||||
|
return cast<CGameCtnEditorFree>(GetApp().Editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGameCtnChallenge@ getMap() {
|
||||||
|
return cast<CGameCtnChallenge>(GetApp().RootMap);;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getAuthorTime(CGameCtnChallenge@ _Map) {
|
||||||
|
return _Map.TMObjective_AuthorTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAuthorTime(CGameCtnChallenge@ _Map, uint _AuthorTime) {
|
||||||
|
_Map.TMObjective_AuthorTime = _AuthorTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValidationStatus(CGameCtnEditorFree@ _Editor) {
|
||||||
|
CGameEditorPluginMapMapType@ pluginmaptype = cast<CGameEditorPluginMapMapType>(_Editor.PluginMapType);
|
||||||
|
if (pluginmaptype is null) return;
|
||||||
|
pluginmaptype.ValidationStatus = CGameEditorPluginMapMapType::EValidationStatus::Validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetWarning() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
#endif
|
30
MapValidator/Source/Games/TURBO.as
Normal file
30
MapValidator/Source/Games/TURBO.as
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#if TURBO
|
||||||
|
CGameCtnEditorFree@ getEditor() {
|
||||||
|
return cast<CGameCtnEditorFree>(GetApp().Editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGameCtnChallenge@ getMap() {
|
||||||
|
return cast<CGameCtnChallenge>(GetApp().Challenge);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getAuthorTime(CGameCtnChallenge@ _Map) {
|
||||||
|
return _Map.TMObjective_AuthorTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAuthorTime(CGameCtnChallenge@ _Map, uint _AuthorTime) {
|
||||||
|
_Map.TMObjective_AuthorTime = _AuthorTime;
|
||||||
|
|
||||||
|
// Remove the map UID, the game will generate it again when saving
|
||||||
|
_Map.IdName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValidationStatus(CGameCtnEditorFree@ _Editor) {
|
||||||
|
CGameCtnEditorPluginMapType@ pluginmaptype = cast<CGameCtnEditorPluginMapType>(_Editor.EditorMapType);
|
||||||
|
if (pluginmaptype is null) return;
|
||||||
|
pluginmaptype.ValidationStatus = CGameCtnEditorPluginMapType::EValidationStatus::Validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetWarning() {
|
||||||
|
return "Note: your map must have a start and a finish\n(or a multilap + 1CP) to be validated with the plugin";
|
||||||
|
}
|
||||||
|
#endif
|
32
MapValidator/Source/Games/UNITED.as
Normal file
32
MapValidator/Source/Games/UNITED.as
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#if UNITED
|
||||||
|
CTrackManiaEditor@ getEditor() {
|
||||||
|
return cast<CTrackManiaEditor>(cast<CTrackMania>(GetApp()).Editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGameCtnChallenge@ getMap() {
|
||||||
|
return cast<CGameCtnChallenge>(GetApp().Challenge);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getAuthorTime(CGameCtnChallenge@ _Map) {
|
||||||
|
return _Map.ChallengeParameters.AuthorTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAuthorTime(CGameCtnChallenge@ _Map, uint _AuthorTime) {
|
||||||
|
_Map.ChallengeParameters.AuthorTime = _AuthorTime;
|
||||||
|
_Map.ChallengeParameters.AuthorScore = _AuthorTime;
|
||||||
|
_Map.ChallengeParameters.GoldTime = Math::Floor((1000 + _AuthorTime + _AuthorTime * 0.06)/1000)*1000;
|
||||||
|
_Map.ChallengeParameters.SilverTime = Math::Floor((1000 + _AuthorTime + _AuthorTime * 0.2)/1000)*1000;
|
||||||
|
_Map.ChallengeParameters.BronzeTime = Math::Floor((1000 + _AuthorTime + _AuthorTime * 0.5)/1000)*1000;
|
||||||
|
|
||||||
|
// Remove the map UID, the game will generate it again when saving
|
||||||
|
_Map.IdName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValidationStatus(CTrackManiaEditor@ _Editor) {
|
||||||
|
return; // doesn't exists in UNITED
|
||||||
|
}
|
||||||
|
|
||||||
|
string GetWarning() {
|
||||||
|
return "Note: for an unknown reason, it happens that the times of\nthe medals are not updated, I invite you to check by yourself";
|
||||||
|
}
|
||||||
|
#endif
|
@ -1,128 +1,109 @@
|
|||||||
// Based on the Moski plugin which is also based on the Miss plugin :)
|
// Based on the Moski plugin which is also based on the Miss plugin :)
|
||||||
|
|
||||||
bool menu_visibility = false;
|
const string C_InvalidValueError = "Invalid value. You can set a human readable value like \\$<\\$aaa1:23.456\\$>\nor a value in milliseconds like \\$<\\$aaa83456\\$>";
|
||||||
int author_time;
|
|
||||||
|
bool G_MenuVisibility = false;
|
||||||
|
string G_AuthorTimeText = "0:00:00.000";
|
||||||
|
|
||||||
void Main() {}
|
void Main() {}
|
||||||
|
|
||||||
void validate(int author_time) {
|
|
||||||
// Get editor var
|
|
||||||
#if UNITED
|
|
||||||
CTrackManiaEditor@ editor = cast<CTrackManiaEditor>(cast<CTrackMania>(GetApp()).Editor);
|
|
||||||
#else
|
|
||||||
CGameCtnEditorFree@ editor = cast<CGameCtnEditorFree>(GetApp().Editor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get map & pluginmaptype if possible
|
|
||||||
#if TURBO
|
|
||||||
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().Challenge);
|
|
||||||
CGameCtnEditorPluginMapType@ pluginmaptype = cast<CGameCtnEditorPluginMapType>(editor.EditorMapType);
|
|
||||||
#elif UNITED
|
|
||||||
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().Challenge);
|
|
||||||
auto pluginmaptype == null;
|
|
||||||
#else
|
|
||||||
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().RootMap);
|
|
||||||
CGameEditorPluginMapMapType@ pluginmaptype = cast<CGameEditorPluginMapMapType>(editor.PluginMapType);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (editor is null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pluginmaptype !is null) {
|
|
||||||
#if TURBO
|
|
||||||
pluginmaptype.ValidationStatus = CGameCtnEditorPluginMapType::EValidationStatus::Validated;
|
|
||||||
#else
|
|
||||||
pluginmaptype.ValidationStatus = CGameEditorPluginMapMapType::EValidationStatus::Validated;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (map !is null) {
|
|
||||||
#if UNITED
|
|
||||||
map.ChallengeParameters.AuthorTime = author_time;
|
|
||||||
map.ChallengeParameters.AuthorScore = author_time;
|
|
||||||
map.ChallengeParameters.GoldTime = Math::Floor((1000 + author_time + author_time * 0.06)/1000)*1000;
|
|
||||||
map.ChallengeParameters.SilverTime = Math::Floor((1000 + author_time + author_time * 0.2)/1000)*1000;
|
|
||||||
map.ChallengeParameters.BronzeTime = Math::Floor((1000 + author_time + author_time * 0.5)/1000)*1000;
|
|
||||||
#else
|
|
||||||
map.TMObjective_AuthorTime = author_time;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !TMNEXT
|
|
||||||
map.IdName = ""; // Remove the map UID, the game will generate it again when saving
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Render() {
|
void Render() {
|
||||||
if (!menu_visibility) {
|
auto editor = getEditor();
|
||||||
|
if (editor is null) {
|
||||||
|
G_MenuVisibility = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITED
|
auto map = getMap();
|
||||||
CTrackManiaEditor@ editor = cast<CTrackManiaEditor>(cast<CTrackMania>(GetApp()).Editor);
|
if (map is null) {
|
||||||
#else
|
G_MenuVisibility = false;
|
||||||
CGameCtnEditorFree@ editor = cast<CGameCtnEditorFree>(GetApp().Editor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if TMNEXT || MP4
|
|
||||||
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().RootMap);
|
|
||||||
#else
|
|
||||||
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().Challenge);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (map is null || editor is null) {
|
|
||||||
menu_visibility = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UI::Begin("\\$cf9" + Icons::Flag + "\\$z Map Validator###MapValidator", menu_visibility, UI::WindowFlags::NoResize | UI::WindowFlags::AlwaysAutoResize | UI::WindowFlags::NoCollapse)){
|
if (!G_MenuVisibility) {
|
||||||
author_time = UI::InputInt("Author time in ms", author_time ,1);
|
// Store the last Author Time when hidden
|
||||||
|
uint CurrentAuthorTime = getAuthorTime(map);
|
||||||
if (author_time < 0) author_time = 0;
|
if (CurrentAuthorTime < 4294967295) {
|
||||||
|
G_AuthorTimeText = Time::Format(CurrentAuthorTime);
|
||||||
if (UI::Button("Validate")) {
|
}
|
||||||
validate(author_time);
|
return;
|
||||||
menu_visibility = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert time in ms to humain readable time
|
UI::SetNextItemWidth(200.0);
|
||||||
string display_time = Text::Format('%02d',(author_time / 1000 / 60) % 60) + ":" + Text::Format('%02d',(author_time / 1000) % 60) + "." + Text::Format('%03d',author_time % 1000);
|
if (UI::Begin("\\$cf9" + Icons::Flag + "\\$z Map Validator###MapValidator", G_MenuVisibility, UI::WindowFlags::NoResize | UI::WindowFlags::AlwaysAutoResize | UI::WindowFlags::NoCollapse)){
|
||||||
if (Math::Floor(author_time / 1000 / 60 / 60) > 0) {
|
UI::SetNextItemWidth(100.0);
|
||||||
display_time = Text::Format('%d',author_time / 1000 / 60 / 60) + ":" + display_time;
|
G_AuthorTimeText = UI::InputText("###AuthorTimeText", G_AuthorTimeText);
|
||||||
}
|
|
||||||
UI::SameLine();
|
UI::SameLine();
|
||||||
UI::Text("with " + display_time + " of author time");
|
|
||||||
|
|
||||||
#if TURBO
|
const bool IsMilliseconds = IsMillisecondsFormat(G_AuthorTimeText);
|
||||||
UI::Text("Note: your map must have a start and a finish\n(or a multilap + 1CP) to be validated with the plugin");
|
const bool IsButtonDisabled = (!IsMilliseconds && !IsValidAuthorTime(G_AuthorTimeText));
|
||||||
#elif UNITED
|
|
||||||
UI::Text("Note: for an unknown reason, it happens that the times of\nthe medals are not updated, I invite you to check by yourself");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UI::End();
|
// Creating group to be able to display the tooltip even when the button is disabled
|
||||||
|
UI::BeginGroup();
|
||||||
|
UI::BeginDisabled(IsButtonDisabled);
|
||||||
|
if (UI::Button("Validate")) {
|
||||||
|
int AuthorTime = 0;
|
||||||
|
if (IsMilliseconds) AuthorTime = Text::ParseUInt(G_AuthorTimeText);
|
||||||
|
else AuthorTime = Time::ParseRelativeTime(G_AuthorTimeText);
|
||||||
|
|
||||||
|
setAuthorTime(map, AuthorTime);
|
||||||
|
setValidationStatus(editor);
|
||||||
|
G_MenuVisibility = false;
|
||||||
}
|
}
|
||||||
|
UI::EndDisabled();
|
||||||
|
UI::EndGroup();
|
||||||
|
|
||||||
|
// Time tooltip
|
||||||
|
if (UI::IsItemHovered()) {
|
||||||
|
UI::BeginTooltip();
|
||||||
|
if (IsButtonDisabled) {
|
||||||
|
UI::Text(C_InvalidValueError);
|
||||||
|
} else if (IsMilliseconds) {
|
||||||
|
UI::Text(Time::Format(Text::ParseUInt(G_AuthorTimeText)));
|
||||||
|
} else {
|
||||||
|
UI::Text("" + Time::ParseRelativeTime(G_AuthorTimeText) + " ms");
|
||||||
|
}
|
||||||
|
UI::EndTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warning tooltip depending the game
|
||||||
|
const string warning = GetWarning();
|
||||||
|
if (warning != "") {
|
||||||
|
UI::SameLine();
|
||||||
|
UI::Text("\\$fa2" + Icons::Info);
|
||||||
|
if (UI::IsItemHovered()) {
|
||||||
|
UI::BeginTooltip();
|
||||||
|
UI::Text(warning);
|
||||||
|
UI::EndTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UI::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderMenu() {
|
void RenderMenu() {
|
||||||
#if UNITED
|
auto editor = getEditor();
|
||||||
CTrackManiaEditor@ editor = cast<CTrackManiaEditor>(cast<CTrackMania>(GetApp()).Editor);
|
if (editor is null) return;
|
||||||
#else
|
|
||||||
CGameCtnEditorFree@ editor = cast<CGameCtnEditorFree>(GetApp().Editor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if TMNEXT || MP4
|
auto map = getMap();
|
||||||
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().RootMap);
|
if (map is null) return;
|
||||||
#else
|
|
||||||
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().Challenge);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (map is null || editor is null) {
|
if(UI::MenuItem("\\$cf9" + Icons::Flag + "\\$z Map Validator", "", G_MenuVisibility)) {
|
||||||
return;
|
G_MenuVisibility = !G_MenuVisibility;
|
||||||
}
|
|
||||||
|
|
||||||
if(UI::MenuItem("\\$cf9" + Icons::Flag + "\\$z Map Validator", "", menu_visibility)) {
|
|
||||||
menu_visibility = !menu_visibility;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsMillisecondsFormat(string _AuthorTimeText) {
|
||||||
|
return Regex::IsMatch(_AuthorTimeText, '\\d+');
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsValidAuthorTime(string _AuthorTimeText) {
|
||||||
|
if (!Regex::IsMatch(_AuthorTimeText, '[\\d\\.:]+')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Regex::IsMatch(_AuthorTimeText, '^(((((\\d+:)?[0-5])?\\d:)?[0-5])?\\d)\\.\\d{3}$')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
@ -2,8 +2,7 @@
|
|||||||
name = "Map Validator"
|
name = "Map Validator"
|
||||||
author = "Beu"
|
author = "Beu"
|
||||||
category = "Map Editor"
|
category = "Map Editor"
|
||||||
|
|
||||||
siteid = 91
|
siteid = 91
|
||||||
version = "1.6"
|
version = "1.8"
|
||||||
|
|
||||||
blocks = [ "Plugin_MapValidator" ]
|
blocks = [ "Plugin_MapValidator" ]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user