Jump to content
  • 0

GUI - Move entity to different .json file


Ainz Ooal Gown

Question

Hi All,

 

Is there a way to move an entity from one .json to another?

 

I am currently working on my UI, and I have the need to move the experience bar from the PlayerBox.json to the HotbarWindow.json. Is this possible?

 

I tried to move the code, but didnt think it would be as easy as that. I then checked the source, but cant see anything that would allow the move...

 

Spoiler

3735e0761a55d209323af0dbbce66889.png

 

I know its this I need to move to HotbarWindow.json, from the PlayerBox.json

Spoiler

            "EXPBackground": {
          "Bounds": "13,9,168,16",
          "Padding": "0,0,0,0",
          "AlignmentEdgeDistances": "0,0,0,0",
          "AlignmentTransform": "0,0",
          "Margin": "0,0,0,0",
          "RenderColor": "255,255,255,255",
          "Alignments": "",
          "DrawBackground": true,
          "MinimumSize": "1,1",
          "MaximumSize": "4096,4096",
          "Disabled": false,
          "Hidden": false,
          "RestrictToParent": false,
          "MouseInputEnabled": true,
          "HideToolTip": false,
          "ToolTipBackground": null,
          "ToolTipFont": null,
          "ToolTipTextColor": "",
          "Texture": "",
          "HoverSound": null,
          "LeftMouseClickSound": null,
          "RightMouseClickSound": null
        },
        "EXPBar": {
          "Bounds": "0,0,168,14",
          "Padding": "0,0,0,0",
          "AlignmentEdgeDistances": "0,0,0,0",
          "AlignmentTransform": "0,0",
          "Margin": "0,0,0,0",
          "RenderColor": "255,255,255,255",
          "Alignments": "",
          "DrawBackground": true,
          "MinimumSize": "1,1",
          "MaximumSize": "4096,4096",
          "Disabled": false,
          "Hidden": true,
          "RestrictToParent": false,
          "MouseInputEnabled": true,
          "HideToolTip": false,
          "ToolTipBackground": null,
          "ToolTipFont": null,
          "ToolTipTextColor": "",
          "Texture": "expbar.png",
          "HoverSound": null,
          "LeftMouseClickSound": null,
          "RightMouseClickSound": null
        },
        "EXPTitle": {
          "Bounds": "95,95,27,16",
          "Padding": "0,0,0,0",
          "AlignmentEdgeDistances": "0,0,0,0",
          "AlignmentTransform": "0,0",
          "Margin": "0,0,0,0",
          "RenderColor": "255,255,255,255",
          "Alignments": "",
          "DrawBackground": true,
          "MinimumSize": "1,1",
          "MaximumSize": "4096,4096",
          "Disabled": false,
          "Hidden": false,
          "RestrictToParent": false,
          "MouseInputEnabled": false,
          "HideToolTip": false,
          "ToolTipBackground": null,
          "ToolTipFont": null,
          "ToolTipTextColor": "",
          "BackgroundTemplate": null,
          "TextColor": "255,255,255,255",
          "HoveredTextColor": "",
          "ClickedTextColor": "",
          "DisabledTextColor": "255,90,90,90",
          "TextAlign": "Left, Top",
          "TextPadding": "0,0,0,0",
          "AutoSizeToContents": true,
          "Font": "sourcesansproblack,10",
          "TextScale": 1.0
        },
        "EXPLabel": {
          "Bounds": "130,95,168,16",
          "Padding": "0,0,0,0",
          "AlignmentEdgeDistances": "0,0,0,0",
          "AlignmentTransform": "0,0",
          "Margin": "0,0,0,0",
          "RenderColor": "255,255,255,255",
          "Alignments": "",
          "DrawBackground": true,
          "MinimumSize": "1,1",
          "MaximumSize": "4096,4096",
          "Disabled": false,
          "Hidden": false,
          "RestrictToParent": false,
          "MouseInputEnabled": false,
          "HideToolTip": false,
          "ToolTipBackground": null,
          "ToolTipFont": null,
          "ToolTipTextColor": "",
          "BackgroundTemplate": null,
          "TextColor": "255,255,255,255",
          "HoveredTextColor": "",
          "ClickedTextColor": "",
          "DisabledTextColor": "255,90,90,90",
          "TextAlign": "Center",
          "TextPadding": "0,0,0,0",
          "AutoSizeToContents": false,
          "Font": "sourcesansproblack,10",
          "TextScale": 1.0
        },

 

If anyone can point me in the right direction that would be great :)

 

Thanks

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 2

Patch File <-- Open in new tab, right click, and save as...

 

Ok, so I don't know if you have modified the EntityBox.cs file or the HotBar.cs file, but I am going to give you a patch file I just made that should work. If it doesn't apply, I will try to help you modify the code to make it work if you are having trouble.

 

The patch file pretty much just moves anything related to the ExpBar over to the HotBar.cs file. Since the ExpBar is only drawn for us, we can completely remove it from the EntityBox.cs file since we don't need to draw it for other entities. In addition to moving some variables and methods over, it also deletes the section of code that runs the update method since we need to update it in the HotBar.cs file now. Along with that, it removes any lines of code that hide the ExpBar if it is an entity other than ourselves (since it no longer exists in the EntityBox).

 

As for how the json files work, when you create an ImagePanel, Label, or other similar objects, you specify the parent object that it is attached to along with the name you want displayed in the json file. When looking through the json files, you will see that some things are children of something else, thats because those children used that object as their parent in the code. So something like this:

 

    ExpBackground = new ImagePanel(HotbarWindow, "EXPBackground");

 

