mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-22 12:38:12 +07:00
Implemented default skills set by save file
This commit is contained in:
parent
72164128c8
commit
4624f6c3d3
@ -17,12 +17,21 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
import com.riiablo.CharacterClass;
|
||||||
|
import com.riiablo.Keys;
|
||||||
import com.riiablo.Riiablo;
|
import com.riiablo.Riiablo;
|
||||||
|
import com.riiablo.codec.DC;
|
||||||
import com.riiablo.codec.DC6;
|
import com.riiablo.codec.DC6;
|
||||||
|
import com.riiablo.codec.excel.SkillDesc;
|
||||||
|
import com.riiablo.codec.excel.Skills;
|
||||||
|
import com.riiablo.key.MappedKey;
|
||||||
|
import com.riiablo.loader.DC6Loader;
|
||||||
import com.riiablo.screen.GameScreen;
|
import com.riiablo.screen.GameScreen;
|
||||||
import com.riiablo.widget.Button;
|
import com.riiablo.widget.Button;
|
||||||
import com.riiablo.widget.HotkeyButton;
|
import com.riiablo.widget.HotkeyButton;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
public class ControlPanel extends Table implements Disposable {
|
public class ControlPanel extends Table implements Disposable {
|
||||||
private static final String TAG = "ControlPanel";
|
private static final String TAG = "ControlPanel";
|
||||||
private static final boolean DEBUG_MOBILE = !true;
|
private static final boolean DEBUG_MOBILE = !true;
|
||||||
@ -40,6 +49,28 @@ public class ControlPanel extends Table implements Disposable {
|
|||||||
|
|
||||||
final AssetDescriptor<DC6> SkilliconDescriptor = new AssetDescriptor<>("data\\global\\ui\\SPELLS\\Skillicon.DC6", DC6.class);
|
final AssetDescriptor<DC6> SkilliconDescriptor = new AssetDescriptor<>("data\\global\\ui\\SPELLS\\Skillicon.DC6", DC6.class);
|
||||||
DC6 Skillicon;
|
DC6 Skillicon;
|
||||||
|
|
||||||
|
final AssetDescriptor<DC6> CharSkilliconDescriptor[];
|
||||||
|
DC6 CharSkillicon[];
|
||||||
|
|
||||||
|
private static int getClassId(String charClass) {
|
||||||
|
switch (charClass.charAt(0)) {
|
||||||
|
case 'a': return charClass.charAt(1) == 'm' ? CharacterClass.AMAZON.id : CharacterClass.ASSASSIN.id;
|
||||||
|
case 'b': return CharacterClass.BARBARIAN.id;
|
||||||
|
case 'd': return CharacterClass.DRUID.id;
|
||||||
|
case 'n': return CharacterClass.NECROMANCER.id;
|
||||||
|
case 'p': return CharacterClass.PALADIN.id;
|
||||||
|
case 's': return CharacterClass.SORCERESS.id;
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DC getSkillicon(String charClass, int i) {
|
||||||
|
int classId = getClassId(charClass);
|
||||||
|
DC icons = classId == -1 ? Skillicon : CharSkillicon[classId];
|
||||||
|
return i < icons.getNumPages() ? icons : null;
|
||||||
|
}
|
||||||
|
|
||||||
HotkeyButton leftSkill, rightSkill;
|
HotkeyButton leftSkill, rightSkill;
|
||||||
|
|
||||||
GameScreen gameScreen;
|
GameScreen gameScreen;
|
||||||
@ -62,12 +93,40 @@ public class ControlPanel extends Table implements Disposable {
|
|||||||
Riiablo.assets.finishLoadingAsset(SkilliconDescriptor);
|
Riiablo.assets.finishLoadingAsset(SkilliconDescriptor);
|
||||||
Skillicon = Riiablo.assets.get(SkilliconDescriptor);
|
Skillicon = Riiablo.assets.get(SkilliconDescriptor);
|
||||||
|
|
||||||
|
CharSkilliconDescriptor = new AssetDescriptor[7];
|
||||||
|
CharSkillicon = new DC6[CharSkilliconDescriptor.length];
|
||||||
|
for (int i = 0; i < CharSkilliconDescriptor.length; i++) {
|
||||||
|
CharSkilliconDescriptor[i] = new AssetDescriptor<>("data\\global\\ui\\SPELLS\\" + CharacterClass.get(i).spellIcons + ".DC6", DC6.class, DC6Loader.DC6Parameters.COMBINE);
|
||||||
|
Riiablo.assets.load(CharSkilliconDescriptor[i]);
|
||||||
|
Riiablo.assets.finishLoadingAsset(CharSkilliconDescriptor[i]);
|
||||||
|
CharSkillicon[i] = Riiablo.assets.get(CharSkilliconDescriptor[i]);
|
||||||
|
}
|
||||||
|
|
||||||
final int numFrames = ctrlpnl.getNumFramesPerDir();
|
final int numFrames = ctrlpnl.getNumFramesPerDir();
|
||||||
healthWidget = new HealthWidget(ctrlpnl.getTexture(0));
|
healthWidget = new HealthWidget(ctrlpnl.getTexture(0));
|
||||||
manaWidget = new ManaWidget(ctrlpnl.getTexture(numFrames - 2));
|
manaWidget = new ManaWidget(ctrlpnl.getTexture(numFrames - 2));
|
||||||
|
|
||||||
if (!DEBUG_MOBILE && Gdx.app.getType() == Application.ApplicationType.Desktop) {
|
if (!DEBUG_MOBILE && Gdx.app.getType() == Application.ApplicationType.Desktop) {
|
||||||
leftSkill = new HotkeyButton(Skillicon, 0, -1);
|
int leftSkillId = gameScreen.player.actions[0][0];
|
||||||
|
if (leftSkillId > 0) {
|
||||||
|
final Skills.Entry skill = Riiablo.files.skills.get(leftSkillId);
|
||||||
|
final SkillDesc.Entry desc = Riiablo.files.skilldesc.get(skill.skilldesc);
|
||||||
|
int iconCel = desc.IconCel;
|
||||||
|
DC icons = getSkillicon(skill.charclass, iconCel);
|
||||||
|
if (icons == null) {
|
||||||
|
icons = Skillicon;
|
||||||
|
iconCel = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
leftSkill = new HotkeyButton(icons, iconCel, skill.Id);
|
||||||
|
int index = ArrayUtils.indexOf(gameScreen.player.skillBar, leftSkillId);
|
||||||
|
if (index != ArrayUtils.INDEX_NOT_FOUND) {
|
||||||
|
MappedKey mapping = Keys.Skill[index];
|
||||||
|
leftSkill.map(mapping);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
leftSkill = new HotkeyButton(Skillicon, 0, -1);
|
||||||
|
}
|
||||||
leftSkill.addListener(new ClickListener() {
|
leftSkill.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
@ -75,12 +134,26 @@ public class ControlPanel extends Table implements Disposable {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int leftSkillId = gameScreen.player.actions[0][0];
|
int rightSkillId = gameScreen.player.actions[0][1];
|
||||||
if (leftSkillId > 0) {
|
if (rightSkillId > 0) {
|
||||||
|
final Skills.Entry skill = Riiablo.files.skills.get(rightSkillId);
|
||||||
|
final SkillDesc.Entry desc = Riiablo.files.skilldesc.get(skill.skilldesc);
|
||||||
|
int iconCel = desc.IconCel;
|
||||||
|
DC icons = getSkillicon(skill.charclass, iconCel);
|
||||||
|
if (icons == null) {
|
||||||
|
icons = Skillicon;
|
||||||
|
iconCel = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
rightSkill = new HotkeyButton(icons, iconCel, skill.Id);
|
||||||
|
int index = ArrayUtils.indexOf(gameScreen.player.skillBar, rightSkillId);
|
||||||
|
if (index != ArrayUtils.INDEX_NOT_FOUND) {
|
||||||
|
MappedKey mapping = Keys.Skill[index];
|
||||||
|
rightSkill.map(mapping);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rightSkill = new HotkeyButton(Skillicon, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rightSkill = new HotkeyButton(Skillicon, 0, -1);
|
|
||||||
rightSkill.addListener(new ClickListener() {
|
rightSkill.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
@ -88,11 +161,6 @@ public class ControlPanel extends Table implements Disposable {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int rightSkillId = gameScreen.player.actions[0][1];
|
|
||||||
if (rightSkillId > 0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = Integer.MIN_VALUE;
|
int height = Integer.MIN_VALUE;
|
||||||
for (int i = 1; i < numFrames - 2; i++) {
|
for (int i = 1; i < numFrames - 2; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user