private void LoadLanguageList() { SortedDictionary <string, string> treemap = new SortedDictionary <string, string>(); try { StreamReader bufferedreader = new StreamReader(Minecraft.GetResourceStream("lang.languages.txt"), Encoding.UTF8); for (string s = bufferedreader.ReadLine(); s != null; s = bufferedreader.ReadLine()) { string[] @as = StringHelperClass.StringSplit(s, "=", true); if (@as != null && @as.Length == 2) { treemap[@as[0]] = @as[1]; } } } catch (IOException ioexception) { Utilities.LogException(ioexception); return; } languageList = treemap; }
public virtual void Compile(string src) { string[] srcShaders = StringHelperClass.StringSplit(src, "//\n", true); Attach(Shader.CreateCompiled(Shader.VERTEX, srcShaders[0])); Attach(Shader.CreateCompiled(Shader.FRAGMENT, srcShaders[1])); Link(); }
private string CheckH2pSuffix(string a) { string[] temp = StringHelperClass.StringSplit(a, "[.]h2p", true); string tempus = temp[0]; tempus = tempus + ".h2p"; return(tempus); }
private object parseTextData(string data, int tagValue) { // first, get the description of what we're supposed to parse EventValueDescription[] desc = mValueDescriptionMap[tagValue]; if (desc == null) { // TODO parse and create string values. return(null); } if (desc.Length == 1) { return(getObjectFromString(data, desc[0].eventValueType)); } else if (data.StartsWith("[") && data.EndsWith("]")) { data = data.Substring(1, data.Length - 1 - 1); // get each individual values as String string[] values = StringHelperClass.StringSplit(data, ",", true); if (tagValue == GcEventContainer.GC_EVENT_TAG) { // special case for the GC event! object[] objects = new object[2]; objects[0] = getObjectFromString(values[0], EventContainer.EventValueTypes.LONG); objects[1] = getObjectFromString(values[1], EventContainer.EventValueTypes.LONG); return(objects); } else { // must be the same number as the number of descriptors. if (values.Length != desc.Length) { return(null); } object[] objects = new object[values.Length]; for (int i = 0; i < desc.Length; i++) { object obj = getObjectFromString(values[i], desc[i].eventValueType); if (obj == null) { return(null); } objects[i] = obj; } return(objects); } } return(null); }
/// <summary> /// Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). /// </summary> protected override void KeyTyped(char par1, int par2) { ServerTextField.Func_50037_a(par1, par2); if (par1 == 034) { ActionPerformed(ControlList[0]); } ControlList[0].Enabled = ServerTextField.GetText().Length > 0 && StringHelperClass.StringSplit(ServerTextField.GetText(), ":", true).Length > 0; }
/// <summary> /// Adds the buttons (and other controls) to the screen in question. /// </summary> public override void InitGui() { StringTranslate stringtranslate = StringTranslate.GetInstance(); //Keyboard.EnableRepeatEvents(true); ControlList.Clear(); ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + 12, stringtranslate.TranslateKey("selectServer.select"))); ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel"))); ServerTextField = new GuiTextField(FontRenderer, Width / 2 - 100, 116, 200, 20); ServerTextField.SetMaxStringLength(128); ServerTextField.setFocused(true); ServerTextField.SetText(Field_52009_d); ControlList[0].Enabled = ServerTextField.GetText().Length > 0 && StringHelperClass.StringSplit(ServerTextField.GetText(), ":", true).Length > 0; }
/// <summary> /// Adds the buttons (and other controls) to the screen in question. /// </summary> public override void InitGui() { StringTranslate stringtranslate = StringTranslate.GetInstance(); //Keyboard.EnableRepeatEvents(true); ControlList.Clear(); ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + 12, stringtranslate.TranslateKey("addServer.add"))); ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel"))); ServerName = new GuiTextField(FontRenderer, Width / 2 - 100, 76, 200, 20); ServerName.setFocused(true); ServerName.SetText(ServerNBTStorage.Name); ServerAddress = new GuiTextField(FontRenderer, Width / 2 - 100, 116, 200, 20); ServerAddress.SetMaxStringLength(128); ServerAddress.SetText(ServerNBTStorage.Host); ControlList[0].Enabled = ServerAddress.GetText().Length > 0 && StringHelperClass.StringSplit(ServerAddress.GetText(), ":", true).Length > 0 && ServerName.GetText().Length > 0; }
/// <summary> /// Join server by ServerNBTStorage /// </summary> private void JoinServer(ServerNBTStorage par1ServerNBTStorage) { string s = par1ServerNBTStorage.Host; string[] @as = StringHelperClass.StringSplit(s, ":", true); if (s.StartsWith("[")) { int i = s.IndexOf("]"); if (i > 0) { string s1 = s.Substring(1, i - 1); string s2 = s.Substring(i + 1).Trim(); if (s2.StartsWith(":") && s2.Length > 0) { s2 = s2.Substring(1); @as = new string[2]; @as[0] = s1; @as[1] = s2; } else { @as = new string[1]; @as[0] = s1; } } } if (@as.Length > 2) { @as = new string[1]; @as[0] = s; } Mc.DisplayGuiScreen(new GuiConnecting(Mc, @as[0], @as.Length <= 1 ? 25565 : ParseIntWithDefault(@as[1], 25565))); }
private AchievementMap() { GuidMap = new Dictionary <int, string>(); try { StreamReader bufferedreader = new StreamReader(Minecraft.GetResourceStream("achievement.map.txt")); string s; while ((s = bufferedreader.ReadLine()) != null) { string[] @as = StringHelperClass.StringSplit(s, ",", true); int i = Convert.ToInt32(@as[0]); GuidMap[i] = @as[1]; } bufferedreader.Close(); } catch (Exception exception) { Utilities.LogException(exception); } }
/// <summary> /// Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). /// </summary> protected override void KeyTyped(char par1, int par2) { ServerName.Func_50037_a(par1, par2); ServerAddress.Func_50037_a(par1, par2); if (par1 == '\t') { if (ServerName.Func_50025_j()) { ServerName.setFocused(false); ServerAddress.setFocused(true); } else { ServerName.setFocused(true); ServerAddress.setFocused(false); } } if (par1 == '\r') { ActionPerformed(ControlList[0]); } ControlList[0].Enabled = ServerAddress.GetText().Length > 0 && StringHelperClass.StringSplit(ServerAddress.GetText(), ":", true).Length > 0 && ServerName.GetText().Length > 0; if (ControlList[0].Enabled) { string s = ServerAddress.GetText().Trim(); string[] @as = StringHelperClass.StringSplit(s, ":", true); if (@as.Length > 2) { ControlList[0].Enabled = false; } } }
private EventValueDescription[] processDescription(string description) { string[] descriptions = StringHelperClass.StringSplit(description, "\\s*,\\s*", true); //$NON-NLS-1$ List <EventValueDescription> list = new List <EventValueDescription>(); foreach (string desc in descriptions) { var m = PATTERN_DESCRIPTION.Match(desc); if (m.Success) { try { string name = m.Groups[0].Value; string typeString = m.Groups[1].Value; int typeValue = Convert.ToInt32(typeString); EventContainer.EventValueTypes?eventValueType = EventContainer.EventValueType.getEventValueType(typeValue); if (eventValueType == null) { // just ignore this description if the value is not recognized. // TODO: log the error. } typeString = m.Groups[2].Value; if (typeString != null && typeString.Length > 0) { //skip the | typeString = typeString.Substring(1); typeValue = Convert.ToInt32(typeString); var valueType = (EventValueDescription.ValueTypes)typeValue; list.Add(new EventValueDescription(name, eventValueType.Value, valueType)); } else { list.Add(new EventValueDescription(name, eventValueType.Value)); } } catch (SystemException) { // just ignore this description if one number is malformed. // TODO: log the error. } catch (InvalidValueTypeException) { // just ignore this description if data type and data unit don't match // TODO: log the error. } } else { Log.e("EventLogParser", string.Format("Can't parse {0}", description)); //$NON-NLS-1$ - $NON-NLS-1$ } } if (list.Count == 0) { return(null); } return(list.ToArray()); }
private string RemoveFileSuffix(string a) { // THIS DOES NOT WORK CAUSE OF PATH -> return Path.GetFileNameWithoutExtension(a); string[] temp = StringHelperClass.StringSplit(a, "[.]", true); return(temp[0]); }
/// <summary> /// Loads the options from the options file. It appears that this has replaced the previous 'loadOptions' /// </summary> public virtual void LoadOptions() { try { if (!File.Exists(OptionsFile)) { return; } StreamReader bufferedreader = new StreamReader(OptionsFile); for (string s = ""; (s = bufferedreader.ReadLine()) != null;) { try { string[] @as = StringHelperClass.StringSplit(s, ":", true); if (@as[0].Equals("music")) { MusicVolume = ParseFloat(@as[1]); } if (@as[0].Equals("sound")) { SoundVolume = ParseFloat(@as[1]); } if (@as[0].Equals("mouseSensitivity")) { MouseSensitivity = ParseFloat(@as[1]); } if (@as[0].Equals("fov")) { FovSetting = ParseFloat(@as[1]); } if (@as[0].Equals("gamma")) { GammaSetting = ParseFloat(@as[1]); } if (@as[0].Equals("invertYMouse")) { InvertMouse = @as[1].Equals("true"); } if (@as[0].Equals("viewDistance")) { RenderDistance = Convert.ToInt32(@as[1]); } if (@as[0].Equals("guiScale")) { GuiScale = Convert.ToInt32(@as[1]); } if (@as[0].Equals("particles")) { ParticleSetting = Convert.ToInt32(@as[1]); } if (@as[0].Equals("bobView")) { ViewBobbing = @as[1].Equals("true"); } if (@as[0].Equals("anaglyph3d")) { Anaglyph = @as[1].Equals("true"); } if (@as[0].Equals("advancedOpengl")) { AdvancedOpengl = @as[1].Equals("true"); } if (@as[0].Equals("fpsLimit")) { LimitFramerate = Convert.ToInt32(@as[1]); } if (@as[0].Equals("difficulty")) { Difficulty = Convert.ToInt32(@as[1]); } if (@as[0].Equals("fancyGraphics")) { FancyGraphics = @as[1].Equals("true"); } if (@as[0].Equals("ao")) { AmbientOcclusion = @as[1].Equals("true"); } if (@as[0].Equals("clouds")) { Clouds = @as[1].Equals("true"); } if (@as[0].Equals("skin")) { Skin = @as[1]; } if (@as[0].Equals("lastServer") && @as.Length >= 2) { LastServer = @as[1]; } if (@as[0].Equals("lang") && @as.Length >= 2) { Language = @as[1]; } int i = 0; while (i < KeyBindings.Length) { if (@as[0].Equals((new StringBuilder()).Append("key_").Append(KeyBindings[i].KeyDescription).ToString())) { KeyBindings[i].KeyCode = Convert.ToInt32(@as[1]); } i++; } } catch (Exception exception1) { Console.WriteLine(exception1.ToString()); Console.WriteLine(); Console.WriteLine((new StringBuilder()).Append("Skipping bad option: ").Append(s).ToString()); } } KeyBinding.ResetKeyBindingArrayAndHash(); bufferedreader.Close(); } catch (Exception exception) { Console.WriteLine("Failed to load options"); Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } }
public void createSharedTypeAttributeIndex(Hashtable knownSharedClasses, Hashtable indexedClasses) { Hashtable commonRBStore = new Hashtable(); Dictionary <string, AttributeIndex> sharedAttributeIndexMap = new Dictionary <string, AttributeIndex>(); IEnumerator iteouterSharedTypes = knownSharedClasses.GetEnumerator(); Type genericType = typeof(RBStore <>).MakeGenericType(Common.MemoryUtil.GetDataType(Common.MemoryUtil.Net_System_String)); IIndexStore store = (IIndexStore)Activator.CreateInstance(genericType, new object[] { _cacheName, Common.MemoryUtil.Net_System_String, this.TAG_INDEX_KEY }); commonRBStore.Add(this.TAG_INDEX_KEY, store); while (iteouterSharedTypes.MoveNext()) { DictionaryEntry outerEntry = (DictionaryEntry)iteouterSharedTypes.Current; Hashtable outerEntryValue = (Hashtable)outerEntry.Value; string name = (string)outerEntryValue["name"]; string[] temp = StringHelperClass.StringSplit(name, ":", true); string outerTypeName = temp[0]; //Create Attribute Index even if not queryindexed sharedAttributeIndexMap.Add(outerTypeName, new AttributeIndex(_cacheName, outerTypeName)); sharedAttributeIndexMap[outerTypeName].TypeMap = _typeMap; if (indexedClasses.Count > 0 && isQueryindexed(outerTypeName, indexedClasses)) { Hashtable outerTypeAttributes = (Hashtable)outerEntryValue["attribute"]; if (outerTypeAttributes != null) { IEnumerator iteOuterTypeAttribute = outerTypeAttributes.GetEnumerator(); while (iteOuterTypeAttribute.MoveNext()) { DictionaryEntry tempEntry = (DictionaryEntry)iteOuterTypeAttribute.Current; Hashtable outerAttributeMeta = (Hashtable)tempEntry.Value; string outerOrderNo = (string)outerAttributeMeta["order"]; string outerAttributeName = (string)outerAttributeMeta["name"]; if (isQueryindexedAttribute(outerTypeName, outerAttributeName, indexedClasses)) { IEnumerator iteInnerSharedTypes = knownSharedClasses.GetEnumerator(); while (iteInnerSharedTypes.MoveNext()) { DictionaryEntry innerEntry = (DictionaryEntry)iteInnerSharedTypes.Current; Hashtable innerEntryValue = (Hashtable)innerEntry.Value; string name1 = (string)innerEntryValue["name"]; string[] temp1 = StringHelperClass.StringSplit(name1, ":", true); string innerTypeName = temp1[0]; if (!outerTypeName.Equals(innerTypeName) && isQueryindexed(innerTypeName, indexedClasses)) { Hashtable innerTypeAttributes = (Hashtable)((Hashtable)innerEntry.Value)["attribute"]; IEnumerator iteInnerTypeAttribute = innerTypeAttributes.GetEnumerator(); while (iteInnerTypeAttribute.MoveNext()) { DictionaryEntry tempEntry1 = (DictionaryEntry)iteInnerTypeAttribute.Current; Hashtable innerAttributeMeta = (Hashtable)tempEntry1.Value; string innerorderNo = (string)innerAttributeMeta["order"]; string innerAttributeName = (string)innerAttributeMeta["name"]; if (innerorderNo.Equals(outerOrderNo) && isQueryindexedAttribute(innerTypeName, innerAttributeName, indexedClasses)) { if (commonRBStore.ContainsKey(outerTypeName + ":" + outerAttributeName)) { if (!commonRBStore.ContainsKey(innerTypeName + ":" + innerAttributeName)) { IIndexStore commonRB = (IIndexStore)commonRBStore[outerTypeName + ":" + outerAttributeName]; commonRBStore.Add(innerTypeName + ":" + innerAttributeName, commonRB); } break; } else { String storeDataType = TypeInfoMap.GetAttributeType(innerTypeName, innerAttributeName); genericType = typeof(RBStore <>).MakeGenericType(Common.MemoryUtil.GetDataType(storeDataType)); IIndexStore commonRB = (IIndexStore)Activator.CreateInstance(genericType, new object[] { _cacheName, storeDataType, innerAttributeName }); commonRBStore.Add(innerTypeName + ":" + innerAttributeName, commonRB); commonRBStore.Add(outerTypeName + ":" + outerAttributeName, commonRB); break; } } } } } } } } } } if (sharedAttributeIndexMap.Count > 0) { IEnumerator iteSharedIndexMap = sharedAttributeIndexMap.GetEnumerator(); while (iteSharedIndexMap.MoveNext()) { List <AttributeIndex> sharedTypes = new List <AttributeIndex>(); System.Collections.Generic.KeyValuePair <string, AttributeIndex> outerEntry = (System.Collections.Generic.KeyValuePair <string, AttributeIndex>)iteSharedIndexMap.Current; string outerTypeName = (string)outerEntry.Key; AttributeIndex outerSharedIndex = (AttributeIndex)outerEntry.Value; foreach (System.Collections.Generic.KeyValuePair <string, AttributeIndex> innerEntry in sharedAttributeIndexMap) { string innerTypeName = (string)innerEntry.Key; if (!innerTypeName.Equals(outerTypeName)) { AttributeIndex innerSharedIndex = (AttributeIndex)innerEntry.Value; sharedTypes.Add(innerSharedIndex); } } outerSharedIndex.CommonRBStores = commonRBStore; _sharedAttributeIndex.Add(outerTypeName, outerSharedIndex); } } }
/// <summary> /// Poll server for MOTD, lag, and player count/max /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void pollServer(ServerNBTStorage par1ServerNBTStorage) throws IOException public void PollServer(ServerNBTStorage par1ServerNBTStorage) { string s = par1ServerNBTStorage.Host; string[] @as = StringHelperClass.StringSplit(s, ":", true); if (s.StartsWith("[")) { int i = s.IndexOf("]"); if (i > 0) { string s2 = s.Substring(1, i - 1); string s3 = s.Substring(i + 1).Trim(); if (s3.StartsWith(":") && s3.Length > 0) { s3 = s3.Substring(1); @as = new string[2]; @as[0] = s2; @as[1] = s3; } else { @as = new string[1]; @as[0] = s2; } } } if (@as.Length > 2) { @as = new string[1]; @as[0] = s; } string s1 = @as[0]; int j = @as.Length <= 1 ? 25565 : ParseIntWithDefault(@as[1], 25565); Socket socket = null; NetworkStream dataStream = null; try { socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.SendTimeout = 3000; //socket.SetTcpNoDelay(true); //socket.SetTrafficClass(18); socket.Connect(s1, j); dataStream = new NetworkStream(socket); dataStream.WriteByte(254); if (dataStream.ReadByte() != 255) { throw new IOException("Bad message"); } string s4 = Packet.ReadString(new BinaryReader(dataStream), 256); char[] ac = s4.ToCharArray(); for (int k = 0; k < ac.Length; k++) { if (ac[k] != '\u0247' && ChatAllowedCharacters.AllowedCharacters.IndexOf(ac[k]) < 0) { ac[k] = '?'; } } s4 = new string(ac); string[] as1 = StringHelperClass.StringSplit(s4, "\u0247", true); s4 = as1[0]; int l = -1; int i1 = -1; try { l = Convert.ToInt32(as1[1]); i1 = Convert.ToInt32(as1[2]); } catch (Exception exception) { Utilities.LogException(exception); } par1ServerNBTStorage.Motd = (new StringBuilder()).Append("\u02477").Append(s4).ToString(); if (l >= 0 && i1 > 0) { par1ServerNBTStorage.PlayerCount = (new StringBuilder()).Append("\u02477").Append(l).Append("\u02478/\u02477").Append(i1).ToString(); } else { par1ServerNBTStorage.PlayerCount = "\u02478???"; } } finally { try { if (dataStream != null) { dataStream.Close(); } } catch (Exception throwable) { Utilities.LogException(throwable); } try { if (socket != null) { socket.Close(); } } catch (Exception throwable2) { Utilities.LogException(throwable2); } } }