$gameScreen.picture(PID).Height ??? exist ???

I do not know if I am too tired, but I can not find how return Height; of a picture?


I am completely blocked. :headshake:
I do not know what to look for.
I just need to get the height of the previous images.
Images are generated dynamically and randomly, and their size varies depending on the content.
I just need to be able to get the height.
But for several hours I've run into a wall.
How to simply return the height of an picture?


Maybe there is another idea, but I must obliquely recuperate this height.


A picture is worth 1000 words, here is the concept
The second Quest need to take the last Height of the last quest and add to the var Dy
Those quests have never same size and need to be calculate.


//PID = Picture ID
$gameScreen.picture(PID-1).Height
$gameScreen.picture(PID-1)._Height


quest-menue.jpg


I check every prototype and function and found nothing,


Capture.JPG


Here the sample of the script am work on 

Spoiler
//QUEST FUNCTION DATA JS consctor of dynamic quest engine
//Infinite Loop, Wait need break conditional check all Quest in meta
for (var Q = 0, PID = 575, Dx = 820, Dy = 350;; Q++) {
console.log('q= ' + Q);
if (!$dataArmors[QuestsID].meta['QuestTitle' + Q]) {
console.log('break ');
} // if not exist in meta, break , beacause no have more quest list
console.log('ok= ' + Q);
var Qtitle = $dataArmors[QuestsID].meta['QuestTitle' + Q];
// 1: affiche le titre de la quest
$gameScreen.setDTextPicture('\\OW[6]\\I[12] ' + Qtitle, 28);
$gameScreen.setFont('GameFont');
$gameScreen.showPicture(PID, '', 0, Dx, Dy, 100, 100, 255, 0);
$gameScreen.picture(PID).QuestID = $dataArmors[QuestsID].meta.QuestTips0
$gameScreen.setPictureCallCommon(PID, 26, 4); //Call picture click 5.5: Mouse OVER single Quest description
// check le type pour savoir comment interpreter le process validation la quest
var QType = $dataArmors[1].meta['QuestType' + Q]('Type');
if (QType === 'receipe') {
console.log(QType);
if ($dataArmors[1].meta['QuestCheck' + Q]) { // si vrai existe ? ajoute un icon valider et change la couleur
$gameScreen.setDTextPicture('\\OW[6]\\I[12]\\c[11] ' + Qtitle, 28);
$gameScreen.setFont('GameFont');
$gameScreen.showPicture(PID, '', 0, Dx, Dy, 100, 100, 255, 0);
$gameScreen.picture(PID).QuestID = $dataArmors[QuestsID].meta.QuestTips0;
}
} else if (QType === 'item') {}
if (Q === 1) {
break;
console.log('break ');
} // break test to delette, is debug test
console.log('Q= ' + Q);
PID++;
}



Thanks a lot if i can get help or suggestion
If you want height or width you need to get it from picture bitmap. $gameScreen.picture(pictureId) - there is no bitmaps in this container.


After you show a picture you can pick up picture name and use it in ImageManager.loadPicture function. This function will bring back a bitmap of picture for you and then you will be able to get height or width of it.


e.g.


picHeight = ImageManager.loadPicture($gameScreen.picture(pictureID).name()).height
picWidth = ImageManager.loadPicture($gameScreen.picture(pictureID).name()).width


This is only one of the ways to get it you can do it in many other ways.
If you want height or width you need to get it from picture bitmap. $gameScreen.picture(pictureId) - there is no bitmaps in this container.


After you show a picture you can pick up picture name and use it in ImageManager.loadPicture function. This function will bring back a bitmap of picture for you and then you will be able to get height or width of it.


e.g.



picHeight = ImageManager.loadPicture($gameScreen.picture(pictureID).name()).height
picWidth = ImageManager.loadPicture($gameScreen.picture(pictureID).name()).width


This is only one of the ways to get it.

Yep tanks to trying, but i know this way, like i say ,


my pictures are dynamics and virtuals bitmaps.
Ex:


$gameScreen.picture(PID)


return this,  Game_Picture {_name: "1481931332144", _origin: 0, _x: 820, _y: 350, _scaleX: 100…}


they are not in file folder so will get error.
The function generate the dynamic bitmap picture are this


Sprite_Picture.prototype.makeDynamicBitmap = function() {
this.textWidths = [];
this.hiddenWindow = SceneManager.getHiddenWindow();
this.resetFontSettings();
var bitmapVirtual = new Bitmap_Virtual();
this._processText(bitmapVirtual);
this.resetFontSettings();
this.bitmap = new Bitmap(bitmapVirtual.width, bitmapVirtual.height);
if (this.dTextInfo.font) this.bitmap.fontFace = this.dTextInfo.font;
if (this.dTextInfo.color) this.bitmap.fillAll(this.dTextInfo.color);
this._processText(this.bitmap);
this.hiddenWindow = null;
};
Sprite_Picture.prototype._processText = function(bitmap) {
var textState = {index: 0, x: 0, y: 0, text: this.dTextInfo.value, left:0, line:-1, height:0};
this._processNewLine(textState, bitmap);
textState.height = this.hiddenWindow.calcTextHeight(textState, false);
textState.index = 0;
while (textState.text[textState.index]) {
this._processCharacter(textState, bitmap);
}
};




