## expcore.gui.prototype module

Used to create new gui prototypes see elements and concepts [[

### Dependencies

utils.game
expcore.store
expcore.gui.instances

### Functions

Constructor.event(event_name) | Creates a new function to add functions to an event handler
Constructor.extend(new_prototype) | Extents a prototype with the base functions of all gui prototypes, no metatables
Constructor.store(sync, callback) | Creates a new function which adds a store to a gui define
Constructor.setter(value_type, key[, second_key]) | Creates a setter function that checks the type when a value is set
Prototype:uid() | Gets the uid for the element define
Prototype:set_style(style[, function]) | Sets the style for the element define
Prototype:set_embedded_flow(boolean) | Sets the element to be drawn inside a nameless flow, can be given a name using a function
Prototype:raise_event(event_name, ...) | Raises a custom event for this define, any number of params can be given
Prototype:draw_to(element) | The main function for defines, when called will draw an instance of this define to the given element what is drawn is based on the data in draw_data which is set using other functions
Prototype:get_store(category) | Gets the value in this elements store, category needed if categorize function used
Prototype:set_store(category, value) | Sets the value in this elements store, category needed if categorize function used
Prototype:clear_store([category]) | Sets the value in this elements store to nil, category needed if categorize function used

### Fields

Prototype.debug_name | Sets a debug alias for the define
Prototype.set_caption | Sets the caption for the element define
Prototype.set_tooltip | Sets the tooltip for the element define
Prototype.set_pre_authenticator | Sets an authenticator that blocks the draw function if check fails
Prototype.set_post_authenticator | Sets an authenticator that disables the element if check fails
Prototype.on_draw | Registers a callback to the on_draw event
Prototype.on_style_update | Registers a callback to the on_style_update event

### Dependencies

# utils.game
# expcore.store
# expcore.gui.instances

### Functions

# Constructor.event(event_name)

  Creates a new function to add functions to an event handler

  Parameters:
  - event_name : (string) the name of the event that callbacks will be added to
  Returns:
  - (function) the function used to register handlers
# Constructor.extend(new_prototype)

  Extents a prototype with the base functions of all gui prototypes, no metatables

  Parameters:
  - new_prototype : (table) the prototype that you want to add the functions to
  Returns:
  - (table) the same prototype but with the new functions added
# Constructor.store(sync, callback)

  Creates a new function which adds a store to a gui define

  Parameters:
  - sync : (boolean) if the function should create a synced store
  - callback : (function) the function called when needing to update the value of an element
  Returns:
  - (function) the function that will add a store for this define
# Constructor.setter(value_type, key[, second_key])

  Creates a setter function that checks the type when a value is set

  Parameters:
  - value_type : (string) the type that the value should be when it is set
  - key : (string) the key of the define that will be set
  - second_key : (string) allows for setting of a key in a sub table (optional)
  Returns:
  - (function) the function that will check the type and set the value
# Prototype:uid()

  Gets the uid for the element define

  Returns:
  - (string) the uid of this element define
# Prototype:set_style(style[, function])

  Sets the style for the element define

  Parameters:
  - style : (string) the style that will be used for this element when drawn
  - function : (callback) function is called when element is drawn to alter its style (optional)
  Returns:
  - (self) the element define to allow chaining
# Prototype:set_embedded_flow(boolean)

  Sets the element to be drawn inside a nameless flow, can be given a name using a function

  Parameters:
  - boolean : (state) |function when true a padless flow is created to contain the element
  Returns:
  - (self) the element define to allow chaining
# Prototype:raise_event(event_name, ...)

  Raises a custom event for this define, any number of params can be given

  Parameters:
  - event_name : (string) the name of the event that you want to raise
  - ... : (any) any params that you want to pass to the event
  Returns:
  - (number) the number of handlers that were registered
# Prototype:draw_to(element)

  The main function for defines, when called will draw an instance of this define to the given element what is drawn is based on the data in draw_data which is set using other functions

  Parameters:
  - element : (LuaGuiElement) the element that the define will draw a instance of its self onto
  Returns:
  - (LuaGuiElement) the new element that was drawn
# Prototype:get_store(category)

  Gets the value in this elements store, category needed if categorize function used

  Parameters:
  - category : (string) [opt] the category to get such as player name or force name
  Returns:
  - (any) the value that is stored for this define
# Prototype:set_store(category, value)

  Sets the value in this elements store, category needed if categorize function used

  Parameters:
  - category : (string) [opt] the category to get such as player name or force name
  - value : (any) the value to set for this define, must be valid for its type ie for checkbox etc
  Returns:
  - (boolean) true if the value was set
# Prototype:clear_store([category])

  Sets the value in this elements store to nil, category needed if categorize function used

  Parameters:
  - category : (string) the category to get such as player name or force name (optional)
  Returns:
  - (boolean) true if the value was set

### Fields

# Prototype.debug_name

  Sets a debug alias for the define

  - name : (string) the debug name for the element define that can be used to get this element define
# Prototype.set_caption

  Sets the caption for the element define

  - caption : (string) the caption that will be drawn with the element
# Prototype.set_tooltip

  Sets the tooltip for the element define

  - tooltip : (string) the tooltip that will be displayed for this element when drawn
# Prototype.set_pre_authenticator

  Sets an authenticator that blocks the draw function if check fails

  - callback : (function) the function that will be ran to test if the element should be drawn or not callback param - LuaPlayer player - the player that the element is being drawn to callback param - string define_name - the name of the define that is being drawn callback return - boolean - false will stop the element from being drawn
# Prototype.set_post_authenticator

  Sets an authenticator that disables the element if check fails

  - callback : (function) the function that will be ran to test if the element should be enabled or not callback param - LuaPlayer player - the player that the element is being drawn to callback param - string define_name - the name of the define that is being drawn callback return - boolean - false will disable the element
# Prototype.on_draw

  Registers a callback to the on_draw event

  - callback : (function) callback param - LuaPlayer player - the player that the element was drawn to callback param - LuaGuiElement element - the element that was drawn callback param - any ... - any other params passed by the draw_to function
# Prototype.on_style_update

  Registers a callback to the on_style_update event

  - callback : (function) callback param - LuaStyle style - the style that was changed and/or needs changing