Author Topic: Blockland fails to do math when setting the Y position of a GUI  (Read 906 times)


Only works after the 2nd time PlayGUI is awoken. On the 1st time it does this stuff.
The X position of 319 is fine, it's that 916 that makes no sense.

getRes(); does the same thing.

Putting this in the position field when the swatch control is being made also results in 916.
10ms after PlayGUI is awoken also results in 916.
Moving the resize command above the parent results in 916.

Echoing the math results gives 628, which is what it should be with a height of 768.

I don't understand.

Code: [Select]
   function PlayGui::onWake(%this,%a,%b,%c)
   {
      parent::onWake(%this,%a,%b,%c);
      MiningHUD.schedule(10,resize,(getWord($pref::Video::resolution,0)-386)/2,getWord($pref::Video::resolution,1)-140,386,104);
   }

As far as I can tell, client mods are run before the graphical interface is truly "loaded". You can see a black box of the correct size, but Blockland doesn't finish initializing the game window until after every client add-on has already loaded.

Or in other words:

GUI.extent = 350 SPC $TheWidth;
$TheWidth = 800;

As far as I can tell, client mods are run before the graphical interface is truly "loaded". You can see a black box of the correct size, but Blockland doesn't finish initializing the game window until after every client add-on has already loaded.

Or in other words:

GUI.extent = 350 SPC $TheWidth;
$TheWidth = 800;
I don't... what?

Regardless, that shouldn't be returning 916. $pref::Video::resolution never changes unless you change your resolution.
This needs to work on resolutions other than 1024 and 800 as I know not everyone uses them.

Why use a package?

In your GUI, just do this:
Code: [Select]
new GuiControl(yourGUI) {
   position = (getWord($pref::Video::resolution,0)-386)/2 SPC getWord($pref::Video::resolution,1)-140;
   extent = "386 104";
   //other stuff here
};

I tested this and $Pref::Video::Resolution is set properly.

Why use a package?

In your GUI, just do this:
Code: [Select]
new GuiControl(yourGUI) {
   position = (getWord($pref::Video::resolution,0)-386)/2 SPC getWord($pref::Video::resolution,1)-140;
   extent = "386 104";
   //other stuff here
};

I tested this and $Pref::Video::Resolution is set properly.
I was doing that
Code: [Select]
//--- OBJECT WRITE BEGIN ---
   %HUD = new GuiSwatchCtrl(MiningHUD) {
      profile = "GuiDefaultProfile";
      horizSizing = "center";
      vertSizing = "top";
      //position = "127 340";
      position = (getWord($pref::Video::resolution,0)-386)/2 SPC getWord($pref::Video::resolution,1)-140;

Fixed it anyways, moved that into PlayGui::onRender and it's working fine.