DayZ 1.24
Loading...
Searching...
No Matches
RenderTarget.c
Go to the documentation of this file.
1#ifdef GAME_TEMPLATE
2
3[EditorAttribute("box", "GameLib/Scripted", "Render target", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255")]
4class RenderTargetClass
5{
6
7}
8
9RenderTargetClass RenderTargetSource;
10
11class RenderTarget: GenericEntity
12{
13 [Attribute("0", "slider", "Camera index", "0 31 1")]
14 int CameraIndex;
15 [Attribute("0", "editbox", "Position X <0, 1>")]
16 float X;
17 [Attribute("0", "editbox", "Position Y <0, 1>")]
18 float Y;
19 [Attribute("1", "editbox", "Render target width <0, 1>")]
20 float Width;
21 [Attribute("1", "editbox", "Render target height <0, 1>")]
22 float Height;
23 [Attribute("-1", "editbox", "Sort index (the lesser the more important)")]
24 int Sort;
25 [Attribute("0", "combobox", "Autoinit", "", { ParamEnum("No", "0"), ParamEnum("Yes", "1") })]
26 int AutoInit;
27 [Attribute("0", "combobox", "Forcing creation of render target for camera #0 in Workbench", "", { ParamEnum("No", "0"), ParamEnum("Yes", "1") })]
28 bool ForceCreation;
29 bool m_Show = true; // when autoinit, wait with showing the render target after all entities are created (EOnInit)
30 ref RenderTargetWidget m_RenderWidget;
31
32 void RenderTarget(IEntitySource src, IEntity parent)
33 {
34 SetFlags(EntityFlags.ACTIVE, false);
35
36 if (AutoInit)
37 {
38 m_Show = false;
39 SetEventMask(EntityEvent.INIT);
40 Init();
41 }
42 }
43
44 void ~RenderTarget()
45 {
46 delete m_RenderWidget;
47 }
48
49 void Init()
50 {
51#ifdef WORKBENCH // Workbench is using its own renderer for main camera, it is not using render target widget.
52 if (!ForceCreation && CameraIndex == 0)
53 return;
54#endif
55
56 int screenW, screenH;
57 GetScreenSize(screenW, screenH);
58
59 int posX = (float)(screenW * X);
60 int posY = (float)(screenH * Y);
61 int widthPix = (float)(screenW * Width);
62 int heightPix = (float)(screenH * Height);
63 if (Class.CastTo(m_RenderWidget, GetGame().GetWorkspace().CreateWidget(RenderTargetWidgetTypeID, posX, posY, widthPix, heightPix, WidgetFlags.VISIBLE | WidgetFlags.HEXACTSIZE | WidgetFlags.VEXACTSIZE | WidgetFlags.HEXACTPOS | WidgetFlags.VEXACTPOS, 0xffffffff, Sort)))
64 {
65 m_RenderWidget.Show(m_Show);
66 SetWidgetWorld(m_RenderWidget, GetGame().GetWorldEntity(), CameraIndex);
67 }
68 }
69 override void EOnInit(IEntity other, int extra)
70 {
71 if (m_RenderWidget)
72 {
73 m_Show = true;
74 m_RenderWidget.Show(m_Show);
75 }
76 }
77}
78
79#endif
override Widget Init()
Definition DayZGame.c:120
override void EOnInit(IEntity other, int extra)
proto native WorkspaceWidget GetWorkspace()
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto native CGame GetGame()
proto native void SetFlags(ShapeFlags flags)
proto void Sort(void param_array[], int num)
Sorts static array of integers(ascendically) / floats(ascendically) / strings(alphabetically)
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
void ParamEnum(string key, string value, string desc="")
Definition EnEntity.c:808
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44
EntityFlags
Entity flags.
Definition EnEntity.c:114
void EditorAttribute(string style, string category, string description, vector sizeMin, vector sizeMax, string color, string color2="0 0 0 0", bool visible=true, bool insertable=true, bool dynamicBox=false)
Definition EnEntity.c:851
@ Y
Definition EnSystem.c:316
@ X
Definition EnSystem.c:315
proto void GetScreenSize(out int x, out int y)
proto native void SetWidgetWorld(RenderTargetWidget w, IEntity wrldEntity, int camera)
WidgetFlags
Definition EnWidgets.c:58
proto native external Widget CreateWidget(WidgetType type, int left, int top, int width, int height, WidgetFlags flags, int color, int sort, Widget parentWidget=NULL)
Create widgets by WidgetType.