diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 3ec02254de..4e405530cb 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -359,6 +359,7 @@ map.publish.confirm = Are you sure you want to publish this map?\n\n[lightgray]M workshop.menu = Select what you would like to do with this item. workshop.info = Item Info changelog = Changelog (optional): +updatedesc = Overwrite Title & Description eula = Steam EULA missing = This item has been deleted or moved.\n[lightgray]The workshop listing has now been automatically un-linked. publishing = [accent]Publishing... diff --git a/core/src/mindustry/editor/MapEditorDialog.java b/core/src/mindustry/editor/MapEditorDialog.java index 0a4802e13b..bd7eae828e 100644 --- a/core/src/mindustry/editor/MapEditorDialog.java +++ b/core/src/mindustry/editor/MapEditorDialog.java @@ -348,10 +348,19 @@ public class MapEditorDialog extends Dialog implements Disposable{ Core.app.post(() -> ui.showErrorMessage("@editor.save.noname")); }else{ Map map = maps.all().find(m -> m.name().equals(name)); - if(map != null && !map.custom){ + if(map != null && !map.custom && !map.workshop){ handleSaveBuiltin(map); }else{ + boolean workshop = false; + //try to preserve Steam ID + if(map != null && map.tags.containsKey("steamid")){ + editor.tags.put("steamid", map.tags.get("steamid")); + workshop = true; + } returned = maps.saveMap(editor.tags); + if(workshop){ + returned.workshop = workshop; + } ui.showInfoFade("@editor.saved"); } } diff --git a/desktop/build.gradle b/desktop/build.gradle index 39259c321e..4b817dd51d 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -60,6 +60,7 @@ if(!project.ext.hasSprites() && System.getenv("JITPACK") != "true"){ } //this is only for local testing +//add -Prelease -PversionModifier=steam as build properties task steamtest(dependsOn: dist){ doLast{ copy{ diff --git a/desktop/src/mindustry/desktop/steam/SWorkshop.java b/desktop/src/mindustry/desktop/steam/SWorkshop.java index 9799da60d8..fe15cfdc6c 100644 --- a/desktop/src/mindustry/desktop/steam/SWorkshop.java +++ b/desktop/src/mindustry/desktop/steam/SWorkshop.java @@ -69,14 +69,7 @@ public class SWorkshop implements SteamUGCCallback{ return; } - showPublish(id -> update(p, id, null)); - } - - /** Update an existing item with a changelog. */ - public void updateItem(Publishable p, String changelog){ - String id = p.getSteamID(); - long handle = Strings.parseLong(id, -1); - update(p, new SteamPublishedFileID(handle), changelog); + showPublish(id -> update(p, id, null, true)); } /** Fetches info for an item, checking to make sure that it exists.*/ @@ -113,6 +106,12 @@ public class SWorkshop implements SteamUGCCallback{ cont.row(); TextArea field = cont.area("", t -> {}).size(500f, 160f).get(); field.setMaxLength(400); + cont.row(); + + boolean[] updatedesc = {false}; + + cont.check("@updatedesc", b -> updatedesc[0] = b).pad(4); + buttons.defaults().size(120, 54).pad(4); buttons.button("@ok", () -> { if(!p.prePublish()){ @@ -121,7 +120,7 @@ public class SWorkshop implements SteamUGCCallback{ } ui.loadfrag.show("@publishing"); - updateItem(p, field.getText().replace("\r", "\n")); + SWorkshop.this.update(p, new SteamPublishedFileID(Strings.parseLong(p.getSteamID(), -1)), field.getText().replace("\r", "\n"), updatedesc[0]); dialog.hide(); hide(); }); @@ -149,19 +148,21 @@ public class SWorkshop implements SteamUGCCallback{ SVars.net.friends.activateGameOverlayToWebPage("steam://url/CommunityFilePage/" + id.handle()); } - void update(Publishable p, SteamPublishedFileID id, String changelog){ + void update(Publishable p, SteamPublishedFileID id, String changelog, boolean updateDescription){ Log.info("Calling update(@) @", p.steamTitle(), id.handle()); String sid = id.handle() + ""; updateItem(id, h -> { - if(p.steamDescription() != null){ - ugc.setItemDescription(h, p.steamDescription()); + if(updateDescription){ + ugc.setItemTitle(h, p.steamTitle()); + if(p.steamDescription() != null){ + ugc.setItemDescription(h, p.steamDescription()); + } } Seq tags = p.extraTags(); tags.add(p.steamTag()); - ugc.setItemTitle(h, p.steamTitle()); ugc.setItemTags(h, tags.toArray(String.class)); ugc.setItemPreview(h, p.createSteamPreview(sid).absolutePath()); ugc.setItemContent(h, p.createSteamFolder(sid).absolutePath());