コード例 #1
0
    void InstansiateBackground()
    {
        GUI.FocusControl(null);
        if (backgroundLibrary.ContainsID(uuid))
        {
            Debug.Log("uuid already exists!");
            return;
        }
        BackgroundEntry bke = Editor.CreateInstance <BackgroundEntry>();

        bke.name      = uuid;
        bke.uuid      = uuid;
        bke.entryName = uuid;
        bke.repColor  = repColor;
        string path = "Assets/LibraryData/Backgrounds/" + uuid + ".asset";

        AssetDatabase.CreateAsset(bke, path);
        backgroundLibrary.InsertEntry(bke, 0);
        Undo.RecordObject(backgroundLibrary, "Added background");
        EditorUtility.SetDirty(backgroundLibrary);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        currentEntryList = backgroundLibrary.GetRepresentations("", filterStr);
        uuid             = "";
        selBackground    = 0;
        SelectBackground();
    }
コード例 #2
0
    public override void CopyValues(ScrObjLibraryEntry other)
    {
        base.CopyValues(other);
        BackgroundEntry ce = (BackgroundEntry)other;

        sprite = ce.sprite;
    }
コード例 #3
0
        private void DrawPreview(string path, BackgroundEntry entry, SerializedProperty entryProperty)
        {
            var sprite = Resources.Load <Sprite>(path);

            if (sprite == null)
            {
                EditorGUILayout.HelpBox("Invalid background resource path!", MessageType.Error);
                return;
            }

            if (GUILayout.Button("Correct Snapshot Scale Y for Aspect Ratio"))
            {
                CorrectSnapshotScaleY(entry, sprite.texture, entryProperty);
            }

            if (GUILayout.Button("Correct Snapshot Scale X for Aspect Ratio"))
            {
                CorrectSnapshotScaleX(entry, sprite.texture, entryProperty);
            }

            if (GUILayout.Button("Reset Snapshot Scale Offset"))
            {
                ResetSnapshotScaleOffset(entryProperty);
            }

            var height = EditorGUIUtility.currentViewWidth / sprite.texture.width * sprite.texture.height;
            var rect   = EditorGUILayout.GetControlRect(false, height);

            EditorGUI.DrawPreviewTexture(rect, sprite.texture);
            if (previewDrawSnapshotFrame)
            {
                DrawPreviewSnapshotFrame(entry, rect);
            }
        }
コード例 #4
0
        private static void CorrectSnapshotScaleX(BackgroundEntry entry, Texture tex, SerializedProperty entryProperty)
        {
            var size = entry.snapshotScale * new Vector2(tex.width, tex.height);
            var fix  = Mathf.Abs((1.0f / SnapshotAspectRatio) / (size.x / size.y));

            entryProperty.FindPropertyRelative("snapshotScale.x").floatValue *= fix;
        }
コード例 #5
0
    void SaveSelectedBackground()
    {
        BackgroundEntry bke = (BackgroundEntry)backgroundLibrary.GetEntryByIndex(selBackground);

        bke.CopyValues(backgroundValues);
        Undo.RecordObject(bke, "Updated background");
        EditorUtility.SetDirty(bke);
    }
コード例 #6
0
ファイル: BackgroundList.cs プロジェクト: poudink/NSMB-Editor
        private void getFiles()
        {
            bg = (BackgroundEntry)tilesetListBox.SelectedItem;

            GFXFile    = ROM.FS.getFileById(bg.GFXFileID);
            PalFile    = ROM.FS.getFileById(bg.PalFileID);
            LayoutFile = ROM.FS.getFileById(bg.LayoutFileID);
        }
