Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UIScreenshot Class Reference
Inheritance diagram for UIScreenshot:
EMono

Public Member Functions

void Activate (PartialMap partial, DirectoryInfo dir, Action< PartialMap > onSave=null, bool isUpdate=false)
 
void Deactivate ()
 

Static Public Member Functions

static UIScreenshot Create ()
 
static void SavePreview (string path, string name, Action onSave)
 
- Static Public Member Functions inherited from EMono
static int rnd (int a)
 

Public Attributes

Image imageFrame
 
InputField inputName
 
UIButton buttonSave
 
UIButton buttonCancel
 
bool isDeactivating
 

Static Public Attributes

static UIScreenshot Instance
 
- Static Public Attributes inherited from EMono
static Core core
 

Private Member Functions

void Awake ()
 
void Update ()
 

Additional Inherited Members

- Properties inherited from EMono
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SoundManager Sound [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static CoreDebug debug [get]
 

Detailed Description

Definition at line 6 of file UIScreenshot.cs.

Member Function Documentation

◆ Activate()

void UIScreenshot.Activate ( PartialMap  partial,
DirectoryInfo  dir,
Action< PartialMap onSave = null,
bool  isUpdate = false 
)
inline

Definition at line 31 of file UIScreenshot.cs.

32 {
33 inputName.text = (MapPiece.IsEditor ? GetUniqueName("") : EMono._zone.Name);
34 if (isUpdate)
35 {
36 inputName.text = (MapPiece.IsEditor ? partial.ID : partial.name);
37 }
38 buttonSave.SetOnClick(delegate
39 {
40 isDeactivating = true;
41 SE.Play("camera");
42 GetComponent<CanvasGroup>().alpha = 0f;
43 string text = dir.FullName + "/" + (MapPiece.IsEditor ? inputName.text.IsEmpty("new") : GetUniqueName("user")) + ".mp";
44 if (isUpdate)
45 {
47 {
48 PartialMap.Delete(partial.path);
49 }
50 else
51 {
52 text = partial.path;
53 }
54 }
55 partial.name = inputName.text.IsEmpty(EMono._zone.Name);
56 partial.path = text;
57 File.Copy(PartialMap.PathTemp, text, overwrite: true);
58 SavePreview(text, partial.name, delegate
59 {
60 if ((bool)PartialMapMenu.Instance)
61 {
62 PartialMapMenu.Instance.Refresh();
63 }
64 Deactivate();
65 if (onSave != null)
66 {
67 onSave(partial);
68 }
69 });
70 });
71 string GetUniqueName(string id)
72 {
73 for (int i = 1; i < 999999; i++)
74 {
75 if (!File.Exists(dir.FullName + "/" + id + i + ".mp"))
76 {
77 return id + i;
78 }
79 }
80 return id;
81 }
82 }
Definition: EMono.cs:4
static Zone _zone
Definition: EMono.cs:19
static bool IsEditor
Definition: MapPiece.cs:47
static void Delete(string path)
Definition: PartialMap.cs:507
string path
Definition: PartialMap.cs:68
static string PathTemp
Definition: PartialMap.cs:86
string name
Definition: PartialMap.cs:28
virtual string Name
Definition: Spatial.cs:495
UIButton buttonSave
Definition: UIScreenshot.cs:14
InputField inputName
Definition: UIScreenshot.cs:12
void Deactivate()
static void SavePreview(string path, string name, Action onSave)
Definition: UIScreenshot.cs:96
bool isDeactivating
Definition: UIScreenshot.cs:18

References EMono._zone, buttonSave, Deactivate(), PartialMap.Delete(), inputName, isDeactivating, MapPiece.IsEditor, PartialMap.name, Spatial.Name, PartialMap.path, PartialMap.PathTemp, and SavePreview().

Referenced by AM_Copy.OnAfterProcessTiles(), and AM_Copy.RefreshMenu().

◆ Awake()

void UIScreenshot.Awake ( )
inlineprivate

Definition at line 25 of file UIScreenshot.cs.

26 {
27 Instance = this;
28 EMono.ui.Hide(0f);
29 }
static UI ui
Definition: EMono.cs:15
static UIScreenshot Instance
Definition: UIScreenshot.cs:8

References Instance, and EMono.ui.

◆ Create()

static UIScreenshot UIScreenshot.Create ( )
inlinestatic

Definition at line 20 of file UIScreenshot.cs.

21 {
22 return Util.Instantiate<UIScreenshot>("UI/Util/UIScreenshot", EMono.ui);
23 }
Definition: Util.cs:10
static Transform Instantiate(string path, Component parent=null)
Definition: Util.cs:67

References EMono.ui, and Util.

Referenced by AM_Copy.OnAfterProcessTiles(), and AM_Copy.RefreshMenu().

◆ Deactivate()

void UIScreenshot.Deactivate ( )
inline

Definition at line 132 of file UIScreenshot.cs.

133 {
134 UnityEngine.Object.Destroy(base.gameObject);
135 EMono.ui.Show(0f);
136 EInput.Consume();
137 }
Definition: EInput.cs:8
static void Consume(int _skipFrame)
Definition: EInput.cs:656

References EInput.Consume(), and EMono.ui.

Referenced by Activate().

◆ SavePreview()

static void UIScreenshot.SavePreview ( string  path,
string  name,
Action  onSave 
)
inlinestatic

Definition at line 96 of file UIScreenshot.cs.

97 {
98 EMono.core.actionsNextFrame.Add(delegate
99 {
100 EMono.core.actionsNextFrame.Add(delegate
101 {
102 Texture2D texture2D = ScreenCapture.CaptureScreenshotAsTexture();
103 texture2D.filterMode = FilterMode.Point;
104 int num = 300;
105 int num2 = 200;
106 float num3 = (float)num / (float)Screen.width;
107 float num4 = (float)num2 / (float)Screen.height;
108 Vector2 scale = new Vector2(num3, num4);
109 Vector2 offset = new Vector2((1f - num3) * 0.5f, (1f - num4) * 0.5f);
110 RenderTexture renderTexture = new RenderTexture(num, num2, 0);
111 renderTexture.filterMode = FilterMode.Point;
112 renderTexture.Create();
113 RenderTexture active = RenderTexture.active;
114 RenderTexture.active = renderTexture;
115 Graphics.Blit(texture2D, renderTexture, scale, offset);
116 Texture2D texture2D2 = new Texture2D(num, num2, texture2D.format, mipChain: false);
117 texture2D2.filterMode = FilterMode.Point;
118 texture2D2.ReadPixels(new Rect(0f, 0f, num, num2), 0, 0);
119 texture2D2.Apply();
120 RenderTexture.active = active;
121 renderTexture.Release();
122 File.WriteAllBytes(path.GetFullFileNameWithoutExtension() + ".jpg", texture2D2.EncodeToJPG());
123 File.WriteAllText(path.GetFullFileNameWithoutExtension() + ".txt", name);
124 UnityEngine.Object.Destroy(texture2D2);
125 UnityEngine.Object.Destroy(texture2D);
126 UnityEngine.Object.Destroy(renderTexture);
127 onSave?.Invoke();
128 });
129 });
130 }
List< Action > actionsNextFrame
Definition: BaseCore.cs:31
static Core core
Definition: EMono.cs:5

References BaseCore.actionsNextFrame, and EMono.core.

Referenced by Activate().

◆ Update()

void UIScreenshot.Update ( )
inlineprivate

Definition at line 84 of file UIScreenshot.cs.

85 {
87 {
89 }
90 else if (EInput.rightMouse.clicked || Input.GetKeyDown(KeyCode.Escape))
91 {
92 Deactivate();
93 }
94 }
bool clicked
Definition: ButtonState.cs:37
static ButtonState rightMouse
Definition: EInput.cs:351

References ButtonState.clicked, EInput.Consume(), and EInput.rightMouse.

Member Data Documentation

◆ buttonCancel

UIButton UIScreenshot.buttonCancel

Definition at line 16 of file UIScreenshot.cs.

◆ buttonSave

UIButton UIScreenshot.buttonSave

Definition at line 14 of file UIScreenshot.cs.

Referenced by Activate().

◆ imageFrame

Image UIScreenshot.imageFrame

Definition at line 10 of file UIScreenshot.cs.

◆ inputName

InputField UIScreenshot.inputName

Definition at line 12 of file UIScreenshot.cs.

Referenced by Activate().

◆ Instance

UIScreenshot UIScreenshot.Instance
static

Definition at line 8 of file UIScreenshot.cs.

Referenced by Awake(), AM_Copy.OnCancel(), and AM_Copy.OnRenderTile().

◆ isDeactivating

bool UIScreenshot.isDeactivating

Definition at line 18 of file UIScreenshot.cs.

Referenced by Activate().


The documentation for this class was generated from the following file: