mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-03-03 22:21:53 +07:00
Added spell details label
Added spell details label Created static ref to font16 modal background Added constructor to Label that takes in a Color too
This commit is contained in:
parent
5e258077cb
commit
2e77266cd0
@ -6,6 +6,13 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.riiablo.Riiablo;
|
||||
|
||||
public class PaletteIndexedColorDrawable extends TextureRegionDrawable {
|
||||
public static final PaletteIndexedColorDrawable MODAL_FONT16 = new PaletteIndexedColorDrawable(Riiablo.colors.modal75) {{
|
||||
final float PADDING = 6;
|
||||
setLeftWidth(PADDING);
|
||||
setTopHeight(PADDING - 2); // font16 has extra top padding, changing this would require propagating elsewhere
|
||||
setRightWidth(PADDING);
|
||||
setBottomHeight(PADDING);
|
||||
}};
|
||||
|
||||
public Color tint;
|
||||
|
||||
|
@ -642,22 +642,13 @@ public class Item extends Actor implements Disposable {
|
||||
|
||||
public class Details extends Table {
|
||||
private static final float SPACING = 2;
|
||||
private static final float PADDING = 6;
|
||||
|
||||
Label name;
|
||||
Label type;
|
||||
Label usable;
|
||||
|
||||
Details() {
|
||||
// TODO: Change this to a static object ref
|
||||
setBackground(new PaletteIndexedColorDrawable(Riiablo.colors.modal75) {{
|
||||
setLeftWidth(PADDING);
|
||||
setTopHeight(PADDING - 2); // font16 has extra top padding, changing this would require propagating elsewhere
|
||||
setRightWidth(PADDING);
|
||||
setBottomHeight(PADDING);
|
||||
}});
|
||||
//pad(PADDING);
|
||||
|
||||
setBackground(PaletteIndexedColorDrawable.MODAL_FONT16);
|
||||
BitmapFont font = Riiablo.fonts.font16;
|
||||
name = new Label(Item.this.getName(), font);
|
||||
type = new Label(Riiablo.string.lookup(base.namestr), font);
|
||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
@ -16,12 +17,17 @@ import com.riiablo.codec.DC;
|
||||
import com.riiablo.codec.DC6;
|
||||
import com.riiablo.codec.excel.SkillDesc;
|
||||
import com.riiablo.codec.excel.Skills;
|
||||
import com.riiablo.graphics.PaletteIndexedBatch;
|
||||
import com.riiablo.graphics.PaletteIndexedColorDrawable;
|
||||
import com.riiablo.loader.DC6Loader;
|
||||
import com.riiablo.screen.GameScreen;
|
||||
import com.riiablo.widget.Button;
|
||||
import com.riiablo.widget.Label;
|
||||
import com.riiablo.widget.LabelButton;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class SpellsPanel extends WidgetGroup implements Disposable {
|
||||
private static final String TAG = "SpellsPanel";
|
||||
private static final String SPELLS_PATH = "data\\global\\ui\\SPELLS\\";
|
||||
@ -126,17 +132,40 @@ public class SpellsPanel extends WidgetGroup implements Disposable {
|
||||
Label skillsRemaining = new Label("0", Riiablo.fonts.font16);
|
||||
skillsRemaining.setAlignment(Align.center);
|
||||
skillsRemaining.setSize(40, 21);
|
||||
skillsRemaining.setPosition(256, 348);
|
||||
skillsRemaining.setPosition(256, 348); // 276, 359 middle
|
||||
addActor(skillsRemaining);
|
||||
|
||||
float[] X = { 0, 15, 84, 153 };
|
||||
float[] Y = { 0, 370, 302, 234, 166, 98, 30 };
|
||||
for (int i = charClass.firstSpell; i < charClass.lastSpell; i++) {
|
||||
Skills.Entry skill = Riiablo.files.skills.get(i);
|
||||
SkillDesc.Entry desc = Riiablo.files.skilldesc.get(skill.skilldesc);
|
||||
final SkillDesc.Entry desc = Riiablo.files.skilldesc.get(skill.skilldesc);
|
||||
final Table details = new Table() {{
|
||||
final float SPACING = 2;
|
||||
setBackground(PaletteIndexedColorDrawable.MODAL_FONT16);
|
||||
add(new Label(Riiablo.string.lookup(desc.str_name), Riiablo.fonts.font16, Riiablo.colors.green)).center().space(SPACING).row();
|
||||
add(new Label(Riiablo.fonts.font16) {{
|
||||
// TODO: It might possible to optimize this more -- goal is to reverse lines since they are backwards for some reason
|
||||
String text = Riiablo.string.lookup(desc.str_long);
|
||||
String[] lines = StringUtils.split(text, '\n');
|
||||
ArrayUtils.reverse(lines);
|
||||
text = StringUtils.join(lines, '\n');
|
||||
setText(text);
|
||||
setAlignment(Align.center);
|
||||
}}).center().space(SPACING).row();
|
||||
pack();
|
||||
}};
|
||||
Button button = new Button(new Button.ButtonStyle(
|
||||
new TextureRegionDrawable(Skillicon.getTexture(desc.IconCel)),
|
||||
new TextureRegionDrawable(Skillicon.getTexture(desc.IconCel + 1))));
|
||||
new TextureRegionDrawable(Skillicon.getTexture(desc.IconCel + 1)))) {
|
||||
@Override
|
||||
public void draw(PaletteIndexedBatch batch, float parentAlpha) {
|
||||
super.draw(batch, parentAlpha);
|
||||
if (isOver()) {
|
||||
gameScreen.setDetails(details, null, SpellsPanel.this, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
button.setPosition(X[desc.SkillColumn], Y[desc.SkillRow]);
|
||||
//button.setSize(48, 48);
|
||||
|
||||
|
@ -33,6 +33,11 @@ public class Label extends com.badlogic.gdx.scenes.scene2d.ui.Label {
|
||||
super(text, new LabelStyle(font, null));
|
||||
}
|
||||
|
||||
public Label(String text, BitmapFont font, Color color) {
|
||||
this(text, font);
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
public Label(BitmapFont font) {
|
||||
this(null, font);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user