Exemplo n.º 1
0
 public void Can_load_assets_from_directories()
 {
     var target = new AssetLoader(_lookupDirectories);
     Assert.AreEqual(10, target.Assets.Count);
     Assert.AreEqual(1, target.FromDirectory("scripts1.1").Count());
     Assert.AreEqual(4, target.FromTree("scripts1.2").Count());
 }
Exemplo n.º 2
0
        internal Autodesk3ds(AssetLoader loader, Autodesk3dsFormat format)
            : base(format.Manager, "3DS Model - " + loader.Name)
        {
            var reader = loader.Reader;

            AssetFormat = format;

            Chunk chunk, subchunk;
            if (!Chunk.ReadRequired(loader, ChunkId.Main, out chunk))
                return;

            while (chunk.ReadSubchunk(out subchunk)) {
                switch (subchunk.Id) {
                    case ChunkId.ModelVersion:
                        int modelVersion = subchunk.ReadContentInt(0);
                        if (modelVersion > MaxModelVersion || modelVersion < MinModelVersion)
                            loader.AddError(chunk.Offset, "3DS model version {0} is out of range ({1} to {2} supported).", modelVersion, MinModelVersion, MaxModelVersion);
                        break;

                    case ChunkId.Editor:
                        ReadEditor(subchunk);
                        break;

                    default:
                        chunk.ReportUnknownSubchunkError(subchunk);
                        break;
                }

                subchunk.RequireAtEnd();
            }
        }
Exemplo n.º 3
0
        public void Get_all_content_for_asset_using_a_test_processor()
        {
            AssetPipeline.Processors.Add(new TestAssetProcessor());

            var target = new AssetLoader(_lookupDirectories);
            var content = target.GetContent("test1.a.js");
            Assert.AreEqual("AA", content);
        }
Exemplo n.º 4
0
 private void Awake()
 {
     if (!_singleton)
     {
         _singleton = this;
         return;
     }
     Destroy(this);
 }
Exemplo n.º 5
0
        public void Can_load_assest_from_single_file()
        {
            var target = new AssetLoader(_lookupDirectories);
            Asset result1 = target.Load("test1.a.js");
            Assert.AreEqual(2, result1.Children.Count()); // one real + one from require_self

            Asset result2 = target.Load("test1.b.js");
            Assert.AreEqual(5, result2.Children.Count());
        }
Exemplo n.º 6
0
 internal ZipArchive(AssetLoader loader)
     : base(loader)
 {
     ZipFile = new ZipFile(loader.Reader.BaseStream);
     foreach (ZipEntry entry in ZipFile) {
         if (entry.IsDirectory)
             continue;
         new ZipRecord(this, entry);
     }
 }
Exemplo n.º 7
0
	public static AssetLoader Get()
	{
		if(!s_instance)
		{
			GameObject loader = new GameObject();
			loader.name = "AssetLoader";
			s_instance = loader.AddComponent<AssetLoader>();
			return s_instance;
		}
		return AssetLoader.s_instance;
	}
Exemplo n.º 8
0
 protected override async Task LoadAsync(HttpClient httpClient)
 {
     var assetLoader = new AssetLoader(httpClient, SavePath, true);
     try
     {
         await assetLoader.DownloadAllAsync();
         assetLoader.MoveTemp();
     }
     catch
     {
         assetLoader.DeleteTemp();
         throw;
     }
 }
Exemplo n.º 9
0
        public void Get_all_content_for_asset()
        {
            var target = new AssetLoader(_lookupDirectories);
            var content = target.GetContent("test1.b.js");
            var expectedResult =
            @"var test1_b = """";
            var test1_1_a = """";
            var test1_1_1_a = """";
            var test1_1_1_b = """";
            var test1_2_a = """";
            var test1_2_b = """";";

            Assert.AreEqual(expectedResult, content.Trim());
        }
Exemplo n.º 10
0
        /// <summary>Load the PCX image file.</summary>
        /// <param name="loader"></param>
        /// <returns></returns>
        public override Asset Load(AssetLoader loader)
        {
            BinaryReader reader = loader.Reader;
            PcxHeader header = new PcxHeader(reader);

            int pitch = (header.BitsPerPixel * header.ColorPlaneCount + 7) / 8 * header.SizeX;
            int[] data = new int[pitch * header.SizeY + 1];

            for (int row = 0; row < header.SizeY; row++) {
                switch (header.Compression) {
                    case PcxCompression.None:
                        for (int index = 0; index < pitch; index++)
                            data[pitch * row + index] = reader.ReadByte();
                        break;

                    case PcxCompression.RLE:
                        for (int offset = pitch * row, end = offset + header.BytesPerScanLine; offset < end; ) {
                            byte value = reader.ReadByte();

                            if (value < 0xC0) {
                                data[offset++] = value;
                            } else {
                                int runEnd = offset + value - 0xC0;
                                byte code = reader.ReadByte();

                                while (offset < runEnd)
                                    data[offset++] = code;
                            }
                        }
                        break;

                    default:
                        throw new NotImplementedException();
                }
            }

            PaletteAsset palette = null;

            if(header.ColorPlaneCount == 1) {
                if(reader.BaseStream.ReadByte() == PaletteMagic) {
                    palette = PaletteAsset.ReadRgb(Manager, loader.Name + " Palette", reader, 1 << header.BitsPerPixel, 255);
                }
            }

            if(palette != null)
                return new IndexedTextureAsset(loader, palette, header.SizeX, header.SizeY, data, pitch);
            else
                throw new NotImplementedException();
        }
Exemplo n.º 11
0
		void AssetLoaded(AssetLoader.Loader loader)
		{
			Debug.Log("BDArmory loaded shaders: ");
			for(int i = 0; i < loader.objects.Length; i++)
			{
				Shader s = (Shader)loader.objects[i];
				if(s == null) continue;

				Debug.Log("- " + s.name);

				if(s.name == "BDArmory/Bullet")
				{
					BulletShader = s;
				}
				else if(s.name == "BDArmory/Unlit Black")
				{
					UnlitBlackShader = s;
				}
				else if(s.name == "BDArmory/Grayscale Effect")
				{
					GrayscaleEffectShader = s;
				}
			}
		}
Exemplo n.º 12
0
 public void Get_all_content_for_asset_containing_require_self()
 {
     var target = new AssetLoader(_lookupDirectories);
     var content = target.GetContent("test1.a.js");
     Assert.AreEqual("var test1_1_1_a = \"\";var test1_a = \"\";", content.Trim().Replace("\n", "").Replace("\r", ""));
 }
Exemplo n.º 13
0
 public void Get_all_content_for_asset_which_contains_coffeescript()
 {
     var target = new AssetLoader(_lookupDirectories);
     var content = target.GetContent("test2.a.js");
     Assert.AreEqual("var test;\ntest = 5;", content.Trim());
 }
Exemplo n.º 14
0
        void Load(string filename)
        {
            // load the map
            Map map = Map.LoadFromFile(filename);

            this.parent.LoadTiles(map.Width, map.Height);

            this.parent.ClearTiles(); // clear the parent tiles

            foreach (Tile tile in map.Tiles)
            {
                EditorTile newTile = new EditorTile("", Vector2.Zero, EditorManager.defaultTile, TileType.Empty);
                // handle normal tiles
                if (tile.TileType == TileType.Normal)
                {
                    newTile = new EditorTile(tile.Name, tile.Transform.Position, AssetLoader.LoadTexture("Textures/" + tile.Name + ".png"), tile.TileType);
                }
                else if (tile.TileType == TileType.Block)
                {
                    newTile = new EditorTile(tile.Name, tile.Transform.Position, AssetLoader.LoadTexture("Textures/blocks/" + tile.Name + ".png"), tile.TileType);
                }
                else if (tile.TileType == TileType.Door)
                {
                    newTile = new EditorTile(tile.Name, tile.Transform.Position, AssetLoader.LoadTexture("Textures/doors/" + tile.Name + ".png"), tile.TileType);
                }

                // set depth
                newTile.Depth = tile.Depth;
                // set data
                newTile.Data = tile.Data;

                // get rotation
                newTile.Transform.Rotation = tile.Transform.Rotation;

                // add the new tile
                if (newTile.Name != "")
                {
                    this.parent.AddTile(newTile);
                }
            }

            foreach (MapMarker marker in map.Markers)
            {
                // try and find the tile owner
                var tileOwner = this.parent.tiles.Find(x => x.Transform.Position == marker.StartingPosition) as EditorTile;

                if (tileOwner != null)
                {
                    // find the type of tile and load the map marker
                    if (marker.MarkerType == MarkerType.PlayerSpawnPoint)
                    {
                        tileOwner.SetMarker(new MapMarker(marker.Name, tileOwner.StartingPosition, AssetLoader.LoadTexture("textures/objects/" + marker.Name + ".png"), marker.MarkerType));
                    }
                    else if (marker.MarkerType == MarkerType.SpawnPoint)
                    {
                        tileOwner.SetMarker(new MapMarker(marker.Name, tileOwner.StartingPosition, AssetLoader.LoadTexture("textures/monsters/" + marker.Name + ".png"), marker.MarkerType));
                    }
                    else if (marker.MarkerType == MarkerType.NPCSpawnPoint)
                    {
                        tileOwner.SetMarker(new MapMarker(marker.Name, tileOwner.StartingPosition, AssetLoader.LoadTexture("textures/npcs/" + marker.Name + ".png"), marker.MarkerType));
                    }
                    else if (marker.MarkerType == MarkerType.LightSource)
                    {
                        tileOwner.SetMarker(new MapMarker(marker.Name, tileOwner.StartingPosition, AssetLoader.LoadTexture("textures/lights/" + marker.Name + ".png"), marker.MarkerType));
                    }
                }
            }
        }
Exemplo n.º 15
0
        ///  <summary>
        ///     Create a Texture2D from a bitmap font.
        ///  </summary>
        /// <param name="fontName"></param>
        /// <param name="text"></param>
        ///  <param name="fontSize"></param>
        ///  <param name="color"></param>
        /// <param name="textAlignment"></param>
        /// <param name="maxWidth"></param>
        ///  <returns></returns>
        internal static Texture2D Create(string fontName, string text, float fontSize, Color color, Alignment textAlignment, int maxWidth)
        {
            // Stores the size of the text & Texture2D
            SizeF textSize;

            var alignment = GetAlignment(textAlignment);

            var font = GetCustomFont(fontName, fontSize) ?? new Font(fontName, fontSize, FontStyle.Regular);

            // Here we're creating a "virtual" graphics instance to measure
            // the size of the text.
            using (var bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb))
                using (var g = System.Drawing.Graphics.FromImage(bmp))
                    using (var format = new StringFormat())
                    {
                        g.SmoothingMode      = SmoothingMode.HighQuality;
                        g.InterpolationMode  = InterpolationMode.HighQualityBilinear;
                        g.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                        g.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
                        g.CompositingQuality = CompositingQuality.HighQuality;
                        g.PageUnit           = GraphicsUnit.Pixel;

                        format.Alignment     = alignment;
                        format.LineAlignment = alignment;

                        // Measure the string
                        textSize = g.MeasureString(text, font, maxWidth, format);
                    }

            // Bitmaps must have non-zero size.
            textSize.Width  = Math.Max(1, textSize.Width);
            textSize.Height = Math.Max(1, textSize.Height);

            // Create the actual bitmap using the size of the text.
            using (var bmp = new Bitmap((int)(textSize.Width + 0.5), (int)(textSize.Height + 0.5), PixelFormat.Format32bppArgb))
                using (var g = System.Drawing.Graphics.FromImage(bmp))
                    using (var brush = new SolidBrush(System.Drawing.Color.White))
                        using (var format = new StringFormat())
                        {
                            g.SmoothingMode      = SmoothingMode.HighQuality;
                            g.InterpolationMode  = InterpolationMode.HighQualityBilinear;
                            g.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                            g.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
                            g.CompositingQuality = CompositingQuality.HighQuality;
                            g.PageUnit           = GraphicsUnit.Pixel;

                            format.Alignment     = alignment;
                            format.LineAlignment = alignment;

                            var rect = new RectangleF(0, 0, textSize.Width, textSize.Height);
                            g.DrawString(text, font, brush, rect, format);

                            // Flush all graphics changes to the bitmap
                            g.Flush();

                            // Dispose of the font.
                            font.Dispose();

                            // On Windows the alpha is not premultiplied. This results in subtle border artifacts when scaled or
                            // moved around improperly.
                            // On Linux the alpha is premultipled.
                            // This is regardless of the Bitmap PixelFormat.

                            // bmp.RawFormat = ImageFormat.Png;
                            return(AssetLoader.LoadTexture2D(ImageToByte2(bmp)));
                        }
        }
        public override void Initialize()
        {
            Name              = nameof(PrivateMessagingWindow);
            ClientRectangle   = new Rectangle(0, 0, 600, 600);
            BackgroundTexture = AssetLoader.LoadTextureUncached("privatemessagebg.png");

            unknownGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.unknownicon);
            adminGameIcon   = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.cncneticon);

            personalMessageColor  = AssetLoader.GetColorFromString(ClientConfiguration.Instance.SentPMColor);
            otherUserMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor);

            lblPrivateMessaging           = new XNALabel(WindowManager);
            lblPrivateMessaging.Name      = nameof(lblPrivateMessaging);
            lblPrivateMessaging.FontIndex = 1;
            lblPrivateMessaging.Text      = "PRIVATE MESSAGING";

            AddChild(lblPrivateMessaging);
            lblPrivateMessaging.CenterOnParent();
            lblPrivateMessaging.ClientRectangle = new Rectangle(
                lblPrivateMessaging.X, 12,
                lblPrivateMessaging.Width,
                lblPrivateMessaging.Height);

            tabControl                 = new XNAClientTabControl(WindowManager);
            tabControl.Name            = nameof(tabControl);
            tabControl.ClientRectangle = new Rectangle(60, 50, 0, 0);
            tabControl.ClickSound      = new EnhancedSoundEffect("button.wav");
            tabControl.FontIndex       = 1;
            tabControl.AddTab("Messages", 160);
            tabControl.AddTab("Friend List", 160);
            tabControl.AddTab("All Players", 160);
            tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;

            lblPlayers                 = new XNALabel(WindowManager);
            lblPlayers.Name            = nameof(lblPlayers);
            lblPlayers.ClientRectangle = new Rectangle(12, tabControl.Bottom + 24, 0, 0);
            lblPlayers.FontIndex       = 1;
            lblPlayers.Text            = "PLAYERS:";

            lbUserList                 = new XNAListBox(WindowManager);
            lbUserList.Name            = nameof(lbUserList);
            lbUserList.ClientRectangle = new Rectangle(lblPlayers.X,
                                                       lblPlayers.Bottom + 6,
                                                       150, Height - lblPlayers.Bottom - 18);
            lbUserList.RightClick             += LbUserList_RightClick;
            lbUserList.SelectedIndexChanged   += LbUserList_SelectedIndexChanged;
            lbUserList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbUserList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;

            lblMessages                 = new XNALabel(WindowManager);
            lblMessages.Name            = nameof(lblMessages);
            lblMessages.ClientRectangle = new Rectangle(lbUserList.Right + 12,
                                                        lblPlayers.Y, 0, 0);
            lblMessages.FontIndex = 1;
            lblMessages.Text      = "MESSAGES:";

            lbMessages                 = new ChatListBox(WindowManager);
            lbMessages.Name            = nameof(lbMessages);
            lbMessages.ClientRectangle = new Rectangle(lblMessages.X,
                                                       lbUserList.Y,
                                                       Width - lblMessages.X - 12,
                                                       lbUserList.Height - 25);
            lbMessages.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbMessages.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;

            tbMessageInput                 = new XNATextBox(WindowManager);
            tbMessageInput.Name            = nameof(tbMessageInput);
            tbMessageInput.ClientRectangle = new Rectangle(lbMessages.X,
                                                           lbMessages.Bottom + 6, lbMessages.Width, 19);
            tbMessageInput.EnterPressed     += TbMessageInput_EnterPressed;
            tbMessageInput.MaximumTextLength = 200;
            tbMessageInput.Enabled           = false;

            playerContextMenu                 = new XNAContextMenu(WindowManager);
            playerContextMenu.Name            = nameof(playerContextMenu);
            playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2);
            playerContextMenu.Disable();
            playerContextMenu.AddItem("Add Friend", PlayerContextMenu_ToggleFriend);
            playerContextMenu.AddItem("Toggle Block", PlayerContextMenu_ToggleIgnore, null, () => (bool)lbUserList.SelectedItem.Tag, null);
            playerContextMenu.AddItem("Invite", PlayerContextMenu_Invite, null, () => !string.IsNullOrEmpty(inviteChannelName));
            playerContextMenu.AddItem("Join", PlayerContextMenu_JoinUser, null, () => JoinUserAction != null && IsSelectedUserOnline());

            notificationBox            = new PrivateMessageNotificationBox(WindowManager);
            notificationBox.Enabled    = false;
            notificationBox.Visible    = false;
            notificationBox.LeftClick += NotificationBox_LeftClick;

            AddChild(tabControl);
            AddChild(lblPlayers);
            AddChild(lbUserList);
            AddChild(lblMessages);
            AddChild(lbMessages);
            AddChild(tbMessageInput);
            AddChild(playerContextMenu);
            WindowManager.AddAndInitializeControl(notificationBox);

            base.Initialize();

            CenterOnParent();

            tabControl.SelectedTab = 0;

            connectionManager.PrivateMessageReceived += ConnectionManager_PrivateMessageReceived;
            connectionManager.UserAdded            += ConnectionManager_UserAdded;
            connectionManager.UserRemoved          += ConnectionManager_UserRemoved;
            connectionManager.UserGameIndexUpdated += ConnectionManager_UserGameIndexUpdated;

            sndMessageSound = new EnhancedSoundEffect("message.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundMessageCooldown);

            sndPrivateMessageSound = new EnhancedSoundEffect("pm.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundPrivateMessageCooldown);

            sndMessageSound.Enabled = UserINISettings.Instance.MessageSound;

            GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;
        }
Exemplo n.º 17
0
 /// <summary>Matches based on the 128-byte header.</summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 public override LoadMatchStrength LoadMatch(AssetLoader loader)
 {
     if (loader.Length < PcxHeader.ByteSize)
         return LoadMatchStrength.None;
     PcxHeader header = new PcxHeader(loader.Reader);
     if (!header.IsValid)
         return LoadMatchStrength.None;
     return LoadMatchStrength.Strong;
 }
Exemplo n.º 18
0
        /* New mod loading system
         * void toggleIsModDisabled(LoadedModInfo mod)
         * {
         *  if (mod == null)
         *      return;
         *              mod.IsEnabled = !mod.IsEnabled;
         *
         *  ReloadModItems();
         * }
         */

        // Old mod loading system
        void addModToList(Mod mod, GameObject parent)
        {
            bool?isModNotActive = ModsManager.Instance.IsModDeactivated(mod);

            if (!isModNotActive.HasValue)
            {
                return;
            }

            GameObject modItemPrefab = AssetLoader.GetObjectFromFile("modswindow", "ModItemPrefab", "Clone Drone in the Danger Zone_Data/");
            GameObject modItem       = Instantiate(modItemPrefab, parent.transform);

            string modName = mod.GetModName();
            string url     = mod.GetModImageURL();

            _modItems.Add(modItem);

            if (!string.IsNullOrEmpty(url))
            {
                setImageFromURL(url, mod);
            }

            ModdedObject modItemModdedObject = modItem.GetComponent <ModdedObject>();

            modItemModdedObject.GetObject <Text>(0).text = modName;                 // Set title
            modItemModdedObject.GetObject <Text>(1).text = mod.GetModDescription(); // Set description
            modItemModdedObject.GetObject <Text>(5).text = ModBotLocalizationManager.FormatLocalizedStringFromID("mods_menu_mod_id", mod.GetUniqueID());

            Button enableOrDisableButton = modItem.GetComponent <ModdedObject>().GetObject <Button>(3);

            if (isModNotActive.Value)
            {
                modItem.GetComponent <Image>().color = Color.red;
                LocalizedTextField localizedTextField = enableOrDisableButton.transform.GetChild(0).GetComponent <LocalizedTextField>();
                localizedTextField.LocalizationID = "mods_menu_enable_mod";
                Accessor.CallPrivateMethod("tryLocalizeTextField", localizedTextField);

                enableOrDisableButton.colors = new ColorBlock()
                {
                    normalColor = Color.green * 1.2f, highlightedColor = Color.green, pressedColor = Color.green * 0.8f, colorMultiplier = 1
                };
            }

            Button BroadcastButton = modItemModdedObject.GetObject <Button>(6);

            BroadcastButton.onClick.AddListener(delegate { onBroadcastButtonClicked(mod); });
            BroadcastButton.gameObject.SetActive(GameModeManager.IsMultiplayer());

            Button DownloadButton = modItemModdedObject.GetObject <Button>(7);

            DownloadButton.onClick.AddListener(delegate { onDownloadButtonClicked(mod); });
            bool hasNoFile = ModsManager.Instance.GetIsModOnlyLoadedInMemory(mod);

            DownloadButton.gameObject.SetActive(hasNoFile);

            int modId = ModsManager.Instance.GetAllMods().IndexOf(mod);

            modItemModdedObject.GetObject <Button>(3).onClick.AddListener(delegate { toggleIsModDisabled(modId); });       // Add disable button callback
            modItemModdedObject.GetObject <Button>(4).onClick.AddListener(delegate { openModsOptionsWindowForMod(mod); }); // Add Mod Options button callback
            modItemModdedObject.GetObject <Button>(4).interactable = mod.ImplementsSettingsWindow();
        }
Exemplo n.º 19
0
        /// <summary>
        /// Returns a task that finishes with a SkillTree object once it has been initialized.
        /// </summary>
        /// <param name="persistentData"></param>
        /// <param name="dialogCoordinator">Can be null if the resulting tree is not used.</param>
        /// <param name="controller">Null if no initialization progress should be displayed.</param>
        /// <param name="assetLoader">Can optionally be provided if the caller wants to backup assets.</param>
        /// <returns></returns>
        public static async Task<SkillTree> CreateAsync(IPersistentData persistentData, IDialogCoordinator dialogCoordinator,
            ProgressDialogController controller = null, AssetLoader assetLoader = null)
        {
            controller?.SetProgress(0);

            var dataFolderPath = AppData.GetFolder("Data", true);
            _assetsFolderPath = dataFolderPath + "Assets/";

            if (assetLoader == null)
                assetLoader = new AssetLoader(new HttpClient(), dataFolderPath, false);

            var skillTreeTask = LoadTreeFileAsync(dataFolderPath + "Skilltree.txt",
                () => assetLoader.DownloadSkillTreeToFileAsync());
            var optsTask = LoadTreeFileAsync(dataFolderPath + "Opts.txt",
                () => assetLoader.DownloadOptsToFileAsync());
            await Task.WhenAny(skillTreeTask, optsTask);
            controller?.SetProgress(0.1);

            var skillTreeObj = await skillTreeTask;
            var optsObj = await optsTask;
            controller?.SetProgress(0.25);

            var tree = new SkillTree(persistentData, dialogCoordinator);
            await tree.InitializeAsync(skillTreeObj, optsObj, controller, assetLoader);
            return tree;
        }
Exemplo n.º 20
0
        public override void Initialize()
        {
            Name              = "GameLoadingLobby";
            ClientRectangle   = new Rectangle(0, 0, 590, 510);
            BackgroundTexture = AssetLoader.LoadTexture("loadmpsavebg.png");

            lblDescription                 = new XNALabel(WindowManager);
            lblDescription.Name            = nameof(lblDescription);
            lblDescription.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblDescription.Text            = "Wait for all players to join and get ready, then click Load Game to load the saved multiplayer game.";

            panelPlayers = new XNAPanel(WindowManager);
            panelPlayers.ClientRectangle         = new Rectangle(12, 32, 373, 125);
            panelPlayers.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            panelPlayers.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;

            AddChild(lblDescription);
            AddChild(panelPlayers);

            lblPlayerNames = new XNALabel[8];
            for (int i = 0; i < 8; i++)
            {
                XNALabel lblPlayerName = new XNALabel(WindowManager);
                lblPlayerName.Name = nameof(lblPlayerName) + i;

                if (i < 4)
                {
                    lblPlayerName.ClientRectangle = new Rectangle(9, 9 + 30 * i, 0, 0);
                }
                else
                {
                    lblPlayerName.ClientRectangle = new Rectangle(190, 9 + 30 * (i - 4), 0, 0);
                }

                lblPlayerName.Text = "Player " + i;
                panelPlayers.AddChild(lblPlayerName);
                lblPlayerNames[i] = lblPlayerName;
            }

            lblMapName                 = new XNALabel(WindowManager);
            lblMapName.Name            = nameof(lblMapName);
            lblMapName.FontIndex       = 1;
            lblMapName.ClientRectangle = new Rectangle(panelPlayers.Right + 12,
                                                       panelPlayers.Y, 0, 0);
            lblMapName.Text = "MAP:";

            lblMapNameValue                 = new XNALabel(WindowManager);
            lblMapNameValue.Name            = nameof(lblMapNameValue);
            lblMapNameValue.ClientRectangle = new Rectangle(lblMapName.X,
                                                            lblMapName.Y + 18, 0, 0);
            lblMapNameValue.Text = "Map name";

            lblGameMode                 = new XNALabel(WindowManager);
            lblGameMode.Name            = nameof(lblGameMode);
            lblGameMode.ClientRectangle = new Rectangle(lblMapName.X,
                                                        panelPlayers.Y + 40, 0, 0);
            lblGameMode.FontIndex = 1;
            lblGameMode.Text      = "GAME MODE:";

            lblGameModeValue                 = new XNALabel(WindowManager);
            lblGameModeValue.Name            = nameof(lblGameModeValue);
            lblGameModeValue.ClientRectangle = new Rectangle(lblGameMode.X,
                                                             lblGameMode.Y + 18, 0, 0);
            lblGameModeValue.Text = "Game mode";

            lblSavedGameTime                 = new XNALabel(WindowManager);
            lblSavedGameTime.Name            = nameof(lblSavedGameTime);
            lblSavedGameTime.ClientRectangle = new Rectangle(lblMapName.X,
                                                             panelPlayers.Bottom - 40, 0, 0);
            lblSavedGameTime.FontIndex = 1;
            lblSavedGameTime.Text      = "SAVED GAME:";

            ddSavedGame                 = new XNAClientDropDown(WindowManager);
            ddSavedGame.Name            = nameof(ddSavedGame);
            ddSavedGame.ClientRectangle = new Rectangle(lblSavedGameTime.X,
                                                        panelPlayers.Bottom - 21,
                                                        Width - lblSavedGameTime.X - 12, 21);
            ddSavedGame.SelectedIndexChanged += DdSavedGame_SelectedIndexChanged;

            lbChatMessages      = new ChatListBox(WindowManager);
            lbChatMessages.Name = nameof(lbChatMessages);
            lbChatMessages.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbChatMessages.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbChatMessages.ClientRectangle         = new Rectangle(12, panelPlayers.Bottom + 12,
                                                                   Width - 24,
                                                                   Height - panelPlayers.Bottom - 12 - 29 - 34);

            tbChatInput                 = new XNATextBox(WindowManager);
            tbChatInput.Name            = nameof(tbChatInput);
            tbChatInput.ClientRectangle = new Rectangle(lbChatMessages.X,
                                                        lbChatMessages.Bottom + 3, lbChatMessages.Width, 19);
            tbChatInput.MaximumTextLength = 200;
            tbChatInput.EnterPressed     += TbChatInput_EnterPressed;

            btnLoadGame                 = new XNAClientButton(WindowManager);
            btnLoadGame.Name            = nameof(btnLoadGame);
            btnLoadGame.ClientRectangle = new Rectangle(lbChatMessages.X,
                                                        tbChatInput.Bottom + 6, 133, 23);
            btnLoadGame.Text       = "Load Game";
            btnLoadGame.LeftClick += BtnLoadGame_LeftClick;

            btnLeaveGame                 = new XNAClientButton(WindowManager);
            btnLeaveGame.Name            = nameof(btnLeaveGame);
            btnLeaveGame.ClientRectangle = new Rectangle(Width - 145,
                                                         btnLoadGame.Y, 133, 23);
            btnLeaveGame.Text       = "Leave Game";
            btnLeaveGame.LeftClick += BtnLeaveGame_LeftClick;

            AddChild(lblMapName);
            AddChild(lblMapNameValue);
            AddChild(lblGameMode);
            AddChild(lblGameModeValue);
            AddChild(lblSavedGameTime);
            AddChild(lbChatMessages);
            AddChild(tbChatInput);
            AddChild(btnLoadGame);
            AddChild(btnLeaveGame);
            AddChild(ddSavedGame);

            base.Initialize();

            sndJoinSound     = new EnhancedSoundEffect("joingame.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundGameLobbyJoinCooldown);
            sndLeaveSound    = new EnhancedSoundEffect("leavegame.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundGameLobbyLeaveCooldown);
            sndMessageSound  = new EnhancedSoundEffect("message.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundMessageCooldown);
            sndGetReadySound = new EnhancedSoundEffect("getready.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundGameLobbyGetReadyCooldown);

            MPColors = MultiplayerColor.LoadColors();

            WindowManager.CenterControlOnScreen(this);
        }
Exemplo n.º 21
0
 protected void LoadUI(string objectName, string bundle = "kerbokatz")
 {
     AssetLoader.Add(bundle, objectName, AssetLoaded);
 }
Exemplo n.º 22
0
    private void LoadUI(UIASSETS_ID id, int num)
    {
        subUiResPath = GlobalInstanceFunction.Instance.GetAssetsName((int)id, AssetLoader.EAssetType.ASSET_UI);
        if (subUIs_ == null)
        {
            subUIs_ = new List <string>();
            subUIs_.Add(subUiResPath);
        }
        else
        {
            if (!subUIs_.Contains(subUiResPath))
            {
                subUIs_.Add(subUiResPath);
            }
        }

        AssetLoader.LoadAssetBundle(subUiResPath, AssetLoader.EAssetType.ASSET_UI, (Assets, paramData) =>
        {
            if (hasDestroy)
            {
                //AssetInfoMgr.Instance.DecRefCount(subUiResPath, true);
                return;
            }
            if (null == Assets || null == Assets.mainAsset)
            {
                return;
            }
            GameObject go = (GameObject)GameObject.Instantiate(Assets.mainAsset) as GameObject;
            if (this == null && !gameObject.activeSelf)
            {
                Destroy(go);
            }
            go.transform.parent     = this.panel.transform;
            go.transform.position   = Vector3.zero;
            go.transform.localScale = Vector3.one;
            if (num == 1)
            {
                posObj = go;
                if (PropertyBtn.isEnabled)
                {
                    posObj.SetActive(false);
                }
            }
            else
            if (num == 2)
            {
                reductionObj = go;
                if (reductionBtn.isEnabled)
                {
                    reductionObj.SetActive(false);
                }
            }
            else
            if (num == 3)
            {
                QianghuaObj = go;
                if (qianghuaBtn.isEnabled)
                {
                    QianghuaObj.SetActive(false);
                }
            }
            else
            if (num == 4)
            {
                ReformObj = go;
                if (ReformBtn.isEnabled)
                {
                    ReformObj.SetActive(false);
                }
            }
            else
            if (num == 6)
            {
                epuObj = go;
                if (zhuangbeiBtn.isEnabled)
                {
                    epuObj.SetActive(false);
                }
            }
            UIManager.Instance.AdjustUIDepth(go.transform, true, 1000);
            NetWaitUI.HideMe();
            // UIManager.Instance.AdjustUIDepth(go.transform);
            //stateBtn.GetComponent<BoxCollider> ().enabled = true;
        }
                                    , null);
    }
Exemplo n.º 23
0
        public override void Load()
        {
            try
            {
                mapPath = System.IO.File.ReadAllText("launchoptions.txt");
            }
            catch (FileNotFoundException fnfe)
            { }

            // reset lists
            this.gameObjects = new List <GameObject>();
            this.frames      = new List <UI.Frame>();

            //this.Name = "test";

            //this.Background = AssetLoader.LoadTexture("Assets/Textures/backgrounds/wood1.png");

            Trapdoor trapdoor = new Trapdoor();

            this.AddGameObject(trapdoor);

            GameData.AddItemToBackpack(ItemData.New(ItemData.mushroomHelmet));
            GameData.AddItemToBackpack(ItemData.New(ItemData.mushroomHelmet));
            GameData.AddItemToBackpack(ItemData.New(ItemData.mushroomHelmet));



            /*Enemy enemy = new Enemy();
             * enemy.Transform.Position = new Vector2(500, 500);
             * this.AddGameObject(enemy);
             *
             * Enemy enemy2 = new Enemy();
             * enemy2.Transform.Position = new Vector2(800, 200);
             * this.AddGameObject(enemy2);*/

            /*Bat bat = new Bat();
             * bat.Transform.Position = new Vector2(0, 0);*/
            //this.AddGameObject(bat);

            /*Bat bat2 = new Bat();
             * bat2.Transform.Position = new Vector2(2000, 0);*/
            //this.AddGameObject(bat2);

            /*BabyFishDemon fish = new BabyFishDemon();
             * fish.Transform.Position = new Vector2(100, 720);*/
            //this.AddGameObject(fish);

            player = new Player();
            this.AddGameObject(player);



            fadeScreen = new GameObject("fade");
            fadeScreen.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/UI/fade.png");
            fadeScreen.Sprite.Color   = Color.White * 0; // make the screen invisible
            this.AddGameObject(fadeScreen);

            /*upperWall = new GameObject("upperwall");
             * upperWall.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/blocks/stone_block.png");
             * this.AddGameObject(upperWall);*/

            this.inventory  = new Inventory();
            this.statsFrame = new StatsFrame();

            /*TestUIFrame testUIframe = new TestUIFrame();
             * this.AddFrame(testUIframe);*/

            this.AddFrame(inventory);
            this.AddFrame(npcTalkingFrame);
            this.AddFrame(statsFrame);
            this.AddFrame(deathFrame);
            this.AddFrame(pauseFrame);
            this.AddFrame(beatMushroomFrame);

            //weather = new Weather();
            //this.AddGameObject(weather);

            this.LoadMap(false);



            base.Load();
            //enemy.SetInterval(1000);
        }
Exemplo n.º 24
0
        public void LoadMap(bool fullReset, string atDoor = "")
        {
            var map = Map.LoadFromFile(this.mapPath);

            var doors = map.Tiles.FindAll(x => x.TileType == TileType.Door);

            if (this.mapPath.Contains("mudtrap") || this.mapPath.Contains("mushroom"))
            {
                SceneManager.SoundManager.PlaySong("theme", 0.8f);
            }
            else if (this.mapPath.Contains("dungeon"))
            {
                SceneManager.SoundManager.PlaySong("adventure", 0.7f);
            }
            else
            {
                SceneManager.SoundManager.PlaySong("clora", 0.8f);
            }

            //whacky
            if (atDoor == "LAST")
            {
                atDoor = lastDoor;
            }

            this.lightSources.Clear();
            this.ClearTiles();
            if (fullReset) // use if not the first loading
            {
                this.gameObjects.RemoveAll(x => x.Name != "player");
            }

            // load tiles
            foreach (Tile tile in map.Tiles)
            {
                try
                {
                    // load the texture
                    if (tile.TileType != TileType.Door)
                    {
                        tile.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/tiles/" + tile.Name + ".png");
                    }
                    else
                    {
                        tile.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/tiles/" + tile.Name.Split(';')[0] + ".png");
                    }
                }
                catch (System.IO.FileNotFoundException fnfe)
                {
                    var a = 0;
                }

                /*if (tile.Name == "ocean1" || tile.Name == "wood_base" || tile.Name == "wood_wall")
                 *  tile.SetType(TileType.Block);*/
                tile.SetMapCoords(50);



                if (tile.Name != null && tile.Name != "delete")
                {
                    // check for an animation tile and add it
                    if (tile.Sprite.Texture.Width > 50)
                    {
                        var animtile = new AnimationTile(tile.Name, tile.Transform.Position, tile.Sprite.Texture, tile.TileType);
                        animtile.SetMapCoords(50);
                        this.AddTile(animtile);
                    }
                    else
                    {
                        this.AddTile(tile);
                    }
                }
            }
            // try to find the player's starting position
            var playerStart = map.Markers.Find(x => x.MarkerType == MarkerType.PlayerSpawnPoint);

            if (playerStart != null && atDoor == "")
            {
                player.Transform.Position = playerStart.StartingPosition;
            }
            else if (atDoor != "" || (atDoor == "" && lastDoor != "")) // if loading in at a door
            {
                if (atDoor == "")
                {
                    atDoor = lastDoor;
                }
                else
                {
                    lastDoor = atDoor;
                }
                // find the specific door with the specific given door data name
                var door = doors.Find(x => x.Data != null && x.Data.Contains(atDoor));
                if (door != null)
                {
                    player.Transform.Position = new Vector2(door.Transform.Position.X, door.Transform.Position.Y + player.Sprite.Texture.Height);
                }
            }

            // parse through enemies
            var enemies = MarkerParser.ParseEnemies(map.Markers);

            foreach (Enemy enemy in enemies)
            {
                // if it's a boss, start the attack
                if (enemy.GetType() == typeof(MushroomBoss))
                {
                    enemy.StartAttack(player);
                }
                this.AddGameObject(enemy);
            }



            // parse through npcs
            var npcs = MarkerParser.ParseNPCs(map.Markers);

            foreach (NPC npc in npcs)
            {
                this.AddGameObject(npc);
            }

            // get light sources
            var lights = MarkerParser.ParseLightsources(map.Markers);

            foreach (LightSource ls in lights)
            {
                this.AddLightSource(ls);
            }

            // reset player
            player.Reset();
            if (player.EntityStats != null)
            {
                player.EntityStats.HP = player.EntityStats.FullStats.MaxHP;
            }

            statsFrame.player = player;

            // reload
            base.Load();

            //this.AddLightSource(new LightSource(Vector2.One, Vector2.One, Color.White));

            /*Pickup pickup = new Pickup();
             * pickup.Transform.Position = player.Transform.Position;
             * pickup.PickupItem = ItemData.ironHelmet;
             * this.AddGameObject(pickup);*/
            /*MushroomMinion mush = new MushroomMinion();
             * mush.Transform.Position = new Vector2(500, 500);
             * mush.Load();
             * this.AddGameObject(mush);*/
        }
 void Awake()
 {
     Instance = this;
 }
 public SpeciesDefinitionConverter(AssetLoader loader = null)
 => this.loader = loader;
Exemplo n.º 27
0
 /// <summary>Match the loader context to the format.</summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 public override LoadMatchStrength LoadMatch(AssetLoader loader)
 {
     return loader.Reader.MatchMagic(Magic) ? LoadMatchStrength.Medium : LoadMatchStrength.None;
 }
 public BodyPartConverter(AssetLoader loader = null) => this.loader = loader;
Exemplo n.º 29
0
        public T Load <T>(IAssetInfo asset)
        {
            AssetLoader <T> loader = this.GetLoader <T>(asset.AssetName);

            return(loader(asset.AssetName));
        }
 protected void Start()
 {
     AssetLoader.Get().LoadUIScreen(this.GetScreenName(), new AssetLoader.GameObjectCallback(this.OnUIScreenLoaded), null, false);
 }
Exemplo n.º 31
0
 public override void LoadAssetsAsyc(AssetList list, FloatRef progress)
 {
     if (assetloader == null)
     {
         assetloader = new AssetLoader(datapaths);
     }
     assetloader.LoadAssetsAsync(list, progress);
 }
Exemplo n.º 32
0
 private void BGTexture(string image)
 {
     _bgImage.texture = ResourceManager.Load <Texture>(AssetLoader.GetStoryBgImage(image));
 }
Exemplo n.º 33
0
 private void Awake()
 {
     Instance = this;
 }
Exemplo n.º 34
0
 public void Doesnt_get_files_for_asset_which_is_not_on_lookup_path()
 {
     var target = new AssetLoader(_lookupDirectories);
     var files = target.GetFiles(new [] { "test1.1.a.js" });
     Assert.AreEqual(0, files.Count);
 }
Exemplo n.º 35
0
 public static Object LoadAssetNow(string path, Type type)
 {
     return(AssetLoader.LoadAssetNow(path, type));
 }
Exemplo n.º 36
0
        public override void Initialize()
        {
            Name                    = "TopBar";
            ClientRectangle         = new Rectangle(0, -39, WindowManager.RenderResolutionX, 39);
            PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            BackgroundTexture       = AssetLoader.CreateTexture(Color.Black, 1, 1);
            DrawBorders             = false;

            btnMainButton                 = new XNAClientButton(WindowManager);
            btnMainButton.Name            = "btnMainButton";
            btnMainButton.ClientRectangle = new Rectangle(12, 9, 160, 23);
            btnMainButton.Text            = "Main Menu (F2)";
            btnMainButton.LeftClick      += BtnMainButton_LeftClick;

            btnCnCNetLobby                 = new XNAClientButton(WindowManager);
            btnCnCNetLobby.Name            = "btnCnCNetLobby";
            btnCnCNetLobby.ClientRectangle = new Rectangle(184, 9, 160, 23);
            btnCnCNetLobby.Text            = "CnCNet Lobby (F3)";
            btnCnCNetLobby.LeftClick      += BtnCnCNetLobby_LeftClick;

            btnPrivateMessages                 = new XNAClientButton(WindowManager);
            btnPrivateMessages.Name            = "btnPrivateMessages";
            btnPrivateMessages.ClientRectangle = new Rectangle(356, 9, 160, 23);
            btnPrivateMessages.Text            = "Private Messages (F4)";
            btnPrivateMessages.LeftClick      += BtnPrivateMessages_LeftClick;

            lblDate                 = new XNALabel(WindowManager);
            lblDate.Name            = "lblDate";
            lblDate.FontIndex       = 1;
            lblDate.Text            = Renderer.GetSafeString(DateTime.Now.ToShortDateString(), lblDate.FontIndex);
            lblDate.ClientRectangle = new Rectangle(Width -
                                                    (int)Renderer.GetTextDimensions(lblDate.Text, lblDate.FontIndex).X - 12, 18,
                                                    lblDate.Width, lblDate.Height);

            lblTime                 = new XNALabel(WindowManager);
            lblTime.Name            = "lblTime";
            lblTime.FontIndex       = 1;
            lblTime.Text            = "99:99:99";
            lblTime.ClientRectangle = new Rectangle(Width -
                                                    (int)Renderer.GetTextDimensions(lblTime.Text, lblTime.FontIndex).X - 12, 4,
                                                    lblTime.Width, lblTime.Height);

            btnLogout                 = new XNAClientButton(WindowManager);
            btnLogout.Name            = "btnLogout";
            btnLogout.ClientRectangle = new Rectangle(lblDate.X - 87, 9, 75, 23);
            btnLogout.FontIndex       = 1;
            btnLogout.Text            = "Log Out";
            btnLogout.AllowClick      = false;
            btnLogout.LeftClick      += BtnLogout_LeftClick;

            btnOptions                 = new XNAClientButton(WindowManager);
            btnOptions.Name            = "btnOptions";
            btnOptions.ClientRectangle = new Rectangle(btnLogout.X - 122, 9, 110, 23);
            btnOptions.Text            = "Options (F12)";
            btnOptions.LeftClick      += BtnOptions_LeftClick;

            lblConnectionStatus           = new XNALabel(WindowManager);
            lblConnectionStatus.Name      = "lblConnectionStatus";
            lblConnectionStatus.FontIndex = 1;
            lblConnectionStatus.Text      = "OFFLINE";

            AddChild(btnMainButton);
            AddChild(btnCnCNetLobby);
            AddChild(btnPrivateMessages);
            AddChild(btnOptions);
            AddChild(lblTime);
            AddChild(lblDate);
            AddChild(btnLogout);
            AddChild(lblConnectionStatus);

            if (ClientConfiguration.Instance.DisplayPlayerCountInTopBar)
            {
                lblCnCNetStatus                      = new XNALabel(WindowManager);
                lblCnCNetStatus.Name                 = "lblCnCNetStatus";
                lblCnCNetStatus.FontIndex            = 1;
                lblCnCNetStatus.Text                 = ClientConfiguration.Instance.LocalGame.ToUpper() + " PLAYERS ONLINE:";
                lblCnCNetPlayerCount                 = new XNALabel(WindowManager);
                lblCnCNetPlayerCount.Name            = "lblCnCNetPlayerCount";
                lblCnCNetPlayerCount.FontIndex       = 1;
                lblCnCNetPlayerCount.Text            = "-";
                lblCnCNetPlayerCount.ClientRectangle = new Rectangle(btnOptions.X - 50, 11, lblCnCNetPlayerCount.Width, lblCnCNetPlayerCount.Height);
                lblCnCNetStatus.ClientRectangle      = new Rectangle(lblCnCNetPlayerCount.X - lblCnCNetStatus.Width - 6, 11, lblCnCNetStatus.Width, lblCnCNetStatus.Height);
                AddChild(lblCnCNetStatus);
                AddChild(lblCnCNetPlayerCount);
                CnCNetPlayerCountTask.CnCNetGameCountUpdated += CnCNetInfoController_CnCNetGameCountUpdated;
                cncnetPlayerCountCancellationSource           = new CancellationTokenSource();
                CnCNetPlayerCountTask.InitializeService(cncnetPlayerCountCancellationSource);
            }

            lblConnectionStatus.CenterOnParent();

            base.Initialize();

            Keyboard.OnKeyPressed                    += Keyboard_OnKeyPressed;
            connectionManager.Connected              += ConnectionManager_Connected;
            connectionManager.Disconnected           += ConnectionManager_Disconnected;
            connectionManager.ConnectionLost         += ConnectionManager_ConnectionLost;
            connectionManager.WelcomeMessageReceived += ConnectionManager_WelcomeMessageReceived;
            connectionManager.AttemptedServerChanged += ConnectionManager_AttemptedServerChanged;
            connectionManager.ConnectAttemptFailed   += ConnectionManager_ConnectAttemptFailed;
        }
Exemplo n.º 37
0
 public void Get_all_file_names_for_asset()
 {
     var target = new AssetLoader(_lookupDirectories);
     var files = target.GetFiles(new []{ "test1.b.js" });
     Assert.AreEqual(6, files.Count);
     Assert.AreEqual("test1.b.js", Path.GetFileName(files[0]));
     Assert.AreEqual("test1.1.a.js", Path.GetFileName(files[1]));
     Assert.AreEqual("test1.1.1.a.js", Path.GetFileName(files[2]));
     Assert.AreEqual("test1.1.1.b.js", Path.GetFileName(files[3]));
     Assert.AreEqual("test1.2.a.js", Path.GetFileName(files[4]));
     Assert.AreEqual("test1.2.b.js", Path.GetFileName(files[5]));
 }
Exemplo n.º 38
0
        public override void Initialize()
        {
            base.Initialize();

            Name = "GameOptionsPanel";

            var lblScrollRate = new XNALabel(WindowManager);

            lblScrollRate.Name            = "lblScrollRate";
            lblScrollRate.ClientRectangle = new Rectangle(12,
                                                          14, 0, 0);
            lblScrollRate.Text = "Scroll Rate:";

            lblScrollRateValue                 = new XNALabel(WindowManager);
            lblScrollRateValue.Name            = "lblScrollRateValue";
            lblScrollRateValue.FontIndex       = 1;
            lblScrollRateValue.Text            = "3";
            lblScrollRateValue.ClientRectangle = new Rectangle(
                Width - lblScrollRateValue.Width - 12,
                lblScrollRate.Y, 0, 0);

            trbScrollRate                 = new XNATrackbar(WindowManager);
            trbScrollRate.Name            = "trbClientVolume";
            trbScrollRate.ClientRectangle = new Rectangle(
                lblScrollRate.Right + 32,
                lblScrollRate.Y - 2,
                lblScrollRateValue.X - lblScrollRate.Right - 47,
                22);
            trbScrollRate.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            trbScrollRate.MinValue          = 0;
            trbScrollRate.MaxValue          = MAX_SCROLL_RATE;
            trbScrollRate.ValueChanged     += TrbScrollRate_ValueChanged;

            chkScrollCoasting                 = new XNAClientCheckBox(WindowManager);
            chkScrollCoasting.Name            = "chkScrollCoasting";
            chkScrollCoasting.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                trbScrollRate.Bottom + 20, 0, 0);
            chkScrollCoasting.Text = "Scroll Coasting";

            chkTargetLines                 = new XNAClientCheckBox(WindowManager);
            chkTargetLines.Name            = "chkTargetLines";
            chkTargetLines.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkScrollCoasting.Bottom + 24, 0, 0);
            chkTargetLines.Text = "Target Lines";

            chkTooltips      = new XNAClientCheckBox(WindowManager);
            chkTooltips.Name = "chkTooltips";
            chkTooltips.Text = "Tooltips";

            var lblPlayerName = new XNALabel(WindowManager);

            lblPlayerName.Name = "lblPlayerName";
            lblPlayerName.Text = "Player Name*:";

#if YR
            chkShowHiddenObjects                 = new XNAClientCheckBox(WindowManager);
            chkShowHiddenObjects.Name            = "chkShowHiddenObjects";
            chkShowHiddenObjects.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkTargetLines.Bottom + 24, 0, 0);
            chkShowHiddenObjects.Text = "Show Hidden Objects";

            chkTooltips.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkShowHiddenObjects.Bottom + 24, 0, 0);

            lblPlayerName.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkTooltips.Bottom + 30, 0, 0);

            AddChild(chkShowHiddenObjects);
#else
            chkTooltips.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkTargetLines.Bottom + 24, 0, 0);
#endif

#if DTA || TI || TS
            chkBlackChatBackground                 = new XNAClientCheckBox(WindowManager);
            chkBlackChatBackground.Name            = "chkBlackChatBackground";
            chkBlackChatBackground.ClientRectangle = new Rectangle(
                chkScrollCoasting.X,
                chkTooltips.Bottom + 24, 0, 0);
            chkBlackChatBackground.Text = "Use black background for in-game chat messages";

            AddChild(chkBlackChatBackground);
#endif

#if DTA || TS
            chkAltToUndeploy                 = new XNAClientCheckBox(WindowManager);
            chkAltToUndeploy.Name            = "chkAltToUndeploy";
            chkAltToUndeploy.ClientRectangle = new Rectangle(
                chkScrollCoasting.X,
                chkBlackChatBackground.Bottom + 24, 0, 0);
            chkAltToUndeploy.Text = "Undeploy units by holding Alt key instead of a regular move command";

            AddChild(chkAltToUndeploy);

            lblPlayerName.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkAltToUndeploy.Bottom + 30, 0, 0);
#elif TI
            lblPlayerName.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkBlackChatBackground.Bottom + 30, 0, 0);
#endif



            tbPlayerName      = new XNATextBox(WindowManager);
            tbPlayerName.Name = "tbPlayerName";
            tbPlayerName.MaximumTextLength = ClientConfiguration.Instance.MaxNameLength;
            tbPlayerName.ClientRectangle   = new Rectangle(trbScrollRate.X,
                                                           lblPlayerName.Y - 2, 200, 19);
            tbPlayerName.Text = ProgramConstants.PLAYERNAME;

            var lblNotice = new XNALabel(WindowManager);
            lblNotice.Name            = "lblNotice";
            lblNotice.ClientRectangle = new Rectangle(lblPlayerName.X,
                                                      lblPlayerName.Bottom + 30, 0, 0);
            lblNotice.Text = "* If you are currently connected to CnCNet, you need to log out and reconnect" +
                             Environment.NewLine + "for your new name to be applied.";

            hotkeyConfigWindow = new HotkeyConfigurationWindow(WindowManager);
            DarkeningPanel.AddAndInitializeWithControl(WindowManager, hotkeyConfigWindow);
            hotkeyConfigWindow.Disable();

            var btnConfigureHotkeys = new XNAClientButton(WindowManager);
            btnConfigureHotkeys.Name            = "btnConfigureHotkeys";
            btnConfigureHotkeys.ClientRectangle = new Rectangle(lblPlayerName.X, lblNotice.Bottom + 36, 160, 23);
            btnConfigureHotkeys.Text            = "Configure Hotkeys";
            btnConfigureHotkeys.LeftClick      += BtnConfigureHotkeys_LeftClick;

            AddChild(lblScrollRate);
            AddChild(lblScrollRateValue);
            AddChild(trbScrollRate);
            AddChild(chkScrollCoasting);
            AddChild(chkTargetLines);
            AddChild(chkTooltips);
            AddChild(lblPlayerName);
            AddChild(tbPlayerName);
            AddChild(lblNotice);
            AddChild(btnConfigureHotkeys);
        }
Exemplo n.º 39
0
    private void OnGUI()
    {
        GUIUtil.GUIEnable(bEnable: true);
        GUI.skin = SharedHudSkin;
        if ((mTextureBundles.isDone && mTextureBundles.assetBundle == null) || mTextureBundles.error != null)
        {
            GUI.Box(screenSpace, GUIContent.none, "blackbox");
            GUI.Label(new Rect(0f, screenSpace.height / 2f, screenSpace.width, 150f), "Loading Assets Error.", "MissionHeader");
            Logger.traceError(mTextureBundles.error);
            return;
        }
        GUI.Box(screenSpace, GUIContent.none, "blackbox");
        GUI.Label(new Rect(0f, screenSpace.height / 2f, screenSpace.width, 30f), "Loading Assets: " + mTextureBundles.progress * 100f + "%", GUIUtil.mInstance.mShowcaseSkin.GetStyle("SuitLoadStyle"));
        if (mTextureBundles.isDone && !bTexturesLoaded)
        {
            return;
        }
        GUI.BeginGroup(screenSpace);
        string b = (Event.current.type != EventType.Repaint) ? lastHover : string.Empty;

        if (bLoading)
        {
            MessageBox.Local("Loading...", "Please wait.", null, false, MessageBox.MessageType.MB_NoButtons);
        }
        Vector2 mousePosition = Event.current.mousePosition;
        float   num           = 0f;

        if (StartAnim == -1)
        {
            if (mFactionSelected == -1)
            {
                num = fMiddle;
            }
            else if (mFactionSelected == 0)
            {
                if (bViewFaction)
                {
                    Vector2 mousePosition2 = Event.current.mousePosition;
                    num = Mathf.Clamp((0f - mousePosition2.x) / (float)Screen.width * 3.25f + 4.55f, 1.75f, 4f);
                }
                else
                {
                    num = 1.75f;
                }
            }
            else if (mFactionSelected == 1)
            {
                if (bViewFaction)
                {
                    Vector2 mousePosition3 = Event.current.mousePosition;
                    num = Mathf.Clamp((0f - mousePosition3.x) / (float)Screen.width * 3.55f - 1.25f, -4f, -1.45f);
                }
                else
                {
                    num = -1.45f;
                }
            }
            mCurrentScroll += (num - mCurrentScroll) * Time.deltaTime;
        }
        num = mCurrentScroll;
        float num2 = num * ScrollFactor;
        float num3 = screenSpace.width / 2f + num2;

        GUI.color = Color.white;
        GUI.DrawTexture(new Rect(((0f - screenSpace.height) * 4.5f + screenSpace.width) / 2f + num2, 0f, screenSpace.height * 4.5f, screenSpace.height), mBackground);
        if (StartAnim != -1)
        {
            if (StartAnim == 3)
            {
                GUI.DrawTexture(new Rect(0f, 0f, screenSpace.width, 23f), ChooseYourFaction);
            }
            GUI.color = new Color(1f, 1f, 1f, 1f - BlackFade);
            GUI.Box(screenSpace, GUIContent.none, "blackbox");
            GUI.color = Color.white;
            GUI.EndGroup();
            return;
        }
        GUI.color = OutlineColor;
        for (int i = 0; i < DrawBanzaiOutlines.Length; i++)
        {
            if (DrawBanzaiOutlines[i])
            {
                GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * BanzaiSuitOutlineRects[i].x, fObjectOffsetX * BanzaiSuitOutlineRects[i].y, fObjectOffsetX * (float)BanzaiSuitOutlineTextures[i].width, fObjectOffsetX * (float)BanzaiSuitOutlineTextures[i].height), BanzaiSuitOutlineTextures[i]);
            }
        }
        GUI.color = Color.white;
        for (int j = 0; j < DrawBanzaiOutlines.Length; j++)
        {
            if (!DrawBanzaiOutlines[j])
            {
                continue;
            }
            GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * BanzaiSuitRects[j].x, fObjectOffsetX * BanzaiSuitRects[j].y, fObjectOffsetX * (float)BanzaiSuitTextures[j].width, fObjectOffsetX * (float)BanzaiSuitTextures[j].height), BanzaiSuitTextures[j]);
            if (Event.current.type != EventType.MouseUp || !(fIgnoreClick <= 0f))
            {
                continue;
            }
            if (mFactionSelected == -1)
            {
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Change_Column);
                mFadeLeft        = 1f;
                mFactionSelected = 0;
                mSuitSelected    = -1;
                for (int k = 0; k < mNameTimer.Length; k++)
                {
                    mNameTimer[k] = 1f;
                }
                break;
            }
            if (mFactionSelected == 0 && mSuitSelected == -1)
            {
                mSuitSelected = mBanzaiSuits[j];
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Equip_Press);
            }
        }
        GUI.color = OutlineColor;
        for (int l = 0; l < DrawAtlasOutlines.Length; l++)
        {
            if (DrawAtlasOutlines[l])
            {
                GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * AtlasSuitOutlineRects[l].x, fObjectOffsetX * AtlasSuitOutlineRects[l].y, fObjectOffsetX * (float)AtlasSuitOutlineTextures[l].width, fObjectOffsetX * (float)AtlasSuitOutlineTextures[l].height), AtlasSuitOutlineTextures[l]);
            }
        }
        GUI.color = Color.white;
        for (int m = 0; m < DrawAtlasOutlines.Length; m++)
        {
            if (!DrawAtlasOutlines[m])
            {
                continue;
            }
            GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * AtlasSuitRects[m].x, fObjectOffsetX * AtlasSuitRects[m].y, fObjectOffsetX * (float)AtlasSuitTextures[m].width, fObjectOffsetX * (float)AtlasSuitTextures[m].height), AtlasSuitTextures[m]);
            if (Event.current.type != EventType.MouseUp || !(fIgnoreClick <= 0f))
            {
                continue;
            }
            if (mFactionSelected == -1)
            {
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Change_Column);
                mFadeLeft        = 1f;
                mFactionSelected = 1;
                mSuitSelected    = -1;
                for (int n = 0; n < mNameTimer.Length; n++)
                {
                    mNameTimer[n] = 1f;
                }
                break;
            }
            if (mFactionSelected == 1 && mSuitSelected == -1)
            {
                mSuitSelected = mAtlasSuits[m];
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Equip_Press);
            }
        }
        if (mFactionSelected == -1)
        {
            GUI.DrawTexture(new Rect(0f, 0f, screenSpace.width, 23f), ChooseYourFaction);
            int num4 = -1;
            for (int num5 = 0; num5 < FactionButtons.Length; num5++)
            {
                Rect rect = FactionButtons[num5];
                rect.x       = num3 + fObjectOffsetX * rect.x;
                rect.y      *= fObjectOffsetX;
                rect.height *= fObjectOffsetX;
                rect.width  *= fObjectOffsetX;
                if (rect.Contains(mousePosition))
                {
                    num4 = num5;
                }
            }
            if (num4 != -1 && mFactionHovered != num4)
            {
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Over);
            }
            mFactionHovered = num4;
            for (int num6 = 0; num6 < DrawBanzaiOutlines.Length; num6++)
            {
                DrawBanzaiOutlines[num6] = (mFactionHovered == 0);
            }
            for (int num7 = 0; num7 < DrawAtlasOutlines.Length; num7++)
            {
                DrawAtlasOutlines[num7] = (mFactionHovered == 1);
            }
        }
        else
        {
            if (!bViewFaction)
            {
                GUI.DrawTexture(new Rect(0f, 0f, screenSpace.width, 23f), ChooseYourExosuit);
            }
            Rect[] array  = null;
            bool[] array2 = null;
            if (mFactionSelected == 0)
            {
                if (!bViewFaction)
                {
                    for (int num8 = 0; num8 < BanzaiSuitIcons.Length; num8++)
                    {
                        Rect position = BanzaiSuitIconRect[num8];
                        position.x      *= fObjectOffsetX;
                        position.y      *= fObjectOffsetX;
                        position.width  *= fObjectOffsetX;
                        position.height *= fObjectOffsetX;
                        position.x      += num3 + (float)(int)(position.width * mFadeLeft);
                        position.width   = (int)(position.width * (1f - mFadeLeft));
                        GUI.BeginGroup(position);
                        Rect position2 = new Rect((0f - BanzaiSuitIconRect[num8].width) * fObjectOffsetX * mFadeLeft, 0f, (float)BanzaiSuitIcons[num8].width * fObjectOffsetX, (float)BanzaiSuitIcons[num8].height * fObjectOffsetX);
                        GUI.DrawTexture(position2, BanzaiSuitIcons[num8]);
                        GUI.EndGroup();
                        Rect position3 = new Rect(position.x, position.y, (int)((float)FactionTextBG[0].width * fObjectOffsetX * (1f - mNameTimer[num8])), (float)FactionTextBG[0].height * fObjectOffsetX);
                        position3.x -= position3.width;
                        GUI.BeginGroup(position3);
                        GUI.DrawTexture(new Rect((int)((float)(-FactionTextBG[0].width) * fObjectOffsetX * mNameTimer[num8]), 0f, (float)FactionTextBG[0].width * fObjectOffsetX, (float)FactionTextBG[0].height * fObjectOffsetX), FactionTextBG[0]);
                        GUI.DrawTexture(new Rect((float)(int)((float)(-FactionTextBG[0].width) * fObjectOffsetX * mNameTimer[num8]) + ((float)FactionTextBG[0].width * fObjectOffsetX - (float)BanzaiSuitText[num8].width * fObjectOffsetX) / 2f, 10f, (float)BanzaiSuitText[num8].width * fObjectOffsetX, (float)BanzaiSuitText[num8].height * fObjectOffsetX), BanzaiSuitText[num8]);
                        GUI.EndGroup();
                    }
                    switch (GUIUtil.Button(new Rect(10f, 10f, 80f, 38f), "BACK", "ModalButton"))
                    {
                    case GUIUtil.GUIState.Hover:
                    case GUIUtil.GUIState.Active:
                        if (Event.current.type == EventType.Repaint)
                        {
                            b = "BACK";
                            if (lastHover != b)
                            {
                                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                            }
                        }
                        break;

                    case GUIUtil.GUIState.Click:
                        b = "BACK";
                        GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                        mFactionSelected = -1;
                        mSuitSelected    = -1;
                        mFadeLeft        = 1f;
                        GUI.EndGroup();
                        return;
                    }
                }
                array  = BanzaiButtons;
                array2 = DrawBanzaiOutlines;
                switch (GUIUtil.Button(new Rect(10f, screenSpace.height - 48f, 120f, 38f), (!bViewFaction) ? "VIEW FACTION" : "BACK TO SUITS", "ModalButton"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "BACK TO SUITS";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "BACK TO SUITS";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                    bViewFaction  = !bViewFaction;
                    mSuitSelected = -1;
                    GUI.EndGroup();
                    return;
                }
            }
            else if (mFactionSelected == 1)
            {
                if (!bViewFaction)
                {
                    for (int num9 = 0; num9 < AtlasSuitIcons.Length; num9++)
                    {
                        Rect position4 = AtlasSuitIconRect[num9];
                        position4.x      *= fObjectOffsetX;
                        position4.y      *= fObjectOffsetX;
                        position4.width  *= fObjectOffsetX;
                        position4.height *= fObjectOffsetX;
                        position4.x      += num3;
                        position4.width  *= 1f - mFadeLeft;
                        GUI.BeginGroup(position4);
                        GUI.DrawTexture(new Rect(0f, 0f, (float)AtlasSuitIcons[num9].width * fObjectOffsetX, (float)AtlasSuitIcons[num9].height * fObjectOffsetX), AtlasSuitIcons[num9]);
                        GUI.EndGroup();
                        Rect position5 = new Rect(position4.x + position4.width, position4.y, (float)FactionTextBG[1].width * fObjectOffsetX * (1f - mNameTimer[num9]), (float)FactionTextBG[1].height * fObjectOffsetX);
                        GUI.BeginGroup(position5);
                        GUI.DrawTexture(new Rect(0f, 0f, (float)FactionTextBG[1].width * fObjectOffsetX, (float)FactionTextBG[1].height * fObjectOffsetX), FactionTextBG[1]);
                        GUI.DrawTexture(new Rect(((float)FactionTextBG[1].width * fObjectOffsetX - (float)AtlasSuitText[num9].width * fObjectOffsetX) / 2f, 10f, (float)AtlasSuitText[num9].width * fObjectOffsetX, (float)AtlasSuitText[num9].height * fObjectOffsetX), AtlasSuitText[num9]);
                        GUI.EndGroup();
                    }
                    switch (GUIUtil.Button(new Rect(screenSpace.width - 90f, 10f, 80f, 38f), "BACK", "ModalButton"))
                    {
                    case GUIUtil.GUIState.Hover:
                    case GUIUtil.GUIState.Active:
                        if (Event.current.type == EventType.Repaint)
                        {
                            b = "BACK";
                            if (lastHover != b)
                            {
                                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                            }
                        }
                        break;

                    case GUIUtil.GUIState.Click:
                        b = "BACK";
                        GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                        mFactionSelected = -1;
                        mSuitSelected    = -1;
                        mFadeLeft        = 1f;
                        GUI.EndGroup();
                        return;
                    }
                }
                array  = AtlasButtons;
                array2 = DrawAtlasOutlines;
                switch (GUIUtil.Button(new Rect(screenSpace.width - 130f, screenSpace.height - 48f, 120f, 38f), (!bViewFaction) ? "VIEW FACTION" : "BACK TO SUITS", "ModalButton"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "BACK TO SUITS";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "BACK TO SUITS";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                    bViewFaction  = !bViewFaction;
                    mSuitSelected = -1;
                    GUI.EndGroup();
                    return;
                }
            }
            if (mSuitSelected == -1 && !bViewFaction)
            {
                for (int num10 = 0; num10 < array.Length; num10++)
                {
                    Rect rect2 = array[num10];
                    rect2.x      *= fObjectOffsetX;
                    rect2.y      *= fObjectOffsetX;
                    rect2.width  *= fObjectOffsetX;
                    rect2.height *= fObjectOffsetX;
                    rect2.x      += num2;
                    if (rect2.Contains(mousePosition))
                    {
                        if (!array2[num10])
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Over);
                        }
                        array2[num10] = true;
                    }
                    else
                    {
                        array2[num10] = false;
                    }
                }
            }
            SuitInspector.TempSuitInfo tempSuitInfo = new SuitInspector.TempSuitInfo();
            GUIUtil.GUIEnable(bEnable: true);
            if (mSuitSelected != -1)
            {
                tempSuitInfo.mSuitName = GameData.getExosuit(mSuitSelected).mSuitName;
                Exosuit exosuit = GameData.getExosuit(mSuitSelected);
                tempSuitInfo.mSuitShow    = exosuit.mShowName;
                tempSuitInfo.mSuitName    = exosuit.mSuitName;
                tempSuitInfo.mIndex       = mSuitSelected;
                tempSuitInfo.mDescription = exosuit.mDescription;
                tempSuitInfo.mShieldPower = exosuit.mBaseHealth;
                tempSuitInfo.mShieldRegen = exosuit.mBaseRegenHealth;
                tempSuitInfo.mJetpack     = exosuit.mBaseJetFuel;
                tempSuitInfo.mSpeed       = exosuit.mBaseSpeed;
                tempSuitInfo.mTech        = exosuit.mBaseTech;
                Rect position6 = new Rect(150f, 60f, screenSpace.width - 300f, screenSpace.height - 120f);
                GUI.BeginGroup(position6);
                mSuitInspector.DrawSuitInfo(tempSuitInfo, bDraw3D: true);
                float num11 = 230f + (position6.width - 230f) / 2f;
                if (GameData.getExosuit(mSuitSelected).getHighPolyModel() == null)
                {
                    GUI.Label(new Rect(num11 - 200f, position6.height / 2f - 90f, 400f, 40f), "Loading Suit: " + (int)(AssetLoader.GetSuitLoadProgress(tempSuitInfo.mIndex, AssetLoader.SuitAsset.SuitType.high) * 100f) + "%", GUIUtil.mInstance.mShowcaseSkin.GetStyle("SuitLoadStyle"));
                    GUIUtil.DrawLoadingAnim(new Rect(num11 - 64f, (Screen.height - 128) / 2, 128f, 128f), 1);
                }
                GUI.color = Color.white;
                switch (GUIUtil.Button(new Rect(num11 - 70f, position6.height - 45f, 140f, 34f), "CHOOSE EXOSUIT", "ModalButton"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "CHOOSE EXOSUIT";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "CHOOSE EXOSUIT";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                    MessageBox.ResetWindowPosition();
                    MessageBox.AddMessageCustom("Join " + GameData.getFactionDisplayName(mFactionSelected + 1) + "?", "Once you pledge your allegiance to a faction, you can not switch sides. Are you sure you want to select the " + tempSuitInfo.mSuitName + " and join " + GameData.getFactionDisplayName(mFactionSelected + 1) + "?", null, true, OnJoinConfirm, "Yes, Join", "No, Cancel");
                    break;
                }
                switch (GUIUtil.Button(new Rect(position6.width - 64f, 0f, 64f, 42f), GUIContent.none, "Close"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "Close";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "Close";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Button_Inactive);
                    mSuitSelected = -1;
                    break;
                }
                GUI.EndGroup();
            }
        }
        GUI.EndGroup();
        if (Event.current.type == EventType.MouseUp)
        {
            fIgnoreClick = 0.05f;
        }
        lastHover = b;
    }
Exemplo n.º 40
0
 void Awake()
 {
     isReady     = false;
     ms_Instance = this;
 }
Exemplo n.º 41
0
 void OnDestroy()
 {
     ms_Instance = null;
     isReady     = false;
 }
        public override void Initialize()
        {
            Name = "PrivateMessageNotificationBox";
            BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 196), 1, 1);
            ClientRectangle   = new Rectangle(WindowManager.RenderResolutionX - 300, -100, 300, 100);
            DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;

            XNALabel lblHeader = new XNALabel(WindowManager);

            lblHeader.Name      = "lblHeader";
            lblHeader.FontIndex = 1;
            lblHeader.Text      = "PRIVATE MESSAGE";
            AddChild(lblHeader);
            lblHeader.CenterOnParent();
            lblHeader.ClientRectangle = new Rectangle(lblHeader.X,
                                                      6, lblHeader.Width, lblHeader.Height);

            XNAPanel linePanel = new XNAPanel(WindowManager);

            linePanel.Name            = "linePanel";
            linePanel.ClientRectangle = new Rectangle(0, Height - 20, Width, 1);

            XNALabel lblHint = new XNALabel(WindowManager);

            lblHint.Name       = "lblHint";
            lblHint.RemapColor = UISettings.SubtleTextColor;
            lblHint.Text       = "Press F4 to respond";

            AddChild(lblHint);
            lblHint.CenterOnParent();
            lblHint.ClientRectangle = new Rectangle(lblHint.X,
                                                    linePanel.Y + 3,
                                                    lblHint.Width, lblHint.Height);

            gameIconPanel                   = new XNAPanel(WindowManager);
            gameIconPanel.Name              = "gameIconPanel";
            gameIconPanel.ClientRectangle   = new Rectangle(12, 30, 16, 16);
            gameIconPanel.DrawBorders       = false;
            gameIconPanel.BackgroundTexture = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.dtaicon);

            lblSender                 = new XNALabel(WindowManager);
            lblSender.Name            = "lblSender";
            lblSender.FontIndex       = 1;
            lblSender.ClientRectangle = new Rectangle(gameIconPanel.Right + 3,
                                                      gameIconPanel.Y, 0, 0);
            lblSender.Text = "Rampastring:";

            lblMessage                 = new XNALabel(WindowManager);
            lblMessage.Name            = "lblMessage";
            lblMessage.ClientRectangle = new Rectangle(12, lblSender.Bottom + 6, 0, 0);
            lblMessage.RemapColor      = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor);
            lblMessage.Text            = "This is a test message.";

            AddChild(lblHeader);
            AddChild(gameIconPanel);
            AddChild(linePanel);
            AddChild(lblSender);
            AddChild(lblMessage);

            base.Initialize();
        }
Exemplo n.º 43
0
    public void LoadTextures()
    {
        AssetBundle assetBundle = mTextureBundles.assetBundle;

        mBanzaiSuits   = (int[])GameData.BanzaiDefaultSuits.Clone();
        mAtlasSuits    = (int[])GameData.AtlasDefaultSuits.Clone();
        mAtlasSuits[0] = GameData.AtlasDefaultSuits[2];
        mAtlasSuits[2] = GameData.AtlasDefaultSuits[0];
        int[] atlasDefaultSuits = GameData.AtlasDefaultSuits;
        foreach (int suitId in atlasDefaultSuits)
        {
            AssetLoader.AddSuitToLoad(suitId, AssetLoader.SuitAsset.SuitType.high, 100);
        }
        int[] banzaiDefaultSuits = GameData.BanzaiDefaultSuits;
        foreach (int suitId2 in banzaiDefaultSuits)
        {
            AssetLoader.AddSuitToLoad(suitId2, AssetLoader.SuitAsset.SuitType.high, 100);
        }
        BanzaiSuitTextures        = new Texture2D[mBanzaiSuits.Length];
        BanzaiSuitOutlineTextures = new Texture2D[mBanzaiSuits.Length];
        BanzaiSuitText            = new Texture2D[mBanzaiSuits.Length];
        BanzaiSuitIcons           = new Texture2D[mBanzaiSuits.Length];
        for (int k = 0; k < mBanzaiSuits.Length; k++)
        {
            string text = GameData.getExosuit(mBanzaiSuits[k]).mSuitFileName.ToLower();
            BanzaiSuitTextures[k]        = (assetBundle.Load(text) as Texture2D);
            BanzaiSuitOutlineTextures[k] = (assetBundle.Load(text + "_over") as Texture2D);
            BanzaiSuitText[k]            = (assetBundle.Load(text + "_text") as Texture2D);
            BanzaiSuitIcons[k]           = (assetBundle.Load(text + "_icon") as Texture2D);
        }
        AtlasSuitTextures        = new Texture2D[mAtlasSuits.Length];
        AtlasSuitOutlineTextures = new Texture2D[mAtlasSuits.Length];
        AtlasSuitText            = new Texture2D[mAtlasSuits.Length];
        AtlasSuitIcons           = new Texture2D[mAtlasSuits.Length];
        for (int l = 0; l < mAtlasSuits.Length; l++)
        {
            string text2 = GameData.getExosuit(mAtlasSuits[l]).mSuitFileName.ToLower();
            AtlasSuitTextures[l]        = (assetBundle.Load(text2) as Texture2D);
            AtlasSuitOutlineTextures[l] = (assetBundle.Load(text2 + "_over") as Texture2D);
            AtlasSuitText[l]            = (assetBundle.Load(text2 + "_text") as Texture2D);
            AtlasSuitIcons[l]           = (assetBundle.Load(text2 + "_icon") as Texture2D);
        }
        mBackground       = (assetBundle.Load("Background") as Texture2D);
        FactionTextBG     = new Texture2D[2];
        FactionTextBG[0]  = (assetBundle.Load("BanzaiSlidingBar") as Texture2D);
        FactionTextBG[1]  = (assetBundle.Load("AtlasSlidingBar") as Texture2D);
        ChooseYourExosuit = (assetBundle.Load("ChooseYourExosuit") as Texture2D);
        ChooseYourFaction = (assetBundle.Load("ChooseYourFaction") as Texture2D);
        for (int m = 0; m < AtlasSuitIconRect.Length; m++)
        {
            AtlasSuitIconRect[m].height = AtlasSuitIcons[m].height;
            AtlasSuitIconRect[m].width  = AtlasSuitIcons[m].width;
        }
        for (int n = 0; n < BanzaiSuitIconRect.Length; n++)
        {
            BanzaiSuitIconRect[n].height = BanzaiSuitIcons[n].height;
            BanzaiSuitIconRect[n].width  = BanzaiSuitIcons[n].width;
        }
        for (int num = 0; num < BanzaiSuitOutlineRects.Length; num++)
        {
            BanzaiSuitOutlineRects[num] = new Rect(BanzaiSuitRects[num].x - 3f, BanzaiSuitRects[num].y - 3f, BanzaiSuitOutlineTextures[num].width, BanzaiSuitOutlineTextures[num].height);
            AtlasSuitOutlineRects[num]  = new Rect(AtlasSuitRects[num].x - 3f, AtlasSuitRects[num].y - 3f, AtlasSuitOutlineTextures[num].width, AtlasSuitOutlineTextures[num].height);
        }
        bTexturesLoaded = true;
    }
Exemplo n.º 44
0
 /// <summary>Read the chunk header.</summary>
 /// <param name="loader"></param>
 public Chunk(AssetLoader loader)
 {
     var reader = loader.Reader;
     Loader = loader;
     Offset = reader.BaseStream.Position;
     Id = (ChunkId)reader.ReadUInt16();
     Length = reader.ReadInt32();
 }
Exemplo n.º 45
0
 public void Get_all_files_for_asset_containing_require_self()
 {
     var target = new AssetLoader(_lookupDirectories);
     var files = target.GetFiles("test1.a.js");
     Assert.AreEqual(2, files.Count);
     Assert.AreEqual("test1.1.1.a.js", Path.GetFileName(files[0]));
     Assert.AreEqual("test1.a.js", Path.GetFileName(files[1]));
 }
Exemplo n.º 46
0
 /// <summary>Load the 3DS model.</summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 public override Asset Load(AssetLoader loader)
 {
     return new Autodesk3ds(loader, this);
 }
Exemplo n.º 47
0
        /// <summary>Load the DDS file.</summary>
        /// <param name="loader"></param>
        /// <returns></returns>
        public override Asset Load(AssetLoader loader)
        {
            using (BinaryReader reader = loader.Reader) {
                reader.RequireMagic(Magic);

                int headerSize = reader.ReadInt32();
                if (headerSize != HeaderSize)
                    throw new InvalidDataException();
                Flags flags = (Flags)reader.ReadInt32();
                if ((flags & RequiredFlags) != RequiredFlags)
                    throw new InvalidDataException();
                int height = reader.ReadInt32();
                int width = reader.ReadInt32();
                int pitchOrLinearSize = reader.ReadInt32();
                int depth = reader.ReadInt32();
                int mipMapCount = reader.ReadInt32();
                reader.BaseStream.Seek(4 * 11, SeekOrigin.Current); // Reserved
                var pixelFormat = new PixelFormat(reader);
                Caps caps = (Caps)reader.ReadInt32(); // Surface complexity
                if ((caps & Caps.Texture) == 0)
                    throw new InvalidDataException();
                Caps2 caps2 = (Caps2)reader.ReadInt32(); // Surface type
                int caps3 = reader.ReadInt32();
                int caps4 = reader.ReadInt32();
                int reserved2 = reader.ReadInt32();

                Format format = null;

                if (pixelFormat.HasFourCC) {
                    if (pixelFormat.FourCC == "DX10")
                        throw new NotSupportedException();
                    format = FormatFourCCs[pixelFormat.FourCC];
                } else if (pixelFormat.HasRGB) {
                    int b0 = 255, b1 = 255 << 8, b2 = 255 << 16, b3 = 255 << 24;

                    if (pixelFormat.HasAlphaPixels && pixelFormat.RGBBitCount == 32) {
                        if (pixelFormat.MatchMasks(b2, b1, b0, b3))
                            format = Glare.Graphics.Formats.Vector4nbBGRA;
                        else if (pixelFormat.MatchMasks(b0, b1, b2, b3))
                            format = Glare.Graphics.Formats.Vector4nb;
                    }
                }

                if (format == null)
                    throw new NotSupportedException();

                if (caps2 != Caps2.None)
                    throw new NotSupportedException("Cube maps or volume textures not supported.");

                int linearSize;

                if ((flags & Flags.Pitch) != 0)
                    linearSize = pitchOrLinearSize * height;
                else if ((flags & Flags.LinearSize) != 0)
                    linearSize = pitchOrLinearSize;
                else
                    linearSize = format.AlignedByteSize(new Vector2i(width, height));

                byte[] data = new byte[linearSize];

                if ((flags & Flags.MipMapCount) == 0)
                    mipMapCount = 1;

                Texture2D texture = new Texture2D();//format, new Vector2i(width, height));
                for (int level = 0; level < mipMapCount; level++) {
                    if (reader.Read(data, 0, linearSize) != linearSize)
                        throw new InvalidDataException();
                    texture.Surface.Levels[level].DataCompressed(format, new Vector2i(width, height), data);

                    width = Math.Max(1, (width + 1) / 2);
                    height = Math.Max(1, (height + 1) / 2);
                    linearSize = format.AlignedByteSize(width, height);
                }

                texture.Name = loader.Name;
                return new TextureAsset(loader, texture);
            }
        }
Exemplo n.º 48
0
        public override void Initialize()
        {
            lbTunnelList      = new TunnelListBox(WindowManager, tunnelHandler);
            lbTunnelList.Name = nameof(lbTunnelList);

            Name  = "GameCreationWindow";
            Width = lbTunnelList.Width + UIDesignConstants.EMPTY_SPACE_SIDES * 2 +
                    UIDesignConstants.CONTROL_HORIZONTAL_MARGIN * 2;
            BackgroundTexture = AssetLoader.LoadTexture("gamecreationoptionsbg.png");

            tbGameName      = new XNATextBox(WindowManager);
            tbGameName.Name = nameof(tbGameName);
            tbGameName.MaximumTextLength = 23;
            tbGameName.ClientRectangle   = new Rectangle(Width - 150 - UIDesignConstants.EMPTY_SPACE_SIDES -
                                                         UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, UIDesignConstants.EMPTY_SPACE_TOP +
                                                         UIDesignConstants.CONTROL_VERTICAL_MARGIN, 150, 21);
            tbGameName.Text = ProgramConstants.PLAYERNAME + "'s Game";

            lblRoomName                 = new XNALabel(WindowManager);
            lblRoomName.Name            = nameof(lblRoomName);
            lblRoomName.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                        UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, tbGameName.Y + 1, 0, 0);
            lblRoomName.Text = "Game room name:";

            ddMaxPlayers                 = new XNAClientDropDown(WindowManager);
            ddMaxPlayers.Name            = nameof(ddMaxPlayers);
            ddMaxPlayers.ClientRectangle = new Rectangle(tbGameName.X, tbGameName.Bottom + 20,
                                                         tbGameName.Width, 21);
            for (int i = 8; i > 1; i--)
            {
                ddMaxPlayers.AddItem(i.ToString());
            }
            ddMaxPlayers.SelectedIndex = 0;

            lblMaxPlayers                 = new XNALabel(WindowManager);
            lblMaxPlayers.Name            = nameof(lblMaxPlayers);
            lblMaxPlayers.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                          UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, ddMaxPlayers.Y + 1, 0, 0);
            lblMaxPlayers.Text = "Maximum number of players:";

            tbPassword      = new XNATextBox(WindowManager);
            tbPassword.Name = nameof(tbPassword);
            tbPassword.MaximumTextLength = 20;
            tbPassword.ClientRectangle   = new Rectangle(tbGameName.X, ddMaxPlayers.Bottom + 20,
                                                         tbGameName.Width, 21);

            lblPassword                 = new XNALabel(WindowManager);
            lblPassword.Name            = nameof(lblPassword);
            lblPassword.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                        UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, tbPassword.Y + 1, 0, 0);
            lblPassword.Text = "Password (leave blank for none):";

            btnDisplayAdvancedOptions                 = new XNAClientButton(WindowManager);
            btnDisplayAdvancedOptions.Name            = nameof(btnDisplayAdvancedOptions);
            btnDisplayAdvancedOptions.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                                      UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, lblPassword.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 3, UIDesignConstants.BUTTON_WIDTH_160, UIDesignConstants.BUTTON_HEIGHT);
            btnDisplayAdvancedOptions.Text       = "Advanced Options";
            btnDisplayAdvancedOptions.LeftClick += BtnDisplayAdvancedOptions_LeftClick;

            lblTunnelServer                 = new XNALabel(WindowManager);
            lblTunnelServer.Name            = nameof(lblTunnelServer);
            lblTunnelServer.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                            UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, lblPassword.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 4, 0, 0);
            lblTunnelServer.Text    = "Tunnel server:";
            lblTunnelServer.Enabled = false;
            lblTunnelServer.Visible = false;

            lbTunnelList.X = UIDesignConstants.EMPTY_SPACE_SIDES +
                             UIDesignConstants.CONTROL_HORIZONTAL_MARGIN;
            lbTunnelList.Y = lblTunnelServer.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN;
            lbTunnelList.Disable();
            lbTunnelList.ListRefreshed += LbTunnelList_ListRefreshed;

            btnCreateGame                 = new XNAClientButton(WindowManager);
            btnCreateGame.Name            = nameof(btnCreateGame);
            btnCreateGame.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                          UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, btnDisplayAdvancedOptions.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 3,
                                                          UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnCreateGame.Text       = "Create Game";
            btnCreateGame.LeftClick += BtnCreateGame_LeftClick;

            btnCancel                 = new XNAClientButton(WindowManager);
            btnCancel.Name            = nameof(btnCancel);
            btnCancel.ClientRectangle = new Rectangle(Width - UIDesignConstants.BUTTON_WIDTH_133 - UIDesignConstants.EMPTY_SPACE_SIDES -
                                                      UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, btnCreateGame.Y, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            int btnLoadMPGameX = btnCreateGame.Right + (btnCancel.X - btnCreateGame.Right) / 2 - UIDesignConstants.BUTTON_WIDTH_133 / 2;

            btnLoadMPGame                 = new XNAClientButton(WindowManager);
            btnLoadMPGame.Name            = nameof(btnLoadMPGame);
            btnLoadMPGame.ClientRectangle = new Rectangle(btnLoadMPGameX, btnCreateGame.Y, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnLoadMPGame.Text            = "Load Game";
            btnLoadMPGame.LeftClick      += BtnLoadMPGame_LeftClick;

            AddChild(tbGameName);
            AddChild(lblRoomName);
            AddChild(ddMaxPlayers);
            AddChild(lblMaxPlayers);
            AddChild(tbPassword);
            AddChild(lblPassword);
            AddChild(btnDisplayAdvancedOptions);
            AddChild(lblTunnelServer);
            AddChild(lbTunnelList);
            AddChild(btnCreateGame);
            if (!ClientConfiguration.Instance.DisableMultiplayerGameLoading)
            {
                AddChild(btnLoadMPGame);
            }
            AddChild(btnCancel);

            base.Initialize();

            Height = btnCreateGame.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN + UIDesignConstants.EMPTY_SPACE_BOTTOM;

            CenterOnParent();

            UserINISettings.Instance.SettingsSaved += Instance_SettingsSaved;

            if (UserINISettings.Instance.AlwaysDisplayTunnelList)
            {
                BtnDisplayAdvancedOptions_LeftClick(this, EventArgs.Empty);
            }
        }
Exemplo n.º 49
0
        private async Task InitializeAsync(string treestring, string opsstring, [CanBeNull] ProgressDialogController controller,
            AssetLoader assetLoader)
        {
            if (!_initialized)
            {
                var jss = new JsonSerializerSettings
                {
                    Error = (sender, args) =>
                    {
                        // This one is known: "515":{"x":_,"y":_,"oo":[],"n":[]}} has an Array in "oo".
                        if (args.ErrorContext.Path != "groups.515.oo")
                            Log.Error("Exception while deserializing Json tree", args.ErrorContext.Error);
                        args.ErrorContext.Handled = true;
                    }
                };

                var inTree = JsonConvert.DeserializeObject<PoESkillTree>(treestring, jss);
                var inOpts = JsonConvert.DeserializeObject<Opts>(opsstring, jss);

                controller?.SetProgress(0.25);
                await assetLoader.DownloadSkillNodeSpritesAsync(inTree, d => controller?.SetProgress(0.25 + d * 0.30));
                IconInActiveSkills = new SkillIcons();
                IconActiveSkills = new SkillIcons();
                foreach (var obj in inTree.skillSprites)
                {
                    SkillIcons icons;
                    string prefix;
                    if (obj.Key.EndsWith("Active"))
                    {
                        // Adds active nodes to IconActiveSkills
                        icons = IconActiveSkills;
                        prefix = obj.Key.Substring(0, obj.Key.Length - "Active".Length);
                    }
                    else if (obj.Key.EndsWith("Inactive"))
                    {
                        // Adds inactive nodes to IconInActiveSkills
                        icons = IconInActiveSkills;
                        prefix = obj.Key.Substring(0, obj.Key.Length - "Inactive".Length);
                    }
                    else
                    {
                        // Adds masteries to IconInActiveSkills
                        icons = IconInActiveSkills;
                        prefix = obj.Key;
                    }
                    var sprite = obj.Value[AssetZoomLevel];
                    var path = _assetsFolderPath + sprite.filename;
                    icons.Images[sprite.filename] = ImageHelper.OnLoadBitmapImage(new Uri(path, UriKind.Absolute));
                    foreach (var o in sprite.coords)
                    {
                        var iconKey = prefix + "_" + o.Key;
                        icons.SkillPositions[iconKey] = new Rect(o.Value.x, o.Value.y, o.Value.w, o.Value.h);
                        icons.SkillImages[iconKey] = sprite.filename;
                    }
                }

                controller?.SetProgress(0.55);
                // The last percent progress is reserved for rounding errors as progress must not get > 1.
                await assetLoader.DownloadAssetsAsync(inTree, d => controller?.SetProgress(0.55 + d * 0.44));
                foreach (var ass in inTree.assets)
                {
                    var path = _assetsFolderPath + ass.Key + ".png";
                    Assets[ass.Key] = ImageHelper.OnLoadBitmapImage(new Uri(path, UriKind.Absolute));
                }

                RootNodeList = new List<int>();
                if (inTree.root != null)
                {
                    foreach (int i in inTree.root.ot)
                    {
                        RootNodeList.Add(i);
                    }
                }
                else if (inTree.main != null)
                {
                    foreach (int i in inTree.main.ot)
                    {
                        RootNodeList.Add(i);
                    }
                }

                _ascClasses = new AscendancyClasses();
                if (inOpts != null)
                {
                    foreach (KeyValuePair<int, baseToAscClass> ascClass in inOpts.ascClasses)
                    {
                        var classes = new List<AscendancyClasses.Class>();
                        foreach (KeyValuePair<int, classes> asc in ascClass.Value.classes)
                        {
                            var newClass = new AscendancyClasses.Class
                            {
                                Order = asc.Key,
                                DisplayName = asc.Value.displayName,
                                Name = asc.Value.name,
                                FlavourText = asc.Value.flavourText,
                                FlavourTextColour = asc.Value.flavourTextColour.Split(',').Select(int.Parse).ToArray()
                            };
                            int[] tempPointList = asc.Value.flavourTextRect.Split(',').Select(int.Parse).ToArray();
                            newClass.FlavourTextRect = new Vector2D(tempPointList[0], tempPointList[1]);
                            classes.Add(newClass);

                        }
                        AscClasses.Classes.Add(ascClass.Value.name, classes);
                    }
                }

                CharBaseAttributes = new Dictionary<string, float>[7];
                foreach (var c in inTree.characterData)
                {
                    CharBaseAttributes[c.Key] = new Dictionary<string, float>
                    {
                        {"+# to Strength", c.Value.base_str},
                        {"+# to Dexterity", c.Value.base_dex},
                        {"+# to Intelligence", c.Value.base_int}
                    };
                }

                Skillnodes = new Dictionary<ushort, SkillNode>();
                RootNodeClassDictionary = new Dictionary<string, int>();
                StartNodeDictionary = new Dictionary<int, int>();
                AscRootNodeList = new HashSet<SkillNode>();

                foreach (var nd in inTree.nodes)
                {
                    var skillNode = new SkillNode
                    {
                        Id = nd.id,
                        Name = nd.dn,
                        //this value should not be split on '\n' as it causes the attribute list to seperate nodes
                        attributes = nd.dn.Contains("Jewel Socket") ? new[] { "+1 Jewel Socket" } : nd.sd,
                        Orbit = nd.o,
                        OrbitIndex = nd.oidx,
                        Icon = nd.icon,
                        LinkId = nd.ot,
                        G = nd.g,
                        Da = nd.da,
                        Ia = nd.ia,
                        Sa = nd.sa,
                        Spc = nd.spc.Length > 0 ? (int?)nd.spc[0] : null,
                        IsMultipleChoice = nd.isMultipleChoice,
                        IsMultipleChoiceOption = nd.isMultipleChoiceOption,
                        passivePointsGranted = nd.passivePointsGranted,
                        ascendancyName = nd.ascendancyName,
                        IsAscendancyStart = nd.isAscendancyStart,
                        reminderText = nd.reminderText
                    };
                    if (nd.ks && !nd.not && !nd.isJewelSocket && !nd.m)
                    {
                        skillNode.Type = NodeType.Keystone;
                    }
                    else if (!nd.ks && nd.not && !nd.isJewelSocket && !nd.m)
                    {
                        skillNode.Type = NodeType.Notable;
                    }
                    else if (!nd.ks && !nd.not && nd.isJewelSocket && !nd.m)
                    {
                        skillNode.Type = NodeType.JewelSocket;
                    }
                    else if (!nd.ks && !nd.not && !nd.isJewelSocket && nd.m)
                    {
                        skillNode.Type = NodeType.Mastery;
                    }
                    else if (!nd.ks && !nd.not && !nd.isJewelSocket && !nd.m)
                    {
                        skillNode.Type = NodeType.Normal;
                    }
                    else
                    {
                        throw new InvalidOperationException($"Invalid node type for node {skillNode.Name}");
                    }
                    Skillnodes.Add(nd.id, skillNode);
                    if(skillNode.IsAscendancyStart)
                        if(!AscRootNodeList.Contains(skillNode))
                            AscRootNodeList.Add(skillNode);
                    if (RootNodeList.Contains(nd.id))
                    {
                        if (!RootNodeClassDictionary.ContainsKey(nd.dn.ToUpperInvariant()))
                        {
                            RootNodeClassDictionary.Add(nd.dn.ToUpperInvariant(), nd.id);
                        }
                        foreach (var linkedNode in nd.ot)
                        {
                            if (!StartNodeDictionary.ContainsKey(nd.id) && !nd.isAscendancyStart)
                            {
                                StartNodeDictionary.Add(linkedNode, nd.id);
                            }
                        }
                    }
                    foreach (var node in nd.ot)
                    {
                        if (!StartNodeDictionary.ContainsKey(nd.id) && RootNodeList.Contains(node))
                        {
                            StartNodeDictionary.Add(nd.id, node);
                        }
                    }

                }

                foreach (var skillNode in Skillnodes)
                {
                    foreach (var i in skillNode.Value.LinkId)
                    {
                        if (Links.Count(nd => (nd[0] == i && nd[1] == skillNode.Key) || nd[0] == skillNode.Key && nd[1] == i) != 1)
                            Links.Add(new[] { skillNode.Key, i });
                    }
                }
                foreach (var ints in Links)
                {
                    Regex regexString = new Regex(@"Can Allocate Passives from the .* starting point");
                    bool isScionAscendancyNotable = false;
                    foreach (var attibute in Skillnodes[ints[0]].attributes)
                    {
                        if (regexString.IsMatch(attibute))
                            isScionAscendancyNotable = true;
                    }
                    foreach (var attibute in Skillnodes[ints[1]].attributes)
                    {
                        if (regexString.IsMatch(attibute))
                            isScionAscendancyNotable = true;
                    }

                    if (isScionAscendancyNotable && StartNodeDictionary.Keys.Contains(ints[0]))
                    {
                        if (!Skillnodes[ints[1]].Neighbor.Contains(Skillnodes[ints[0]]))
                            Skillnodes[ints[1]].Neighbor.Add(Skillnodes[ints[0]]);
                    }
                    else if (isScionAscendancyNotable && StartNodeDictionary.Keys.Contains(ints[1]))
                    {
                        if (!Skillnodes[ints[0]].Neighbor.Contains(Skillnodes[ints[1]]))
                            Skillnodes[ints[0]].Neighbor.Add(Skillnodes[ints[1]]);
                    }
                    else
                    {
                        if (!Skillnodes[ints[0]].Neighbor.Contains(Skillnodes[ints[1]]))
                            Skillnodes[ints[0]].Neighbor.Add(Skillnodes[ints[1]]);
                        if (!Skillnodes[ints[1]].Neighbor.Contains(Skillnodes[ints[0]]))
                            Skillnodes[ints[1]].Neighbor.Add(Skillnodes[ints[0]]);
                    }
                }

                var regexAttrib = new Regex("[0-9]*\\.?[0-9]+");
                foreach (var skillnode in Skillnodes)
                {
                    //add each other as visible neighbors
                    foreach (var snn in skillnode.Value.Neighbor)
                    {
                        if (snn.IsAscendancyStart && skillnode.Value.LinkId.Contains(snn.Id))
                            continue;
                        skillnode.Value.VisibleNeighbors.Add(snn);
                    }

                    //populate the Attributes fields with parsed attributes 
                    skillnode.Value.Attributes = new Dictionary<string, List<float>>();
                    foreach (string s in skillnode.Value.attributes)
                    {
                        var values = new List<float>();

                        foreach (Match m in regexAttrib.Matches(s))
                        {
                            if (!AttributeTypes.Contains(regexAttrib.Replace(s, "#")))
                                AttributeTypes.Add(regexAttrib.Replace(s, "#"));
                            if (m.Value == "")
                                values.Add(float.NaN);
                            else
                                values.Add(float.Parse(m.Value, CultureInfo.InvariantCulture));
                        }
                        string cs = (regexAttrib.Replace(s, "#"));

                        skillnode.Value.Attributes[cs] = values;
                    }
                }

                NodeGroups = new List<SkillNodeGroup>();
                foreach (var gp in inTree.groups)
                {
                    var ng = new SkillNodeGroup();

                    ng.OcpOrb = gp.Value.oo;
                    ng.Position = new Vector2D(gp.Value.x, gp.Value.y);
                    foreach (var node in gp.Value.n)
                    {
                        ng.Nodes.Add(Skillnodes[node]);
                    }
                    NodeGroups.Add(ng);
                }
                foreach (SkillNodeGroup group in NodeGroups)
                {
                    foreach (SkillNode node in group.Nodes)
                    {
                        node.SkillNodeGroup = group;
                    }
                }

                const int padding = 500; //This is to account for jewel range circles. Might need to find a better way to do it.
                SkillTreeRect = new Rect2D(new Vector2D(inTree.min_x * 1.1 - padding, inTree.min_y * 1.1 - padding),
                    new Vector2D(inTree.max_x * 1.1 + padding, inTree.max_y * 1.1 + padding));
            }

            if (_persistentData.Options.ShowAllAscendancyClasses)
                DrawAscendancy = true;

            InitialSkillTreeDrawing();
            controller?.SetProgress(1);

            _initialized = true;
        }
Exemplo n.º 50
0
 /// <summary>Matches if the magic number matches ("PK\x03\x04").</summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 public override LoadMatchStrength LoadMatch(AssetLoader loader)
 {
     return loader.Length > 4 && loader.Reader.ReadInt32() == ZipArchive.Magic ? LoadMatchStrength.Medium : LoadMatchStrength.None;
 }
Exemplo n.º 51
0
 public void loadMap(uint mapid)
 {
     AssetLoader.GetInstance().Load(URLUtil.GetResourceLibPath() + "Scene/" + mapid + "/min.img", LoadImgComplete, AssetType.BUNDLER);
     infor = MinMapDataManager.instance.GetMinMap(mapid);
 }
Exemplo n.º 52
0
        void Update()
        {
            if (!isReady)
            {
                return;
            }
            if (!FlightGlobals.ready)
            {
                return;
            }
            if (craftSettings == null)
            {
                GetCraftSettings();
            }

            if (!craftSettings.runAutoScience)
            {
                return;
            }
            if (FlightGlobals.ActiveVessel.packed)
            {
                return;
            }
            if (!FlightGlobals.ActiveVessel.IsControllable)
            {
                return;
            }
            if (!CheckEVA())
            {
                return;
            }
            #region icon
            if (lastFrameCheck + frameCheck < Time.time)
            {
                var frame = Time.deltaTime / frameCheck;
                if (CurrentFrame + frame < 55)
                {
                    CurrentFrame += frame;
                }
                else
                {
                    CurrentFrame = 0;
                }
                icon           = AssetLoader.GetAsset <Sprite>("icon" + (int)CurrentFrame, "Icons/AutomatedScienceSampler", "AutomatedScienceSampler/AutomatedScienceSampler");//Utilities.GetTexture("icon" + (int)CurrentFrame, "ForScienceContinued/Textures");
                lastFrameCheck = Time.time;
            }

            #endregion
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            if (nextUpdate == 0)
            {//add some delay so it doesnt run as soon as the vehicle launches
                if (!FlightGlobals.ready)
                {
                    return;
                }
                nextUpdate = Planetarium.GetUniversalTime() + 1;
                UpdateShipInformation();
                return;
            }

            if (!FlightGlobals.ready || !Utilities.canVesselBeControlled(FlightGlobals.ActiveVessel))
            {
                return;
            }
            if (Planetarium.GetUniversalTime() < nextUpdate)
            {
                return;
            }
            nextUpdate = Planetarium.GetUniversalTime() + 1;
            Log(sw.Elapsed.TotalMilliseconds);
            foreach (var experiment in experiments)
            {
                IScienceActivator activator;
                if (!activators.TryGetValue(experiment.GetType(), out activator))
                {
                    Log("Activator for ", experiment.GetType(), " not found! Using default!");
                    activator = DefaultActivator.instance;
                }
                var subject = activator.GetScienceSubject(experiment);
                var value   = activator.GetScienceValue(experiment, shipCotainsExperiments, subject);
                if (activator.CanRunExperiment(experiment, value))
                {
                    Log("Deploying ", experiment.part.name, " for :", value, " science! ", subject.id);
                    activator.DeployExperiment(experiment);
                    AddToContainer(subject.id);
                }
                else if (BasicTransferCheck() && activator.CanTransfer(experiment, scienceContainers[craftSettings.currentContainer - 1]))
                {
                    activator.Transfer(experiment, scienceContainers[craftSettings.currentContainer - 1]);
                }
                else if (craftSettings.resetExperiments && activator.CanReset(experiment))
                {
                    activator.Reset(experiment);
                }

                Log("Experiment checked in: ", sw.Elapsed.TotalMilliseconds);
            }
            Log("Total: ", sw.Elapsed.TotalMilliseconds);
        }
Exemplo n.º 53
0
 /// <summary>Read a required chunk, creating a load error if it wasn't present.</summary>
 /// <param name="loader"></param>
 /// <param name="requiredId"></param>
 /// <param name="chunk"></param>
 /// <returns></returns>
 public static bool ReadRequired(AssetLoader loader, ChunkId requiredId, out Chunk chunk)
 {
     chunk = new Chunk(loader);
     return chunk.RequireId(requiredId);
 }
Exemplo n.º 54
0
 public override LoadMatchStrength LoadMatch(AssetLoader loader)
 {
     return(loader.Reader.MatchMagic(Library.Magic) ? LoadMatchStrength.Medium : LoadMatchStrength.None);
 }
Exemplo n.º 55
0
 /// <summary>Match based on the header.</summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 public override LoadMatchStrength LoadMatch(AssetLoader loader)
 {
     if (loader.Length < 32)
         return LoadMatchStrength.None;
     Autodesk3ds.Chunk chunk = new Autodesk3ds.Chunk(loader);
     if (chunk.Id != Autodesk3ds.ChunkId.Main || chunk.End != loader.End)
         return LoadMatchStrength.None;
     return LoadMatchStrength.Medium; // Stronger than a magic match, not as strong as a real header.
 }
Exemplo n.º 56
0
 public override Asset Load(AssetLoader loader)
 {
     return(new Library(Manager, loader));
 }
Exemplo n.º 57
0
 /// <summary>
 /// Load the zip archive.
 /// </summary>
 /// <param name="loader"></param>
 /// <returns></returns>
 public override Asset Load(AssetLoader loader)
 {
     return new ZipArchive(loader);
 }
Exemplo n.º 58
0
        /// <summary>
        /// Parses a Battle(E).ini file. Returns true if succesful (file found), otherwise false.
        /// </summary>
        /// <param name="path">The path of the file, relative to the game directory.</param>
        /// <returns>True if succesful, otherwise false.</returns>
        private bool ParseBattleIni(string path)
        {
            Logger.Log("Attempting to parse " + path + " to populate mission list.");

            string battleIniPath = MainClientConstants.gamepath + path;

            if (!File.Exists(battleIniPath))
            {
                Logger.Log("File " + path + " not found. Ignoring.");
                return(false);
            }

            IniFile battle_ini = new IniFile(battleIniPath);

            List <string> battleKeys = battle_ini.GetSectionKeys("Battles");

            if (battleKeys == null)
            {
                return(false); // File exists but [Battles] doesn't
            }
            foreach (string battleEntry in battleKeys)
            {
                string battleSection = battle_ini.GetStringValue("Battles", battleEntry, "NOT FOUND");

                if (!battle_ini.SectionExists(battleSection))
                {
                    continue;
                }

                var mission = new Mission(battle_ini, battleSection);

                Missions.Add(mission);

                XNAListBoxItem item = new XNAListBoxItem();
                item.Text = mission.GUIName;
                if (!mission.Enabled)
                {
                    item.TextColor = UISettings.DisabledButtonColor;
                }
                else if (string.IsNullOrEmpty(mission.Scenario))
                {
                    item.TextColor = AssetLoader.GetColorFromString(
                        ClientConfiguration.Instance.ListBoxHeaderColor);
                    item.IsHeader   = true;
                    item.Selectable = false;
                }
                else
                {
                    item.TextColor = lbCampaignList.DefaultItemColor;
                }

                if (!string.IsNullOrEmpty(mission.IconPath))
                {
                    item.Texture = AssetLoader.LoadTexture(mission.IconPath + "icon.png");
                }

                lbCampaignList.AddItem(item);
            }

            Logger.Log("Finished parsing " + path + ".");
            return(true);
        }
Exemplo n.º 59
0
        void AssetLoaded(AssetLoader.Loader loader)
        {
            // You get a object that contains all the object that match your laoding request
            for (int i = 0; i < loader.definitions.Length; i++ )
            {
                UnityEngine.Object o = loader.objects[i];
                if (o == null)
                    continue;

                if (o.GetType() == typeof(Canvas))
                    kscCanvas = o as Canvas;
            }
            assetBundleLoaded = true;
        }
Exemplo n.º 60
0
        public override void Initialize()
        {
            BackgroundTexture = AssetLoader.LoadTexture("missionselectorbg.png");
            ClientRectangle   = new Rectangle(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
            BorderColor       = UISettings.WindowBorderColor;

            Name = "CampaignSelector";

            var lblSelectCampaign = new XNALabel(WindowManager);

            lblSelectCampaign.Name            = "lblSelectCampaign";
            lblSelectCampaign.FontIndex       = 1;
            lblSelectCampaign.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblSelectCampaign.Text            = "MISSIONS:";

            lbCampaignList      = new XNAListBox(WindowManager);
            lbCampaignList.Name = "lbCampaignList";
            lbCampaignList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            lbCampaignList.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbCampaignList.ClientRectangle   = new Rectangle(12,
                                                             lblSelectCampaign.ClientRectangle.Bottom + 6, 300, 516);
            lbCampaignList.SelectedIndexChanged += LbCampaignList_SelectedIndexChanged;

            var lblMissionDescriptionHeader = new XNALabel(WindowManager);

            lblMissionDescriptionHeader.Name            = "lblMissionDescriptionHeader";
            lblMissionDescriptionHeader.FontIndex       = 1;
            lblMissionDescriptionHeader.ClientRectangle = new Rectangle(
                lbCampaignList.ClientRectangle.Right + 12,
                lblSelectCampaign.ClientRectangle.Y, 0, 0);
            lblMissionDescriptionHeader.Text = "MISSION DESCRIPTION:";

            tbMissionDescription                 = new XNATextBlock(WindowManager);
            tbMissionDescription.Name            = "tbMissionDescription";
            tbMissionDescription.ClientRectangle = new Rectangle(
                lblMissionDescriptionHeader.ClientRectangle.X,
                lblMissionDescriptionHeader.ClientRectangle.Bottom + 6,
                ClientRectangle.Width - 24 - lbCampaignList.ClientRectangle.Right, 430);
            tbMissionDescription.DrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            tbMissionDescription.Alpha    = 1.0f;

            tbMissionDescription.BackgroundTexture = AssetLoader.CreateTexture(AssetLoader.GetColorFromString(ClientConfiguration.Instance.AltUIBackgroundColor),
                                                                               tbMissionDescription.ClientRectangle.Width, tbMissionDescription.ClientRectangle.Height);

            var lblDifficultyLevel = new XNALabel(WindowManager);

            lblDifficultyLevel.Name      = "lblDifficultyLevel";
            lblDifficultyLevel.Text      = "DIFFICULTY LEVEL";
            lblDifficultyLevel.FontIndex = 1;
            Vector2 textSize = Renderer.GetTextDimensions(lblDifficultyLevel.Text, lblDifficultyLevel.FontIndex);

            lblDifficultyLevel.ClientRectangle = new Rectangle(
                tbMissionDescription.ClientRectangle.Left + (tbMissionDescription.ClientRectangle.Width - (int)textSize.X) / 2,
                tbMissionDescription.ClientRectangle.Bottom + 12, (int)textSize.X, (int)textSize.Y);

            trbDifficultySelector                 = new XNATrackbar(WindowManager);
            trbDifficultySelector.Name            = "trbDifficultySelector";
            trbDifficultySelector.ClientRectangle = new Rectangle(
                tbMissionDescription.ClientRectangle.X, lblDifficultyLevel.ClientRectangle.Bottom + 6,
                tbMissionDescription.ClientRectangle.Width, 30);
            trbDifficultySelector.MinValue          = 0;
            trbDifficultySelector.MaxValue          = 2;
            trbDifficultySelector.BackgroundTexture = AssetLoader.CreateTexture(
                new Color(0, 0, 0, 128), 2, 2);
            trbDifficultySelector.ButtonTexture = AssetLoader.LoadTextureUncached(
                "trackbarButton_difficulty.png");

            var lblEasy = new XNALabel(WindowManager);

            lblEasy.Name            = "lblEasy";
            lblEasy.FontIndex       = 1;
            lblEasy.Text            = "EASY";
            lblEasy.ClientRectangle = new Rectangle(trbDifficultySelector.ClientRectangle.X,
                                                    trbDifficultySelector.ClientRectangle.Bottom + 6, 1, 1);

            var lblNormal = new XNALabel(WindowManager);

            lblNormal.Name            = "lblNormal";
            lblNormal.FontIndex       = 1;
            lblNormal.Text            = "NORMAL";
            textSize                  = Renderer.GetTextDimensions(lblNormal.Text, lblNormal.FontIndex);
            lblNormal.ClientRectangle = new Rectangle(
                tbMissionDescription.ClientRectangle.Left + (tbMissionDescription.ClientRectangle.Width - (int)textSize.X) / 2,
                lblEasy.ClientRectangle.Y, (int)textSize.X, (int)textSize.Y);

            var lblHard = new XNALabel(WindowManager);

            lblHard.Name            = "lblHard";
            lblHard.FontIndex       = 1;
            lblHard.Text            = "HARD";
            lblHard.ClientRectangle = new Rectangle(
                tbMissionDescription.ClientRectangle.Right - lblHard.ClientRectangle.Width,
                lblEasy.ClientRectangle.Y, 1, 1);

            btnLaunch                 = new XNAClientButton(WindowManager);
            btnLaunch.Name            = "btnLaunch";
            btnLaunch.ClientRectangle = new Rectangle(12, ClientRectangle.Height - 35, 133, 23);
            btnLaunch.Text            = "Launch";
            btnLaunch.AllowClick      = false;
            btnLaunch.LeftClick      += BtnLaunch_LeftClick;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(ClientRectangle.Width - 145,
                                                      btnLaunch.ClientRectangle.Y, 133, 23);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            AddChild(lblSelectCampaign);
            AddChild(lblMissionDescriptionHeader);
            AddChild(lbCampaignList);
            AddChild(tbMissionDescription);
            AddChild(lblDifficultyLevel);
            AddChild(btnLaunch);
            AddChild(btnCancel);
            AddChild(trbDifficultySelector);
            AddChild(lblEasy);
            AddChild(lblNormal);
            AddChild(lblHard);

            // Set control attributes from INI file
            base.Initialize();

            // Center on screen
            CenterOnParent();

            trbDifficultySelector.Value = UserINISettings.Instance.Difficulty;

            ParseBattleIni("INI\\Battle.ini");
            ParseBattleIni("INI\\" + ClientConfiguration.Instance.BattleFSFileName);

            cheaterWindow = new CheaterWindow(WindowManager);
            DarkeningPanel dp = new DarkeningPanel(WindowManager);

            dp.AddChild(cheaterWindow);
            AddChild(dp);
            dp.CenterOnParent();
            cheaterWindow.CenterOnParent();
            cheaterWindow.YesClicked += CheaterWindow_YesClicked;
            cheaterWindow.Disable();
        }