implement main menu, implement textfield widget, implement create world screen, implement splash screen
This commit is contained in:
@@ -6,9 +6,11 @@ export default class ScreenRenderer {
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.resolution = this.minecraft.isInGame() ? 1 : this.minecraft.window.scaleFactor; // Increase resolution for the splash text
|
||||
|
||||
// Update camera size
|
||||
this.window.canvas2d.width = this.window.width;
|
||||
this.window.canvas2d.height = this.window.height;
|
||||
this.window.canvas2d.width = this.window.width * this.resolution;
|
||||
this.window.canvas2d.height = this.window.height * this.resolution;
|
||||
|
||||
// Get context stack of 2d canvas
|
||||
this.stack2d = this.window.canvas2d.getContext('2d');
|
||||
@@ -21,18 +23,31 @@ export default class ScreenRenderer {
|
||||
let mouseX = this.minecraft.window.mouseX;
|
||||
let mouseY = this.minecraft.window.mouseY;
|
||||
|
||||
this.stack2d.save();
|
||||
this.stack2d.scale(this.resolution, this.resolution, this.resolution);
|
||||
|
||||
// Reset 2d canvas
|
||||
this.stack2d.clearRect(0, 0, this.window.width, this.window.height);
|
||||
|
||||
// Render in-game overlay
|
||||
if (this.minecraft.loadingScreen === null) {
|
||||
this.minecraft.ingameOverlay.render(this.stack2d, mouseX, mouseY, partialTicks);
|
||||
try {
|
||||
// Render in-game overlay
|
||||
if (this.minecraft.isInGame() && this.minecraft.loadingScreen === null) {
|
||||
this.minecraft.ingameOverlay.render(this.stack2d, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
// Render current screen
|
||||
if (this.minecraft.currentScreen !== null) {
|
||||
this.minecraft.currentScreen.drawScreen(this.stack2d, mouseX, mouseY, partialTicks)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
// Render current screen
|
||||
if (!(this.minecraft.currentScreen === null)) {
|
||||
this.minecraft.currentScreen.drawScreen(this.stack2d, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
this.stack2d.restore();
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.stack2d.clearRect(0, 0, this.window.width, this.window.height);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user