コード例 #1
0
        private static Color AlterColor(Color origColor, bool random)
        {
            if (random)
            {
                return(new Color(RandomUtil.GetInt(255), RandomUtil.GetInt(255), RandomUtil.GetInt(255)));
            }
            else
            {
                // mSavedColors is a Vector color stored as RGB ratios of 0 to 1

                Vector3 hsv = CompositorUtil.ColorShifter.ColorToHsv(CompositorUtil.ColorToVector3(origColor));

                /*
                 * hsv.x += RandomUtil.GetFloat(-0.01f, 0.01f);
                 * if (hsv.x > 1)
                 * {
                 *  hsv.x = 1;
                 * }
                 * else if (hsv.x < 0)
                 * {
                 *  hsv.x = 0;
                 * }
                 */

                hsv.y += RandomUtil.GetFloat(-0.25f, 0.25f);
                if (hsv.y > 1)
                {
                    hsv.y = 1;
                }
                else if (hsv.y < 0.01)
                {
                    hsv.y = 0.01f;
                }

                hsv.z += RandomUtil.GetFloat(-0.25f, 0.25f);
                if (hsv.z > 1)
                {
                    hsv.z = 1;
                }
                else if (hsv.z < 0.01)
                {
                    hsv.z = 0.01f;
                }

                return(CompositorUtil.Vector3ToColor(CompositorUtil.ColorShifter.HsvToColor(hsv)));
            }
        }
コード例 #2
0
ファイル: BuyProductList.cs プロジェクト: yakoder/NRaas
            protected override void OnPerform()
            {
                CompositorUtil.ApplyPreset(mPresetEntry);
                SortedList <string, Complate> patterns = new SortedList <string, Complate>();

                foreach (KeyValuePair <string, Complate> pair2 in mPresetEntry.Value)
                {
                    patterns.Add(pair2.Key, pair2.Value);
                }

                using (DesignModeSwap swap = new DesignModeSwap())
                {
                    if (swap.SetSourceObject(this.mObject))
                    {
                        swap.ClearOldCompositors();
                    }

                    string   key      = mPresetEntry.Key;
                    Complate complate = null;
                    if (!patterns.TryGetValue(key, out complate))
                    {
                        return;
                    }

                    SortedList <string, bool> enabledStencils = new SortedList <string, bool>();
                    foreach (Complate.Variable variable in complate.Variables)
                    {
                        if (variable.Type == Complate.Variable.Types.Bool)
                        {
                            string str2 = variable.Name.ToLower();
                            if (str2.StartsWith("stencil ") && str2.EndsWith(" enabled"))
                            {
                                enabledStencils.Add(variable.Name, bool.Parse(variable.Value));
                            }
                        }
                    }

                    string presetStringFromPresetEntry = SimBuilder.GetPresetStringFromPresetEntry(mPresetEntry);

                    Complate.SetupDesignSwap(swap, patterns, presetStringFromPresetEntry, true, enabledStencils);

                    swap.ApplyToObject();
                }
            }
コード例 #3
0
ファイル: CASMakeupEx.cs プロジェクト: yakoder/NRaas
        private static Color[] GetMakeupColors(CASMakeup ths, BodyTypes type)
        {
            Vector3[] makeupVectorColors = GetMakeupVectorColors(ths, type);
            if (makeupVectorColors == null)
            {
                return(null);
            }
            int length = makeupVectorColors.Length;

            if (CASController.Singleton.ShowAllMakeupPresetsCheat)
            {
                length = 0x4;
            }
            Color[] colorArray = new Color[length];
            for (int i = 0x0; i < makeupVectorColors.Length; i++)
            {
                colorArray[i] = CompositorUtil.Vector3ToColor(makeupVectorColors[i]);
            }
            for (int j = makeupVectorColors.Length; j < length; j++)
            {
                colorArray[j] = new Color(0xffffffff);
            }
            return(colorArray);
        }