コード例 #7
0
ファイル: BackgroundList.cs プロジェクト: poudink/NSMB-Editor
        private void Setproperties_btn_Click(object sender, EventArgs e)
        {
            bg = (BackgroundEntry)tilesetListBox.SelectedItem;

            bool IsLevelBG = true;

            if (bg.id > 75 || bg.mappedTileset)
            {
                IsLevelBG = false;
            }
            SetBGPropertiesDialog newBg = new SetBGPropertiesDialog(bg.id, bg.name.Split(':')[1].Remove(0, 1), bg.GFXFileID, bg.PalFileID, bg.LayoutFileID, bg.BitmapOffset, bg.PaletteOffsets, IsLevelBG);

            if (newBg.Canceled)
            {
                return;
            }

            string listName = bg.topLayer ? "Foregrounds" : "Backgrounds";

            if (bg.mappedTileset)
            {
                listName = "MappedTileset";
            }

            if (string.IsNullOrWhiteSpace(newBg.bgName))
            {
                ROM.UserInfo.removeListItem(listName, bg.id, true);
                string newName = LanguageManager.GetList(listName)[bg.id];
                bool   empty   = false;
                if (string.IsNullOrWhiteSpace(newName.Split(':')[1]))
                {
                    newName += " " + LanguageManager.Get("BackgroundList", "empty");
                    empty    = true;
                }

                tilesetListBox.Items[tilesetListBox.SelectedIndex] = new BackgroundEntry(bg.topLayer, bg.id, newName, bg.mappedTileset, empty);
                return;
            }

            string NewFullName = string.Format("{0}: {1}", bg.id, newBg.bgName);

            if (!IsLevelBG)
            {
                NewFullName = string.Format("{0}: {1}@{2}@{3}@{4}@{5}@{6}@not_level_bg", bg.id, newBg.bgName, newBg.bgNCGID, newBg.bgNCLID, newBg.bgNSCID, newBg.bgBMPOffs, newBg.bgPALOffs);
            }
            else
            {
                ROM.SetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NCG : ROM.Data.Table_BG_NCG, (ushort)newBg.bgNCGID);
                ROM.SetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NCL : ROM.Data.Table_BG_NCL, (ushort)newBg.bgNCLID);
                ROM.SetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NSC : ROM.Data.Table_BG_NSC, (ushort)newBg.bgNSCID);
            }

            ROM.UserInfo.setListItem(listName, bg.id, NewFullName, true);
            tilesetListBox.Items[tilesetListBox.SelectedIndex] = new BackgroundEntry(bg.topLayer, bg.id, NewFullName, false);
        }
コード例 #8
0
 private void SetBackground(BackgroundEntry bg, ImageSource img)
 {
     if (bg.Image == null)
     {
         bg.Image = new Image()
         {
             Stretch = Stretch.Fill,
         };
         Children.Add(bg.Image);
     }
     bg.Image.Source = img;
 }
コード例 #9
0
ファイル: BackgroundList.cs プロジェクト: MCGlux/NSMB-Editor
        private void getFiles()
        {
            bg = (BackgroundEntry)tilesetListBox.SelectedItem;

            GFXFileID    = ROM.GetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NCG : ROM.Data.Table_BG_NCG);
            PalFileID    = ROM.GetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NCL : ROM.Data.Table_BG_NCL);
            LayoutFileID = ROM.GetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NSC : ROM.Data.Table_BG_NSC);

            GFXFile    = ROM.FS.getFileById(GFXFileID);
            PalFile    = ROM.FS.getFileById(PalFileID);
            LayoutFile = ROM.FS.getFileById(LayoutFileID);
        }
コード例 #10
0
 void SelectBackground()
 {
     if (selBackground == -1)
     {
         // Nothing selected
         backgroundValues.ResetValues();
     }
     else
     {
         // Something selected
         BackgroundEntry bke = (BackgroundEntry)backgroundLibrary.GetEntryByIndex(selBackground);
         backgroundValues.CopyValues(bke);
     }
 }
コード例 #11
0
 public void CopyValues(Frame other)
 {
     background = other.background;
     characters = new CharacterEntry[Constants.DIALOGUE_PLAYERS_COUNT];
     poses      = new int[Constants.DIALOGUE_PLAYERS_COUNT];
     for (int i = 0; i < Constants.DIALOGUE_PLAYERS_COUNT; i++)
     {
         characters[i] = other.characters[i];
         poses[i]      = other.poses[i];
     }
     talkingIndex = other.talkingIndex;
     talkingName  = other.talkingName;
     dialogueText = other.dialogueText;
     bkgMusic     = other.bkgMusic;
 }
