User:Raiguard/Tutorial:Modding tutorial/GUI/Style guide: Difference between revisions
(Initial stub page.) |
(Rework titlebar and content frame explanations, add more images.) |
||
Line 4: | Line 4: | ||
== Window == | == Window == | ||
[[File:GUI tutorial window types.png|frame|Examples of standard vs. dialog windows.]] | |||
Windows are created using <code>standalone_inner_frame_in_outer_frame</code>. For windows that contain multiple sub-windows (e.g. most windows that hold a character inventory) <code>outer_frame</code> is used as the outer frame and <code>inner_frame_in_outer_frame</code> is used for each internal window. | Windows are created using <code>standalone_inner_frame_in_outer_frame</code>. For windows that contain multiple sub-windows (e.g. most windows that hold a character inventory) <code>outer_frame</code> is used as the outer frame and <code>inner_frame_in_outer_frame</code> is used for each internal window. | ||
Generally there are three kinds of windows: | |||
* '''Standard''' windows have a close button in the top-right corner, and are opened/closed manually either by clicking something or using a hotkey. | |||
* '''Dialog''' windows have a row of dialog buttons along the bottom, and do ''not'' have a close button. These are used when there is a clear hierarchy of actions - you go "back" to the previous action, or you "confirm" the current action. These windows '''must''' have a "Back" button in the bottom-left corner, and '''may''' have a "Confirm" button in the bottom-right corner. Other buttons on the bottom row are optional and should be used sparingly. | |||
* '''Compact''' windows have neither a titlebar nor a dialog row. These are usually mini-GUIs that are opened/closed automatically as a result of some user action. There are no set rules for these kinds of GUIs, it entirely depends on what they're used for. | |||
=== Titlebar === | === Titlebar === | ||
[[File:GUI tutorial dialog types.png|frame|Draggable vs. non-draggable windows.]] | |||
Each non-compact window '''must''' have a titlebar. All titlebars include a '''title''', and for windows that are meant to be draggable, the titlebar includes a drag handle. '''Standard''' windows also include a close button. Other frame action buttons may be added to the left of the close button, but should be used sparingly. | |||
Titlebars are created using a simple '''horizontal flow''' with no special edits - the default style is perfect for this case. | Titlebars are created using a simple '''horizontal flow''' with no special edits - the default style is perfect for this case. | ||
Line 20: | Line 25: | ||
* The "drag handle" is an <code>empty-widget</code> element with the <code>draggable_space_header</code> style. You will need to apply <code>horizontally_stretchable</code> to the element's style, and set the <code>height</code> to <code>24</code>. If adding a close button or other frame action button, set the <code>right_margin</code> to <code>4</code>. | * The "drag handle" is an <code>empty-widget</code> element with the <code>draggable_space_header</code> style. You will need to apply <code>horizontally_stretchable</code> to the element's style, and set the <code>height</code> to <code>24</code>. If adding a close button or other frame action button, set the <code>right_margin</code> to <code>4</code>. | ||
* Close buttons, or any other frame action buttons you are adding, are created with <code>sprite-button</code> using the <code>frame_action_button</code> style. The default sprite should be colored (RGB) <code>227,227,227</code>, and the hovered and clicked sprites should be colored (RGB) <code>29,29,29</code>. Custom frame action sprites should be 26x26 with a 3px padding around the edges, making for a file size of 32x32. As of the time of writing, the base game does not use mipmaps for these icons, but it would probably be a good idea to add them to your own icons just in case. | * Close buttons, or any other frame action buttons you are adding, are created with <code>sprite-button</code> using the <code>frame_action_button</code> style. The default sprite should be colored (RGB) <code>227,227,227</code>, and the hovered and clicked sprites should be colored (RGB) <code>29,29,29</code>. Custom frame action sprites should be 26x26 with a 3px padding around the edges, making for a file size of 32x32. As of the time of writing, the base game does not use mipmaps for these icons, but it would probably be a good idea to add them to your own icons just in case. | ||
* <code>drag_target</code> should be set | * When creating draggable windows, <code>drag_target</code> should be set on the flow element that comprises the titlebar, not the "drag handle" itself. | ||
* If your window is not in <code>screen</code> or is otherwise non-draggable, '''DO NOT''' add a drag handle. Instead, use an <code>empty-widget</code> with <code>horizontally_stretchable</code> enabled. | * If your window is not in <code>screen</code> or is otherwise non-draggable, '''DO NOT''' add a drag handle. Instead, use an <code>empty-widget</code> with <code>horizontally_stretchable</code> enabled. | ||
=== Content frame === | === Content frame === | ||
Each non-compact window '''must''' have a "content frame" (the light grey pane seen in the above screenshots). This is where the meat of your interface will go. | |||
Content frames are created using the <code>inside_shallow_frame_with_padding</code> style. This will give you 12px of padding in the frame. If you need to have zero padding, use <code>inside_shallow_frame</code> instead. | |||
[[File:GUI tutorial content frame with padding.png|frame|An example of <code>inside_shallow_frame_with_padding</code>, demonstrating the built-in 12px padding.]] | |||
'''TO BE CONTINUED''' | '''TO BE CONTINUED''' |
Revision as of 03:35, 30 May 2020
This style guide is designed to give you an overview of the precepts and specific element styles used to create 0.18-esque GUIs. This guide is not to be taken as gospel - the contents are merely suggestions to help you improve your interfaces.
This style guide assumes you know how to create GUIs, assign styles to elements, and edit styles. If you do not know these things, this guide won't be of much use to you.
Window
Windows are created using standalone_inner_frame_in_outer_frame
. For windows that contain multiple sub-windows (e.g. most windows that hold a character inventory) outer_frame
is used as the outer frame and inner_frame_in_outer_frame
is used for each internal window.
Generally there are three kinds of windows:
- Standard windows have a close button in the top-right corner, and are opened/closed manually either by clicking something or using a hotkey.
- Dialog windows have a row of dialog buttons along the bottom, and do not have a close button. These are used when there is a clear hierarchy of actions - you go "back" to the previous action, or you "confirm" the current action. These windows must have a "Back" button in the bottom-left corner, and may have a "Confirm" button in the bottom-right corner. Other buttons on the bottom row are optional and should be used sparingly.
- Compact windows have neither a titlebar nor a dialog row. These are usually mini-GUIs that are opened/closed automatically as a result of some user action. There are no set rules for these kinds of GUIs, it entirely depends on what they're used for.
Titlebar
Each non-compact window must have a titlebar. All titlebars include a title, and for windows that are meant to be draggable, the titlebar includes a drag handle. Standard windows also include a close button. Other frame action buttons may be added to the left of the close button, but should be used sparingly.
Titlebars are created using a simple horizontal flow with no special edits - the default style is perfect for this case.
- The title text is a
label
using theframe_title
style. - The "drag handle" is an
empty-widget
element with thedraggable_space_header
style. You will need to applyhorizontally_stretchable
to the element's style, and set theheight
to24
. If adding a close button or other frame action button, set theright_margin
to4
. - Close buttons, or any other frame action buttons you are adding, are created with
sprite-button
using theframe_action_button
style. The default sprite should be colored (RGB)227,227,227
, and the hovered and clicked sprites should be colored (RGB)29,29,29
. Custom frame action sprites should be 26x26 with a 3px padding around the edges, making for a file size of 32x32. As of the time of writing, the base game does not use mipmaps for these icons, but it would probably be a good idea to add them to your own icons just in case. - When creating draggable windows,
drag_target
should be set on the flow element that comprises the titlebar, not the "drag handle" itself. - If your window is not in
screen
or is otherwise non-draggable, DO NOT add a drag handle. Instead, use anempty-widget
withhorizontally_stretchable
enabled.
Content frame
Each non-compact window must have a "content frame" (the light grey pane seen in the above screenshots). This is where the meat of your interface will go.
Content frames are created using the inside_shallow_frame_with_padding
style. This will give you 12px of padding in the frame. If you need to have zero padding, use inside_shallow_frame
instead.
TO BE CONTINUED