커스텀 커스텀 펑션 만들기. (스크립트 실행하기)
페이지 정보
본문
안녕하세요. 소심비형입니다. 이전 시간에 알아본 커스텀 펑션에서 다른 스크립트를 실행하는 방법에 대해 간단하게 알아보도록 하겠습니다. 이 기능은 NGM의 기본 액션으로 제공하고 있지만~ 별도로 내가 만든 펑션에서 로직에 따라 처리하고 싶을수도 있습니다. 기본 기능만으로도 충분하지만, 몇몇분들은 이런게 있었으면 좋겠다라고 생각할수도 있죠-_-ㅋ
이전 시간에 만든 CustomFunction 프로젝트를 비주얼 스튜디오에서 열어주세요.
아래 절차대로 새로운 클래스를 추가합니다. 클래스의 이름은 PlayScriptModel입니다.
- CustomFunction에서 우클릭
- 추가
- 클래스 클릭
- Visual C# 항목
- 클래스
- PlayScriptModel.cs 입력
- 추가 클릭
새로운 클래스가 추가되었습니다. 여기부터는 아래 동영상을 참고해서 직접 코드를 작성 해보세요.
아래는 예제에서 사용한 전체 코드입니다.
PlayScriptModel.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using NGM.Interface; namespace CustomFunction { public class PlayScriptModel : NGM.Models.Interface.BaseCustomFunctionModel { private string _scriptName; public override string DisplayCategory => "펑션"; public override string DisplayName => "스크립트 실행"; [Category("Data")] [DisplayName("스크립트 경로")] [Description("실행할 스크립트 파일의 전체 경로입니다.")] [Browsable(true)] [DefaultValue(null)] public string FullName { get; set; } [Category("Action")] [DisplayName("스크립트 이름")] [Description("실행할 스크립트를 선택하세요.")] [Browsable(true)] [DefaultValue(null)] [TypeConverter(typeof(NGM.Models.TypeConverter.ScriptConverter))] public string Name { get { return _scriptName; } set { _scriptName = value; var scriptItem = NGM.Models.Data.ItemFactory .GetScripts(MainView.Text) .Where(w => (w as NGM.Models.Item.ScriptItem).Name == _scriptName) .FirstOrDefault(); if (scriptItem != null) FullName = System.IO.Path.Combine( NGM.Models.Interface.SystemHelper.ScriptDirectory(), (scriptItem as NGM.Models.Item.ScriptItem).FullName ); if (TreeView != null) { TreeView.Invoke((Action)delegate { if (TreeView.SelectedNode != null) { string nodeText = TreeView.SelectedNode.Text.Split('[')[0].Split('(')[0].Split(':')[0]; if (!string.IsNullOrEmpty(Name)) nodeText += $"[{Name}]"; if (!string.IsNullOrEmpty(ID)) nodeText += $"({ID})"; if (!string.IsNullOrEmpty(Description)) nodeText += $":{Description}"; TreeView.SelectedNode.Text = nodeText; } }); } } } public override void Execute(IMainView mainView, IPlayer player) { mainView.OpenScripts(new string[] { this.FullName }); var script = NGM.Models.Interface.SystemHelper.GetScriptView(mainView, this.Name); script.Play(); } } } | cs |
개발자에게 후원하기
추천, 구독, 홍보 꼭~ 부탁드립니다.
여러분의 후원이 빠른 귀농을 가능하게 해줍니다~ 답답한 도시를 벗어나 귀농하고 싶은 개발자~
감사합니다~
추천0 비추천0
- 이전글함수 상자 - 표현식 - 시간 사칙연산 (Function tool box, Expression, Time Formula) 20.01.30
- 다음글[워밍업] 커스텀 펑션 - 아웃풋에 로그 남기기. 20.01.30
댓글목록
등록된 댓글이 없습니다.