Workshop map updates, removal detection

This commit is contained in:
Anuken
2019-09-28 13:13:23 -04:00
parent a9edee1550
commit 438b3d9752
7 changed files with 156 additions and 40 deletions

View File

@@ -37,6 +37,10 @@ public interface Platform{
/** Steam: View a map listing on the workshop.*/
default void viewMapListing(String mapid){}
/** Steam: View map workshop info, removing the map ID tag if its listing is deleted.
* Also presents the option to update the map. */
default void viewMapListingInfo(Map map){}
/** Steam: Open workshop for maps.*/
default void openWorkshop(){}

View File

@@ -147,13 +147,13 @@ public class MapEditorDialog extends Dialog implements Disposable{
if(steam){
menu.cont.addImageTextButton("$editor.publish.workshop", Icon.linkSmall, () -> {
Map map = save();
if(editor.getTags().containsKey("steamid")){
platform.viewMapListing(editor.getTags().get("steamid"));
platform.viewMapListingInfo(map);
return;
}
Map map = save();
if(map == null) return;
if(map.tags.get("description", "").length() < 4){
@@ -167,7 +167,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
}
platform.publishMap(map);
}).padTop(-3).size(swidth * 2f + 10, 60f).update(b -> b.setText(editor.getTags().containsKey("steamid") ? "$view.workshop" : "$editor.publish.workshop"));
}).padTop(-3).size(swidth * 2f + 10, 60f).update(b -> b.setText(editor.getTags().containsKey("steamid") ? editor.getTags().get("author").equals(player.name) ? "$workshop.listing" : "$view.workshop" : "$editor.publish.workshop"));
menu.cont.row();
}

View File

@@ -41,6 +41,10 @@ public class Bar extends Element{
}
public void reset(float value){
this.value = lastValue = blink = value;
}
public void set(Supplier<String> name, FloatProvider fraction, Color color){
this.fraction = fraction;
this.lastValue = fraction.get();

View File

@@ -38,6 +38,7 @@ public class LoadingFragment extends Fragment{
}
public void setProgress(FloatProvider progress){
bar.reset(0f);
bar.visible(true);
bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent);
}