RMMV [Followup Q] Moving *&Scaling* the HUD mid game in Galv_Tools

Kaymon145

Veteran
Veteran
Joined
Apr 22, 2022
Messages
34
Reaction score
17
First Language
English
Primarily Uses
RMMV
Hello everyone, I am using Galv_Tools along with MBS_MapZoom and am running into the issue where the tool HUD is placed incorrectly while zoomed in. My maps only change zoom amount when transferring maps so I thought about using a variable to control how much to move the HUD by and adjust it accordingly on transfer.
Galv's plugin has parameters for HUD X,Y, but unfortunately it appears they are static and don't accept variables. I tried looking into the code and was messing with this line just to see if I could get it to move, but it appears to not be updating position even when the variable is changed in game. Here is the part of Galv's code I was looking at, I added the var offset part to try and get it assigned to my variable.
Code:
Sprite_ToolHud.prototype.setBitmap = function() {
    var offset = $gameVariables.value(30);
    this.x = (Galv.TOOLS.hudXY[0] + offset);
    this.y = (Galv.TOOLS.hudXY[1] + offset);
    this.bitmap = ImageManager.loadSystem(Galv.TOOLS.hudImg);
};

EDIT: I just realized it is moving but it's a map behind, im changing the variable whenever the player transfers maps but I don't think the variable is updating in time to tell the HUD where to draw, it's always set to the position i set it to when entering the last map..
 
Last edited:

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,964
Reaction score
2,335
First Language
Dutch
Primarily Uses
RMMV
I dont know the plugin (only by name), but you might see if you could
do if parameter is called "offset", try to make it "eval(offset)".
than on parameter, use $gameVariables.value(id);

id = number ID of the variable.

ingame, you could do variable = 40 to make the x,y to that value.
if map change, you could reposition it if needed.
 

Kaymon145

Veteran
Veteran
Joined
Apr 22, 2022
Messages
34
Reaction score
17
First Language
English
Primarily Uses
RMMV
Thats what I'm trying to do and it almost works but its late.. say if variable 30 is 0 and I go into a house and change variable 30 to anything it dosen't actually change the HUD position till I go to the next map, it looks like its being updated somewhere here :
Code:
//-----------------------------------------------------------------------------
//  SCENE MAP
//-----------------------------------------------------------------------------

Galv.TOOLS.Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
    Galv.TOOLS.Scene_Map_start.call(this);
    Galv.TOOLS.updateToolList();
};


//-----------------------------------------------------------------------------
//  GAME MAP
//-----------------------------------------------------------------------------

Galv.TOOLS.Game_Map_refresh = Game_Map.prototype.refresh;
Game_Map.prototype.refresh = function() {
    Galv.TOOLS.Game_Map_refresh.call(this);
    Galv.TOOLS.updateToolList();
};
So I need to somehow check if the variable has changed or not beforehand..
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,964
Reaction score
2,335
First Language
Dutch
Primarily Uses
RMMV
creating a var offset as 1 variable, will set x and y to 1 value.

I mean more this way:

if varable offset (is on top), than you can simply do:

JavaScript:
Sprite_ToolHud.prototype.setBitmap = function() {
    this.x = (Galv.TOOLS.hudXY[0] + eval(offset));
    this.y = (Galv.TOOLS.hudXY[1] + eval(offset));
    this.bitmap = ImageManager.loadSystem(Galv.TOOLS.hudImg);
};

than in the parameters inside the plugin,
you do $gameVariables.value(30) (for x)
and $gameVariables.value(31) (for y)

if this doesn't update correctly, I can take a look later on.
but it should refresh/update normally. as the rest should function.

EDIT:
this is what you could to update if need.
on the parameters you can set the value like this:

$gameVariables.value(30),$gameVariables.value(31)

JavaScript:
Sprite_ToolHud.prototype.update = function() {
    Sprite_Base.prototype.update.call(this);
    this.updateVisible();
    if (!$gameVariables.value(30) || !$gameVariables.value(31)) {
        this.setBitmap();
    }

};

if one of the variable number has changed, it update the setBitmap function.
I dont know if it will work, but if it doesn't, we can check further.

(feel free to change the 30 and 31 that you desire though).
 