And the function add property of $gameScreen.picture are 


$gameScreen.picture(PID).dTextInfo


return a object

Code:
// example console.log
Object {value: "OW[6]I[12]c[11] I[189]Trouvé le plant de construction des gates ↵", size: 28, align: 0, color: null, font: "GameFont"}


//is creat by 
    Game_Screen.prototype.getDTextPictureInfo = function() {
        return {value:this.dTextValue, size:this.dTextSize, align:this.dTextAlign,
            color:this.dTextBackColor, font:this.dTextFont};
    };
You would need to look at the Sprite_Picture object rather than the Game_Picture object to get the bitmap information.


Starting from SceneManager._scene look through the children for the spriteset, then the pictureContainer, then the sprite_picture objects.  I'm not sure if they'll be named like that.
I mean if you know you need a bitmap so what a problem? It just an example with picture name.


As i say you need a bitmap and you create somewhere your bitmaps, so just create height and width parameters for your pictures acordiong to those bitmaps.


As much i can understand you create your pictures bitmaps in Sprite_Picture.prototype.makeDynamicBitmap


Then for your code it will be something like this i think


Sprite_Picture.prototype.makeDynamicBitmap = function() {
this.textWidths = [];
this.hiddenWindow = SceneManager.getHiddenWindow();
this.resetFontSettings();
var bitmapVirtual = new Bitmap_Virtual();
this._processText(bitmapVirtual);
this.resetFontSettings();
this.bitmap = new Bitmap(bitmapVirtual.width, bitmapVirtual.height);
this.picture().setPicSize(this.bitmap);//new
if (this.dTextInfo.font) this.bitmap.fontFace = this.dTextInfo.font;
if (this.dTextInfo.color) this.bitmap.fillAll(this.dTextInfo.color);
this._processText(this.bitmap);
this.hiddenWindow = null;
};
//new function
Game_Picture.prototype.setPicSize = function(bitmap) {
this._width = bitmap.width;
this._height = bitmap.height;
};


Sorry if i understand something wrong, my English is bad so I have troubles with it 🙂
You would need to look at the Sprite_Picture object rather than the Game_Picture object to get the bitmap information.


Starting from SceneManager._scene look through the children for the spriteset, then the pictureContainer, then the sprite_picture objects.  I'm not sure if they'll be named like that.

OMG Why you know so many things.
You are really super mr .@Shaz  🤣


Ok so i found it in


SceneManager._scene.children[0]._pictureStorage[PID]

Code:
// ex: for get a heigth for a picture .... 200
var PID = 200;
SceneManager._scene.children[0]._pictureStorage[PID].height
//or for width
SceneManager._scene.children[0]._pictureStorage[PID].width
As much i can understand you create your pictures bitmaps in Sprite_Picture.prototype.makeDynamicBitmap


Then for your code it will be something like this i think


Sorry if rstand something wrong, my English is bad so I have troubles with it 🙂



tanks for you help, but @Shaz found me i way , i can not modify the plugin without permission. 🙂
so ... ask for permission?  If you're not sharing the edit, there's probably no issue.  What plugin is it?
so ... ask for permission?  If you're not sharing the edit, there's probably no issue.  What plugin is it?



http://triacontane.blogspot.ca/2015/12/rpgmv-rpgmv-dtext-1-rpgmv-dtext-dtext.html
Don't know where you got your information from ... on that very page:

Terms of service



This plug-in is released under the MIT license. It is possible to modify and re-distribute without permission to the author, and there is no restriction on usage forms (commercial, 18 prohibition etc.). However, please keep the license indication of the header.



That clearly says you CAN modify and redistribute without the author's permission.


Also, I'm not a guy, so that's mrs, not mr.  😉
Don't know where you got your information from ... on that very page:


That clearly says you CAN modify and redistribute without the author's permission.


Also, I'm not a guy, so that's mrs, not mr.  😉

tanks for info.
Sorry i just check you profile, my mistake. 
Also, you don't need to quote every single post.  Makes it difficult to read the thread, especially when it's just two people posting one after the other.


