Minor workshop fixes

This commit is contained in:
Anuken
2022-04-17 11:08:51 -04:00
parent 495250850e
commit 95c34996af
4 changed files with 26 additions and 14 deletions

View File

@@ -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.menu = Select what you would like to do with this item.
workshop.info = Item Info workshop.info = Item Info
changelog = Changelog (optional): changelog = Changelog (optional):
updatedesc = Overwrite Title & Description
eula = Steam EULA eula = Steam EULA
missing = This item has been deleted or moved.\n[lightgray]The workshop listing has now been automatically un-linked. missing = This item has been deleted or moved.\n[lightgray]The workshop listing has now been automatically un-linked.
publishing = [accent]Publishing... publishing = [accent]Publishing...

View File

@@ -348,10 +348,19 @@ public class MapEditorDialog extends Dialog implements Disposable{
Core.app.post(() -> ui.showErrorMessage("@editor.save.noname")); Core.app.post(() -> ui.showErrorMessage("@editor.save.noname"));
}else{ }else{
Map map = maps.all().find(m -> m.name().equals(name)); Map map = maps.all().find(m -> m.name().equals(name));
if(map != null && !map.custom){ if(map != null && !map.custom && !map.workshop){
handleSaveBuiltin(map); handleSaveBuiltin(map);
}else{ }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); returned = maps.saveMap(editor.tags);
if(workshop){
returned.workshop = workshop;
}
ui.showInfoFade("@editor.saved"); ui.showInfoFade("@editor.saved");
} }
} }

View File

@@ -60,6 +60,7 @@ if(!project.ext.hasSprites() && System.getenv("JITPACK") != "true"){
} }
//this is only for local testing //this is only for local testing
//add -Prelease -PversionModifier=steam as build properties
task steamtest(dependsOn: dist){ task steamtest(dependsOn: dist){
doLast{ doLast{
copy{ copy{

View File

@@ -69,14 +69,7 @@ public class SWorkshop implements SteamUGCCallback{
return; return;
} }
showPublish(id -> update(p, id, null)); showPublish(id -> update(p, id, null, true));
}
/** 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);
} }
/** Fetches info for an item, checking to make sure that it exists.*/ /** Fetches info for an item, checking to make sure that it exists.*/
@@ -113,6 +106,12 @@ public class SWorkshop implements SteamUGCCallback{
cont.row(); cont.row();
TextArea field = cont.area("", t -> {}).size(500f, 160f).get(); TextArea field = cont.area("", t -> {}).size(500f, 160f).get();
field.setMaxLength(400); 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.defaults().size(120, 54).pad(4);
buttons.button("@ok", () -> { buttons.button("@ok", () -> {
if(!p.prePublish()){ if(!p.prePublish()){
@@ -121,7 +120,7 @@ public class SWorkshop implements SteamUGCCallback{
} }
ui.loadfrag.show("@publishing"); 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(); dialog.hide();
hide(); hide();
}); });
@@ -149,19 +148,21 @@ public class SWorkshop implements SteamUGCCallback{
SVars.net.friends.activateGameOverlayToWebPage("steam://url/CommunityFilePage/" + id.handle()); 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()); Log.info("Calling update(@) @", p.steamTitle(), id.handle());
String sid = id.handle() + ""; String sid = id.handle() + "";
updateItem(id, h -> { updateItem(id, h -> {
if(p.steamDescription() != null){ if(updateDescription){
ugc.setItemDescription(h, p.steamDescription()); ugc.setItemTitle(h, p.steamTitle());
if(p.steamDescription() != null){
ugc.setItemDescription(h, p.steamDescription());
}
} }
Seq<String> tags = p.extraTags(); Seq<String> tags = p.extraTags();
tags.add(p.steamTag()); tags.add(p.steamTag());
ugc.setItemTitle(h, p.steamTitle());
ugc.setItemTags(h, tags.toArray(String.class)); ugc.setItemTags(h, tags.toArray(String.class));
ugc.setItemPreview(h, p.createSteamPreview(sid).absolutePath()); ugc.setItemPreview(h, p.createSteamPreview(sid).absolutePath());
ugc.setItemContent(h, p.createSteamFolder(sid).absolutePath()); ugc.setItemContent(h, p.createSteamFolder(sid).absolutePath());