Last edited:

Kaymon145

Veteran
Veteran
Joined
Apr 22, 2022
Messages
34
Reaction score
17
First Language
English
Primarily Uses
RMMV
creating a var offset as 1 variable, will set x and y to 1 value.

I mean more this way:

if varable offset (is on top), than you can simply do:

JavaScript:
Sprite_ToolHud.prototype.setBitmap = function() {
    this.x = (Galv.TOOLS.hudXY[0] + eval(offset));
    this.y = (Galv.TOOLS.hudXY[1] + eval(offset));
    this.bitmap = ImageManager.loadSystem(Galv.TOOLS.hudImg);
};

than in the parameters inside the plugin,
you do $gameVariables.value(30) (for x)
and $gameVariables.value(31) (for y)

if this doesn't update correctly, I can take a look later on.
but it should refresh/update normally. as the rest should function.

EDIT:
this is what you could to update if need.
on the parameters you can set the value like this:

$gameVariables.value(30),$gameVariables.value(31)

JavaScript:
Sprite_ToolHud.prototype.update = function() {
    Sprite_Base.prototype.update.call(this);
    this.updateVisible();
    if (!$gameVariables.value(30) || !$gameVariables.value(31)) {
        this.setBitmap)
    }

};

if one of the variable number has changed, it update the setBitmap function.
I dont know if it will work, but if it doesn't, we can check further.

(feel free to change the 30 and 31 that you desire though).
Ahhh that did it! And that actually helped me come up with a solution to another problem I was having as well, I always forget the eval! Thank you thank you!!
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,964
Reaction score
2,335
First Language
Dutch
Primarily Uses
RMMV
I made a small mistake in the code and updated it.
as "this.setBitmap)" instead of "this.setBitmap();"
which might caught your eyes and fixed that.

but if you have more problems and it's working, 1 problem solved :)
if the other is the same or close, what else?

if totally different, make a new thread =).
 

Kaymon145

Veteran
Veteran
Joined
Apr 22, 2022
Messages
34
Reaction score
17
First Language
English
Primarily Uses
RMMV
I made a small mistake in the code and updated it.
as "this.setBitmap)" instead of "this.setBitmap();"
which might caught your eyes and fixed that.

but if you have more problems and it's working, 1 problem solved :)
if the other is the same or close, what else?

if totally different, make a new thread =).
I actually do have a follow up question still regarding this same bit of code. Currently I have :
Code:
Sprite_ToolHud.prototype.setBitmap = function() {

    var offset = eval($gameVariables.value(30));
    if (offset = 1) {
         offsetX = 80;
         offsetY = 160;
} else {
         offsetX = 160;
         offsetY = 320;
}
    this.x = (Galv.TOOLS.hudXY[0] + eval(offsetX));
    this.y = (Galv.TOOLS.hudXY[1] + eval(offsetY));
    this.bitmap = ImageManager.loadSystem(Galv.TOOLS.hudImg);
};
Which works well to set the position according to my variable, but due to zooming the size is still off. I want to either A: Change the hudImg based on the variable or B: adjust the image size based on variable.
It looks like the part loading the image comes much earlier in the code though so I'm not sure if it can be dynamically changed during game or not.
Code:
Galv.TOOLS.hudImg = PluginManager.parameters('Galv_Tools')["HUD Image"];
Galv.TOOLS.zoom = Number(PluginManager.parameters('Galv_Tools')["Initial Zoom"]);
Galv.TOOLS.numSize = Number(PluginManager.parameters('Galv_Tools')["Number Size"]);
I tried adding the variable to it as a string and just naming my images hudimage1 hudimage2 ect but I think my syntax might have been off, I tried both
Code:
Galv.TOOLS.hudImg = PluginManager.parameters('Galv_Tools')["HUD Image" + eval($gameVariables.value(30))];
and
Galv.TOOLS.hudImg = PluginManager.parameters('Galv_Tools')["HUD Image" + ($gameVariables.value(30))];
and
Galv.TOOLS.hudImg = PluginManager.parameters('Galv_Tools')[("HUD Image") + ($gameVariables.value(30))];
All of which just cause the HUD to not appear at all. My thoughts are I'm either typing something wrong, the images are loaded on game startup and can't be altered during game, or I'm just going about this in the totally wrong way again =P
Is there a way to just add more parameters before the bitmap is drawn, like this.xScale or something similar?
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,964
Reaction score
2,335
First Language
Dutch
Primarily Uses
RMMV
if you have an eval in the code, you just have to set the eval in the plugin
parameter.

