Fixed single player character animations

Fixed issue with single player player entity creation by blocking some packets
Fixed issue with character colormap transforms not working as intended for 0x7
Small fix for in-game chat box printing enters -- need to block key commands while typing
Added padding to in-game chat box
Removed shift to not move in-town (was not working as intended anyways)
This commit is contained in:
Collin Smith 2019-02-10 02:08:56 -08:00
parent 22ebede88f
commit c5efbc13a1
4 changed files with 68 additions and 11 deletions

View File

@ -394,16 +394,16 @@ public class Animation extends BaseDrawable {
}
public void setTransform(Index colormap, int id) {
//if (colormap != null) System.out.println("----> " + colormap + "; " + id);
transform = colormap;
transform = colormap;
transformColor = colormap == null ? 0 : id;
}
public void setTransform(byte packedTransform) {
if ((packedTransform & 0xFF) == 0xFF) {
int transform = packedTransform & 0xFF;
if (transform == 0xFF) {
setTransform(null, 0);
} else {
setTransform(Diablo.colormaps.get(packedTransform >>> 5), packedTransform & 0x1F);
setTransform(Diablo.colormaps.get(transform >>> 5), transform & 0x1F);
}
}

View File

@ -67,6 +67,8 @@ public class Entity {
StringBuilder builder = new StringBuilder();
if (bits == NONE) {
builder.append("NONE");
} else if (bits == ALL) {
builder.append("ALL");
} else {
if ((bits & HD) == HD) builder.append("HD").append("|");
if ((bits & TR) == TR) builder.append("TR").append("|");
@ -270,6 +272,7 @@ public class Entity {
byte transform = getTransform(comp);
animation.getLayer(c).setTransform(transform);
System.out.println(comp + " transform " + transform + " " + ((transform & 0xFF) >>> 5) + "|" + (transform & 0x1f));
/*
if (item != null) {
// FIXME: colors don't look right for sorc Tirant circlet changing hair color

View File

@ -99,7 +99,7 @@ public class Player extends Entity {
private void loadEquipped(EnumMap<BodyLoc, Item> items) {
equipped.putAll(items);
for (Map.Entry<BodyLoc, Item> entry : equipped.entrySet()) {
for (Map.Entry<BodyLoc, Item> entry : items.entrySet()) {
entry.getValue().load();
//if (DEBUG_EQUIPPED) Gdx.app.debug(TAG, entry.getKey() + ": " + entry.getValue());
}
@ -134,7 +134,7 @@ public class Player extends Entity {
//invalidate();
//setArmType(slot, item.base.alternateGfx);
int components = loc.components();
if (components > 0) dirty |= components;
dirty |= components;
updateWeaponClass();
notifySlotChanged(loc, oldItem, item);
@ -194,6 +194,7 @@ public class Player extends Entity {
return Diablo.cofs.chars_cof;
}
@Override
public void update() {
if (ignoreUpdate) {
super.update();

View File

@ -122,7 +122,56 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
this.fontColor = Diablo.colors.white;
this.background = new PaletteIndexedColorDrawable(Diablo.colors.modal);
this.cursor = new TextureRegionDrawable(Diablo.textures.white);
}});
float padding = 4;
background.setLeftWidth(padding);
background.setTopHeight(padding);
background.setRightWidth(padding);
background.setBottomHeight(padding);
}}) {
//boolean newlyVisible = false;
{
writeEnters = false;
//setTextFieldFilter(new TextFieldFilter() {
// @Override
// public boolean acceptChar(TextField textField, char c) {
// return c != ENTER_ANDROID && c != ENTER_DESKTOP;
// }
//});
/*setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(TextField textField, char c) {
if (c == ENTER_ANDROID || c == ENTER_DESKTOP) {
//if (newlyVisible) {
// newlyVisible = false;
// return;
//}
String text = input.getText();
if (!text.isEmpty()) {
Gdx.app.debug(TAG, text);
Message message = new Message(player.stats.getName(), text);
out.println(Packets.build(message));
input.setText("");
}
input.setVisible(false);
}
}
});*/
}
//@Override
//public void setVisible(boolean visible) {
//if (visible && !isVisible()) {
// newlyVisible = true;
//}
// super.setVisible(visible);
//}
};
input.setDebug(true);
input.setSize(Diablo.VIRTUAL_WIDTH * 0.75f, Diablo.fonts.fontformal12.getLineHeight() * 3);
input.setPosition(Diablo.VIRTUAL_WIDTH_CENTER - input.getWidth() / 2, 100);
input.setAlignment(Align.topLeft);
@ -201,7 +250,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
public void changed(ChangeEvent event, Actor actor) {
float x = touchpad.getKnobPercentX();
float y = touchpad.getKnobPercentY();
if (x == 0 && y == 0 || UIUtils.shift()) {
if (x == 0 && y == 0) {
player.setMode("TN");
return;
//} else if (-0.5f < x && x < 0.5f
@ -424,9 +473,13 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
Gdx.app.log(TAG, "connecting to " + socket.getRemoteAddress() + "...");
in = IOUtils.buffer(new InputStreamReader(socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream(), true);
String connect = Packets.build(new Connect(player));
out.println(connect);
if (!(socket instanceof PipedSocket)) {
String connect = Packets.build(new Connect(player));
out.println(connect);
} else {
String connectResponse = Packets.build(new ConnectResponse(1));
out.println(connectResponse);
}
}
updateTask = Timer.schedule(new Timer.Task() {