private static void FindNewTables(object state) { // Kill if bwin is not running Process[] p = Process.GetProcessesByName("bwinbe"); // todo: broaden this with PP and bwin wildcard searches if (p.Count() == 0) { return; } // Find all poker tables (bwin table class is #32770 - window title contains $ (other applications also use this class name) var tableHandles = WHelper.EnumAllWindows(IntPtr.Zero, "#32770").Where(hWnd => WHelper.GetWindowTitle(hWnd).Contains("$")); lock (Table.KnownTables) { // Register any new tables & start watching them foreach (var handle in tableHandles.Where(h => Table.Find(h, false) == null)) { // Verify that it is indeed a table window (tourney lobbeys will also be found // Check for random element that only exists in tables if (WHelper.EnumAllWindows(handle, "Static").Where(hWnd => WHelper.GetWindowTitle(hWnd).Contains("Fold to any bet")).Count() > 0) { // Register the table string winTitle = WHelper.GetWindowTitle(handle); Logger.Log($"Registering new bwin table: {handle} - " + winTitle); Table table = new Table(handle); GHelper.SafeThreadStart(() => WatchTable(table)); } } } }
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { parts = parts.OrderBy(x => GHelper.GetPartType(x).layer).ToList(); List <Texture2D> textures = new List <Texture2D>(); List <Vector2> offsets = new List <Vector2>(); foreach (string key in parts) { try { PartType partType = GHelper.GetPartType(key); Texture2D texture = ModContent.GetTexture(partType.useTexture); textures.Add(texture); Vector2 offset = partType.offset; offsets.Add(offset); } catch (Exception e) { Gunplay.Instance.Logger.Error("Something failed when getting invTexture in PostDrawInInventory! " + e.Message); } } for (int index = 0; index < textures.Count; index++) { Texture2D texture = textures[index]; Vector2 offset = offsets[index]; spriteBatch.Draw(texture, position + offset, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); } }
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { Vector2 position = item.position - Main.screenPosition + new Vector2(item.width / 2, item.height / 2); List <Texture2D> textures = new List <Texture2D>(); List <Vector2> offsets = new List <Vector2>(); parts = parts.OrderBy(x => GHelper.GetPartType(x).layer).ToList(); foreach (string key in parts) { try { PartType partType = GHelper.GetPartType(key); Texture2D tex = ModContent.GetTexture(partType.useTexture); textures.Add(tex); Vector2 offset = partType.offset; offsets.Add(offset); } catch (Exception e) { Gunplay.Instance.Logger.Error("Something failed when getting invTexture in PostDrawInWorld! " + e.Message); } } for (int index = 0; index < textures.Count; index++) { Texture2D texture = textures[index]; Vector2 offset = offsets[index] / 2f; spriteBatch.Draw(texture, position + offset, null, lightColor, rotation, texture.Size() * 0.5f, scale, SpriteEffects.None, 0f); } }
public FramesGui() { Size = Gui.FramesSize; Position = Gui.FramesPos; Color = new Color(60, 60, 60); selectBox = new Sprite(GameContent.boxbox); selectBox.SetColor(Color.CornflowerBlue); selectBox.Size = SpriteFrame.frameSize; hoverBox = new Sprite(GameContent.box); hoverBox.SetColor(new Color(20, 20, 20)); hoverBox.Size = SpriteFrame.frameSize; hoverBox.Alpha = 25; btReset = CreateBt(Position.X + 4, Position.Y + 4 + 24, "Reset"); btReset.SetColor(new Color(50, 50, 50)); ibSpeed = new InputBox(ScreenManager.gd, 80, 24); ibSpeed.Position = Position + new Vector2(4) + new Vector2(128, 24); lbSpeed = new Label(GameContent.font, "FrameLength"); lbSpeed.Position = new Vector2(GHelper.Center(ibSpeed.Rectangle, lbSpeed.TextSize).X, ibSpeed.Position.Y - lbSpeed.TextSize.Y - 2); }
void AddButtons() { if (btTexture == null) { btTexture = Extras.CreateFilledBox(ScreenManager.GraphicsDevice); } switch (pType) { case PopupType.Ok: btOk = new Button(ScreenManager.GraphicsDevice, btTexture, 64, 32, "Ok"); btOk.Position = new Vector2(GHelper.Center(box.Rectangle, btOk.Size).X, box.Rectangle.Bottom - btOk.Size.Y - 4); break; case PopupType.YesNo: btYes = new Button(ScreenManager.GraphicsDevice, btTexture, 64, 32, "Yes"); btYes.Position = new Vector2(box.Position.X + 4, box.Rectangle.Bottom - btYes.Size.Y - 4); btNo = new Button(ScreenManager.GraphicsDevice, btTexture, 64, 32, "No"); btNo.Position = new Vector2(box.Position.X + box.Size.X - btNo.Size.X - 4, box.Rectangle.Bottom - btNo.Size.Y - 4); break; case PopupType.OkCancel: btOk = new Button(ScreenManager.GraphicsDevice, btTexture, 64, 32, "Ok"); btOk.Position = new Vector2(box.Position.X + 4, box.Rectangle.Bottom - btOk.Size.Y - 4); btCancel = new Button(ScreenManager.GraphicsDevice, btTexture, 64, 32, "Cancel"); btCancel.Position = new Vector2(box.Position.X + box.Size.X - btCancel.Size.X - 4, box.Rectangle.Bottom - btCancel.Size.Y - 4); break; default: break; } }
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { Texture2D texture = ModContent.GetTexture("Gunplay/Items/GunParts/Barrels/HandgunBarrel"); try { texture = ModContent.GetTexture(GHelper.GetPartType(partKey).invTexture); } catch (Exception e) { Gunplay.Instance.Logger.Error("Something failed when getting invTexture in PostDrawInInventory! " + e.Message); } //spriteBatch.Draw(texture, new Vector2(0, 0), null, drawColor, 0, origin, scale, SpriteEffects.None, 0f); //Vector2 modifiedPosition = position /*- Main.itemTexture[item.type].Size()*//* + texture.Size()*/; //Texture2D originalTexture = Main.itemTexture[item.type]; //Rectangle originalFrame = originalTexture.Frame(1, 1, 0, 0); float inventoryScale = Main.inventoryScale; //Vector2 modifiedPosition = position - (Main.itemTexture[item.type].Size() * Main.inventoryScale) / 2f + (Main.itemTexture[item.type].Size() * Main.inventoryScale) / 2f; //modifiedPosition = modifiedPosition + (texture.Size() * Main.inventoryScale) / 2f - (texture.Size() * Main.inventoryScale) / 2f; Vector2 modifiedPosition = position + new Vector2(texture.Width / 2f, texture.Height / 2f); Vector2 modifiedOrigin = texture.Size() * ((scale / inventoryScale) / 2f - 0.5f); // position2 = position + (orig. tex size * invScale)/2f - (orig. tex size) * 1f / 2f //position = position2 - ((orig. tex size * invScale)/2f - (orig. tex size) * 1f / 2f) => position = position2 - (orig. tex size * invScale)/2f + (orig. tex size) * inv. scale / 2f) //spriteBatch.Draw(texture, modifiedPosition, null, drawColor, 0, modifiedOrigin, scale, SpriteEffects.None, 0f); //spriteBatch.Draw(texture, modifiedPosition, null, drawColor, 0, origin, scale, SpriteEffects.None, 0f); spriteBatch.Draw(texture, position, null, drawColor, 0, modifiedOrigin, scale, SpriteEffects.None, 0f); }
public static void Start() { StartTime = DateTime.Now; if (IsRunning == null) // First call to start { // Regularly looks for new log files & starts watching any found IsRunning = true; timer = new Timer(WatchNewLogFiles, null, 0, 10000); } else if (IsRunning == false) // Restart { // Restarts watch on all known log files IsRunning = true; lock (activeLogFiles) { foreach (string logFile in activeLogFiles) { GHelper.SafeThreadStart(() => WatchLog(logFile)); } } } // Register all open tables on startup / restart WHelper.EnumAllWindows(IntPtr.Zero, "PokerStarsTableFrameClass").ToList() .ForEach(h => Table.Find(h, registerMissing: true)); }
public AnimationsListGui() { Size = Gui.AnimListSize; Position = Gui.AnimListPos; Color = new Color(60, 60, 60); var textSize = UtilityContent.debugFont.MeasureString("label #"); AnimationLabel.TextHeight = (int)textSize.Y; selectedBox = new Sprite(Extras.CreateHollowBox(ScreenManager.gd, Gui.rightWidth, (int)textSize.Y, 1)); //selectedBox.Size = new Vector2(Gui.rightWidth, textSize.Y); selectedBox.Color = Color.LightSteelBlue; selectedBox.Alpha = 100; hoverBox = new Sprite(); hoverBox.Size = new Vector2(Gui.rightWidth, textSize.Y); hoverBox.Color = new Color(80, 80, 80); hoverBox.Alpha = 50; btAdd = new Button(ScreenManager.gd, 42, 32, "Add"); btAdd.SetColor(new Color(50, 50, 50)); btAdd.Position = new Vector2(GHelper.Center(Rectangle, btAdd.Size).X - 32, Position.Y + 4); btDel = new Button(ScreenManager.gd, 42, 32, "Del"); btDel.SetColor(new Color(50, 50, 50)); btDel.Position = new Vector2(GHelper.Center(Rectangle, btDel.Size).X + 32, Position.Y + 4); }
public override void Load(ContentManager content) { base.Load(content); mTree = new MotherTree(); mTree.Position = GHelper.Center(Globals.ScreenBox, mTree.Size) + new Vector2(0, -(mTree.Size.Y / 3)); }
public GameState(GameScreen g) { game = g; lbTitle = new Label(UtilityContent.debugFont, GetType().Name); lbTitle.Scale = 1.5f; lbTitle.Position = new Vector2(GHelper.Center(OboGlobals.ScreenBox, lbTitle.Size * lbTitle.Scale).X, 100); }
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { PartType partType = GHelper.GetPartType(partKey); item.height = ModContent.GetTexture(partType.invTexture).Height; item.width = ModContent.GetTexture(partType.invTexture).Width; item.SetNameOverride(GHelper.GetPartName(partKey)); return(false); }
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) { PartType pType = GHelper.GetPartType(partKey); item.height = ModContent.GetTexture(pType.invTexture).Height; item.width = ModContent.GetTexture(pType.invTexture).Width; item.SetNameOverride(GHelper.GetPartName(partKey)); return(false); }
public override void Load() { base.Load(); CreateBox(); AddButtons(); lbText = new Label(font, msg); lbText.Position = new Vector2(GHelper.Center(box.Rectangle, lbText.TextSize).X, box.Position.Y + 4); }
void onPacketCallback(Packet packet) { TestProto msg = packet.ToOBJ(typeof(TestProto)) as TestProto; Debug.LogError("cs msg:" + msg.a + "," + msg.b + "," + msg.c + "," + GHelper.toString <int>(msg.d.ToArray())); packet.mMetaPacket = null;//清除缓存 LuaObject lo = packet.ToLua("TestProto") as LuaObject; Debug.LogError("lua msg:" + lo.value <string>("a") + "," + lo.value <int>("b") + "," + lo.value <int>("c") + "," + GHelper.toString <int>(lo.value <int[]>("d"))); }
public override void Serialize(NetworkWriter w) { base.Serialize(w); w.Write(attrs.Count); for (int i = 0; i < attrs.Count; ++i) { byte[] bs = GHelper.Object2Bytes(attrs[i]); w.WriteBytesFull(bs); } }
public void Draw(SpriteBatch sb) { for (int i = 0; i < labels.Count; i++) { var lb = labels[i]; var pos = GHelper.Center(Globals.ScreenBox, lb.TextSize) - new Vector2(0, Globals.ScreenHeight / 5 + (i * lb.TextSize.Y + 1)); lb.Position = pos; lb.Draw(sb); } }
public override void Deserialize(NetworkReader r) { base.Deserialize(r); int count = r.ReadInt32(); for (int i = 0; i < count; ++i) { byte[] bs = r.ReadBytesAndSize(); Attr attr = (Attr)GHelper.Bytes2Object(bs); attrs.Add(attr); } }
public static void GenerateVersionInfo(BuildTarget buildTarget, int versionCode = 0) { if (versionCode == 0) { versionCode = GameVersion.code; } GameConfig.VersionInfo version = new GameConfig.VersionInfo(versionCode); string mainifestPath = Path.Combine(XManifest.updateRenameResOutputPath, XManifest.name); if (File.Exists(mainifestPath)) { version.ManifestChecksum = GHelper.ComputeFileChecksum(mainifestPath); } version.ResRoot = "http://cdn-tf02.dev.tapenjoy.com/"; version.ResRootPublish = "http://lf3-ma18cdn-cn.dailygn.com/obj/light-game-cn/ma18/tf02/"; string content = LitJson.JsonMapper.ToJson(version); Debug.Log(string.Format("version content: {0}", content)); string path = Path.Combine(Environment.CurrentDirectory, string.Format("build/ver/{0}", XManifest.GetPlatformFolder(EditorUserBuildSettings.activeBuildTarget))); if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); string name = Path.Combine(path, "ver.txt"); Debug.Log(String.Format("version file save at: {0}", name)); try { FileStream fs = new FileStream(name, FileMode.Create); System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding(false); StreamWriter sw = new StreamWriter(fs, utf8); sw.Write(content); sw.Close(); fs.Close(); } catch (IOException e) { Debug.Log(e.Message); } //GenerateShareConfigJson(version.GetVersionCode()); GenerateInnerVersionInfo(buildTarget, versionCode); }
public static byte[] Load(string fn) { #if !RELEASE //Debug.LogFormat("LuasLoader {0}", fn); #endif fn = fn.Replace(".", "/"); string bytefn = fn.Replace("/", "+"); string hashName = GHelper.Md5Sum(bytefn); #if !USE_BUNDLE_IN_EDITOR && (UNITY_EDITOR || UNITY_STANDALONE || !PUBLISH || ENABLE_GM) foreach (var path in Defines.LuaFileSearchPath) { byte[] buffer = LoadFrom(path, fn); string p = Path.Combine(path, fn + ".lua"); if (buffer != null) { FileInfo fi = new FileInfo(p); string lastWrite = fi.LastWriteTime.ToString(); fileMap.Add(fn); fileMapKey.Add(lastWrite + p); return(buffer); } } #endif XManifest.AssetInfo info = XManifest.Instance.Find(hashName); if (info != null) { if (info.location == XManifest.Location.Streaming) { return(ResHelper.LoadBytesFromStreamingAssets(System.IO.Path.Combine(streamBasePath, info.fullName))); } else { var filePath1 = System.IO.Path.Combine(dataBasePath, info.fullName); if (System.IO.File.Exists(filePath1)) { System.IO.FileStream fs = System.IO.File.OpenRead(filePath1); byte[] buffer = new byte[(int)fs.Length]; fs.Read(buffer, 0, (int)fs.Length); fs.Close(); return(buffer); } } } else { } return(null); }
void CreateBox() { box = new Sprite(); box.Texture = Extras.CreateFilledBox(ScreenManager.GraphicsDevice); box.SetSize(224, 96); box.Position = GHelper.Center(Globals.ScreenBox, box.Size) - new Vector2(0, box.Size.Y * .5f); box.SetColor(Color); outline = new Sprite(); outline.Texture = Extras.CreateFilledBox(ScreenManager.GraphicsDevice); outline.SetSize((int)box.Size.X + 4, (int)box.Size.Y + 4); outline.Position = box.Position - new Vector2(2, 2); outline.SetColor(Color.Black); }
protected override void onUnitInit() { mAttr.reset(); mSkill.reset(); mBuff.reset(); mMove.reset(); mAI.reset(); mSkill.addSkills(GHelper.toIntArray(table.skills)); if (!isServer) { mHeadInfo = HeadInfo.Bind(this.transform, this); } }
static void WriteVersion(int version, string id, int vendor) { StreamWriter saveFile = File.CreateText(Application.dataPath + "/Source/CS/Version.cs"); int now = GHelper.DateTimeToTimeStamp(System.DateTime.Now); saveFile.Write( @" public static class GameVersion { public static int code = " + version.ToString() + @"; public static string identifier = " + "\"" + id + "\"" + @"; public static int vendor = " + vendor + @"; public static int buildTime = " + now + @"; }" ); saveFile.Close(); }
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { Texture2D texture = ModContent.GetTexture("Gunplay/Items/GunParts/Barrels/HandgunBarrel"); Vector2 position = item.position - Main.screenPosition + new Vector2(item.width / 2, item.height / 2); try { texture = ModContent.GetTexture(GHelper.GetPartType(partKey).invTexture); } catch (Exception e) { Gunplay.Instance.Logger.Error("Something failed when getting invTexture in PostDrawInWorld! " + e.Message); } spriteBatch.Draw(texture, position, null, lightColor, rotation, texture.Size() * 0.5f, scale, SpriteEffects.None, 0f); }
IEnumerator CreateActor() { mUnitCount = mActorInfo.Count; for (int i = 0; i < mActorInfo.Count; ++i) { ActorInfo a = mActorInfo [i]; Unit u = NetMgr.server.createMonster(a.actorId, Vector3.right, a.pos); if (!string.IsNullOrEmpty(a.drop)) { (u as Monster).drops = GHelper.toIntArray(a.drop); } //u.AddStateListener (OnUnitStateChange); yield return(null); } }
public static void GetFileInfo(string path, out uint checksum, out uint size) { FileInfo info = new FileInfo(path); if (info == null) { Debug.LogError("path not exsit:" + path); checksum = 0; size = 0; } else { size = (uint)info.Length; checksum = GHelper.ComputeFileChecksum(path); } }
public override void ModifyTooltips(List <TooltipLine> tooltips) { foreach (TooltipLine line in tooltips) { if (line.Name == "ItemName" && line.mod == "Terraria") { line.text = GHelper.GetToolName(parts) + " " + itemType; } } string effectsText = ""; foreach (KeyValuePair <string, int> pair in effects) { EffectType effectType = GHelper.GetEffectType(pair.Key); if (effectsText != "") { effectsText += "\n"; } effectsText += $"{effectType.name}"; if (effectType.showLevel) { effectsText += $" Level {pair.Value}"; } if (Main.keyState.PressingShift()) { effectsText += $": {effectType.desc}"; } } tooltips.Add(new TooltipLine(mod, "TerrariaConstruct:EffectsLine", effectsText)); if (!Main.keyState.PressingShift() && effects.Count > 0) { tooltips.Add(new TooltipLine(mod, "TerrariaConstruct:ShiftMessageLine", "Press Shift to see descriptions!")); } if (GHelper.CheckForBrokenParts(parts)) { tooltips.Add(new TooltipLine(mod, "TerrariaConstruct:BrokenPartsLine", "This tool has broken parts! Did you disable a mod since you last played?")); } tooltips.Add(new TooltipLine(mod, "h", "Power = " + GHelper.PowerFromParts(parts))); }
public override void Draw(SpriteBatch sb) { base.Draw(sb); int i = 0; foreach (var f in frames) { var spacing = 8; int y = (int)GHelper.Center(Rectangle, SpriteFrame.frameSize).Y; int x = (int)Position.X + spacing + (i * (int)SpriteFrame.frameSize.X) + (i * 16); var pos = new Vector2(x, y); if (!f.IsDragging) { f.position = pos; if (f.Rectangle.Contains(Input.MousePos)) { hoverBox.Position = f.position; hoverBox.Draw(sb); } } f.Draw(sb, SelectedSheet); f.DrawInfo(sb); sb.DrawString(GameContent.font, $"{i + 1}", pos - new Vector2(10), Color.White); i++; } if (frame != null) { selectBox.Position = frame.position; selectBox.Draw(sb); } btReset.Draw(sb); ibSpeed.Draw(sb); lbSpeed.Draw(sb); }
public override void ModifyTooltips(List <TooltipLine> tooltips) { foreach (TooltipLine line in tooltips) { if (line.Name == "ItemName" && line.mod == "Terraria") { line.text = GHelper.GetPartName(partKey); } } string effectsText = ""; Dictionary <string, int> effects = GHelper.GetPartType(partKey).effects; foreach (KeyValuePair <string, int> pair in effects) { EffectType effectType = GHelper.GetEffectType(pair.Key); if (effectsText != "") { effectsText += "\n"; } effectsText += $"{effectType.name}"; if (effectType.showLevel) { effectsText += $" Level {pair.Value}"; } if (Main.keyState.PressingShift()) { effectsText += $": {effectType.desc}"; } } tooltips.Add(new TooltipLine(mod, "TerrariaConstruct:EffectsLine", effectsText)); if (!Main.keyState.PressingShift() && effects.Count > 0) { tooltips.Add(new TooltipLine(mod, "TerrariaConstruct:ShiftMessageLine", "Press Shift to see descriptions!")); } if (GHelper.GetPartType(partKey) == PartData.UnknownPart) { TooltipLine line = new TooltipLine(mod, "TerrariaConstruct:BrokenPartLine", "This part is broken! Did you disable a mod since you last played?"); tooltips.Add(line); } }
public override void SetDefaults() { item.width = 32; item.height = 32; item.useStyle = ItemUseStyleID.SwingThrow; item.useTurn = true; item.autoReuse = true; item.UseSound = SoundID.Item6; item.useTime = 10; item.useAnimation = 10; item.noUseGraphic = true; //hmm yes let me remove the held item layer instead //TerrariaConstruct.instance.Logger.Info("Power Before: " + power); //power = TCHelper.PowerFromParts(parts); //TerrariaConstruct.instance.Logger.Info("Power Mid: " + power); GHelper.SetDefaults(item); //TerrariaConstruct.instance.Logger.Info("Power After: " + power); }
public SaveWindow() { SetSize(240, 160); Position = GHelper.Center(Globals.ScreenBox, Size); Color = new Color(25, 25, 25); lbName = new Label(UtilityContent.debugFont, "Filename:"); lbName.Position = new Vector2(GHelper.Center(Rectangle, lbName.TextSize).X, Position.Y + 15); ibName = new InputBox(ScreenManager.gd, 200, 24); ibName.Position = new Vector2(GHelper.Center(Rectangle, ibName.Size).X, Position.Y + 60); ibName.Text = ibDefaultText; btOk = new Button(ScreenManager.gd, 72, 26, "Ok"); btOk.Position = new Vector2(GHelper.Center(Rectangle, btOk.Size).X - 48, Position.Y + 100); btClose = new Button(ScreenManager.gd, 72, 26, "Close"); btClose.Position = new Vector2(GHelper.Center(Rectangle, btOk.Size).X + 48, Position.Y + 100); }