-
Notifications
You must be signed in to change notification settings - Fork 9
SHORTTUTORIAL: Widgets
RimWorld Widgets are the graphical user interface controls that you use throughout the game.
Important Things To Know:
- Unlike most UI programming these days, RimWorld.Widgets are not declarative! Other UI system like HTML have you declare a button and all the repaint and redraw functionality is handled by the widget. In RimWorld, your drawing of the widgets is occurring while handling events so you are not dealing with callback handling.
- RimWorld's Widgets sit on top of the Unity GUI scripting.
Quick Impressions:
- Using RimWorld Widgets ensures that all your controls look like the rest of RimWorld.
- In general, RimWorld has a ton of widgets so you should famliarize yourself with the Verse.Widgets class.
-
Primitives
- Line (multiple versions)- draws a line from A to B
- Box (multiple versions)- draws a box on the screen
- ThingIcon - draws the Thing's uiIcon at a location
-
Label, LabelScrollable
- ListSeparator - draws a header for a list and an underline to space it from the list below it
-
Buttons
- Button
- RadioButton
- RadioButtonLabeled,
- ButtonText
- ButtonImage
- CloseButtonFor (a rect),
- Checkbox,
- CheckboxLabeled,
- CheckboxLabeledSelectable (statefulbutton?),
- CheckboxMulti,
-
Text Input
- TextField
- TextFieldNumeric,
- TextFieldNumericLabeled,
- TextFieldPercent,
- TextArea
- TextAreaScrollable
- TextEntryLabeled
- TextField
-
Sliders
- HorizontalSlider
- FrequencyHorizontalSlider,
-
Range ?
- FloatRange,
- IntRange,
- QualityRange,
- FloatRangeWithTypeIn,
-
Bar
- FillableBar,
- FillableBarLabeled,
- FillableBarChangeArrows,
-
Decorations and Feedback *
-
Don't Use
- DrawWindowBackground - called by Page and Window classes, not your code
- DrawMenuSection - sets up an area to look like a menu
, DrawWindowBackgroundTutor, DrawShadowAround, DrawAtlas, ScrollHorizontal, BeginScrollView, EndScrollView, DrawHighlightSelected, DrawHighlightIfMouseOver, DrawHighlight, DrawTitleBG,
InfoCardButton, InfoCardButtonWorker,
DrawTextureRotated, DrawTextureFitted,
ToUVRect, DrawTexturePart
The Event
is a global class that from the UnityEngine. Calling Event.get_current() will give you the currently operating event, from which you can get_keyCode() or get_type().
Here is a listing of the types: UnityEngine EventType. The numbers in RimWorld start at zero and increment, so MouseDown is 0, MouseUp is 1, KeyDown is 4, ScrollWheel is 6, etc.
- ListingStandard - helps to organize widget layout