Visual improvements
- Added a custom font for item amount displays - Added an indicator for openable items - Changed open item indicator to be more obvious - Fixed ExponentAnimation overshooting target during FPS spikes
This commit is contained in:
parent
c6e6dc6851
commit
9885a1ca42
@ -27,6 +27,7 @@ import ru.windcorp.progressia.client.graphics.font.GNUUnifontLoader;
|
|||||||
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
||||||
import ru.windcorp.progressia.client.graphics.texture.Atlases;
|
import ru.windcorp.progressia.client.graphics.texture.Atlases;
|
||||||
import ru.windcorp.progressia.client.graphics.world.WorldRenderProgram;
|
import ru.windcorp.progressia.client.graphics.world.WorldRenderProgram;
|
||||||
|
import ru.windcorp.progressia.client.graphics.world.hud.HUDTextures;
|
||||||
import ru.windcorp.progressia.client.localization.Localizer;
|
import ru.windcorp.progressia.client.localization.Localizer;
|
||||||
import ru.windcorp.progressia.common.resource.ResourceManager;
|
import ru.windcorp.progressia.common.resource.ResourceManager;
|
||||||
import ru.windcorp.progressia.common.util.crash.CrashReports;
|
import ru.windcorp.progressia.common.util.crash.CrashReports;
|
||||||
@ -46,6 +47,7 @@ public class ClientProxy implements Proxy {
|
|||||||
() -> Typefaces
|
() -> Typefaces
|
||||||
.setDefault(GNUUnifontLoader.load(ResourceManager.getResource("assets/unifont-13.0.03.hex.gz")))
|
.setDefault(GNUUnifontLoader.load(ResourceManager.getResource("assets/unifont-13.0.03.hex.gz")))
|
||||||
);
|
);
|
||||||
|
RenderTaskQueue.waitAndInvoke(HUDTextures::loadItemAmountTypeface);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw CrashReports.report(e, "ClientProxy failed");
|
throw CrashReports.report(e, "ClientProxy failed");
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,12 @@ public class ExponentAnimation {
|
|||||||
float difference = value - target;
|
float difference = value - target;
|
||||||
value += difference * (1 - Math.exp(speed * timeStep));
|
value += difference * (1 - Math.exp(speed * timeStep));
|
||||||
|
|
||||||
|
float newDifference = value - target;
|
||||||
|
if (difference * newDifference < 0) {
|
||||||
|
// Whoops, we've overshot
|
||||||
|
value = target;
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,15 +17,20 @@
|
|||||||
*/
|
*/
|
||||||
package ru.windcorp.progressia.client.graphics.world.hud;
|
package ru.windcorp.progressia.client.graphics.world.hud;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import ru.windcorp.progressia.client.graphics.texture.Atlases;
|
import ru.windcorp.progressia.client.graphics.texture.Atlases;
|
||||||
import ru.windcorp.progressia.client.graphics.texture.SimpleTexture;
|
import ru.windcorp.progressia.client.graphics.texture.SimpleTexture;
|
||||||
import ru.windcorp.progressia.client.graphics.texture.Texture;
|
import ru.windcorp.progressia.client.graphics.texture.Texture;
|
||||||
import ru.windcorp.progressia.client.graphics.texture.Atlases.AtlasGroup;
|
import ru.windcorp.progressia.client.graphics.texture.Atlases.AtlasGroup;
|
||||||
import ru.windcorp.progressia.common.resource.ResourceManager;
|
import ru.windcorp.progressia.common.resource.ResourceManager;
|
||||||
|
import ru.windcorp.progressia.common.util.crash.CrashReports;
|
||||||
|
|
||||||
public class HUDTextures {
|
public class HUDTextures {
|
||||||
|
|
||||||
private static final AtlasGroup HUD_ATLAS_GROUP = new AtlasGroup("HUD", 1 << 12);
|
private static final AtlasGroup HUD_ATLAS_GROUP = new AtlasGroup("HUD", 1 << 12);
|
||||||
|
|
||||||
|
private static ItemAmountTypeface itemAmountTypeface = null;
|
||||||
|
|
||||||
public static Texture getHUDTexture(String name) {
|
public static Texture getHUDTexture(String name) {
|
||||||
return new SimpleTexture(
|
return new SimpleTexture(
|
||||||
@ -39,5 +44,17 @@ public class HUDTextures {
|
|||||||
public static AtlasGroup getHUDAtlasGroup() {
|
public static AtlasGroup getHUDAtlasGroup() {
|
||||||
return HUD_ATLAS_GROUP;
|
return HUD_ATLAS_GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ItemAmountTypeface getItemAmountTypeface() {
|
||||||
|
return itemAmountTypeface;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadItemAmountTypeface() {
|
||||||
|
try {
|
||||||
|
itemAmountTypeface = new ItemAmountTypeface();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw CrashReports.report(e, "Could not load item amount typeface");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Progressia
|
||||||
|
* Copyright (C) 2020-2021 Wind Corporation and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package ru.windcorp.progressia.client.graphics.world.hud;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import ru.windcorp.progressia.client.graphics.flat.FlatRenderProgram;
|
||||||
|
import ru.windcorp.progressia.client.graphics.font.SpriteTypeface;
|
||||||
|
import ru.windcorp.progressia.client.graphics.model.ShapeRenderProgram;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.ComplexTexture;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.Texture;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.TextureLoader;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.TexturePrimitive;
|
||||||
|
import ru.windcorp.progressia.client.graphics.texture.TextureSettings;
|
||||||
|
import ru.windcorp.progressia.common.resource.ResourceManager;
|
||||||
|
|
||||||
|
public class ItemAmountTypeface extends SpriteTypeface {
|
||||||
|
|
||||||
|
public static final int HEIGHT = 5;
|
||||||
|
public static final int WIDTH = 3;
|
||||||
|
|
||||||
|
private final Texture[] textures = new Texture[10];
|
||||||
|
|
||||||
|
public ItemAmountTypeface() throws IOException {
|
||||||
|
super("ItemAmount", HEIGHT, 1);
|
||||||
|
|
||||||
|
ComplexTexture atlas = new ComplexTexture(new TexturePrimitive(
|
||||||
|
TextureLoader.loadPixels(
|
||||||
|
ResourceManager.getTextureResource("gui/ItemAmountTypeface"),
|
||||||
|
new TextureSettings(false)
|
||||||
|
).getData()
|
||||||
|
), 30, 5);
|
||||||
|
|
||||||
|
for (int i = 0; i <= 9; ++i) {
|
||||||
|
textures[i] = atlas.get(i * WIDTH, 0, WIDTH, HEIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Texture getTexture(char c) {
|
||||||
|
if (!supports(c))
|
||||||
|
return textures[0];
|
||||||
|
return textures[c - '0'];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShapeRenderProgram getProgram() {
|
||||||
|
return FlatRenderProgram.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(char c) {
|
||||||
|
return c >= '0' && c <= '9';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,6 +20,7 @@ package ru.windcorp.progressia.client.graphics.world.hud;
|
|||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
import glm.mat._4.Mat4;
|
import glm.mat._4.Mat4;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
import ru.windcorp.progressia.client.graphics.Colors;
|
||||||
|
import ru.windcorp.progressia.client.graphics.backend.InputTracker;
|
||||||
import ru.windcorp.progressia.client.graphics.flat.FlatRenderProgram;
|
import ru.windcorp.progressia.client.graphics.flat.FlatRenderProgram;
|
||||||
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
@ -42,6 +43,7 @@ public class SlotComponent extends Component {
|
|||||||
static final float TEXTURE_SIZE = 24;
|
static final float TEXTURE_SIZE = 24;
|
||||||
|
|
||||||
private static Renderable containerOpenDecoration = null;
|
private static Renderable containerOpenDecoration = null;
|
||||||
|
private static Renderable containerOpenableDecoration = null;
|
||||||
|
|
||||||
private final ItemContainer container;
|
private final ItemContainer container;
|
||||||
private final int index;
|
private final int index;
|
||||||
@ -63,7 +65,7 @@ public class SlotComponent extends Component {
|
|||||||
|
|
||||||
setScale(2);
|
setScale(2);
|
||||||
|
|
||||||
Font sizeFont = new Font().deriveOutlined().withScale(1);
|
Font sizeFont = new Font(HUDTextures.getItemAmountTypeface()).deriveOutlined().withScale(2);
|
||||||
addChild(new DynamicLabel(getName() + ".Size", sizeFont, () -> amountDisplayString, getPreferredSize().x));
|
addChild(new DynamicLabel(getName() + ".Size", sizeFont, () -> amountDisplayString, getPreferredSize().x));
|
||||||
|
|
||||||
setLayout(new LayoutAlign(0, 0, 0));
|
setLayout(new LayoutAlign(0, 0, 0));
|
||||||
@ -74,6 +76,13 @@ public class SlotComponent extends Component {
|
|||||||
HUDTextures.getHUDTexture("DecorationContainerOpen")
|
HUDTextures.getHUDTexture("DecorationContainerOpen")
|
||||||
).setSize(TEXTURE_SIZE + 2).setOrigin(-1, -1, 0).create();
|
).setSize(TEXTURE_SIZE + 2).setOrigin(-1, -1, 0).create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (containerOpenableDecoration == null) {
|
||||||
|
containerOpenableDecoration = new PgmBuilder(
|
||||||
|
FlatRenderProgram.getDefault(),
|
||||||
|
HUDTextures.getHUDTexture("DecorationContainerOpenable")
|
||||||
|
).setSize(TEXTURE_SIZE + 2).setOrigin(-1, -1, 0).create();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemSlot getSlot() {
|
public ItemSlot getSlot() {
|
||||||
@ -155,10 +164,26 @@ public class SlotComponent extends Component {
|
|||||||
|
|
||||||
if (contents instanceof ItemDataContainer) {
|
if (contents instanceof ItemDataContainer) {
|
||||||
ItemDataContainer asContainer = (ItemDataContainer) contents;
|
ItemDataContainer asContainer = (ItemDataContainer) contents;
|
||||||
|
|
||||||
if (asContainer.isOpen()) {
|
if (asContainer.isOpen()) {
|
||||||
renderer.pushColorMultiplier().mul(Colors.BLUE);
|
renderer.pushColorMultiplier().mul(Colors.BLUE);
|
||||||
containerOpenDecoration.render(renderer);
|
containerOpenDecoration.render(renderer);
|
||||||
renderer.popColorMultiplier();
|
renderer.popColorMultiplier();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
double dx = InputTracker.getCursorX() - (getX() + getWidth() / 2);
|
||||||
|
double dy = InputTracker.getCursorY() - (getY() + getHeight() / 2);
|
||||||
|
double distanceToCursorSquared = dx*dx + dy*dy;
|
||||||
|
final double maxDistanceSquared = (scale * TEXTURE_SIZE * 4) * (scale * TEXTURE_SIZE * 4);
|
||||||
|
|
||||||
|
float opacity = (float) (1 - distanceToCursorSquared / maxDistanceSquared);
|
||||||
|
|
||||||
|
if (opacity > 0) {
|
||||||
|
renderer.pushColorMultiplier().mul(Colors.BLUE.x, Colors.BLUE.y, Colors.BLUE.z, opacity);
|
||||||
|
containerOpenableDecoration.render(renderer);
|
||||||
|
renderer.popColorMultiplier();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class PlayerManager {
|
|||||||
private EntityDataPlayer spawnPlayerEntity(String login) {
|
private EntityDataPlayer spawnPlayerEntity(String login) {
|
||||||
EntityDataPlayer player = (EntityDataPlayer) EntityDataRegistry.getInstance().create("Core:Player");
|
EntityDataPlayer player = (EntityDataPlayer) EntityDataRegistry.getInstance().create("Core:Player");
|
||||||
|
|
||||||
player.getHand(0).slot().setContents(ItemDataRegistry.getInstance().create("Test:Stick"), 7);
|
player.getHand(0).slot().setContents(ItemDataRegistry.getInstance().create("Test:Stick"), 20);
|
||||||
player.getEquipmentSlot(0).slot().setContents(ItemDataRegistry.getInstance().create("Test:CardboardBackpack"), 1);
|
player.getEquipmentSlot(0).slot().setContents(ItemDataRegistry.getInstance().create("Test:CardboardBackpack"), 1);
|
||||||
|
|
||||||
player.setPosition(getServer().getWorld().getGenerator().suggestSpawnLocation());
|
player.setPosition(getServer().getWorld().getGenerator().suggestSpawnLocation());
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1011 B After Width: | Height: | Size: 1009 B |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
src/main/resources/assets/textures/gui/ItemAmountTypeface.png
Normal file
BIN
src/main/resources/assets/textures/gui/ItemAmountTypeface.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 214 B |
Reference in New Issue
Block a user