diff --git a/android/src/mindustry/android/AndroidLauncher.java b/android/src/mindustry/android/AndroidLauncher.java index b72d734b0b..0c9143dc42 100644 --- a/android/src/mindustry/android/AndroidLauncher.java +++ b/android/src/mindustry/android/AndroidLauncher.java @@ -173,6 +173,15 @@ public class AndroidLauncher extends AndroidApplication{ throw new ArcRuntimeException(e); } } + + @Override + public Writer writer(boolean append, String charset){ + try{ + return new OutputStreamWriter(write(append), charset); + }catch(IOException ex){ + throw new ArcRuntimeException(ex); + } + } }).toArray(Fi.class); Core.app.post(() -> Core.app.post(() -> params.handleChooseResult(files))); diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 1a6feccf95..256e947660 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sort by stars export.file = Export File import.file = Import File copy.clipboard = Copy to Clipboard -import.clipboard = Load from Clipboard +load.clipboard = Load from Clipboard workshop.browse = Browse Workshop workshop.share = Share on Workshop diff --git a/core/assets/bundles/bundle_be.properties b/core/assets/bundles/bundle_be.properties index 4232b29011..23213f1b2e 100644 --- a/core/assets/bundles/bundle_be.properties +++ b/core/assets/bundles/bundle_be.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Сартаваць па зоркам export.file = Экспартаваць файл import.file = Імпартаваць файл copy.clipboard = Скапіяваць у буфер абмена -import.clipboard = Уставіць з буфера абмену +load.clipboard = Уставіць з буфера абмену workshop.browse = Browse Workshop workshop.share = Падзяліцца ў Майстэрні diff --git a/core/assets/bundles/bundle_bg.properties b/core/assets/bundles/bundle_bg.properties index 0264770235..6e6bd36c7e 100644 --- a/core/assets/bundles/bundle_bg.properties +++ b/core/assets/bundles/bundle_bg.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Сортирай по рейтинг export.file = Изнасяне във файл import.file = Внасяне от файл copy.clipboard = Копирай в Клипборда -import.clipboard = Внеси от Клипборда +load.clipboard = Внеси от Клипборда workshop.browse = Browse Workshop workshop.share = Сподели в Работилницата diff --git a/core/assets/bundles/bundle_ca.properties b/core/assets/bundles/bundle_ca.properties index 6ec0f4eb28..e68e5de2af 100644 --- a/core/assets/bundles/bundle_ca.properties +++ b/core/assets/bundles/bundle_ca.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Ordena per valoració export.file = Exporta un fitxer import.file = Importa un fitxer copy.clipboard = Copia al porta-retalls -import.clipboard = Importa del porta-retalls +load.clipboard = Importa del porta-retalls workshop.browse = Browse Workshop workshop.share = Comparteix al Workshop de l’Steam diff --git a/core/assets/bundles/bundle_cs.properties b/core/assets/bundles/bundle_cs.properties index 9a2a3cc511..13c9e5d7b4 100644 --- a/core/assets/bundles/bundle_cs.properties +++ b/core/assets/bundles/bundle_cs.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Řadit podle hvězd export.file = Exportovat soubor import.file = Importovat soubor copy.clipboard = Zkopírovat do schránky -import.clipboard = Importovat ze schránky +load.clipboard = Importovat ze schránky workshop.browse = Browse Workshop workshop.share = Sdílet skrze Workshop na Steamu diff --git a/core/assets/bundles/bundle_da.properties b/core/assets/bundles/bundle_da.properties index d19728bbc4..614d46dccb 100644 --- a/core/assets/bundles/bundle_da.properties +++ b/core/assets/bundles/bundle_da.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sort by stars export.file = Exporter fil import.file = Importer fil copy.clipboard = Kopier til udklipsholder -import.clipboard = Importer fra udklipsholder +load.clipboard = Importer fra udklipsholder workshop.browse = Browse Workshop workshop.share = Del på Workshop diff --git a/core/assets/bundles/bundle_de.properties b/core/assets/bundles/bundle_de.properties index d7e02e9fcf..559ac9fbdc 100644 --- a/core/assets/bundles/bundle_de.properties +++ b/core/assets/bundles/bundle_de.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Nach Sternen sortieren export.file = Datei exportieren import.file = Datei importieren copy.clipboard = In Zwischenablage kopieren -import.clipboard = Aus Zwischenablage importieren +load.clipboard = Aus Zwischenablage importieren workshop.browse = Browse Workshop workshop.share = Im Workshop teilen diff --git a/core/assets/bundles/bundle_es.properties b/core/assets/bundles/bundle_es.properties index f5813e2335..2991f5a527 100644 --- a/core/assets/bundles/bundle_es.properties +++ b/core/assets/bundles/bundle_es.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Mejor valorados export.file = Exportar archivo import.file = Importar archivo copy.clipboard = Copiar al portapapeles -import.clipboard = Importar desde el portapapeles +load.clipboard = Importar desde el portapapeles workshop.browse = Browse Workshop workshop.share = Compartir en Steam Workshop diff --git a/core/assets/bundles/bundle_et.properties b/core/assets/bundles/bundle_et.properties index 8156ffd843..d184b2e5bf 100644 --- a/core/assets/bundles/bundle_et.properties +++ b/core/assets/bundles/bundle_et.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sorteeri tähtede järgi export.file = Ekspordi Fail import.file = Impordi Fail copy.clipboard = Kopeeri Lõikelauale -import.clipboard = Impordi Lõikelaualt +load.clipboard = Impordi Lõikelaualt workshop.browse = Browse Workshop workshop.share = Jaga Workshop'is diff --git a/core/assets/bundles/bundle_eu.properties b/core/assets/bundles/bundle_eu.properties index 9d8d8a4012..b2ae87a0b2 100644 --- a/core/assets/bundles/bundle_eu.properties +++ b/core/assets/bundles/bundle_eu.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Ordenatu izarren arabera export.file = Esportatu fitxategia import.file = Inportatu fitxategia copy.clipboard = Kopiatu arbelera -import.clipboard = Inportatu arbeletik +load.clipboard = Inportatu arbeletik workshop.browse = Browse Workshop workshop.share = Partekatu tailerrean diff --git a/core/assets/bundles/bundle_fi.properties b/core/assets/bundles/bundle_fi.properties index 8126ccd208..f9a3eaf158 100644 --- a/core/assets/bundles/bundle_fi.properties +++ b/core/assets/bundles/bundle_fi.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Järjestä tähtien määrän perusteella export.file = Vie tiedosto import.file = Tuo tiedosto copy.clipboard = Kopioi leikepöydälle -import.clipboard = Tuo leikepöydältä +load.clipboard = Tuo leikepöydältä workshop.browse = Browse Workshop workshop.share = Jaa Workshoppiin diff --git a/core/assets/bundles/bundle_fil.properties b/core/assets/bundles/bundle_fil.properties index 3d71a44640..b2cc918ec4 100644 --- a/core/assets/bundles/bundle_fil.properties +++ b/core/assets/bundles/bundle_fil.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Uriin sa kasikatan export.file = Mag-export ng File import.file = Kumuha ng File copy.clipboard = Kopyahin sa Clipboard -import.clipboard = Kunin mula sa Clipboard +load.clipboard = Kunin mula sa Clipboard workshop.browse = Browse Workshop workshop.share = Ibahagi sa Workshop diff --git a/core/assets/bundles/bundle_fr.properties b/core/assets/bundles/bundle_fr.properties index 74e677cbe4..68d418e7bf 100644 --- a/core/assets/bundles/bundle_fr.properties +++ b/core/assets/bundles/bundle_fr.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Classer par étoiles export.file = Exporter le fichier import.file = Importer un fichier copy.clipboard = Copier dans le presse-papier -import.clipboard = Importer depuis presse-papier +load.clipboard = Importer depuis presse-papier workshop.browse = Browse Workshop workshop.share = Partager sur le Steam Workshop diff --git a/core/assets/bundles/bundle_hu.properties b/core/assets/bundles/bundle_hu.properties index 139c354110..d5fadeb836 100644 --- a/core/assets/bundles/bundle_hu.properties +++ b/core/assets/bundles/bundle_hu.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Legjobbra értékeltek export.file = Exportálás fájlba import.file = Importálás fájlból copy.clipboard = Másolás a vágólapra -import.clipboard = Betöltés a vágólapról +load.clipboard = Betöltés a vágólapról workshop.browse = Browse Workshop workshop.share = Megosztás a Steam Műhelyben diff --git a/core/assets/bundles/bundle_id_ID.properties b/core/assets/bundles/bundle_id_ID.properties index b27cb82867..78d23dec06 100644 --- a/core/assets/bundles/bundle_id_ID.properties +++ b/core/assets/bundles/bundle_id_ID.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Urut berdasarkan bintang export.file = Ekspor File import.file = Impor File copy.clipboard = Salin ke papan klip -import.clipboard = Impor dari papan klip +load.clipboard = Impor dari papan klip workshop.browse = Cari di Workshop workshop.share = Bagikan di Workshop diff --git a/core/assets/bundles/bundle_it.properties b/core/assets/bundles/bundle_it.properties index 7808e6ac87..410dd6e4f3 100644 --- a/core/assets/bundles/bundle_it.properties +++ b/core/assets/bundles/bundle_it.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Ordinato per stelle export.file = Esporta File import.file = Importa File copy.clipboard = Copia negli Appunti -import.clipboard = Importa dagli Appunti +load.clipboard = Importa dagli Appunti workshop.browse = Browse Workshop workshop.share = Condividi nel Workshop diff --git a/core/assets/bundles/bundle_ja.properties b/core/assets/bundles/bundle_ja.properties index ea65b166ed..69a00de373 100644 --- a/core/assets/bundles/bundle_ja.properties +++ b/core/assets/bundles/bundle_ja.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = お気に入り数で並べる export.file = ファイルに出力する import.file = ファイルから読み込む copy.clipboard = クリップボードにコピーする -import.clipboard = クリップボードから読み込む +load.clipboard = クリップボードから読み込む workshop.browse = Browse Workshop workshop.share = ワークショップで共有する diff --git a/core/assets/bundles/bundle_ko.properties b/core/assets/bundles/bundle_ko.properties index 3145365682..de5d3099e1 100644 --- a/core/assets/bundles/bundle_ko.properties +++ b/core/assets/bundles/bundle_ko.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = 추천(스타) 수 export.file = 파일 내보내기 import.file = 파일 가져오기 copy.clipboard = 클립보드에 복사 -import.clipboard = 클립보드에서 가져오기 +load.clipboard = 클립보드에서 가져오기 workshop.browse = Browse Workshop workshop.share = 창작마당에 공유 diff --git a/core/assets/bundles/bundle_lt.properties b/core/assets/bundles/bundle_lt.properties index b61009cca8..a43e3451a1 100644 --- a/core/assets/bundles/bundle_lt.properties +++ b/core/assets/bundles/bundle_lt.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Rūšiuoti pagal žvaigždes export.file = Eksportuoti failą import.file = Importuoti failą copy.clipboard = Kopijuoti į iškarpinę -import.clipboard = Importuoti iš iškarpinės +load.clipboard = Importuoti iš iškarpinės workshop.browse = Naršyti Dirbtuves workshop.share = Dalintis Dirbtuvėje diff --git a/core/assets/bundles/bundle_nl.properties b/core/assets/bundles/bundle_nl.properties index 0bde306c0a..c062a54ee6 100644 --- a/core/assets/bundles/bundle_nl.properties +++ b/core/assets/bundles/bundle_nl.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sorteer op sterren export.file = Exporteer bestand import.file = Importeer bestand copy.clipboard = Kopi�ren naar Klembord -import.clipboard = Importeren van Klembord +load.clipboard = Importeren van Klembord workshop.browse = Browse Workshop workshop.share = Delen op de Werkplaats diff --git a/core/assets/bundles/bundle_nl_BE.properties b/core/assets/bundles/bundle_nl_BE.properties index 87f0a357c6..bce66224c1 100644 --- a/core/assets/bundles/bundle_nl_BE.properties +++ b/core/assets/bundles/bundle_nl_BE.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sort by stars export.file = Exporteer Bestand import.file = Exporteer Bestand copy.clipboard = Kopieer naar Klembord -import.clipboard = Importeer vanaf Klembord +load.clipboard = Importeer vanaf Klembord workshop.browse = Browse Workshop workshop.share = Deel op Workshop diff --git a/core/assets/bundles/bundle_pl.properties b/core/assets/bundles/bundle_pl.properties index 296b38ab17..87ab4e3f63 100644 --- a/core/assets/bundles/bundle_pl.properties +++ b/core/assets/bundles/bundle_pl.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sortuj wg gwiazdek export.file = Eksportuj plik import.file = Importuj plik copy.clipboard = Kopiuj do schowka -import.clipboard = Importuj ze schowka +load.clipboard = Importuj ze schowka workshop.browse = Browse Workshop workshop.share = Podziel się na Warsztacie diff --git a/core/assets/bundles/bundle_pt_BR.properties b/core/assets/bundles/bundle_pt_BR.properties index 87794dd7c3..56bd289873 100644 --- a/core/assets/bundles/bundle_pt_BR.properties +++ b/core/assets/bundles/bundle_pt_BR.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Ordenar por estrelas export.file = Exportar Arquivo import.file = Importar Arquivo copy.clipboard = Copiar para a área de transferência -import.clipboard = Importar da área de transferência +load.clipboard = Importar da área de transferência workshop.browse = Browse Workshop workshop.share = Compartilhar na Oficina diff --git a/core/assets/bundles/bundle_pt_PT.properties b/core/assets/bundles/bundle_pt_PT.properties index 8de74ce2ff..d20892359b 100644 --- a/core/assets/bundles/bundle_pt_PT.properties +++ b/core/assets/bundles/bundle_pt_PT.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Ordenar por estrelas export.file = Exportar Ficheiro import.file = Importar Ficheiro copy.clipboard = Copiar para a área de transferência -import.clipboard = Importar da área de transferência +load.clipboard = Importar da área de transferência workshop.browse = Browse Workshop workshop.share = Partilhar na Workshop diff --git a/core/assets/bundles/bundle_ro.properties b/core/assets/bundles/bundle_ro.properties index e8a6f83094..923fa43fbb 100644 --- a/core/assets/bundles/bundle_ro.properties +++ b/core/assets/bundles/bundle_ro.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Cele mai multe stele export.file = Exportă Fișier import.file = Importă Fișier copy.clipboard = Copiază în Clipboard -import.clipboard = Importă din Clipboard +load.clipboard = Importă din Clipboard workshop.browse = Browse Workshop workshop.share = Partajează pe Workshop diff --git a/core/assets/bundles/bundle_ru.properties b/core/assets/bundles/bundle_ru.properties index bb26df97da..08ee963199 100644 --- a/core/assets/bundles/bundle_ru.properties +++ b/core/assets/bundles/bundle_ru.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Сортировка по количеству звёз export.file = Экспортировать файл import.file = Импортировать файл copy.clipboard = Скопировать в буфер обмена -import.clipboard = Вставить из буфера обмена +load.clipboard = Вставить из буфера обмена workshop.browse = Browse Workshop workshop.share = Поделиться в Мастерской diff --git a/core/assets/bundles/bundle_sr.properties b/core/assets/bundles/bundle_sr.properties index da09fb5c9c..556b2c5842 100644 --- a/core/assets/bundles/bundle_sr.properties +++ b/core/assets/bundles/bundle_sr.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sortiraj po broju "zvezdica" export.file = Izvezi dokument import.file = Uvezi dokument copy.clipboard = Iskopiraj u privremenu memoriju -import.clipboard = Uvezi is privremene memoriju +load.clipboard = Uvezi is privremene memoriju workshop.browse = Browse Workshop workshop.share = Podeli na radionici diff --git a/core/assets/bundles/bundle_sv.properties b/core/assets/bundles/bundle_sv.properties index fb55877a8a..3d10b19c9f 100644 --- a/core/assets/bundles/bundle_sv.properties +++ b/core/assets/bundles/bundle_sv.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sortera efter stjärnor export.file = Exportera Fil import.file = Importera Fil copy.clipboard = Kopiera till urklipp -import.clipboard = Importera från urklipp +load.clipboard = Importera från urklipp workshop.browse = Browse Workshop workshop.share = Dela på Workshoppen diff --git a/core/assets/bundles/bundle_th.properties b/core/assets/bundles/bundle_th.properties index 384e0300c5..d740d9513b 100644 --- a/core/assets/bundles/bundle_th.properties +++ b/core/assets/bundles/bundle_th.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = เรียงตามคะแนนดาว export.file = ส่งออกไฟล์ import.file = นำเข้าไฟล์ copy.clipboard = คัดลอกไปที่คลิปบอร์ด -import.clipboard = นำเข้าจากคลิปบอร์ด +load.clipboard = นำเข้าจากคลิปบอร์ด workshop.browse = ค้นหาในเวิร์กช็อป workshop.share = แชร์บนเวิร์กช็อป diff --git a/core/assets/bundles/bundle_tk.properties b/core/assets/bundles/bundle_tk.properties index cb6fcc5c94..4420e03b7a 100644 --- a/core/assets/bundles/bundle_tk.properties +++ b/core/assets/bundles/bundle_tk.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sort by stars export.file = Export File import.file = Import File copy.clipboard = Copy to Clipboard -import.clipboard = Import from Clipboard +load.clipboard = Import from Clipboard workshop.browse = Browse Workshop workshop.share = Share on Workshop diff --git a/core/assets/bundles/bundle_tr.properties b/core/assets/bundles/bundle_tr.properties index e986df1f69..c72126d504 100644 --- a/core/assets/bundles/bundle_tr.properties +++ b/core/assets/bundles/bundle_tr.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Yıldız sayısına göre sırala export.file = Dışarı Aktar import.file = İçeri Aktar copy.clipboard = Panoya Kopyala -import.clipboard = Panodan Yapıştır +load.clipboard = Panodan Yapıştır workshop.browse = Browse Workshop workshop.share = Atölyede paylaş diff --git a/core/assets/bundles/bundle_uk_UA.properties b/core/assets/bundles/bundle_uk_UA.properties index b22fa4f40c..3fae1bd10f 100644 --- a/core/assets/bundles/bundle_uk_UA.properties +++ b/core/assets/bundles/bundle_uk_UA.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Сортувати за популярністю export.file = Експортувати файл import.file = Імпортувати файл copy.clipboard = Копіювати в буфер обміну -import.clipboard = Імпортувати з клавіатури +load.clipboard = Імпортувати з клавіатури workshop.browse = Browse Workshop workshop.share = Поширити в Майстерню diff --git a/core/assets/bundles/bundle_vi.properties b/core/assets/bundles/bundle_vi.properties index f3ce8b5909..f1d63327c6 100644 --- a/core/assets/bundles/bundle_vi.properties +++ b/core/assets/bundles/bundle_vi.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = Sắp xếp theo sao export.file = Xuất Tệp import.file = Nhập Tệp copy.clipboard = Sao chép vào Bộ nhớ tạm -import.clipboard = Nhập từ Bộ nhớ tạm +load.clipboard = Nhập từ Bộ nhớ tạm workshop.browse = Duyệt qua Workshop workshop.share = Chia sẻ lên Workshop diff --git a/core/assets/bundles/bundle_zh_CN.properties b/core/assets/bundles/bundle_zh_CN.properties index 701d40d5ba..de22d76bb4 100644 --- a/core/assets/bundles/bundle_zh_CN.properties +++ b/core/assets/bundles/bundle_zh_CN.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = 按星标数排序 export.file = 导出文件 import.file = 导入文件 copy.clipboard = 复制到剪贴板 -import.clipboard = 从剪贴板导入 +load.clipboard = 从剪贴板导入 workshop.browse = Browse Workshop workshop.share = 分享到创意工坊 diff --git a/core/assets/bundles/bundle_zh_TW.properties b/core/assets/bundles/bundle_zh_TW.properties index 05837c4da9..3b9fb9ed8b 100644 --- a/core/assets/bundles/bundle_zh_TW.properties +++ b/core/assets/bundles/bundle_zh_TW.properties @@ -61,7 +61,7 @@ mods.browser.sortstars = 以星數篩選 export.file = 匯出檔案 import.file = 匯入檔案 copy.clipboard = 複製到剪貼簿 -import.clipboard = 從剪貼簿匯入 +load.clipboard = 從剪貼簿匯入 workshop.browse = Browse Workshop workshop.share = 分享到工作坊 diff --git a/core/src/mindustry/core/Platform.java b/core/src/mindustry/core/Platform.java index cf86077496..6f5a2890bb 100644 --- a/core/src/mindustry/core/Platform.java +++ b/core/src/mindustry/core/Platform.java @@ -98,7 +98,7 @@ public interface Platform{ return uuid; } - /** Only used for iOS or android: open the share menu for a map or save. */ + /** Only used for iOS: open the share menu for a map or save. */ default void shareFile(Fi file){ } diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 4466590104..725de94b09 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -93,6 +93,11 @@ public class UI implements ApplicationListener, Loadable{ private final IntMap labels = new IntMap<>(); public UI(){ + Events.on(ResetEvent.class, e -> { + labels.clear(); + popups.clear(); + }); + Fonts.loadFonts(); } @@ -454,12 +459,14 @@ public class UI implements ApplicationListener, Loadable{ return; } - var label = labels.get(id, WorldLabel::create); // todo: pool? + var label = id == -1 ? WorldLabel.create() : labels.get(id, WorldLabel::create); // todo: pool? + label.id = Integer.MIN_VALUE; //arbitrary value that won't be synced to, it's fine if IDs conflict label.x = worldx; label.y = worldy; label.text = info; label.flags = (byte)flags; // flag | flag2 at call site turns it into an int so the flags param here has to be int or casting has to be done at every call site - label.duration = duration; + label.duration = duration == Float.MAX_VALUE ? -1 : duration; // prefer -1 to Float.MAX_VALUE so that the update() function isn't called every tick + if(id != -1 && label.duration >= 0 && label.expired == null) label.expired = () -> labels.remove(id); // only set once to prevent extra garbage for updated labels label.add(); } diff --git a/core/src/mindustry/editor/data/MapBundlesView.java b/core/src/mindustry/editor/data/MapBundlesView.java index cfbb68d9d8..aed721b27d 100644 --- a/core/src/mindustry/editor/data/MapBundlesView.java +++ b/core/src/mindustry/editor/data/MapBundlesView.java @@ -71,7 +71,7 @@ public class MapBundlesView implements AssetView{ TextButtonStyle style = Styles.flatt; t.defaults().size(280f, 60f).left(); t.row(); - t.button("@import.clipboard", Icon.copy, style, () -> { + t.button("@load.clipboard", Icon.copy, style, () -> { dialog.hide(); handler.get(Core.app.getClipboardText()); }).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null); diff --git a/core/src/mindustry/editor/data/MapContentView.java b/core/src/mindustry/editor/data/MapContentView.java index 224e8b4afb..798fe4eba8 100644 --- a/core/src/mindustry/editor/data/MapContentView.java +++ b/core/src/mindustry/editor/data/MapContentView.java @@ -116,7 +116,7 @@ public class MapContentView implements AssetView{ TextButtonStyle style = Styles.flatt; t.defaults().size(280f, 60f).left(); t.row(); - t.button("@import.clipboard", Icon.copy, style, () -> { + t.button("@load.clipboard", Icon.copy, style, () -> { dialog.hide(); handler.get(Core.app.getClipboardText()); }).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null); diff --git a/core/src/mindustry/editor/data/MapPatchesView.java b/core/src/mindustry/editor/data/MapPatchesView.java index 07761b311d..b814576370 100644 --- a/core/src/mindustry/editor/data/MapPatchesView.java +++ b/core/src/mindustry/editor/data/MapPatchesView.java @@ -104,7 +104,7 @@ public class MapPatchesView implements AssetView{ TextButtonStyle style = Styles.flatt; t.defaults().size(280f, 60f).left(); t.row(); - t.button("@import.clipboard", Icon.copy, style, () -> { + t.button("@load.clipboard", Icon.copy, style, () -> { dialog.hide(); handler.get(Core.app.getClipboardText()); }).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null); diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 8240ca8b76..a1c60506ec 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -1682,7 +1682,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, /** Update table alignment after configuring.*/ public void updateTableAlign(Table table){ Vec2 pos = Core.input.mouseScreen(x, y - block.size * tilesize / 2f - 1); - table.setPosition(pos.x, pos.y, Align.top); + table.setPosition(pos.x - Core.scene.marginLeft, pos.y - Core.scene.marginBottom, Align.top); } /** Returns whether a hand cursor should be shown over this block. */ diff --git a/core/src/mindustry/entities/comp/WorldLabelComp.java b/core/src/mindustry/entities/comp/WorldLabelComp.java index f0e9c09b4a..a57a93f928 100644 --- a/core/src/mindustry/entities/comp/WorldLabelComp.java +++ b/core/src/mindustry/entities/comp/WorldLabelComp.java @@ -32,20 +32,24 @@ public abstract class WorldLabelComp implements Posc, Drawc, Syncc{ public byte flags = flagBackground | flagOutline; /** If not null, this label gets set to the parent position with x, y used as offsets. */ public @Nullable Posc parent; - /** Duration in seconds. Ignored if zero or negative. */ - public transient float duration; + /** Duration in seconds. Ignored if negative */ + public transient float duration = -1; + public transient @Nullable Runnable expired; @Replace public float clipSize(){ if(parent != null) return Float.MAX_VALUE; - return text.length() * 10f * fontSize; + return text == null ? 0f : text.length() * 10f * fontSize; } @Override public void update(){ - if(duration > 0){ + if(duration >= 0){ duration -= Time.delta / 60f; - if(duration <= 0) hide(); + if(duration <= 0){ + hide(); + if(expired != null) expired.run(); + } } } @@ -60,6 +64,7 @@ public abstract class WorldLabelComp implements Posc, Drawc, Syncc{ } public static void drawAt(String text, float x, float y, float layer, int flags, float fontSize, int align, int lineAlign){ + if(text == null) return; Draw.z(layer); float z = Drawf.text(); diff --git a/core/src/mindustry/logic/LogicDialog.java b/core/src/mindustry/logic/LogicDialog.java index f88f166e4d..80d8f7e86e 100644 --- a/core/src/mindustry/logic/LogicDialog.java +++ b/core/src/mindustry/logic/LogicDialog.java @@ -135,7 +135,7 @@ public class LogicDialog extends BaseDialog{ Core.app.setClipboardText(canvas.save()); }).marginLeft(12f).row(); - t.button("@import.clipboard", Icon.download, style, () -> { + t.button("@load.clipboard", Icon.download, style, () -> { dialog.hide(); try{ canvas.load(Core.app.getClipboardText().replace("\r\n", "\n")); diff --git a/core/src/mindustry/mod/DataPatcher.java b/core/src/mindustry/mod/DataPatcher.java index e4775905d2..f4959335f0 100644 --- a/core/src/mindustry/mod/DataPatcher.java +++ b/core/src/mindustry/mod/DataPatcher.java @@ -44,7 +44,6 @@ public class DataPatcher{ private static DataPatcher currentDataPatcher; private static ContentParser parser = createParser(); - private boolean applied; private ContentLoader contentLoader; private ObjectSet usedpatches = new ObjectSet<>(); @@ -109,49 +108,6 @@ public class DataPatcher{ Attribute.map = oldAttributeMap; }); - //patches are read first. - for(var set : patches){ - set.warnings.clear(); - set.error = false; - - try{ - Object someValue = parser.getJson().fromJson(null, Jval.read(set.patch).toString(Jformat.plain)); - if(!(someValue instanceof JsonValue value)) throw new SerializationException("Patch must be a JSON object."); - - if(Vars.state.rules.planet != null && value.has("requiredPlanets")){ - JsonValue req = value.get("requiredPlanets"); - value.remove("requiredPlanets"); - - //this should be ignored unless this instance is a dedicated server - if(Vars.headless){ - String[] planets = req.isArray() ? req.asStringArray() : new String[]{req.asString()}; - if(!Structs.contains(planets, Vars.state.rules.planet.name)){ - continue; - } - } - } - - set.json = value; - currentlyApplyingPatch = set; - visitStack.clear(); - - set.name = value.getString("name", ""); - value.remove("name"); //patchsets can have a name, ignore it if present - for(var child : value){ - assign(root, child.name, child, null, null, null); - } - currentlyApplyingPatch = null; - - }catch(Exception e){ - set.error = true; - set.name = ""; - set.warnings.add(Strings.getSimpleMessage(e)); - currentlyApplyingPatch = null; - - Log.err("Failed to apply patch: " + set.patch, e); - } - } - if(!content.isEmpty()){ content.sort(); @@ -262,6 +218,48 @@ public class DataPatcher{ if(reloadContentWorld) fixContentArrays(); } + for(var set : patches){ + set.warnings.clear(); + set.error = false; + + try{ + Object someValue = parser.getJson().fromJson(null, Jval.read(set.patch).toString(Jformat.plain)); + if(!(someValue instanceof JsonValue value)) throw new SerializationException("Patch must be a JSON object."); + + if(Vars.state.rules.planet != null && value.has("requiredPlanets")){ + JsonValue req = value.get("requiredPlanets"); + value.remove("requiredPlanets"); + + //this should be ignored unless this instance is a dedicated server + if(Vars.headless){ + String[] planets = req.isArray() ? req.asStringArray() : new String[]{req.asString()}; + if(!Structs.contains(planets, Vars.state.rules.planet.name)){ + continue; + } + } + } + + set.json = value; + currentlyApplyingPatch = set; + visitStack.clear(); + + set.name = value.getString("name", ""); + value.remove("name"); //patchsets can have a name, ignore it if present + for(var child : value){ + assign(root, child.name, child, null, null, null); + } + currentlyApplyingPatch = null; + + }catch(Exception e){ + set.error = true; + set.name = ""; + set.warnings.add(Strings.getSimpleMessage(e)); + currentlyApplyingPatch = null; + + Log.err("Failed to apply patch: " + set.patch, e); + } + } + afterCallbacks.each(Runnable::run); } @@ -603,6 +601,7 @@ public class DataPatcher{ Seq prevBuilder = Reflect.>get(Block.class, bl, "consumeBuilder").copy(); boolean hadItems = bl.hasItems, hadLiquids = bl.hasLiquids, hadPower = bl.hasPower, acceptedItems = bl.acceptsItems; Runnable resetCons = () -> { + if(bl.isPatchContent()) return; //useless Reflect.set(Block.class, bl, "consumeBuilder", prevBuilder); bl.reinitializeConsumers(); bl.hasItems = hadItems; diff --git a/core/src/mindustry/ui/dialogs/SchematicsDialog.java b/core/src/mindustry/ui/dialogs/SchematicsDialog.java index 11c6ade3ec..5254128993 100644 --- a/core/src/mindustry/ui/dialogs/SchematicsDialog.java +++ b/core/src/mindustry/ui/dialogs/SchematicsDialog.java @@ -231,7 +231,7 @@ public class SchematicsDialog extends BaseDialog{ TextButtonStyle style = Styles.flatt; t.defaults().size(280f, 60f).left(); t.row(); - t.button("@import.clipboard", Icon.copy, style, () -> { + t.button("@load.clipboard", Icon.copy, style, () -> { dialog.hide(); try{ Schematic s = Schematics.readBase64(Core.app.getClipboardText()); diff --git a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java index ae932d60fa..f48a46d63d 100644 --- a/core/src/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/mindustry/ui/fragments/BlockInventoryFragment.java @@ -233,7 +233,7 @@ public class BlockInventoryFragment{ private void updateTablePosition(){ Vec2 v = Core.input.mouseScreen(build.x + build.block.size * tilesize / 2f, build.y + build.block.size * tilesize / 2f); table.pack(); - table.setPosition(v.x, v.y, Align.topLeft); + table.setPosition(v.x - Core.scene.marginLeft, v.y - Core.scene.marginBottom, Align.topLeft); } private Element itemImage(TextureRegion region, Prov text){ diff --git a/core/src/mindustry/world/blocks/distribution/DirectionalUnloader.java b/core/src/mindustry/world/blocks/distribution/DirectionalUnloader.java index d32cfdd4c2..6f944e4855 100644 --- a/core/src/mindustry/world/blocks/distribution/DirectionalUnloader.java +++ b/core/src/mindustry/world/blocks/distribution/DirectionalUnloader.java @@ -45,8 +45,14 @@ public class DirectionalUnloader extends Block{ drawCached = true; drawDynamic = false; - config(Item.class, (DirectionalUnloaderBuild tile, Item item) -> tile.unloadItem = item); - configClear((DirectionalUnloaderBuild tile) -> tile.unloadItem = null); + config(Item.class, (DirectionalUnloaderBuild tile, Item item) -> { + tile.unloadItem = item; + tile.recache(); + }); + configClear((DirectionalUnloaderBuild tile) -> { + tile.unloadItem = null; + tile.recache(); + }); } @Override diff --git a/core/src/mindustry/world/blocks/logic/LogicBlock.java b/core/src/mindustry/world/blocks/logic/LogicBlock.java index 52445f8034..70d536200e 100644 --- a/core/src/mindustry/world/blocks/logic/LogicBlock.java +++ b/core/src/mindustry/world/blocks/logic/LogicBlock.java @@ -620,6 +620,7 @@ public class LogicBlock extends Block{ } private @Nullable Building optionalLink(String name){ + if(name == null || name.isEmpty()) return null; // Quick check the name can even be a link to avoid building/using the map needlessly char ch = name.charAt(name.length() - 1); if(ch < '0' || ch > '9') return null;