コード例 #12
0
ファイル: BackgroundList.cs プロジェクト: MCGlux/NSMB-Editor
        private void RenameBtn_Click(object sender, EventArgs e)
        {
            string          newName;
            BackgroundEntry bg       = tilesetListBox.SelectedItem as BackgroundEntry;
            string          listName = bg.topLayer ? "Foregrounds" : "Backgrounds";

            if (textForm.ShowDialog(LanguageManager.Get("BackgroundList", "renamePrompt"), bg.name, out newName) == DialogResult.OK)
            {
                if (newName == string.Empty)
                {
                    ROM.UserInfo.removeListItem(listName, bg.id, true);
                    tilesetListBox.Items[tilesetListBox.SelectedIndex] = new BackgroundEntry(bg.topLayer, bg.id, LanguageManager.GetList(listName)[bg.id]);
                    return;
                }
                ROM.UserInfo.setListItem(listName, bg.id, newName, true);
                tilesetListBox.Items[tilesetListBox.SelectedIndex] = new BackgroundEntry(bg.topLayer, bg.id, newName);
            }
        }
コード例 #13
0
ファイル: Frame.cs プロジェクト: parrexion/TheHalarianRuin
 public void CopyValues(Frame other)
 {
     background = other.background;
     characters = new CharacterEntry[Constants.DIALOGUE_PLAYERS_COUNT];
     poses      = new int[Constants.DIALOGUE_PLAYERS_COUNT];
     for (int i = 0; i < Constants.DIALOGUE_PLAYERS_COUNT; i++)
     {
         characters[i] = other.characters[i];
         poses[i]      = other.poses[i];
     }
     talkingIndex = other.talkingIndex;
     talkingName  = other.talkingName;
     dialogueText = other.dialogueText;
     bkgMusic     = other.bkgMusic;
     movements    = new List <DialogueMoveTuple>();
     for (int i = 0; i < other.movements.Count; i++)
     {
         movements.Add(other.movements[i]);
     }
 }
コード例 #14
0
    void DeleteBackground()
    {
        GUI.FocusControl(null);
        BackgroundEntry bke  = (BackgroundEntry)backgroundLibrary.GetEntryByIndex(selBackground);
        string          path = "Assets/LibraryData/Backgrounds/" + bke.uuid + ".asset";

        backgroundLibrary.RemoveEntryByIndex(selBackground);
        Undo.RecordObject(backgroundLibrary, "Deleted background");
        EditorUtility.SetDirty(backgroundLibrary);
        bool res = AssetDatabase.MoveAssetToTrash(path);

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        if (res)
        {
            Debug.Log("Removed background: " + bke.uuid);
            selBackground = -1;
        }
    }
コード例 #15
0
        private static void GenerateSnapshot(BackgroundEntry entry)
        {
            if (entry == null)
            {
                return;
            }
            var sprite = Resources.Load <Sprite>(entry.resourcePath);

            if (sprite == null)
            {
                return;
            }
            var tex = sprite.texture;

            Graphics.Blit(tex, SnapshotRenderTexture, entry.snapshotScale, entry.snapshotOffset);
            var data = GetSnapshotPNGData();

            var assetFullPath    = GetAssetFullPath(sprite);
            var snapshotFullPath =
                Path.Combine(GetResourcesFolder(assetFullPath), entry.snapshotResourcePath + ".png");

            File.WriteAllBytes(snapshotFullPath, data);
        }
コード例 #16
0
	void RefreshDictionaries(BackgroundEntry entry, Vector3[] vertices){
		
		entry.vDictionary.Clear();
		
		for(int i = 0; i < vertices.Length; i++){
						
			entry.vDictionary.Add(vertices[i],i);
		}
	
				
	}