コード例 #4
0
ファイル: CAPUnicornEx.cs プロジェクト: yakoder/NRaas
        public static void PopulateHornColors()
        {
            try
            {
                CAPUnicorn ths = CAPUnicorn.gSingleton;
                if (ths == null)
                {
                    return;
                }

                CASPartPreset preset;
                ths.mHornColorsGrid.Clear();
                List <CASPart> wornHornParts = new List <CASPart>();

                CASPart wornPart = ths.GetWornHornPart();

                CASLogic singleton = CASLogic.GetSingleton();

                foreach (CASPart part in singleton.mCasParts)
                {
                    if ((part.BodyType == BodyTypes.PetHorn) &&
                        (part.Species == CASAgeGenderFlags.Horse) &&
                        ((part.Age & singleton.Age) != CASAgeGenderFlags.None))
                    {
                        wornHornParts.Add(part);
                    }
                }

                CompositorUtil.GetPatternsFromCASPart(wornPart);
                ObjectDesigner.SetCASPart(wornPart.Key);
                ResourceKey layoutKey    = ResourceKey.CreateUILayoutKey("EyeColorPresetGridItem", 0x0);
                string      designPreset = null;

                // Custom
                try
                {
                    designPreset = Responder.Instance.CASModel.GetDesignPreset(wornPart);
                }
                catch
                { }

                foreach (CASPart wornHornPart in wornHornParts)
                {
                    uint num = CASUtils.PartDataNumPresets(wornHornPart.Key);

                    int i = 0;

                    for (uint j = 0x0; j < num; j++)
                    {
                        preset = new CASPartPreset(wornHornPart, CASUtils.PartDataGetPresetId(wornHornPart.Key, j), CASUtils.PartDataGetPreset(wornHornPart.Key, j));

                        ths.AddHornPresetGridItem(ths.mHornColorsGrid, layoutKey, preset, wornHornPart, (uint)(j + 0x1));
                        if (CAPUnicorn.HornPresetCompare(designPreset, preset.mPresetString))
                        {
                            ths.mCurrentHornColorPreset      = preset;
                            ths.mHornColorsGrid.SelectedItem = i;
                            if (UIUtils.GetCustomContentType(wornHornPart.Key, preset.mPresetId) == ResourceKeyContentCategory.kInstalled)
                            {
                                ths.mHornColorDeleteButton.Enabled = false;
                            }
                            else
                            {
                                ths.mHornColorDeleteButton.Enabled = true;
                            }
                        }

                        i++;
                    }
                }

                if (ths.mHornColorsGrid.SelectedItem == -1)
                {
                    ths.mHornColorDeleteButton.Enabled = false;
                }

                bool flag = ths.mHornColorsGrid.Count > (ths.mHornColorsGrid.VisibleRows * ths.mHornColorsGrid.VisibleColumns);
                Rect area = ths.mHornColorPanel.Area;
                area.Height = flag ? ths.mHornColorPanelHeightWithScrollbars : (ths.mHornColorPanelHeightWithScrollbars - 21f);
                ths.mHornColorPanel.Area = area;
            }
            catch (Exception e)
            {
                Common.Exception("PopulateHornColors", e);
            }
        }
