Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PhotoSaveModeEditorUIComponent.c
Go to the documentation of this file.
2{
3 protected const string IMAGE_PATH_TEST = "UI/TestImg.png";
4
5 protected static const int RESOLUTION_X = 1920; // save dimension
6 protected static const int RESOLUTION_Y = 1080; // save dimension
7
8 [Attribute("Toolbar_CaptureButton")]
9 protected string m_sCaptureButton;
10
11 [Attribute("")]
12 protected string m_sCaptureAction;
13
14 [Attribute("use_screenshot")]
16
17 [Attribute("EditorMenuConfirm")]
19
20 [Attribute("InputButtonRoot0")]
21 protected string m_sActionButton;
22
25
26 protected static ref ImageWidget s_wDebugImage;
27
28 //------------------------------------------------------------------------------------------------
29 override void HandlerAttached(Widget w)
30 {
31 super.HandlerAttached(w);
32
33 // UI setup
34 Widget captureButton = w.FindAnyWidget(m_sCaptureButton);
36 m_CaptureButtonEvents.GetOnClick().Insert(OnCaptureImage);
37
38 Widget inputButton = captureButton.FindAnyWidget(m_sActionButton);
39 SCR_InputButtonComponent inputButtonCmp = SCR_InputButtonComponent.Cast(inputButton.FindHandler(SCR_InputButtonComponent));
41
42 GetGame().GetInputManager().AddActionListener(m_sConfirmScreenshotAction, EActionTrigger.DOWN, OnCaptureImage);
43
44 // Inputs
45 GetGame().GetInputManager().AddActionListener(m_sCaptureAction, EActionTrigger.DOWN, OnCaptureImage);
46 }
47
48 //------------------------------------------------------------------------------------------------
50 protected void OnCaptureImage()
51 {
53 }
54
55 //------------------------------------------------------------------------------------------------
57 protected void CaptureImage(int resolutionX, int resolutionY)
58 {
60
61 if (editorMenuManager)
62 editorMenuManager.SetVisible(false, true);
63
64 GetGame().GetCallqueue().Call(CallFrameLater, resolutionX, resolutionY); // Hiding UI for screenshot needs to happen next frame for UI to update visibility
65 }
66
67 //------------------------------------------------------------------------------------------------
68 protected void OnMakeScreenshot(int resolutionX, int resolutionY)
69 {
70 int width, height;
71 System.GetNativeResolution(width, height);
72 System.MakeScreenshotRawData(OnScreenshot, 0, 0, width, height, resolutionX, resolutionY);
73 }
74
75 //---------------------------------------------------------------------------------------------
76 protected void OnScreenshot(PixelRawData data, int imageWidth, int imageHeight, int stride)
77 {
78 #ifdef WORKBENCH
79 //Workbench.SavePixelRawData(IMAGE_PATH_TEST, data, imageWidth, imageHeight, stride);
80 #endif
81
82 // Create comfirm dialog
86
88
89 /*
90 string screenshot = IMAGE_PATH_TEST;
91
92 SCR_SaveWorkshopManager manager = SCR_SaveWorkshopManager.GetInstance();
93 SCR_EditedSaveManifest editedManifest = manager.GetEditedSaveManifest();
94 WorldSaveManifest manifest = editedManifest.GetManifest();
95 WorldSaveItem save;
96 manager.GetCurrentSave(save);
97
98 if (editedManifest.GetEditingValue() == "thumbnail")
99 {
100 save.SaveJPEG(data, RESOLUTION_X, RESOLUTION_Y, 50, 4, true);
101 //editedManifest.m_Manifest.m_sPreview = screenshot;
102 }
103 else if (editedManifest.GetEditingValue() == "gallery")
104 {
105 if (!manifest.m_aScreenshots)
106 manifest.m_aScreenshots = {};
107
108 for (int i = manifest.m_aScreenshots.Count() - 1; i >= 0; i--)
109 {
110 if (manifest.m_aScreenshots[i] == string.Empty)
111 manifest.m_aScreenshots.Remove(i);
112 }
113
114 manifest.m_aScreenshots.Insert(screenshot);
115 }
116
117 manager.SetEditedSaveManifest(manifest, editedManifest.GetEditingValue(), "img");
118 */
119
120 if (editorMenuManager)
121 editorMenuManager.SetVisible(true, true);
122 }
123
124 //---------------------------------------------------------------------------------------------
126 {
128 SCR_EditorManagerEntity editorManager = core.GetEditorManager();
129
130 SCR_EditorManagerEntity.GetInstance().SetCurrentMode(EEditorMode.EDIT);
131 }
132
133 //---------------------------------------------------------------------------------------------
135 {
136 //SCR_SaveWorkshopManager manager = SCR_SaveWorkshopManager.GetInstance();
137 //manager.ClearEditedSaveManifest();
138 }
139
140 //---------------------------------------------------------------------------------------------
141 // DEBUG FUNCTIONS FOR TESTING CAPTURING A SCREEN
142 //---------------------------------------------------------------------------------------------
143
144 //------------------------------------------------------------------------------------------------
146 static void CaptureImageDebug(int resolutionX, int resolutionY, notnull ImageWidget outputWidget)
147 {
149
150 if (editorMenuManager)
151 editorMenuManager.SetVisible(false, true);
152
153 s_wDebugImage = outputWidget;
154 s_wDebugImage.SetVisible(false);
155 GetGame().GetCallqueue().Call(CallFrameLaterDebug, resolutionX, resolutionY); // Hiding UI for screenshot needs to happen next frame for UI to update visibility
156 }
157
158 //------------------------------------------------------------------------------------------------
159 protected static void OnMakeScreenshotDebug(int resolutionX, int resolutionY)
160 {
161 int width, height;
162 System.GetNativeResolution(width, height);
163 WorkspaceWidget workspace = GetGame().GetWorkspace();
164 System.MakeScreenshotTexture(OnScreenshotDebug, 0, 0, width, height, workspace.DPIScale(resolutionX), workspace.DPIScale(resolutionY));
165 }
166
167 //---------------------------------------------------------------------------------------------
169 {
170 if (s_wDebugImage)
171 {
172 s_wDebugImage.SetVisible(true);
173 s_wDebugImage.CopyImageTexture(s_wDebugImage.GetImage(), data);
174 }
175
177
178 if (editorMenuManager)
179 editorMenuManager.SetVisible(true, true);
180 }
181
182 //---------------------------------------------------------------------------------------------
183 void CallFrameLater(int resX, int resY)
184 {
185 GetGame().GetCallqueue().Call(OnMakeScreenshot, resX, resY);
186 }
187
188 //---------------------------------------------------------------------------------------------
189 static void CallFrameLaterDebug(int resX, int resY)
190 {
191 GetGame().GetCallqueue().Call(OnMakeScreenshotDebug, resX, resY);
192 }
193}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Get all prefabs that have the spawner data
Core component to manage SCR_EditorManagerEntity.
SCR_EditorManagerEntity GetEditorManager()
bool SetAction(string action, EInputDeviceType currentInputDevice=-1, bool forceUpdate=false)
static void CaptureImageDebug(int resolutionX, int resolutionY, notnull ImageWidget outputWidget)
Capture image of current camere view [DEBUG].
static void OnScreenshotDebug(ScreenshotTextureData data)
void OnMakeScreenshot(int resolutionX, int resolutionY)
static void OnMakeScreenshotDebug(int resolutionX, int resolutionY)
void CaptureImage(int resolutionX, int resolutionY)
Capture image of current camere view.
void OnCaptureImage()
Capture image of current camere view.
void OnScreenshot(PixelRawData data, int imageWidth, int imageHeight, int stride)
static SCR_ConfigurableDialogUi CreateDialog(string presetName)
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6
EActionTrigger