If there is something specific in the post that you want to refer to, quote it and remove everything else (ie - don't quote the entire thing), or just do the @Jonforum tagging stuff which will let everyone know who you're talking to (if there's more than 2 people active in the thread) and sends them a notification.
@Shaz OK i got this bad habit i don't remember how longer how.
I will try follow your recommendation
tanks a lot for your help @+
@Shaz  @Krimer


Ok i update, because is not really work


why when i use it in my console debug is return me the height, but not in a function


SceneManager._scene.children[0]._pictureStorage[571].height


Is return me the height : 56 
this is ok.
But when i use them in a function ,is alway return 0. 


function myfunction() {
return SceneManager._scene.children[0]._pictureStorage[571].height
}

$gameScreen.showPicture(571, 'filename', 0, 50, 50, 100, 100, 255, 0); // example
var t = myfunction();
console.log(t);
// Is alway return me 0
// i try many way, is return me (56), only if i execute to console debug






the full script are here 

Spoiler
Code:
function xxx() {
return SceneManager._scene.children[0]._pictureStorage[571].height
}


// ## -------- FULL QUEST SHOW AND SUBQUEST SHOW ----------  |
function ShowFullQuest(QuestsID) {
    console.log('Show The FULL Quest ' + QuestsID);
	var XY = [817,142]; // Base de XY guide for Questwindow
    // Quest Title
    $gameScreen.setDTextPicture('\\OW[10] ' + $dataArmors[QuestsID].name + ' ', 48);
    $gameScreen.setFont('GameFont');
    $gameScreen.showPicture(571, '', 0, XY[0], XY[1], 100, 100, 255, 0); // Title of the fullQuest
	var t = xxx();
	console.log(t);
    // Quest Descript
    $gameScreen.setDTextPicture('\\OW[6] ' + $dataArmors[QuestsID].description.match(/.{1,64}\b/g).join(' \n ') + ' ', 19);
    $gameScreen.setFont('GameFont3');
    $gameScreen.showPicture(572, '', 0, 820, 222, 100, 100, 255, 0); // description of the fullQuest
	var t = xxx();
	console.log(t);
    // Quest PROGRESS TITLE
    $gameScreen.setDTextPicture('\\OW[8] QUEST PROGRESS ', 36);
    $gameScreen.setFont('GameFont');
    $gameScreen.showPicture(573, '', 0, 817, 310, 100, 100, 255, 0); // progress of the fullQuest
	var t = xxx();// return 0000
	console.log(t);
    //QUEST FUNCTION DATA JS consctor of dynamic quest engine
    //Infinite Loop, Wait need break conditional check all Quest in meta
    
}
Because you are calling the function to return the height while the picture is still being loaded.  MV loads resources asynchronously which means if it hasn't already been loaded once in the current playthrough, you can't get those properties immediately after the showPicture call - you need to wait and confirm that it's finished loading.


You can't put a loop to keep checking until it's > 0 either, because that will cause all other processing (including the loading) to halt.
You can't put a loop to keep checking until it's > 0

We had the same idea.
I try in a loop before asking the question.
The result remains the same.

Code:
function myfunction() {
return SceneManager._scene.children[0]._pictureStorage[571].height
}

function ShowFullQuest(QuestsID) {
  $gameScreen.showPicture(571, 'filename', 0, 50, 50, 100, 100, 255, 0); // example
  for (var t=0; t==0; ) {
  var t = myfunction(); // Is alway return me 0
  console.log(t); 
  }
}
You haven't actually said what it is you are trying to accomplish.  Why do you need to know the picture's height, and why are you doing it all via script?  If I were writing a hud script I wouldn't be using the Show Picture command at all - I'd be using sprites.
@Shaz


It is a bit difficult to express myself in detail in another language.
But overall, my quest menu is the only one that needs to compute and calcultate the height of the previous images (text=imageBitmap).


As you can see in the video I just gave you, see all Objectives in quest.
It displays all quests in court, categorized by galaxy and planet.
Objectives are taken in a DataBASE, and generate dynamically.



The problems is that I can not choose fixed height, do not predetermine because they are all differences, certain with more text, other contains items.
And sometimes paragraphs.
All the text you see in the image is generated in bitmap.
A text has volatile ID that I do not like the same.


And the biggest problem is that for the latency of the transitions to be effective, they must be executed in a function very quickly.


There is a possibility of putting a Y value for each type of quest in the DB, but I would have liked to be able to get this value more efficiently.


I show you all my menu, maybe you will more understand how i work
At the end is the QuestMenu
The one i need calculate height of each subquest.












The Questmenue Final concept are like this.

Spoiler
quest-menuev2.png
I am not really experienced in JS. So i can only offer some workaround, do pictures placement asynchronously too, I mean show all pictures anywhere out of map screen and after use setTimeout to place them after short period of time. For me 50-200 mc is enough but its need testing. Its can be workaround for you or bad idea, it depends on how your system works. But i don't recommend to listen to me and find other way 🙂   
@Krimer


I had thought to setTimeout, but unfortunately I'm afraid it will make too unstable the menu and open door for bug.
I did as you said above, I have modify the plugin that create the bitmap, thanks to you for the solution.
But, The problem remains the same, but cleaner.


What I will try to do, is just .
The first step generate and displays the all the quest but with transparent 0%, and each time make a picture store is ID in a var with (Array push () method) to store the important IDs.
2 step, i will  Being able to take the height of each one because they are already generating.
and simply moved the picture with all ID stored in my var array .
Is the only way i see.


Tanks you for your script at the top
 

Original thread: https://forums.rpgmakerweb.com/threads/gamescreen-picture-pid-height-exist.72378/