コード例 #5
0
ファイル: CASMakeupEx.cs プロジェクト: yakoder/NRaas
        private static void OnColorsSaved(Color[] colors)
        {
            try
            {
                CASMakeup ths = CASMakeup.gSingleton;
                if (ths == null)
                {
                    return;
                }

                bool flag  = false;
                bool flag2 = false;
                if (CASMakeup.sCategory != BodyTypes.CostumeMakeup)
                {
                    foreach (ItemGridCellItem item in ths.mGridMakeupPresets.Items)
                    {
                        flag2 = true;
                        ResourceKey mTag = (ResourceKey)item.mTag;
                        ColorInfo   info = ColorInfo.FromResourceKey(mTag);
                        for (int i = 0x0; i < info.Colors.Length; i++)
                        {
                            Vector3 vector = CompositorUtil.ColorToVector3(colors[i]);
                            Vector3 v      = CompositorUtil.ColorToVector3(info.Colors[i]);
                            if (!vector.IsSimilarTo(v))
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        ColorInfo info2 = new ColorInfo();
                        info2.Usage = ColorInfo.PreferredUse.Makeup;
                        switch (CASMakeup.sCategory)
                        {
                        case BodyTypes.FirstFace:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupLipstick;
                            break;

                        case BodyTypes.EyeShadow:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupEyeshadow;
                            break;

                        case BodyTypes.EyeLiner:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupEyeliner;
                            break;

                        case BodyTypes.Blush:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupBlush;
                            break;
                        }
                        info2.Colors = colors;
                        flag         = info2.SaveMakeupPreset(info2.UsageSubCategory) != ResourceKey.kInvalidResourceKey;
                        ths.PopulatePresetsGrid(CASMakeup.sCategory, ths.mCurrentPreset.mPart, ths.mButtonFilter.Selected);
                    }
                }
                else
                {
                    CASPart wornPart = ths.mCurrentPreset.mPart;

                    ObjectDesigner.SetCASPart(wornPart.Key);
                    Vector3[] makeupVectorColors = ths.GetMakeupVectorColors(wornPart);
                    uint      num = CASUtils.PartDataNumPresets(wornPart.Key);
                    for (uint j = 0x0; j < num; j++)
                    {
                        KeyValuePair <string, Dictionary <string, Complate> > presetEntryFromPresetString = (KeyValuePair <string, Dictionary <string, Complate> >)SimBuilder.GetPresetEntryFromPresetString(CASUtils.PartDataGetPreset(wornPart.Key, j));
                        Vector3[] vectorArray2 = ths.GetMakeupVectorColors(presetEntryFromPresetString);
                        flag2 = true;
                        for (uint k = 0x0; k < vectorArray2.Length; k++)
                        {
                            if (!makeupVectorColors[k].IsSimilarTo(vectorArray2[k]))
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        uint index = ObjectDesigner.AddDesignPreset(Responder.Instance.CASModel.GetDesignPreset(wornPart));
                        flag = index != uint.MaxValue;
                        CASClothingRow row = ths.FindRow(wornPart);
                        if (row != null)
                        {
                            row.CreateGridItems(true);
                            row.PopulateGrid(true);
                        }
                        ths.mButtonCostumeFilter.Tag = true;
                        ths.mContentTypeFilter.UpdateFilterButtonState();
                        ThumbnailKey key = new ThumbnailKey(wornPart.Key, (int)CASUtils.PartDataGetPresetId(wornPart.Key, index), (uint)wornPart.BodyType, (uint)wornPart.AgeGenderSpecies, ThumbnailSize.Large);
                        ThumbnailManager.InvalidateThumbnail(key);
                    }
                }

                if (flag)
                {
                    CASController.Singleton.ErrorMsg(CASErrorCode.SaveSuccess);
                }
                else if (flag2)
                {
                    Simulator.AddObject(new OneShotFunctionTask(delegate
                    {
                        string messageText = Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/CAS/Hair:SaveDuplicate", new object[0x0]);
                        SimpleMessageDialog.Show(null, messageText, ModalDialog.PauseMode.PauseTask, new Vector2(-1f, -1f), "ui_error", "ui_hardwindow_close");
                    }));
                }
                else
                {
                    CASController.Singleton.ErrorMsg(CASErrorCode.SaveFailed);
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnColorsSaved", e);
            }
        }
コード例 #6
0
ファイル: CASMakeupEx.cs プロジェクト: yakoder/NRaas
        private static void OnDialogClosed(bool accept, bool colorChanged, Color[] colors)
        {
            try
            {
                CASMakeup ths = CASMakeup.gSingleton;
                if (ths == null)
                {
                    return;
                }

                if (CASMakeup.sCategory == BodyTypes.CostumeMakeup)
                {
                    if (accept)
                    {
                        SetMakeupColors(ths, CASMakeup.sCategory, colors, true);
                        List <ItemGridCellItem> items = ths.mGridCostumeParts.Items;
                        int num = 0x0;
                        foreach (ItemGridCellItem item in items)
                        {
                            CASClothingRow mWin = item.mWin as CASClothingRow;
                            if (mWin != null)
                            {
                                mWin.ShowSelectedItem(false);
                                if (mWin.SelectedItem != -1)
                                {
                                    mWin.CreateGridItems(true);
                                    mWin.PopulateGrid(true);
                                    ths.mGridCostumeParts.SelectedItem = num;
                                    ths.mCurrentFocusedRow             = mWin;
                                    ths.mCurrentFocusedRow.SetArrowGlow(true);
                                    ths.mCurrentPreset = mWin.Selection as CASPartPreset;
                                    ths.UpdateCostumePresetState();
                                }
                                num++;
                            }
                        }
                    }
                    else if (colorChanged)
                    {
                        Responder.Instance.CASModel.RequestUndo();
                        Responder.Instance.CASModel.RequestClearRedoOperations();
                    }
                }
                else if (!accept)
                {
                    if (colorChanged)
                    {
                        Responder.Instance.CASModel.RequestUndo();
                        Responder.Instance.CASModel.RequestClearRedoOperations();
                    }
                }
                else
                {
                    SetMakeupColors(ths, CASMakeup.sCategory, colors, true);
                    ths.mGridMakeupPresets.SelectedItem = -1;
                    int index = 0x0;
                    List <ItemGridCellItem> list2 = ths.mGridMakeupPresets.Items;
                    Vector3[] vecColors           = new Vector3[colors.Length];
                    foreach (Color color in colors)
                    {
                        vecColors[index] = CompositorUtil.ColorToVector3(color);
                        index++;
                    }

                    index = 0x0;
                    foreach (ItemGridCellItem item2 in list2)
                    {
                        ResourceKey mTag      = (ResourceKey)item2.mTag;
                        ColorInfo   colorInfo = ColorInfo.FromResourceKey(mTag);
                        if (CASMakeup.CompareColors(vecColors, colorInfo))
                        {
                            ths.mGridMakeupPresets.SelectedItem = index;
                            break;
                        }
                        index++;
                    }
                    ths.UpdatePresetState();
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnDialogClosed", e);
            }
        }