zapat 56 Posted January 5, 2014 It may or may not be a trivial question: How can one add texture (or image) to a button in UI? Share this post Link to post Share on other sites
John Spartan 89 Posted January 5, 2014 (edited) edit/create a config entry for a new button with properties' you need and inheriting the vanilla values you don't want to change. put something like this in your config cpp of your addon class RscControlsGroup; // External class reference class RscControlsGroupNoScrollbars; // External class reference class RscText; // External class reference class RscProgress; // External class reference class RscIGProgress; // External class reference class RscHitZones; // External class reference class RscIGUIValue; // External class reference class RscIGUIText; // External class reference class IGUIBack; // External class reference class RscFrame; // External class reference class RscPicture; // External class reference class RscCombo; // External class reference class RscButtonMenu; // External class reference class my_RscButtonMenu : RscButtonMenu { animTextureNormal = "\My_addonpath\my_button_normal_ca.paa"; animTextureDisabled = "\My_addonpath\my_button_disabled_ca.paa"; animTextureOver = "\My_addonpath\my_button_over_ca.paa"; animTextureFocused = "\My_addonpath\my_button_focus_ca.paa"; animTexturePressed = "\My_addonpath\my_button_down_ca.paa"; animTextureDefault = "\My_addonpath\my_button_default_ca.paa"; colorBackground[] = {0, 0, 0, 0.8}; colorBackground2[] = {1, 1, 1, 0.5}; color[] = {1, 1, 1, 1}; color2[] = {1, 1, 1, 1}; colorText[] = {1, 1, 1, 1}; colorDisabled[] = {1, 1, 1, 0.25}; }; for more information I would advise to look at Iceman's awesome tutorial on UI's Edited January 5, 2014 by John_Spartan Share this post Link to post Share on other sites
zapat 56 Posted January 5, 2014 I've never knew what it (RscButtonMenu) was for. Now I do. :) Thanks. Does it take images too, or paa only? If we are at this topic: what is RscShortcutButton? BTW: the -otherwise excellent- guide from Iceman doesn't contain info on this. Share this post Link to post Share on other sites
John Spartan 89 Posted January 5, 2014 Is RscButtonMenu the same as RscShortcutButton in BIS' stuff? - similar, open up BI's configs and you will see the difference. ui_f\a3\ui_f\config.cpp is the file in game that contains all this info. Arma game engine handles only .paa files for textures, but there is no issue converting tga/png files to paa with BI's tools. Share this post Link to post Share on other sites
zapat 56 Posted January 5, 2014 I am not getting closer... Custom texture is not shown. #argb does. And I have no clue what is Hitzone and Shortcutpos although I browsed the appropriate classes. Share this post Link to post Share on other sites
John Spartan 89 Posted January 5, 2014 - Hitzone is the definition of are where the button can be activated by clicking it - Shortcutpos is the area which on roll of a mouse will display a hint/description of your button regarding textures, what is the path to your custom textures, is it a new addon pbo or you are trying to get them ingame within a mission pbo? Share this post Link to post Share on other sites
zapat 56 Posted January 5, 2014 in "media" folder of my mission. Works well with "Media\test.paa" in RscPicture. Share this post Link to post Share on other sites
iceman77 18 Posted January 5, 2014 Just for additional info, you could also simply use an active text control and set it to a picture style. Share this post Link to post Share on other sites
zapat 56 Posted January 5, 2014 Yoohoo, it works now! Thanks Iceman for the tip! It seems a lot simpler than the RscButtonMenu, although I shoud probably figure that out too for the long run... Share this post Link to post Share on other sites
Dreadleif 4 Posted January 25, 2016 Just for additional info, you could also simply use an active text control and set it to a picture style. Sorry to bring this up again, but what does this mean? I'm also trying to either make buttons in my mission either a picture, or translucent, by messing with dialogs.hpp and defines.hpp, which I include in description.ext: #include "defines.hpp" #include "dialogs.hpp" example of dialogs.hpp class text2: RscText { idc = 1001; text = "pics\AIMinit.jpg"; //--- ToDo: Localize; x = 0.356024 * safezoneW + safezoneX; y = 0.295991 * safezoneH + safezoneY; w = 0.18397 * safezoneW; h = 0.0850039 * safezoneH; tooltip = "text2"; //--- ToDo: Localize; }; class pic1: RscPicture { idc = 1200; text = "pics\AIMinit.jpg"; x = 0.356024 * safezoneW + safezoneX; y = 0.414996 * safezoneH + safezoneY; w = 0.18397 * safezoneW; h = 0.102005 * safezoneH; tooltip = "pic1"; //--- ToDo: Localize; action = "_nil=[]execVM ""scripts\mercstore\mike.sqf"""; }; The text and the picture don't do anything when clicked, and the button always has the same texture.. I simply want it invisible. Could it be done by changing some of these values for the button in -- defines.hpp? class RscButton { access = 0; type = CT_BUTTON; text = ""; colorText[] = {1,1,1,.9}; colorDisabled[] = {0.4,0.4,0.4,0}; colorBackground[] = {0.75,0.75,0.75,0.8}; colorBackgroundDisabled[] = {0,0.0,0}; colorBackgroundActive[] = {0.75,0.75,0.75,1}; colorFocused[] = {0.75,0.75,0.75,.5}; colorShadow[] = {0.023529,0,0.0313725,1}; colorBorder[] = {0.023529,0,0.0313725,1}; soundEnter[] = {"\ca\ui\data\sound\onover",0.09,1}; soundPush[] = {"\ca\ui\data\sound\new1",0,0}; soundClick[] = {"\ca\ui\data\sound\onclick",0.07,1}; soundEscape[] = {"\ca\ui\data\sound\onescape",0.09,1}; style = 2; x = 0; y = 0; w = 0.055589; h = 0.039216; shadow = 2; font = "PuristaLight"; sizeEx = 0.03921; offsetX = 0.003; offsetY = 0.003; offsetPressedX = 0.002; offsetPressedY = 0.002; borderSize = 0; }; I'm really lost here =(... As long as my buttons look like crap I really can't get any further with my mission. All I would want is make the texture/color translucent for the RscButton, I know someone out there probably knows the answer. Share this post Link to post Share on other sites
zapat 56 Posted January 25, 2016 Here's what I have: class BRUI_TACV_buttonTemplate:RscActiveText { x = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; y = "1.6 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; w = "1 * (((safezoneW / safezoneH) min 1.2) / 40)"; h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; style = ST_PICTURE; color[] = {1,1,1,0.8}; colorActive[] = {1,1,1,1}; colorDisabled[] = {1,1,1,1}; text = "TACV\Icons\grenadeB.paa"; }; but I guess you'll need to use paa. I solely use this approach, so I don't know about others. Making it invisible is very easy. Use the RscActiveText as is (without style) and make text color [0,0,0,0]. you will need text though to fill the whole button, you just make it invisible. (So text = "" won't work). Share this post Link to post Share on other sites
dreadedentity 278 Posted January 25, 2016 Well since this thread got revived, I noticed something a little incorrect (at least for today, it might have been true in 2014) in an above post Arma game engine handles only .paa files for textures, but there is no issue converting tga/png files to paa with BI's tools. I got ImageToPAA in Arma 3 Tools to work when using a picture that was 256x256, but it failed every other time I tried to use it. After a little research it seems to only work correctly on pictures that are square and who's side measurements are a multiple of 2, starting at 24(16). @Dreadleif Before I answer your question I'm going to ask you another question. As long as my buttons look like crap I really can't get any further with my mission. Why? The way your dialog looks has literally nothing to do with the way the mission works during the development phase. You'd be much better off just using an addAction to run the scripts, rather than relying on dialog elements, until you get the mission finished. Appearance is part of the polishing stage, where you make things look pretty. Basically, if you're worried about making things look nice, after you get things looking the way you want them to, you better be typing up a forum post because you're in the distribution stage, baby. Now, you need to read the wiki. Your "buttons" don't work because they aren't buttons, they are a textbox and a picturebox, and changing the RscButton class definition will not help because you do not use RscButton. Picture boxes (and alternatively text boxes) do not have an "action" member that they use, so that will not work 100% of the time, guaranteed. However, they do have another event handler that you want to use, onMouseButtonDown or onMouseButtonUp, you use it the same way as action. Here's an example from a dialog that I'm working on: class RscButton_1600: RscText { idc = 1600; style = ST_PICTURE; fixedWidth = 0; text = "myPicture"; //--- ToDo: Localize; shadow = 2; x = 0.967496 * safezoneW + safezoneX; y = 0.0159797 * safezoneH + safezoneY; w = 0.0262433 * safezoneW; h = 0.042 * safezoneH; onMouseButtonDown = "call ACSCE_fnc_closeEditor"; onMouseMoving = "if (_this select 3) then {(_this select 0) ctrlSetTextColor [0.96,0.62,0,1]} else {(_this select 0) ctrlSetTextColor [1,1,1,1]};"; }; Share this post Link to post Share on other sites