Basically what I'm trying to do is this:
Split my screen into 3 parts
Part 1: character image
Part 2: Game
Part 3: Status
Part 1 is just the character image on the right of the screen.
Part 2 is the actual game area, with the maps and everything.
Part 3 below the game would be the character's statuses.
This is my first attempt at making a plugin and I haven't found anything similar to this yet, if anyone can give me a hint as to how I should go about it...
Split my screen into 3 parts
Part 1: character image
Part 2: Game
Part 3: Status
Part 1 is just the character image on the right of the screen.
Part 2 is the actual game area, with the maps and everything.
Part 3 below the game would be the character's statuses.
This is my first attempt at making a plugin and I haven't found anything similar to this yet, if anyone can give me a hint as to how I should go about it...
JavaScript:
/*:
* @target MZ
* @plugindesc Custom screen layout with character portrait, game area, and status panel.
* @author N.
*
* @param CharacterImage
* @text Character Image
* @desc The filename of the character image (from the img/pictures folder).
* @default CharacterImage
*
* @param StatusHeight
* @text Status Panel Height
* @desc The height of the status panel at the bottom (in pixels).
* @default 100
*
* @param GameAreaWidth
* @text Game area width
* @desc The width of the game panel (in pixels).
* @default 500
*
* @param GameAreaHeight
* @text Game area height
* @desc The height of the game panel (in pixels).
* @default 500
*
* @help
* This plugin divides the screen into:
* - Right 30%: Character portrait
* - Left 70%: Game area (top 80%) + Status panel (bottom 20%)
*/
(() => {
const parameters = PluginManager.parameters("CustomScreenLayout");
const characterImage = parameters["CharacterImage"] || "CharacterImage";
const statusHeight = Number(parameters["StatusHeight"] || 200);
const gameAreaWidth = Number(parameters["GameAreaWidth"] || 500);
const gameAreaHeight = Number(parameters["GameAreaHeight"] || 500);
// Override Spriteset_Map to adjust the viewport
const _Spriteset_Map_initialize = Spriteset_Map.prototype.initialize;
Spriteset_Map.prototype.initialize = function() {
// Chama o initialize original para criar o viewport
_Spriteset_Map_initialize.call(this);
// Redefine o tamanho da área de jogo
const adjustedWidth = Graphics.width * 0.7; // 70% da largura da tela
const adjustedHeight = Graphics.height - statusHeight;
// Define o novo retângulo para o mapa (70% da tela)
this._gameViewport = new PIXI.Rectangle(
0, // Posição X à esquerda
0, // Posição Y no topo
this._mapWidth / 2, // Largura da área de jogo
this._mapHeight /2 // Altura da área de jogo
);
// Aplica a transformação na área de visualização
this._baseSprite.setTransform(this._gameViewport.x, this._gameViewport.y);
this._baseSprite.scale.set(1);
};
// Override Scene_Map to add UI elements
const _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
Scene_Map.prototype.createDisplayObjects = function() {
_Scene_Map_createDisplayObjects.call(this);
this.createCharacterPortrait();
this.createStatusPanel();
this.createRedBorder(); //just a test to understand something
};
Scene_Map.prototype.createCharacterPortrait = function() {
// Left 30% character portrait
this._characterPortrait = new Sprite(ImageManager.loadPicture(characterImage));
this._characterPortrait.x = Graphics.width * 0.7;;
this._characterPortrait.y = 0;
this._characterPortrait.width = Graphics.width * 0.3;
this._characterPortrait.height = Graphics.height;
this.addChild(this._characterPortrait);
};
Scene_Map.prototype.createStatusPanel = function() {
// Status panel (bottom 10% of right 70%)
this._statusPanel = new Sprite(new Bitmap(Graphics.width * 0.65, statusHeight));
this._statusPanel.x = 0;
this._statusPanel.y = Graphics.height - statusHeight;
this._statusPanel.bitmap.fillAll("rgba(0, 0, 0, 0.5)");
this.addChild(this._statusPanel);
// Status text (update these values dynamically in your game)
const stats = ["Influence: 0", "Control: -6", "Fatigue: 12%", "Respect: 0"];
this._statusPanel.bitmap.fontSize = 20;
this._statusPanel.bitmap.textColor = "#FFFFFF";
stats.forEach((stat, index) => {
this._statusPanel.bitmap.drawText(stat, 20 + index * 150, 10, 200, 30, "left");
});
};
Scene_Map.prototype.createRedBorder = function() {
// Cria um bitmap para a borda
const borderWidth = 10; // Largura da borda em pixels
// Cria o sprite de borda
this._redBorder = new Sprite(new Bitmap(Graphics.width, Graphics.height));
const bitmap = this._redBorder.bitmap;
// Desenha as bordas
bitmap.fillRect(0, 0, Graphics.width, borderWidth, "red"); // Topo
bitmap.fillRect(0, Graphics.height - borderWidth, Graphics.width, borderWidth, "red"); // Base
bitmap.fillRect(0, 0, borderWidth, Graphics.height, "red"); // Esquerda
bitmap.fillRect(Graphics.width - borderWidth, 0, borderWidth, Graphics.height, "red"); // Direita
// Adiciona o sprite ao mapa
this.addChild(this._redBorder);
};
})();