| Line 172: |
Line 172: |
| | You can also use the '''id''' attribute to reference the element in your code after the UI has been loaded. | | You can also use the '''id''' attribute to reference the element in your code after the UI has been loaded. |
| | | | |
| − | The game will try to find a corrosponding variable to set for the element for any other attributes you use (Remember case sensitivity). Some elements, like the '''button''', '''input''' and '''combo''' have event variables, i.e. '''onClick''', '''onValueChanged''' 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 (Remember case sensitivity). Some elements, like the '''button''', '''input''' and '''combo''' have event variables, i.e. '''onClick''', '''onValueChanged''' 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)" and OnSelectedChanged="ShowMessageCombo(this)" part. Note that using "this" will refer to the actual component the tag represents. Here's an example of how you would create and use this UI: |
| | <pre class="language-cs">var elements = WindowManager.GenerateUI(ParentMod.LoadFullXMLFile("UI.xml"), null, this); | | <pre class="language-cs">var elements = WindowManager.GenerateUI(ParentMod.LoadFullXMLFile("UI.xml"), null, this); |
| | var label = (Text)elements["lab"]; | | var label = (Text)elements["lab"]; |
| Line 179: |
Line 179: |
| | { | | { |
| | WindowManager.Instance.ShowMessageBox(x, true, DialogWindow.DialogType.Information); | | WindowManager.Instance.ShowMessageBox(x, true, DialogWindow.DialogType.Information); |
| | + | } |
| | + | |
| | + | public void ShowMessageCombo(GUICombobox x) |
| | + | { |
| | + | WindowManager.Instance.ShowMessageBox(x.SelectedItemString, true, DialogWindow.DialogType.Information); |
| | }</pre> | | }</pre> |
| | | | |