Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team Color refactor for modding #10302

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
35 changes: 21 additions & 14 deletions core/src/mindustry/game/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class Team implements Comparable<Team>{
public final int id;
public final Color color;
public final Color[] palette;
public final Color[] palette = new Color[3];;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public final Color[] palette = new Color[3];;
public final Color[] palette = {new Color(), new Color(), new Color()};

public final int[] palettei = new int[3];
public String emoji = "";
public boolean hasPalette;
Expand Down Expand Up @@ -63,27 +63,18 @@ protected Team(int id, String name, Color color){
if(id < 6) baseTeams[id] = this;
all[id] = this;

palette = new Color[3];
palette[0] = color;
palette[0] = color.cpy();
palette[1] = color.cpy().mul(0.75f);
palette[2] = color.cpy().mul(0.5f);
CliffracerX marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +66 to 68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
palette[0] = color.cpy();
palette[1] = color.cpy().mul(0.75f);
palette[2] = color.cpy().mul(0.5f);


for(int i = 0; i < 3; i++){
palettei[i] = palette[i].rgba();
}

setPalette(color);
}

/** Specifies a 3-color team palette. */
protected Team(int id, String name, Color color, Color pal1, Color pal2, Color pal3){
this(id, name, color);

palette[0] = pal1;
palette[1] = pal2;
palette[2] = pal3;
for(int i = 0; i < 3; i++){
palettei[i] = palette[i].rgba();
}
hasPalette = true;
setPalette(pal1, pal2, pal3);
}

/** @return the core items for this team, or an empty item module.
Expand Down Expand Up @@ -142,6 +133,22 @@ public String localized(){
public String coloredName(){
return emoji + "[#" + color + "]" + localized() + "[]";
}

public void setPalette(Color color){
setPalette(color, color.cpy().mul(0.75f), color.cpy().mul(0.5f));
hasPalette = false;
}

public void setPalette(Color pal1, Color pal2, Color pal3){
color.set(pal1);
palette[0].set(pal1);
palette[1].set(pal2);
palette[2].set(pal3);
for(int i = 0; i < 3; i++){
palettei[i] = palette[i].rgba();
}
hasPalette = true;
}

@Override
public int compareTo(Team team){
Expand Down
3 changes: 1 addition & 2 deletions core/src/mindustry/mod/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ private void packSprites(Seq<Fi> sprites, LoadedMod mod, boolean prefix, Seq<Fut
regionName = baseName.contains(".") ? baseName.substring(0, baseName.indexOf(".")) : baseName;

if(!prefix && !Core.atlas.has(regionName)){
Log.warn("Sprite '@' in mod '@' attempts to override a non-existent sprite. Ignoring.", regionName, mod.name);
continue;
Log.warn("Sprite '@' in mod '@' attempts to override a non-existent sprite.", regionName, mod.name);

//(horrible code below)
}
Expand Down
Loading