コード例 #17
0
 private void DrawPreviewSnapshotFrame(BackgroundEntry entry, Rect rect)
 {
     EditorUtils.DrawPreviewCropFrame(rect, new Rect(entry.snapshotOffset, entry.snapshotScale),
                                      previewSnapshotFrameColor, previewSnapshotFrameLineWidth);
 }
コード例 #18
0
ファイル: BackgroundList.cs プロジェクト: MCGlux/NSMB-Editor
        private void getFiles()
        {
            bg = (BackgroundEntry)tilesetListBox.SelectedItem;

            GFXFileID = ROM.GetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NCG : ROM.Data.Table_BG_NCG);
            PalFileID = ROM.GetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NCL : ROM.Data.Table_BG_NCL);
            LayoutFileID = ROM.GetFileIDFromTable(bg.id, bg.topLayer ? ROM.Data.Table_FG_NSC : ROM.Data.Table_BG_NSC);

            GFXFile = ROM.FS.getFileById(GFXFileID);
            PalFile = ROM.FS.getFileById(PalFileID);
            LayoutFile = ROM.FS.getFileById(LayoutFileID);
        }
コード例 #19
0
    protected override void DrawContentWindow()
    {
        BackgroundEntry backgroundValues = (BackgroundEntry)entryValues;

        backgroundValues.sprite = (Sprite)EditorGUILayout.ObjectField("Image", backgroundValues.sprite, typeof(Sprite), false);
    }
コード例 #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="entries"></param>
 /// <param name="container"></param>
 public BackgroundEditorWindow(ScrObjLibraryVariable entries, BackgroundEntry container)
 {
     entryLibrary = entries;
     entryValues  = container;
     LoadLibrary();
 }
コード例 #21
0
	public void RemoveFromBackgroundByPosition(Vector3 wCoords, BackgroundEntry entry){
		RemoveFromBackgroundByPosition(wCoords,entry,true);
	}
コード例 #22
0
	public void RemoveFromBackgroundByPosition(Vector3 wCoords, BackgroundEntry entry, bool refresh){
		
		if(entry == null){
			return;
		}
		
		entry.RemoveEntryFor(wCoords);
		
		if(refresh){
			
			RecalculateBackground();
			
		}
				
		
	}
コード例 #23
0
	public void RemoveBackground(BackgroundEntry entry, bool destroyImmediate){
		
		if(entry != null){
			
			if(destroyImmediate){
				GameObject.DestroyImmediate(entry.backgroundObject);	
			}
			else{
				GameObject.Destroy(entry.backgroundObject);
			}
			
			for(int i= 0; i < backgrounds.Count; i++){
				
				if(backgrounds[i] == entry){
					backgrounds.RemoveAt(i);
					return;
				}
				
			}
			
		}
		
	}
コード例 #24
0
	public void AddBackground(Material material){
		
		BackgroundEntry entry = GetBackgroundEntryForName(material.name);
		
		if(entry != null){
			Debug.LogWarning("Background already exists!");
			return;
		}
						
		GameObject meshObject = null;
		
		entry = new BackgroundEntry();
		entry.backgroundMaterial = material;
				
		meshObject = new GameObject(material.name);
		meshObject.transform.parent = transform;
		meshObject.transform.localPosition = Vector3.zero;
		meshObject.transform.localRotation = Quaternion.identity;
		
		MeshFilter mf = meshObject.AddComponent<MeshFilter>();
		
		Mesh m = new Mesh();
		
		mf.mesh = m;
		
		Renderer r = meshObject.AddComponent<MeshRenderer>();
		
		r.material = material;
				
		RecalculateBackground();
		
		entry.backgroundObject = meshObject;
		entry.backgroundRenderer = r;
		entry.backgroundMeshFilter = mf;
		
		backgrounds.Add(entry);
		
	}
コード例 #25
0
	void AddToDictionaries(List<Vector3> vertices, List<int> indices, BackgroundEntry entry){
		
		for(int i = 0; i < vertices.Count; i++){
			entry.vDictionary.Add(vertices[i],indices[i]);
			worldCoordMappings.Add(vertices[i],entry);
		}
				
	}