Jump to content
Sign in to follow this  
minipopov

[Release] OOP Class to manage your display "easier"

Recommended Posts

Hello,

Link for OOP:https://github.com/code34/oop.h

Link: https://github.com/minipopov/HelperGUI

 

I just release a OOP Class that i use in my GUI Editor to manage control, which it  be easier for me cause there is lot of log if you re doing something wrong... This class contain many function that help me to set Listbox, edit text, text... there is also some getter.. AND i use this class also to make some verification on string like "is my string contain space? is it numeric?..."

How do i use this class? First of all is instantiate this where you want. Personnaly i add it into initPlayerLocal.sqf

HelperGui = "new" call oo_HelperGui;

There is a function to set display where you wan't manage control.

["setDisplay", (findDisplay 1500)] call HelperGui;

And now many function..

Setter:

Spoiler

@input: array [control/id control, typeControl as scalar]
@return: true/false
["verifyType", _array] call HelperGui;

 

@input: array [control/id control, action as string]
@return: true/false
["setAction", _array] call HelperGui; // array could be [control, "your action"], [id control, "your action"] return true/false

 

@input: array [control/id control, string/scalar]
@return: true/false
["setString", _array] call HelperGui; // array could be [control, "your action"], [id control, "your action"] return true/false

 

@input: array 
    [
        ["list", [array of data]],
        ["control",control/id control],
        ["name", index of name in data],
        (Opt)["value", index of value in data], //Default it will be there own index in lb
        (Opt)["tooltip", index of tooltip in data],
        (Opt)["picture", index of picture in data]
    ]
@return: void
["setLB", _array] call HelperGui; // array could be [control, "your action"], [id control, "your action"] return true/false

And Getter:

Spoiler

Get string of control, return default value when something goes wrong like controlNull

@input: id of control OR control

@default return: Empty string ""

["getString", _control] call HelperGui;

@input: array [id control/ control, default return value => must be string]

["getString", _array] call HelperGui;

 

Get scalar of control and make private parse number function. That remove space, special char something that parseNumber doesn't make. Return default value when something goes wrong

@input: id of control OR control

@default return: Empty string -1

["getScalar", _control] call HelperGui;

@input: array [id control/ control, default return value => must be scalar]

["getScalar", _array] call HelperGui;

 

Return true/false when control is checked/unchecked Default value is false if you try to get getCtrlChecked on bad control

@input: control or id of control

["getCtrlChecked", _array] call HelperGui;

 

GetValue of LB

@input: control/idControl Default return:-1

["getLbSelValue", _control] call HelperGui;

@input: array [control/id of control, default return => scalar]

["getLbSelValue", _array] call HelperGui;

 

Get array of control

@input: control/idControl Default return:[]

["getArrayFromControl", _control] call HelperGui;

@input: array [control/id of control, default return => scalar]

["getArrayFromControl", _array] call HelperGui;

 

Get text of control as color

@input: control/idControl Default return:[-1,-1,-1,-1]

["getColor", _control] call HelperGui;

@input: array [control/id of control, default return => scalar]

["getColor", _array] call HelperGui;

 

 

 

And there is some functions that i use in special case

Spoiler

Remove space at begin and end from string

@input:string

@return:string

["trim", _string] call HelperGui;

 

Check if string contain any space

@input:string

@return:true/false

["containSpace", _string] call HelperGui

 

Check if string contain pattern

@input:array[string, pattern]

@return:true/false

["stringContain", _array] call HelperGui;

 

Another way of format string. 

@input:array [string, ["value1","value2"...]

@return:string

["stringFormat", _array] call HelperGui;

 

Remove all space from string

@input:string

@return:string

["removeSpace", _string] call HelperGui;

 

Replace any pattern by new string

@input:array [string, match pattern, replace pattern]

@return:string

["stringReplace", _array] call HelperGui;

 

Convert color array to texture

@input: array of color

@return: texture as string

["getTextureFromArray", _color] call HelperGui;

 

Parse number with some fix..

@input: string

@output: scalar

["parseNumber", _string] call HelperGui;

 

This is not fully optimised but at this the moment it's works well for what i'm doing. May be you should read file one time before use it

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×