public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { SDictionary <object, object> sdict = (SDictionary <object, object>)obj; info.AddValue("keys", new List <object>(sdict.Keys)); info.AddValue("values", new List <object>(sdict.Values)); }
private static void GenericMenuAddGUI <TKey, TValue>(this SDictionary <TKey, TValue> dict, GenericMenu menu) { if (EditorGUILayout.DropdownButton(new GUIContent("+"), FocusType.Keyboard)) { menu.ShowAsContext(); } }
public void ActEffect(SDictionary dict) { if (dict.keys.Contains(s)) { if (type == operationType.Add) { dict.SetValue(s, dict.value(s) + f); } if (type == operationType.Divide) { dict.SetValue(s, dict.value(s) / f); } if (type == operationType.Minus) { dict.SetValue(s, dict.value(s) - f); } if (type == operationType.Multiply) { dict.SetValue(s, dict.value(s) * f); } if (type == operationType.Equal) { dict.SetValue(s, f); } } }
public static bool SubstitutionsMatch(SDictionary <string, string> substitutions, SDictionary <string, string> other) { if (substitutions == null) { return(other == null || other.Count == 0); } if (substitutions.Count == 0) { return(other == null || other.Count == 0); } if (substitutions.Count != other.Count) { return(false); } //we're down to the wire now, have to check each entry foreach (KeyValuePair <string, string> sub in substitutions) { string otherSubValue = string.Empty; if (!other.TryGetValue(sub.Key, out otherSubValue) || otherSubValue != sub.Value) { //other contained entry that didn't match sub entry return(false); } } //wow they're actually the same return(true); }
// Use this for initialization void Start() { // A voxel dictionary to store all the voxel viewing information voxelDict = new SDictionary(); viewportVoxelDict = new SDictionary(); connectionDict = new V1Dictionary(); // Start with a dummy voxel. currentVoxel = new Voxel(); previousIndex = new Vector3(0, 0, 0); previousDisplayPosition = new Vector3(0, 0, 0); previousViewportIndex = new Vector3(0, 0, 0); previousViewportDisplayPosition = new Vector3(0, 0, 0); // Start with a dummy viewport currentViewportVoxel = new Voxel(); // Scale the marker transform once at the beginning of the run. marker.transform.localScale = gridInterval; // Scale the viewport marker transform once at the beginning of the run. viewportMarker.transform.localScale = viewportGridInterval; // Set up the export timer timeLimit = exportTime; }
public void MapAssets() { if (mAssetBundle != null && mAssetMap == null) { try { string[] names = mAssetBundle.GetAllAssetNames(); mMainAsset = mAssetBundle.mainAsset; if (mMainAsset == null && names.Length > 0) { mMainAsset = mAssetBundle.LoadAsset(names[0]); } if (names.Length > 0) { mAssetMap = new SDictionary <int, UnityEngine.Object>(); for (int i = 0; i < names.Length; ++i) { //Debug.Log("<color=yellow> names: " + i + " " + names[i] + "</color>"); mAssetMap[names[i].GetHashCode()] = mAssetBundle.LoadAsset(names[i]); } } } catch { string[] names = mAssetBundle.GetAllAssetNames(); if (names.Length > 0) { Debug.LogError("MapAssets:" + names[0]); } } } }
public WIGroupsState() { LocationExcludeTypes = new List <string> (); LocationLookup = new SDictionary <string, string> (); QuestItemLookup = new SDictionary <string, string> (); CharacterLookup = new SDictionary <string, string> (); LocationExcludeTypes.Add("PathMarker"); }
public EditPageText(TalkDataContainerScriptable.EditPageData data) { _data = data; _temp = new SDictionary <int, Highlight>(); _highlightedText = new StringBuilder(); Init(); OnTextChanged += OnTextChangedHandler; }
static void Main(string[] args) { SDictionary <string, string> b = new SDictionary <string, string>(); b.Add("foo", "bar"); System.IO.MemoryStream memStream = new System.IO.MemoryStream(); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); f.Serialize(memStream, b); memStream.Position = 0; b = f.Deserialize(memStream) as SDictionary <string, string>; }
public static void DoGUILayout <TKey, TValue>(this SDictionary <TKey, TValue> dict, ValueGUI <TValue> valueGUI, AddGUI addGUI, string title, bool oneLine = false, bool showRemove = true) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(title + ": " + dict.Count, EditorUtils.Bold, GUILayout.MaxWidth(120)); GUILayout.Space(-20); //GUILayout.FlexibleSpace(); addGUI(); GUILayout.EndHorizontal(); EditorUtils.Separator(); if (dict.Count > 0) { DoGUILayout(dict, valueGUI, oneLine, showRemove); } }
private static void StringAddGUI <TValue>(SDictionary <string, TValue> dict, ref string toAdd, GetNew <TValue> getNew) { EditorGUILayout.LabelField("New:", GUILayout.Width(45)); toAdd = EditorGUILayout.TextField(toAdd); if (GUILayout.Button(new GUIContent("Add"), GUILayout.Width(45))) { if (!string.IsNullOrWhiteSpace(toAdd) && !dict.ContainsKey(toAdd)) { dict.Add(toAdd, getNew()); } toAdd = string.Empty; GUIUtility.keyboardControl = 0; } }
private static void EnumAddGUI <TKey, TValue>(this SDictionary <TKey, TValue> dict, GetNew <TValue> getNew) where TKey : System.Enum { if (EditorGUILayout.DropdownButton(new GUIContent("+"), FocusType.Keyboard)) { GenericMenu menu = new GenericMenu(); foreach (var t in EnumUtils.GetValues <TKey>()) { if (!dict.ContainsKey(t)) { menu.AddItem(new GUIContent(t.ToString()), false, (obj) => dict.Add((TKey)obj, getNew()), t); } } menu.ShowAsContext(); } }
public void SaveColors() { //find fields FieldInfo[] fields = this.GetType().GetFields(); SDictionary <string, SColor> saveData = new SDictionary <string, SColor>(); foreach (FieldInfo field in fields) { if (field.FieldType == typeof(Color)) //TODO find best way to clean fields { string colorName = field.Name; Color color = (Color)field.GetValue(this); mStandardColorLookup.Add(colorName, color); } } }
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { SDictionary <object, object> sdict = new SDictionary <object, object>(); List <object> keys = (List <object>)info.GetValue("keys", typeof(List <object>)); List <object> values = (List <object>)info.GetValue("values", typeof(List <object>)); for (int i = 0; i < keys.Count; i++) { sdict.Add(keys[i], i < values.Count ? values[i] : default); } obj = sdict; return(obj); }
public bool passCheck(SDictionary newD) { dict = newD; if (available(propertyName)) { if (checkType == propertyCheck.GreaterThan) { if (dict.value(propertyName) > value) { return(true); } } else if (checkType == propertyCheck.EqualTo) { if (dict.value(propertyName) == value) { return(true); } } else if (checkType == propertyCheck.GreaterOrEqual) { if (dict.value(propertyName) >= value) { return(true); } } else if (checkType == propertyCheck.LowerOrEqual) { if (dict.value(propertyName) <= value) { return(true); } } else if (checkType == propertyCheck.LowerThan) { if (dict.value(propertyName) < value) { return(true); } } else if (checkType == propertyCheck.NA) { return(true); } return(false); } return(false); }
public void Load() { if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var files = Directory.GetFiles(dir); foreach (var file in files) { if (!File.Exists(file)) { continue; } var lines = File.ReadAllLines(file); foreach (var line in lines) { // 주석 라인 처리 if (line.StartsWith("#")) { continue; } var columns = line.Split(';'); if (columns.Length < 2) { continue; } var answer = columns[0].Trim(); var desc = columns[1].Trim(); var selections = answer.Split(':'); if (selections.Length == 1) { // 주관식 문제 Dictionary.Add(new Question(answer, desc)); } else { // 답안 지정 객관식 문제 SDictionary.Add(new SelectableQuestion(selections.ToList(), desc)); } } } }
public void UnLoadAssets() { if (mAssetMap != null) { foreach (KeyValuePair <int, UnityEngine.Object> kvp in mAssetMap) { if (kvp.Value != null) { UnLoadAsset(kvp.Value); } } mAssetMap.Clear(); mAssetMap = null; } if (mMainAsset != null) { UnLoadAsset(mMainAsset); } mMainAsset = null; }
private static void DoGUILayout <TKey, TValue>(SDictionary <TKey, TValue> dict, ValueGUI <TValue> valueGUI, bool oneLine, bool showRemove) { EditorGUI.indentLevel++; TKey toDelete = default; bool delete = false; TKey[] keys = new TKey[dict.Count]; dict.Keys.CopyTo(keys, 0); System.Array.Sort(keys); foreach (var key in keys) { GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(key.ToString()); GUILayout.Space(1); if (oneLine) { dict[key] = valueGUI(dict[key]); } if (showRemove) { GUILayout.FlexibleSpace(); if (GUILayout.Button("-", GUILayout.Width(45))) { toDelete = key; delete = true; } } GUILayout.EndHorizontal(); if (!oneLine) { dict[key] = valueGUI(dict[key]); } } if (delete) { dict.Remove(toDelete); } EditorGUI.indentLevel--; EditorUtils.Separator(); }
public void CopyFrom(WISaveState saveState) { CanEnterInventory = saveState.CanEnterInventory; CanBeCarried = saveState.CanBeCarried; CanBeDropped = saveState.CanBeDropped; UnloadWhenStacked = saveState.UnloadWhenStacked; LastState = saveState.LastState; if (Scripts == null) { Scripts = new SDictionary <string, string>(); } else { Scripts.Clear(); } var scriptsEnum = saveState.Scripts.GetEnumerator(); while (scriptsEnum.MoveNext()) { Scripts.Add(scriptsEnum.Current.Key, scriptsEnum.Current.Value); } }
public void RefreshCuratedItems() { //looks through each worlditem in the current museum's list //and sets it to visible / proper quality for (int i = 0; i < ActiveCuratedArtifacts.Count; i++) { Artifact artifact = ActiveCuratedArtifacts[i]; if (artifact != null && artifact.State.MuseumName == ActiveMuseum.Name) { //see if the artifact list contains its age //if it does, make it visible with the highest quality //otherwise make it invisible bool isVisible = false; ArtifactQuality aquiredQuality; SDictionary <ArtifactAge, ArtifactQuality> lookup = null; if (artifact.StackName.Contains("Large")) { lookup = ActiveMuseum.LargeArtifactsAquired; } else { lookup = ActiveMuseum.SmallArtifactsAquired; } if (lookup.TryGetValue(artifact.State.Age, out aquiredQuality)) { //we've aquired this age artifact //so make it visible and set the quality artifact.SetCuratedProperties(true, aquiredQuality); } else { //we havnen't aquired it, make it invisible artifact.SetCuratedProperties(false, ArtifactQuality.VeryPoor); } } } }
public void Solve() { int n = ReadInt(); int m = ReadInt(); var a = ReadIntMatrix(n); int ans = n; var f = new bool[m + 1]; var p = new int[n]; for (int i = 0; i < m; i++) { var d = new SDictionary <int, int>(); for (int j = 0; j < n; j++) { while (f[a[j][p[j]]]) { p[j]++; } d[a[j][p[j]]]++; } int x = 1; for (int j = 2; j <= m; j++) { if (d[j] > d[x]) { x = j; } } ans = Math.Min(ans, d[x]); f[x] = true; } Write(ans); }
private void LoadfilesBackground(System.Object sender, DoWorkEventArgs e) { string aerror = string.Empty; try { if (sender != null) { BackgroundWorker worker = (BackgroundWorker)sender; worker.DoWork -= LoadfilesBackground; } if (File.Exists(mPluginConfigfilename)) { this.mPluginConfig = (PluginSettings)Util.DeSerializeObject(mPluginConfigfilename, typeof(PluginSettings)); } //create default file if (mPluginConfig == null) { mPluginConfig = new PluginSettings(); mPluginConfig.Shortcuts = new SDictionary<string, string>(); mPluginConfig.Shortcuts.Add("hr", "House Recall"); mPluginConfig.Shortcuts.Add("mr", "House Mansion_Recall"); mPluginConfig.Shortcuts.Add("ah", "Allegiance Hometown"); mPluginConfig.Shortcuts.Add("ls", "Lifestone"); mPluginConfig.Shortcuts.Add("mp", "Marketplace"); mPluginConfig.Alerts = getbaseAlerts(); mPluginConfig.AlertKeyMob = "Monster"; mPluginConfig.AlertKeyPortal = "Portal"; mPluginConfig.AlertKeySalvage = "Salvage"; mPluginConfig.AlertKeyScroll = "Salvage"; mPluginConfig.AlertKeyThropy = "Trophy"; mPluginConfig.Alertwawfinished = "finished.wav"; } //HACK: Still hating the sounds // mplayer = new mediaplayer(); // mplayer.Volume = mPluginConfig.wavVolume; loadcolortable(); //Check for Gamedata.xml if (!File.Exists(Util.docPath + "\\GameData.xml")) { //Create it if !exists iGameData.defaultfill(); Util.SerializeObject(Util.docPath + "\\GameData.xml", iGameData); } //Now that it exists, check version and update if needed if (File.Exists(Util.docPath + "\\GameData.xml")) { iGameData = (AlincoVVS.PluginCore.GameData)Util.DeSerializeObject(Util.docPath + "\\GameData.xml", typeof(GameData)); //Look to code this for a single line revision of Gamedata version, currently must update in 2 locations if (iGameData.version < 10) { iGameData.defaultfill(); Util.SerializeObject(Util.docPath + "\\GameData.xml", iGameData); } } mWorldConfigfilename = Util.docPath + "\\" + Util.normalizePath(Core.CharacterFilter.Server); if (!Directory.Exists(mWorldConfigfilename)) { Directory.CreateDirectory(mWorldConfigfilename); } mExportInventoryname = Util.docPath + "\\Inventory"; if (!Directory.Exists(mExportInventoryname)) { Directory.CreateDirectory(mExportInventoryname); writebasexslt(mExportInventoryname + "\\Inventory.xslt"); } mExportInventoryname += "\\" + Core.CharacterFilter.Server + ".xml"; mWorldInventoryname = Util.docPath + "\\" + Util.normalizePath(Core.CharacterFilter.Server) + "\\Inventory.xml"; if (File.Exists(mWorldInventoryname)) { object tobj = Util.DeSerializeObject(mWorldInventoryname, typeof(SDictionary<int, InventoryItem>)); if (tobj != null) { mGlobalInventory = (global::AlincoVVS.PluginCore.SDictionary<int, global::AlincoVVS.PluginCore.InventoryItem>)tobj; mStorageInfo = (global::AlincoVVS.PluginCore.SDictionary<int, string>)Util.DeSerializeObject(mWorldInventoryname + "storage", typeof(SDictionary<int, string>)); } else { mGlobalInventory = new SDictionary<int, InventoryItem>(); } } else { writebasexslt(Util.docPath + "\\" + Util.normalizePath(Core.CharacterFilter.Server) + "\\Inventory.xslt"); } mCharConfigfilename = mWorldConfigfilename; mWorldConfigfilename += "\\Settings.xml"; if (File.Exists(mWorldConfigfilename)) { mWorldConfig = (WorldSettings)Util.DeSerializeObject(mWorldConfigfilename, typeof(WorldSettings)); } mCharConfigfilename += "\\" + Util.normalizePath(Core.CharacterFilter.Name) + ".xml"; if (File.Exists(mCharConfigfilename)) { mCharconfig = (CharSettings)Util.DeSerializeObject(mCharConfigfilename, typeof(CharSettings)); } if (mWorldConfig == null) { mWorldConfig = new WorldSettings(); } if (mCharconfig == null) { mCharconfig = new CharSettings(); } mProtectedCorpses.Add("Corpse of " + Core.CharacterFilter.Name); mFilesLoaded = true; } catch (Exception ex) { aerror = ex.Message + ex.StackTrace; Util.ErrorLogger(ex); } if (aerror != string.Empty) { Util.bcast(aerror); } }
public static void EnumAddGUIVal <TKey, TValue>(this SDictionary <TKey, TValue> dict) where TKey : System.Enum { EnumAddGUI(dict, () => default); }
public static void EnumAddGUI <TKey, TValue>(this SDictionary <TKey, TValue> dict) where TKey : System.Enum where TValue : new() { EnumAddGUI(dict, () => new TValue()); }
public static void StringAddGUI <TValue>(this SDictionary <string, TValue> dict, ref string toAdd) where TValue : new() { StringAddGUI(dict, ref toAdd, () => new TValue()); }
public static void StringAddGUID <TValue>(this SDictionary <string, TValue> dict, ref string toAdd) { StringAddGUI(dict, ref toAdd, () => default); }