Workshop tweaks
This commit is contained in:
@@ -174,6 +174,7 @@ save.playtime = Playtime: {0}
|
|||||||
warning = Warning.
|
warning = Warning.
|
||||||
confirm = Confirm
|
confirm = Confirm
|
||||||
delete = Delete
|
delete = Delete
|
||||||
|
view.workshop = View In Workshop
|
||||||
ok = OK
|
ok = OK
|
||||||
open = Open
|
open = Open
|
||||||
customize = Customize Rules
|
customize = Customize Rules
|
||||||
@@ -222,6 +223,7 @@ editor.oregen.info = Ore Generation:
|
|||||||
editor.mapinfo = Map Info
|
editor.mapinfo = Map Info
|
||||||
editor.author = Author:
|
editor.author = Author:
|
||||||
editor.description = Description:
|
editor.description = Description:
|
||||||
|
editor.nodescription = A map must have a description of at least 4 characters before being published.
|
||||||
editor.waves = Waves:
|
editor.waves = Waves:
|
||||||
editor.rules = Rules:
|
editor.rules = Rules:
|
||||||
editor.generation = Generation:
|
editor.generation = Generation:
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class Vars implements Loadable{
|
|||||||
public static EntityCollisions collisions;
|
public static EntityCollisions collisions;
|
||||||
public static DefaultWaves defaultWaves;
|
public static DefaultWaves defaultWaves;
|
||||||
public static LoopControl loops;
|
public static LoopControl loops;
|
||||||
public static Platform platform;
|
public static Platform platform = new Platform(){};
|
||||||
public static Plugins plugins;
|
public static Plugins plugins;
|
||||||
|
|
||||||
public static World world;
|
public static World world;
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ public interface Platform{
|
|||||||
return Array.with();
|
return Array.with();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Steam: View a map listing on the workshop.*/
|
||||||
|
default void viewMapListing(Map map){}
|
||||||
|
|
||||||
/** Steam: Open workshop for maps.*/
|
/** Steam: Open workshop for maps.*/
|
||||||
default void openWorkshop(){}
|
default void openWorkshop(){}
|
||||||
|
|
||||||
|
|||||||
@@ -154,9 +154,20 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
if(steam){
|
if(steam){
|
||||||
menu.cont.addImageTextButton("$editor.publish.workshop", Icon.linkSmall, () -> {
|
menu.cont.addImageTextButton("$editor.publish.workshop", Icon.linkSmall, () -> {
|
||||||
Map map = save();
|
Map map = save();
|
||||||
if(map != null){
|
|
||||||
platform.publishMap(map);
|
if(map == null) return;
|
||||||
|
|
||||||
|
if(map.tags.get("description", "").length() < 4){
|
||||||
|
ui.showErrorMessage("$editor.nodescription");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Gamemode.survival.valid(map)){
|
||||||
|
ui.showErrorMessage("$map.nospawn");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
platform.publishMap(map);
|
||||||
}).padTop(-3).size(swidth * 2f + 10, 60f);
|
}).padTop(-3).size(swidth * 2f + 10, 60f);
|
||||||
|
|
||||||
menu.cont.row();
|
menu.cont.row();
|
||||||
@@ -276,7 +287,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map save(){
|
public Map save(){
|
||||||
String name = editor.getTags().get("name", "").trim();
|
String name = editor.getTags().get("name", "").trim();
|
||||||
editor.getTags().put("rules", JsonIO.write(state.rules));
|
editor.getTags().put("rules", JsonIO.write(state.rules));
|
||||||
editor.getTags().remove("width");
|
editor.getTags().remove("width");
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class Map implements Comparable<Map>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FileHandle previewFile(){
|
public FileHandle previewFile(){
|
||||||
return Vars.mapPreviewDirectory.child(file.nameWithoutExtension() + ".png");
|
return Vars.mapPreviewDirectory.child((workshop ? file.parent().name() : file.nameWithoutExtension()) + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileHandle cacheFile(){
|
public FileHandle cacheFile(){
|
||||||
@@ -133,6 +133,8 @@ public class Map implements Comparable<Map>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Map map){
|
public int compareTo(Map map){
|
||||||
|
int work = -Boolean.compare(workshop, map.workshop);
|
||||||
|
if(work != 0) return work;
|
||||||
int type = -Boolean.compare(custom, map.custom);
|
int type = -Boolean.compare(custom, map.custom);
|
||||||
if(type != 0) return type;
|
if(type != 0) return type;
|
||||||
int modes = Boolean.compare(Gamemode.pvp.valid(this), Gamemode.pvp.valid(map));
|
int modes = Boolean.compare(Gamemode.pvp.valid(this), Gamemode.pvp.valid(map));
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.anuke.arc.assets.loaders.resolvers.*;
|
|||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.files.*;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.*;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ public class MapPreviewLoader extends TextureLoader{
|
|||||||
try{
|
try{
|
||||||
super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter);
|
super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
Log.err(e);
|
||||||
MapPreviewParameter param = (MapPreviewParameter)parameter;
|
MapPreviewParameter param = (MapPreviewParameter)parameter;
|
||||||
Vars.maps.queueNewPreview(param.map);
|
Vars.maps.queueNewPreview(param.map);
|
||||||
}
|
}
|
||||||
@@ -31,11 +32,11 @@ public class MapPreviewLoader extends TextureLoader{
|
|||||||
try{
|
try{
|
||||||
return super.loadSync(manager, fileName, file, parameter);
|
return super.loadSync(manager, fileName, file, parameter);
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
e.printStackTrace();
|
Log.err(e);
|
||||||
try{
|
try{
|
||||||
return new Texture(file);
|
return new Texture(file);
|
||||||
}catch(Throwable e2){
|
}catch(Throwable e2){
|
||||||
e2.printStackTrace();
|
Log.err(e2);
|
||||||
return new Texture("sprites/error.png");
|
return new Texture("sprites/error.png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,10 +324,8 @@ public class Maps{
|
|||||||
public void loadPreviews(){
|
public void loadPreviews(){
|
||||||
|
|
||||||
for(Map map : maps){
|
for(Map map : maps){
|
||||||
Log.info("Generating preview for {0}", map.name());
|
|
||||||
//try to load preview
|
//try to load preview
|
||||||
if(map.previewFile().exists()){
|
if(map.previewFile().exists()){
|
||||||
Log.info("> exists");
|
|
||||||
//this may fail, but calls queueNewPreview
|
//this may fail, but calls queueNewPreview
|
||||||
Core.assets.load(new AssetDescriptor<>(map.previewFile().path() + "." + mapExtension, Texture.class, new MapPreviewParameter(map))).loaded = t -> map.texture = (Texture)t;
|
Core.assets.load(new AssetDescriptor<>(map.previewFile().path() + "." + mapExtension, Texture.class, new MapPreviewParameter(map))).loaded = t -> map.texture = (Texture)t;
|
||||||
|
|
||||||
@@ -338,7 +336,6 @@ public class Maps{
|
|||||||
queueNewPreview(map);
|
queueNewPreview(map);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Log.info("> doesn't exist, queuing");
|
|
||||||
queueNewPreview(map);
|
queueNewPreview(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,7 +344,6 @@ public class Maps{
|
|||||||
private void createAllPreviews(){
|
private void createAllPreviews(){
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> {
|
||||||
for(Map map : previewList){
|
for(Map map : previewList){
|
||||||
Log.info("> > GEN NEW preview for {0}", map.name());
|
|
||||||
createNewPreview(map, e -> Core.app.post(() -> map.texture = Core.assets.get("sprites/error.png")));
|
createNewPreview(map, e -> Core.app.post(() -> map.texture = Core.assets.get("sprites/error.png")));
|
||||||
}
|
}
|
||||||
previewList.clear();
|
previewList.clear();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import io.anuke.arc.*;
|
|||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.input.*;
|
import io.anuke.arc.input.*;
|
||||||
import io.anuke.arc.math.*;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.scene.event.*;
|
|
||||||
import io.anuke.arc.scene.ui.*;
|
import io.anuke.arc.scene.ui.*;
|
||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
@@ -205,13 +204,17 @@ public class MapsDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
}).fillX().height(54f).marginLeft(10);
|
}).fillX().height(54f).marginLeft(10);
|
||||||
|
|
||||||
table.addImageTextButton("$delete", Icon.trash16Small, () -> {
|
table.addImageTextButton(map.workshop ? "$view.workshop" : "$delete", map.workshop ? Icon.linkSmall : Icon.trash16Small, () -> {
|
||||||
ui.showConfirm("$confirm", Core.bundle.format("map.delete", map.name()), () -> {
|
if(map.workshop){
|
||||||
maps.removeMap(map);
|
platform.viewMapListing(map);
|
||||||
dialog.hide();
|
}else{
|
||||||
setup();
|
ui.showConfirm("$confirm", Core.bundle.format("map.delete", map.name()), () -> {
|
||||||
});
|
maps.removeMap(map);
|
||||||
}).fillX().height(54f).marginLeft(10).disabled(!map.custom).touchable(map.custom ? Touchable.enabled : Touchable.disabled);
|
dialog.hide();
|
||||||
|
setup();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).fillX().height(54f).marginLeft(10).disabled(!map.workshop && !map.custom);
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,6 +202,11 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
return !steam ? super.getExternalMaps() : SVars.workshop.getMapFiles();
|
return !steam ? super.getExternalMaps() : SVars.workshop.getMapFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void viewMapListing(Map map){
|
||||||
|
SVars.net.friends.activateGameOverlayToWebPage("steam://url/CommunityFilePage/" + map.file.parent().name());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetProvider getNet(){
|
public NetProvider getNet(){
|
||||||
return steam ? SVars.net : new ArcNetImpl();
|
return steam ? SVars.net : new ArcNetImpl();
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ public class SWorkshop implements SteamUGCCallback{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void publishMap(Map map){
|
public void publishMap(Map map){
|
||||||
|
if(map.tags.containsKey("steamid")){
|
||||||
|
Log.info("Map already published, redirecting to ID.");
|
||||||
|
SVars.net.friends.activateGameOverlayToWebPage("steam://url/CommunityFilePage/" + map.tags.get("steamid"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//update author name when publishing
|
||||||
|
map.tags.put("author", SVars.net.friends.getPersonaName());
|
||||||
|
|
||||||
FloatingDialog dialog = new FloatingDialog("$confirm");
|
FloatingDialog dialog = new FloatingDialog("$confirm");
|
||||||
dialog.setFillParent(false);
|
dialog.setFillParent(false);
|
||||||
dialog.cont.add("$map.publish.confirm").width(600f).wrap();
|
dialog.cont.add("$map.publish.confirm").width(600f).wrap();
|
||||||
@@ -141,6 +150,12 @@ public class SWorkshop implements SteamUGCCallback{
|
|||||||
if(needsToAcceptWLA){
|
if(needsToAcceptWLA){
|
||||||
SVars.net.friends.activateGameOverlayToWebPage("https://steamcommunity.com/sharedfiles/workshoplegalagreement");
|
SVars.net.friends.activateGameOverlayToWebPage("https://steamcommunity.com/sharedfiles/workshoplegalagreement");
|
||||||
}
|
}
|
||||||
|
ui.editor.editor.getTags().put("steamid", SteamNativeHandle.getNativeHandle(publishedFileID) + "");
|
||||||
|
try{
|
||||||
|
ui.editor.save();
|
||||||
|
}catch(Exception e){
|
||||||
|
Log.err(e);
|
||||||
|
}
|
||||||
Events.fire(new MapPublishEvent());
|
Events.fire(new MapPublishEvent());
|
||||||
}else{
|
}else{
|
||||||
ui.showErrorMessage(Core.bundle.format("map.publish.error ", result.name()));
|
ui.showErrorMessage(Core.bundle.format("map.publish.error ", result.name()));
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=de8be7efb888294932a9d41140ac9a71b4ff7f18
|
archash=818e26ff093403031fcf31d3424dacb9c646d4b6
|
||||||
|
|||||||
Reference in New Issue
Block a user