FreshGUI v2.1
The graphical user interface designed for games
New version released! Please update to v2.1b if you are using a previous version of FreshGUI!
Latest Version: FreshGUI v2.1b
Changelog
/i]
FreshGUI Changelog
v2.1b - MINOR UPDATE
================================================================
CONTRIBUTOR: CALEB GOFF (outSync)
- Added FUI_GetGadgetHeight() command, which returns the height of the specified gadget.
- Added FUI_GetGadgetWidth() command, which returns the width of the specified gadget.
- Added FreshGUI keywords file.
- Added FreshGUI help files.
- Fixed problem with FUI_ExistError function.
- Launched Official FreshGUI webspace (http://myopia.c-reality.com/pages/FreshGUI.html)
v2.1 - MAJOR UPDATE
================================================================
CONTRIBUTOR: CALEB GOFF (outSync)
- Added gadget CheckBox
RELATED INFORMATION:
- [Added] FUI_GetChecked(handle): returns the "checked" value of the specified Checkbox gadget (0 = unchecked, 1 = checked)
- [Added] FUI_SetChecked(handle): sets the "checked" value of the specified Checkbox gadget (0 = unchecked, 1 = checked)
- [Updated] All "general" gadget commands, like GetText, SetText, and PositionGadget, support the new Checkbox gadgets
- Added gadget Menu Box
Menu boxes allow a little more style for creating a menu of buttons, unlike the standard Box gadget. These gadgets are similiar in look, but allow for a
title string to be placed at the top, and look a bit more like List Boxes than regular Boxes.
RELATED INFORMATION:
- [Updated] All "general" gadget commands, like GetText, SetText, and PositionGadget, support the new Menu Box gadgets
- Added gadget Progress Bar
Progress Bars allow you to give users a report of the progress of a specific action, like loading a game map, or various media elements of a project. This is
not done automatically, but you're given multiple functions to manage the progress bar. There are two styles for progress bars, one just has a regular fill-in
"loading bar" and the other style is essentially the same, except it displays a text readout of the progress in the middle (e.g., "25%").
RELATED INFORMATION:
- [Added] FUI_SetProgressBarPos(handle,pos): sets the position of the progress bar, and must be a value equal to, or between 0 and 100
- [Added] FUI_GetProgressBarPos(handle): returns the position of the progress bar, and will be a value equal to, or between 0 and 100
- [New] A style value of 2 will display a text readout, while any other value will cause the progress bar to default to the standard style
- [Updated] All "general" gadget commands, like GetText, SetText, and PositionGadget, support the new Progress Bar gadgets
- Added Gadget Packs
Gadgets can now be grouped together into "packs," which allow multiple gadgets to be dealt with using single commands. Packs can have
an unlimited amount of gadgets assigned to them. Take note that the state of the Pack affects the state of all the gadgets assigned to it.
Setting the visibility of a Pack with three buttons assigned to it to 0 (hidden) will hide all of the buttons, even if their personal visibility
state of 1 (visible). Gadgets will automatically unassign themselves from their previous pack if the pack is deleted (and revert to their personal
states). See FreshGUI-Example.DBA for an in-action example of Gadget Packs.
RELATED INFORMATION:
- [Added] FUI_MakeGadgetPack(): creates a new gadget Pack and returns the handle (for developer reference, Packs are handled much like Radiobutton Groups)
- [Added] FUI_AssignPack(handle,packHandle): assigns the specified gadget ("handle") to the specified pack ("packHandle")
- [Added] FUI_GetPackVisible(packHandle): returns the visibility state of the specified pack ("packHandle") (0 = hidden, 1 = visible)
- [Added] FUI_SetPackVisible(packHandle): sets the visibility state of the specified pack ("packHandle") (0 = hidden, 1 = visible)
- [Added] FUI_DeletePack(packHandle): this will delete the specified pack, and all gadgets assigned to that pack will automatically be unassigned
- [Added] FUI_UnassignPack(handle): this will unassign the specified gadget from any pack it currently belongs to
- [Added] FUI_PackExist(packHandle): returns a 0 if the pack does not exist, a 1 if it does exist
- [Added] FUI_GetGadgetPack(handle): returns either a 0 if the specified gadget does not belong to a pack, or the handle of the pack the gadget belongs to
- Added enhanced template control
RELATED INFORMATION:
- [Added] Each gadget now uses its own individual font, specified in the template INI files.
- [Added] Gadgets now automatically adjust to fit the specified font style and font gadget
- Modified Radiobuttons so they are round instead of square
- All constants utilized by FreshGUI now have an "fui" prefix, eliminating the possibility of code conflicts. Constants remained the same,
as the chances for conflicts in those is minimal. FreshGUI documentation now contains a list of the globals and constants used, for developer
reference.
- Added Style field for buttons, so you can specify a "regular" button, which is just the text, or a "box" button, which has a box background
styled with the theme. This adds another argument to the FUI_MakeButton command, and either a "0" (regular butt,n) or a "1" (box button) should
be passed for that argument's value. The button section in template INI files now includes the Primary, Secondary Color & Alpha fields.
- New group listings, so FUI_GetGadgetGroup can now also return g_checkboxes, g_progressbars, and g_menuboxes.
- Updated the FreshGUI-Example.DBA file to reflect the latest changes, and use the new gadgets.
================================================================
CONTRIBUTOR: Joseph Thomson (Hamish McHaggis)
Major adjustments:
- Handles system introduced where a unique ID for each gadget is
returned from its creation function. These handles contain both
the index data (what was the old gadget number) and the group
the gadget belongs to (e.g. g_boxes, or g_inputs).
Old: FUI_MakeBox(1,5,5,110,100)
FUI_DeleteGadget(1,g_boxes)
New: Box = FUI_MakeBox(5,5,110,100)
FUI_DeleteGadget(Box)
- Refined mouse-gadget interfacing. New global gadget_clicked,
gadget_held and gadget_hovered variables mean only one gadget
can be clicked, held or hovered at one time.
gadget_held - Gadget handle is stored from the time that
the mouse is clicked on the gadget, to the
time the mouse is released (regardless of
where the mouse is moved in that time).
gadget_clicked - Gadget handle is stored there briefly when
the gadget has been held, and the mouse is
released while hovering the gadget in question.
gadget_hovered - Gadget handle is stored there when the mouse
is hovering the gadget. If gadgets overlap
only one will be registered as being hovered.
Click and Hover variables for individual gadgets have been removed
as you can't click on more than one gadget at a time (though multiple
hovering may be possible, and could be put back in quite easily).
Selected property for input gadgets has also been removed.
- Gadget arrays are now dynamic, allowing for a practically unlimited
number of each gadget (only limited by the handle system, but still
maximum (2,147,483,647/NumGroups) gadgets per group are allowed)
without having to create wasted memory. Max gadgets per group is
stored in m_gadgets.
- Fine tuned listboxes. Height now generated from the ViewItems
parameter, which now represents the number of list items that can be
displayed at a time. Added many functions to control listbox items
directly, and have fixed the code to work with many listboxes, not
just one as before. As a result they now use the string list system
mentioned below (technical changes).
- Scroll buttons now scroll constantly when you hold them down (and at
a set rate controlled by the scroll_speed constant).
- Made sure that every GET function has a complimentary SET function
(except in particular cases when property cannot be set).
- Templates are now stored in .ini files. This requires IanM's ini plugin,
which is provided with this version, to be installed.
- Various functions added for access to new functionality.
--------------------------------------------------------------------------------
Function name/functionality changes:
- FUI_HideGadget renamed FUI_SetGadgetVisible for logical reasons.
- Standardised ListItems, ListBoxItems and Items to all be called "ListItems".
- FUI_MakeListBox no longer has a height parameter, but the height is
generated from the number of items it contains (as mentioned above).
- Removed all font parameters from make gadget functions for consistancy.
They now all have the default font by default.
- Changed Color1, Color2 and Color3 to Red, Green and Blue respectively.
--------------------------------------------------------------------------------
Technical changes:
- Time-based variable added (dt). This means that fading effects will
fade at the same rate no matter what the frame rate.
- Error message functions added for convenience.
- Added select-case statements to replace long list of if-statements.
It looks nicer and is probably faster.
- Added in a string list system which allows listboxes to have a list of
the items that they own, and allows users to be able to reference list
items by their position in the list.
--------------------------------------------------------------------------------
LIST OF CONSTANTS FOR EXTERNAL USE:
-----------------------------------------------------
GADGET GROUPS - Returned from FUI_GetGadgetGroup()
-----------------------------------------------------
g_buttons
g_boxes
g_inputs
g_listboxes
g_listitems
g_scrollbuttons
g_radiobuttons
--------------------------------------------------------------------------------
LIST OF FUNCTIONS FOR EXTERNAL USE:
----------------------------------
GET FUNCTIONS
----------------------------------
handle = FUI_GetRadioSelected(radioGroup) - Returns the handle of the radio button selected in the current group
handle = FUI_GetInputSelected() - Returns the handle of the currently selected input gadget
handle = FUI_GetGadgetClicked() - Returns a handle if a gadget is clicked
handle = FUI_GetGadgetHeld() - Returns a handle if a gadget is held
handle = FUI_GetGadgetHovered() - Returns a handle if a gadget is hovered
group = FUI_GetGadgetGroup() - Returns the group a gadget belongs to (i.e. what type of gadget it is)
text$ = FUI_GetGadgetText(handle) - Returns a gadget's related text
position = FUI_GetScrollPosition(handle) - Gets the scroll position of a gadget (i.e. the first item that is displayed)
xPos = FUI_GetGadgetPositionX(handle) - Returns the x position of a gadget
yPos = FUI_GetGadgetPositionY(handle) - Returns the y position of a gadget
index = FUI_GetItemSelected(handle) - Returns the currently selected item of a gadget
handle = FUI_GetItemHandle(handle,index) - Returns the handle of a specific listitem gadget belonging to another gadget
text$ = FUI_GetItemText(handle,index) - Returns the text of an item belonging to a gadget
text$ = FUI_GetItemCount(handle) - Returns the number of items belonging to a gadget
----------------------------------
SET FUNCTIONS
----------------------------------
FUI_SetRadioSelected(handle) - Sets a radio button to be selected. This will unselect the currently selected radio button in the same group
FUI_SetInputSelected(handle) - Sets an input gadget as selected. This will unselect any other input gadgets that are selected
FUI_SetGadgetClicked(handle) - Can be used to simulate clicking (not fully recommended)
FUI_SetGadgetHeld(handle) - Can be used to simulate holding (not fully recommended)
FUI_SetGadgetHovered(handle) - Can be used to simulate hovering (not fully recommended)
FUI_PositionGadget(handle,newX,newY) - Positions a gadget on the screen
FUI_SetGadgetText(handle,text$) - Sets a gadget's related text
FUI_SetScrollPosition(handle,position) - Sets the scroll position of a gadget (i.e. the first item that is displayed)
FUI_SetItemSelected(handle) - Sets a specific item belonging to a gadget as selected. This will unselect any other items that are selected
FUI_SetItemText(handle,index,text$) - Sets the text of a listitem belonging to a gadget
FUI_SetItemPosition(handle,index,position) - Sets the position of a listitem within a gadget (i.e. the order the gadgets are displayed in)
----------------------------------------------------------------------
MAKE GADGET FUNCTIONS - Return handles to gadgets that are created
----------------------------------------------------------------------
handle = FUI_MakeButton(X,Y,String$)
handle = FUI_MakeBox(X,Y,Width,Height)
handle = FUI_MakeInput(X,Y,String$,OptionalInput$,MaxCharacters)
handle = FUI_MakeListBox(X,Y,Width,Title$,ViewItems,MaxItems)
handle = FUI_AddItem(ParentHandle,Title$)
handle = FUI_MakeScrollButton(ParentHandle,bType,String$)
handle = FUI_MakeRadioButton(X,Y,String$,Group)
----------------------------------
MAIN GADGET FUNCTIONS
----------------------------------
FUI_SetGadgetVisible(handle,flag) - Sets whether a gadget is visible or not (0 = hidden, 1 = visible)
FUI_DeleteGadget(handle) - Deletes a gadget
exist = FUI_GadgetExist(handle) - Returns 1 if a gadget exists, 0 if it doesn't
FUI_DeleteItem(handle,index) - Deletes a specific listitem gadget belonging to another gadget
----------------------------------
OTHER FUNCTIONS
----------------------------------
FUI_UpdateGadgets() - Central update function. Should be called once per loop
FUI_SetTemplate(Name$) - Sets the template for the GUI system. Templates are stored in ini files.
handle = FUI_MakeRadioGroup() - Creates a radio group, and returns a handle to it (radio groups are not gadgets, and so may have the same handle as a gadget)
dt# = FUI_GetDT() - Returns the delta-time variable. Used internally to regulate time-based operations, but could be used externally
FreshGUI is a graphical user interface for games, developed using Cloggy's wonderful DLL. Unlike BlueGUI, which accesses the Windows API, FreshGUI is completely coded in DarkBASIC Professional and is designed to be used in games, not applications (although it can certainly be used for them). FreshGUI is an open-source project, and may be freely used and modified to fit your purposes, as long as the license is followed.
Key Features:
- Easy to implement and get started
- Customizeable templates defined in INI files
- Fast, modular code
- Designed for games from the ground up
- 10 Gadgets available, with over 55 commands
Command List:
FreshGUI Command List
gosub FUI_Init
FUI_UpdateGadgets
handle = FUI_GetRadioSelected(radioGroup)
FUI_SetRadioSelected(handle)
FUI_MakeGadgetPack()
FUI_AssignPack(handle,packHandle)
FUI_GetPackVisible(packHandle)
FUI_SetPackVisible(packHandle)
FUI_DeletePack(packHandle)
FUI_UnassignPack(handle)
FUI_PackExist(packHandle)
FUI_GetGadgetPack(handle)
FUI_SetChecked(handle)
FUI_GetChecked(handle)
FUI_SetProgressBarPos(handle,pos)
FUI_GetProgressBarPos(handle)
handle = FUI_GetInputSelected()
FUI_SetInputSelected(handle)
position = FUI_GetScrollPosition(handle)
FUI_SetScrollPosition(handle,position)
index = FUI_GetItemSelected(handle)
totalcount = FUI_GetItemCount(handle)
text$ = FUI_GetItemText(handle,index)
handle = FUI_GetItemHandle(handle,index)
FUI_SetItemText(handle,index,text$)
FUI_SetItemPosition(handle,index,position)
FUI_SetItemSelected(handle)
handle - FUI_GetGadgetClicked()
handle = FUI_GetGadgetHeld()
handle = FUI_GetGadgetHovered()
group = FUI_GetGadgetGroup()
text$ = FUI_GetGadgetText(handle)
xPos = FUI_GetGadgetPositionX(handle)
yPos = FUI_GetGadgetPositionY(handle)
FUI_SetGadgetClicked(handle)
FUI_SetGadgetHeld(handle)
FUI_SetGadgetHovered(handle)
FUI_PositionGadget(handle,newX,newY)
FUI_SetGadgetText(handle,text$)
handle = FUI_MakeButton(X,Y,String$,Style)
handle = FUI_MakeBox(X,Y,Width,Height)
handle = FUI_MakeInput(X,Y,String$,OptionalInput$,MaxCharacters)
handle = FUI_MakeListBox(X,Y,Width,Title$,ViewItems,MaxItems)
handle = FUI_AddItem(ParentHandle,Title$)
handle = FUI_MakeScrollButton(ParentHandle,bType,String$)
handle = FUI_MakeRadioButton(X,Y,String$,Group)
handle = FUI_MakeCheckBox(X,Y,String$,Checked)
handle = FUI_MakeProgressBar(X,Y,Width,Height,Style)
handle = FUI_MakeMenuBox(X,Y,Width,Height,Title$)
FUI_SetGadgetVisible(handle,flag)
FUI_DeleteGadget(handle)
exist = FUI_GadgetExist(handle)
FUI_DeleteItem(handle,index)
FUI_UpdateGadgets()
FUI_SetTemplate(name$)
handle = FUI_MakeRadioGroup()
dt# = FUI_GetDT()
width = FUI_GetGadgetHeight(handle) [New!]
height = FUI_GetGadgetWidth(handle) [New!]
To Use FreshGUI
- Download the latest version from the link above, unzip.
- Install the latest version of Cloggy's D3D DLL, and IanM's Matrix_1_Data DLL
- To use FreshGUI in your projects, include the "FreshGUI-Include.dba" file
The FreshGUI license is included in the FreshGUI-Include.dba file, but to sum it up: FreshGUI may be used for any purpose, commercial, shareware, or freeware, as long as credit is provided in your project, and the FreshGUI-Include.dba file used for your project is provided in the installation folder, so others can benefit from any modifications you have made.
I hope you enjoy using FreshGUI