mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
color palette saving
for now saves palette colours as their hex value. This will miss out on the alpha value.
This commit is contained in:
parent
46192c3709
commit
48ca98ca84
2 changed files with 99 additions and 11 deletions
|
|
@ -550,6 +550,7 @@ inline void ColorI::set(const String& hex)
|
||||||
red = (U8)(convertFromHex(redString));
|
red = (U8)(convertFromHex(redString));
|
||||||
green = (U8)(convertFromHex(greenString));
|
green = (U8)(convertFromHex(greenString));
|
||||||
blue = (U8)(convertFromHex(blueString));
|
blue = (U8)(convertFromHex(blueString));
|
||||||
|
alpha = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline S32 ColorI::convertFromHex(const String& hex) const
|
inline S32 ColorI::convertFromHex(const String& hex) const
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ $guiContent = new GuiColorPickerCtrl(ColorPickerDlg,EditorGuiGroup) {
|
||||||
changeChildSizeToFit = "0";
|
changeChildSizeToFit = "0";
|
||||||
changeChildPosition = "0";
|
changeChildPosition = "0";
|
||||||
position = "0 24";
|
position = "0 24";
|
||||||
extent = "271 481";
|
extent = "271 491";
|
||||||
profile = "GuiDefaultProfile";
|
profile = "GuiDefaultProfile";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
|
||||||
|
|
@ -283,20 +283,26 @@ $guiContent = new GuiColorPickerCtrl(ColorPickerDlg,EditorGuiGroup) {
|
||||||
};
|
};
|
||||||
new GuiRolloutCtrl() {
|
new GuiRolloutCtrl() {
|
||||||
caption = ":: Color Palette";
|
caption = ":: Color Palette";
|
||||||
|
margin = "5 5 5 5";
|
||||||
position = "0 445";
|
position = "0 445";
|
||||||
extent = "271 36";
|
extent = "271 46";
|
||||||
profile = "GuiRolloutProfile";
|
profile = "GuiRolloutProfile";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
|
||||||
new GuiStackControl() {
|
new GuiDynamicCtrlArrayControl(ColorPaletteStack) {
|
||||||
stackingType = "Dynamic";
|
colCount = "12";
|
||||||
padding = "5";
|
colSize = "12";
|
||||||
changeChildSizeToFit = "0";
|
rowSize = "12";
|
||||||
position = "0 17";
|
rowCount = "3";
|
||||||
extent = "271 16";
|
rowSpacing = "1";
|
||||||
profile = "GuiDefaultProfile";
|
colSpacing = "1";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
dynamicSize = "1";
|
||||||
};
|
padding = "3 3 3 3";
|
||||||
|
position = "0 17";
|
||||||
|
extent = "271 47";
|
||||||
|
profile = "GuiDefaultProfile";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -342,6 +348,87 @@ function GetColorF( %currentColor, %callback, %root, %updateCallback, %cancelCal
|
||||||
%root.pushDialog(ColorPickerDlg);
|
%root.pushDialog(ColorPickerDlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ColorPaletteStack::onWake(%this)
|
||||||
|
{
|
||||||
|
if($Pref::ColorPicker::ColorPalette $= "")
|
||||||
|
{
|
||||||
|
$Pref::ColorPicker::ColorPalette = "#FFFFFF #FF0000 #00FF00 #0000FF";
|
||||||
|
}
|
||||||
|
|
||||||
|
%colorCount = getWordCount($Pref::ColorPicker::ColorPalette);
|
||||||
|
|
||||||
|
if(%colorCount > 63)
|
||||||
|
%colorCount = 63;
|
||||||
|
|
||||||
|
for(%i=0; %i < %colorCount; %i++)
|
||||||
|
{
|
||||||
|
%hex = getWord($Pref::ColorPicker::ColorPalette, %i);
|
||||||
|
%rgb = ColorHEXToRGB(%hex);
|
||||||
|
%rgb = ColorIntToFloat(%rgb);
|
||||||
|
|
||||||
|
%colorBox = new GuiSwatchButtonCtrl() {
|
||||||
|
extent = "16 16";
|
||||||
|
color = %rgb;
|
||||||
|
profile = "GuiDefaultProfile";
|
||||||
|
colorHex = %hex;
|
||||||
|
useMouseEvents = "1";
|
||||||
|
class = "ColorPaletteSwatch";
|
||||||
|
};
|
||||||
|
|
||||||
|
ColorPaletteStack.Add(%colorBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
%button = new GuiButtonCtrl() {
|
||||||
|
text = "+";
|
||||||
|
extent = "16 16";
|
||||||
|
profile = "ToolsGuiButtonProfile";
|
||||||
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
command = "ColorPaletteStack.addCurrentColorToStack();";
|
||||||
|
};
|
||||||
|
|
||||||
|
ColorPaletteStack.Add(%button);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ColorPaletteStack::addCurrentColorToStack(%this)
|
||||||
|
{
|
||||||
|
%hex = HexTextEditor.getValue();
|
||||||
|
//Make sure we have 6 characters
|
||||||
|
while(strlen(%hex) < 6)
|
||||||
|
{
|
||||||
|
%hex = "0" @ %hex;
|
||||||
|
}
|
||||||
|
%hex = strupr(%hex);
|
||||||
|
|
||||||
|
$Pref::ColorPicker::ColorPalette = "#" @ %hex SPC $Pref::ColorPicker::ColorPalette;
|
||||||
|
ColorPaletteStack.clear();
|
||||||
|
ColorPaletteStack.onWake();
|
||||||
|
}
|
||||||
|
|
||||||
|
function ColorPaletteStack::onSleep(%this)
|
||||||
|
{
|
||||||
|
ColorPaletteStack.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
function ColorPaletteSwatch::onMouseDown(%this)
|
||||||
|
{
|
||||||
|
//Update all the other color fields
|
||||||
|
%rgb = ColorHEXToRGB(%this.colorHex);
|
||||||
|
%hsb = ColorRGBToHSB(%rgb);
|
||||||
|
|
||||||
|
// these automatically update our ColorNewSelected which
|
||||||
|
// updates all text fields including these.
|
||||||
|
ColorHueRange.setSelectedHue(getWord(%hsb, 0));
|
||||||
|
ColorHueRange.executeUpdate();
|
||||||
|
|
||||||
|
ColorBlendRange.setSelectedSaturation(getWord(%hsb, 1));
|
||||||
|
ColorBlendRange.setSelectedBrightness(getWord(%hsb, 2));
|
||||||
|
ColorBlendRange.executeUpdate();
|
||||||
|
|
||||||
|
// for now just set full alpha until we save out alpha as well
|
||||||
|
ColorAlphaRange.setSelectedAlpha(255);
|
||||||
|
ColorAlphaRange.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
function ColorPickerRGBClass::onValidate(%this)
|
function ColorPickerRGBClass::onValidate(%this)
|
||||||
{
|
{
|
||||||
%red = RedTextEdit.getValue();
|
%red = RedTextEdit.getValue();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue