コード例 #1
0
ファイル: UIWorldListItem.cs プロジェクト: EmuDevs/EDTerraria
 public UIWorldListItem(WorldFileData data)
 {
     BorderColor = new Color(89, 116, 213) * 0.7f;
     _dividerTexture = TextureManager.Load("Images/UI/Divider");
     _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
     _buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
     _buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
     _buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
     _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
     _buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
     _buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
     Height.Set(96f, 0.0f);
     Width.Set(0.0f, 1f);
     SetPadding(6f);
     _data = data;
     _worldIcon = new UIImage(GetIcon());
     _worldIcon.Left.Set(4f, 0.0f);
     _worldIcon.OnDoubleClick += new UIElement.MouseEvent(PlayGame);
     Append(_worldIcon);
     UIImageButton uiImageButton1 = new UIImageButton(_buttonPlayTexture);
     uiImageButton1.VAlign = 1f;
     uiImageButton1.Left.Set(4f, 0.0f);
     uiImageButton1.OnClick += new UIElement.MouseEvent(PlayGame);
     OnDoubleClick += new UIElement.MouseEvent(PlayGame);
     uiImageButton1.OnMouseOver += new UIElement.MouseEvent(PlayMouseOver);
     uiImageButton1.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut);
     Append(uiImageButton1);
     UIImageButton uiImageButton2 = new UIImageButton(_data.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture);
     uiImageButton2.VAlign = 1f;
     uiImageButton2.Left.Set(28f, 0.0f);
     uiImageButton2.OnClick += new UIElement.MouseEvent(FavoriteButtonClick);
     uiImageButton2.OnMouseOver += new UIElement.MouseEvent(FavoriteMouseOver);
     uiImageButton2.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut);
     uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
     Append(uiImageButton2);
     UIImageButton uiImageButton4 = new UIImageButton(_buttonDeleteTexture);
     uiImageButton4.VAlign = 1f;
     uiImageButton4.HAlign = 1f;
     uiImageButton4.OnClick += new UIElement.MouseEvent(DeleteButtonClick);
     uiImageButton4.OnMouseOver += new UIElement.MouseEvent(DeleteMouseOver);
     uiImageButton4.OnMouseOut += new UIElement.MouseEvent(DeleteMouseOut);
     _deleteButton = uiImageButton4;
     if (!_data.IsFavorite)
         Append(uiImageButton4);
     _buttonLabel = new UIText("", 1f, false);
     _buttonLabel.VAlign = 1f;
     _buttonLabel.Left.Set(80f, 0.0f);
     _buttonLabel.Top.Set(-3f, 0.0f);
     Append(_buttonLabel);
     _deleteButtonLabel = new UIText("", 1f, false);
     _deleteButtonLabel.VAlign = 1f;
     _deleteButtonLabel.HAlign = 1f;
     _deleteButtonLabel.Left.Set(-30f, 0.0f);
     _deleteButtonLabel.Top.Set(-3f, 0.0f);
     Append(_deleteButtonLabel);
 }
コード例 #2
0
ファイル: WorldFile.cs プロジェクト: MEFBAEA/mefbaea
 public static WorldFileData CreateMetadata(string name, bool cloudSave, bool isExpertMode)
 {
     WorldFileData worldFileData = new WorldFileData(Main.GetWorldPathFromName(name, cloudSave), cloudSave);
     worldFileData.Name = name;
     worldFileData.IsExpertMode = isExpertMode;
     worldFileData.CreationTime = DateTime.Now;
     worldFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.World);
     worldFileData.SetFavorite(false, true);
     return worldFileData;
 }
コード例 #3
0
ファイル: WorldFileData.cs プロジェクト: saniainf/EDTerraria
        public static WorldFileData FromInvalidWorld(string path, bool cloudSave)
        {
            WorldFileData worldFileData = new WorldFileData(path);

            worldFileData.IsExpertMode = false;
            worldFileData.Metadata     = FileMetadata.FromCurrentSettings(FileType.World);
            worldFileData.SetWorldSize(1, 1);
            worldFileData.HasCorruption = true;
            worldFileData.IsHardMode    = false;
            worldFileData.IsValid       = false;
            worldFileData.Name          = FileUtilities.GetFileName(path, false);
            worldFileData.CreationTime  = cloudSave ? DateTime.Now : File.GetCreationTime(path);
            return(worldFileData);
        }
コード例 #4
0
        public static WorldFileData FromInvalidWorld(string path, bool cloudSave)
        {
            WorldFileData worldFileData = new WorldFileData(path, cloudSave);

            worldFileData.GameMode = 0;
            worldFileData.SetSeedToEmpty();
            worldFileData.WorldGeneratorVersion = 0UL;
            worldFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.World);
            worldFileData.SetWorldSize(1, 1);
            worldFileData.HasCorruption = true;
            worldFileData.IsHardMode    = false;
            worldFileData.IsValid       = false;
            worldFileData.Name          = FileUtilities.GetFileName(path, false);
            worldFileData.UniqueId      = Guid.Empty;
            worldFileData.CreationTime  = cloudSave ? DateTime.Now : File.GetCreationTime(path);
            return(worldFileData);
        }
コード例 #5
0
		public static WorldFileData FromInvalidWorld(string path, bool cloudSave)
		{
			WorldFileData worldFileData = new WorldFileData(path, cloudSave);
			worldFileData.IsExpertMode = false;
			worldFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.World);
			worldFileData.SetWorldSize(1, 1);
			worldFileData.HasCorruption = true;
			worldFileData.IsHardMode = false;
			worldFileData.IsValid = false;
			worldFileData.Name = FileUtilities.GetFileName(path, false);
			if (!cloudSave)
			{
				worldFileData.CreationTime = File.GetCreationTime(path);
			}
			else
			{
				worldFileData.CreationTime = DateTime.Now;
			}
			return worldFileData;
		}
コード例 #6
0
ファイル: WorldFile.cs プロジェクト: MEFBAEA/mefbaea
 public static WorldFileData GetAllMetadata(string file, bool cloudSave)
 {
     if (file == null || (cloudSave && SocialAPI.Cloud == null))
     {
         return null;
     }
     WorldFileData worldFileData = new WorldFileData(file, cloudSave);
     if (!FileUtilities.Exists(file, cloudSave))
     {
         worldFileData.CreationTime = DateTime.Now;
         worldFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.World);
         return worldFileData;
     }
     try
     {
         Stream stream;
         if (cloudSave)
         {
             stream = new MemoryStream(SocialAPI.Cloud.Read(file));
         } else {
             stream = new FileStream(file, FileMode.Open);
         }
         using (stream)
         {
             using (BinaryReader binaryReader = new BinaryReader(stream))
             {
                 int num = binaryReader.ReadInt32();
                 if (num >= 135)
                 {
                     worldFileData.Metadata = FileMetadata.Read(binaryReader, FileType.World);
                 }
                 else
                 {
                     worldFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.World);
                 }
                 if (num <= Main.curRelease)
                 {
                     binaryReader.ReadInt16();
                     stream.Position = (long)binaryReader.ReadInt32();
                     worldFileData.Name = binaryReader.ReadString();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     int y = binaryReader.ReadInt32();
                     int x = binaryReader.ReadInt32();
                     worldFileData.SetWorldSize(x, y);
                     worldFileData.IsExpertMode = (num >= 112 && binaryReader.ReadBoolean());
                     if (num >= 141)
                     {
                         worldFileData.CreationTime = DateTime.FromBinary(binaryReader.ReadInt64());
                     }
                     else if (!cloudSave)
                     {
                         worldFileData.CreationTime = File.GetCreationTime(file);
                     }
                     else
                     {
                         worldFileData.CreationTime = DateTime.Now;
                     }
                     binaryReader.ReadByte();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     binaryReader.ReadDouble();
                     binaryReader.ReadDouble();
                     binaryReader.ReadDouble();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadInt32();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadInt32();
                     binaryReader.ReadInt32();
                     worldFileData.HasCrimson = binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     if (num >= 118)
                     {
                         binaryReader.ReadBoolean();
                     }
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadBoolean();
                     binaryReader.ReadByte();
                     binaryReader.ReadInt32();
                     worldFileData.IsHardMode = binaryReader.ReadBoolean();
                     return worldFileData;
                 }
             }
         }
     }
     catch (Exception)
     {
     }
     return null;
 }
コード例 #7
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
 static Main()
 {
     Main.curRelease = 156;
     Main.versionNumber = "v1.3.0.8";
     Main.versionNumber2 = "v1.3.0.8";
     Main.destroyerHB = new Vector2(0f, 0f);
     Main.drawBackGore = false;
     Main.expertLife = 2f;
     Main.expertDamage = 2f;
     Main.expertDebuffTime = 2f;
     Main.expertKnockBack = 0.9f;
     Main.expertNPCDamage = 1.5f;
     Main.knockBackMultiplier = 1f;
     Main.damageMultiplier = 1f;
     Main.ServerSideCharacter = false;
     Main.ContentLoaded = false;
     Main.maxMsg = 106;
     Main.GlobalTime = 0f;
     Main.GlobalTimerPaused = false;
     Main._tileFrameSeed = (ulong)Guid.NewGuid().GetHashCode();
     Main.npcStreamSpeed = 60;
     Main.musicError = 0;
     Main.dedServFPS = false;
     Main.dedServCount1 = 0;
     Main.dedServCount2 = 0;
     Main.superFast = false;
     Main.hairLoaded = new bool[134];
     Main.wingsLoaded = new bool[37];
     Main.goreLoaded = new bool[907];
     Main.projectileLoaded = new bool[Main.maxProjectileTypes];
     Main.itemFlameLoaded = new bool[Main.maxItemTypes];
     Main.backgroundLoaded = new bool[207];
     Main.tileSetsLoaded = new bool[Main.maxTileSets];
     Main.wallLoaded = new bool[Main.maxWallTypes];
     Main.NPCLoaded = new bool[Main.maxNPCTypes];
     Main.armorHeadLoaded = new bool[194];
     Main.armorBodyLoaded = new bool[195];
     Main.armorLegsLoaded = new bool[135];
     Main.accHandsOnLoaded = new bool[19];
     Main.accHandsOffLoaded = new bool[12];
     Main.accBackLoaded = new bool[10];
     Main.accFrontLoaded = new bool[5];
     Main.accShoesLoaded = new bool[18];
     Main.accWaistLoaded = new bool[12];
     Main.accShieldLoaded = new bool[6];
     Main.accNeckLoaded = new bool[9];
     Main.accFaceLoaded = new bool[9];
     Main.accballoonLoaded = new bool[16];
     Vector2[] vector2 = new Vector2[] { new Vector2(14f, 34f), new Vector2(14f, 32f), new Vector2(14f, 26f), new Vector2(14f, 22f), new Vector2(14f, 18f) };
     Main.OffsetsNPCOffhand = vector2;
     Vector2[] vector2Array = new Vector2[] { new Vector2(14f, 20f), new Vector2(14f, 20f), new Vector2(14f, 20f), new Vector2(14f, 18f), new Vector2(14f, 20f), new Vector2(16f, 4f), new Vector2(16f, 16f), new Vector2(18f, 14f), new Vector2(18f, 14f), new Vector2(18f, 14f), new Vector2(16f, 16f), new Vector2(16f, 16f), new Vector2(16f, 16f), new Vector2(16f, 16f), new Vector2(14f, 14f), new Vector2(14f, 14f), new Vector2(12f, 14f), new Vector2(14f, 16f), new Vector2(16f, 16f), new Vector2(16f, 16f) };
     Main.OffsetsPlayerOffhand = vector2Array;
     Vector2[] vector21 = new Vector2[] { new Vector2(6f, 19f), new Vector2(5f, 10f), new Vector2(12f, 10f), new Vector2(13f, 17f), new Vector2(12f, 19f), new Vector2(5f, 10f), new Vector2(7f, 17f), new Vector2(6f, 16f), new Vector2(6f, 16f), new Vector2(6f, 16f), new Vector2(6f, 17f), new Vector2(7f, 17f), new Vector2(7f, 17f), new Vector2(7f, 17f), new Vector2(8f, 17f), new Vector2(9f, 16f), new Vector2(9f, 12f), new Vector2(8f, 17f), new Vector2(7f, 17f), new Vector2(7f, 17f) };
     Main.OffsetsPlayerOnhand = vector21;
     Vector2[] vector2Array1 = new Vector2[] { new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f) };
     Main.OffsetsPlayerHeadgear = vector2Array1;
     Main.BlackFadeIn = 0;
     Main.noWindowBorder = false;
     Main.ugBack = 0;
     Main.oldUgBack = 0;
     Main.bgFrame = new int[1];
     Main.bgFrameCounter = new int[1];
     Main.skipMenu = false;
     Main.verboseNetplay = false;
     Main.stopTimeOuts = false;
     Main.showSpam = false;
     Main.showItemOwner = false;
     Main.nextNPC = new bool[Main.maxNPCTypes];
     Main.musicBox = -1;
     Main.musicBox2 = -1;
     Main.hbPosition = 1;
     Main.cEd = false;
     Main.wFrCounter = 0f;
     Main.wFrame = 0f;
     Main.drawDiag = false;
     Main.drawRelease = false;
     Main.drawBetterDebug = false;
     Main.betterDebugRelease = false;
     Main.renderNow = false;
     Main.drawToScreen = false;
     Main.targetSet = false;
     Main.essScale = 1f;
     Main.essDir = -1;
     Main.cloudBGX = new float[2];
     Main.cloudBG = new int[] { 112, 113 };
     Main.treeMntBG = new int[2];
     Main.treeBG = new int[3];
     Main.corruptBG = new int[3];
     Main.jungleBG = new int[3];
     Main.snowMntBG = new int[2];
     Main.snowBG = new int[3];
     Main.hallowBG = new int[3];
     Main.crimsonBG = new int[3];
     Main.desertBG = new int[2];
     Main.treeX = new int[4];
     Main.treeStyle = new int[4];
     Main.caveBackX = new int[4];
     Main.caveBackStyle = new int[4];
     Main.debugWords = "";
     Main.gamePad = false;
     Main.xMas = false;
     Main.halloween = false;
     Main.snowDust = 0;
     Main.chTitle = false;
     Main.hairWindow = false;
     Main.clothesWindow = false;
     Main.ingameOptionsWindow = false;
     Main.achievementsWindow = false;
     Main.keyCount = 0;
     Main.keyString = new string[10];
     Main.keyInt = new int[10];
     Main.gFade = 0;
     Main.gFader = 0f;
     Main.gFadeDir = 1;
     Main.netDiag = false;
     Main.txData = 0;
     Main.rxData = 0;
     Main.txMsg = 0;
     Main.rxMsg = 0;
     Main.uCarry = 0f;
     Main.drawSkip = false;
     Main.fpsCount = 0;
     Main.fpsTimer = new Stopwatch();
     Main.updateTimer = new Stopwatch();
     Main.fountainColor = -1;
     Main.monolithType = -1;
     Main.showSplash = true;
     Main.ignoreErrors = true;
     Main.defaultIP = "";
     Main.dayRate = 1;
     Main.maxScreenW = 1920;
     Main.minScreenW = 800;
     Main.maxScreenH = 1200;
     Main.minScreenH = 600;
     Main.iS = 1f;
     Main.render = false;
     Main.qaStyle = 0;
     Main.zoneX = 99;
     Main.zoneY = 87;
     Main.harpNote = 0f;
     Main.projHostile = new bool[Main.maxProjectileTypes];
     Main.projHook = new bool[Main.maxProjectileTypes];
     Main.pvpBuff = new bool[Main.maxBuffTypes];
     Main.persistentBuff = new bool[Main.maxBuffTypes];
     Main.vanityPet = new bool[191];
     Main.lightPet = new bool[191];
     Main.meleeBuff = new bool[Main.maxBuffTypes];
     Main.debuff = new bool[Main.maxBuffTypes];
     Main.buffName = new string[Main.maxBuffTypes];
     Main.buffTip = new string[Main.maxBuffTypes];
     Main.buffNoSave = new bool[Main.maxBuffTypes];
     Main.buffNoTimeDisplay = new bool[Main.maxBuffTypes];
     Main.buffDoubleApply = new bool[Main.maxBuffTypes];
     Main.maxMP = 10;
     Main.recentWorld = new string[Main.maxMP];
     Main.recentIP = new string[Main.maxMP];
     Main.recentPort = new int[Main.maxMP];
     Main.shortRender = true;
     Main.owBack = true;
     Main.quickBG = 2;
     Main.bgDelay = 0;
     Main.bgStyle = 0;
     Main.bgAlpha = new float[10];
     Main.bgAlpha2 = new float[10];
     Main.EquipPage = 0;
     Main.EquipPageSelected = 0;
     Main.wof = -1;
     Main.wofF = 0;
     Main.offScreenRange = 200;
     Main.maxMapUpdates = 250000;
     Main.refreshMap = false;
     Main.loadMapLastX = 0;
     Main.loadMapLock = false;
     Main.loadMap = false;
     Main.mapReady = false;
     Main.textureMaxWidth = 2000;
     Main.textureMaxHeight = 1800;
     Main.updateMap = false;
     Main.mapMinX = 0;
     Main.mapMaxX = 0;
     Main.mapMinY = 0;
     Main.mapMaxY = 0;
     Main.mapTimeMax = 30;
     Main.mapTime = Main.mapTimeMax;
     Main.mapTargetX = 5;
     Main.mapTargetY = 2;
     Main.initMap = new bool[Main.mapTargetX, Main.mapTargetY];
     Main.mapWasContentLost = new bool[Main.mapTargetX, Main.mapTargetY];
     Main.OurFavoriteColor = new Color(255, 231, 69);
     Main.mapInit = false;
     Main.mapEnabled = true;
     Main.mapStyle = 1;
     Main.grabMapX = 0f;
     Main.grabMapY = 0f;
     Main.miniMapX = 0;
     Main.miniMapY = 0;
     Main.miniMapWidth = 0;
     Main.miniMapHeight = 0;
     Main.mapMinimapScale = 1.25f;
     Main.mapMinimapAlpha = 1f;
     Main.mapOverlayScale = 2.5f;
     Main.mapOverlayAlpha = 0.35f;
     Main.mapFullscreen = false;
     Main.resetMapFull = false;
     Main.mapFullscreenScale = 4f;
     Main.mapFullscreenPos = new Vector2(-1f, -1f);
     Main.renderCount = 99;
     Main.saveTime = new Stopwatch();
     Main.mcColor = new Color(125, 125, 255);
     Main.hcColor = new Color(200, 125, 255);
     Main.highVersionColor = new Color(255, 255, 0);
     Main.errorColor = new Color(255, 0, 0);
     Main.mouseHC = false;
     Main.craftingHide = false;
     Main.armorHide = false;
     Main.craftingAlpha = 1f;
     Main.armorAlpha = 1f;
     Main.buffAlpha = new float[Main.maxBuffTypes];
     Main.trashItem = new Item();
     Main.hardMode = false;
     Main.sceneWaterPos = Vector2.Zero;
     Main.sceneTilePos = Vector2.Zero;
     Main.sceneTile2Pos = Vector2.Zero;
     Main.sceneWallPos = Vector2.Zero;
     Main.sceneBackgroundPos = Vector2.Zero;
     Main.maxQ = true;
     Main.gfxQuality = 1f;
     Main.gfxRate = 0.01f;
     Main.DiscoR = 255;
     Main.DiscoB = 0;
     Main.DiscoG = 0;
     Main.teamCooldown = 0;
     Main.teamCooldownLen = 300;
     Main.gamePaused = false;
     Main.gameInactive = false;
     Main.updateTime = 0;
     Main.drawTime = 0;
     Main.uCount = 0;
     Main.updateRate = 0;
     Main.frameRate = 0;
     Main.RGBRelease = false;
     Main.qRelease = false;
     Main.netRelease = false;
     Main.frameRelease = false;
     Main.showFrameRate = false;
     Main.magmaBGFrame = 0;
     Main.magmaBGFrameCounter = 0;
     Main.saveTimer = 0;
     Main.autoJoin = false;
     Main.serverStarting = false;
     Main.leftWorld = 0f;
     Main.rightWorld = 134400f;
     Main.topWorld = 0f;
     Main.bottomWorld = 38400f;
     Main.maxTilesX = (int)Main.rightWorld / 16 + 1;
     Main.maxTilesY = (int)Main.bottomWorld / 16 + 1;
     Main.maxSectionsX = Main.maxTilesX / 200;
     Main.maxSectionsY = Main.maxTilesY / 150;
     Main.numDust = 6000;
     Main.numPlayers = 0;
     Main.maxNetPlayers = 255;
     Main.maxRain = 750;
     Main.slimeWarningTime = 0;
     Main.slimeWarningDelay = 420;
     Main.slimeRainNPCSlots = 0.65f;
     Main.slimeRainNPC = new bool[Main.maxNPCTypes];
     Main.slimeRainTime = 0;
     Main.slimeRain = false;
     Main.slimeRainKillCount = 0;
     Main.cameraX = 0f;
     Main.drewLava = false;
     Main.liquidAlpha = new float[12];
     Main.waterStyle = 0;
     Main.worldRate = 1;
     Main.caveParallax = 0.88f;
     Main.liquid = new Liquid[Liquid.resLiquid];
     Main.liquidBuffer = new LiquidBuffer[10000];
     Main.dedServ = false;
     Main.spamCount = 0;
     Main.curMusic = 0;
     Main.dayMusic = 0;
     Main.ugMusic = 0;
     Main.showItemText = true;
     Main.autoSave = true;
     Main.validateSaves = true;
     Main.bannerMouseOver = false;
     Main.buffString = "";
     Main.libPath = "";
     Main.lo = 0;
     Main.LogoA = 255;
     Main.LogoB = 0;
     Main.LogoT = false;
     Main.statusText = "";
     Main.worldName = "";
     Main.background = 0;
     Main.caveBackground = 0;
     Main.ugBackTransition = 0f;
     Main.teamColor = new Color[6];
     Main.dayTime = true;
     Main.time = 13500;
     Main.moonPhase = 0;
     Main.sunModY = 0;
     Main.moonModY = 0;
     Main.grabSky = false;
     Main.bloodMoon = false;
     Main.pumpkinMoon = false;
     Main.snowMoon = false;
     Main.cloudAlpha = 0f;
     Main.maxRaining = 0f;
     Main.oldMaxRaining = 0f;
     Main.rainTime = 0;
     Main.raining = false;
     Main.eclipse = false;
     Main.eclipseLight = 0f;
     Main.checkForSpawns = 0;
     Main.helpText = 0;
     Main.autoGen = false;
     Main.autoPause = false;
     Main.projFrames = new int[Main.maxProjectileTypes];
     Main.projPet = new bool[Main.maxProjectileTypes];
     Main.demonTorch = 1f;
     Main.demonTorchDir = 1;
     Main.martianLight = 1f;
     Main.martianLightDir = 1;
     Main.placementPreview = true;
     Main.weatherCounter = 0;
     Main.cloudLimit = 200;
     Main.numClouds = Main.cloudLimit;
     Main.numCloudsTemp = Main.numClouds;
     Main.windSpeedTemp = 0f;
     Main.windSpeed = 0f;
     Main.windSpeedSet = 0f;
     Main.windSpeedSpeed = 0f;
     Main.cloud = new Cloud[200];
     Main.resetClouds = true;
     Main.fadeCounter = 0;
     Main.invAlpha = 1f;
     Main.invDir = 1f;
     Main.maxMoons = 3;
     Main.moonType = 0;
     Main.numTileColors = 31;
     Main.tileAltTextureInit = new bool[Main.maxTileSets, Main.numTileColors];
     Main.tileAltTextureDrawn = new bool[Main.maxTileSets, Main.numTileColors];
     Main.numTreeStyles = 19;
     Main.treeAltTextureInit = new bool[Main.numTreeStyles, Main.numTileColors];
     Main.treeAltTextureDrawn = new bool[Main.numTreeStyles, Main.numTileColors];
     Main.checkTreeAlt = new bool[Main.numTreeStyles, Main.numTileColors];
     Main.wallAltTextureInit = new bool[Main.maxWallTypes, Main.numTileColors];
     Main.wallAltTextureDrawn = new bool[Main.maxWallTypes, Main.numTileColors];
     Main.musicFade = new float[40];
     Main.musicVolume = 0.75f;
     Main.ambientVolume = 0.75f;
     Main.soundVolume = 1f;
     Main.MenuServerMode = ServerSocialMode.None;
     Main.tileLighted = new bool[Main.maxTileSets];
     Main.tileMergeDirt = new bool[Main.maxTileSets];
     Main.tileCut = new bool[Main.maxTileSets];
     Main.tileAlch = new bool[Main.maxTileSets];
     Main.tileShine = new int[Main.maxTileSets];
     Main.tileShine2 = new bool[Main.maxTileSets];
     Main.wallHouse = new bool[Main.maxWallTypes];
     Main.wallDungeon = new bool[Main.maxWallTypes];
     Main.wallLight = new bool[Main.maxWallTypes];
     Main.wallBlend = new int[Main.maxWallTypes];
     Main.tileStone = new bool[Main.maxTileSets];
     Main.tileAxe = new bool[Main.maxTileSets];
     Main.tileHammer = new bool[Main.maxTileSets];
     Main.tileWaterDeath = new bool[Main.maxTileSets];
     Main.tileLavaDeath = new bool[Main.maxTileSets];
     Main.tileTable = new bool[Main.maxTileSets];
     Main.tileBlockLight = new bool[Main.maxTileSets];
     Main.tileNoSunLight = new bool[Main.maxTileSets];
     Main.tileDungeon = new bool[Main.maxTileSets];
     Main.tileSpelunker = new bool[Main.maxTileSets];
     Main.tileSolidTop = new bool[Main.maxTileSets];
     Main.tileSolid = new bool[Main.maxTileSets];
     Main.tileBouncy = new bool[Main.maxTileSets];
     Main.tileValue = new short[Main.maxTileSets];
     Main.tileLargeFrames = new byte[Main.maxTileSets];
     Main.wallLargeFrames = new byte[Main.maxWallTypes];
     Main.tileRope = new bool[Main.maxTileSets];
     Main.tileBrick = new bool[Main.maxTileSets];
     Main.tileMoss = new bool[Main.maxTileSets];
     Main.tileNoAttach = new bool[Main.maxTileSets];
     Main.tileNoFail = new bool[Main.maxTileSets];
     Main.tileObsidianKill = new bool[Main.maxTileSets];
     Main.tileFrameImportant = new bool[Main.maxTileSets];
     Main.tilePile = new bool[Main.maxTileSets];
     Main.tileBlendAll = new bool[Main.maxTileSets];
     Main.tileGlowMask = new short[Main.maxTileSets];
     Main.tileContainer = new bool[Main.maxTileSets];
     Main.tileSign = new bool[Main.maxTileSets];
     Main.tileMerge = new bool[Main.maxTileSets][];
     Main.cageFrames = 25;
     Main.critterCage = false;
     Main.bunnyCageFrame = new int[Main.cageFrames];
     Main.bunnyCageFrameCounter = new int[Main.cageFrames];
     Main.squirrelCageFrame = new int[Main.cageFrames];
     Main.squirrelCageFrameCounter = new int[Main.cageFrames];
     Main.squirrelCageFrameOrange = new int[Main.cageFrames];
     Main.squirrelCageFrameCounterOrange = new int[Main.cageFrames];
     Main.mallardCageFrame = new int[Main.cageFrames];
     Main.mallardCageFrameCounter = new int[Main.cageFrames];
     Main.duckCageFrame = new int[Main.cageFrames];
     Main.duckCageFrameCounter = new int[Main.cageFrames];
     Main.birdCageFrame = new int[Main.cageFrames];
     Main.birdCageFrameCounter = new int[Main.cageFrames];
     Main.redBirdCageFrame = new int[Main.cageFrames];
     Main.redBirdCageFrameCounter = new int[Main.cageFrames];
     Main.blueBirdCageFrame = new int[Main.cageFrames];
     Main.blueBirdCageFrameCounter = new int[Main.cageFrames];
     Main.butterflyCageMode = new byte[9, Main.cageFrames];
     Main.butterflyCageFrame = new int[9, Main.cageFrames];
     Main.butterflyCageFrameCounter = new int[9, Main.cageFrames];
     Main.scorpionCageFrame = new int[2, Main.cageFrames];
     Main.scorpionCageFrameCounter = new int[2, Main.cageFrames];
     Main.snailCageFrame = new int[Main.cageFrames];
     Main.snailCageFrameCounter = new int[Main.cageFrames];
     Main.snail2CageFrame = new int[Main.cageFrames];
     Main.snail2CageFrameCounter = new int[Main.cageFrames];
     Main.fishBowlFrameMode = new byte[Main.cageFrames];
     Main.fishBowlFrame = new int[Main.cageFrames];
     Main.fishBowlFrameCounter = new int[Main.cageFrames];
     Main.frogCageFrame = new int[Main.cageFrames];
     Main.frogCageFrameCounter = new int[Main.cageFrames];
     Main.mouseCageFrame = new int[Main.cageFrames];
     Main.mouseCageFrameCounter = new int[Main.cageFrames];
     Main.jellyfishCageMode = new byte[3, Main.cageFrames];
     Main.jellyfishCageFrame = new int[3, Main.cageFrames];
     Main.jellyfishCageFrameCounter = new int[3, Main.cageFrames];
     Main.wormCageFrame = new int[Main.cageFrames];
     Main.wormCageFrameCounter = new int[Main.cageFrames];
     Main.penguinCageFrame = new int[Main.cageFrames];
     Main.penguinCageFrameCounter = new int[Main.cageFrames];
     Main.slugCageFrame = new int[3, Main.cageFrames];
     Main.slugCageFrameCounter = new int[3, Main.cageFrames];
     Main.grasshopperCageFrame = new int[Main.cageFrames];
     Main.grasshopperCageFrameCounter = new int[Main.cageFrames];
     Main.tileSand = new bool[Main.maxTileSets];
     Main.tileFlame = new bool[Main.maxTileSets];
     Main.npcCatchable = new bool[Main.maxNPCTypes];
     Main.tileFrame = new int[Main.maxTileSets];
     Main.tileFrameCounter = new int[Main.maxTileSets];
     Main.wallFrame = new byte[Main.maxWallTypes];
     Main.wallFrameCounter = new byte[Main.maxWallTypes];
     Main.backgroundWidth = new int[207];
     Main.backgroundHeight = new int[207];
     Main.tilesLoaded = false;
     //Main.Map = new WorldMap(Main.maxTilesX, Main.maxTilesY);
     //Main.tile = new Tile[Main.maxTilesX, Main.maxTilesY];
     Main.tile = new TileProvider();
     Main.star = new Star[130];
     Main.item = new Item[401];
     Main.itemLockoutTime = new int[401];
     Main.npc = new NPC[201];
     Main.projectile = new Projectile[1001];
     Main.projectileIdentity = new int[256, 1001];
     Main.combatText = new CombatText[100];
     Main.itemText = new ItemText[20];
     Main.chest = new Chest[1000];
     Main.sign = new Sign[1000];
     Main.itemFrame = new int[401];
     Main.itemFrameCounter = new int[401];
     Main.itemAnimations = new DrawAnimation[Main.maxItemTypes];
     Main.itemAnimationsRegistered = new List<int>();
     Main.screenWidth = 1152;
     Main.screenHeight = 864;
     Main.screenMaximized = false;
     Main.chatLength = 600;
     Main.chatMode = false;
     Main.chatRelease = false;
     Main.showCount = 10;
     Main.numChatLines = 500;
     Main.startChatLine = 0;
     Main.chatText = "";
     Main.inputTextEnter = false;
     Main.inputTextEscape = false;
     Main.hotbarScale = new float[] { 1f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f };
     Main.mouseTextColor = 0;
     Main.mouseTextColorChange = 1;
     Main.mouseLeftRelease = false;
     Main.mouseRightRelease = false;
     Main.playerInventory = false;
     Main.stackCounter = 0;
     Main.stackDelay = 7;
     Main.superFastStack = 0;
     Main.mouseItem = new Item();
     Main.guideItem = new Item();
     Main.reforgeItem = new Item();
     Main.inventoryScale = 0.75f;
     Main.hasFocus = true;
     Main.recFastScroll = false;
     Main.recBigList = false;
     Main.recStart = 0;
     Main.recipe = new Recipe[Recipe.maxRecipes];
     Main.availableRecipe = new int[Recipe.maxRecipes];
     Main.availableRecipeY = new float[Recipe.maxRecipes];
     Main.myPlayer = 0;
     Main.player = new Player[256];
     Main.playerDrawDust = new List<int>();
     Main.playerDrawGore = new List<int>();
     Main.npcChatRelease = false;
     Main.editSign = false;
     Main.editChest = false;
     Main.blockInput = false;
     Main.defaultChestName = string.Empty;
     Main.npcChatText = "";
     Main.npcChatFocus1 = false;
     Main.npcChatFocus2 = false;
     Main.npcChatFocus3 = false;
     Main.npcShop = 0;
     Main.numShops = 21;
     Main.npcChatCornerItem = 0;
     Main.travelShop = new int[40];
     Main.anglerWhoFinishedToday = new List<string>();
     Main.anglerQuest = 0;
     Main.anglerQuestItemNetIDs = new int[] { 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488 };
     Main.craftGuide = false;
     Main.reforge = false;
     Main.toolTip = new Item();
     Main.motd = "";
     Main.numDisplayModes = 0;
     Main.displayWidth = new int[99];
     Main.displayHeight = new int[99];
     Main.gameMenu = true;
     Main.maxLoadPlayer = 1000;
     Main.maxLoadWorld = 1000;
     Main.PlayerList = new List<PlayerFileData>();
     Main.ActivePlayerFileData = new PlayerFileData();
     Main.PendingPlayer = null;
     Main.WorldList = new List<WorldFileData>();
     Main.ActiveWorldFileData = new WorldFileData();
     object[] objArray = new object[] { Environment.GetFolderPath(Environment.SpecialFolder.Personal), Path.DirectorySeparatorChar, "My Games", Path.DirectorySeparatorChar, "Terraria" };
     Main.SavePath = string.Concat(objArray);
     Main.WorldPath = string.Concat(Main.SavePath, Path.DirectorySeparatorChar, "Worlds");
     Main.CloudWorldPath = "worlds";
     Main.PlayerPath = string.Concat(Main.SavePath, Path.DirectorySeparatorChar, "Players");
     Main.CloudPlayerPath = "players";
     Main.Configuration = new Preferences(string.Concat(Main.SavePath, Path.DirectorySeparatorChar, "config.json"), false, false);
     Main.itemName = new string[Main.maxItemTypes];
     Main.npcName = new string[Main.maxNPCTypes];
     Main.PendingResolutionWidth = 800;
     Main.PendingResolutionHeight = 600;
     Main.invasionType = 0;
     Main.invasionX = 0;
     Main.invasionSize = 0;
     Main.invasionDelay = 0;
     Main.invasionWarn = 0;
     Main.invasionSizeStart = 0;
     Main.invasionProgressNearInvasion = false;
     Main.invasionProgressMode = 2;
     Main.invasionProgressIcon = 0;
     Main.invasionProgress = 0;
     Main.invasionProgressMax = 0;
     Main.invasionProgressWave = 0;
     Main.invasionProgressDisplayLeft = 0;
     Main.invasionProgressAlpha = 0f;
     Main.npcFrameCount = new int[] { 1, 2, 2, 3, 6, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 25, 23, 25, 21, 15, 26, 2, 10, 1, 16, 16, 16, 3, 1, 15, 3, 1, 3, 1, 1, 21, 25, 1, 1, 1, 3, 3, 15, 3, 7, 7, 4, 5, 6, 5, 3, 3, 23, 6, 3, 6, 6, 2, 5, 3, 2, 7, 7, 4, 2, 8, 1, 5, 1, 2, 4, 16, 5, 4, 4, 15, 15, 15, 15, 2, 4, 6, 6, 24, 16, 1, 1, 1, 1, 1, 1, 4, 3, 1, 1, 1, 1, 1, 1, 5, 6, 7, 16, 1, 1, 25, 23, 12, 20, 21, 1, 2, 2, 3, 6, 1, 1, 1, 15, 4, 11, 1, 23, 6, 6, 3, 1, 2, 2, 1, 3, 4, 1, 2, 1, 4, 2, 1, 15, 3, 25, 4, 5, 7, 3, 2, 12, 12, 4, 4, 4, 8, 8, 9, 5, 6, 4, 15, 23, 3, 3, 8, 5, 4, 13, 15, 12, 4, 14, 14, 3, 2, 5, 3, 2, 3, 23, 5, 14, 16, 5, 2, 2, 12, 3, 3, 3, 3, 2, 2, 2, 2, 2, 7, 14, 15, 16, 8, 3, 15, 15, 15, 2, 3, 20, 25, 23, 26, 4, 4, 16, 16, 20, 20, 20, 2, 2, 2, 2, 8, 12, 3, 4, 2, 4, 25, 26, 26, 6, 3, 3, 3, 3, 3, 3, 4, 4, 5, 4, 6, 7, 15, 4, 7, 6, 1, 1, 2, 4, 3, 5, 3, 3, 3, 4, 5, 6, 4, 2, 1, 8, 4, 4, 1, 8, 1, 4, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 3, 3, 3, 3, 3, 3, 15, 3, 6, 12, 20, 20, 20, 15, 15, 15, 5, 5, 6, 6, 5, 2, 7, 2, 6, 6, 6, 6, 6, 15, 15, 15, 15, 15, 11, 4, 2, 2, 3, 3, 3, 15, 15, 15, 10, 14, 12, 1, 10, 8, 3, 3, 2, 2, 2, 2, 7, 15, 15, 15, 6, 3, 10, 10, 6, 9, 8, 9, 8, 20, 10, 6, 23, 1, 4, 24, 2, 4, 6, 6, 10, 15, 15, 15, 15, 4, 4, 26, 23, 8, 2, 4, 4, 4, 4, 2, 2, 4, 12, 12, 9, 9, 9, 1, 9, 11, 2, 2, 9, 5, 6, 4, 18, 8, 11, 1, 4, 5, 8, 4, 1, 1, 1, 1, 4, 2, 5, 4, 11, 5, 11, 1, 1, 1, 10, 10, 15, 8, 17, 6, 6, 1, 12, 12, 13, 15, 9, 5, 10, 7, 7, 7, 7, 7, 7, 7, 4, 4, 16, 16, 25, 5, 7, 3, 10, 2, 6, 2, 19, 19, 19, 19, 26, 3, 1, 1, 1, 1, 1, 16, 21, 9, 16, 7, 6, 18, 13, 20, 12, 12, 20, 6, 14, 14, 14, 14, 6, 1, 3, 25, 19, 20, 22, 2, 4, 4, 4, 11, 9, 8, 1, 9, 1, 8, 8, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 1, 6, 9, 1, 1, 1, 1, 1, 1, 4, 1, 10, 1, 8, 4, 1, 5, 8, 8, 8, 8, 9, 9, 5, 4, 8, 16, 8, 2, 3, 3, 6, 6 };
     Main.npcLifeBytes = new Dictionary<int, byte>();
     Main.clientPlayer = new Player();
     Main.getIP = Main.defaultIP;
     Main.getPort = Convert.ToString(Netplay.ListenPort);
     Main.menuMultiplayer = false;
     Main.menuServer = false;
     Main.netMode = 0;
     Main._targetNetMode = 0;
     Main._hasPendingNetmodeChange = false;
     Main.maxNPCUpdates = 5;
     Main.maxItemUpdates = 5;
     Main.cUp = "W";
     Main.cLeft = "A";
     Main.cDown = "S";
     Main.cRight = "D";
     Main.cJump = "Space";
     Main.cThrowItem = "T";
     Main.cHeal = "H";
     Main.cMana = "J";
     Main.cBuff = "B";
     Main.cHook = "E";
     Main.cTorch = "LeftShift";
     Main.cInv = "Escape";
     Main.cSmart = "LeftControl";
     Main.cMount = "R";
     Main.cSmartToggle = true;
     Main.smartDigEnabled = false;
     Main.smartDigShowing = false;
     Main.cursorOverride = -1;
     Main.signHover = -1;
     Main.cMapZoomIn = "Add";
     Main.cMapZoomOut = "Subtract";
     Main.cMapAlphaUp = "PageUp";
     Main.cMapAlphaDown = "PageDown";
     Main.cMapFull = "M";
     Main.cMapStyle = "Tab";
     Main.mouseColor = new Color(255, 50, 95);
     Main.cursorColor = Color.White;
     Main.cursorColorDirection = 1;
     Main.cursorAlpha = 0f;
     Main.cursorScale = 0f;
     Main.signBubble = false;
     Main.signX = 0;
     Main.signY = 0;
     Main.hideUI = false;
     Main.releaseUI = false;
     Main.fixedTiming = true;
     Main.oldStatusText = "";
     Main.autoShutdown = false;
     Main.serverGenLock = false;
     Main.sundialCooldown = 0;
     Main.fastForwardTime = false;
     Main.ambientWaterfallX = -1f;
     Main.ambientWaterfallY = -1f;
     Main.ambientWaterfallStrength = 0f;
     Main.ambientLavafallX = -1f;
     Main.ambientLavafallY = -1f;
     Main.ambientLavafallStrength = 0f;
     Main.ambientLavaX = -1f;
     Main.ambientLavaY = -1f;
     Main.ambientLavaStrength = 0f;
     Main.ambientCounter = 0;
     Main.ProjectileUpdateLoopIndex = -1;
     Main.maxMenuItems = 16;
     Main.selectedPlayer = 0;
     Main.selectedWorld = 0;
     Main.menuMode = 0;
     Main.menuSkip = 0;
     Main.cpItem = new Item();
     Main.newWorldName = "";
     Main.hoverItemName = "";
     Main.inventoryBack = new Color(220, 220, 220, 220);
     Main.mouseText = false;
     Main.sX = Main.screenWidth - 800;
     Main.oldClothesColor = new Color[4];
     Main.selColor = Color.White;
     Main.focusColor = 0;
     Main.colorDelay = 0;
     Main.setKey = -1;
     Main.bgScroll = 0;
     Main.autoPass = false;
     Main.menuFocus = 0;
     Main.blockMouse = false;
     string[] strArrays = new string[] { "MonolithVortex", "MonolithNebula", "MonolithStardust", "MonolithSolar" };
     Main.MonolithFilterNames = strArrays;
     string[] strArrays1 = new string[] { "MonolithVortex", "MonolithNebula", "MonolithStardust", "MonolithSolar" };
     Main.MonolithSkyNames = strArrays1;
     Main.bgScale = 1f;
     Main.bgW = (int)(1024f * Main.bgScale);
     Main.backColor = Color.White;
     Main.trueBackColor = Main.backColor;
 }
コード例 #8
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
 public void SetWorld(string world)
 {
     Main.ActiveWorldFileData = WorldFile.GetAllMetadata(world);
     Main.WorldPathClassic = world;
 }
コード例 #9
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
        public void LoadDedConfig(string configPath)
        {
            if (File.Exists(configPath))
            {
                using (StreamReader streamReader = new StreamReader(configPath))
                {
                    while (true)
                    {
                        string str = streamReader.ReadLine();
                        string str1 = str;
                        if (str == null)
                        {
                            break;
                        }
                        try
                        {
                            if (str1.Length > 6 && str1.Substring(0, 6).ToLower() == "world=")
                            {
                                string str2 = str1.Substring(6);
                                Main.ActiveWorldFileData = WorldFile.GetAllMetadata(str2);
                            }
                            if (str1.Length > 5 && str1.Substring(0, 5).ToLower() == "port=")
                            {
                                string str3 = str1.Substring(5);
                                try
                                {
                                    Netplay.ListenPort = Convert.ToInt32(str3);
                                }
                                catch (Exception ex)
                                {
            #if DEBUG
                                    Console.WriteLine(ex);
                                    System.Diagnostics.Debugger.Break();

            #endif
                                }
                            }
                            if (str1.Length > 11 && str1.Substring(0, 11).ToLower() == "maxplayers=")
                            {
                                string str4 = str1.Substring(11);
                                try
                                {
                                    Main.maxNetPlayers = Convert.ToInt32(str4);
                                }
                                catch (Exception ex)
                                {
            #if DEBUG
                                    Console.WriteLine(ex);
                                    System.Diagnostics.Debugger.Break();

            #endif
                                }
                            }
            #if !MONO
                            if (str1.Length > 9 && str1.Substring(0, 9).ToLower() == "priority=")
                            {
                                string str5 = str1.Substring(9);
                                try
                                {
                                    int num = Convert.ToInt32(str5);
                                    if (num >= 0 && num <= 5)
                                    {
                                        Process currentProcess = Process.GetCurrentProcess();
                                        if (num == 0)
                                        {
                                            currentProcess.PriorityClass = ProcessPriorityClass.RealTime;
                                        }
                                        else if (num == 1)
                                        {
                                            currentProcess.PriorityClass = ProcessPriorityClass.High;
                                        }
                                        else if (num == 2)
                                        {
                                            currentProcess.PriorityClass = ProcessPriorityClass.AboveNormal;
                                        }
                                        else if (num == 3)
                                        {
                                            currentProcess.PriorityClass = ProcessPriorityClass.Normal;
                                        }
                                        else if (num == 4)
                                        {
                                            currentProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
                                        }
                                        else if (num == 5)
                                        {
                                            currentProcess.PriorityClass = ProcessPriorityClass.Idle;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
            #if DEBUG
                                    Console.WriteLine(ex);
                                    System.Diagnostics.Debugger.Break();

            #endif
                                }
                            }
            #endif
                            if (str1.Length > 9 && str1.Substring(0, 9).ToLower() == "password="******"motd=")
                            {
                                Main.motd = str1.Substring(5);
                            }
                            if (str1.Length > 5 && str1.Substring(0, 5).ToLower() == "lang=")
                            {
                                Lang.lang = Convert.ToInt32(str1.Substring(5));
                            }
                            if (str1.Length >= 10 && str1.Substring(0, 10).ToLower() == "worldpath=")
                            {
                                Main.WorldPath = str1.Substring(10);
                            }
                            if (str1.Length >= 10 && str1.Substring(0, 10).ToLower() == "worldname=")
                            {
                                Main.worldName = str1.Substring(10);
                            }
                            if (str1.Length > 8 && str1.Substring(0, 8).ToLower() == "banlist=")
                            {
                                Netplay.BanFilePath = str1.Substring(8);
                            }
                            if (str1.Length > 11 && str1.Substring(0, 11).ToLower() == "difficulty=")
                            {
                                string str6 = str1.Substring(11);
                                if (str6 == "0")
                                {
                                    Main.expertMode = false;
                                }
                                else if (str6 == "1")
                                {
                                    Main.expertMode = true;
                                }
                            }
                            if (str1.Length > 11 && str1.Substring(0, 11).ToLower() == "autocreate=")
                            {
                                string str7 = str1.Substring(11);
                                if (str7 == "0")
                                {
                                    Main.autoGen = false;
                                }
                                else if (str7 == "1")
                                {
                                    Main.maxTilesX = 4200;
                                    Main.maxTilesY = 1200;
                                    Main.autoGen = true;
                                }
                                else if (str7 == "2")
                                {
                                    Main.maxTilesX = 6300;
                                    Main.maxTilesY = 1800;
                                    Main.autoGen = true;
                                }
                                else if (str7 == "3")
                                {
                                    Main.maxTilesX = 8400;
                                    Main.maxTilesY = 2400;
                                    Main.autoGen = true;
                                }
                            }
                            if (str1.Length > 7 && str1.Substring(0, 7).ToLower() == "secure=" && str1.Substring(7) == "1")
                            {
                                Netplay.spamCheck = true;
                            }
                            if (str1.Length > 10 && str1.Substring(0, 10).ToLower() == "npcstream=")
                            {
                                string str8 = str1.Substring(10);
                                try
                                {
                                    Main.npcStreamSpeed = Convert.ToInt32(str8);
                                }
                                catch (Exception ex)
                                {
            #if DEBUG
                                    Console.WriteLine(ex);
                                    System.Diagnostics.Debugger.Break();

            #endif
                                }
                            }
                        }
                        catch (Exception ex)
                        {
            #if DEBUG
                            Console.WriteLine(ex);
                            System.Diagnostics.Debugger.Break();

            #endif
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
        public void DedServ()
        {
            ServerApi.Hooks.InvokeGameInitialize();
            string str;
            Main.rand = new Random();
            Console.Title = string.Concat("Terraria Server ", Main.versionNumber2);
            Main.dedServ = true;
            Main.showSplash = false;
            if (Main.autoGen)
            {
                Main.ActiveWorldFileData = new WorldFileData();
                Main.ActiveWorldFileData.Path = Main.WorldPathClassic;
            }
            this.Initialize();
            Lang.setLang(false);
            for (int i = 0; i < 540; i++)
            {
                NPC nPC = new NPC();
                nPC.SetDefaults(i, -1f);
                Main.npcName[i] = nPC.name;
            }

            if (Console.IsInputRedirected == true && string.IsNullOrEmpty(Main.WorldPathClassic) == true && !Main.autoGen)
            {
                throw new Exception("When running in the background, the world must be specified with -world <path>");
            }

            while (string.IsNullOrEmpty(Main.worldPathName))
            {
                bool flag = true;
                while (flag)
                {
                    Main.LoadWorlds();
                    Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                    Console.WriteLine("");
                    for (int j = 0; j < Main.WorldList.Count; j++)
                    {
                        object[] name = new object[]
                        {
                            j + 1,
                            '\t',
                            '\t', Main.WorldList[j].Name
                        };
                        Console.WriteLine("{0,-4}{1,-22}{2}, {3}, {4,-6}{5}",
                            j + 1,
                            Main.WorldList[j].Name,
                            Main.WorldList[j].IsHardMode ? "hard" : "norm",
                            Main.WorldList[j].HasCrimson ? "crim" : "corr",
                            Main.WorldList[j].IsExpertMode ? "exp" : "norm",
                            String.Format("Last used: {0}",
                                File.GetLastWriteTime(Main.WorldList[j].Path).ToString("g")));
                    }
                    Console.WriteLine();
                    Console.WriteLine("n           \tNew World");
                    Console.WriteLine("d   <number>\tDelete World");
                    Console.WriteLine("");
                    Console.Write("Choose World: ");
                    string str2 = Console.ReadLine() ?? "";
                    try
                    {
                        Console.Clear();
                    }
                    catch (Exception ex)
                    {
            #if DEBUG
                        Console.WriteLine(ex);
                        System.Diagnostics.Debugger.Break();

            #endif
                    }
                    if (str2.Length >= 2 && str2.Substring(0, 2).ToLower() == "d ")
                    {
                        try
                        {
                            int num = Convert.ToInt32(str2.Substring(2)) - 1;
                            if (num < Main.WorldList.Count)
                            {
                                Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                                Console.WriteLine("");
                                Console.WriteLine(string.Concat("Really delete ", Main.WorldList[num].Name, "?"));
                                Console.Write("(y/n): ");
                                if (Console.ReadLine().ToLower() == "y")
                                {
                                    Main.EraseWorld(num);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
            #if DEBUG
                            Console.WriteLine(ex);
                            System.Diagnostics.Debugger.Break();

            #endif
                        }
                        try
                        {
                            Console.Clear();
                        }
                        catch (Exception ex)
                        {
            #if DEBUG
                            Console.WriteLine(ex);
                            System.Diagnostics.Debugger.Break();

            #endif
                        }
                    }
                    else if (str2 == "n" || str2 == "N")
                    {
                        bool flag1 = true;
                        while (flag1)
                        {
                            Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                            Console.WriteLine("");
                            Console.WriteLine(string.Concat("1", '\t', "Small"));
                            Console.WriteLine(string.Concat("2", '\t', "Medium"));
                            Console.WriteLine(string.Concat("3", '\t', "Large"));
                            Console.WriteLine("");
                            Console.Write("Choose size: ");
                            str = Console.ReadLine();
                            try
                            {
                                int num1 = Convert.ToInt32(str);
                                if (num1 == 1)
                                {
                                    Main.maxTilesX = 4200;
                                    Main.maxTilesY = 1200;
                                    flag1 = false;
                                }
                                else if (num1 == 2)
                                {
                                    Main.maxTilesX = 6400;
                                    Main.maxTilesY = 1800;
                                    flag1 = false;
                                }
                                else if (num1 == 3)
                                {
                                    Main.maxTilesX = 8400;
                                    Main.maxTilesY = 2400;
                                    flag1 = false;
                                }
                            }
                            catch (Exception ex)
                            {
            #if DEBUG
                                Console.WriteLine(ex);
                                System.Diagnostics.Debugger.Break();

            #endif
                            }
                            try
                            {
                                Console.Clear();
                            }
                            catch (Exception ex)
                            {
            #if DEBUG
                                Console.WriteLine(ex);
                                System.Diagnostics.Debugger.Break();

            #endif
                            }
                        }
                        flag1 = true;
                        while (flag1)
                        {
                            Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                            Console.WriteLine("");
                            Console.WriteLine(string.Concat("1", '\t', "Normal"));
                            Console.WriteLine(string.Concat("2", '\t', "Expert"));
                            Console.WriteLine("");
                            Console.Write("Choose difficulty: ");
                            str = Console.ReadLine();
                            try
                            {
                                int num2 = Convert.ToInt32(str);
                                if (num2 == 1)
                                {
                                    Main.expertMode = false;
                                    flag1 = false;
                                }
                                else if (num2 == 2)
                                {
                                    Main.expertMode = true;
                                    flag1 = false;
                                }
                            }
                            catch (Exception ex)
                            {
            #if DEBUG
                                Console.WriteLine(ex);
                                System.Diagnostics.Debugger.Break();

            #endif
                            }
                            try
                            {
                                Console.Clear();
                            }
                            catch (Exception ex)
                            {
            #if DEBUG
                                Console.WriteLine(ex);
                                System.Diagnostics.Debugger.Break();

            #endif
                            }
                        }
                        flag1 = true;
                        while (flag1)
                        {
                            Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                            Console.WriteLine("");
                            Console.Write("Enter world name: ");
                            Main.newWorldName = Console.ReadLine();
                            if (Main.newWorldName != "" && Main.newWorldName != " " && Main.newWorldName != null)
                            {
                                if (Main.newWorldName.Length > 20)
                                {
                                    Main.newWorldName = Main.newWorldName.Substring(0, 20);
                                }
                                flag1 = false;
                            }
                            try
                            {
                                Console.Clear();
                            }
                            catch (Exception ex)
                            {
            #if DEBUG
                                Console.WriteLine(ex);
                                System.Diagnostics.Debugger.Break();

            #endif
                            }
                        }
                        Main.worldName = Main.newWorldName;
                        Main.ActiveWorldFileData = WorldFile.CreateMetadata(Main.worldName, Main.expertMode);
                        Main.menuMode = 10;
                        Main.serverGenLock = true;
                        GenerationProgress generationProgress = new GenerationProgress();
                        WorldGen.CreateNewWorld(generationProgress);
                        flag1 = false;
                        while (Main.menuMode == 10)
                        {
                            if (Main.oldStatusText == Main.statusText)
                            {
                                continue;
                            }
                            Main.oldStatusText = Main.statusText;
                            Console.WriteLine(Main.statusText);
                        }
                        try
                        {
                            Console.Clear();
                        }
                        catch (Exception ex)
                        {
            #if DEBUG
                            Console.WriteLine(ex);
                            System.Diagnostics.Debugger.Break();

            #endif
                        }

                        int oldProgress = 0;
                        int oldValue = 0;

                        while (Main.serverGenLock)
                        {

                            if ((int)(generationProgress.TotalProgress * 100) != oldProgress || (int)(generationProgress.Value * 100) != oldValue)
                            {
                                Main.statusText = string.Format(string.Concat("{0:0%} - ", generationProgress.Message, " - {1:0%}"), generationProgress.TotalProgress, generationProgress.Value);
                                Main.oldStatusText = Main.statusText;
                                oldProgress = (int)(generationProgress.TotalProgress * 100);
                                oldValue = (int)(generationProgress.Value * 100);
                                Console.WriteLine(Main.statusText);
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            int num3 = Convert.ToInt32(str2);
                            num3--;
                            if (num3 >= 0 && num3 < Main.WorldList.Count)
                            {
                                bool flag2 = true;
                                while (flag2)
                                {
                                    Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                                    Console.WriteLine("");
                                    Console.Write("Max players (press enter for {0}): ", Main.maxNetPlayers);
                                    string str3 = Console.ReadLine();
                                    try
                                    {
                                        if (str3 == "")
                                        {
                                            str3 = Main.maxNetPlayers.ToString();
                                        }
                                        int num4 = Convert.ToInt32(str3);
                                        if (num4 <= 255 && num4 >= 1)
                                        {
                                            Main.maxNetPlayers = num4;
                                            flag2 = false;
                                        }
                                        flag2 = false;
                                    }
                                    catch (Exception ex)
                                    {
            #if DEBUG
                                        Console.WriteLine(ex);
                                        System.Diagnostics.Debugger.Break();

            #endif
                                    }
                                    try
                                    {
                                        Console.Clear();
                                    }
                                    catch (Exception ex)
                                    {
            #if DEBUG
                                        Console.WriteLine(ex);
                                        System.Diagnostics.Debugger.Break();

            #endif
                                    }
                                }
                                flag2 = true;
                                while (flag2)
                                {
                                    if (Netplay.ListenPort != 7777) //If the port has been changed by the API do not allow it to be changed.
                                    {
                                        flag2 = false;
                                        break;
                                    }
                                    Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber2));
                                    Console.WriteLine("");
                                    Console.Write("Server port (press enter for 7777): ");
                                    string str4 = Console.ReadLine();
                                    try
                                    {
                                        if (str4 == "")
                                        {
                                            str4 = "7777";
                                        }
                                        int num5 = Convert.ToInt32(str4);
                                        if (num5 <= 65535)
                                        {
                                            Netplay.ListenPort = num5;
                                            flag2 = false;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
            #if DEBUG
                                        Console.WriteLine(ex);
                                        System.Diagnostics.Debugger.Break();

            #endif
                                    }
                                    try
                                    {
                                        Console.Clear();
                                    }
                                    catch (Exception ex)
                                    {
            #if DEBUG
                                        Console.WriteLine(ex);
                                        System.Diagnostics.Debugger.Break();

            #endif
                                    }
                                }
                                Main.ActiveWorldFileData = Main.WorldList[num3];
                                flag = false;
                                try
                                {
                                    Console.Clear();
                                }
                                catch (Exception ex)
                                {
            #if DEBUG
                                    Console.WriteLine(ex);
                                    System.Diagnostics.Debugger.Break();

            #endif
                                }
                            }
                        }
                        catch (Exception ex)
                        {
            #if DEBUG
                            Console.WriteLine(ex);
                            System.Diagnostics.Debugger.Break();

            #endif
                        }
                    }
                }
            }
            try
            {
                Console.Clear();
            }
            catch (Exception ex)
            {
            #if DEBUG
                Console.WriteLine(ex);
                System.Diagnostics.Debugger.Break();

            #endif
            }
            WorldGen.serverLoadWorld();
            Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber));
            Console.WriteLine("");
            while (!Netplay.IsServerRunning)
            {
                if (Main.oldStatusText == Main.statusText)
                {
                    continue;
                }
                Main.oldStatusText = Main.statusText;
                Console.WriteLine(Main.statusText);
            }
            try
            {
                Console.Clear();
            }
            catch (Exception ex)
            {
            #if DEBUG
                Console.WriteLine(ex);
                System.Diagnostics.Debugger.Break();

            #endif
            }
            Console.WriteLine(string.Concat("Terraria Server ", Main.versionNumber));
            Console.WriteLine("");
            Console.WriteLine(string.Concat("Listening on port ", Netplay.ListenPort));
            Console.WriteLine("Type 'help' for a list of commands.");
            Console.WriteLine("");
            Console.Title = string.Concat("Terraria Server: ", Main.worldName);

            Stopwatch stopwatch = new Stopwatch();
            if (!Main.autoShutdown)
            {
                Main.startDedInput();
            }
            ServerApi.Hooks.InvokeGamePostInitialize();
            stopwatch.Start();
            double num6 = 16.6666666666667;
            double num7 = 0;
            int num8 = 0;
            while (!Netplay.disconnect)
            {
                double elapsedMilliseconds = (double)stopwatch.ElapsedMilliseconds;
                if (elapsedMilliseconds + num7 >= num6)
                {
                    num8++;
                    num7 = num7 + (elapsedMilliseconds - num6);
                    stopwatch.Reset();
                    stopwatch.Start();
                    if (Main.oldStatusText != Main.statusText)
                    {
                        Main.oldStatusText = Main.statusText;
                        Console.WriteLine(Main.statusText);
                    }
                    if (Netplay.anyClients || ServerApi.ForceUpdate)
                    {
                        ServerApi.Hooks.InvokeGameUpdate();
                        this.Update();
                        ServerApi.Hooks.InvokeGamePostUpdate();
                    }
                    double elapsedMilliseconds1 = (double)stopwatch.ElapsedMilliseconds + num7;
                    if (elapsedMilliseconds1 < num6)
                    {
                        int num9 = (int)(num6 - elapsedMilliseconds1) - 1;
                        if (num9 > 1)
                        {
                            Thread.Sleep(num9 - 1);
                            if (!Netplay.anyClients)
                            {
                                num7 = 0;
                                Thread.Sleep(10);
                            }
                        }
                    }
                }
                Thread.Sleep(0);
            }
        }
コード例 #11
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
 private static int WorldListSortMethod(WorldFileData data1, WorldFileData data2)
 {
     return data1.Name.CompareTo(data2.Name);
 }
コード例 #12
0
        public static WorldFileData GetAllMetadata(string file, bool cloudSave)
        {
            Stream memoryStream;
            if (file == null || cloudSave && SocialAPI.Cloud == null)
            {
                return null;
            }
            try
            {
                WorldFileData worldFileDatum = new WorldFileData(file, cloudSave);
                if (cloudSave)
                {
                    memoryStream = new MemoryStream(SocialAPI.Cloud.Read(file));
                }
                else
                {
                    memoryStream = new FileStream(file, FileMode.Open);
                }
                using (Stream stream = memoryStream)
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        int num = binaryReader.ReadInt32();
                        if (num < 135)
                        {
                            worldFileDatum.Metadata = FileMetadata.FromCurrentSettings(FileType.World);
                        }
                        else
                        {
                            worldFileDatum.Metadata = FileMetadata.Read(binaryReader, FileType.World);
                        }
                        if (num <= Main.curRelease)
                        {
                            binaryReader.ReadInt16();
                            stream.Position = (long)binaryReader.ReadInt32();
                            worldFileDatum.Name = binaryReader.ReadString();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            int num1 = binaryReader.ReadInt32();
                            worldFileDatum.SetWorldSize(binaryReader.ReadInt32(), num1);
                            worldFileDatum.IsExpertMode = (num < 112 ? false : binaryReader.ReadBoolean());
                            if (num >= 141)
                            {
                                worldFileDatum.CreationTime = DateTime.FromBinary(binaryReader.ReadInt64());
                            }
                            else if (cloudSave)
                            {
                                worldFileDatum.CreationTime = DateTime.Now;
                            }
                            else
                            {
                                worldFileDatum.CreationTime = File.GetCreationTime(file);
                            }
                            binaryReader.ReadByte();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            binaryReader.ReadDouble();
                            binaryReader.ReadDouble();
                            binaryReader.ReadDouble();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadInt32();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadInt32();
                            binaryReader.ReadInt32();
                            worldFileDatum.HasCrimson = binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            if (num >= 118)
                            {
                                binaryReader.ReadBoolean();
                            }
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadBoolean();
                            binaryReader.ReadByte();
                            binaryReader.ReadInt32();
                            worldFileDatum.IsHardMode = binaryReader.ReadBoolean();
                            return worldFileDatum;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception during world metadata load.");
                Console.WriteLine("If you are using -autocreate, it is safe to ignore this.");
            #if DEBUG
                Console.WriteLine(ex);
                System.Diagnostics.Debugger.Break();

            #endif
            }
            return new WorldFileData();
        }
コード例 #13
0
 public static WorldFileData CreateMetadata(string name, bool isExpertMode)
 {
     WorldFileData worldFileDatum = new WorldFileData(Main.GetWorldPathFromName(name))
     {
         Name = name,
         IsExpertMode = isExpertMode,
         CreationTime = DateTime.Now,
         Metadata = FileMetadata.FromCurrentSettings(FileType.World)
     };
     return worldFileDatum;
 }
コード例 #14
0
		public UIWorldListItem(WorldFileData data)
		{
			this.BorderColor = new Color(89, 116, 213) * 0.7f;
			this._dividerTexture = TextureManager.Load("Images/UI/Divider");
			this._innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
			this._buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
			this._buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
			this._buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
			this._buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
			this._buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
			this._buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
			this.Height.Set(96f, 0f);
			this.Width.Set(0f, 1f);
			base.SetPadding(6f);
			this._data = data;
			this._worldIcon = new UIImage(this.GetIcon());
			this._worldIcon.Left.Set(4f, 0f);
			this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
			base.Append(this._worldIcon);
			UIImageButton uIImageButton = new UIImageButton(this._buttonPlayTexture);
			uIImageButton.VAlign = 1f;
			uIImageButton.Left.Set(4f, 0f);
			uIImageButton.OnClick += new UIElement.MouseEvent(this.PlayGame);
			base.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
			uIImageButton.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
			uIImageButton.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
			base.Append(uIImageButton);
			UIImageButton uIImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
			uIImageButton2.VAlign = 1f;
			uIImageButton2.Left.Set(28f, 0f);
			uIImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
			uIImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
			uIImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
			uIImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
			base.Append(uIImageButton2);
			if (SocialAPI.Cloud != null)
			{
				UIImageButton uIImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
				uIImageButton3.VAlign = 1f;
				uIImageButton3.Left.Set(52f, 0f);
				uIImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
				uIImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
				uIImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
				base.Append(uIImageButton3);
			}
			UIImageButton uIImageButton4 = new UIImageButton(this._buttonDeleteTexture);
			uIImageButton4.VAlign = 1f;
			uIImageButton4.HAlign = 1f;
			uIImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
			uIImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
			uIImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
			this._deleteButton = uIImageButton4;
			if (!this._data.IsFavorite)
			{
				base.Append(uIImageButton4);
			}
			this._buttonLabel = new UIText("", 1f, false);
			this._buttonLabel.VAlign = 1f;
			this._buttonLabel.Left.Set(80f, 0f);
			this._buttonLabel.Top.Set(-3f, 0f);
			base.Append(this._buttonLabel);
			this._deleteButtonLabel = new UIText("", 1f, false);
			this._deleteButtonLabel.VAlign = 1f;
			this._deleteButtonLabel.HAlign = 1f;
			this._deleteButtonLabel.Left.Set(-30f, 0f);
			this._deleteButtonLabel.Top.Set(-3f, 0f);
			base.Append(this._deleteButtonLabel);
		}
コード例 #15
0
ファイル: WorldFile.cs プロジェクト: EmuDevs/EDTerraria
        public static WorldFileData GetAllMetadata(string file)
        {
            if (file != null)
            {
                WorldFileData data = new WorldFileData(file);
                if (!FileUtilities.Exists(file))
                {
                    data.CreationTime = DateTime.Now;
                    data.Metadata = FileMetadata.FromCurrentSettings(FileType.World);
                    return data;
                }
                try
                {
                    using (Stream stream = new FileStream(file, FileMode.Open))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                        {
                            int num = reader.ReadInt32();
                            if (num >= 0x87)
                                data.Metadata = FileMetadata.Read(reader, FileType.World);
                            else
                                data.Metadata = FileMetadata.FromCurrentSettings(FileType.World);

                            if (num <= Main.curRelease)
                            {
                                reader.ReadInt16();
                                stream.Position = reader.ReadInt32();
                                data.Name = reader.ReadString();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                int y = reader.ReadInt32();
                                int x = reader.ReadInt32();
                                data.SetWorldSize(x, y);
                                data.IsExpertMode = (num >= 0x70) && reader.ReadBoolean();
                                if (num >= 0x8d)
                                    data.CreationTime = DateTime.FromBinary(reader.ReadInt64());
                                else
                                    data.CreationTime = DateTime.Now;
                                data.CreationTime = File.GetCreationTime(file);
                                reader.ReadByte();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                reader.ReadDouble();
                                reader.ReadDouble();
                                reader.ReadDouble();
                                reader.ReadBoolean();
                                reader.ReadInt32();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadInt32();
                                reader.ReadInt32();
                                data.HasCrimson = reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                if (num >= 0x76)
                                {
                                    reader.ReadBoolean();
                                }
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadBoolean();
                                reader.ReadByte();
                                reader.ReadInt32();
                                data.IsHardMode = reader.ReadBoolean();
                                return data;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            return null;
        }