Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ setting.meld-unit-light-scale = Unit light radius multiplier
setting.meld-highvis-overlay = High-vis block overlay\n(Turret ranges and etc... over Fow/Lighting)
setting.meld-bulbhead-omnimove = Bulbhead Omnimovement\n(Move like a non-naval)
setting.meld-port-saves = Port Saves\n[red]HIGHLY EXPERIMENTAL\nallows you to load a meld hjson map in meld java[]

setting.meld-shitpost-bundles = Shitpost Bundles


unit.ticks = ticks
Expand Down
1 change: 1 addition & 0 deletions src/meld/SettingKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static String pref(String in){
connectedSonar = pref("connected-sonar"),
unitLightScale = pref("unit-light-scale"),
overlayOverFog = pref("highvis-overlay"),
shitpostBundles = pref("shitpost-bundles"),

//Expirimental- doesn't sync in multiplayer and off by default
bulbheadOmnimove = pref("bulbhead-omnimove"),
Expand Down
81 changes: 60 additions & 21 deletions src/meld/core/Bundles.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,82 @@

import java.util.*;
import arc.*;
import arc.files.*;
import arc.struct.*;
import arc.util.*;
import arc.util.io.*;
import meld.*;
import mindustry.*;
import mindustry.ui.dialogs.*;
import mindustry.ctype.*;
import mindustry.mod.*;

import static arc.Core.*;

// very hacky dont do this
// still very hacky, dont do this
public final class Bundles{
private static final Locale locale = new Locale("shitpost");
private static final Locale shitpostLocale = new Locale("shitpost");

private Bundles(){}

public static void load(){
setupLocale();
loadBundle();
var enabled = Core.settings.getBool(SettingKeys.shitpostBundles, false);
shitpost(enabled);
}

private static void setupLocale(){
Vars.locales = new Seq<>(Vars.locales).add(locale).toArray();
LanguageDialog.displayNames.put(locale.toString(), "Meld Shitpost");
public static void shitpost(boolean enable){
// since when is this valid syntax????
if(enable) enable(); else disable();

reloadModBundles();
reloadContentFields();
}

private static void loadBundle(){
if(!settings.getString("locale").equals(locale.toString())) return;
Log.info("loading meld shitpost bundle");
private static void enable(){
if(isShitpost()) return;

var modRoot = Vars.mods.getMod(Meld.name).root;
var bundleFile = modRoot.child("bundles").child("bundle_" + locale + ".properties");
if(!bundleFile.exists()){
Log.warn("couldn't find shitpost bundle");
return;
}
var bundle = I18NBundle.createEmptyBundle();
Reflect.set(bundle, "locale", shitpostLocale);
Reflect.set(bundle, "parent", Core.bundle);
Reflect.set(bundle, "formatter", new TextFormatter(shitpostLocale, !I18NBundle.getSimpleFormatter()));
Core.bundle = bundle;
}

private static void disable(){
if(!isShitpost()) return;

Reflect.set(bundle, "locale", locale);
PropertiesUtils.load(bundle.getProperties(), bundleFile.reader());
Core.bundle = Reflect.get(Core.bundle, "parent");
}

private static void reloadModBundles(){
var bundles = Reflect.<ObjectMap<String, Seq<Fi>>>get(Vars.mods, "bundles");

/// 1:1 copied from {@link Mods#buildFiles()}
I18NBundle bundle = Core.bundle;
while(bundle != null){
String str = bundle.getLocale().toString();
String locale = "bundle" + (str.isEmpty() ? "" : "_" + str);
for(Fi file : bundles.get(locale, Seq::new)){
try{
PropertiesUtils.load(bundle.getProperties(), file.reader());
}catch(Throwable e){
Log.err("Error loading bundle: " + file + "/" + locale, e);
}
}
bundle = bundle.getParent();
}
}

/// 1:1 copied from {@link UnlockableContent#UnlockableContent(String)}
private static void reloadContentFields(){
Vars.content.each(it -> {
if(it instanceof UnlockableContent uc){
uc.localizedName = Core.bundle.get(uc.getContentType() + "." + uc.name + ".name", uc.name);
uc.description = Core.bundle.getOrNull(uc.getContentType() + "." + uc.name + ".description");
uc.details = Core.bundle.getOrNull(uc.getContentType() + "." + uc.name + ".details");
uc.credit = Core.bundle.getOrNull(uc.getContentType() + "." + uc.name + ".credit");
}
});
}

private static boolean isShitpost(){
return Core.bundle.getLocale() == shitpostLocale;
}
}
9 changes: 8 additions & 1 deletion src/meld/ui/MeldSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import meld.Meld;
import meld.SettingKeys;
import meld.content.MeldUnits;
import meld.core.*;
import mindustry.Vars;
import mindustry.content.Blocks;
import mindustry.ctype.UnlockableContent;
import mindustry.io.SaveFileReader;
import mindustry.ui.dialogs.SettingsMenuDialog;

public class MeldSettings {
public static boolean replaceLighting, invertAmbient, connectedSonar, overlayOverFog,
public static boolean replaceLighting, invertAmbient, connectedSonar, overlayOverFog, shitpostBundles,

//The expirimental settings
bulbheadOmnimove, portSaves;
Expand All @@ -33,6 +34,7 @@ public static void loadSettings(){
invertAmbient = Core.settings.getBool(SettingKeys.invertAmbient, false);
connectedSonar = Core.settings.getBool(SettingKeys.connectedSonar, true);
overlayOverFog = Core.settings.getBool(SettingKeys.overlayOverFog, true);
shitpostBundles = Core.settings.getBool(SettingKeys.shitpostBundles, false);

float newLightScale = Core.settings.getInt(SettingKeys.unitLightScale, 100);
MeldUnits.lightRadiusMultiplier(newLightScale);
Expand Down Expand Up @@ -62,6 +64,11 @@ public static void loadSettings(){
check(t, SettingKeys.invertAmbient, false, b -> invertAmbient = b);
check(t, SettingKeys.connectedSonar, true, b -> connectedSonar = b);
check(t, SettingKeys.overlayOverFog, true, b -> overlayOverFog = b);
check(t, SettingKeys.shitpostBundles, false, b -> {
Vars.ui.loadAnd(() -> {
Bundles.shitpost(shitpostBundles = b);
});
});

t.sliderPref(Core.bundle.get(SettingKeys.unitLightScale), 100, 1, 200, f -> {
MeldUnits.lightRadiusMultiplier(f);
Expand Down
Loading