Rework MapValidator + add human readable format
This commit is contained in:
parent
652bd5fe1a
commit
55c5952258
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,81 @@
|
|||||||
// 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;
|
bool G_MenuVisibility = false;
|
||||||
int author_time;
|
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
|
|
||||||
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
|
UI::BeginDisabled(!IsValidAuthorTime(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");
|
if (UI::Button("Validate")) {
|
||||||
#elif UNITED
|
setAuthorTime(map, Time::ParseRelativeTime(G_AuthorTimeText));
|
||||||
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");
|
setValidationStatus(editor);
|
||||||
#endif
|
G_MenuVisibility = false;
|
||||||
|
}
|
||||||
|
UI::EndDisabled();
|
||||||
|
|
||||||
|
string warning = GetWarning();
|
||||||
|
if (warning != "") {
|
||||||
|
UI::SameLine();
|
||||||
|
UI::Text("\\$fa2" + Icons::Info);
|
||||||
|
if (UI::IsItemHovered()) {
|
||||||
|
UI::BeginTooltip();
|
||||||
|
UI::Text(warning);
|
||||||
|
UI::EndTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UI::End();
|
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 IsValidAuthorTime(string _AuthorTimeText) {
|
||||||
|
if (!Regex::IsMatch(_AuthorTimeText, '[\\d\\.:]+')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Regex::IsMatch(_AuthorTimeText, '^((\\d+):)?(\\d|[0-5]\\d):(\\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.7"
|
||||||
|
|
||||||
blocks = [ "Plugin_MapValidator" ]
|
blocks = [ "Plugin_MapValidator" ]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user