Tutorial:Context Viewer (Warhammer 3): Difference between revisions

From Total War Modding
(How to use the context viewer)
mNo edit summary
Line 17: Line 17:




Keep in mind: the context viewer won't always be stable. There are elements, context object types, and operations which will crash your game.
The context viewer appears in the centre of the screen by default but can be dragged around as you please.  
 
 




Keep in mind: the context viewer won't always be stable. There are elements, context object types, and operations which will crash your game.


== Using the Context Viewer ==
== Using the Context Viewer ==

Revision as of 09:23, 30 March 2022

The context viewer is a CA hack that can be activated in the settings menu in Total War: Warhammer 3.


You already knew that, of course, because you've been using it to cheat in your single player games.

But what you might not know is you can also use it to make UI mod creation easier. This guide is intended to teach you how to use the viewer and outline some places it can make the UI Modding workflow easier.

This guide is intended to provide examples of how to use this tool. Depending what you're using it for, you may want to first familiarize yourself with Component Context Objects.

Enabling the Context Viewer

options > settings > Modding > enable context viewer

To enable the context viewer, simply open the settings menu, hit the gear icon (fourth down on the left side menu), and then check the box under Modding.


You can now open the context viewer in game using your ` key. That's right above tab, to the left of 1, on a standard keyboard.


The context viewer appears in the centre of the screen by default but can be dragged around as you please.



Keep in mind: the context viewer won't always be stable. There are elements, context object types, and operations which will crash your game.

Using the Context Viewer

The Documentation folder in the game's data packfile has two documentation files: an HTML file which we will refer to as the Component Context Object documentation, or CCO Documentation, and a short microsoft word file called context_viewer_doc, which explains how to use the context viewer.

Context Viewer Guide.png

The image on the right shows the different key areas of the context viewer numbered 1 through 8. Here is a breakdown of these areas:

  1. You can press the context menu button to open the context menu on the left. This provides a handy list of shortcuts to get started with investigating the game state.  These shortcuts are tailored to each game area. There is also a list of all exposed database contexts.
  2. You can press the Component tree button to open up the component tree view on the right hand side, this shows the whole UI hierarchy which is useful for inspecting and manipulating the game UI
  3. You can press the Events button to open up the events viewer on the right hand side (same space that the component tree occupies).  While open you can see events appear in the list as they fire from the game.
  4. You can press the help button to easily access the documentation, which includes this document as well as the documentation for all the exposed context types
  5. The centre of the panel is where the information for the current inspect context is shown. Queries are shown first, followed by commands which are shown as buttons.
  6. This text input is where you can write out ‘context expressions’ to perform more advanced queries/commands. You will note some command buttons are disabled and have arguments next to their names.  These can only be performed by using this text input since you can type out the command and pass any relevant parameters to the command to be performed. We often refer to this as the expression tester.
  7. You can press the back button to easily return to the previous inspected contexts
  8. You can press the refresh button to get the most up to date information for the current inspected context. Most information is updated live automatically, except for any queries returning other contexts or lists of contexts.

·

Furthermore, while the context viewer is open, you can middle mouse click on the following to inspect the context for that object immediately:

  • UI objects
  • Battle units
  • Battle buildings
  • Campaign characters
  • Campaign settlements

You can additionally hold the ALT key while middle clicking components to select from a list of all components under the Mouse. This is useful for when multiple components overlap eachother.

Example Usages

Here are some common tasks the UI Context Viewer can help with.

Gathering UI Path/GUIDs for Scripting/XML Editing

Context viewer copy 2.jpg

When you are scripting using UI elements you often require the path from the root component to a given component you want to work with.

To use the context viewer to make this easier, use the component tree to navigate to the component that you are looking for.

Then use CopyFullPathToClipboard() in the expression tester box. You can now paste this into your scripts.

You can also use the related CopyStringToClipboard(GuidOriginal()) to copy the GUID - this can be used to find the component with the twui.xml files.