GithubHelp home page GithubHelp logo

Comments (3)

firasmestiri avatar firasmestiri commented on August 23, 2024

for further investigation, and to be able to trace the problem, i think it may be beneficial to add an overlay text that shows the currently pressed key(s) to see if the problem is related to the key ids

i already tried to implement something like this but it doesn't seem to work

public class DebugOverlay extends CoreScreenLayer {
public static final float MB_SIZE = 1048576.0f;
@In
private Config config;
@In
private SystemConfig systemConfig;
@In
private CameraTargetSystem cameraTarget;
@In
private Time time;
@In
private EntityManager entityManager;
@In
private LocalPlayer localPlayer;
@In
private WorldProvider worldProvider;
@In
private DebugMetricsSystem debugMetricsSystem;
@In
private StorageManager storageManager;
private UILabel metricsLabel;
@Override
public void initialise() {
bindVisible(new ReadOnlyBinding<Boolean>() {
@Override
public Boolean get() {
return systemConfig.debugEnabled.get();
}
});
UILabel debugLine1 = find("debugLine1", UILabel.class);
// This limit doesn't change after start-up.
final long dataLimit = OperatingSystemMemory.isAvailable()
? OperatingSystemMemory.dataAndStackSizeLimit() : -1;
if (debugLine1 != null) {
debugLine1.bindText(new ReadOnlyBinding<>() {
@Override
public String get() {
Runtime runtime = Runtime.getRuntime();
long totalHeapSize = runtime.totalMemory();
float usedHeapMemory = ((float) totalHeapSize - (float) runtime.freeMemory()) / MB_SIZE;
String s = String.format(
"FPS: %.1f, Heap Usage: %.1f MB, Total Heap: %.1f MB, Max Heap: %.1f MB",
time.getFps(),
usedHeapMemory,
totalHeapSize / MB_SIZE,
runtime.maxMemory() / MB_SIZE
);
if (OperatingSystemMemory.isAvailable()) {
// Check data size, because that's the one comparable to Terasology#setMemoryLimit
long dataSize = OperatingSystemMemory.dataAndStackSize();
// How much bigger is that than the number reported by the Java runtime?
long nonJavaHeapDataSize = dataSize - totalHeapSize;
String limitString = (dataLimit > 0)
? String.format(" / %.1f MB (%02d%%)", dataLimit / MB_SIZE, 100 * dataSize / dataLimit)
: "";
return String.format(
"%s, Data: %.1f MB%s, Extra: %.1f MB",
s, dataSize / MB_SIZE, limitString, nonJavaHeapDataSize / MB_SIZE
);
} else {
return s;
}
}
});
}
UILabel debugLine2 = find("debugLine2", UILabel.class);
if (debugLine2 != null) {
debugLine2.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
return String.format("Active Entities: %s, Current Target: %s", entityManager.getActiveEntityCount(), cameraTarget.toString());
}
});
}
UILabel debugLine3 = find("debugLine3", UILabel.class);
if (debugLine3 != null) {
debugLine3.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
if (!localPlayer.isValid()) {
return "";
}
Vector3f pos = localPlayer.getPosition(new Vector3f());
Vector3i chunkPos = Chunks.toChunkPos(pos, new Vector3i());
Vector3f rotation = localPlayer.getViewDirection(new Vector3f());
Vector3f cameraPos = localPlayer.getViewPosition(new Vector3f());
String orientation = "";
switch (Orientation.fromDirection(rotation.x, rotation.z)) {
case NORTH:
orientation = "N";
break;
case EAST:
orientation = "E";
break;
case SOUTH:
orientation = "S";
break;
case WEST:
orientation = "W";
break;
case NORTHEAST:
orientation = "NE";
break;
case SOUTHEAST:
orientation = "SE";
break;
case SOUTHWEST:
orientation = "SW";
break;
case NORTHWEST:
orientation = "NW";
break;
}
return String.format(Locale.US, "Position: (%.2f, %.2f, %.2f), Chunk (%d, %d, %d), " +
"Eye (%.2f, %.2f, %.2f), Rot (%.2f, %.2f, %.2f) %s", pos.x, pos.y, pos.z,
chunkPos.x, chunkPos.y, chunkPos.z,
cameraPos.x, cameraPos.y, cameraPos.z,
rotation.x, rotation.y, rotation.z, orientation);
}
});
}
UILabel debugLine4 = find("debugLine4", UILabel.class);
if (debugLine4 != null) {
debugLine4.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
return String.format("World Time: %.3f, Time Dilation: %.1f",
worldProvider.getTime().getDays() - 0.0005f, // use floor instead of rounding up
time.getGameTimeDilation());
}
});
}
UILabel debugInfo = find("debugInfo", UILabel.class);
if (debugInfo != null) {
debugInfo.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
return "[H] : Debug Documentation";
}
});
}
UILabel saveStatusLabel = find("saveStatusLabel", UILabel.class);
// clients do not have a storage manager
if (saveStatusLabel != null && storageManager != null) {
saveStatusLabel.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
return "Saving... ";
}
});
saveStatusLabel.bindVisible(
new ReadOnlyBinding<Boolean>() {
@Override
public Boolean get() {
return storageManager.isSaving();
}
}
);
}
UILabel wireframeMode = find("wireframeMode", UILabel.class);
if (wireframeMode != null) {
wireframeMode.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
return "WIREFRAME MODE";
}
});
wireframeMode.bindVisible(
new ReadOnlyBinding<Boolean>() {
@Override
public Boolean get() {
return config.getRendering().getDebug().isWireframe();
}
}
);
}
UILabel chunkRenderMode = find("chunkBBRenderMode", UILabel.class);
if (chunkRenderMode != null) {
chunkRenderMode.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
return "CHUNK BOUNDING BOX RENDER MODE";
}
});
chunkRenderMode.bindVisible(
new ReadOnlyBinding<Boolean>() {
@Override
public Boolean get() {
return config.getRendering().getDebug().isRenderChunkBoundingBoxes();
}
}
);
}
metricsLabel = find("metrics", UILabel.class);
}
@Override
public void update(float delta) {
metricsLabel.setText(debugMetricsSystem.getCurrentMode().getMetrics());
}
@Override
public boolean isModal() {
return false;
}
@Override
protected boolean isEscapeToCloseAllowed() {
return false;
}
/**
* Moves forward through the MetricsMode instances and displays the content of the next available one.
*/
public void toggleMetricsMode() {
MetricsMode mode = debugMetricsSystem.toggle();
PerformanceMonitor.setEnabled(mode.isPerformanceManagerMode());
}
}

it can be done along the existing debug text

from terasology.

firasmestiri avatar firasmestiri commented on August 23, 2024

i also forgot to mention, i analyzed the classes and code related to input management

the main class responsible for this issue is most likely in this class Bind commands

public class BindCommands extends BaseComponentSystem {
public static final ImmutableMap<Integer, SimpleUri> AZERTY = new ImmutableMap.Builder<Integer, SimpleUri>()
.put(KeyId.Z, new SimpleUri("engine:forwards"))
.put(KeyId.S, new SimpleUri("engine:backwards"))
.put(KeyId.Q, new SimpleUri("engine:left"))
.build();

the issue might be in the AZERTY() method specifically, and the keyid could be mistranslated or not correctly mapped

from terasology.

Cervator avatar Cervator commented on August 23, 2024

Hi @firasmestiri and thank you for both the report and suggestions :-)

It can sometimes be a little easier to troubleshoot over on our Discord, but this may also work if patient.

AZERTY probably hasn't been touched for years at this point, and bugs do sneak in. I'm not sure which if any current maintainers even have an AZERTY keyboard to help test and validate things.

Are you able to run the game from source and maybe run it in debug mode to step through the code to see if it is simply skipping that method or something?

from terasology.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.