implement sorting for customs
BIN
data/ui/play/sort_alpha_d.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
data/ui/play/sort_alpha_h.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
data/ui/play/sort_alpha_i.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
data/ui/play/sort_alpha_n.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
data/ui/play/sort_date_d.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
data/ui/play/sort_date_h.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
data/ui/play/sort_date_i.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
data/ui/play/sort_date_n.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
|
|
@ -32,7 +32,7 @@ class Marbleland {
|
||||||
|
|
||||||
for (missionData in claJson) {
|
for (missionData in claJson) {
|
||||||
// filter
|
// filter
|
||||||
if (missionData.compatibility != 'mbw' && missionData.compatibility != 'mbg')
|
if (missionData.datablockCompatibility != 'mbw' && missionData.datablockCompatibility != 'mbg')
|
||||||
continue;
|
continue;
|
||||||
if (!['gold', 'platinum', 'ultra', 'platinumquest'].contains(missionData.modification))
|
if (!['gold', 'platinum', 'ultra', 'platinumquest'].contains(missionData.modification))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -61,6 +61,7 @@ class Marbleland {
|
||||||
mission.ultimateTime = missionData.ultimateTime != null ? missionData.ultimateTime / 1000 : 0;
|
mission.ultimateTime = missionData.ultimateTime != null ? missionData.ultimateTime / 1000 : 0;
|
||||||
mission.hasEgg = missionData.hasEgg;
|
mission.hasEgg = missionData.hasEgg;
|
||||||
mission.isClaMission = true;
|
mission.isClaMission = true;
|
||||||
|
mission.addedAt = missionData.addedAt;
|
||||||
|
|
||||||
var game = missionData.modification;
|
var game = missionData.modification;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import haxe.Int64;
|
||||||
import src.Http.HttpRequest;
|
import src.Http.HttpRequest;
|
||||||
import gui.Canvas;
|
import gui.Canvas;
|
||||||
import gui.MessageBoxOkDlg;
|
import gui.MessageBoxOkDlg;
|
||||||
|
|
@ -40,6 +41,7 @@ class Mission {
|
||||||
public var game:String;
|
public var game:String;
|
||||||
public var hasEgg:Bool;
|
public var hasEgg:Bool;
|
||||||
public var isCustom:Bool;
|
public var isCustom:Bool;
|
||||||
|
public var addedAt:Int64;
|
||||||
|
|
||||||
var next:Mission;
|
var next:Mission;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class PlayMissionGui extends GuiImage {
|
||||||
|
|
||||||
var setSelectedFunc:Int->Void;
|
var setSelectedFunc:Int->Void;
|
||||||
var setScoreHover:Bool->Void;
|
var setScoreHover:Bool->Void;
|
||||||
var setCategoryFunc:(String, String, ?Bool) -> Void;
|
var setCategoryFunc:(String, String, ?String, ?Bool) -> Void;
|
||||||
var buttonHoldFunc:(dt:Float, mouseState:MouseState) -> Void;
|
var buttonHoldFunc:(dt:Float, mouseState:MouseState) -> Void;
|
||||||
|
|
||||||
var pmScoreButton:GuiButton;
|
var pmScoreButton:GuiButton;
|
||||||
|
|
@ -204,6 +204,27 @@ class PlayMissionGui extends GuiImage {
|
||||||
}
|
}
|
||||||
pmBox.addChild(pmSearch);
|
pmBox.addChild(pmSearch);
|
||||||
|
|
||||||
|
var sortType = 0; // 0 = alphabetical, 1 = date
|
||||||
|
|
||||||
|
var sortAlphaImgs = loadButtonImages("data/ui/play/sort_alpha");
|
||||||
|
var sortDateImgs = loadButtonImages("data/ui/play/sort_date");
|
||||||
|
|
||||||
|
var pmSort = new GuiButton(sortAlphaImgs);
|
||||||
|
pmSort.position = new Vector(366, 325);
|
||||||
|
pmSort.extent = new Vector(43, 43);
|
||||||
|
pmSort.pressedAction = (e) -> {
|
||||||
|
sortType = (sortType + 1) % 2;
|
||||||
|
if (sortType == 0) {
|
||||||
|
@:privateAccess pmSort.anim.frames = sortAlphaImgs;
|
||||||
|
}
|
||||||
|
if (sortType == 1) {
|
||||||
|
@:privateAccess pmSort.anim.frames = sortDateImgs;
|
||||||
|
}
|
||||||
|
setCategoryFunc(currentGame, currentCategoryStatic, sortType == 1 ? "date" : "alpha");
|
||||||
|
// MarbleGame.canvas.pushDialog(new SearchGui(currentGame, currentCategory == "custom"));
|
||||||
|
}
|
||||||
|
pmBox.addChild(pmSort);
|
||||||
|
|
||||||
var pmPrev = new GuiButton(loadButtonImages("data/ui/play/prev"));
|
var pmPrev = new GuiButton(loadButtonImages("data/ui/play/prev"));
|
||||||
pmPrev.position = new Vector(436, 325);
|
pmPrev.position = new Vector(436, 325);
|
||||||
pmPrev.extent = new Vector(72, 43);
|
pmPrev.extent = new Vector(72, 43);
|
||||||
|
|
@ -605,7 +626,7 @@ class PlayMissionGui extends GuiImage {
|
||||||
MarbleGame.canvas.pushDialog(mbo);
|
MarbleGame.canvas.pushDialog(mbo);
|
||||||
} else {
|
} else {
|
||||||
currentCategory = "custom";
|
currentCategory = "custom";
|
||||||
setCategoryFunc("gold", "custom");
|
setCategoryFunc("gold", "custom", sortType == 1 ? "date" : "alpha");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pmDifficultyCtrl.addChild(pmDifficultyGoldCustom);
|
pmDifficultyCtrl.addChild(pmDifficultyGoldCustom);
|
||||||
|
|
@ -621,7 +642,7 @@ class PlayMissionGui extends GuiImage {
|
||||||
MarbleGame.canvas.pushDialog(mbo);
|
MarbleGame.canvas.pushDialog(mbo);
|
||||||
} else {
|
} else {
|
||||||
currentCategory = "custom";
|
currentCategory = "custom";
|
||||||
setCategoryFunc("platinum", "custom");
|
setCategoryFunc("platinum", "custom", sortType == 1 ? "date" : "alpha");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pmDifficultyCtrl.addChild(pmDifficultyPlatinumCustom);
|
pmDifficultyCtrl.addChild(pmDifficultyPlatinumCustom);
|
||||||
|
|
@ -637,7 +658,7 @@ class PlayMissionGui extends GuiImage {
|
||||||
MarbleGame.canvas.pushDialog(mbo);
|
MarbleGame.canvas.pushDialog(mbo);
|
||||||
} else {
|
} else {
|
||||||
currentCategory = "custom";
|
currentCategory = "custom";
|
||||||
setCategoryFunc("ultra", "custom");
|
setCategoryFunc("ultra", "custom", sortType == 1 ? "date" : "alpha");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pmDifficultyCtrl.addChild(pmDifficultyUltraCustom);
|
pmDifficultyCtrl.addChild(pmDifficultyUltraCustom);
|
||||||
|
|
@ -812,7 +833,7 @@ class PlayMissionGui extends GuiImage {
|
||||||
|
|
||||||
currentList = MissionList.missionList["platinum"]["beginner"];
|
currentList = MissionList.missionList["platinum"]["beginner"];
|
||||||
|
|
||||||
setCategoryFunc = function(game:String, category:String, ?doRender:Bool = true) {
|
setCategoryFunc = function(game:String, category:String, ?sort:String = null, ?doRender:Bool = true) {
|
||||||
currentList = category == "custom" ? (switch (game) {
|
currentList = category == "custom" ? (switch (game) {
|
||||||
case 'gold' if (Marbleland.goldMissions.length != 0): Marbleland.goldMissions;
|
case 'gold' if (Marbleland.goldMissions.length != 0): Marbleland.goldMissions;
|
||||||
case 'platinum' if (Marbleland.platinumMissions.length != 0): Marbleland.platinumMissions;
|
case 'platinum' if (Marbleland.platinumMissions.length != 0): Marbleland.platinumMissions;
|
||||||
|
|
@ -836,6 +857,24 @@ class PlayMissionGui extends GuiImage {
|
||||||
pmAchievements.disabled = true;
|
pmAchievements.disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (category == "custom") {
|
||||||
|
pmSort.anim.visible = true;
|
||||||
|
pmSort.disabled = false;
|
||||||
|
} else {
|
||||||
|
pmSort.anim.visible = false;
|
||||||
|
pmSort.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sort != null) {
|
||||||
|
currentList = currentList.copy(); // Don't modify the originals
|
||||||
|
if (sort == "alpha") {
|
||||||
|
currentList.sort((x, y) -> x.title > y.title ? 1 : (x.title < y.title ? -1 : 0));
|
||||||
|
}
|
||||||
|
if (sort == "date") {
|
||||||
|
currentList.sort((x, y) -> x.addedAt > y.addedAt ? 1 : (x.addedAt < y.addedAt ? -1 : 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
currentCategoryStatic = currentCategory;
|
currentCategoryStatic = currentCategory;
|
||||||
|
|
||||||
if (currentGame != game) {
|
if (currentGame != game) {
|
||||||
|
|
@ -1044,7 +1083,7 @@ class PlayMissionGui extends GuiImage {
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
setCategoryFunc(currentGame, currentCategoryStatic, false);
|
setCategoryFunc(currentGame, currentCategoryStatic, null, false);
|
||||||
|
|
||||||
#if js
|
#if js
|
||||||
var kofi = new GuiButton(loadButtonImages("data/ui/kofi1"));
|
var kofi = new GuiButton(loadButtonImages("data/ui/kofi1"));
|
||||||
|
|
|
||||||