Workshop map listing button

This commit is contained in:
Anuken 2019-10-04 19:43:26 -04:00
parent edb0ece03b
commit 1b93da20f4
6 changed files with 22 additions and 11 deletions

View File

@ -39,8 +39,8 @@ public interface Platform{
/** Steam: View a map listing on the workshop.*/
default void viewMapListing(Map map){}
/** Steam: View a map listing on the workshop.*/
default void viewMapListing(String mapid){}
/** Steam: View a listing on the workshop.*/
default void viewListing(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. */

View File

@ -150,7 +150,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
menu.cont.addImageTextButton("$editor.publish.workshop", Icon.linkSmall, () -> {
Map builtin = maps.all().find(m -> m.name().equals(editor.getTags().get("name", "").trim()));
if(editor.getTags().containsKey("steamid") && builtin != null && !builtin.custom){
platform.viewMapListing(editor.getTags().get("steamid"));
platform.viewListing(editor.getTags().get("steamid"));
return;
}

View File

@ -76,6 +76,7 @@ public class Mods implements Loadable{
@Override
public void loadAsync(){
if(loaded.isEmpty()) return;
Time.mark();
packer = new PixmapPacker(2048, 2048, Format.RGBA8888, 2, true);
@ -104,11 +105,14 @@ public class Mods implements Loadable{
});
Log.info("Packed {0} images for mod '{1}'.", packed[0], mod.meta.name);
}
Log.info("Time to pack textures: {0}", Time.elapsed());
}
@Override
public void loadSync(){
if(packer == null) return;
Time.mark();
Texture editor = Core.atlas.find("clear-editor").getTexture();
PixmapPacker editorPacker = new PixmapPacker(2048, 2048, Format.RGBA8888, 2, true);
@ -140,6 +144,7 @@ public class Mods implements Loadable{
packer.dispose();
packer = null;
Log.info("Time to update textures: {0}", Time.elapsed());
}
/** Removes a mod file and marks it for requiring a restart. */
@ -271,7 +276,7 @@ public class Mods implements Loadable{
try{
//this binds the content but does not load it entirely
Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString(), type);
Log.info("[{0}] Loaded '{1}'.", mod.meta.name, loaded);
Log.info("[{0}] Loaded '{1}'.", mod.meta.name, (loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded));
}catch(Exception e){
throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e);
}

View File

@ -76,10 +76,16 @@ public class ModsDialog extends FloatingDialog{
setup();
}).height(50f).margin(8f).width(130f);
title.addImageButton(Icon.trash16Small, Styles.cleari, () -> ui.showConfirm("$confirm", "$mod.remove.confirm", () -> {
mods.removeMod(mod);
setup();
})).size(50f);
title.addImageButton(mod.workshopID != null ? Icon.linkSmall : Icon.trash16Small, Styles.cleari, () -> {
if(mod.workshopID == null){
ui.showConfirm("$confirm", "$mod.remove.confirm", () -> {
mods.removeMod(mod);
setup();
});
}else{
platform.viewListing(mod.workshopID);
}
}).size(50f);
}).growX().left().padTop(-14f).padRight(-14f);
t.row();

View File

@ -228,11 +228,11 @@ public class DesktopLauncher extends ClientLauncher{
@Override
public void viewMapListing(Map map){
viewMapListing(map.file.parent().name());
viewListing(map.file.parent().name());
}
@Override
public void viewMapListing(String mapid){
public void viewListing(String mapid){
SVars.net.friends.activateGameOverlayToWebPage("steam://url/CommunityFilePage/" + mapid);
}

View File

@ -112,7 +112,7 @@ public class SWorkshop implements SteamUGCCallback{
dialog.addCloseButton();
dialog.buttons.addImageTextButton("$view.workshop", Icon.linkSmall, () -> {
platform.viewMapListing(id);
platform.viewListing(id);
dialog.hide();
}).size(210f, 64f);