but that leaves me to another question first.

can you show a gif or small video or 2 screen when normal and when zoomed in?
otherwise, there might be a better solution.

if normal = correct, and zoomed in = incorrect (as it scale with it or move elsewhere,
there might be an advanced code required to retain in the window position with
no effect on the zooming part.
 

Kaymon145

Veteran
Veteran
Joined
Apr 22, 2022
Messages
34
Reaction score
17
First Language
English
Primarily Uses
RMMV
if you have an eval in the code, you just have to set the eval in the plugin
parameter.

but that leaves me to another question first.

can you show a gif or small video or 2 screen when normal and when zoomed in?
otherwise, there might be a better solution.

if normal = correct, and zoomed in = incorrect (as it scale with it or move elsewhere,
there might be an advanced code required to retain in the window position with
no effect on the zooming part.
HUDSIZES.png
As of now, I have 3 different zoom settings, normal, zoom 1.5, and zoom 2.0. I was able to do something similar for my battler graphics using a switch to determine what graphic is loaded, but that only worked cause theres only 2 options, I think I need to use a variable this time since there are 3 options. My code for switching things when theres only 2 options is as follows
Code:
this.bitmap = ImageManager.loadSystem(($gameSwitches.value(40) ? 'Weapons' : 'WeaponsL') + pageId);
Is there a way to just add the value of the variable on to the end of the HUD image filename as a text string? so It would look for hudimage+the value of the variable?
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,964
Reaction score
2,335
First Language
Dutch
Primarily Uses
RMMV
I think you need to update "setBitmap" function differently.
but that is a bit out of my lead.

if someone with more knowledge, he can check the zoom plugin and
Galv_Tools.js and set for example:

if: zoom >= 0 (default)
the image stays normal and doesn't zoomed in, ratain the x and y
and the screen position (like it would be inaffected), otherwise,
the normal way if it's NOT imported.

but I dont know how exactly to do that while I do JS as a hobby, so I'm no
expert into that part.

but I hope a better coder can help you achieve what you want as I try to
keep things simple as possible of what I learn and know.

I cannot help you more than this, sorry, but I wish you good luck on your project
and a better coder can help you better for some checks and zooming.
 

Kaymon145

Veteran
Veteran
Joined
Apr 22, 2022
Messages
34
Reaction score
17
First Language
English
Primarily Uses
RMMV
I think I came up with a solution! I'll post it here in case anyone else is trying to do something similar.
Code:
Sprite_ToolHud.prototype.setBitmap = function() {

    var offset = eval($gameVariables.value(30));
    if (offset = 10) {
         offsetX = 10;
         offsetY = 20;
} else if (offset = 15) {
         offsetX = 20;
         offsetY = 30;
} else {
         offsetX = 30;
         offsetY = 40;
}
    this.x = (Galv.TOOLS.hudXY[0] + eval(offsetX));
    this.scale.x = eval($gameVariables.value(30)/10);
    this.y = (Galv.TOOLS.hudXY[1] + eval(offsetY));
    this.scale.y = eval($gameVariables.value(30)/10);
    this.bitmap = ImageManager.loadSystem(Galv.TOOLS.hudImg);
};

than whenever I want to zoom in 1.5, I set variable 30 to 15 and it gets divided by 10 for the scale value. I still have to play with the offset numbers to get the correct position but its moving and changing sizes now at the right time so I think I'm on the right track =)
 

Latest Threads

Latest Profile Posts

I'm having a surprisingly easy time with the wait for Hogwarts Legacy, though I know other gamers are salivating hard.
:awat:What are you two down there doing?
This status is here just to take up space. And to make you read that.
Commenting just for the sake of commenting. :biggrin:
Just... two more to go...
dylan kickstaeter.png

Forum statistics

Threads
124,356
Messages
1,162,983
Members
163,147
Latest member
mayasmith7464
Top