Realtime Menu Color Tweaker
by Martin Schultz · 05/15/2007 (11:39 am) · 13 comments
Download Code File
ColorTweaker is a scripted GUI that allows to edit the colors of all GUI profiles within the game or within the menus in realtime. The gui offers two drop down boxes where to select the gui profile (like guiButtonProfile) and a property dropdown where you could select which property to change using the provided RGBA color sliders (yes, even alpha values are editable in realtime).
It allows quick prototyping of how different gui color variations could look like or to quickly change the default Torque look to something more fancy. Writing back the changes is not supported yet, but the script line which to be replaced with the new values will be outputted by the GUI so that you can simply copy and paste the new color into your scripts.
The code for the GUI control is not cleaned up yet, it's just out of the development folder taken and put into a resource because I think it might be useful for others too. If you have improvements or bugfixes to this, please drop me a line or post a reply below.
Have fun with this one!
Martin
=======================================================================
Here is the manual that is included within the zip file:
1) Please add the "menuColorTweaker.gui" file to your/client/ui/ folder.
2) Open the file/client/init.cs and right after the following line:
exec("./ui/StartupGui.gui");
add this line to initalize the ColorTweaker (around 73):
exec("./ui/menuColorTweaker.gui"); // <- New line!
3) Open the file/client/scripts/default.bind.cs and add at the end the following block. It allows us to open the ColorTweaker in the menus or even in-game via the key binding CTRL+W:
// Global key binding for the color tweaker to let it work in the menus or in-game
function openColorTweaker(%val)
{
if (!%val)
return;
Canvas.pushDialog(MenuColorTweakerDlg);
}
GlobalActionMap.bind(keyboard, "ctrl w", openColorTweaker);
4) Done! Start your game and hit CTRL+W in-game or in the menus, select as example the guiButtonProfile from the profile dropdown list, select fillColor from the property list and move the color sliders to see all buttons that have that standard profile to change their fill color.
ColorTweaker is a scripted GUI that allows to edit the colors of all GUI profiles within the game or within the menus in realtime. The gui offers two drop down boxes where to select the gui profile (like guiButtonProfile) and a property dropdown where you could select which property to change using the provided RGBA color sliders (yes, even alpha values are editable in realtime).
It allows quick prototyping of how different gui color variations could look like or to quickly change the default Torque look to something more fancy. Writing back the changes is not supported yet, but the script line which to be replaced with the new values will be outputted by the GUI so that you can simply copy and paste the new color into your scripts.
The code for the GUI control is not cleaned up yet, it's just out of the development folder taken and put into a resource because I think it might be useful for others too. If you have improvements or bugfixes to this, please drop me a line or post a reply below.
Have fun with this one!
Martin
=======================================================================
Here is the manual that is included within the zip file:
1) Please add the "menuColorTweaker.gui" file to your
2) Open the file
exec("./ui/StartupGui.gui");
add this line to initalize the ColorTweaker (around 73):
exec("./ui/menuColorTweaker.gui"); // <- New line!
3) Open the file
// Global key binding for the color tweaker to let it work in the menus or in-game
function openColorTweaker(%val)
{
if (!%val)
return;
Canvas.pushDialog(MenuColorTweakerDlg);
}
GlobalActionMap.bind(keyboard, "ctrl w", openColorTweaker);
4) Done! Start your game and hit CTRL+W in-game or in the menus, select as example the guiButtonProfile from the profile dropdown list, select fillColor from the property list and move the color sliders to see all buttons that have that standard profile to change their fill color.
#2
06/20/2007 (12:20 pm)
Hehe, glad you like it, Shon. If you have questions, don't hesitate to ask. :-)
#3
Once again thanks Martin.
06/21/2007 (4:58 am)
Yes I do like it and and plan to make the variables save as $Pref:: and put save them in prefs.cs so we can let the user make their own colors and let them have fun and save it. When I finish it I will post here.Once again thanks Martin.
#4
06/21/2007 (5:06 am)
Good idea with the prefs! :-)
#5
10/06/2007 (1:46 pm)
Nice, but is there some way to make it so that it could recolor objects? such as having the color of a character customizable?
#6
10/13/2007 (3:18 pm)
I love this gizmo. A LOT!
#7
10/13/2007 (3:19 pm)
OK.. forgotto rate it... Did I say ALOT!
#8
It seems you can select only the profiles used in the colortweaker dialog... Would be usefull to have access to all profiles loaded in game...
;)
11/17/2007 (5:23 am)
Useful resource but...It seems you can select only the profiles used in the colortweaker dialog... Would be usefull to have access to all profiles loaded in game...
;)
#9
@Joz: I haven't looked at the code closely but imagine you could easily add to the list of profiles.
Anyway I am just sticking in my two cents worth. I still think this is a very useful utility because I used to have to edit the above files and then go see what the effect was. Now I can change it on the fly and if I don't like it I can change it again.
11/17/2007 (6:49 am)
@Tyler: This is only for GUI colors. Characters use regular graphic files like JPEG and PNG files. You use Photoshop or a like program to change those colors. Check out resources about skins. This utility is great because it gets the values from obcsure files in the TGE build such as common/ui/defaultProfiles.cs and starter.fps/client/ui/customProfiles.cs which have all the GUI defaults for the game. Take a good look at these files. They contain everything you need to make cool GUI, also check out starter.fps/client/ui/defaultGameProfiles.cs@Joz: I haven't looked at the code closely but imagine you could easily add to the list of profiles.
Anyway I am just sticking in my two cents worth. I still think this is a very useful utility because I used to have to edit the above files and then go see what the effect was. Now I can change it on the fly and if I don't like it I can change it again.
#10
11/17/2007 (7:10 am)
Yeah, can modify only the profiles hardcoded in the dialog. Didn't find at that time a way to dynamically read them all out.
#11
But what I wanna ask if anyone has any idea how to implement a way in wich the profiles list loads dinamically all the profiles instead to have to hard code it by hand having to add every profile you may create...
I think something similar is done in the dropdown present in the guieditor when selecting a control you have a field in wich specify the associated profile... the dropdown show you all the profiles available... But really I cannot figure out how it's done and in wich files to search the implementation of that... :(
I'm not a programmer eheheh :)
JoZ
11/17/2007 (8:47 am)
Yes for sure! :)But what I wanna ask if anyone has any idea how to implement a way in wich the profiles list loads dinamically all the profiles instead to have to hard code it by hand having to add every profile you may create...
I think something similar is done in the dropdown present in the guieditor when selecting a control you have a field in wich specify the associated profile... the dropdown show you all the profiles available... But really I cannot figure out how it's done and in wich files to search the implementation of that... :(
I'm not a programmer eheheh :)
JoZ
#12
Here is what I did
At the bottom of gui/editor/guiInspectorTypes.cc I added this:
Then I changed the onWake in the gui to this:
Surely could be more elegant, but it does the trick
04/02/2008 (12:56 am)
Thanks for this, saved me quite a bit of time, I too wished it to import all of my gui profiles instead of having to try to manage them in the code.Here is what I did
At the bottom of gui/editor/guiInspectorTypes.cc I added this:
static S32 QSORT_CALLBACK guiProfilesCompare(const void *a,const void *b)
{
StringTableEntry sa = *(StringTableEntry*)a;
StringTableEntry sb = *(StringTableEntry*)b;
return(dStricmp(sa, sb));
}
ConsoleFunction(getGuiProfiles, const char *, 1, 1, "getGuiProfiles()")
{
char *ret = Con::getReturnBuffer(8192);
Vector<StringTableEntry> entries;
SimGroup * grp = Sim::getGuiDataGroup();
for(SimGroup::iterator i = grp->begin(); i != grp->end(); i++)
{
GuiControlProfile * profile = dynamic_cast<GuiControlProfile *>(*i);
if(profile)
entries.push_back(profile->getName());
}
// sort the entries
dQsort(entries.address(), entries.size(), sizeof(StringTableEntry), guiProfilesCompare);
// build the list, with the first record being the size of the list
ret[0] = 0;
char szBuffer[4];
dSprintf( szBuffer, 4, "%d", entries.size() );
dStrcat(ret, szBuffer);
dStrcat(ret, "\n");
for(U32 j = 0; j < entries.size(); j++)
{
dStrcat(ret, entries[j]);
dStrcat(ret, "\n");
}
return ret;
}Then I changed the onWake in the gui to this:
function MenuColorTweakerDlg::onWake(%this)
{
//error("MenuColorTweakerDlg::onWake...");
//MenuColorTweakerDlg::setSlider("0 0 0 0"); // default to all left
%id = 0;
ColorTweakerProfileSelectDDL.clear();
ColorTweakerProfileSelectDDL.add("Please select profile...", %id++);
// First record returned by getGuiProfiles is the amount of records.
%profiles = getGuiProfiles();
%profilesCount = getRecord(%profiles,0);
for(%i = 1; %i <= %profilesCount; %i++)
{
%profile = getRecord(%profiles, %i);
if (%profile !$= "")
ColorTweakerProfileSelectDDL.add(%profile, %id++);
}
ColorTweakerProfileSelectDDL.setSelected(1);
%id = 0;
ColorTweakerTypeSelectDDL.clear();
ColorTweakerTypeSelectDDL.add("Please select property...", %id++);
ColorTweakerTypeSelectDDL.add("fillColor", %id++);
ColorTweakerTypeSelectDDL.add("fillColorHL", %id++);
ColorTweakerTypeSelectDDL.add("fillColorNA", %id++);
ColorTweakerTypeSelectDDL.add("borderColor", %id++);
ColorTweakerTypeSelectDDL.add("borderColorHL", %id++);
ColorTweakerTypeSelectDDL.add("borderColorNA", %id++);
ColorTweakerTypeSelectDDL.add("fontColor", %id++);
ColorTweakerTypeSelectDDL.add("fontColorHL", %id++);
ColorTweakerTypeSelectDDL.add("fontColorNA", %id++);
ColorTweakerTypeSelectDDL.add("fontColorSEL", %id++);
ColorTweakerTypeSelectDDL.add("fontColorLink", %id++);
ColorTweakerTypeSelectDDL.add("fontColorLinkHL", %id++);
ColorTweakerTypeSelectDDL.setSelected(1);
}Surely could be more elegant, but it does the trick
#13
04/02/2008 (12:58 am)
Cool, good job! :-) 
Torque Owner Shon Gale