Creates a new ImagePanel object named ExpBackground with the parent HotbarWindow and is named EXPBackground in the json file. When you modify the bounds or alignment of EXPBackground now, it is in reference to the HotbarWindow. At the end of the initialization, the code will deserialize and you will get the resulting json file.

 

Once you apply the patch and build, you will need to modify your HotbarWindow.json file to fit your needs. I would recommend keeping a backup of the original TargetBox.json file so you can reference the width, height, and other settings of the ExpBar since after you build, it wil be deleted from TargetBox.json. Hope this helps and sorry I'm a bit late, just saw this about an hour ago.

 

@ me if you have any questions and I'll will try to help as much as possible.

 

 

 

Link to comment
Share on other sites

  • 0
33 minutes ago, jcsnider said:

You'd have to move the entire code elements from the entitybox window to the hotbarwindow and then the logic that controls them. It is 95% code based changes.

 

So basically move all below from EntityBox.cs (and everything it relates to):

Spoiler

            ExpBackground = new ImagePanel(EntityInfoPanel, "EXPBackground");
            ExpBar = new ImagePanel(EntityInfoPanel, "EXPBar");
            ExpTitle = new Framework.Gwen.Control.Label(EntityInfoPanel, "EXPTitle");
            ExpTitle.SetText(Strings.EntityBox.exp);
            ExpLbl = new Framework.Gwen.Control.Label(EntityInfoPanel, "EXPLabel");

 

To HotBar.cs, in the //Init section?

 

Then move the code in the .json files over?

 

Sorry still learning :P

Link to comment
Share on other sites

  • 0
On 6/26/2020 at 5:19 AM, CCarrMcMahon said:

Patch File <-- Open in new tab, right click, and save as...

 

Ok, so I don't know if you have modified the EntityBox.cs file or the HotBar.cs file, but I am going to give you a patch file I just made that should work. If it doesn't apply, I will try to help you modify the code to make it work if you are having trouble.

 

The patch file pretty much just moves anything related to the ExpBar over to the HotBar.cs file. Since the ExpBar is only drawn for us, we can completely remove it from the EntityBox.cs file since we don't need to draw it for other entities. In addition to moving some variables and methods over, it also deletes the section of code that runs the update method since we need to update it in the HotBar.cs file now. Along with that, it removes any lines of code that hide the ExpBar if it is an entity other than ourselves (since it no longer exists in the EntityBox).

 

As for how the json files work, when you create an ImagePanel, Label, or other similar objects, you specify the parent object that it is attached to along with the name you want displayed in the json file. When looking through the json files, you will see that some things are children of something else, thats because those children used that object as their parent in the code. So something like this:

 

    ExpBackground = new ImagePanel(HotbarWindow, "EXPBackground");

 

Creates a new ImagePanel object named ExpBackground with the parent HotbarWindow and is named EXPBackground in the json file. When you modify the bounds or alignment of EXPBackground now, it is in reference to the HotbarWindow. At the end of the initialization, the code will deserialize and you will get the resulting json file.

 

Once you apply the patch and build, you will need to modify your HotbarWindow.json file to fit your needs. I would recommend keeping a backup of the original TargetBox.json file so you can reference the width, height, and other settings of the ExpBar since after you build, it wil be deleted from TargetBox.json. Hope this helps and sorry I'm a bit late, just saw this about an hour ago.

 

@ me if you have any questions and I'll will try to help as much as possible.

 

 

 

 

Wow! Thanks buddy, sorry Ive just seen this post (been busy with work) and thanks for the reply. I will give this a go and let you know :)

Link to comment
Share on other sites

  • 0
On 6/26/2020 at 5:19 AM, CCarrMcMahon said:

Patch File <-- Open in new tab, right click, and save as...

 

Ok, so I don't know if you have modified the EntityBox.cs file or the HotBar.cs file, but I am going to give you a patch file I just made that should work. If it doesn't apply, I will try to help you modify the code to make it work if you are having trouble.

 

The patch file pretty much just moves anything related to the ExpBar over to the HotBar.cs file. Since the ExpBar is only drawn for us, we can completely remove it from the EntityBox.cs file since we don't need to draw it for other entities. In addition to moving some variables and methods over, it also deletes the section of code that runs the update method since we need to update it in the HotBar.cs file now. Along with that, it removes any lines of code that hide the ExpBar if it is an entity other than ourselves (since it no longer exists in the EntityBox).

 

As for how the json files work, when you create an ImagePanel, Label, or other similar objects, you specify the parent object that it is attached to along with the name you want displayed in the json file. When looking through the json files, you will see that some things are children of something else, thats because those children used that object as their parent in the code. So something like this:

 

    ExpBackground = new ImagePanel(HotbarWindow, "EXPBackground");

 

Creates a new ImagePanel object named ExpBackground with the parent HotbarWindow and is named EXPBackground in the json file. When you modify the bounds or alignment of EXPBackground now, it is in reference to the HotbarWindow. At the end of the initialization, the code will deserialize and you will get the resulting json file.

 

Once you apply the patch and build, you will need to modify your HotbarWindow.json file to fit your needs. I would recommend keeping a backup of the original TargetBox.json file so you can reference the width, height, and other settings of the ExpBar since after you build, it wil be deleted from TargetBox.json. Hope this helps and sorry I'm a bit late, just saw this about an hour ago.

 

@ me if you have any questions and I'll will try to help as much as possible.

 

 

 

 

Hey buddy, thanks for the patch it works perfectly!!

 

e55bab21c2fa16ed72d20718be573779.png

 

Really appriciate it :)

Link to comment
Share on other sites

×
×
  • Create New...