Merging changes from private branch

This commit is contained in:
Anuken
2025-04-04 11:47:35 -04:00
parent cf5c6d0905
commit b7dbe54d76
161 changed files with 2484 additions and 1137 deletions

View File

@@ -105,11 +105,38 @@ public class Fonts{
});
}
public static void loadContentIcons(){
Seq<Font> fonts = Seq.with(Fonts.def, Fonts.outline);
Texture uitex = Core.atlas.find("logo").texture;
public static void registerIcon(String name, String regionName, int ch, TextureRegion region){
int size = (int)(Fonts.def.getData().lineHeight/Fonts.def.getData().scaleY);
unicodeIcons.put(name, ch);
stringIcons.put(name, ((char)ch) + "");
unicodeToName.put(ch, regionName);
Vec2 out = Scaling.fit.apply(region.width, region.height, size, size);
Glyph glyph = new Glyph();
glyph.id = ch;
glyph.srcX = 0;
glyph.srcY = 0;
glyph.width = (int)out.x;
glyph.height = (int)out.y;
glyph.u = region.u;
glyph.v = region.v2;
glyph.u2 = region.u2;
glyph.v2 = region.v;
glyph.xoffset = 0;
glyph.yoffset = -size;
glyph.xadvance = size;
glyph.kerning = null;
glyph.fixedWidth = true;
glyph.page = 0;
Fonts.def.getData().setGlyph(ch, glyph);
Fonts.outline.getData().setGlyph(ch, glyph);
}
public static void loadContentIcons(){
Texture uitex = Core.atlas.find("logo").texture;
try(var reader = Core.files.internal("icons/icons.properties").reader(Vars.bufferSize)){
String line;
while((line = reader.readLine()) != null){
@@ -123,29 +150,7 @@ public class Fonts{
continue;
}
unicodeIcons.put(nametex[0], ch);
stringIcons.put(nametex[0], ((char)ch) + "");
unicodeToName.put(ch, texture);
Vec2 out = Scaling.fit.apply(region.width, region.height, size, size);
Glyph glyph = new Glyph();
glyph.id = ch;
glyph.srcX = 0;
glyph.srcY = 0;
glyph.width = (int)out.x;
glyph.height = (int)out.y;
glyph.u = region.u;
glyph.v = region.v2;
glyph.u2 = region.u2;
glyph.v2 = region.v;
glyph.xoffset = 0;
glyph.yoffset = -size;
glyph.xadvance = size;
glyph.kerning = null;
glyph.fixedWidth = true;
glyph.page = 0;
fonts.each(f -> f.getData().setGlyph(ch, glyph));
registerIcon(nametex[0], texture, ch, region);
}
}catch(IOException e){
throw new RuntimeException(e);
@@ -153,11 +158,30 @@ public class Fonts{
stringIcons.put("alphachan", stringIcons.get("alphaaaa"));
//TODO: mod emojis can't work because most mod icons are not on the UI page!
/*
if(Vars.mods.list().contains(m -> m.shouldBeEnabled())){
ContentType[] types = {ContentType.liquid, ContentType.item, ContentType.block, ContentType.status, ContentType.unit};
int startChar = 0xE000 + 1;
for(var type : types){
for(var cont : Vars.content.getBy(type)){
if(!cont.isVanilla() && cont instanceof UnlockableContent u && u.uiIcon.found()){
int id = startChar;
registerIcon(u.name, u.uiIcon instanceof AtlasRegion atlas ? atlas.name : u.name, id, u.uiIcon);
startChar ++;
}
}
}
}*/
for(Team team : Team.baseTeams){
team.emoji = stringIcons.get(team.name, "");
}
}
public static void loadContentIconsHeadless(){
try(var reader = Core.files.internal("icons/icons.properties").reader(Vars.bufferSize)){
String line;

View File

@@ -56,7 +56,7 @@ public class Minimap extends Table{
if(renderer.minimap.getTexture() != null){
Draw.alpha(parentAlpha);
renderer.minimap.drawEntities(x, y, width, height, 0.75f, false);
renderer.minimap.drawEntities(x, y, width, height, false);
}
clipEnd();

View File

@@ -119,7 +119,7 @@ public class DatabaseDialog extends BaseDialog{
for(int i = 0; i < array.size; i++){
UnlockableContent unlock = array.get(i);
Image image = unlocked(unlock) ? new Image(unlock.uiIcon).setScaling(Scaling.fit) : new Image(Icon.lock, Pal.gray);
Image image = unlocked(unlock) ? new Image(new TextureRegionDrawable(unlock.uiIcon), mobile ? Color.white : Color.lightGray).setScaling(Scaling.fit) : new Image(Icon.lock, Pal.gray);
//banned cross
if(state.isGame() && (unlock instanceof UnitType u && u.isBanned() || unlock instanceof Block b && state.rules.isBanned(b))){

View File

@@ -365,7 +365,7 @@ public class ModsDialog extends BaseDialog{
private @Nullable String getStateDetails(LoadedMod item){
if(item.isOutdated()){
return "@mod.outdatedv7.details";
return Core.bundle.format("mod.outdated.details", item.isJava() ? minJavaModGameVersion : minModGameVersion);
}else if(item.isBlacklisted()){
return "@mod.blacklisted.details";
}else if(!item.isSupported()){

View File

@@ -179,6 +179,7 @@ public class ConsoleFragment extends Table{
public String injectConsoleVariables(){
return
"var unit = Vars.player.unit();" +
"var player = Vars.player;" +
"var team = Vars.player.team();" +
"var core = Vars.player.core();" +
"var items = Vars.player.team().items();" +

View File

@@ -687,44 +687,6 @@ public class HudFragment{
}
}
/** @deprecated see {@link CoreBuild#beginLaunch(CoreBlock)} */
@Deprecated
public void showLaunch(){
float margin = 30f;
Image image = new Image();
image.color.a = 0f;
image.touchable = Touchable.disabled;
image.setFillParent(true);
image.actions(Actions.delay((coreLandDuration - margin) / 60f), Actions.fadeIn(margin / 60f, Interp.pow2In), Actions.delay(6f / 60f), Actions.remove());
image.update(() -> {
image.toFront();
ui.loadfrag.toFront();
if(state.isMenu()){
image.remove();
}
});
Core.scene.add(image);
}
/** @deprecated see {@link CoreBuild#beginLaunch(CoreBlock)} */
@Deprecated
public void showLand(){
Image image = new Image();
image.color.a = 1f;
image.touchable = Touchable.disabled;
image.setFillParent(true);
image.actions(Actions.fadeOut(35f / 60f), Actions.remove());
image.update(() -> {
image.toFront();
ui.loadfrag.toFront();
if(state.isMenu()){
image.remove();
}
});
Core.scene.add(image);
}
private void toggleMenus(){
if(flip != null){
flip.getStyle().imageUp = shown ? Icon.downOpen : Icon.upOpen;

View File

@@ -48,7 +48,7 @@ public class MinimapFragment{
Draw.rect(reg, w/2f + panx*zoom, h/2f + pany*zoom, size, size * ratio);
Rect bounds = getRectBounds();
renderer.minimap.drawEntities(bounds.x, bounds.y, bounds.width, bounds.height, zoom, true);
renderer.minimap.drawEntities(bounds.x, bounds.y, bounds.width, bounds.height, true);
}
Draw.reset();

View File

@@ -332,7 +332,7 @@ public class PlacementFragment{
};
//top table with hover info
frame.table(Tex.buttonEdge2,top -> {
frame.table(Tex.buttonEdge2, top -> {
topTable = top;
top.add(new Table()).growX().update(topTable -> {