| Line 173: |
Line 173: |
| | | | |
| | The game will try to find a corrosponding variable to set for the element for any other attributes you use (Rememeber case sensivity). Some elements, like the button and combo have event variable, i.e. onClick and OnSelectedChanged (use visual studio's code lookup feature to see what is possible), these can be set to function calls that will be called directly on an object you set when creating the UI, i.e. the onClick="ShowMessage(Hehe)" part. Here's an example of how you would create and use this UI: | | The game will try to find a corrosponding variable to set for the element for any other attributes you use (Rememeber case sensivity). Some elements, like the button and combo have event variable, i.e. onClick and OnSelectedChanged (use visual studio's code lookup feature to see what is possible), these can be set to function calls that will be called directly on an object you set when creating the UI, i.e. the onClick="ShowMessage(Hehe)" part. Here's an example of how you would create and use this UI: |
| − | var elements = WindowManager.GenerateUI(ParentMod.LoadFullXMLFile("UI.xml"), null, this)["lab"];
| + | <pre class="language-cs">var elements = WindowManager.GenerateUI(ParentMod.LoadFullXMLFile("UI.xml"), null, this)["lab"]; |
| − | var label = (Text)elements["lab"];
| + | var label = (Text)elements["lab"]; |
| − | Debug.log(label.text);
| + | Debug.log(label.text); |
| − | public void ShowMessage(string x)
| + | public void ShowMessage(string x) |
| − | {
| + | { |
| − | WindowManager.Instance.ShowMessageBox(x, true, DialogWindow.DialogType.Information);
| + | WindowManager.Instance.ShowMessageBox(x, true, DialogWindow.DialogType.Information); |
| − | }
| + | }</pre> |
| | | | |
| | Note that the '''parent''' parameter of '''GenerateUI''' call is null, because all the UI will be added as a child to the parent object, but since we are spawning a window, this is not necessary to define. and I'm using '''this''' for the callback parameter, so when you click the button, the method '''ShowMessage''' from this current class will be called. | | Note that the '''parent''' parameter of '''GenerateUI''' call is null, because all the UI will be added as a child to the parent object, but since we are spawning a window, this is not necessary to define. and I'm using '''this''' for the callback parameter, so when you click the button, the method '''ShowMessage''' from this current class will be called. |