public void PlaySound(string name, int vol) { if (paused) { return; } if (sounds.ContainsKey(name)) { AudioEffect ass = ((AudioEffect)sounds.Get(name)); ass.AudioEffectVolume(vol); ass.PlayAudioEffect(); } else { if (clipCount > 50) { int idx = sounds.Size() - 1; string k = (string)sounds.GetKey(idx); AudioEffect clip = (AudioEffect)sounds.Remove(k); clip.StopAudioEffect(); clip = null; clipCount--; } asound = new AudioEffect(name); asound.AudioEffectVolume(vol); asound.PlayAudioEffect(); sounds.Put(name, asound); clipCount++; } }
private void Set(XMLElement Pack) { this.fileName = Pack.GetAttribute("file", null); this.name = Pack.GetAttribute("name", fileName); int r = Pack.GetIntAttribute("r", -1); int g = Pack.GetIntAttribute("g", -1); int b = Pack.GetIntAttribute("b", -1); int a = Pack.GetIntAttribute("a", -1); if (r != -1 && g != -1 && b != -1 && a != -1) { colorMask = new LColor(r, g, b, a); } if (fileName != null) { List <XMLElement> blocks = Pack.List("block"); foreach (XMLElement e in blocks) { PackEntry entry = new PackEntry(null); int id = e.GetIntAttribute("id", count); entry.id = id; entry.fileName = e.GetAttribute("name", null); entry.bounds.left = e.GetIntAttribute("left", 0); entry.bounds.top = e.GetIntAttribute("top", 0); entry.bounds.right = e.GetIntAttribute("right", 0); entry.bounds.bottom = e.GetIntAttribute("bottom", 0); if (entry.fileName != null) { temps.Put(entry.fileName, entry); } else { temps.Put(Convert.ToString(id), entry); } count++; } this.packing = false; this.packed = true; } this.useAlpha = true; }
public void Add(String resName, int x, int y, int w, int h) { String path = _Update(resName); lock (charas) { String keyName = path.Replace(" ", "").ToLower(); AVGChara chara = (AVGChara)charas.Get(keyName); if (chara == null) { chara = new AVGChara(path, x, y, w, h); chara.SetFlag(FadeEffect.TYPE_FADE_OUT, charaShowDelay); charas.Put(keyName, chara); } else { chara.SetFlag(FadeEffect.TYPE_FADE_OUT, charaShowDelay); chara.SetX(x); chara.SetY(y); } } }
private void Parse(Stream file) { if (displays == null) { displays = new ArrayMap(DEFAULT_MAX_CHAR); } else { displays.Clear(); } try { StreamReader ins = new StreamReader(file, System.Text.Encoding.UTF8); info = ins.ReadLine(); common = ins.ReadLine(); page = ins.ReadLine(); ArrayMap kerning = new ArrayMap( 64); List <CharDef> charDefs = new List <CharDef>( DEFAULT_MAX_CHAR); int maxChar = 0; bool done = false; for (; !done;) { string line = ins.ReadLine(); if (line == null) { done = true; } else { if (line.StartsWith("chars c")) { } else if (line.StartsWith("char")) { CharDef def = ParseChar(line); if (def != null) { maxChar = MathUtils.Max(maxChar, def.id); charDefs.Add(def); } } if (line.StartsWith("kernings c")) { } else if (line.StartsWith("kerning")) { StringTokenizer tokens = new StringTokenizer(line, " ="); tokens.NextToken(); tokens.NextToken(); short first = short.Parse(tokens.NextToken()); tokens.NextToken(); int second = int.Parse(tokens.NextToken()); tokens.NextToken(); int offset = int.Parse(tokens.NextToken()); List <short> values = (List <short>)kerning.GetValue(first); if (values == null) { values = new List <short>(); kerning.Put(first, values); } values.Add((short)((offset << 8) | second)); } } } this.chars = new CharDef[maxChar + 1]; for (IEnumerator <CharDef> iter = charDefs.GetEnumerator(); iter.MoveNext();) { CharDef def = (CharDef)iter.Current; chars[def.id] = def; } ArrayMap.Entry[] entrys = kerning.ToEntrys(); for (int j = 0; j < entrys.Length; j++) { ArrayMap.Entry entry = entrys[j]; short first = (short)entry.GetKey(); List <short> valueList = (List <short>)entry.GetValue(); short[] valueArray = new short[valueList.Count]; int i = 0; for (IEnumerator <short> valueIter = valueList.GetEnumerator(); valueIter .MoveNext(); i++) { valueArray[i] = (short)valueIter.Current; } chars[first].kerning = valueArray; } } catch (IOException e) { Log.Exception(e); throw new Exception("Invalid font file: " + file); } }
public string DoExecute() { if (isClose) { return(null); } this.executeCommand = null; this.addCommand = true; this.isInnerCommand = (innerCommand != null); this.if_bool = false; this.elseif_bool = false; try { if (isInnerCommand && isCall) { SetVariables(innerCommand.GetVariables()); if (innerCommand.Next()) { return(innerCommand.DoExecute()); } else { InnerCallFalse(); return(executeCommand); } } else if (isInnerCommand && !isCall) { SetVariables(innerCommand.GetVariables()); if (innerCommand.Next()) { return(innerCommand.DoExecute()); } else { innerCommand = null; isInnerCommand = false; return(executeCommand); } } nowPosFlagName = offsetPos.ToString(); int length = conditionEnvironmentList.Size(); if (length > 0) { object ifResult = conditionEnvironmentList.Get(length - 1); if (ifResult != null) { backIfBool = (bool)(((Boolean)ifResult)); } } if (scriptList == null) { ResetCache(); return(executeCommand); } else if (scriptList.Length - 1 < offsetPos) { ResetCache(); return(executeCommand); } string cmd = scriptList[offsetPos]; if (cmd.StartsWith(RESET_CACHE_TAG)) { ResetCache(); return(executeCommand); } if (isCache) { cacheCommandName = NowCacheOffsetName(cmd); object cache = CollectionUtils.Get(scriptContext, cacheCommandName); if (cache != null) { return((string)cache); } } if (flaging) { flaging = !(cmd.StartsWith(FLAG_LS_E_TAG) || cmd .EndsWith(FLAG_LS_E_TAG)); return(executeCommand); } if (!flaging) { if (cmd.StartsWith(FLAG_LS_B_TAG) && !cmd.EndsWith(FLAG_LS_E_TAG)) { flaging = true; return(executeCommand); } else if (cmd.StartsWith(FLAG_LS_B_TAG) && cmd.EndsWith(FLAG_LS_E_TAG)) { return(executeCommand); } } SetupRandom(cmd); SetupSET(cmd); if (cmd.EndsWith(END_TAG)) { functioning = false; return(executeCommand); } if (cmd.StartsWith(BEGIN_TAG)) { temps = CommandSplit(cmd); if (temps.Count == 2) { functioning = true; functions.Put(temps[1], new string[0]); return(executeCommand); } } if (functioning) { int size = functions.Size() - 1; string[] function = (string[])functions.Get(size); int index = function.Length; function = (string[])CollectionUtils.Expand(function, 1); function[index] = cmd; functions.Set(size, function); return(executeCommand); } if (((!esleflag && !ifing) || (esleflag && ifing)) && cmd.StartsWith(CALL_TAG) && !isCall) { temps = CommandSplit(cmd); if (temps.Count == 2) { string functionName = (string)temps[1]; string[] funs = (string[])functions.Get(functionName); if (funs != null) { innerCommand = new Command(scriptName + FLAG + functionName, funs); innerCommand.CloseCache(); innerCommand.SetVariables(GetVariables()); InnerCallTrue(); return(null); } } } if (!if_bool && !elseif_bool) { if_bool = cmd.StartsWith(IF_TAG); elseif_bool = cmd.StartsWith(ELSE_TAG); } if (if_bool) { esleover = esleflag = SetupIF(cmd, nowPosFlagName, setEnvironmentList, conditionEnvironmentList); addCommand = false; ifing = true; } else if (elseif_bool) { string[] value_ren = StringUtils.Split(cmd, " "); if (!backIfBool && !esleflag) { if (value_ren.Length > 1 && IF_TAG.Equals(value_ren[1])) { esleover = esleflag = SetupIF( cmd.Replace(ELSE_TAG, "").Trim(), nowPosFlagName, setEnvironmentList, conditionEnvironmentList); addCommand = false; } else if (value_ren.Length == 1 && ELSE_TAG.Equals(value_ren[0])) { if (!esleover) { esleover = esleflag = SetupIF("if 1==1", nowPosFlagName, setEnvironmentList, conditionEnvironmentList); addCommand = false; } } } else { esleflag = false; addCommand = false; conditionEnvironmentList.Put(nowPosFlagName, (bool)(false)); } } if (cmd.StartsWith(IF_END_TAG)) { conditionEnvironmentList.Clear(); backIfBool = false; addCommand = false; ifing = false; if_bool = false; elseif_bool = false; esleover = false; return(null); } if (backIfBool) { if (cmd.StartsWith(INCLUDE_TAG)) { if (IncludeCommand(cmd)) { return(null); } } } else if (cmd.StartsWith(INCLUDE_TAG) && !ifing && !backIfBool && !esleflag) { if (IncludeCommand(cmd)) { return(null); } } if (cmd.StartsWith(OUT_TAG)) { isRead = false; addCommand = false; executeCommand = (SELECTS_TAG + " " + readBuffer.ToString()); } if (isRead) { readBuffer.Append(cmd); readBuffer.Append(FLAG); addCommand = false; } if (cmd.StartsWith(IN_TAG)) { readBuffer.Remove(0, readBuffer.Length - (0)); isRead = true; return(executeCommand); } if (addCommand && ifing) { if (backIfBool && esleflag) { executeCommand = cmd; } } else if (addCommand) { executeCommand = cmd; } if (cmd.StartsWith(FLAG_SAVE_TAG)) { temps = CommandSplit(cmd); if (temps != null && temps.Count == 2) { executeCommand = cmd; SaveCommand(null, null); return(executeCommand); } } else if (cmd.StartsWith(FLAG_LOAD_TAG)) { temps = CommandSplit(cmd); if (temps != null && temps.Count == 2) { executeCommand = cmd; LoadCommand(null, -1); return(executeCommand); } } if (executeCommand != null) { printTags = Command.GetNameTags(executeCommand, PRINT_TAG + BRACKET_LEFT_TAG, BRACKET_RIGHT_TAG); if (printTags != null) { for (IEnumerator it = printTags.GetEnumerator(); it.MoveNext();) { string key = (string)it.Current; object value_ren = CollectionUtils.Get(setEnvironmentList, key); if (value_ren != null) { executeCommand = StringUtils .ReplaceMatch( executeCommand, (PRINT_TAG + BRACKET_LEFT_TAG + key + BRACKET_RIGHT_TAG) , value_ren.ToString()); } else { executeCommand = StringUtils .ReplaceMatch( executeCommand, (PRINT_TAG + BRACKET_LEFT_TAG + key + BRACKET_RIGHT_TAG) , key); } } } if (isCache) { CollectionUtils.Put(scriptContext, cacheCommandName, executeCommand); } } } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { if (!isInnerCommand) { offsetPos++; } } return(executeCommand); }
private bool SetupIF(string commandString, string nowPosFlagName, Dictionary <object, object> setEnvironmentList, ArrayMap conditionEnvironmentList) { bool result = false; conditionEnvironmentList.Put(nowPosFlagName, (bool)(false)); try { IList temps = CommandSplit(commandString); int size = temps.Count; object valueA = null; object valueB = null; string condition = null; if (size <= 4) { valueA = temps[1]; valueB = temps[3]; valueA = (CollectionUtils.Get(setEnvironmentList, valueA) == null) ? valueA : CollectionUtils.Get(setEnvironmentList, valueA); valueB = (CollectionUtils.Get(setEnvironmentList, valueB) == null) ? valueB : CollectionUtils.Get(setEnvironmentList, valueB); condition = (string)temps[2]; } else { int count = 0; StringBuilder sbr = new StringBuilder(); for (IEnumerator it = temps.GetEnumerator(); it.MoveNext();) { string res = (string)it.Current; if (count > 0) { if (!IsCondition(res)) { sbr.Append(res); } else { valueA = sbr.ToString(); valueA = exp.Parse(valueA).ToString(); sbr.Remove(0, sbr.Length - (0)); condition = res; } } count++; } valueB = sbr.ToString(); } if (!MathUtils.IsNan((string)valueB)) { try { valueB = exp.Parse(valueB); } catch (Exception) { } } if (valueA == null || valueB == null) { conditionEnvironmentList .Put(nowPosFlagName, (bool)(false)); } if ("==".Equals(condition)) { conditionEnvironmentList.Put(nowPosFlagName, (bool)(result = valueA.ToString().Equals(valueB.ToString()))); } else if ("!=".Equals(condition)) { conditionEnvironmentList.Put(nowPosFlagName, (bool)(result = !valueA.ToString().Equals(valueB.ToString()))); } else if (">".Equals(condition)) { float numberA = Single.Parse(valueA.ToString(), JavaRuntime.NumberFormat); float numberB = Single.Parse(valueB.ToString(), JavaRuntime.NumberFormat); conditionEnvironmentList.Put(nowPosFlagName, (bool)(result = numberA > numberB)); } else if ("<".Equals(condition)) { float numberA = Single.Parse(valueA.ToString(), JavaRuntime.NumberFormat); float numberB = Single.Parse(valueB.ToString(), JavaRuntime.NumberFormat); conditionEnvironmentList.Put(nowPosFlagName, (bool)(result = numberA < numberB)); } else if (">=".Equals(condition)) { float numberA = Single.Parse(valueA.ToString(), JavaRuntime.NumberFormat); float numberB = Single.Parse(valueB.ToString(), JavaRuntime.NumberFormat); conditionEnvironmentList.Put(nowPosFlagName, (bool)(result = numberA >= numberB)); } else if ("<=".Equals(condition)) { float numberA = Single.Parse(valueA.ToString(), JavaRuntime.NumberFormat); float numberB = Single.Parse(valueB.ToString(), JavaRuntime.NumberFormat); conditionEnvironmentList.Put(nowPosFlagName, (bool)(result = numberA <= numberB)); } } catch (Exception ex) { Log.Exception(ex); } return(result); }
public void Put(NSObject key, NSObject obj) { _dict.Put(key, obj); }
private void DrawBatchString(float tx, float ty, string text, LColor c, int startIndex, int endIndex) { if (isClose) { return; } if (displays.Size() > DEFAULT_MAX_CHAR) { displays.Clear(); } lazyHashCode = 1; if (c != null) { lazyHashCode = LSystem.Unite(lazyHashCode, c.r); lazyHashCode = LSystem.Unite(lazyHashCode, c.g); lazyHashCode = LSystem.Unite(lazyHashCode, c.b); lazyHashCode = LSystem.Unite(lazyHashCode, c.a); } string key = text + lazyHashCode; Display display = (Display)displays.Get(key); if (display == null) { int x = 0, y = 0; displayList.GLBegin(); displayList.SetBatchPos(tx, ty); if (c != null) { displayList.SetImageColor(c); } CharDef lastCharDef = null; char[] data = text.ToCharArray(); for (int i = 0; i < data.Length; i++) { int id = data[i]; if (id == '\n') { x = 0; y += GetLineHeight(); continue; } if (id >= chars.Length) { continue; } CharDef charDef = chars[id]; if (charDef == null) { continue; } if (lastCharDef != null) { x += lastCharDef.GetKerning(id); } lastCharDef = charDef; if ((i >= startIndex) && (i <= endIndex)) { charDef.Draw(x, y); } x += charDef.advance; } if (c != null) { displayList.SetImageColor(LColor.white); } displayList.GLEnd(); display = new Display(); display.cache = displayList.NewBatchCache(); display.text = text; display.width = 0; display.height = 0; displays.Put(key, display); } else if (display.cache != null) { display.cache.x = tx; display.cache.y = ty; LTextureBatch.Commit(displayList, display.cache); } }
public virtual void PaintObjects(GLEx g, int minX, int minY, int maxX, int maxY) { lock (objects) { IIterator it = objects.Iterator(); for (; it.HasNext();) { thing = (Actor)it.Next(); if (!thing.visible) { continue; } isListener = (thing.actorListener != null); if (isVSync) { if (isListener) { thing.actorListener.Update(elapsedTime); } thing.Update(elapsedTime); } RectBox rect = thing.GetRectBox(); actorX = minX + thing.GetX(); actorY = minY + thing.GetY(); actorWidth = rect.width; actorHeight = rect.height; if (actorX + actorWidth < minX || actorX > maxX || actorY + actorHeight < minY || actorY > maxY) { continue; } LTexture actorImage = thing.GetImage(); if (actorImage != null) { width = (actorImage.GetWidth() * thing.scaleX); height = (actorImage.GetHeight() * thing.scaleY); isBitmapFilter = (thing.filterColor != null); thing.SetLastPaintSeqNum(paintSeq++); angle = thing.GetRotation(); colorAlpha = thing.alpha; if (thing.isAnimation) { if (isBitmapFilter) { g.DrawTexture(actorImage, actorX, actorY, width, height, angle, thing.filterColor); } else { if (colorAlpha != 1f) { g.SetAlpha(colorAlpha); } g.DrawTexture(actorImage, actorX, actorY, width, height, angle); if (colorAlpha != 1f) { g.SetAlpha(1f); } } } else { int texId = actorImage.GetTextureID(); LTextureBatch batch = (LTextureBatch)textures .GetValue(texId); if (batch == null) { LTextureBatch pBatch = LTextureBatch .BindBatchCache(this, texId, actorImage); batch = pBatch; batch.GLBegin(); textures.Put(texId, batch); } batch.SetTexture(actorImage); if (isBitmapFilter) { batch.Draw(actorX, actorY, width, height, angle, thing.filterColor); } else { if (colorAlpha != 1f) { alphaColor.a = colorAlpha; } batch.Draw(actorX, actorY, width, height, angle, alphaColor); if (colorAlpha != 1f) { alphaColor.a = 1; } } } } if (thing.isConsumerDrawing) { if (actorX == 0 && actorY == 0) { thing.Draw(g); if (isListener) { thing.actorListener.Draw(g); } } else { g.Translate(actorX, actorY); thing.Draw(g); if (isListener) { thing.actorListener.Draw(g); } g.Translate(-actorX, -actorY); } } } int size = textures.Size(); if (size > 0) { for (int i = 0; i < size; i++) { LTextureBatch batch = (LTextureBatch)textures.Get(i); batch.GLEnd(); } textures.Clear(); } } }
public virtual void AddActionKey(Int32 keyCode, ActionKey e) { keyActions.Put(keyCode, e); keySize = keyActions.Size(); }
public JSONObject Put(string key, object value_ren) { _map.Put(key, value_ren); return(this); }
public void AddActionKey(Int32 keyCode, ActionKey e) { keyActions.Put(keyCode, e); }