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.*/ /** Steam: View a map listing on the workshop.*/
default void viewMapListing(Map map){} default void viewMapListing(Map map){}
/** Steam: View a map listing on the workshop.*/ /** Steam: View a listing on the workshop.*/
default void viewMapListing(String mapid){} default void viewListing(String mapid){}
/** Steam: View map workshop info, removing the map ID tag if its listing is deleted. /** Steam: View map workshop info, removing the map ID tag if its listing is deleted.
* Also presents the option to update the map. */ * 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, () -> { menu.cont.addImageTextButton("$editor.publish.workshop", Icon.linkSmall, () -> {
Map builtin = maps.all().find(m -> m.name().equals(editor.getTags().get("name", "").trim())); Map builtin = maps.all().find(m -> m.name().equals(editor.getTags().get("name", "").trim()));
if(editor.getTags().containsKey("steamid") && builtin != null && !builtin.custom){ if(editor.getTags().containsKey("steamid") && builtin != null && !builtin.custom){
platform.viewMapListing(editor.getTags().get("steamid")); platform.viewListing(editor.getTags().get("steamid"));
return; return;
} }

View File

@ -76,6 +76,7 @@ public class Mods implements Loadable{
@Override @Override
public void loadAsync(){ public void loadAsync(){
if(loaded.isEmpty()) return; if(loaded.isEmpty()) return;
Time.mark();
packer = new PixmapPacker(2048, 2048, Format.RGBA8888, 2, true); 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("Packed {0} images for mod '{1}'.", packed[0], mod.meta.name);
} }
Log.info("Time to pack textures: {0}", Time.elapsed());
} }
@Override @Override
public void loadSync(){ public void loadSync(){
if(packer == null) return; if(packer == null) return;
Time.mark();
Texture editor = Core.atlas.find("clear-editor").getTexture(); Texture editor = Core.atlas.find("clear-editor").getTexture();
PixmapPacker editorPacker = new PixmapPacker(2048, 2048, Format.RGBA8888, 2, true); PixmapPacker editorPacker = new PixmapPacker(2048, 2048, Format.RGBA8888, 2, true);
@ -140,6 +144,7 @@ public class Mods implements Loadable{
packer.dispose(); packer.dispose();
packer = null; packer = null;
Log.info("Time to update textures: {0}", Time.elapsed());
} }
/** Removes a mod file and marks it for requiring a restart. */ /** Removes a mod file and marks it for requiring a restart. */
@ -271,7 +276,7 @@ public class Mods implements Loadable{
try{ try{
//this binds the content but does not load it entirely //this binds the content but does not load it entirely
Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString(), type); 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){ }catch(Exception e){
throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", 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(); setup();
}).height(50f).margin(8f).width(130f); }).height(50f).margin(8f).width(130f);
title.addImageButton(Icon.trash16Small, Styles.cleari, () -> ui.showConfirm("$confirm", "$mod.remove.confirm", () -> { title.addImageButton(mod.workshopID != null ? Icon.linkSmall : Icon.trash16Small, Styles.cleari, () -> {
mods.removeMod(mod); if(mod.workshopID == null){
setup(); ui.showConfirm("$confirm", "$mod.remove.confirm", () -> {
})).size(50f); mods.removeMod(mod);
setup();
});
}else{
platform.viewListing(mod.workshopID);
}
}).size(50f);
}).growX().left().padTop(-14f).padRight(-14f); }).growX().left().padTop(-14f).padRight(-14f);
t.row(); t.row();

View File

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

View File

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